LDMX Software
TestBeamClusterAnalyzer.cxx
Go to the documentation of this file.
1
9
10#include <cmath>
11
12#include "TrigScint/Event/TrigScintCluster.h"
13
14namespace trigscint {
15
16TestBeamClusterAnalyzer::TestBeamClusterAnalyzer(const std::string& name,
17 framework::Process& process)
18 : Analyzer(name, process) {}
19
20void TestBeamClusterAnalyzer::configure(
22 input_col_ = parameters.get<std::string>("input_collection");
23 input_pass_name_ = parameters.get<std::string>("input_pass_name");
24 // wide_input_col_ =
25 // parameters.get<std::string>("3hitInputCollection");
26 // wide_input_pass_name_ =
27 // parameters.get<std::string>("3hitInputPassName");
28
29 ldmx_log(trace) << "In configure(), got parameters "
30 << "\n\t inputCollection = " << input_col_
31 << "\n\t inputPassName = " << input_pass_name_;
32 // << "\n\t 3hitInputCollection = " << wide_input_col_
33 // << "\n\t 3hitInputPassName = " << wide_input_pass_name_
34
35 return;
36}
37
38void TestBeamClusterAnalyzer::analyze(const framework::Event& event) {
39 if (!event.exists(input_col_, input_pass_name_)) {
40 ldmx_log(info) << "No cluster collection " << input_col_ << "_"
41 << input_pass_name_ << " found. Skipping analysis of event";
42 return;
43 }
44
45 const auto clusters{event.getCollection<ldmx::TrigScintCluster>(
46 input_col_, input_pass_name_)};
47
48 int n1hit = 0;
49 int n2hit = 0;
50 int n3hit = 0;
51
52 int n_clusters = clusters.size();
53 int idx = 0;
54 for (auto cluster : clusters) {
55 int seed = cluster.getSeed();
56 int n_hits = cluster.getNHits();
57 if (n_hits == 3)
58 n3hit++;
59 else if (n_hits == 2)
60 n2hit++;
61 else if (n_hits == 1)
62 n1hit++;
63
64 float pe = cluster.getPE();
65
66 h_pe_in_clusters_[seed]->Fill(pe);
67
68 /* // this requires different implementation. use getHitIDs and use the
69 indices in there
70 // in a loop over hits in the event to extract the PEs
71 // -- later.
72 for (auto hits : cluster.getConstituents() )
73 h_pe_in_hits_[seed]->Fill(PE);
74 */
75 // instead of always checking distance between the first two, instead, fill
76 // with distance from current to previous this should give us a better idea
77 // about if we're dominated by close-by activity in secondaries
78 if (idx > 0) { // look back at the previous cluster when more than one
79 h_delta_centroids_->Fill(
80 fabs(clusters[idx].getCentroid() - clusters[idx - 1].getCentroid()));
81 h_delta_vs_seed_->Fill(
82 clusters[idx - 1].getSeed(),
83 fabs(clusters[idx].getCentroid() - clusters[idx - 1].getCentroid()));
84 }
85 idx++; // increment afterwards
86 } // over clusters
87
88 /*
89
90 if (n2hit)
91 hN3N2->Fill((float)n3hit/n2hit);
92 if (n1hit) {
93 hN3N1->Fill((float)n3hit/n1hit);
94 hN2N1->Fill((float)n2hit/n1hit);
95 }
96 */
97 h_n3_n2_->Fill(n2hit, n3hit);
98 h_n3_n1_->Fill(n1hit, n3hit);
99 h_n2_n1_->Fill(n1hit, n2hit);
100
101 h_n_clusters_->Fill(n_clusters);
102 // todo: get hit collection to fill Nhits later?
103 h_n_hits_->Fill(3 * n3hit + 2 * n2hit + n1hit);
104
105 return;
106}
107
108void TestBeamClusterAnalyzer::onProcessStart() {
109 ldmx_log(trace)
110 << "\n\n Process starts! My analyzer should do something -- like "
111 "print this";
112
113 getHistoDirectory();
114
115 int p_emax = 600;
116 int n_p_ebins = 0.25 * p_emax;
117 // float Qmax = PEmax / (6250. / 4.e6);
118 // float Qmin = -10;
119 // int nQbins = (Qmax - Qmin) / 4;
120
121 for (int i_b = 0; i_b < n_channels_; i_b++) {
122 h_pe_in_hits_[i_b] =
123 new TH1F(Form("hPE_chan%i", i_b), Form(";PE, chan%i", i_b), n_p_ebins,
124 0, p_emax);
125 h_pe_in_clusters_[i_b] =
126 new TH1F(Form("h_pe_in_clusters_chan%i", i_b), Form(";PE, chan%i", i_b),
127 n_p_ebins, 0, p_emax);
128 }
129
130 h_delta_vs_seed_ = new TH2F(
131 "h_delta_vs_speed", ";bar_id_{seed};#delta_{centroid}", n_channels_ + 1,
132 -0.5, n_channels_ - 0.5, 5 * n_channels_, 0, n_channels_);
133
134 h_delta_centroids_ = new TH1F("h_delta_centroids", ";#delta_{centroid}",
135 5 * n_channels_, -0.5, n_channels_ - 0.5);
136
137 h_n_hits_ = new TH1F(
138 "hNHits", "Number of hits in the event; n_{hits}; Events", 10, 0, 10);
139 h_n_clusters_ = new TH1F(
140 "h_n_clusters", "Number of clusters in the event; n_{clusters}; Events",
141 10, 0, 10);
142
143 /*
144 hN3N2 = new TH1F("hN3N2", "Ratio of 3-hit to 2-hit clusters;
145 n_{3-hit}/n_{2-hit}; Events", 10, 0, 4); hN3N1 = new TH1F("hN3N1", "Ratio of
146 3-hit to 1-hit clusters; n_{3-hit}/n_{1-hit}; Events", 10, 0, 4); hN2N1 = new
147 TH1F("hN2N1", "Ratio of 2-hit to 1-hit clusters; n_{2-hit}/n_{1-hit}; Events",
148 10, 0, 4);
149 */
150 int n_cl = 6;
151
152 h_n3_n2_ = new TH2F(
153 "hN3N2", "Number of 3-hit vs 2-hit clusters; n_{2-hit};n_{3-hit}; Events",
154 n_cl, -0.5, n_cl - 0.5, n_cl, -0.5, n_cl - 0.5);
155 h_n3_n1_ = new TH2F(
156 "hN3N1", "Number of 3-hit vs 1-hit clusters; n_{1-hit};n_{3-hit}; Events",
157 n_cl, -0.5, n_cl - 0.5, n_cl, -0.5, n_cl - 0.5);
158 h_n2_n1_ = new TH2F(
159 "hN2N1", "Number of 2-hit vs 1-hit clusters; n_{1-hit};n_{2-hit}; Events",
160 n_cl, -0.5, n_cl - 0.5, n_cl, -0.5, n_cl - 0.5);
161
162 return;
163}
164
165void TestBeamClusterAnalyzer::onProcessEnd() { return; }
166
167} // namespace trigscint
168
#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:40
bool exists(const std::string &name, const std::string &passName, bool unique=true) const
Check for the existence of an object or collection with the given name and pass name in the event.
Definition Event.cxx:107
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
Stores cluster information from the trigger scintillator pads.