LDMX Software
Public Member Functions | Private Attributes | Static Private Attributes | List of all members
trigscint::QualityFlagAnalyzer Class Reference

Public Member Functions

 QualityFlagAnalyzer (const std::string &name, framework::Process &process)
 
void configure (framework::config::Parameters &parameters) override
 Callback for the EventProcessor to configure itself from the given set of parameters.
 
void analyze (const framework::Event &event) override
 Process the event and make histograms or summaries.
 
void onProcessStart () override
 Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.
 
void onProcessEnd () override
 Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.
 
- Public Member Functions inherited from framework::Analyzer
 Analyzer (const std::string &name, Process &process)
 Class constructor.
 
- Public Member Functions inherited from framework::EventProcessor
 EventProcessor (const std::string &name, Process &process)
 Class constructor.
 
virtual ~EventProcessor ()
 Class destructor.
 
virtual void onNewRun (const ldmx::RunHeader &runHeader)
 Callback for the EventProcessor to take any necessary action when the run being processed changes.
 
virtual void onFileOpen (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a new event input ROOT file is opened.
 
virtual void onFileClose (EventFile &eventFile)
 Callback for the EventProcessor to take any necessary action when a event input ROOT file is closed.
 
template<class T >
const T & getCondition (const std::string &condition_name)
 Access a conditions object for the current event.
 
TDirectory * getHistoDirectory ()
 Access/create a directory in the histogram file for this event processor to create histograms and analysis tuples.
 
void setStorageHint (framework::StorageControl::Hint hint)
 Mark the current event as having the given storage control hint from this module.
 
void setStorageHint (framework::StorageControl::Hint hint, const std::string &purposeString)
 Mark the current event as having the given storage control hint from this module and the given purpose string.
 
int getLogFrequency () const
 Get the current logging frequency from the process.
 
int getRunNumber () const
 Get the run number from the process.
 
std::string getName () const
 Get the processor name.
 
void createHistograms (const std::vector< framework::config::Parameters > &histos)
 Internal function which is used to create histograms passed from the python configuration @parma histos vector of Parameters that configure histograms to create.
 

Private Attributes

std::vector< std::vector< TH1F * > > vChargeVsTime
 
std::string inputEventCol_
 
std::string inputEventPassName_ {""}
 
std::string inputHitCol_
 
std::string inputHitPassName_ {""}
 
std::vector< double > peds_
 
std::vector< double > gain_
 
int startSample_ {0}
 
const int nEv {200}
 
const int nFlags {6}
 
int peFillNb {0}
 
const int flags [6]
 
int nEvDrawn [6] = {0}
 
TH1F * hOut [200][16]
 
TH1F * hOutPE [200][16]
 
TH1F * hOutFlag [6][200][16]
 
TH1F * hPE [16]
 
TH2F * hTDCfireChanvsEvent
 

Static Private Attributes

static constexpr int nChannels {16}
 

Additional Inherited Members

- Static Public Member Functions inherited from framework::EventProcessor
static void declare (const std::string &classname, int classtype, EventProcessorMaker *)
 Internal function which is part of the PluginFactory machinery.
 
- Static Public Attributes inherited from framework::Analyzer
static const int CLASSTYPE {2}
 Constant used to track EventProcessor types by the PluginFactory.
 
- Protected Member Functions inherited from framework::EventProcessor
void abortEvent ()
 Abort the event immediately.
 
- Protected Attributes inherited from framework::EventProcessor
HistogramHelper histograms_
 Interface class for making and filling histograms.
 
NtupleManagerntuple_ {NtupleManager::getInstance()}
 Manager for any ntuples.
 
logging::logger theLog_
 The logger for this EventProcessor.
 

Detailed Description

Definition at line 24 of file QualityFlagAnalyzer.h.

Constructor & Destructor Documentation

◆ QualityFlagAnalyzer()

trigscint::QualityFlagAnalyzer::QualityFlagAnalyzer ( const std::string &  name,
framework::Process process 
)

Definition at line 12 of file QualityFlagAnalyzer.cxx.

14 : Analyzer(name, process) {}
Analyzer(const std::string &name, Process &process)
Class constructor.

Member Function Documentation

◆ analyze()

void trigscint::QualityFlagAnalyzer::analyze ( const framework::Event event)
overridevirtual

Process the event and make histograms or summaries.

Parameters
eventThe Event to analyze

Implements framework::Analyzer.

Definition at line 38 of file QualityFlagAnalyzer.cxx.

38 {
39 const auto channels{event.getCollection<trigscint::EventReadout>(
40 inputEventCol_, inputEventPassName_)};
41 const auto hits{event.getCollection<trigscint::TestBeamHit>(
42 inputHitCol_, inputHitPassName_)};
43
44 int evNb = event.getEventNumber();
45 // while (evNb < 0 ) {
46 // ldmx_log(debug) << "event number = " << evNb << " < 0; incrementing event
47 // number "; evNb++;
48 //}
49 int nChan = channels.size();
50 ldmx_log(debug) << "in event " << evNb << "; nChannels = " << nChan;
51
52 bool existsIntermediatePE = false;
53 float hitPEs[nChannels] = {0.};
54
55 // ok. get each channel, and find the associated hit, using bar nb.
56
57 for (auto chan : channels) {
58 std::vector<float> q = chan.getQ();
59 std::vector<float> qErr = chan.getQError();
60 std::vector<int> tdc = chan.getTDC();
61 // int nTimeSamp = q.size();
62 int bar = chan.getChanID();
63
64 int flag = chan.getQualityFlag();
65
66 // check if this is messing up flag
67 for (auto hit : hits) { // we will be ok even if there is no match
68 if (hit.getBarID() == bar) { //
69 flag = hit.getQualityFlag();
70 hitPEs[bar] = hit.getPE();
71 if (flag == 0 && bar < 12 && 15 < hit.getPE() && hit.getPE() < 40)
72 existsIntermediatePE = true;
73 }
74 }
75
76 ldmx_log(debug) << "Got event flag " << flag;
77
78 // if flag = 0, fill for clean versions of the usual event displays
79 if (flag == 0 && evNb < nEv &&
80 bar < nChannels) { // stick within the predefined histogram array
81 for (int iT = 0; iT < q.size(); iT++) {
82 ldmx_log(debug) << "in event " << evNb << "; channel " << bar
83 << ", got charge[" << iT << "] = " << q.at(iT);
84 hOut[evNb][bar]->SetBinContent(iT + startSample_, q.at(iT));
85 hOut[evNb][bar]->SetBinError(iT + startSample_, fabs(qErr.at(iT)));
86 } // if within the number of events to plot individually
87 } // over time samples
88
89 // now select on flags
90 // special case: flag = 0 (this will happen to all eventually, so catch it
91 // now
92 if (flag == 0 && nEvDrawn[nFlags - 1] <
93 nEv) { // then draw if we haven't collected enough
94 int fillNb = nEvDrawn[nFlags - 1];
95 for (int iT = 0; iT < q.size(); iT++) { // fill this plot with all q
96 hOutFlag[nFlags - 1][fillNb][bar]->SetBinContent(iT + startSample_,
97 q.at(iT));
98 hOutFlag[nFlags - 1][fillNb][bar]->SetBinError(iT + startSample_,
99 fabs(qErr.at(iT)));
100 }
101 // keep track of actual event number
102 hOutFlag[nFlags - 1][fillNb][bar]->GetYaxis()->SetTitle(
103 Form("Q, flag 0, chan %i, ev %i [fC]", bar, evNb));
104 nEvDrawn[nFlags - 1]++; // update filled event counter for this flag (0)
105 } // if nothing was flagged
106 else { // hit was flagged somehow
107 for (int iF = 0; iF < nFlags - 1; iF++) { // do all but the last
108 int fillNb = nEvDrawn[iF];
109 ldmx_log(debug) << "Checking flag " << flags[iF];
110 // we're starting from the high numbers and iteratively subtracting
111 if (flag >= flags[iF]) {
112 ldmx_log(debug) << "Checking flag " << flags[iF];
113 if (fillNb < nEv) { // then 1. this flag must be raised 2. draw if we
114 // haven't collected enough
115 for (int iT = 0; iT < q.size(); iT++) { // fill this plot with all
116 // q
117 hOutFlag[iF][fillNb][bar]->SetBinContent(iT + startSample_,
118 q.at(iT));
119 hOutFlag[iF][fillNb][bar]->SetBinError(iT + startSample_,
120 fabs(qErr.at(iT)));
121 } // over time samples
122 hOutFlag[iF][fillNb][bar]->GetYaxis()->SetTitle(
123 Form("Q, flag %i, chan %i, ev %i [fC]", flags[iF], bar, evNb));
124 nEvDrawn[iF]++; // update filled event counter for this flag
125 }
126 flag -= flags[iF]; // subtract that flag from sum
127 } // if this flag
128 } // over flags
129 } // if any non-zero flag
130 } // over channels
131
132 // select 15 < PE < 40 events
133 if (existsIntermediatePE &&
134 peFillNb < nEv) { // then 1. this flag must be raised 2. draw if we
135 // haven't collected enough
136 ldmx_log(debug) << "Got at least one intermediate PE channel";
137 for (auto chan : channels) {
138 std::vector<float> q = chan.getQ();
139 std::vector<float> qErr = chan.getQError();
140 std::vector<int> tdc = chan.getTDC();
141 // int nTimeSamp = q.size();
142 int bar = chan.getChanID();
143 for (int iT = 0; iT < q.size(); iT++) { // fill this plot with all q
144 hOutPE[peFillNb][bar]->SetBinContent(iT + startSample_, q.at(iT));
145 hOutPE[peFillNb][bar]->SetBinError(iT + startSample_,
146 fabs(qErr.at(iT)));
147 } // over time samples
148 hOutPE[peFillNb][bar]->GetYaxis()->SetTitle(
149 Form("Q, chan %i, ev %i, PE %.2f", bar, evNb, hitPEs[bar]));
150 } // over channels
151 peFillNb++; // update filled event counter for this flag
152 } // if fill
153
154 return;
155}
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).
Definition TestBeamHit.h:24

◆ configure()

void trigscint::QualityFlagAnalyzer::configure ( framework::config::Parameters parameters)
overridevirtual

Callback for the EventProcessor to configure itself from the given set of parameters.

The parameters a processor has access to are the member variables of the python class in the sequence that has className equal to the EventProcessor class name.

For an example, look at MyProcessor.

Parameters
parametersParameters for configuration.

Reimplemented from framework::EventProcessor.

Definition at line 16 of file QualityFlagAnalyzer.cxx.

16 {
17 inputEventCol_ = parameters.getParameter<std::string>("inputEventCollection");
18 inputEventPassName_ =
19 parameters.getParameter<std::string>("inputEventPassName");
20 inputHitCol_ = parameters.getParameter<std::string>("inputHitCollection");
21 inputHitPassName_ = parameters.getParameter<std::string>("inputHitPassName");
22 peds_ = parameters.getParameter<std::vector<double> >("pedestals");
23 gain_ = parameters.getParameter<std::vector<double> >("gain");
24 startSample_ = parameters.getParameter<int>("startSample");
25
26 std::cout << " [ QualityFlagAnalyzer ] In configure(), got parameters "
27 << "\n\t inputEventCollection = " << inputEventCol_
28 << "\n\t inputEventPassName = " << inputEventPassName_
29 << "\n\t inputHitCollection = " << inputHitCol_
30 << "\n\t inputHitPassName = " << inputHitPassName_
31 << "\n\t startSample = " << startSample_
32 << "\n\t pedestals[0] = " << peds_[0]
33 << "\n\t gain[0] = " << gain_[0] << "\t." << std::endl;
34
35 return;
36}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89

References framework::config::Parameters::getParameter().

◆ onProcessEnd()

void trigscint::QualityFlagAnalyzer::onProcessEnd ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events finishes, such as calculating job-summary quantities.

Reimplemented from framework::EventProcessor.

Definition at line 209 of file QualityFlagAnalyzer.cxx.

209{ return; }

◆ onProcessStart()

void trigscint::QualityFlagAnalyzer::onProcessStart ( )
overridevirtual

Callback for the EventProcessor to take any necessary action when the processing of events starts, such as creating histograms.

Reimplemented from framework::EventProcessor.

Definition at line 157 of file QualityFlagAnalyzer.cxx.

157 {
158 std::cout << "\n\n Process starts! My analyzer should do something -- like "
159 "print this \n\n"
160 << std::endl;
162
163 int nTimeSamp = 40;
164 int PEmax = 100;
165 int nPEbins = 5 * PEmax;
166 // float Qmax = PEmax / (6250. / 4.e6);
167 // float Qmin = -10;
168 // int nQbins = (Qmax - Qmin) / 4;
169
170 ldmx_log(debug) << "Setting up histograms... ";
171
172 for (int iB = 0; iB < nChannels; iB++) {
173 hPE[iB] = new TH1F(Form("hPE_chan%i", iB), Form(";PE, chan%i", iB), nPEbins,
174 0, PEmax);
175 }
176
177 for (int iE = 0; iE < nEv; iE++) {
178 for (int iB = 0; iB < nChannels; iB++) {
179 hOut[iE][iB] =
180 new TH1F(Form("hCharge_chan%i_ev%i", iB, iE),
181 Form(";time sample; Q, channel %i, event %i [fC]", iB, iE),
182 nTimeSamp, -0.5, nTimeSamp - 0.5);
183 hOutPE[iE][iB] =
184 new TH1F(Form("hCharge_PEcut_chan%i_nb%i", iB, iE),
185 Form(";time sample; Q, channel %i, event %i [fC]", iB, iE),
186 nTimeSamp, -0.5, nTimeSamp - 0.5);
187 for (int iF = 0; iF < nFlags; iF++) {
188 hOutFlag[iF][iE][iB] = new TH1F(
189 Form("hCharge_flag%i_chan%i_nb%i", flags[iF], iB, iE),
190 Form(";time sample; Q, flag %i, chan %i, ev %i [fC]", iF, iB, iE),
191 nTimeSamp, -0.5,
192 nTimeSamp - 0.5); // less confusing to name them upon actual use
193 // hOutFlag[iF][iE][iB] = new TH1F("hCharge_flag", "",
194 // nTimeSamp,-0.5,nTimeSamp-0.5);
195 }
196 }
197 }
198
199 hTDCfireChanvsEvent =
200 new TH2F("hTDCfireChanvsEvent", ";channel with TDC < 63;event number",
201 nChannels, -0.5, nChannels - 0.5, nEv, 0, nEv);
202
203 peFillNb = 0;
204 ldmx_log(debug) << "done setting up histograms";
205
206 return;
207}
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...

Member Data Documentation

◆ flags

const int trigscint::QualityFlagAnalyzer::flags[6]
private
Initial value:
= {16, 8, 4,
2, 1, 0}

Definition at line 57 of file QualityFlagAnalyzer.h.

57 {16, 8, 4,
58 2, 1, 0}; // this order just makes looping easier

◆ gain_

std::vector<double> trigscint::QualityFlagAnalyzer::gain_
private

Definition at line 47 of file QualityFlagAnalyzer.h.

◆ hOut

TH1F* trigscint::QualityFlagAnalyzer::hOut[200][16]
private

Definition at line 60 of file QualityFlagAnalyzer.h.

◆ hOutFlag

TH1F* trigscint::QualityFlagAnalyzer::hOutFlag[6][200][16]
private

Definition at line 62 of file QualityFlagAnalyzer.h.

◆ hOutPE

TH1F* trigscint::QualityFlagAnalyzer::hOutPE[200][16]
private

Definition at line 61 of file QualityFlagAnalyzer.h.

◆ hPE

TH1F* trigscint::QualityFlagAnalyzer::hPE[16]
private

Definition at line 63 of file QualityFlagAnalyzer.h.

◆ hTDCfireChanvsEvent

TH2F* trigscint::QualityFlagAnalyzer::hTDCfireChanvsEvent
private

Definition at line 65 of file QualityFlagAnalyzer.h.

◆ inputEventCol_

std::string trigscint::QualityFlagAnalyzer::inputEventCol_
private

Definition at line 42 of file QualityFlagAnalyzer.h.

◆ inputEventPassName_

std::string trigscint::QualityFlagAnalyzer::inputEventPassName_ {""}
private

Definition at line 43 of file QualityFlagAnalyzer.h.

43{""};

◆ inputHitCol_

std::string trigscint::QualityFlagAnalyzer::inputHitCol_
private

Definition at line 44 of file QualityFlagAnalyzer.h.

◆ inputHitPassName_

std::string trigscint::QualityFlagAnalyzer::inputHitPassName_ {""}
private

Definition at line 45 of file QualityFlagAnalyzer.h.

45{""};

◆ nChannels

constexpr int trigscint::QualityFlagAnalyzer::nChannels {16}
staticconstexprprivate

Definition at line 52 of file QualityFlagAnalyzer.h.

52{16};

◆ nEv

const int trigscint::QualityFlagAnalyzer::nEv {200}
private

Definition at line 51 of file QualityFlagAnalyzer.h.

51{200};

◆ nEvDrawn

int trigscint::QualityFlagAnalyzer::nEvDrawn[6] = {0}
private

Definition at line 59 of file QualityFlagAnalyzer.h.

59{0}; // keep a counter for each flag type to get good stats

◆ nFlags

const int trigscint::QualityFlagAnalyzer::nFlags {6}
private

Definition at line 53 of file QualityFlagAnalyzer.h.

53{6};

◆ peds_

std::vector<double> trigscint::QualityFlagAnalyzer::peds_
private

Definition at line 46 of file QualityFlagAnalyzer.h.

◆ peFillNb

int trigscint::QualityFlagAnalyzer::peFillNb {0}
private

Definition at line 54 of file QualityFlagAnalyzer.h.

54{0};

◆ startSample_

int trigscint::QualityFlagAnalyzer::startSample_ {0}
private

Definition at line 48 of file QualityFlagAnalyzer.h.

48{0};

◆ vChargeVsTime

std::vector<std::vector<TH1F*> > trigscint::QualityFlagAnalyzer::vChargeVsTime
private

Definition at line 39 of file QualityFlagAnalyzer.h.


The documentation for this class was generated from the following files: