From 3a9c3fa26a528daeffe799adecba406fc098a2c8 Mon Sep 17 00:00:00 2001 From: Sean Dobbs Date: Mon, 13 Nov 2023 18:02:47 -0500 Subject: [PATCH 1/2] Properly set TAGH energy based on current geometry --- src/libraries/HDDM/DEventSourceREST.cc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/libraries/HDDM/DEventSourceREST.cc b/src/libraries/HDDM/DEventSourceREST.cc index 50229468f..e97af87e9 100644 --- a/src/libraries/HDDM/DEventSourceREST.cc +++ b/src/libraries/HDDM/DEventSourceREST.cc @@ -654,12 +654,12 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, continue; } - double Elo = tagmGeom->getElow(column); - double Ehi = tagmGeom->getEhigh(column); - double Ebeam = (Elo + Ehi)/2.; + double Elo_tagm = tagmGeom->getElow(column); + double Ehi_tagm = tagmGeom->getEhigh(column); + double Ebeam_tagm = (Elo_tagm + Ehi_tagm)/2.; // read the rest of the data from the REST file - DVector3 mom(0.0, 0.0, Ebeam); + DVector3 mom(0.0, 0.0, Ebeam_tagm); gamma->setPID(Gamma); gamma->setMomentum(mom); gamma->setPosition(pos); @@ -691,7 +691,7 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, // it's easy if the column is already set counter = locTaghChannelList().getCounter(); } else { - // if the TAGM column isn't saved in the REST file, then we do one of two things + // if the TAGH column isn't saved in the REST file, then we do one of two things // 1) if there's no special CCDB context associated with the file, we can just // reverse engineer the counter, assuming the latest CCDB // 2) If there is a special CCDB context specified, then use that instead @@ -715,7 +715,11 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, continue; } - DVector3 mom(0.0, 0.0, locTAGHiter->getE()); + double Elo_tagh = taghGeom->getElow(counter); + double Ehi_tagh = taghGeom->getEhigh(counter); + double Ebeam_tagh = (Elo_tagh + Ehi_tagh)/2.; + + DVector3 mom(0.0, 0.0, Ebeam_tagh); gamma->setPID(Gamma); gamma->setMomentum(mom); gamma->setPosition(pos); From 2298aacc9a5c64235a5b3bcaf2aa5ec71ab9854c Mon Sep 17 00:00:00 2001 From: Sean Dobbs Date: Thu, 30 Nov 2023 10:22:44 -0500 Subject: [PATCH 2/2] moved new() statements around to avoid potential memory leaks --- src/libraries/HDDM/DEventSourceREST.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libraries/HDDM/DEventSourceREST.cc b/src/libraries/HDDM/DEventSourceREST.cc index e97af87e9..7151c2ccb 100644 --- a/src/libraries/HDDM/DEventSourceREST.cc +++ b/src/libraries/HDDM/DEventSourceREST.cc @@ -620,8 +620,6 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, { if (locTAGMiter->getJtag() != tag) continue; - - DBeamPhoton* gamma = new DBeamPhoton(); // load the counter number (if it exists) and set the energy based on the counter unsigned int column = 0; @@ -654,6 +652,8 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, continue; } + DBeamPhoton* gamma = new DBeamPhoton(); + double Elo_tagm = tagmGeom->getElow(column); double Ehi_tagm = tagmGeom->getEhigh(column); double Ebeam_tagm = (Elo_tagm + Ehi_tagm)/2.; @@ -682,8 +682,6 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, if (locTAGHiter->getJtag() != tag) continue; - DBeamPhoton* gamma = new DBeamPhoton(); - // load the counter number (if it exists) and set the energy based on the counter unsigned int counter = 0; hddm_r::TaghChannelList &locTaghChannelList = locTAGHiter->getTaghChannels(); @@ -715,6 +713,8 @@ jerror_t DEventSourceREST::Extract_DBeamPhoton(hddm_r::HDDM *record, continue; } + DBeamPhoton* gamma = new DBeamPhoton(); + double Elo_tagh = taghGeom->getElow(counter); double Ehi_tagh = taghGeom->getEhigh(counter); double Ebeam_tagh = (Elo_tagh + Ehi_tagh)/2.;