From f6053fb78654954f7b5d059e22ae960eb44de8b9 Mon Sep 17 00:00:00 2001 From: Maurizio Ungaro Date: Mon, 13 Feb 2023 15:12:40 -0500 Subject: [PATCH] added DETECTOR_INEFFICIENCY and APPLY_THRESHOLDS options --- .gitignore | 1 - hitprocess/HPS/ECAL_hitprocess.cc | 5 +++++ hitprocess/HPS/SVT_hitprocess.cc | 5 +++++ hitprocess/HPS/muon_hodo_hitprocess.cc | 5 +++++ hitprocess/bdx/cormo_hitprocess.cc | 5 +++++ hitprocess/bdx/crs_hitprocess.cc | 5 +++++ hitprocess/clas12/alert/ahdc_hitprocess.cc | 3 --- hitprocess/clas12/alert/alertshell_hitprocess.cc | 3 --- hitprocess/clas12/alert/atof_hitprocess.cc | 4 +--- hitprocess/clas12/band_hitprocess.cc | 6 +++--- hitprocess/clas12/cnd_hitprocess.cc | 2 +- hitprocess/clas12/ctof_hitprocess.cc | 10 ++++++++-- hitprocess/clas12/ftof_hitprocess.cc | 4 ++-- hitprocess/clas12/rtpc_hitprocess.cc | 5 +++++ hitprocess/clas12/uRwell/uRwell_hitprocess.cc | 5 +++++ hitprocess/injector/bubble_hitprocess.cc | 5 +++++ sensitivity/HitProcess.h | 4 ++++ src/gemc_options.cc | 15 ++++++++++++++- 18 files changed, 73 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index ab2a4635..cc0c0445 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -.sconsign.dblite *.o gui/src/moc_camera_control.cc gui/src/moc_detector_editor.cc diff --git a/hitprocess/HPS/ECAL_hitprocess.cc b/hitprocess/HPS/ECAL_hitprocess.cc index fea4ba68..dc83df6d 100644 --- a/hitprocess/HPS/ECAL_hitprocess.cc +++ b/hitprocess/HPS/ECAL_hitprocess.cc @@ -87,6 +87,11 @@ map ECAL_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["adc"] = adc; dgtz["tdc"] = tdc; + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/HPS/SVT_hitprocess.cc b/hitprocess/HPS/SVT_hitprocess.cc index b761c08f..4ba45bb1 100644 --- a/hitprocess/HPS/SVT_hitprocess.cc +++ b/hitprocess/HPS/SVT_hitprocess.cc @@ -42,6 +42,11 @@ map SVT_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["module"] = module; dgtz["strip"] = strip; + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/HPS/muon_hodo_hitprocess.cc b/hitprocess/HPS/muon_hodo_hitprocess.cc index a4203930..5fd310bb 100644 --- a/hitprocess/HPS/muon_hodo_hitprocess.cc +++ b/hitprocess/HPS/muon_hodo_hitprocess.cc @@ -42,6 +42,11 @@ map muon_hodo_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["tdcl"] = tdcl; dgtz["tdcr"] = tdcr; + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/bdx/cormo_hitprocess.cc b/hitprocess/bdx/cormo_hitprocess.cc index 6658e76d..c5757175 100644 --- a/hitprocess/bdx/cormo_hitprocess.cc +++ b/hitprocess/bdx/cormo_hitprocess.cc @@ -199,6 +199,11 @@ map cormo_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["tdcb"] = TDCB; dgtz["tdcf"] = TDCF; + // define conditions to reject hit + if (rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/bdx/crs_hitprocess.cc b/hitprocess/bdx/crs_hitprocess.cc index 511ecac9..8291e9b8 100644 --- a/hitprocess/bdx/crs_hitprocess.cc +++ b/hitprocess/bdx/crs_hitprocess.cc @@ -335,6 +335,11 @@ map crs_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["tdcb"] = TDCB*1000.;//original time in ps dgtz["tdcf"] = 0; + // define conditions to reject hit + if (rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/clas12/alert/ahdc_hitprocess.cc b/hitprocess/clas12/alert/ahdc_hitprocess.cc index c9473392..f9445558 100644 --- a/hitprocess/clas12/alert/ahdc_hitprocess.cc +++ b/hitprocess/clas12/alert/ahdc_hitprocess.cc @@ -316,9 +316,6 @@ map ahdc_HitProcess::integrateDgt(MHit* aHit, int hitn) { dgtz["ADC_ped"] = doca*1000; - // decide if write an hit or not - rejectHitConditions = false; - writeHit = true; // define conditions to reject hit if (rejectHitConditions) { writeHit = false; diff --git a/hitprocess/clas12/alert/alertshell_hitprocess.cc b/hitprocess/clas12/alert/alertshell_hitprocess.cc index 3654976f..3284974c 100644 --- a/hitprocess/clas12/alert/alertshell_hitprocess.cc +++ b/hitprocess/clas12/alert/alertshell_hitprocess.cc @@ -148,9 +148,6 @@ map alertshell_HitProcess::integrateDgt(MHit* aHit, int hitn) { // cout << " value in hitn var: " << hitn << endl; // cout << " ************** Hit ended! **************** " << endl; - // decide if write an hit or not - rejectHitConditions = false; - writeHit = true; // define conditions to reject hit if (rejectHitConditions) { writeHit = false; diff --git a/hitprocess/clas12/alert/atof_hitprocess.cc b/hitprocess/clas12/alert/atof_hitprocess.cc index ad0a6a15..e3126d5a 100644 --- a/hitprocess/clas12/alert/atof_hitprocess.cc +++ b/hitprocess/clas12/alert/atof_hitprocess.cc @@ -327,9 +327,7 @@ map atof_HitProcess::integrateDgt(MHit* aHit, int hitn) { dgtz["ADC_time"] = time; dgtz["ADC_ped"] = 0; - // decide if write an hit or not - rejectHitConditions = false; - writeHit = true; + // define conditions to reject hit if (rejectHitConditions) { writeHit = false; diff --git a/hitprocess/clas12/band_hitprocess.cc b/hitprocess/clas12/band_hitprocess.cc index 88186eb3..977179ed 100644 --- a/hitprocess/clas12/band_hitprocess.cc +++ b/hitprocess/clas12/band_hitprocess.cc @@ -325,9 +325,9 @@ map band_HitProcess :: integrateDgt(MHit* aHit, int hitn) // define conditions to reject hit - //if(rejectHitConditions) { - // writeHit = false; - //} + if(rejectHitConditions) { + writeHit = false; + } //cout << "RETURNING DGTZ\n"; return dgtz; } diff --git a/hitprocess/clas12/cnd_hitprocess.cc b/hitprocess/clas12/cnd_hitprocess.cc index ba9c57e2..474e3253 100644 --- a/hitprocess/clas12/cnd_hitprocess.cc +++ b/hitprocess/clas12/cnd_hitprocess.cc @@ -588,7 +588,7 @@ map cnd_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["TDC_TDC"] = TDC; // reject hit if below threshold or efficiency - if ( eTotal < threshold ) { + if ( eTotal < threshold && applyThresholds) { rejectHitConditions = true; } diff --git a/hitprocess/clas12/ctof_hitprocess.cc b/hitprocess/clas12/ctof_hitprocess.cc index e7aca7eb..21404b1c 100644 --- a/hitprocess/clas12/ctof_hitprocess.cc +++ b/hitprocess/clas12/ctof_hitprocess.cc @@ -400,14 +400,20 @@ map ctof_HitProcess::integrateDgt(MHit* aHit, int hitn) dgtz["TDC_TDC"] = (int) tdc; // reject hit if below threshold or efficiency - if ( energyDepositedAttenuated < ctc.threshold[sector - 1][layer - 1][side][paddle - 1] ) { + if ( energyDepositedAttenuated < ctc.threshold[sector - 1][layer - 1][side][paddle - 1] && applyThresholds ) { rejectHitConditions = true; } + double random = G4UniformRand(); - if ( random > ctc.efficiency[sector - 1][layer - 1][side][paddle - 1] ) { + if ( random > ctc.efficiency[sector - 1][layer - 1][side][paddle - 1] && applyInefficiencies) { rejectHitConditions = true; } + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/clas12/ftof_hitprocess.cc b/hitprocess/clas12/ftof_hitprocess.cc index 882dc909..3357ef6d 100644 --- a/hitprocess/clas12/ftof_hitprocess.cc +++ b/hitprocess/clas12/ftof_hitprocess.cc @@ -409,7 +409,7 @@ map ftof_HitProcess::integrateDgt(MHit* aHit, int hitn) { // reject hit if below threshold or efficiency - if ( energyDepositedAttenuated < ftc.threshold[sector - 1][panel - 1][pmt][paddle - 1] ) { + if ( energyDepositedAttenuated < ftc.threshold[sector - 1][panel - 1][pmt][paddle - 1] && applyThresholds) { rejectHitConditions = true; } double random = G4UniformRand(); @@ -418,7 +418,7 @@ map ftof_HitProcess::integrateDgt(MHit* aHit, int hitn) { // << ftc.threshold[sector - 1][panel - 1][pmt][paddle - 1] << " and efficiency " << ftc.efficiency[sector - 1][panel - 1][pmt][paddle - 1] // << " random " << random << endl; - if ( random > ftc.efficiency[sector - 1][panel - 1][pmt][paddle - 1] ) { + if ( random > ftc.efficiency[sector - 1][panel - 1][pmt][paddle - 1] && applyInefficiencies) { rejectHitConditions = true; } diff --git a/hitprocess/clas12/rtpc_hitprocess.cc b/hitprocess/clas12/rtpc_hitprocess.cc index 9b4bd200..d1bfd075 100644 --- a/hitprocess/clas12/rtpc_hitprocess.cc +++ b/hitprocess/clas12/rtpc_hitprocess.cc @@ -306,6 +306,11 @@ map rtpc_HitProcess :: integrateDgt(MHit* aHit, int hitn) } + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/hitprocess/clas12/uRwell/uRwell_hitprocess.cc b/hitprocess/clas12/uRwell/uRwell_hitprocess.cc index cc4a20db..d8264f68 100644 --- a/hitprocess/clas12/uRwell/uRwell_hitprocess.cc +++ b/hitprocess/clas12/uRwell/uRwell_hitprocess.cc @@ -106,6 +106,11 @@ mapuRwell_HitProcess :: integrateDgt(MHit* aHit, int hitn) // cout< bubble_HitProcess :: integrateDgt(MHit* aHit, int hitn) dgtz["pid"] = thisPid; dgtz["hitn"] = hitn; + // define conditions to reject hit + if(rejectHitConditions) { + writeHit = false; + } + return dgtz; } diff --git a/sensitivity/HitProcess.h b/sensitivity/HitProcess.h index 1e7f4bdc..4c1b1f6d 100644 --- a/sensitivity/HitProcess.h +++ b/sensitivity/HitProcess.h @@ -71,6 +71,8 @@ class HitProcess gpars = gp; verbosity = gemcOpt.optMap["HIT_VERBOSITY"].arg; accountForHardwareStatus = gemcOpt.optMap["HARDWARESTATUS"].arg; + applyInefficiencies = gemcOpt.optMap["DETECTOR_INEFFICIENCY"].arg; + applyThresholds = gemcOpt.optMap["APPLY_THRESHOLDS"].arg; log_msg = " > " + HCname + " Hit Process "; HCname = name; @@ -145,6 +147,8 @@ class HitProcess string log_msg; bool rejectHitConditions; bool accountForHardwareStatus; + bool applyInefficiencies; + bool applyThresholds; inline double DGauss(double x, double *par, double Edep, double stepTime) { diff --git a/src/gemc_options.cc b/src/gemc_options.cc index 6101e0da..ab588836 100644 --- a/src/gemc_options.cc +++ b/src/gemc_options.cc @@ -762,7 +762,20 @@ void goptions::setGoptions() optMap["HARDWARESTATUS"].type = 0; optMap["HARDWARESTATUS"].ctgr = "control"; - + optMap["DETECTOR_INEFFICIENCY"].arg = 0; + optMap["DETECTOR_INEFFICIENCY"].name = "Accounts for detector inefficiency"; + optMap["DETECTOR_INEFFICIENCY"].help = "Accounts for detector inefficiency\n"; + optMap["DETECTOR_INEFFICIENCY"].help += "This flag can be used by the digitization routines to account for hardware status\n"; + optMap["DETECTOR_INEFFICIENCY"].type = 0; + optMap["DETECTOR_INEFFICIENCY"].ctgr = "control"; + + optMap["APPLY_THRESHOLDS"].arg = 0; + optMap["APPLY_THRESHOLDS"].name = "Accounts for detector thresholds"; + optMap["APPLY_THRESHOLDS"].help = "Accounts for detector thresholds\n"; + optMap["APPLY_THRESHOLDS"].help += "This flag can be used by the digitization routines to account for hardware status\n"; + optMap["APPLY_THRESHOLDS"].type = 0; + optMap["APPLY_THRESHOLDS"].ctgr = "control"; + // Output