36 int evNb =
event.getEventNumber();
41 int nChan = channels.size();
42 ldmx_log(debug) <<
"in event " << evNb <<
"; nChannels = " << nChan;
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();
49 int bar = chan.getChanID();
51 float qPedSubtractedAvg = 0;
52 int firstT = startSample_ - 1;
54 int nSampAboveEventPed = 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);
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;
71 hOut[evNb][bar]->SetLineColor(kRed + 1);
72 hOut[evNb][bar]->SetMarkerColor(hOut[evNb][bar]->GetLineColor());
73 hOut[evNb][bar]->SetMarkerSize(0.2);
75 if (iT + startSample_ > 0)
76 hTDCfireChanvsEvent->Fill(bar, evNb, iT + startSample_);
78 hTDCfireChanvsEvent->Fill(bar, evNb);
81 if (q.at(iT) > 2 * fabs(peds_[bar])) {
84 qPedSubtractedAvg += q.at(iT) - chan.getPedestal();
86 ldmx_log(debug) <<
" above channel overall pedestal: " << q.at(iT)
87 <<
" > " << 2 * fabs(peds_[bar]);
90 if (firstT == startSample_ - 1) firstT = startSample_ + iT;
93 subtrQ += q.at(iT) - peds_[bar];
95 ldmx_log(debug) <<
" above channel event pedestal: " << q.at(iT)
99 float PE = qTot * 6250. / gain_[bar];
100 subtrPE = subtrQ * 6250. / gain_[bar];
101 hTotQvsPed[bar]->Fill(ped, qTot);
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);
111 ldmx_log(debug) <<
"filling qTot histograms";
112 hPedSubtractedTotQvsPed[bar]->Fill(ped, subtrQ);
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";
125void QIEAnalyzer::onProcessStart() {
126 std::cout <<
"\n\n Process starts! My analyzer should do something -- like "
133 int nPEbins = 5 * PEmax;
134 float Qmax = PEmax / (6250. / 4.e6);
136 int nQbins = (Qmax - Qmin) / 4;
138 ldmx_log(debug) <<
"Setting up histograms... ";
140 for (
int iB = 0; iB < nChannels; iB++) {
141 hPE[iB] =
new TH1F(Form(
"hPE_chan%i", iB), Form(
";PE, chan%i", iB), nPEbins,
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 "
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]",
158 1010, Qmin, 1000, 10010, -10,
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]",
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,
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]",
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 "
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);
189 for (
int iE = 0; iE < nEv; iE++) {
190 for (
int iB = 0; iB < nChannels; 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);
198 hTDCfireChanvsEvent =
199 new TH2F(
"hTDCfireChanvsEvent",
";channel with TDC < 63;event number",
200 nChannels, -0.5, nChannels - 0.5, nEv, 0, nEv);
202 ldmx_log(debug) <<
"done setting up histograms";