34 input_col_, input_pass_name_)};
36 int ev_nb =
event.getEventNumber();
41 int num_chan = channels.size();
42 ldmx_log(debug) <<
"in event " << ev_nb <<
"; num_channels = " << num_chan;
44 for (
auto chan : channels) {
45 std::vector<float> q = chan.getQ();
46 std::vector<float> q_err = chan.getQError();
47 std::vector<int> tdc = chan.getTDC();
49 int bar = chan.getChanID();
51 float q_ped_subtracted_avg = 0;
52 int first_t = start_sample_ - 1;
54 int n_samp_above_event_ped = 0;
57 float ped = chan.getPedestal();
58 for (
int i_t = 0; i_t < q.size(); i_t++) {
59 ldmx_log(debug) <<
"in event " << ev_nb <<
"; channel " << bar
60 <<
", got charge[" << i_t <<
"] = " << q.at(i_t);
61 if (ev_nb < n_ev_ && bar < n_channels_) {
64 h_out_[ev_nb][bar]->SetBinContent(i_t + start_sample_, q.at(i_t));
65 h_out_[ev_nb][bar]->SetBinError(i_t + start_sample_,
67 if (tdc.at(i_t) < 63) {
68 ldmx_log(info) <<
"Found fired TDC = " << tdc.at(i_t)
69 <<
" at time sample " << i_t <<
" in channel " << bar
70 <<
" and event " << ev_nb;
72 h_out_[ev_nb][bar]->SetLineColor(kRed + 1);
73 h_out_[ev_nb][bar]->SetMarkerColor(
74 h_out_[ev_nb][bar]->GetLineColor());
75 h_out_[ev_nb][bar]->SetMarkerSize(0.2);
77 if (i_t + start_sample_ > 0)
78 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb, i_t + start_sample_);
80 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb);
83 if (q.at(i_t) > 2 * fabs(peds_[bar])) {
87 q_ped_subtracted_avg += q.at(i_t) - chan.getPedestal();
90 ldmx_log(debug) <<
" above channel overall pedestal: " << q.at(i_t)
91 <<
" > " << 2 * fabs(peds_[bar]);
94 if (first_t == start_sample_ - 1) first_t = start_sample_ + i_t;
96 if (q.at(i_t) > ped) {
97 subtr_q += q.at(i_t) - peds_[bar];
98 n_samp_above_event_ped++;
99 ldmx_log(debug) <<
" above channel event pedestal: " << q.at(i_t)
103 float pe = q_tot * 6250. / gain_[bar];
104 subtr_pe = subtr_q * 6250. / gain_[bar];
105 h_tot_q_vs_ped_[bar]->Fill(ped, q_tot);
106 h_pe_[bar]->Fill(pe);
107 h_pe_vs_t_[bar]->Fill(first_t, pe);
108 if (n_samp_above > 0) {
109 q_ped_subtracted_avg /= n_samp_above;
110 h_ped_subtracted_avg_q_vs_t_[bar]->Fill(first_t, q_ped_subtracted_avg);
111 h_avg_q_vs_t_[bar]->Fill(first_t, q_tot / n_samp_above);
115 ldmx_log(debug) <<
"filling qTot histograms";
116 h_ped_subtracted_tot_q_vs_ped_[bar]->Fill(ped, subtr_q);
119 h_ped_subtracted_tot_q_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_q);
120 h_ped_subtracted_pe_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_pe);
121 h_ped_subtracted_pe_vs_t_[bar]->Fill(first_t, subtr_pe);
122 ldmx_log(debug) <<
" done filling qTot histograms";
129void QIEAnalyzer::onProcessStart() {
131 <<
"\n\n Process starts! My analyzer should do something -- like "
135 int n_time_samp = 68;
137 int n_p_ebins = 5 * p_emax;
138 float qmax = p_emax / (6250. / 4.e6);
140 int n_qbins = (qmax - qmin) / 4;
142 ldmx_log(debug) <<
"Setting up histograms... ";
144 for (
int i_b = 0; i_b < n_channels_; i_b++) {
145 h_pe_[i_b] =
new TH1F(Form(
"h_pe_chan%i", i_b), Form(
";PE, chan%i", i_b),
146 n_p_ebins, 0, p_emax);
147 h_pe_vs_t_[i_b] =
new TH2F(
148 Form(
"h_pe_vs_t__chan%i", i_b),
149 Form(
";First time sample above summing threshold;PE, chan%i", i_b),
150 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
151 h_ped_subtracted_avg_q_vs_t_[i_b] =
new TH2F(
152 Form(
"hPedSubtrAvgQvsT_chan%i", i_b),
153 Form(
";First time sample above threshold;Pedestal subtracted average "
156 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
158 h_ped_subtracted_tot_q_vs_ped_[i_b] =
159 new TH2F(Form(
"hPedSubtrTotQvsPed_chan%i", i_b),
160 Form(
";Channel event pedestal [fC];Event pedestal subtracted "
161 "total Q, chan%i [fC]",
163 1010, qmin, 1000, 10010, -10,
165 h_ped_subtracted_tot_q_vs_n_[i_b] =
166 new TH2F(Form(
"hPedSubtrTotQvsN_chan%i", i_b),
167 Form(
";Number of time samples added; Event pedestal "
168 "subtracted total Q, chan%i [fC]",
170 n_time_samp + 1, -1.5, n_time_samp - 0.5, 10010, -10, 10000);
171 h_tot_q_vs_ped_[i_b] =
new TH2F(
172 Form(
"h_tot_q_vs_ped__chan%i", i_b),
173 Form(
";Channel event pedestal [fC];Event total Q, chan%i [fC]", i_b),
174 1010, qmin, 1000, 10010, -10,
176 h_ped_subtracted_pe_vs_n_[i_b] =
new TH2F(
177 Form(
"hPedSubtrPEvsN_chan%i", i_b),
178 Form(
";Number of time samples above threshold;Pedestal "
179 "subtracted PE, chan%i [fC]",
181 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
182 h_ped_subtracted_pe_vs_t_[i_b] =
new TH2F(
183 Form(
"hPedSubtrPEvsT_chan%i", i_b),
184 Form(
";First time sample above threshold;Pedestal subtracted "
187 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
188 h_avg_q_vs_t_[i_b] =
new TH2F(
189 Form(
"h_avg_q_vs_t_chan%i", i_b),
190 Form(
";First time sample above threshold;Average Q, chan%i [fC]", i_b),
191 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
195 for (
int i_e = 0; i_e < n_ev_; i_e++) {
196 for (
int i_b = 0; i_b < n_channels_; i_b++) {
198 new TH1F(Form(
"hCharge_chan%i_ev%i", i_b, i_e),
199 Form(
";time sample; Q, channel %i, event %i [fC]", i_b, i_e),
200 n_time_samp, -0.5, n_time_samp - 0.5);
204 h_tdc_fire_chan_vs_event_ =
new TH2F(
205 "h_tdc_fire_chan_vs_event",
";channel with TDC < 63;event number",
206 n_channels_, -0.5, n_channels_ - 0.5, n_ev_, 0, n_ev_);
208 ldmx_log(debug) <<
"done setting up histograms";