LDMX Software
TestBeamHitAnalyzer.cxx
Go to the documentation of this file.
1
9
10namespace trigscint {
11
12TestBeamHitAnalyzer::TestBeamHitAnalyzer(const std::string& name,
13 framework::Process& process)
14 : Analyzer(name, process) {}
15
16void TestBeamHitAnalyzer::configure(framework::config::Parameters& parameters) {
17 input_col_ = parameters.get<std::string>("inputCollection");
18 input_pass_name_ = parameters.get<std::string>("inputPassName");
19 peds_ = parameters.get<std::vector<double> >("pedestals");
20 start_sample_ = parameters.get<int>("startSample");
21
22 std::cout << " [ TestBeamHitAnalyzer ] In configure(), got parameters "
23 << "\n\t inputCollection = " << input_col_
24 << "\n\t inputPassName = " << input_pass_name_
25 << "\n\t startSample = " << start_sample_
26 << "\n\t pedestals[0] = " << peds_[0] << "\t." << std::endl;
27
28 return;
29}
30
31void TestBeamHitAnalyzer::analyze(const framework::Event& event) {
32 const auto channels{event.getCollection<trigscint::TestBeamHit>(
33 input_col_, input_pass_name_)};
34
35 int ev_nb = event.getEventNumber();
36 // int nChan = channels.size();
37 int lead_bar = -1;
38 int sublead_bar = -1;
39 float pe_lead = -1;
40 float pe_sublead = -1;
41 bool exists_intermediate_pe = false;
42
43 for (auto chan : channels) {
44 int bar = chan.getBarID();
45 float pe = chan.getPE();
46 if (ev_nb < n_ev_ && bar < n_channels_) {
47 // stick within the predefined histogram array
48 h_ev_disp_->Fill(ev_nb, bar, pe);
49 } // if within event display range
50 if (pe > pe_lead) {
51 pe_sublead = pe_lead;
52 sublead_bar = lead_bar;
53 pe_lead = pe;
54 lead_bar = bar;
55 } else if (pe >
56 pe_sublead) { // need a specific check, bars not sorted in
57 // PE so leadPE might be found before or after
58 pe_sublead = pe;
59 sublead_bar = bar;
60 }
61 h_pe_[bar]->Fill(pe);
62 if (chan.getQualityFlag() == 0 && bar < 12 && 15 < pe && pe < 40)
63 exists_intermediate_pe = true;
64
65 // cross talk/correlations
66 for (auto chan_probe : channels) {
67 int bar_probe = chan_probe.getBarID();
68 if (bar_probe >= bar) // we don't define the lower diagonal of the matrix
69 // of histograms
70 h_cross_talk_[bar][bar_probe]->Fill(pe, chan_probe.getPE());
71 }
72
73 } // over channels
74
75 if (exists_intermediate_pe && fill_nb_ < n_ev_) {
76 for (auto chan : channels) {
77 int bar = chan.getBarID();
78 if (bar < 12) { // stick within the predefined histogram array
79 float pe = chan.getPE();
80 h_ev_disp_pe_->Fill(fill_nb_, bar, pe);
81 }
82 } // if within event display range
83 fill_nb_++;
84 } // if PE range triggers writing these event displays
85
86 if (sublead_bar == -1) {
87 sublead_bar = lead_bar;
88 pe_sublead = pe_lead;
89 }
90 h_pe_vs_delta_[lead_bar]->Fill(lead_bar - sublead_bar, pe_lead);
91 h_delta_pe_vs_delta_[lead_bar]->Fill(lead_bar - sublead_bar,
92 pe_lead - pe_sublead);
93
94 // if ( (subleadBar%2) == (leadBar%2) ) // in same layer (or even, hit).
95 // skip if we're not seeing a max across layers
96 // return; -- on the other hand this is evident from the plot: delta is even
97
98 h_pe_max_vs_delta_->Fill(lead_bar - sublead_bar, pe_lead);
99
100 return;
101}
102
103void TestBeamHitAnalyzer::onProcessStart() {
104 std::cout << "\n\n Process starts! My analyzer should do something -- like "
105 "print this \n\n"
106 << std::endl;
107
108 getHistoDirectory();
109
110 int n_time_samp = 7;
111 int p_emax = 400;
112 int n_p_ebins = 2 * p_emax;
113 // float Qmax = PEmax / (6250. / 4.e6);
114 // float Qmin = -10;
115 // int nQbins = (Qmax - Qmin) / 4;
116
117 for (int i_b = 0; i_b < n_channels_; i_b++) {
118 h_pe_[i_b] = new TH1F(Form("h_pe_chan%i", i_b), Form(";PE, chan%i", i_b),
119 n_p_ebins, 0, p_emax);
120 h_pe_in_clusters_[i_b] =
121 new TH1F(Form("h_pe_in_clusters_chan%i", i_b), Form(";PE, chan%i", i_b),
122 n_p_ebins, 0, p_emax);
123 h_pe_vs_delta_[i_b] = new TH2F(
124 Form("h_pe_vs_delta_chan%i", i_b),
125 Form(";#delta_{barID};PE, chan%i has max PE", i_b), n_channels_ + 1,
126 -n_channels_ / 2 - 0.5, n_channels_ / 2 + 0.5, n_p_ebins, 0, p_emax);
127 h_delta_pe_vs_delta_[i_b] =
128 new TH2F(Form("h_delta_pe_vs_delta_chan%i", i_b),
129 Form(";#delta_{barID};#Delta_PE, chan%i has max PE", i_b),
130 n_channels_ + 1, -n_channels_ / 2 - 0.5, n_channels_ / 2 + 0.5,
131 n_p_ebins, 0, p_emax);
132 }
133
134 // make event displays for events where there are channels with weird event
135 // hit PE counts
136 for (int i_e = 0; i_e < n_ev_; i_e++) {
137 for (int i_b = 0; i_b < n_channels_; i_b++) {
138 h_out_[i_e][i_b] =
139 new TH1F(Form("hCharge_chan%i_ev%i", i_b, i_e),
140 Form(";time sample; Q, chan %i, ev %i [fC]", i_b, i_e),
141 n_time_samp, -0.5, n_time_samp - 0.5);
142 }
143 }
144
145 h_pe_max_vs_delta_ =
146 new TH2F("h_pe_max_vs_delta_", ";#delta_{barID};PE, max hit", n_channels_,
147 -n_channels_ / 2, n_channels_ / 2, n_p_ebins, 0, p_emax);
148 h_ev_disp_ =
149 new TH2F(Form("h_ev_disp_ev%i", n_ev_), ";Event number; Bar ID; PE",
150 n_ev_, 0.5, n_ev_ + 0.5, n_channels_, -0.5, n_channels_ - 0.5);
151 h_ev_disp_pe_ =
152 new TH2F("h_ev_disp_pe_cut", ";Event number; Bar ID; PE", n_ev_, 0.5,
153 n_ev_ + 0.5, n_channels_, -0.5, n_channels_ - 0.5);
154
155 fill_nb_ = 0;
156
157 for (int i_btag = 0; i_btag < n_channels_; i_btag++) {
158 for (int i_bprobe = i_btag; i_bprobe < n_channels_; i_bprobe++) {
159 // use one side of diagonal
160 h_cross_talk_[i_btag][i_bprobe] =
161 new TH2F(Form("h_pe_chan%i_vs_chan%i", i_bprobe, i_btag),
162 Form(";PE, channel %i; PE, channel %i", i_bprobe, i_btag),
163 n_p_ebins, 0, p_emax, n_p_ebins, 0, p_emax);
164 }
165 }
166
167 return;
168}
169
170void TestBeamHitAnalyzer::onProcessEnd() { return; }
171
172} // namespace trigscint
173
#define DECLARE_ANALYZER(CLASS)
Macro which allows the framework to construct an analyzer given its name during configuration.
Implements an event buffer system for storing event data.
Definition Event.h:42
Class which represents the process under execution.
Definition Process.h:36
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:29
const T & get(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:78
This class represents the linearised QIE output from the trigger scintillator, in charge (fC).
Definition TestBeamHit.h:24