From cea7181bbc988b78b323d469d1053ce8d572aa43 Mon Sep 17 00:00:00 2001 From: staylorjlab Date: Tue, 19 Nov 2024 17:40:18 -0500 Subject: [PATCH 1/4] add fdc positions at the upstream end of each package to tree --- src/libraries/ANALYSIS/DEventWriterROOT.cc | 39 +++++++++++++++++++++- src/libraries/ANALYSIS/DEventWriterROOT.h | 8 +++++ 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/src/libraries/ANALYSIS/DEventWriterROOT.cc b/src/libraries/ANALYSIS/DEventWriterROOT.cc index c1118a06aa..01dc287c50 100644 --- a/src/libraries/ANALYSIS/DEventWriterROOT.cc +++ b/src/libraries/ANALYSIS/DEventWriterROOT.cc @@ -5,6 +5,7 @@ static bool BCAL_VERBOSE_OUTPUT = false; static bool FCAL_VERBOSE_OUTPUT = false; static bool CCAL_VERBOSE_OUTPUT = false; static bool DIRC_OUTPUT = true; +static bool FDC_VERBOSE_OUTPUT = true; static bool STORE_PULL_INFO = false; static bool STORE_ERROR_MATRIX_INFO = false; @@ -55,6 +56,14 @@ void DEventWriterROOT::Initialize(JEventLoop* locEventLoop) dTargetCenterZ = 65.0; locGeometry->GetTargetZ(dTargetCenterZ); + // Get upstream positions of each FDC package + vectorfdc_z_wires; + locGeometry->GetFDCZ(fdc_z_wires); + dFdcPackages[0]=fdc_z_wires[0]-1.; // just upstream + dFdcPackages[1]=fdc_z_wires[6]-1.; + dFdcPackages[2]=fdc_z_wires[12]-1.; + dFdcPackages[3]=fdc_z_wires[18]-1.; + //CREATE TTREES for(auto& locVertexInfo : locVertexInfos) { @@ -271,6 +280,8 @@ TMap* DEventWriterROOT::Create_UserInfoMaps(DTreeBranchRegister& locBranchRegist locMiscInfoMap->Add(new TObjString("REST:JANACALIBCONTEXT"), new TObjString(REST_JANA_CALIB_CONTEXT.c_str())); // Note: adding these parameters (e.g. in hd_root) will create warnings with "<-- NO DEFAULT! (TYPO?)". Safe to ignore these. + if(gPARMS->Exists("ANALYSIS:FDC_VERBOSE_ROOT_OUTPUT")) + {gPARMS->GetParameter("ANALYSIS:FDC_VERBOSE_ROOT_OUTPUT", FDC_VERBOSE_OUTPUT); cout << "ANALYSIS:FDC_VERBOSE_ROOT_OUTPUT set to " << FDC_VERBOSE_OUTPUT << ", IGNORE the \"<-- NO DEFAULT! (TYPO?)\" message " << endl;} if(gPARMS->Exists("ANALYSIS:BCAL_VERBOSE_ROOT_OUTPUT")) {gPARMS->GetParameter("ANALYSIS:BCAL_VERBOSE_ROOT_OUTPUT", BCAL_VERBOSE_OUTPUT); cout << "ANALYSIS:BCAL_VERBOSE_ROOT_OUTPUT set to " << BCAL_VERBOSE_OUTPUT << ", IGNORE the \"<-- NO DEFAULT! (TYPO?)\" message " << endl;} if(gPARMS->Exists("ANALYSIS:FCAL_VERBOSE_ROOT_OUTPUT")) @@ -697,6 +708,13 @@ void DEventWriterROOT::Create_Branches_ChargedHypotheses(DTreeBranchRegister& lo locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, "dEdx_CDC"), locArraySizeString, dInitNumTrackArraySize); locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, "dEdx_CDC_integral"), locArraySizeString, dInitNumTrackArraySize); locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, "dEdx_FDC"), locArraySizeString, dInitNumTrackArraySize); + if (FDC_VERBOSE_OUTPUT){ + for (unsigned int j=0;j<4;j++){ + locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, dFDCxLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); + locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, dFDCyLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); + locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName,dFDCzLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); + } + } //TIMING INFO locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, "HitTime"), locArraySizeString, dInitNumTrackArraySize); @@ -1822,7 +1840,26 @@ void DEventWriterROOT::Fill_ChargedHypo(DTreeFillData* locTreeFillData, unsigned locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, "dEdx_CDC"), locChargedTrackHypothesis->Get_dEdx_CDC_amp(), locArrayIndex); locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, "dEdx_CDC_integral"), locChargedTrackHypothesis->Get_dEdx_CDC_int(), locArrayIndex); locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, "dEdx_FDC"), locTrackTimeBased->ddEdx_FDC, locArrayIndex); - + + if (FDC_VERBOSE_OUTPUT){ + if (locTrackTimeBased->extrapolations.find(SYS_FDC) != locTrackTimeBased->extrapolations.end()) { + vectorlocExtraps=locTrackTimeBased->extrapolations.at(SYS_FDC); + unsigned int locPackageIndex=0; + for (unsigned int j=0;jdFdcPackages[locPackageIndex]){ + locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCxLeaves[locPackageIndex].c_str()), locPos.x(), locArrayIndex); + locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCyLeaves[locPackageIndex].c_str()), locPos.y(), locArrayIndex); + locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCzLeaves[locPackageIndex].c_str()), locPos.z(), locArrayIndex); + + locPackageIndex++; + if (locPackageIndex>3) break; + } + + } + } + } + //HIT ENERGY double locTOFdEdx = (locChargedTrackHypothesis->Get_TOFHitMatchParams() != NULL) ? locChargedTrackHypothesis->Get_TOFHitMatchParams()->dEdx : 0.0; locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, "dEdx_TOF"), locTOFdEdx, locArrayIndex); diff --git a/src/libraries/ANALYSIS/DEventWriterROOT.h b/src/libraries/ANALYSIS/DEventWriterROOT.h index 154a619df5..89b66525ab 100644 --- a/src/libraries/ANALYSIS/DEventWriterROOT.h +++ b/src/libraries/ANALYSIS/DEventWriterROOT.h @@ -90,6 +90,14 @@ class DEventWriterROOT : public JObject unsigned int dInitNumComboArraySize; double dTargetCenterZ; + double dFdcPackages[4]; + vectordFDCxLeaves={"FDC_pos1_X","FDC_pos2_X","FDC_pos3_X", + "FDC_pos4_X"}; + vectordFDCyLeaves={"FDC_pos1_Y","FDC_pos2_Y","FDC_pos3_Y", + "FDC_pos4_Y"}; + vectordFDCzLeaves={"FDC_pos1_Z","FDC_pos2_Z","FDC_pos3_Z", + "FDC_pos4_Z"}; + //DEFAULT ACTIONS LISTED SEPARATELY FROM CUSTOM (in case in derived class user does something bizarre) map dCutActionMap_ThrownTopology; From 15fac98b8ca51e318a6c514454687ce0e74fa22c Mon Sep 17 00:00:00 2001 From: staylorjlab Date: Tue, 19 Nov 2024 17:42:38 -0500 Subject: [PATCH 2/4] Add positions of each track at the beginning of each package to the rest output, subject to the REST:WRITE_FDC_TRACK_POS command line variable. --- src/libraries/HDDM/DEventSourceREST.cc | 16 ++++++++++++++++ src/libraries/HDDM/DEventWriterREST.cc | 21 +++++++++++++++++++++ src/libraries/HDDM/DEventWriterREST.h | 1 + src/libraries/HDDM/rest.xml | 1 + 4 files changed, 39 insertions(+) diff --git a/src/libraries/HDDM/DEventSourceREST.cc b/src/libraries/HDDM/DEventSourceREST.cc index ba04fd2a09..4cadb1241c 100644 --- a/src/libraries/HDDM/DEventSourceREST.cc +++ b/src/libraries/HDDM/DEventSourceREST.cc @@ -1408,6 +1408,22 @@ jerror_t DEventSourceREST::Extract_DTrackTimeBased(hddm_r::HDDM *record, tra->setErrorMatrix(loc7x7ErrorMatrix); (*loc7x7ErrorMatrix)(6, 6) = fit.getT0err()*fit.getT0err(); + // Positions at each FDC package + const hddm_r::FdcTrackPosList locFdcTrackPosList = iter->getFdcTrackPoses(); + hddm_r::FdcTrackPosList::iterator locFdcTrackPosIterator = locFdcTrackPosList.begin(); + if (locFdcTrackPosIterator!=locFdcTrackPosList.end()){ + // Create the extrapolation vector + vectormyvector; + tra->extrapolations.emplace(SYS_FDC,myvector); + for(; locFdcTrackPosIterator != locFdcTrackPosList.end(); ++locFdcTrackPosIterator){ + DVector3 pos(locFdcTrackPosIterator->getX(), + locFdcTrackPosIterator->getY(), + locFdcTrackPosIterator->getZ()); + DVector3 mom; + tra->extrapolations[SYS_FDC].push_back(DTrackFitter::Extrapolation_t(pos,mom,0.,0.)); + } + } + // Track parameters at exit of tracking volume const hddm_r::ExitParamsList& locExitParamsList = iter->getExitParamses(); hddm_r::ExitParamsList::iterator locExitParamsIterator = locExitParamsList.begin(); diff --git a/src/libraries/HDDM/DEventWriterREST.cc b/src/libraries/HDDM/DEventWriterREST.cc index a92e80c671..67cf4333cf 100644 --- a/src/libraries/HDDM/DEventWriterREST.cc +++ b/src/libraries/HDDM/DEventWriterREST.cc @@ -28,6 +28,9 @@ DEventWriterREST::DEventWriterREST(JEventLoop* locEventLoop, string locOutputFil } japp->Unlock("RESTWriter"); + REST_WRITE_FDC_TRACK_POS=true; + gPARMS->SetDefaultParameter("REST:WRITE_FDC_TRACK_POS", REST_WRITE_FDC_TRACK_POS,"Add track positions at each FDC package"); + REST_WRITE_TRACK_EXIT_PARAMS=true; gPARMS->SetDefaultParameter("REST:WRITE_TRACK_EXIT_PARAMS", REST_WRITE_TRACK_EXIT_PARAMS,"Add track parameters at exit to tracking volume"); @@ -549,6 +552,24 @@ bool DEventWriterREST::Write_RESTEvent(JEventLoop* locEventLoop, string locOutpu elo3().setDEdxAmp(tracks[i]->ddEdx_FDC_amp_trunc[it]); } } + if (REST_WRITE_FDC_TRACK_POS){ + if (tracks[i]->extrapolations.find(SYS_FDC) != tracks[i]->extrapolations.end()) { + vectorextraps=tracks[i]->extrapolations.at(SYS_FDC); + double oldz=0.; + for (unsigned int k=0;koldz+20.){ + hddm_r::FdcTrackPosList locFdcTrackPoses = tra().addFdcTrackPoses(1); + locFdcTrackPoses().setX(pos.x()); + locFdcTrackPoses().setY(pos.y()); + locFdcTrackPoses().setZ(pos.z()); + oldz=pos.z(); + } + } + } + } + if (REST_WRITE_TRACK_EXIT_PARAMS){ if (tracks[i]->extrapolations.find(SYS_NULL) != tracks[i]->extrapolations.end()) { vectorextraps=tracks[i]->extrapolations.at(SYS_NULL); diff --git a/src/libraries/HDDM/DEventWriterREST.h b/src/libraries/HDDM/DEventWriterREST.h index fa7e1bff50..7dc0577492 100644 --- a/src/libraries/HDDM/DEventWriterREST.h +++ b/src/libraries/HDDM/DEventWriterREST.h @@ -62,6 +62,7 @@ class DEventWriterREST : public JObject bool REST_WRITE_FMWPC_HITS; bool REST_WRITE_CCAL_SHOWERS; bool REST_WRITE_TRACK_EXIT_PARAMS; + bool REST_WRITE_FDC_TRACK_POS; bool ADD_FCAL_DATA_FOR_CPP; bool REST_WRITE_FCAL_HITS; diff --git a/src/libraries/HDDM/rest.xml b/src/libraries/HDDM/rest.xml index 3b5809397a..6ea368c709 100644 --- a/src/libraries/HDDM/rest.xml +++ b/src/libraries/HDDM/rest.xml @@ -82,6 +82,7 @@ + Date: Mon, 2 Dec 2024 08:02:03 -0500 Subject: [PATCH 3/4] Modify code for leaves for FDC (x,y) positions to encode the package numbers in the names. Remove the z position. --- src/libraries/ANALYSIS/DEventWriterROOT.cc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/libraries/ANALYSIS/DEventWriterROOT.cc b/src/libraries/ANALYSIS/DEventWriterROOT.cc index 01dc287c50..542e0edef2 100644 --- a/src/libraries/ANALYSIS/DEventWriterROOT.cc +++ b/src/libraries/ANALYSIS/DEventWriterROOT.cc @@ -712,7 +712,6 @@ void DEventWriterROOT::Create_Branches_ChargedHypotheses(DTreeBranchRegister& lo for (unsigned int j=0;j<4;j++){ locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, dFDCxLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName, dFDCyLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); - locBranchRegister.Register_FundamentalArray(Build_BranchName(locParticleBranchName,dFDCzLeaves[j].c_str()), locArraySizeString, dInitNumTrackArraySize); } } @@ -1844,18 +1843,23 @@ void DEventWriterROOT::Fill_ChargedHypo(DTreeFillData* locTreeFillData, unsigned if (FDC_VERBOSE_OUTPUT){ if (locTrackTimeBased->extrapolations.find(SYS_FDC) != locTrackTimeBased->extrapolations.end()) { vectorlocExtraps=locTrackTimeBased->extrapolations.at(SYS_FDC); - unsigned int locPackageIndex=0; + int locPackageIndex=-1,locOldIndex=-1; for (unsigned int j=0;jdFdcPackages[locPackageIndex]){ + double locZ=locPos.z(); + + if (locZ>dFdcPackages[3]) locPackageIndex=3; + else if (locZ>dFdcPackages[2]) locPackageIndex=2; + else if (locZ>dFdcPackages[1]) locPackageIndex=1; + else locPackageIndex=0; + + if (locPackageIndex!=locOldIndex){ locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCxLeaves[locPackageIndex].c_str()), locPos.x(), locArrayIndex); locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCyLeaves[locPackageIndex].c_str()), locPos.y(), locArrayIndex); - locTreeFillData->Fill_Array(Build_BranchName(locParticleBranchName, dFDCzLeaves[locPackageIndex].c_str()), locPos.z(), locArrayIndex); - - locPackageIndex++; - if (locPackageIndex>3) break; } - + + if (locPackageIndex==3) break; + locOldIndex=locPackageIndex; } } } From 93804cbb004cae2c359f9f4474099642a9009921 Mon Sep 17 00:00:00 2001 From: staylorjlab Date: Wed, 4 Dec 2024 10:42:50 -0500 Subject: [PATCH 4/4] New leaf names for FDC extraps. --- src/libraries/ANALYSIS/DEventWriterROOT.h | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libraries/ANALYSIS/DEventWriterROOT.h b/src/libraries/ANALYSIS/DEventWriterROOT.h index 89b66525ab..832589e043 100644 --- a/src/libraries/ANALYSIS/DEventWriterROOT.h +++ b/src/libraries/ANALYSIS/DEventWriterROOT.h @@ -91,13 +91,8 @@ class DEventWriterROOT : public JObject double dTargetCenterZ; double dFdcPackages[4]; - vectordFDCxLeaves={"FDC_pos1_X","FDC_pos2_X","FDC_pos3_X", - "FDC_pos4_X"}; - vectordFDCyLeaves={"FDC_pos1_Y","FDC_pos2_Y","FDC_pos3_Y", - "FDC_pos4_Y"}; - vectordFDCzLeaves={"FDC_pos1_Z","FDC_pos2_Z","FDC_pos3_Z", - "FDC_pos4_Z"}; - + vectordFDCxLeaves={"FDC1_X","FDC2_X","FDC3_X","FDC4_X"}; + vectordFDCyLeaves={"FDC1_Y","FDC2_Y","FDC3_Y","FDC4_Y"}; //DEFAULT ACTIONS LISTED SEPARATELY FROM CUSTOM (in case in derived class user does something bizarre) map dCutActionMap_ThrownTopology;