38 input_col_, input_pass_name_)};
40 int ev_nb =
event.getEventNumber();
45 int num_chan = channels.size();
46 ldmx_log(debug) <<
"in event " << ev_nb <<
"; num_channels = " << num_chan;
48 for (
auto chan : channels) {
49 std::vector<float> q = chan.getQ();
50 std::vector<float> q_err = chan.getQError();
51 std::vector<int> tdc = chan.getTDC();
53 int bar = chan.getChanID();
55 float q_ped_subtracted_avg = 0;
56 int first_t = start_sample_ - 1;
58 int n_samp_above_event_ped = 0;
61 float ped = chan.getPedestal();
62 for (
int i_t = 0; i_t < q.size(); i_t++) {
63 ldmx_log(debug) <<
"in event " << ev_nb <<
"; channel " << bar
64 <<
", got charge[" << i_t <<
"] = " << q.at(i_t);
65 if (ev_nb < n_ev_tdc_ && bar < n_channels_) {
67 const bool display{ev_nb < n_ev_};
70 h_out_[ev_nb][bar]->SetBinContent(i_t + start_sample_, q.at(i_t));
71 h_out_[ev_nb][bar]->SetBinError(i_t + start_sample_,
74 if (tdc.at(i_t) < 63) {
75 ldmx_log(info) <<
"Found fired TDC = " << tdc.at(i_t)
76 <<
" at time sample " << i_t <<
" in channel " << bar
77 <<
" and event " << ev_nb;
80 h_out_[ev_nb][bar]->SetLineColor(kRed + 1);
81 h_out_[ev_nb][bar]->SetMarkerColor(
82 h_out_[ev_nb][bar]->GetLineColor());
83 h_out_[ev_nb][bar]->SetMarkerSize(0.2);
86 if (i_t + start_sample_ > 0)
87 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb, i_t + start_sample_);
89 h_tdc_fire_chan_vs_event_->Fill(bar, ev_nb);
92 if (q.at(i_t) > 2 * fabs(peds_[bar])) {
96 q_ped_subtracted_avg += q.at(i_t) - chan.getPedestal();
99 ldmx_log(debug) <<
" above channel overall pedestal: " << q.at(i_t)
100 <<
" > " << 2 * fabs(peds_[bar]);
103 if (first_t == start_sample_ - 1) first_t = start_sample_ + i_t;
105 if (q.at(i_t) > ped) {
106 subtr_q += q.at(i_t) - peds_[bar];
107 n_samp_above_event_ped++;
108 ldmx_log(debug) <<
" above channel event pedestal: " << q.at(i_t)
112 float pe = q_tot * 6250. / gain_[bar];
113 subtr_pe = subtr_q * 6250. / gain_[bar];
114 h_tot_q_vs_ped_[bar]->Fill(ped, q_tot);
115 h_pe_[bar]->Fill(pe);
116 h_pe_vs_t_[bar]->Fill(first_t, pe);
117 if (n_samp_above > 0) {
118 q_ped_subtracted_avg /= n_samp_above;
119 h_ped_subtracted_avg_q_vs_t_[bar]->Fill(first_t, q_ped_subtracted_avg);
120 h_avg_q_vs_t_[bar]->Fill(first_t, q_tot / n_samp_above);
124 ldmx_log(debug) <<
"filling qTot histograms";
125 h_ped_subtracted_tot_q_vs_ped_[bar]->Fill(ped, subtr_q);
128 h_ped_subtracted_tot_q_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_q);
129 h_ped_subtracted_pe_vs_n_[bar]->Fill(n_samp_above_event_ped, subtr_pe);
130 h_ped_subtracted_pe_vs_t_[bar]->Fill(first_t, subtr_pe);
131 ldmx_log(debug) <<
" done filling qTot histograms";
138void QIEAnalyzer::onProcessStart() {
140 <<
"\n\n Process starts! My analyzer should do something -- like "
144 int n_time_samp = 68;
146 int n_p_ebins = 5 * p_emax;
147 float qmax = p_emax / (6250. / 4.e6);
149 int n_qbins = (qmax - qmin) / 4;
151 ldmx_log(debug) <<
"Setting up histograms... ";
153 for (
int i_b = 0; i_b < n_channels_; i_b++) {
154 h_pe_[i_b] =
new TH1F(Form(
"h_pe_chan%i", i_b), Form(
";PE, chan%i", i_b),
155 n_p_ebins, 0, p_emax);
156 h_pe_vs_t_[i_b] =
new TH2F(
157 Form(
"h_pe_vs_t__chan%i", i_b),
158 Form(
";First time sample above summing threshold;PE, chan%i", i_b),
159 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
160 h_ped_subtracted_avg_q_vs_t_[i_b] =
new TH2F(
161 Form(
"hPedSubtrAvgQvsT_chan%i", i_b),
162 Form(
";First time sample above threshold;Pedestal subtracted average "
165 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
167 h_ped_subtracted_tot_q_vs_ped_[i_b] =
168 new TH2F(Form(
"hPedSubtrTotQvsPed_chan%i", i_b),
169 Form(
";Channel event pedestal [fC];Event pedestal subtracted "
170 "total Q, chan%i [fC]",
172 1010, qmin, 1000, 10010, -10,
174 h_ped_subtracted_tot_q_vs_n_[i_b] =
175 new TH2F(Form(
"hPedSubtrTotQvsN_chan%i", i_b),
176 Form(
";Number of time samples added; Event pedestal "
177 "subtracted total Q, chan%i [fC]",
179 n_time_samp + 1, -1.5, n_time_samp - 0.5, 10010, -10, 10000);
180 h_tot_q_vs_ped_[i_b] =
new TH2F(
181 Form(
"h_tot_q_vs_ped__chan%i", i_b),
182 Form(
";Channel event pedestal [fC];Event total Q, chan%i [fC]", i_b),
183 1010, qmin, 1000, 10010, -10,
185 h_ped_subtracted_pe_vs_n_[i_b] =
new TH2F(
186 Form(
"hPedSubtrPEvsN_chan%i", i_b),
187 Form(
";Number of time samples above threshold;Pedestal "
188 "subtracted PE, chan%i [fC]",
190 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
191 h_ped_subtracted_pe_vs_t_[i_b] =
new TH2F(
192 Form(
"hPedSubtrPEvsT_chan%i", i_b),
193 Form(
";First time sample above threshold;Pedestal subtracted "
196 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_p_ebins, 0, p_emax);
197 h_avg_q_vs_t_[i_b] =
new TH2F(
198 Form(
"h_avg_q_vs_t_chan%i", i_b),
199 Form(
";First time sample above threshold;Average Q, chan%i [fC]", i_b),
200 n_time_samp + 1, -1.5, n_time_samp - 0.5, n_qbins / 10, qmin,
204 for (
int i_e = 0; i_e < n_ev_; i_e++) {
205 for (
int i_b = 0; i_b < n_channels_; i_b++) {
207 new TH1F(Form(
"hCharge_chan%i_ev%i", i_b, i_e),
208 Form(
";time sample; Q, channel %i, event %i [fC]", i_b, i_e),
209 n_time_samp, -0.5, n_time_samp - 0.5);
213 h_tdc_fire_chan_vs_event_ =
new TH2F(
214 "h_tdc_fire_chan_vs_event",
";channel with TDC < 63;event number",
215 n_channels_, -0.5, n_channels_ - 0.5, n_ev_tdc_, 0, n_ev_tdc_);
217 ldmx_log(debug) <<
"done setting up histograms";