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

Public Member Functions

 QIEAnalyzer (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.
 
float convertToID (float yVal)
 
- 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 inputCol_
 
std::string inputPassName_ {""}
 
std::vector< double > peds_
 
std::vector< double > gain_
 
int startSample_ {0}
 
int nEv {200}
 
int nChannels {16}
 
TH1F * hOut [200][16]
 
TH1F * hPE [16]
 
TH2F * hPEvsT [16]
 
TH2F * hPedSubtractedAvgQvsT [16]
 
TH2F * hPedSubtractedTotQvsPed [16]
 
TH2F * hPedSubtractedTotQvsN [16]
 
TH2F * hTotQvsPed [16]
 
TH2F * hPedSubtractedPEvsN [16]
 
TH2F * hPedSubtractedPEvsT [16]
 
TH2F * hAvgQvsT [16]
 
TH2F * hTDCfireChanvsEvent
 
double yOffset_ {35.}
 
double yToIDfactor_ {50. / 80.}
 

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 23 of file QIEAnalyzer.h.

Constructor & Destructor Documentation

◆ QIEAnalyzer()

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

Definition at line 12 of file QIEAnalyzer.cxx.

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

Member Function Documentation

◆ analyze()

void trigscint::QIEAnalyzer::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 32 of file QIEAnalyzer.cxx.

32 {
33 const auto channels{
34 event.getCollection<trigscint::EventReadout>(inputCol_, inputPassName_)};
35
36 int evNb = event.getEventNumber();
37 // while (evNb < 0 ) {
38 // ldmx_log(debug) << "event number = " << evNb << " < 0; incrementing event
39 // number "; evNb++;
40 //}
41 int nChan = channels.size();
42 ldmx_log(debug) << "in event " << evNb << "; nChannels = " << nChan;
43
44 for (auto chan : channels) {
45 std::vector<float> q = chan.getQ();
46 std::vector<float> qErr = chan.getQError();
47 std::vector<int> tdc = chan.getTDC();
48 // int nTimeSamp = q.size();
49 int bar = chan.getChanID();
50 float qTot = 0;
51 float qPedSubtractedAvg = 0;
52 int firstT = startSample_ - 1;
53 int nSampAbove = 0;
54 int nSampAboveEventPed = 0;
55 float subtrPE = 0;
56 float subtrQ = 0;
57 float ped = chan.getPedestal();
58 for (int iT = 0; iT < q.size(); iT++) {
59 ldmx_log(debug) << "in event " << evNb << "; channel " << bar
60 << ", got charge[" << iT << "] = " << q.at(iT);
61 if (evNb < nEv &&
62 bar < nChannels) { // stick within the predefined histogram array
63 // hOut[evNb][bar]->Fill(iT+startSample_, q.at(iT));
64 hOut[evNb][bar]->SetBinContent(iT + startSample_, q.at(iT));
65 hOut[evNb][bar]->SetBinError(iT + startSample_, fabs(qErr.at(iT)));
66 if (tdc.at(iT) < 63) {
67 ldmx_log(info) << "Found fired TDC = " << tdc.at(iT)
68 << " at time sample " << iT << " in channel " << bar
69 << " and event " << evNb;
70 // for some reason, the style settings are washed out later...
71 hOut[evNb][bar]->SetLineColor(kRed + 1);
72 hOut[evNb][bar]->SetMarkerColor(hOut[evNb][bar]->GetLineColor());
73 hOut[evNb][bar]->SetMarkerSize(0.2);
74
75 if (iT + startSample_ > 0)
76 hTDCfireChanvsEvent->Fill(bar, evNb, iT + startSample_);
77 else
78 hTDCfireChanvsEvent->Fill(bar, evNb);
79 }
80 } // if within the number of events to plot individually
81 if (q.at(iT) > 2 * fabs(peds_[bar])) { // integrate all charge well above
82 // ped to convert to a PE count
83 qTot += q.at(iT);
84 qPedSubtractedAvg += q.at(iT) - chan.getPedestal(); // peds_[ bar ];
85 nSampAbove++;
86 ldmx_log(debug) << " above channel overall pedestal: " << q.at(iT)
87 << " > " << 2 * fabs(peds_[bar]);
88
89 // keep track of first time sample above threshold
90 if (firstT == startSample_ - 1) firstT = startSample_ + iT;
91 } // if above threshold
92 if (q.at(iT) > ped) {
93 subtrQ += q.at(iT) - peds_[bar];
94 nSampAboveEventPed++;
95 ldmx_log(debug) << " above channel event pedestal: " << q.at(iT)
96 << " > " << ped;
97 } // if above channel event pedestal
98 } // over time samples
99 float PE = qTot * 6250. / gain_[bar];
100 subtrPE = subtrQ * 6250. / gain_[bar];
101 hTotQvsPed[bar]->Fill(ped, qTot);
102 hPE[bar]->Fill(PE);
103 hPEvsT[bar]->Fill(firstT, PE);
104 if (nSampAbove > 0) {
105 qPedSubtractedAvg /= nSampAbove;
106 hPedSubtractedAvgQvsT[bar]->Fill(firstT, qPedSubtractedAvg);
107 hAvgQvsT[bar]->Fill(firstT, qTot / nSampAbove);
108 }
109 // if (chan.getPedestal() < 40. ) {
110 // subtrQ = subtrPE/(6250./4.e6); //undo conversion
111 ldmx_log(debug) << "filling qTot histograms";
112 hPedSubtractedTotQvsPed[bar]->Fill(ped, subtrQ);
113 if (ped < 40) // avoid case where we have saturation and a plateau as much
114 // as possible
115 hPedSubtractedTotQvsN[bar]->Fill(nSampAboveEventPed, subtrQ);
116 hPedSubtractedPEvsN[bar]->Fill(nSampAboveEventPed, subtrPE);
117 hPedSubtractedPEvsT[bar]->Fill(firstT, subtrPE);
118 ldmx_log(debug) << " done filling qTot histograms";
119 // }
120 } // over channels
121
122 return;
123}
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).

◆ configure()

void trigscint::QIEAnalyzer::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 15 of file QIEAnalyzer.cxx.

15 {
16 inputCol_ = parameters.getParameter<std::string>("inputCollection");
17 inputPassName_ = parameters.getParameter<std::string>("inputPassName");
18 peds_ = parameters.getParameter<std::vector<double> >("pedestals");
19 gain_ = parameters.getParameter<std::vector<double> >("gain");
20 startSample_ = parameters.getParameter<int>("startSample");
21
22 std::cout << " [ QIEAnalyzer ] In configure(), got parameters "
23 << "\n\t inputCollection = " << inputCol_
24 << "\n\t inputPassName = " << inputPassName_
25 << "\n\t startSample = " << startSample_
26 << "\n\t pedestals[0] = " << peds_[0]
27 << "\n\t gain[0] = " << gain_[0] << "\t." << std::endl;
28
29 return;
30}
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89

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

◆ convertToID()

float trigscint::QIEAnalyzer::convertToID ( float  yVal)
inline

Definition at line 37 of file QIEAnalyzer.h.

37{ return (yVal + yOffset_) * yToIDfactor_; }

◆ onProcessEnd()

void trigscint::QIEAnalyzer::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 207 of file QIEAnalyzer.cxx.

207{ return; }

◆ onProcessStart()

void trigscint::QIEAnalyzer::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 125 of file QIEAnalyzer.cxx.

125 {
126 std::cout << "\n\n Process starts! My analyzer should do something -- like "
127 "print this \n\n"
128 << std::endl;
130
131 int nTimeSamp = 40;
132 int PEmax = 100;
133 int nPEbins = 5 * PEmax;
134 float Qmax = PEmax / (6250. / 4.e6);
135 float Qmin = -10;
136 int nQbins = (Qmax - Qmin) / 4;
137
138 ldmx_log(debug) << "Setting up histograms... ";
139
140 for (int iB = 0; iB < nChannels; iB++) {
141 hPE[iB] = new TH1F(Form("hPE_chan%i", iB), Form(";PE, chan%i", iB), nPEbins,
142 0, PEmax);
143 hPEvsT[iB] = new TH2F(
144 Form("hPEvsT_chan%i", iB),
145 Form(";First time sample above summing threshold;PE, chan%i", iB),
146 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, nPEbins, 0, PEmax);
147 hPedSubtractedAvgQvsT[iB] = new TH2F(
148 Form("hPedSubtrAvgQvsT_chan%i", iB),
149 Form(";First time sample above threshold;Pedestal subtracted average "
150 "Q, chan%i [fC]",
151 iB),
152 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, nQbins / 10, Qmin, Qmax / 10.);
153 hPedSubtractedTotQvsPed[iB] =
154 new TH2F(Form("hPedSubtrTotQvsPed_chan%i", iB),
155 Form(";Channel event pedestal [fC];Event pedestal subtracted "
156 "total Q, chan%i [fC]",
157 iB),
158 1010, Qmin, 1000, 10010, -10,
159 10000); // nQbins/2,Qmin,Qmax/5., nQbins,Qmin,2*Qmax);
160 hPedSubtractedTotQvsN[iB] =
161 new TH2F(Form("hPedSubtrTotQvsN_chan%i", iB),
162 Form(";Number of time samples added; Event pedestal "
163 "subtracted total Q, chan%i [fC]",
164 iB),
165 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, 10010, -10, 10000);
166 hTotQvsPed[iB] = new TH2F(
167 Form("hTotQvsPed_chan%i", iB),
168 Form(";Channel event pedestal [fC];Event total Q, chan%i [fC]", iB),
169 1010, Qmin, 1000, 10010, -10,
170 10000); // nQbins/2,Qmin,Qmax/5., nQbins,Qmin,2*Qmax);
171 hPedSubtractedPEvsN[iB] =
172 new TH2F(Form("hPedSubtrPEvsN_chan%i", iB),
173 Form(";Number of time samples above threshold;Pedestal "
174 "subtracted PE, chan%i [fC]",
175 iB),
176 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, nPEbins, 0, PEmax);
177 hPedSubtractedPEvsT[iB] =
178 new TH2F(Form("hPedSubtrPEvsT_chan%i", iB),
179 Form(";First time sample above threshold;Pedestal subtracted "
180 "PE, chan%i [fC]",
181 iB),
182 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, nPEbins, 0, PEmax);
183 hAvgQvsT[iB] = new TH2F(
184 Form("hAvgQvsT_chan%i", iB),
185 Form(";First time sample above threshold;Average Q, chan%i [fC]", iB),
186 nTimeSamp + 1, -1.5, nTimeSamp - 0.5, nQbins / 10, Qmin, Qmax / 10);
187 }
188
189 for (int iE = 0; iE < nEv; iE++) {
190 for (int iB = 0; iB < nChannels; iB++) {
191 hOut[iE][iB] =
192 new TH1F(Form("hCharge_chan%i_ev%i", iB, iE),
193 Form(";time sample; Q, channel %i, event %i [fC]", iB, iE),
194 nTimeSamp, -0.5, nTimeSamp - 0.5);
195 }
196 }
197
198 hTDCfireChanvsEvent =
199 new TH2F("hTDCfireChanvsEvent", ";channel with TDC < 63;event number",
200 nChannels, -0.5, nChannels - 0.5, nEv, 0, nEv);
201
202 ldmx_log(debug) << "done setting up histograms";
203
204 return;
205}
TDirectory * getHistoDirectory()
Access/create a directory in the histogram file for this event processor to create histograms and ana...

Member Data Documentation

◆ gain_

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

Definition at line 46 of file QIEAnalyzer.h.

◆ hAvgQvsT

TH2F* trigscint::QIEAnalyzer::hAvgQvsT[16]
private

Definition at line 64 of file QIEAnalyzer.h.

◆ hOut

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

Definition at line 55 of file QIEAnalyzer.h.

◆ hPE

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

Definition at line 56 of file QIEAnalyzer.h.

◆ hPedSubtractedAvgQvsT

TH2F* trigscint::QIEAnalyzer::hPedSubtractedAvgQvsT[16]
private

Definition at line 58 of file QIEAnalyzer.h.

◆ hPedSubtractedPEvsN

TH2F* trigscint::QIEAnalyzer::hPedSubtractedPEvsN[16]
private

Definition at line 62 of file QIEAnalyzer.h.

◆ hPedSubtractedPEvsT

TH2F* trigscint::QIEAnalyzer::hPedSubtractedPEvsT[16]
private

Definition at line 63 of file QIEAnalyzer.h.

◆ hPedSubtractedTotQvsN

TH2F* trigscint::QIEAnalyzer::hPedSubtractedTotQvsN[16]
private

Definition at line 60 of file QIEAnalyzer.h.

◆ hPedSubtractedTotQvsPed

TH2F* trigscint::QIEAnalyzer::hPedSubtractedTotQvsPed[16]
private

Definition at line 59 of file QIEAnalyzer.h.

◆ hPEvsT

TH2F* trigscint::QIEAnalyzer::hPEvsT[16]
private

Definition at line 57 of file QIEAnalyzer.h.

◆ hTDCfireChanvsEvent

TH2F* trigscint::QIEAnalyzer::hTDCfireChanvsEvent
private

Definition at line 66 of file QIEAnalyzer.h.

◆ hTotQvsPed

TH2F* trigscint::QIEAnalyzer::hTotQvsPed[16]
private

Definition at line 61 of file QIEAnalyzer.h.

◆ inputCol_

std::string trigscint::QIEAnalyzer::inputCol_
private

Definition at line 43 of file QIEAnalyzer.h.

◆ inputPassName_

std::string trigscint::QIEAnalyzer::inputPassName_ {""}
private

Definition at line 44 of file QIEAnalyzer.h.

44{""};

◆ nChannels

int trigscint::QIEAnalyzer::nChannels {16}
private

Definition at line 51 of file QIEAnalyzer.h.

51{16};

◆ nEv

int trigscint::QIEAnalyzer::nEv {200}
private

Definition at line 50 of file QIEAnalyzer.h.

50{200};

◆ peds_

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

Definition at line 45 of file QIEAnalyzer.h.

◆ startSample_

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

Definition at line 47 of file QIEAnalyzer.h.

47{0};

◆ vChargeVsTime

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

Definition at line 40 of file QIEAnalyzer.h.

◆ yOffset_

double trigscint::QIEAnalyzer::yOffset_ {35.}
private

Definition at line 67 of file QIEAnalyzer.h.

67{35.};

◆ yToIDfactor_

double trigscint::QIEAnalyzer::yToIDfactor_ {50. / 80.}
private

Definition at line 68 of file QIEAnalyzer.h.

68{50. / 80.};

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