40 inputEventCol_, inputEventPassName_)};
42 inputHitCol_, inputHitPassName_)};
44 int evNb =
event.getEventNumber();
49 int nChan = channels.size();
50 ldmx_log(debug) <<
"in event " << evNb <<
"; nChannels = " << nChan;
52 bool existsIntermediatePE =
false;
53 float hitPEs[nChannels] = {0.};
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();
62 int bar = chan.getChanID();
64 int flag = chan.getQualityFlag();
67 for (
auto hit : hits) {
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;
76 ldmx_log(debug) <<
"Got event flag " << flag;
79 if (flag == 0 && evNb < nEv &&
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)));
92 if (flag == 0 && nEvDrawn[nFlags - 1] <
94 int fillNb = nEvDrawn[nFlags - 1];
95 for (
int iT = 0; iT < q.size(); iT++) {
96 hOutFlag[nFlags - 1][fillNb][bar]->SetBinContent(iT + startSample_,
98 hOutFlag[nFlags - 1][fillNb][bar]->SetBinError(iT + startSample_,
102 hOutFlag[nFlags - 1][fillNb][bar]->GetYaxis()->SetTitle(
103 Form(
"Q, flag 0, chan %i, ev %i [fC]", bar, evNb));
104 nEvDrawn[nFlags - 1]++;
107 for (
int iF = 0; iF < nFlags - 1; iF++) {
108 int fillNb = nEvDrawn[iF];
109 ldmx_log(debug) <<
"Checking flag " << flags[iF];
111 if (flag >= flags[iF]) {
112 ldmx_log(debug) <<
"Checking flag " << flags[iF];
115 for (
int iT = 0; iT < q.size(); iT++) {
117 hOutFlag[iF][fillNb][bar]->SetBinContent(iT + startSample_,
119 hOutFlag[iF][fillNb][bar]->SetBinError(iT + startSample_,
122 hOutFlag[iF][fillNb][bar]->GetYaxis()->SetTitle(
123 Form(
"Q, flag %i, chan %i, ev %i [fC]", flags[iF], bar, evNb));
133 if (existsIntermediatePE &&
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();
142 int bar = chan.getChanID();
143 for (
int iT = 0; iT < q.size(); iT++) {
144 hOutPE[peFillNb][bar]->SetBinContent(iT + startSample_, q.at(iT));
145 hOutPE[peFillNb][bar]->SetBinError(iT + startSample_,
148 hOutPE[peFillNb][bar]->GetYaxis()->SetTitle(
149 Form(
"Q, chan %i, ev %i, PE %.2f", bar, evNb, hitPEs[bar]));
157void QualityFlagAnalyzer::onProcessStart() {
158 std::cout <<
"\n\n Process starts! My analyzer should do something -- like "
165 int nPEbins = 5 * PEmax;
170 ldmx_log(debug) <<
"Setting up histograms... ";
172 for (
int iB = 0; iB < nChannels; iB++) {
173 hPE[iB] =
new TH1F(Form(
"hPE_chan%i", iB), Form(
";PE, chan%i", iB), nPEbins,
177 for (
int iE = 0; iE < nEv; iE++) {
178 for (
int iB = 0; iB < nChannels; 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);
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),
199 hTDCfireChanvsEvent =
200 new TH2F(
"hTDCfireChanvsEvent",
";channel with TDC < 63;event number",
201 nChannels, -0.5, nChannels - 0.5, nEv, 0, nEv);
204 ldmx_log(debug) <<
"done setting up histograms";