10 #include <ecl/modules/eclHadronTimeCalibrationValidationCollector/eclHadronTimeCalibrationValidationCollectorModule.h>
13 #include <ecl/dataobjects/ECLCalDigit.h>
14 #include <ecl/dataobjects/ECLDigit.h>
15 #include <ecl/dataobjects/ECLTrig.h>
16 #include <ecl/digitization/EclConfiguration.h>
19 #include <framework/gearbox/Const.h>
20 #include <mdst/dataobjects/ECLCluster.h>
21 #include <mdst/dataobjects/Track.h>
22 #include <mdst/dataobjects/HitPatternCDC.h>
36 REG_MODULE(eclHadronTimeCalibrationValidationCollector);
44 m_dbg_tree_photonClusters(0),
52 "Events with fabs(getTimeFit) > m_timeAbsMax "
53 "are excluded", (
short)80);
56 "If true, TTree 'tree' with more detailed event info is saved in "
57 "the output file specified by HistoManager",
81 "Validating crystal and crate time calibrations using photon clusters in events with lots of tracks and clusters") ;
97 "Validating crystal and crate time calibrations using photon clusters in events with lots of tracks and clusters") ;
114 B2INFO(
"eclHadronTimeCalibrationValidationCollector: Experiment = " <<
m_EventMetaData->getExperiment() <<
120 double binSize = 2000.0 / pow(2, 12);
121 double halfBinSize = binSize / 2.0;
125 double nBinsNeg = floor((
m_timeAbsMax - halfBinSize) / binSize);
126 double min_t = -nBinsNeg * binSize - halfBinSize;
127 int nbins = nBinsNeg * 2 + 1;
128 double max_t = min_t + nbins * binSize;
132 const Int_t N_E_BIN_EDGES = 64;
133 const Int_t N_E_BINS = N_E_BIN_EDGES - 1;
134 Double_t energyBinEdges[N_E_BIN_EDGES] = {0, 0.05, 0.051, 0.052, 0.053, 0.054, 0.055, 0.056, 0.057, 0.058, 0.059, 0.06, 0.062, 0.064, 0.066, 0.068, 0.07, 0.075, 0.08, 0.085, 0.09, 0.095, 0.1, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2, 0.25, 0.3, 0.35, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.2, 1.4, 1.6, 1.8, 2, 2.25, 2.5, 2.8, 3.2, 3.6, 4, 4.4, 4.8, 5.2, 5.6, 6, 6.4, 6.8, 7.2, 7.6, 8};
137 auto cutflow =
new TH1F(
"cutflow",
" ;Cut label number ;Number of events passing cut", 10, 0, 10) ;
138 registerObject<TH1F>(
"cutflow", cutflow) ;
140 auto clusterTime =
new TH1F(
"clusterTime",
";Photon ECL cluster time [ns]; number of photon ECL clusters", nbins, min_t, max_t) ;
141 registerObject<TH1F>(
"clusterTime", clusterTime) ;
143 auto clusterTime_cid =
new TH2F(
"clusterTime_cid",
146 registerObject<TH2F>(
"clusterTime_cid", clusterTime_cid) ;
148 auto clusterTime_run =
new TH2F(
"clusterTime_run",
149 ";Run number ;Photon ECL cluster time [ns]", 7000, 0, 7000, nbins, min_t, max_t) ;
150 registerObject<TH2F>(
"clusterTime_run", clusterTime_run) ;
153 auto clusterTimeClusterE =
new TH2F(
"clusterTimeClusterE",
154 ";Photon cluster energy [GeV];Photon cluster time [ns]", N_E_BINS, energyBinEdges, nbins, min_t, max_t) ;
155 registerObject<TH2F>(
"clusterTimeClusterE", clusterTimeClusterE) ;
158 auto dt99_clusterE =
new TH2F(
"dt99_clusterE",
159 ";Photon cluster energy [GeV];dt99 [ns]", N_E_BINS, energyBinEdges, nbins, 0, max_t) ;
160 registerObject<TH2F>(
"dt99_clusterE", dt99_clusterE) ;
163 auto eventT0 =
new TH1F(
"eventT0",
";event t0 [ns]; number of events", nbins, min_t, max_t) ;
164 registerObject<TH1F>(
"eventT0", eventT0) ;
167 auto clusterTimeE0E1diff =
new TH1F(
"clusterTimeE0E1diff",
168 ";ECL cluster time of max E photon - ECL cluster time of 2nd max E photon [ns]; number of photon ECL cluster time differences",
169 nbins, min_t, max_t) ;
170 registerObject<TH1F>(
"clusterTimeE0E1diff", clusterTimeE0E1diff) ;
182 int cutIndexPassed = 0;
183 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
184 B2DEBUG(22,
"Cutflow: no cuts: index = " << cutIndexPassed);
191 int tempCrysID = eclCalDigit.getCellId() - 1;
192 m_EperCrys[tempCrysID] = eclCalDigit.getEnergy();
197 double evt_t0 = -1000 ;
198 double evt_t0_unc = -1000 ;
210 evt_t0_unc =
m_eventT0->getEventT0Uncertainty() ;
212 B2DEBUG(26,
"Found event t0") ;
218 int nTrkAll =
tracks.getEntries() ;
227 for (
int iTrk = 0 ; iTrk < nTrkAll ; iTrk++) {
231 if (not tempTrackFit) {continue ;}
235 double z0 = tempTrackFit->
getZ0() ;
236 double d0 = tempTrackFit->
getD0() ;
275 B2DEBUG(26,
"Found loose and tight tracks") ;
278 int numGoodTightTracks_minCut = 4 ;
279 if (nTrkTight < numGoodTightTracks_minCut) {
284 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed) ;
285 B2DEBUG(22,
"Cutflow: At least " << numGoodTightTracks_minCut <<
" tight tracks: index = " << cutIndexPassed) ;
288 int numGoodLooseTracks_minCut = numGoodTightTracks_minCut ;
289 if (nTrkLoose < numGoodLooseTracks_minCut) {
294 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed) ;
295 B2DEBUG(22,
"Cutflow: No additional loose tracks: index = " << cutIndexPassed) ;
300 double clusterE_minCut = 0.1 ;
302 int nGoodClusts = 0 ;
303 vector<int> goodClusterIdxs ;
304 for (
int ic = 0; ic < nclust; ic++) {
306 if (eClust > clusterE_minCut) {
307 goodClusterIdxs.push_back(ic) ;
314 int numGoodEMclusters_minCut = 5 ;
315 if (nGoodClusts < numGoodEMclusters_minCut) {
320 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed) ;
321 B2DEBUG(22,
"Cutflow: At least " << numGoodEMclusters_minCut <<
" ECL clusters: index = " << cutIndexPassed) ;
327 double photonE_minCut = 0.05 ;
328 double zernikeMVA_minCut = 0.2 ;
331 vector<int> goodPhotonClusterIdxs ;
332 for (
int ic = 0; ic < nclust; ic++) {
340 if ((eClust > photonE_minCut) &&
343 (!badPhotonTimeResolution) &&
344 (zernikeMVA > zernikeMVA_minCut) &&
346 goodPhotonClusterIdxs.push_back(ic) ;
354 int numGoodPhotonclusters_minCut = 1 ;
355 if (nPhotons < numGoodPhotonclusters_minCut) {
360 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed) ;
361 B2DEBUG(22,
"Cutflow: At least " << numGoodPhotonclusters_minCut <<
" good photon: index = " << cutIndexPassed) ;
368 vector<double> goodClustTimes ;
369 vector<double> goodClust_dt99 ;
370 vector<double> goodClusters_crysE ;
371 vector<double> goodClustE ;
372 vector<int> goodClustMaxEcrys_cid ;
373 for (
long unsigned int i = 0; i < goodPhotonClusterIdxs.size(); i++) {
374 int ic = goodPhotonClusterIdxs[i] ;
380 goodClustMaxEcrys_cid.push_back(cid) ;
383 goodClusters_crysE.push_back(
m_EperCrys[cid - 1]) ;
384 goodClustE.push_back(eClust);
391 vector< pair<double, double> > pair_energy_time ;
392 for (
long unsigned int ic = 0; ic < goodClusters_crysE.size(); ic++) {
393 pair_energy_time.push_back(make_pair(goodClusters_crysE[ic], goodClustTimes[ic])) ;
398 sort(pair_energy_time.begin(), pair_energy_time.end(), greater<>()) ;
402 B2DEBUG(22,
"Event passed all cuts");
406 getObjectPtr<TH1F>(
"eventT0")->Fill(evt_t0) ;
410 string t0Detector =
"UNKNOWN... WHY?";
413 }
else if (isECLt0) {
417 B2DEBUG(26,
"t0 = " << evt_t0 <<
" ns. t0 is from CDC?=" << isCDCt0 <<
", t0 is from ECL?=" << isECLt0 <<
" t0 from " <<
423 for (
long unsigned int i = 0 ; i < goodPhotonClusterIdxs.size() ; i++) {
424 getObjectPtr<TH1F>(
"clusterTime")->Fill(goodClustTimes[i]) ;
425 getObjectPtr<TH2F>(
"clusterTime_cid")->Fill(goodClustMaxEcrys_cid[i] + 0.001, goodClustTimes[i], 1) ;
426 getObjectPtr<TH2F>(
"clusterTime_run")->Fill(
m_EventMetaData->getRun() + 0.001, goodClustTimes[i], 1) ;
427 getObjectPtr<TH2F>(
"clusterTimeClusterE")->Fill(goodClustE[i], goodClustTimes[i], 1) ;
428 getObjectPtr<TH2F>(
"dt99_clusterE")->Fill(goodClustE[i], goodClust_dt99[i], 1) ;
449 B2DEBUG(26,
"Filled cluster tree") ;
452 if (pair_energy_time.size() >= 2) {
453 getObjectPtr<TH1F>(
"clusterTimeE0E1diff")->Fill(pair_energy_time[0].second - pair_energy_time[1].second) ;
472 B2DEBUG(26,
"Filled event tree") ;
Calibration collector module base class.
static const ChargedStable pion
charged pion particle
@ c_nPhotons
CR is split into n photons (N1)
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Values of the result of a track fit with a given particle hypothesis.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
double m_E_photon_clust
Photon cluster energy.
StoreObjPtr< EventT0 > m_eventT0
StoreObjPtr for T0.
int m_tree_run
Run number for debug TTree output.
double m_looseTrkD0
Loose track d0 minimum cut.
bool m_saveTree
If true, save TTree with more detailed event info.
StoreArray< ECLCluster > m_eclClusterArray
Required input array of ECLClusters.
short m_timeAbsMax
Events with abs(time) > m_timeAbsMax are excluded, mostly for histogram x-range purposes.
int m_tree_cid
ECL Cell ID (1..ECLElementNumbers::c_NCrystals) for debug TTree output.
TTree * m_dbg_tree_event
debug output tree for per event
double m_tree_time
Calibrated time.
double m_tightTrkZ0
Tight track z0 minimum cut.
double m_tree_E0
Highest E cluster energy.
int m_NtightTracks
Number of tight tracks.
TTree * m_dbg_tree_photonClusters
Output tree with detailed event data.
void collect() override
Select events and crystals and accumulate histograms.
virtual ~eclHadronTimeCalibrationValidationCollectorModule()
Module destructor.
double m_tree_dt99
dt99 for cluster
StoreArray< ECLCalDigit > m_eclCalDigitArray
Required input array of ECLCalDigits.
std::vector< float > m_EperCrys
ECL Cal digit energy for each crystal.
void prepare() override
Define histograms and read payloads from DB.
double m_tightTrkD0
Tight track d0 minimum cut.
double m_tree_t0
EventT0 (not from ECL) for debug TTree output.
double m_tree_time_fromE0
Calibrated time - highest E cluster.
void inDefineHisto() override
Replacement for defineHisto() in CalibrationCollector modules.
int m_NphotonClusters
Number of photon clusters.
StoreArray< Track > tracks
Required input array of tracks.
eclHadronTimeCalibrationValidationCollectorModule()
Module constructor.
int m_NGoodClusters
Number of good clusters.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
double m_tree_t0_unc
EventT0 uncertainty for debug TTree output.
int m_tree_evt_num
Event number for debug TTree output.
double m_looseTrkZ0
Loose track z0 minimum cut.
REG_MODULE(arichBtest)
Register the Module.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.
Structure for storing the extracted event t0s together with its detector and its uncertainty.