9#include <reconstruction/modules/EventT0Validation/EventT0Validation.h>
11#include <framework/dataobjects/EventT0.h>
13#include <TEfficiency.h>
23 setDescription(
"Make data quality monitoring plots for EventT0 for bhabha, mu mu, and hadron samples for different trigger (time) sources.");
42 m_histECLEventT0 =
new TH1F(
"histECLEventT0",
"ECL EventT0;EventT0 [ns];events / 0.5 ns", nBins, minT0, maxT0);
44 m_histSVDEventT0 =
new TH1F(
"histSVDEventT0",
"SVD EventT0;EventT0 [ns];events / 0.5 ns", nBins, minT0, maxT0);
46 m_histTOPEventT0 =
new TH1F(
"histTOPEventT0",
"TOP EventT0;EventT0 [ns];events / 0.5 ns", nBins, minT0, maxT0);
48 m_histCDCEventT0 =
new TH1F(
"histCDCEventT0",
"CDC EventT0;EventT0 [ns];events / 0.5 ns", nBins, minT0, maxT0);
53 m_histCDCChi2EventT0 =
new TH1F(
"histCDCChi2EventT0",
"CDC FullGrid #chi^{2} EventT0;EventT0 [ns];events / 0.5 ns",
57 m_histCDCGridEventT0 =
new TH1F(
"histCDCGridEventT0",
"CDC Grid search EventT0;EventT0 [ns];events / 0.5 ns", nBins, minT0,
62 new TH1D(
"histAlgorithmSourceCounts",
63 "Number of events with EventT0 from each algorithm;Algorithm;Count",
66 "Number of events in which an EventT0 was found by each algorithm. "\
67 "Some of the CDC algorithms are only executed if no SVD EventT0 is found.",
68 "Values should be around 1000 (1000 events in validation).",
m_contact);
70 new TH1D(
"histAlgorithmSourceCountsActive",
71 "Number of events with EventT0 from each algorithm where it was active;Algorithm;Count",
74 "Number of events in which an EventT0 was found by each algorithm if they are executed. "\
75 "Some of the CDC algorithms are only executed if no SVD EventT0 is found.",
76 "Values should be around 1000 (1000 events in validation).",
m_contact);
78 for (uint i = 0; i < 11; i++) {
97 B2WARNING(
"Missing EventT0, EventT0Validation is skipped.");
108 B2WARNING(
"Missing EventT0, EventT0Validation is skipped.");
113 const double eventT0ECL =
114 m_eventT0->hasTemporaryEventT0(Const::EDetector::ECL) ?
m_eventT0->getBestECLTemporaryEventT0()->eventT0 : -1000;
115 const double eventT0CDC =
116 m_eventT0->hasTemporaryEventT0(Const::EDetector::CDC) ?
m_eventT0->getBestCDCTemporaryEventT0()->eventT0 : -1000;
117 const double eventT0TOP =
118 m_eventT0->hasTemporaryEventT0(Const::EDetector::TOP) ?
m_eventT0->getBestTOPTemporaryEventT0()->eventT0 : -1000;
119 const double eventT0SVD =
120 m_eventT0->hasTemporaryEventT0(Const::EDetector::SVD) ?
m_eventT0->getBestSVDTemporaryEventT0()->eventT0 : -1000;
122 const auto getCDCEventT0sForAlgorithm = [cdcEventT0s =
m_eventT0->getTemporaryEventT0s(Const::EDetector::CDC)](
123 const std::string & algorithm) {
124 std::vector<EventT0::EventT0Component> temporaries;
125 temporaries.reserve(cdcEventT0s.size());
126 for (
const auto& evtt0 : cdcEventT0s) {
127 if (evtt0.algorithm == algorithm) {
128 temporaries.push_back(evtt0);
139 const auto hitBasedCDCT0 = getCDCEventT0sForAlgorithm(
"hit based");
140 const auto chi2CDCT0 = getCDCEventT0sForAlgorithm(
"chi2");
141 const auto gridCDCT0 = getCDCEventT0sForAlgorithm(
"grid");
146 B2DEBUG(20,
"eventT0ECL = " << eventT0ECL <<
" ns") ;
147 B2DEBUG(20,
"eventT0CDC = " << eventT0CDC <<
" ns") ;
148 B2DEBUG(20,
"eventT0TOP = " << eventT0TOP <<
" ns") ;
149 B2DEBUG(20,
"eventT0SVD = " << eventT0SVD <<
" ns") ;
151 const bool hasECLEventT0 =
m_eventT0->hasTemporaryEventT0(Const::EDetector::ECL);
152 const bool hasSVDEventT0 =
m_eventT0->hasTemporaryEventT0(Const::EDetector::SVD);
153 const bool hasTOPEventT0 =
m_eventT0->hasTemporaryEventT0(Const::EDetector::TOP);
154 const bool hasCDCEventT0 =
m_eventT0->hasTemporaryEventT0(Const::EDetector::CDC);
155 const bool hasCDCHitBasedEventT0 = not hitBasedCDCT0.empty();
156 const bool hasCDCFullGridChi2EventT0 = not chi2CDCT0.empty();
157 const bool hasCDCGridEventT0 = not gridCDCT0.empty();
197 algorithmEffi->SetTitle(
"Efficiency of finding an EventT0 per Algorithm");
198 algorithmEffi->GetListOfFunctions()->Add(
new TNamed(
"Contact",
m_contact.c_str()));
199 algorithmEffi->GetListOfFunctions()->Add(
new TNamed(
"Description",
"Efficiencies of the various EventT0 algorithms."));
200 algorithmEffi->GetListOfFunctions()->Add(
new TNamed(
"Check",
"Efficiency should be close to 1 for all active algorithms."));
201 algorithmEffi->GetListOfFunctions()->Add(
new TNamed(
"MetaOptions",
"shifter"));
202 algorithmEffi->Write(
"EventT0AlgorithmEfficiency");
211 const std::string& contact,
const std::string& shifter)
213 hist->GetListOfFunctions()->Add(
new TNamed(
"Contact", contact.c_str()));
214 hist->GetListOfFunctions()->Add(
new TNamed(
"Description", description.c_str()));
215 hist->GetListOfFunctions()->Add(
new TNamed(
"Check", check.c_str()));
216 hist->GetListOfFunctions()->Add(
new TNamed(
"MetaOptions", shifter.c_str()));
TH1F * m_histTOPEventT0
TOP based EventT0 histograms.
TFile * m_outputFile
Output ROOT file.
virtual ~EventT0ValidationModule()
Destructor.
StoreObjPtr< EventT0 > m_eventT0
Store array for event t0.
TH1F * m_histCDCEventT0
CDC based EventT0 histograms.
std::string m_contact
For simplicity, just set the contact once.
virtual void initialize() override
Initialize the module.
TH1D * m_histAlgorithmSourceCounts
Count of events with EventT0 from a given algorithm, numerator for efficiency calculation.
virtual void event() override
This method is called for each event.
TH1F * m_histCDCHitBasedEventT0
CDC hit based EventT0 histograms.
TH1F * m_histCDCChi2EventT0
CDC chi2 based EventT0 histograms.
virtual void endRun() override
This method is called for each run.
TH1F * m_histCDCGridEventT0
CDC grid EventT0 histograms.
std::string m_RootFileName
Name of the output ROOT file.
TH1F * m_histECLEventT0
ECL based EventT0 histograms.
virtual void beginRun() override
This method is called for each run.
const char * c_eventT0Algorithms[11]
EventT0 algorithms for which to calculate fractions of abundance.
EventT0ValidationModule()
Default constructor.
TH1D * m_histAlgorithmSourceCountsActive
Counts of events with EventT0 from a given algorithm, denominator for efficiency calculation.
void setPlotMetaData(TH1 *hist, const std::string &description, const std::string &check, const std::string &contact, const std::string &shifter="shifter")
Set additional plot info: contact, description, shifter.
TH1F * m_histSVDEventT0
SVD based EventT0 histograms.
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...
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.
Abstract base class for different kinds of events.