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