41 input_col_, input_pass_name_)};
43 int ev_nb =
event.getEventNumber();
48 int num_chan = channels.size();
49 ldmx_log(debug) <<
"in event " << ev_nb <<
"; num_channels = " << num_chan;
51 for (
auto chan : channels) {
52 std::vector<float> q = chan.getQ();
53 std::vector<float> q_err = chan.getQError();
54 std::vector<int> tdc = chan.getTDC();
56 int bar = chan.getChanID();
58 float q_ped_subtracted_avg = 0;
59 int first_t = start_sample_ - 1;
61 int n_samp_above_event_ped = 0;
64 float ped = chan.getPedestal();
65 for (
int i_t = 0; i_t < q.size(); i_t++) {
66 ldmx_log(debug) <<
"in event " << ev_nb <<
"; channel " << bar
67 <<
", got charge[" << i_t <<
"] = " << q.at(i_t);
68 if (ev_nb < n_ev_tdc_ && bar < n_channels_) {
70 const bool display{ev_nb < n_ev_};
73 h_out_[ev_nb][bar]->SetBinContent(i_t + start_sample_, q.at(i_t));
74 h_out_[ev_nb][bar]->SetBinError(i_t + start_sample_,
77 if (tdc.at(i_t) < 63) {
78 ldmx_log(info) <<
"Found fired TDC = " << tdc.at(i_t)
79 <<
" at time sample " << i_t <<
" in channel " << bar
80 <<
" and event " << ev_nb;
83 h_out_[ev_nb][bar]->SetLineColor(kRed + 1);
84 h_out_[ev_nb][bar]->SetMarkerColor(
85 h_out_[ev_nb][bar]->GetLineColor());
86 h_out_[ev_nb][bar]->SetMarkerSize(0.2);
89 if (i_t + start_sample_ > 0)
90 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb, i_t + start_sample_);
92 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb);
95 if (q.at(i_t) > 2 * fabs(peds_[bar])) {
99 q_ped_subtracted_avg += q.at(i_t) - chan.getPedestal();
102 ldmx_log(debug) <<
" above channel overall pedestal: " << q.at(i_t)
103 <<
" > " << 2 * fabs(peds_[bar]);
106 if (first_t == start_sample_ - 1) first_t = start_sample_ + i_t;
108 if (q.at(i_t) > ped) {
109 subtr_q += q.at(i_t) - peds_[bar];
110 n_samp_above_event_ped++;
111 ldmx_log(debug) <<
" above channel event pedestal: " << q.at(i_t)
115 float pe = q_tot * 6250. / gain_[bar];
116 subtr_pe = subtr_q * 6250. / gain_[bar];
117 h_tot_q_vs_ped_[bar]->Fill(ped, q_tot);
118 h_pe_[bar]->Fill(pe);
119 h_pe_vs_t_[bar]->Fill(first_t, pe);
120 if (n_samp_above > 0) {
121 q_ped_subtracted_avg /= n_samp_above;
122 h_ped_subtracted_avg_q_vs_t_[bar]->Fill(first_t, q_ped_subtracted_avg);
123 h_avg_q_vs_t_[bar]->Fill(first_t, q_tot / n_samp_above);
127 ldmx_log(debug) <<
"filling qTot histograms";
128 h_ped_subtracted_tot_q_vs_ped_[bar]->Fill(ped, subtr_q);
131 h_ped_subtracted_tot_q_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_q);
132 h_ped_subtracted_pe_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_pe);
133 h_ped_subtracted_pe_vs_t_[bar]->Fill(first_t, subtr_pe);
134 ldmx_log(debug) <<
" done filling qTot histograms";
141void QIEAnalyzer::onProcessStart() {
143 <<
"\n\n Process starts! My analyzer should do something -- like "
147 int n_time_samp = 68;
149 int n_p_ebins = 5 * p_emax;
150 float qmax = p_emax / (6250. / 4.e6);
152 int n_qbins = (qmax - qmin) / 4;
154 ldmx_log(debug) <<
"Setting up histograms... ";
156 for (
int i_b = 0; i_b < n_channels_; i_b++) {
157 h_pe_[i_b] =
new TH1F(Form(
"h_pe_chan%i", i_b), Form(
";PE, chan%i", i_b),
158 n_p_ebins, 0, p_emax);
159 h_pe_vs_t_[i_b] =
new TH2F(
160 Form(
"h_pe_vs_t__chan%i", i_b),
161 Form(
";First time sample above summing threshold;PE, chan%i", i_b),
162 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
163 h_ped_subtracted_avg_q_vs_t_[i_b] =
new TH2F(
164 Form(
"hPedSubtrAvgQvsT_chan%i", i_b),
165 Form(
";First time sample above threshold;Pedestal subtracted average "
168 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
170 h_ped_subtracted_tot_q_vs_ped_[i_b] =
171 new TH2F(Form(
"hPedSubtrTotQvsPed_chan%i", i_b),
172 Form(
";Channel event pedestal [fC];Event pedestal subtracted "
173 "total Q, chan%i [fC]",
175 1010, qmin, 1000, 10010, -10,
177 h_ped_subtracted_tot_q_vs_n_[i_b] =
178 new TH2F(Form(
"hPedSubtrTotQvsN_chan%i", i_b),
179 Form(
";Number of time samples added; Event pedestal "
180 "subtracted total Q, chan%i [fC]",
182 n_time_samp + 1, -1.5, n_time_samp - 0.5, 10010, -10, 10000);
183 h_tot_q_vs_ped_[i_b] =
new TH2F(
184 Form(
"h_tot_q_vs_ped__chan%i", i_b),
185 Form(
";Channel event pedestal [fC];Event total Q, chan%i [fC]", i_b),
186 1010, qmin, 1000, 10010, -10,
188 h_ped_subtracted_pe_vs_n_[i_b] =
new TH2F(
189 Form(
"hPedSubtrPEvsN_chan%i", i_b),
190 Form(
";Number of time samples above threshold;Pedestal "
191 "subtracted PE, chan%i [fC]",
193 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
194 h_ped_subtracted_pe_vs_t_[i_b] =
new TH2F(
195 Form(
"hPedSubtrPEvsT_chan%i", i_b),
196 Form(
";First time sample above threshold;Pedestal subtracted "
199 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
200 h_avg_q_vs_t_[i_b] =
new TH2F(
201 Form(
"h_avg_q_vs_t_chan%i", i_b),
202 Form(
";First time sample above threshold;Average Q, chan%i [fC]", i_b),
203 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
207 for (
int i_e = 0; i_e < n_ev_; i_e++) {
208 for (
int i_b = 0; i_b < n_channels_; i_b++) {
210 new TH1F(Form(
"hCharge_chan%i_ev%i", i_b, i_e),
211 Form(
";time sample; Q, channel %i, event %i [fC]", i_b, i_e),
212 n_time_samp, -0.5, n_time_samp - 0.5);
216 h_tdc_fire_chan_vs_event_ =
new TH2F(
217 "h_tdc_fire_chan_vs_event",
";channel with TDC < 63;event number",
218 n_channels_, -0.5, n_channels_ - 0.5, n_ev_tdc_, 0, n_ev_tdc_);
220 ldmx_log(debug) <<
"done setting up histograms";