10#include <ecl/modules/eclBhabhaTCollector/ECLBhabhaTCollectorModule.h>
13#include <ecl/dataobjects/ECLCalDigit.h>
14#include <ecl/dataobjects/ECLDigit.h>
15#include <ecl/dataobjects/ECLElementNumbers.h>
16#include <ecl/dbobjects/ECLCrystalCalib.h>
17#include <ecl/dbobjects/ECLReferenceCrystalPerCrateCalib.h>
18#include <ecl/digitization/EclConfiguration.h>
21#include <analysis/utility/PCmsLabTransform.h>
22#include <framework/dataobjects/EventMetaData.h>
23#include <framework/gearbox/Const.h>
24#include <mdst/dataobjects/ECLCluster.h>
25#include <mdst/dataobjects/HitPatternCDC.h>
26#include <mdst/dataobjects/Track.h>
46 m_ElectronicsDB(
"ECLCrystalElectronics"),
47 m_ElectronicsTimeDB(
"ECLCrystalElectronicsTime"),
48 m_FlightTimeDB(
"ECLCrystalFlightTime"),
49 m_PreviousCrystalTimeDB(
"ECLCrystalTimeOffset"),
50 m_CrateTimeDB(
"ECLCrateTimeOffset"),
51 m_RefCrystalsCalibDB(
"ECLReferenceCrystalPerCrateCalib"),
52 m_channelMapDB(
"ECLChannelMap")
54 setDescription(
"This module generates sum of all event times per crystal");
57 "Events with fabs(getTimeFit) > m_timeAbsMax "
58 "are excluded", (
short)80);
61 "First CellId to handle.", 1);
66 "If true, TTree 'tree' with more detailed event info is saved in "
67 "the output file specified by HistoManager",
74 addParam(
"skipTrgSel",
skipTrgSel,
"boolean to skip the trigger skim selection",
false);
77 "CDC bhabha t0 bias correction (ns)", 0.);
92 m_dbgTree_electrons =
new TTree(
"tree_electrons",
"Debug data for bhabha time calibration - one entry per electron");
98 &
m_tree_E1Etot)->SetTitle(
"Max Energy Crystal Fraction Energy of Cluster");
100 &
m_tree_E1E2)->SetTitle(
"Max Energy Crystal DIV second max energy crystal in cluster");
117 m_dbgTree_tracks =
new TTree(
"tree_tracks",
"Debug data for bhabha time calibration - one entry per track");
128 "Debug data for bhabha time calibration - one entry per electron - one entry per crystal");
140 m_dbgTree_event =
new TTree(
"tree_event",
"Debug data for bhabha time calibration - one entry per event");
147 "Debug data for bhabha time calibration - one entry per event after all the cuts");
165 "Debug data for bhabha time calibration - one entry per crystal per cluster entry after all cuts");
171 ->SetTitle(
"Time of a crystal within the cluster after application of previous calibrations except t0, ns");
191 "Debug data for bhabha time calibration - one entry per max E crystal entry after cuts");
200 &
m_tree_E1Etot)->SetTitle(
"Max Energy Crystal Fraction Energy of Cluster");
202 &
m_tree_E1E2)->SetTitle(
"Max Energy Crystal DIV second max energy crystal in cluster");
220 B2INFO(
"ECLBhabhaTCollector: Experiment = " <<
m_EventMetaData->getExperiment() <<
230 auto TimevsCrysPrevCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCrysPrevCrateCalibPrevCrystCalib",
231 "Time t psi - ts - tcrate (previous calibs) vs crystal cell ID;crystal cell ID;Time t_psi with previous calib (ns)",
233 registerObject<TH2F>(
"TimevsCrysPrevCrateCalibPrevCrystCalib", TimevsCrysPrevCrateCalibPrevCrystCalib);
235 auto TimevsCratePrevCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCratePrevCrateCalibPrevCrystCalib",
236 "Time t psi - ts - tcrate (previous calibs) vs crate ID;crate ID;Time t_psi previous calib (ns)",
237 52, 1, 52 + 1, nbins, min_t, max_t);
238 registerObject<TH2F>(
"TimevsCratePrevCrateCalibPrevCrystCalib", TimevsCratePrevCrateCalibPrevCrystCalib);
240 auto TimevsCrysNoCalibrations =
new TH2F(
"TimevsCrysNoCalibrations",
243 registerObject<TH2F>(
"TimevsCrysNoCalibrations", TimevsCrysNoCalibrations);
245 auto TimevsCrateNoCalibrations =
new TH2F(
"TimevsCrateNoCalibrations",
246 "Time tpsi vs crate ID;crate ID;Time t_psi (ns)", 52, 1, 52 + 1, nbins, min_t, max_t);
247 registerObject<TH2F>(
"TimevsCrateNoCalibrations", TimevsCrateNoCalibrations);
249 auto TimevsCrysPrevCrateCalibNoCrystCalib =
new TH2F(
"TimevsCrysPrevCrateCalibNoCrystCalib",
250 "Time tpsi - tcrate (previous calib) vs crystal cell ID;crystal cell ID;Time t_psi including previous crate calib (ns)",
252 registerObject<TH2F>(
"TimevsCrysPrevCrateCalibNoCrystCalib", TimevsCrysPrevCrateCalibNoCrystCalib);
254 auto TimevsCrateNoCrateCalibPrevCrystCalib =
new TH2F(
"TimevsCrateNoCrateCalibPrevCrystCalib",
255 "Time tpsi - ts (previous calib) vs crate ID;crate ID;Time t_psi including previous crystal calib (ns)",
256 52, 1, 52 + 1, nbins, min_t, max_t);
257 registerObject<TH2F>(
"TimevsCrateNoCrateCalibPrevCrystCalib", TimevsCrateNoCrateCalibPrevCrystCalib);
262 registerObject<TH1F>(
"TsDatabase", TsDatabase);
266 registerObject<TH1F>(
"TsDatabaseUnc", TsDatabaseUnc);
270 registerObject<TH1F>(
"TcrateDatabase", TcrateDatabase);
274 registerObject<TH1F>(
"TcrateUncDatabase", TcrateUncDatabase);
277 auto tcrateDatabase_ns =
new TH1F(
"tcrateDatabase_ns",
";crate id;tcrate derived from database", 52, 1, 52 + 1);
278 registerObject<TH1F>(
"tcrateDatabase_ns", tcrateDatabase_ns);
281 auto databaseCounter =
new TH1I(
"databaseCounter",
282 ";A database was read in;Number of times database was saved to histogram", 1, 1, 2);
283 registerObject<TH1I>(
"databaseCounter", databaseCounter);
286 auto numCrystalEntriesPerEvent =
new TH1F(
"numCrystalEntriesPerEvent",
287 ";Number crystal entries;Number of events", 15, 0, 15);
288 registerObject<TH1F>(
"numCrystalEntriesPerEvent", numCrystalEntriesPerEvent);
290 auto cutflow =
new TH1F(
"cutflow",
";Cut label number;Number of events passing cut", 20, 0, 20);
291 registerObject<TH1F>(
"cutflow", cutflow);
293 auto maxEcrsytalEnergyFraction =
new TH1F(
"maxEcrsytalEnergyFraction",
294 ";Maximum energy crystal energy / (sum) cluster energy;Number", 22, 0, 1.1);
295 registerObject<TH1F>(
"maxEcrsytalEnergyFraction", maxEcrsytalEnergyFraction);
297 auto refCrysIDzeroingCrate =
new TH1F(
"refCrysIDzeroingCrate",
";cell id;Boolean - is reference crystal",
299 registerObject<TH1F>(
"refCrysIDzeroingCrate", refCrysIDzeroingCrate);
301 auto CDCEventT0Correction =
new TH1F(
"CDCEventT0Correction",
";;CDC event t0 offset correction [ns]", 1, 1, 2);
302 registerObject<TH1F>(
"CDCEventT0Correction", CDCEventT0Correction);
313 " ns correction to CDC event t0 will be applied");
321 int cutIndexPassed = 0;
322 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
323 B2DEBUG(22,
"Cutflow: no cuts: index = " << cutIndexPassed);
333 B2WARNING(
"SoftwareTriggerResult required to select bhabha event is not found");
339 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
340 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end()) {
341 B2WARNING(
"Can't find required bhabha trigger identifier");
345 const bool eBhabha = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
347 B2DEBUG(22,
"eBhabha (trigger passed) = " << eBhabha);
357 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
358 B2DEBUG(22,
"Cutflow: Trigger cut passed: index = " << cutIndexPassed);
368 if (ECLchannelMapHasChanged) {
369 B2INFO(
"ECLBhabhaTCollectorModule::collect() " <<
LogVar(
"ECLchannelMapHasChanged", ECLchannelMapHasChanged));
371 B2FATAL(
"ECLBhabhaTCollectorModule::collect() : Can't initialize eclChannelMapper!");
395 B2DEBUG(29,
"Finished checking if previous crystal time payload has changed");
400 B2DEBUG(29,
"Finished checking if previous crate time payload has changed");
401 B2DEBUG(29,
"m_CrateTime size = " <<
m_CrateTime.size());
405 B2DEBUG(29,
"Finished checking if previous crate time payload has changed");
409 B2DEBUG(29,
"Finished checking if reference crystal cell ids payload has changed");
412 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalTimeOffset from the database"
415 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrateTimeOffset from the database"
418 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalElectronics from the database"
421 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalElectronicsTime from the database"
424 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLCrystalFlightTime from the database"
427 B2DEBUG(25,
"ECLBhabhaTCollector:: loaded ECLReferenceCrystalPerCrateCalib from the database"
439 vector<float> Crate_time_ns(52, 0.0);
444 Crate_time_ns[crateID_temp - 1] =
m_CrateTime[crysID] * TICKS_TO_NS;
454 for (
int crateID_temp = 1; crateID_temp <= 52; crateID_temp++) {
455 getObjectPtr<TH1F>(
"refCrysIDzeroingCrate")->Fill(
m_RefCrystalsCalib[crateID_temp - 1] + 0.001);
463 getObjectPtr<TH1F>(
"TcrateDatabase")->SetBinContent(crysID + 0.001,
m_CrateTime[crysID - 1]);
464 getObjectPtr<TH1F>(
"TcrateUncDatabase")->SetBinContent(crysID + 0.001,
m_CrateTimeUnc[crysID - 1]);
467 B2INFO(
"ECLBhabhaTCollector:: ECLCrystalTimeOffset from the database information:"
470 B2INFO(
"First event so print out previous ts values");
480 for (
int crateID_temp = 1; crateID_temp <= 52; crateID_temp++) {
481 getObjectPtr<TH1F>(
"tcrateDatabase_ns")->SetBinContent(crateID_temp + 0.001, Crate_time_ns[crateID_temp - 1]);
486 getObjectPtr<TH1I>(
"databaseCounter")->SetBinContent(1, 1);
498 double evt_t0_unc = -1;
499 double evt_t0_ECL_closestCDC = -1;
500 double evt_t0_ECL_minChi2 = -1;
506 }
else if (!
m_eventT0->hasTemporaryEventT0(Const::EDetector::CDC)) {
512 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
513 B2DEBUG(22,
"Cutflow: Event t0 exists: index = " << cutIndexPassed);
518 const auto bestCDCEventT0Candidate =
m_eventT0->getBestCDCTemporaryEventT0();
519 evt_t0 = bestCDCEventT0Candidate->eventT0;
520 evt_t0_unc = bestCDCEventT0Candidate->eventT0Uncertainty;
528 if (
m_eventT0->hasTemporaryEventT0(Const::EDetector::ECL)) {
529 vector<EventT0::EventT0Component> evt_t0_list_ECL =
m_eventT0->getTemporaryEventT0s(Const::EDetector::ECL);
532 double smallest_CDC_ECL_t0_diff = fabs(evt_t0_list_ECL[0].eventT0 - evt_t0);
533 int smallest_CDC_ECL_t0_diff_idx = 0;
534 for (
long unsigned int ECLi = 0; ECLi < evt_t0_list_ECL.size(); ECLi++) {
535 double tempt_ECL_t0 = evt_t0_list_ECL[ECLi].eventT0;
536 if (fabs(tempt_ECL_t0 - evt_t0) < smallest_CDC_ECL_t0_diff) {
537 smallest_CDC_ECL_t0_diff = fabs(tempt_ECL_t0 - evt_t0);
538 smallest_CDC_ECL_t0_diff_idx = ECLi;
542 evt_t0_ECL_closestCDC = evt_t0_list_ECL[smallest_CDC_ECL_t0_diff_idx].eventT0;
543 B2DEBUG(26,
"evt_t0_ECL_closestCDC = " << evt_t0_ECL_closestCDC);
547 double smallest_ECL_t0_minChi2 = evt_t0_list_ECL[0].quality;
548 int smallest_ECL_t0_minChi2_idx = 0;
550 B2DEBUG(26,
"evt_t0_list_ECL[0].quality = " << evt_t0_list_ECL[0].quality
551 <<
", with ECL event t0 = " << evt_t0_list_ECL[0].eventT0);
553 for (
long unsigned int ECLi = 0; ECLi < evt_t0_list_ECL.size(); ECLi++) {
554 B2DEBUG(26,
"evt_t0_list_ECL[" << ECLi <<
"].quality = " << evt_t0_list_ECL[ECLi].quality
555 <<
", with ECL event t0 = " <<
556 evt_t0_list_ECL[ECLi].eventT0);
557 if (evt_t0_list_ECL[ECLi].quality < smallest_ECL_t0_minChi2) {
558 smallest_ECL_t0_minChi2 = evt_t0_list_ECL[ECLi].quality;
559 smallest_ECL_t0_minChi2_idx = ECLi;
563 evt_t0_ECL_minChi2 = evt_t0_list_ECL[smallest_ECL_t0_minChi2_idx].eventT0;
565 B2DEBUG(26,
"evt_t0_ECL_minChi2 = " << evt_t0_ECL_minChi2);
566 B2DEBUG(26,
"smallest_ECL_t0_minChi2_idx = " << smallest_ECL_t0_minChi2_idx);
584 int tempCrysID = eclCalDigit.getCellId() - 1;
585 m_EperCrys[tempCrysID] = eclCalDigit.getEnergy();
592 int tempCrysID = eclDigit.getCellId() - 1;
607 double maxp[2] = {0., 0.};
608 int maxiTrk[2] = { -1, -1};
609 int nTrkAll =
tracks.getEntries();
617 for (
int iTrk = 0; iTrk < nTrkAll; iTrk++) {
621 if (not tempTrackFit) {
continue;}
625 double z0 = tempTrackFit->
getZ0();
626 double d0 = tempTrackFit->
getD0();
681 if (charge > 0) {icharge = 1;}
682 if (p > maxp[icharge]) {
684 maxiTrk[icharge] = iTrk;
693 if (nTrkTight != 2) {
698 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
699 B2DEBUG(22,
"Cutflow: Two tight tracks: index = " << cutIndexPassed);
702 if (nTrkLoose != 2) {
707 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
708 B2DEBUG(22,
"Cutflow: No additional loose tracks: index = " << cutIndexPassed);
714 bool oppositelyChargedTracksPassed = maxiTrk[0] != -1 && maxiTrk[1] != -1;
715 if (!oppositelyChargedTracksPassed) {
720 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
721 B2DEBUG(22,
"Cutflow: Oppositely charged tracks: index = " << cutIndexPassed);
730 double trkEClustLab[2] = {0., 0.};
731 double trkEClustCOM[2] = {0., 0.};
734 ROOT::Math::PxPyPzEVector trkp4Lab[2];
735 ROOT::Math::PxPyPzEVector trkp4COM[2];
738 int crysIDMax[2] = { -1, -1 };
739 double crysEMax[2] = { -1, -1 };
740 double crysE2Max[2] = { -1, -1 };
741 int numClustersPerTrack[2] = { 0, 0 };
743 double clusterTime[2] = {0, 0};
747 vector<double> time_ECLCaldigits_bothClusters;
748 vector<int> cid_ECLCaldigits_bothClusters;
749 vector<double> E_ECLCaldigits_bothClusters;
750 vector<double> amp_ECLDigits_bothClusters;
751 vector<int> chargeID_ECLCaldigits_bothClusters;
753 for (
int icharge = 0; icharge < 2; icharge++) {
754 if (maxiTrk[icharge] > -1) {
755 B2DEBUG(22,
"looping over the 2 max pt tracks");
758 if (not tempTrackFit) {
continue;}
760 trkp4COM[icharge] = boostrotate.
rotateLabToCms() * trkp4Lab[icharge];
761 trkpLab[icharge] = trkp4Lab[icharge].P();
762 trkpCOM[icharge] = trkp4COM[icharge].P();
768 auto eclClusterRelationsFromTracks =
tracks[maxiTrk[icharge]]->getRelationsTo<
ECLCluster>();
769 for (
unsigned int clusterIdx = 0; clusterIdx < eclClusterRelationsFromTracks.size(); clusterIdx++) {
771 B2DEBUG(22,
"Looking at clusters. index = " << clusterIdx);
772 auto cluster = eclClusterRelationsFromTracks[clusterIdx];
773 bool goodClusterType =
false;
777 goodClusterType =
true;
778 numClustersPerTrack[icharge]++;
781 if (goodClusterType) {
783 clusterTime[icharge] = cluster->getTime();
785 auto eclClusterRelations = cluster->getRelationsTo<
ECLCalDigit>(
"ECLCalDigits");
788 for (
unsigned int ir = 0; ir < eclClusterRelations.size(); ir++) {
789 const auto calDigit = eclClusterRelations.object(ir);
790 int tempCrysID = calDigit->
getCellId() - 1;
797 if (tempE > crysEMax[icharge]) {
799 crysE2Max[icharge] = crysEMax[icharge];
801 crysEMax[icharge] = tempE;
802 crysIDMax[icharge] = tempCrysID;
805 if (tempE > crysE2Max[icharge] && tempCrysID != crysIDMax[icharge]) {
806 crysE2Max[icharge] = tempE;
813 B2DEBUG(26,
"calDigit(ir" << ir <<
") time = " << calDigit->getTime() <<
"ns , with E = " << tempE <<
" GeV");
814 time_ECLCaldigits_bothClusters.push_back(calDigit->getTime());
815 cid_ECLCaldigits_bothClusters.push_back(tempCrysID);
816 E_ECLCaldigits_bothClusters.push_back(tempE);
817 amp_ECLDigits_bothClusters.push_back(ecl_dig->
getAmp());
818 chargeID_ECLCaldigits_bothClusters.push_back(icharge);
823 trkEClustCOM[icharge] = trkEClustLab[icharge] * trkpCOM[icharge] / trkpLab[icharge];
828 E_DIV_p[icharge] = trkEClustCOM[icharge] / trkpCOM[icharge];
840 int numCrystalsPassingCuts = 0;
842 int crystalIDs[2] = { -1, -1};
843 int crateIDs[2] = { -1, -1};
844 double ts_prevCalib[2] = { -1, -1};
845 double tcrate_prevCalib[2] = { -1, -1};
846 double times_noPreviousCalibrations[2] = { -1, -1};
847 bool crystalCutsPassed[2] = {
false,
false};
848 double crystalEnergies[2] = { -1, -1};
849 double crystalEnergies2[2] = { -1, -1};
851 for (
int iCharge = 0; iCharge < 2; iCharge++) {
852 int crystal_idx = crysIDMax[iCharge];
862 auto amplitude = ecl_dig->
getAmp();
863 crystalEnergies[iCharge] = en;
866 double time = ecl_dig->
getTimeFit() * TICKS_TO_NS - evt_t0;
875 double energyTimeShift =
m_ECLTimeUtil->energyDependentTimeOffsetElectronic(amplitude *
m_Electronics[cid - 1]) * TICKS_TO_NS;
877 B2DEBUG(29,
"cellid = " << cid <<
", amplitude = " << amplitude <<
", time before t(E) shift = " << time <<
878 ", t(E) shift = " << energyTimeShift <<
" ns");
879 time -= energyTimeShift;
892 crystalIDs[iCharge] = cid;
897 tcrate_prevCalib[iCharge] =
m_CrateTime[cid - 1] * TICKS_TO_NS;
898 times_noPreviousCalibrations[iCharge] = time;
901 B2DEBUG(26,
"iCharge = " << iCharge);
902 B2DEBUG(26,
"crateIDs[iCharge] = " << crateIDs[iCharge]);
903 B2DEBUG(26,
"times_noPreviousCalibrations[iCharge] = " << times_noPreviousCalibrations[iCharge]);
904 B2DEBUG(26,
"tcrate_prevCalib[iCharge] = " << tcrate_prevCalib[iCharge]);
905 B2DEBUG(26,
"ts_prevCalib[iCharge] = " << ts_prevCalib[iCharge]);
908 crystalCutsPassed[iCharge] =
true;
912 crystalEnergies2[iCharge] = crysE2Max[iCharge];
940 getObjectPtr<TH1F>(
"maxEcrsytalEnergyFraction")->Fill(en / trkEClustLab[iCharge]);
950 bool E_DIV_p_instance_passed[2] = {
false,
false};
951 double E_DIV_p_CUT = 0.7;
952 for (
int icharge = 0; icharge < 2; icharge++) {
953 E_DIV_p_instance_passed[icharge] = E_DIV_p[icharge] > E_DIV_p_CUT;
955 if (!E_DIV_p_instance_passed[0] || !E_DIV_p_instance_passed[1]) {
960 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
961 B2DEBUG(22,
"Cutflow: E_i/p_i > " << E_DIV_p_CUT <<
": index = " << cutIndexPassed);
967 double invMassTrk = (trkp4Lab[0] + trkp4Lab[1]).M();
968 double invMass_CUT = 0.9;
977 bool invMassCutsPassed = invMassTrk > (invMass_CUT * boostrotate.
getCMSEnergy());
978 if (!invMassCutsPassed) {
983 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
984 B2DEBUG(22,
"Cutflow: m(track 1+2) > " << invMass_CUT <<
"*E_COM = " << invMass_CUT <<
" * " << boostrotate.
getCMSEnergy() <<
985 " : index = " << cutIndexPassed);
990 for (
int iCharge = 0; iCharge < 2; iCharge++) {
991 if (crystalCutsPassed[iCharge]) {
992 getObjectPtr<TH2F>(
"TimevsCrysPrevCrateCalibPrevCrystCalib")->Fill((crystalIDs[iCharge]) + 0.001,
993 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge] - tcrate_prevCalib[iCharge], 1);
994 getObjectPtr<TH2F>(
"TimevsCratePrevCrateCalibPrevCrystCalib")->Fill((crateIDs[iCharge]) + 0.001,
995 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge] - tcrate_prevCalib[iCharge], 1);
996 getObjectPtr<TH2F>(
"TimevsCrysNoCalibrations")->Fill((crystalIDs[iCharge]) + 0.001, times_noPreviousCalibrations[iCharge], 1);
997 getObjectPtr<TH2F>(
"TimevsCrateNoCalibrations")->Fill((crateIDs[iCharge]) + 0.001, times_noPreviousCalibrations[iCharge], 1);
998 getObjectPtr<TH2F>(
"TimevsCrysPrevCrateCalibNoCrystCalib")->Fill((crystalIDs[iCharge]) + 0.001,
999 times_noPreviousCalibrations[iCharge] - tcrate_prevCalib[iCharge], 1);
1000 getObjectPtr<TH2F>(
"TimevsCrateNoCrateCalibPrevCrystCalib")->Fill((crateIDs[iCharge]) + 0.001,
1001 times_noPreviousCalibrations[iCharge] - ts_prevCalib[iCharge], 1);
1004 numCrystalsPassingCuts++;
1012 if (crystalCutsPassed[0] || crystalCutsPassed[1]) {
1015 getObjectPtr<TH1F>(
"cutflow")->Fill(cutIndexPassed);
1016 B2DEBUG(22,
"Cutflow: At least one crystal time and quality cuts passed: index = " << cutIndexPassed);
1018 getObjectPtr<TH1F>(
"numCrystalEntriesPerEvent")->Fill(numCrystalsPassingCuts);
1023 for (
int iCharge = 0; iCharge < 2; iCharge++) {
1024 if (crystalCutsPassed[iCharge]) {
1029 m_tree_time = times_noPreviousCalibrations[iCharge];
1033 m_tree_E1Etot = crystalEnergies[iCharge] / trkEClustLab[iCharge];
1034 m_tree_E1E2 = crystalEnergies[iCharge] / crystalEnergies2[iCharge];
1035 m_tree_E1p = crystalEnergies[iCharge] / trkpLab[iCharge];
1054 if (crystalCutsPassed[0] && crystalCutsPassed[1] &&
1055 numClustersPerTrack[0] == 1 && numClustersPerTrack[1] == 1) {
1076 B2DEBUG(26,
"CDC evt_t0 = " << evt_t0);
1081 for (
long unsigned int digit_i = 0; digit_i < time_ECLCaldigits_bothClusters.size(); digit_i++) {
1091 ts_prevCalib[chargeID_ECLCaldigits_bothClusters[digit_i]] -
1092 tcrate_prevCalib[chargeID_ECLCaldigits_bothClusters[digit_i]];
1093 m_tree_cid = cid_ECLCaldigits_bothClusters[digit_i];
1104 B2DEBUG(26,
"This was for event number = " <<
m_tree_evtNum);
Calibration collector module base class.
static const ChargedStable pion
charged pion particle
bool hasChanged()
Check whether the object has changed since the last call to hasChanged of the accessor).
double m_tree_d0
Track d0 for debug TTree output.
double m_tree_maxEcrystNegClust
Time of the highest energy crystal in the cluster associated to negatively charged track,...
std::vector< float > m_CrateTime
vector obtained from DB object
std::vector< int > m_eclDigitID
ECL digit id sorter.
double m_tree_timeF
ECL fitting time for debug TTree output.
double m_tree_E1Etot
Energy of crystal with maximum energy within ECL cluster divided by total cluster energy,...
double m_tree_tClustNeg
Cluster time of cluster associated to negatively charged track, ns for debug TTree output.
DBObjPtr< ECLCrystalCalib > m_CrateTimeDB
Time offset from crate time calibration (also this calibration) from database.
TTree * m_dbgTree_crystals
Debug TTree output per crystal.
StoreObjPtr< EventT0 > m_eventT0
StoreObjPtr for T0.
StoreArray< ECLDigit > m_eclDigitArray
Required input array of ECLDigits.
double m_tree_clustCrysE
crystal energy, only for the crystals that meet all the selection criteria for debug TTree output
std::vector< float > m_FlightTime
vector obtained from DB object
double m_tree_timetsPreviousTimeCalibs
Time for Ts distribution after application of previous time calibrations for debug TTree output.
double m_looseTrkD0
Loose track d0 minimum cut.
double m_tree_E1E2
Energy of crystal with maximum energy within ECL cluster divided by second most energetic crystal in ...
double m_tree_ECLDigitAmplitude
Amplitude (used to calculate energy) of an ECLDigit within a cluster, for debug TTree output.
double m_tree_tClustPos
Cluster time of cluster associated to positively charged track, ns for debug TTree output.
int m_tree_quality
ECL fit quality for debug TTree output.
bool m_saveTree
If true, save TTree with more detailed event info.
double m_tree_enNeg
Energy of cluster associated to negatively charged track, GeV for debug TTree output.
DBObjPtr< ECLCrystalCalib > m_ElectronicsTimeDB
Time offset from electronics calibration from database.
double m_tree_tClust
Cluster time of a cluster, ns for debug TTree output.
double m_E_DIV_p
Energy divided by momentum, for debug TTree output.
double m_tree_en
Energy of crystal with maximum energy within ECL cluster, GeV for debug TTree output.
int m_minCrystal
First CellId to handle.
std::vector< int > m_eclCalDigitID
ECL cal digit id sorter.
bool m_storeCalib
Boolean for whether or not to store the previous calibration calibration constants.
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.
DBObjPtr< ECLReferenceCrystalPerCrateCalib > m_RefCrystalsCalibDB
Crystal IDs of the one reference crystal per crate from database.
int m_crystalCrate
Crate id for the crystal.
int m_tree_cid
ECL Cell ID (1..ECLElementNumbers::c_NCrystals) for debug TTree output.
double m_tree_time
Time for Ts distribution for debug TTree output.
double m_massInvTracks
invariant mass of the two tracks, for debug TTree output
double m_tree_nCDChits
Number of CDC hits along the track for debug TTree output.
double m_tree_enPlus
Energy of cluster associated to positively charged track, GeV for debug TTree output.
int m_tree_evtNum
Event number for debug TTree output.
double m_tightTrkZ0
Tight track z0 minimum cut.
DBObjPtr< Belle2::ECLChannelMap > m_channelMapDB
Mapper of ecl channels to various other objects, like crates.
std::vector< short > m_RefCrystalsCalib
vector obtained from DB object
double m_tree_t0_ECL_minChi2
EventT0 (from ECL) min chi2 for debug TTree output.
double m_tree_maxEcrystPosClust
Time of the highest energy crystal in the cluster associated to positively charged track,...
void collect() override
Select events and crystals and accumulate histograms.
std::vector< float > m_CrateTimeUnc
uncertainty vector obtained from DB object
TTree * m_dbgTree_allCuts
Debug TTree output after all cuts.
double m_tree_ECLCalDigitTime
Time of an ECLCalDigit within a cluster, ns for debug TTree output.
StoreArray< ECLCalDigit > m_eclCalDigitArray
Required input array of ECLCalDigits.
TTree * m_dbgTree_event
Debug TTree output per event.
double m_tree_z0
Track z0 for debug TTree output.
std::vector< float > m_EperCrys
ECL cal digit energy for each crystal.
bool skipTrgSel
flag to skip the trigger skim selection in the module
double m_tree_p
Track momentum for debug TTree output.
void prepare() override
Define histograms and read payloads from DB.
std::vector< float > m_PreviousCrystalTime
vector obtained from DB object
int m_maxCrystal
Last CellId to handle.
DBObjPtr< ECLCrystalCalib > m_PreviousCrystalTimeDB
Time offset from previous crystal time calibration (this calibration) from database.
double m_tightTrkD0
Tight track d0 minimum cut.
double m_tree_t0
EventT0 (not from ECL) for debug TTree output.
int m_tree_amp
Fitting amplitude from ECL for debug TTree output.
double m_tree_E1p
Energy of crystal with maximum energy within ECL cluster divided by total cluster energy divided by t...
TTree * m_dbgTree_evt_allCuts
Debug TTree output per event after all cuts.
std::vector< float > m_Electronics
vector obtained from DB object
void inDefineHisto() override
Replacement for defineHisto() in CalibrationCollector modules.
int m_charge
particle charge, for debug TTree output
TTree * m_dbgTree_electrons
Output tree with detailed event data.
std::vector< float > m_PreviousCrystalTimeUnc
vector obtained from DB object
std::unique_ptr< Belle2::ECL::ECLTimingUtilities > m_ECLTimeUtil
ECL timing tools.
StoreArray< Track > tracks
StoreArray for tracks.
double m_tree_t0_ECLclosestCDC
EventT0 (from ECL) closest to CDC for debug TTree output.
TTree * m_dbgTree_crys_allCuts
Debug TTree output per crystal after all cuts.
double m_tree_clustCrysE_DIV_maxEcrys
ratio of crystal energy to energy of the crystal that has the maximum energy, only for the crystals t...
DBObjPtr< ECLCrystalCalib > m_FlightTimeDB
Time offset from flight time b/w IP and crystal from database.
DBObjPtr< ECLCrystalCalib > m_ElectronicsDB
electronics amplitude calibration from database Scale amplitudefor each crystal and for dead pre-amps
double m_tree_ECLCalDigitE
Energy of an ECLCalDigit within a cluster, GeV for debug TTree output.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
double m_tree_t0_unc
EventT0 uncertainty for debug TTree output.
std::unique_ptr< Belle2::ECL::ECLChannelMapper > m_crystalMapper
ECL object for keeping track of mapping between crystals and crates etc.
virtual ~ECLBhabhaTCollectorModule()
Module destructor.
double m_hadronEventT0_TO_bhabhaEventT0_correction
correction to apply to CDC event t0 values in bhabha events to correct for CDC event t0 bias compared...
std::vector< float > m_ElectronicsTime
vector obtained from DB object
ECLBhabhaTCollectorModule()
Module constructor.
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Store array for Trigger selection.
TTree * m_dbgTree_tracks
Debug TTree output per track.
double m_looseTrkZ0
Loose track z0 minimum cut.
Class to store calibrated ECLDigits: ECLCalDigits.
int getCellId() const
Get Cell ID.
double getEnergy() const
Get Calibrated Energy.
@ c_nPhotons
CR is split into n photons (N1)
Class to store ECL digitized hits (output of ECLDigi) relation to ECLHit filled in ecl/modules/eclDig...
int getAmp() const
Get Fitting Amplitude.
int getQuality() const
Get Fitting Quality.
int getCellId() const
Get Cell ID.
int getTimeFit() const
Get Fitting Time.
static double getRF()
See m_rf.
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.
short getChargeSign() const
Return track charge (1 or -1).
ROOT::Math::PxPyPzEVector get4Momentum() const
Getter for the 4Momentum at the closest approach of the track in the r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
Class to store variables with their name which were sent to the logging service.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
@ c_accept
Accept this event.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.