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 inputCol_ = parameters.getParameter<std::string>("inputCollection");
19 inputPassName_ = parameters.getParameter<std::string>("inputPassName");
20 // wideInputCol_ =
21 // parameters.getParameter<std::string>("3hitInputCollection");
22 // wideInputPassName_ =
23 // parameters.getParameter<std::string>("3hitInputPassName");
24
25 std::cout << " [ TestBeamClusterAnalyzer ] In configure(), got parameters "
26 << "\n\t inputCollection = " << inputCol_
27 << "\n\t inputPassName = " << inputPassName_ << std::endl;
28 // << "\n\t 3hitInputCollection = " << wideInputCol_
29 // << "\n\t 3hitInputPassName = " << wideInputPassName_
30
31 return;
32}
33
34void TestBeamClusterAnalyzer::analyze(const framework::Event& event) {
35 if (!event.exists(inputCol_, inputPassName_)) {
36 ldmx_log(info) << "No cluster collection " << inputCol_ << "_"
37 << inputPassName_ << " found. Skipping analysis of event";
38 return;
39 }
40
41 const auto clusters{
42 event.getCollection<ldmx::TrigScintCluster>(inputCol_, inputPassName_)};
43
44 int n1hit = 0;
45 int n2hit = 0;
46 int n3hit = 0;
47
48 int nClusters = clusters.size();
49 int idx = 0;
50 for (auto cluster : clusters) {
51 int seed = cluster.getSeed();
52 int nHits = cluster.getNHits();
53 if (nHits == 3)
54 n3hit++;
55 else if (nHits == 2)
56 n2hit++;
57 else if (nHits == 1)
58 n1hit++;
59
60 float PE = cluster.getPE();
61
62 hPEinClusters[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 hPEinHits[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 hDeltaCentroids->Fill(
76 fabs(clusters[idx].getCentroid() - clusters[idx - 1].getCentroid()));
77 hDeltaVsSeed->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 hN3N2->Fill(n2hit, n3hit);
94 hN3N1->Fill(n1hit, n3hit);
95 hN2N1->Fill(n1hit, n2hit);
96
97 hNClusters->Fill(nClusters);
98 // todo: get hit collection to fill Nhits later?
99 hNHits->Fill(3 * n3hit + 2 * n2hit + n1hit);
100
101 return;
102}
103
104void TestBeamClusterAnalyzer::onProcessStart() {
105 std::cout << "\n\n Process starts! My analyzer should do something -- like "
106 "print this \n\n"
107 << std::endl;
108
109 getHistoDirectory();
110
111 int PEmax = 600;
112 int nPEbins = 0.25 * PEmax;
113 // float Qmax = PEmax / (6250. / 4.e6);
114 // float Qmin = -10;
115 // int nQbins = (Qmax - Qmin) / 4;
116
117 for (int iB = 0; iB < nChannels; iB++) {
118 hPEinHits[iB] = new TH1F(Form("hPE_chan%i", iB), Form(";PE, chan%i", iB),
119 nPEbins, 0, PEmax);
120 hPEinClusters[iB] = new TH1F(Form("hPEinClusters_chan%i", iB),
121 Form(";PE, chan%i", iB), nPEbins, 0, PEmax);
122 }
123
124 hDeltaVsSeed =
125 new TH2F("hDeltaVsSeed", ";BarID_{seed};#Delta_{centroid}", nChannels + 1,
126 -0.5, nChannels - 0.5, 5 * nChannels, 0, nChannels);
127
128 hDeltaCentroids = new TH1F("hDeltaCentroids", ";#Delta_{centroid}",
129 5 * nChannels, -0.5, nChannels - 0.5);
130
131 hNHits = new TH1F("hNHits", "Number of hits in the event; N_{hits}; Events",
132 10, 0, 10);
133 hNClusters = new TH1F("hNClusters",
134 "Number of clusters in the event; N_{clusters}; Events",
135 10, 0, 10);
136
137 /*
138 hN3N2 = new TH1F("hN3N2", "Ratio of 3-hit to 2-hit clusters;
139 N_{3-hit}/N_{2-hit}; Events", 10, 0, 4); hN3N1 = new TH1F("hN3N1", "Ratio of
140 3-hit to 1-hit clusters; N_{3-hit}/N_{1-hit}; Events", 10, 0, 4); hN2N1 = new
141 TH1F("hN2N1", "Ratio of 2-hit to 1-hit clusters; N_{2-hit}/N_{1-hit}; Events",
142 10, 0, 4);
143 */
144 int nCl = 6;
145
146 hN3N2 = new TH2F(
147 "hN3N2", "Number of 3-hit vs 2-hit clusters; N_{2-hit};N_{3-hit}; Events",
148 nCl, -0.5, nCl - 0.5, nCl, -0.5, nCl - 0.5);
149 hN3N1 = new TH2F(
150 "hN3N1", "Number of 3-hit vs 1-hit clusters; N_{1-hit};N_{3-hit}; Events",
151 nCl, -0.5, nCl - 0.5, nCl, -0.5, nCl - 0.5);
152 hN2N1 = new TH2F(
153 "hN2N1", "Number of 2-hit vs 1-hit clusters; N_{1-hit};N_{2-hit}; Events",
154 nCl, -0.5, nCl - 0.5, nCl, -0.5, nCl - 0.5);
155
156 return;
157}
158
159void TestBeamClusterAnalyzer::onProcessEnd() { return; }
160
161} // namespace trigscint
162
163DECLARE_ANALYZER_NS(trigscint, TestBeamClusterAnalyzer)
#define DECLARE_ANALYZER_NS(NS, 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:41
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:27
T getParameter(const std::string &name) const
Retrieve the parameter of the given name.
Definition Parameters.h:89
Stores cluster information from the trigger scintillator pads.
int getSeed() const
Get cluster seed channel nb.