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