ATLAS Offline Software
Loading...
Searching...
No Matches
MMHitAnalysis.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "MMHitAnalysis.h"
6
7
8/*Includes specific to Micromegas*/
14#include "CLHEP/Vector/LorentzVector.h"
15
16
17#include <algorithm>
18#include <math.h>
19#include <functional>
20#include <iostream>
21#include <stdio.h>
22
23using namespace std;
24
26 ATH_MSG_DEBUG( "Initializing MMHitAnalysis" );
27
28// Grab the Ntuple and histogramming service for the tree
29 ATH_CHECK(m_readKey.initialize());
30
31
33
34/*-----------------------------------Small sector Wedge 1 histos begin--------------------------------------*/
35 m_h_S1_xy_A = new TH2D("h_mm_S1_xy_A","S1_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
36 m_h_S1_xy_A->StatOverflows();
37 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_xy_A->GetName(), m_h_S1_xy_A));
38
39 m_h_S1_rz_A = new TH2D("h_mm_S1_rz_A","S1_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
40 m_h_S1_rz_A->StatOverflows();
41 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_rz_A->GetName(), m_h_S1_rz_A));
42
43 m_h_S1_r_A = new TH1D("h_mm_S1_r_A","S1_r_A", 1000,0., 14000.);
44 m_h_S1_r_A->StatOverflows();
45 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_r_A->GetName(), m_h_S1_r_A));
46
47 m_h_S1_xy_C = new TH2D("h_mm_S1_xy_C","S1_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
48 m_h_S1_xy_C->StatOverflows();
49 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_xy_C->GetName(), m_h_S1_xy_C));
50
51 m_h_S1_rz_C = new TH2D("h_mm_S1_rz_C","S1_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
52 m_h_S1_rz_C->StatOverflows();
53 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_rz_C->GetName(), m_h_S1_rz_C));
54
55 m_h_S1_r_C = new TH1D("h_mm_S1_r_C","S1_r_C", 1000,0., 14000.);
56 m_h_S1_r_C->StatOverflows();
57 ATH_CHECK(histSvc()->regHist(m_path + m_h_S1_r_C->GetName(), m_h_S1_r_C));
58 /*-----------------------------------Small sector Wedge 1 histos end--------------------------------------*/
59
60 /*-----------------------------------Small sector Wedge 2 histos begin--------------------------------------*/
61 m_h_S2_xy_A = new TH2D("h_mm_S2_xy_A","S2_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
62 m_h_S2_xy_A->StatOverflows();
63 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_xy_A->GetName(), m_h_S2_xy_A));
64
65 m_h_S2_rz_A = new TH2D("h_mm_S2_rz_A","S2_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
66 m_h_S2_rz_A->StatOverflows();
67 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_rz_A->GetName(), m_h_S2_rz_A));
68
69 m_h_S2_r_A = new TH1D("h_mm_S2_r_A","S2_r_A", 1000,0., 14000.);
70 m_h_S2_r_A->StatOverflows();
71 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_r_A->GetName(), m_h_S2_r_A));
72
73 m_h_S2_xy_C = new TH2D("h_mm_S2_xy_C","S2_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
74 m_h_S2_xy_C->StatOverflows();
75 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_xy_C->GetName(), m_h_S2_xy_C));
76
77 m_h_S2_rz_C = new TH2D("h_mm_S2_rz_C","S2_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
78 m_h_S2_rz_C->StatOverflows();
79 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_rz_C->GetName(), m_h_S2_rz_C));
80
81 m_h_S2_r_C = new TH1D("h_mm_S2_r_C","S2_r_C", 1000,0., 14000.);
82 m_h_S2_r_C->StatOverflows();
83 ATH_CHECK(histSvc()->regHist(m_path + m_h_S2_r_C->GetName(), m_h_S2_r_C));
84/*---------------------------------Small sector Wedge 2 histos end--------------------------------------*/
85
86/*-----------------------------------Small sector both Wedges histos begin--------------------------------------*/
87 m_h_S_xy_A = new TH2D("h_mm_S_xy_A","S_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
88 m_h_S_xy_A->StatOverflows();
89 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_xy_A->GetName(), m_h_S_xy_A));
90
91 m_h_S_xy_C = new TH2D("h_mm_S_xy_C","S_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
92 m_h_S_xy_C->StatOverflows();
93 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_xy_C->GetName(), m_h_S_xy_C));
94
95 m_h_S_rz_A = new TH2D("h_mm_S_rz_A","S_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
96 m_h_S_rz_A->StatOverflows();
97 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_rz_A->GetName(), m_h_S_rz_A));
98
99 m_h_S_rz_C = new TH2D("h_mm_S_rz_C","S_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
100 m_h_S_rz_C->StatOverflows();
101 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_rz_C->GetName(), m_h_S_rz_C));
102 /*---------------------------------Small sector both Wedges histos end--------------------------------------*/
103
104 /*-----------------------------------All sector histos begin--------------------------------------*/
105 m_h_xy_A = new TH2D("h_mm_xy_A","xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
106 m_h_xy_A->StatOverflows();
107 ATH_CHECK(histSvc()->regHist(m_path + m_h_xy_A->GetName(), m_h_xy_A));
108
109 m_h_xy_C = new TH2D("h_mm_xy_C","xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
110 m_h_xy_C->StatOverflows();
111 ATH_CHECK(histSvc()->regHist(m_path + m_h_xy_C->GetName(), m_h_xy_C));
112
113 m_h_rz_A = new TH2D("h_mm_rz_A","rz_A", 1000,7000., 8000., 5000, 0., 5000.);
114 m_h_rz_A->StatOverflows();
115 ATH_CHECK(histSvc()->regHist(m_path + m_h_rz_A->GetName(), m_h_rz_A));
116
117 m_h_rz_C = new TH2D("h_mm_rz_C","rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
118 m_h_rz_C->StatOverflows();
119 ATH_CHECK(histSvc()->regHist(m_path + m_h_rz_C->GetName(), m_h_rz_C));
120 /*---------------------------------All sector histos end-------------------------------------------*/
121
122 /*-----------------------------------Large sector Wedge 1 histos begin--------------------------------------*/
123 m_h_L1_xy_A = new TH2D("h_mm_L1_xy_A","L1_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
124 m_h_L1_xy_A->StatOverflows();
125 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_xy_A->GetName(), m_h_L1_xy_A));
126
127 m_h_L1_rz_A = new TH2D("h_mm_L1_rz_A","L1_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
128 m_h_L1_rz_A->StatOverflows();
129 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_rz_A->GetName(), m_h_L1_rz_A));
130
131 m_h_L1_r_A = new TH1D("h_mm_L1_r_A","L1_r_A", 1000,0., 14000.);
132 m_h_L1_r_A->StatOverflows();
133 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_r_A->GetName(), m_h_L1_r_A));
134
135 m_h_L1_xy_C = new TH2D("h_mm_L1_xy_C","L1_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
136 m_h_L1_xy_C->StatOverflows();
137 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_xy_C->GetName(), m_h_L1_xy_C));
138
139 m_h_L1_rz_C = new TH2D("h_mm_L1_rz_C","L1_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
140 m_h_L1_rz_C->StatOverflows();
141 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_rz_C->GetName(), m_h_L1_rz_C));
142
143 m_h_L1_r_C = new TH1D("h_mm_L1_r_C","L1_r_C", 1000,0., 14000.);
144 m_h_L1_r_C->StatOverflows();
145 ATH_CHECK(histSvc()->regHist(m_path + m_h_L1_r_C->GetName(), m_h_L1_r_C));
146 /*-----------------------------------Large sector Wedge 1 histos end--------------------------------------*/
147
148 /*-----------------------------------Large sector Wedge 2 histos begin--------------------------------------*/
149 m_h_L2_xy_A = new TH2D("h_mm_L2_xy_A","L2_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
150 m_h_L2_xy_A->StatOverflows();
151 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_xy_A->GetName(), m_h_L2_xy_A));
152
153 m_h_L2_rz_A = new TH2D("h_mm_L2_rz_A","L2_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
154 m_h_L2_rz_A->StatOverflows();
155 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_rz_A->GetName(), m_h_L2_rz_A));
156
157 m_h_L2_r_A = new TH1D("h_mm_L2_r_A","L2_r_A", 1000,0., 14000.);
158 m_h_L2_r_A->StatOverflows();
159 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_r_A->GetName(), m_h_L2_r_A));
160
161 m_h_L2_xy_C = new TH2D("h_mm_L2_xy_C","L2_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
162 m_h_L2_xy_C->StatOverflows();
163 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_xy_C->GetName(), m_h_L2_xy_C));
164
165 m_h_L2_rz_C = new TH2D("h_mm_L2_rz_C","L2_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
166 m_h_L2_rz_C->StatOverflows();
167 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_rz_C->GetName(), m_h_L2_rz_C));
168
169 m_h_L2_r_C = new TH1D("h_mm_L2_r_C","L2_r_C", 1000,0., 14000.);
170 m_h_L2_r_C->StatOverflows();
171 ATH_CHECK(histSvc()->regHist(m_path + m_h_L2_r_C->GetName(), m_h_L2_r_C));
172 /*-----------------------------------Large sector Wedge 1 histos end--------------------------------------*/
173
174 /*-----------------------------------Large sector both Wedge histos begin--------------------------------------*/
175 m_h_L_xy_A = new TH2D("h_mm_L_xy_A","L_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
176 m_h_L_xy_A->StatOverflows();
177 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_xy_A->GetName(), m_h_L_xy_A));
178
179 m_h_L_rz_A = new TH2D("h_mm_L_rz_A","L_rz_A", 1000,7000., 8000., 5000, 0., 5000.);
180 m_h_L_rz_A->StatOverflows();
181 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_rz_A->GetName(), m_h_L_rz_A));
182
183 m_h_L_xy_C = new TH2D("h_mm_L_xy_C","L_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
184 m_h_L_xy_C->StatOverflows();
185 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_xy_C->GetName(), m_h_L_xy_C));
186
187 m_h_L_rz_C = new TH2D("h_mm_L_rz_C","L_rz_C", 1000,-8000., -7000., 5000, 0., 5000.);
188 m_h_L_rz_C->StatOverflows();
189 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_rz_C->GetName(), m_h_L_rz_C));
190 /*-----------------------------------Large sector both Wedge histos end--------------------------------------*/
191
192
193 return StatusCode::SUCCESS;
194}
195
196StatusCode MMHitAnalysis::execute(const EventContext& ctx) {
197 ATH_MSG_DEBUG( "In MMHitAnalysis::execute()" );
198
199
200 const MMSimHitCollection* p_collection{nullptr};
201 ATH_CHECK(SG::get(p_collection, m_readKey, ctx));
202 for (MMSimHitCollection::const_iterator i_hit = p_collection->begin(); i_hit != p_collection->end(); ++i_hit){
203
204 Amg::Vector3D p = (*i_hit).globalPosition();
205 //Get station names and make plots for each sector
207 int simId = (*i_hit).MMId();
208 std::string sim_stationName = hitHelper->GetStationName(simId);
209 int sim_side = hitHelper->GetSide(simId);
210 //Declare station name strings
211 static const std::string s_m1s1("M1S1");
212 static const std::string s_m2s1("M2S1");
213 static const std::string s_m1s2("M1S2");
214 static const std::string s_m2s2("M2S2");
215 static const std::string s_m1l1("M1L1");
216 static const std::string s_m2l1("M2L1");
217 static const std::string s_m1l2("M1L2");
218 static const std::string s_m2l2("M2L2");
219
220 //Small sectors
221 /*-------------------------Wedge 1 Fill histos begin-------------------------*/
222 //M1S1 (Note: M1->Module 1, S1->Small sector wedge 1)
223
224 //Small sectors at +ve Z (A-Side)
225 if ((sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==1){
226 double r_S1_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
227 m_h_S1_xy_A->Fill(p.x(),p.y());
228 m_h_S1_rz_A->Fill(p.z(), r_S1_A);
229 m_h_S1_r_A->Fill(r_S1_A);
230 }
231
232 //Small sectors at -ve Z (C-Side)
233 if ((sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==-1){
234 double r_S1_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
235 m_h_S1_xy_C->Fill(p.x(),p.y());
236 m_h_S1_rz_C->Fill(p.z(), r_S1_C);
237 m_h_S1_r_C->Fill(r_S1_C);
238 }
239
240 /*------------------------Wedge 1 Fill histos end---------------------------*/
241
242 /*------------------------- Wedge 2 Fill histos begin-------------------------*/
243 //Small sectors at +ve Z (A-Side)
244 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2) && sim_side==1){
245 double r_S2_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
246 m_h_S2_xy_A->Fill(p.x(),p.y());
247 m_h_S2_rz_A->Fill(p.z(), r_S2_A);
248 m_h_S2_r_A->Fill(r_S2_A);
249 }
250
251 //Small sectors at -ve Z (C-Side)
252 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2) && sim_side==-1){
253 double r_S2_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
254 m_h_S2_xy_C->Fill(p.x(),p.y());
255 m_h_S2_rz_C->Fill(p.z(), r_S2_C);
256 m_h_S2_r_C->Fill(r_S2_C);
257 }
258
259 /*------------------------Wedge 2 Fill histos end---------------------------*/
260
261 /*------------------------- Small sectors both wedges Fill histos begin-------------------------*/
262 //Small sectors at +ve Z (A-Side)
263 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2 || sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==1){
264 double r_S_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
265 m_h_S_xy_A->Fill(p.x(),p.y());
266 m_h_S_rz_A->Fill(p.z(), r_S_A);
267 }
268
269 //Small sectors at -ve Z (C-Side)
270 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2 || sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==-1){
271 double r_S_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
272 m_h_S_xy_C->Fill(p.x(),p.y());
273 m_h_S_rz_C->Fill(p.z(), r_S_C);
274 }
275 /*------------------------Small sectors both wedges Fill histos end---------------------------*/
276
277 //All sectors
278 /*-------------------------All sectors Fill histos begin-------------------------*/
279 //Sectors at +ve Z (A-Side)
280 if (sim_side==1){
281 double r_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
282 m_h_xy_A->Fill(p.x(),p.y());
283 m_h_rz_A->Fill(p.z(), r_A);
284 }
285
286 //Sectors at -ve Z (C-Side)
287 if (sim_side==-1){
288 double r_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
289 m_h_xy_C->Fill(p.x(),p.y());
290 m_h_rz_C->Fill(p.z(), r_C);
291 }
292 /*------------------------All sectors Fill histos end---------------------------*/
293
294 //Large sectors
295 /*-------------------------Wedge 1 Fill histos begin-------------------------*/
296 //M1L1 (Note: M1->Module 1, L1->Large sector wedge 1)
297
298 //Large sectors at +ve Z (A-Side)
299 if ((sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==1){
300 double r_L1_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
301 m_h_L1_xy_A->Fill(p.x(),p.y());
302 m_h_L1_rz_A->Fill(p.z(), r_L1_A);
303 m_h_L1_r_A->Fill(r_L1_A);
304 }
305
306 //Large sectors at -ve Z (C-Side)
307 if ((sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==-1){
308 double r_L1_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
309 m_h_L1_xy_C->Fill(p.x(),p.y());
310 m_h_L1_rz_C->Fill(p.z(), r_L1_C);
311 m_h_L1_r_C->Fill(r_L1_C);
312 }
313
314 /*------------------------Wedge 1 Fill histos end---------------------------*/
315
316 /*-------------------------Wedge 2 Fill histos begin-------------------------*/
317 //M1L1 (Note: M1->Module 1, L1->Large sector wedge 1)
318
319 //Large sectors at +ve Z (A-Side)
320 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2) && sim_side==1){
321 double r_L2_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
322 m_h_L2_xy_A->Fill(p.x(),p.y());
323 m_h_L2_rz_A->Fill(p.z(), r_L2_A);
324 m_h_L2_r_A->Fill(r_L2_A);
325 }
326
327 //Large sectors at -ve Z (C-Side)
328 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2) && sim_side==-1){
329 double r_L2_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
330 m_h_L2_xy_C->Fill(p.x(),p.y());
331 m_h_L2_rz_C->Fill(p.z(), r_L2_C);
332 m_h_L2_r_C->Fill(r_L2_C);
333 }
334
335 /*------------------------Wedge 2 Fill histos end---------------------------*/
336
337 /*------------------------- Large sectors both wedges Fill histos begin-------------------------*/
338 //Large sectors at +ve Z (A-Side)
339 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2 || sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==1){
340 double r_L_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
341 m_h_L_xy_A->Fill(p.x(),p.y());
342 m_h_L_rz_A->Fill(p.z(), r_L_A);
343 }
344
345 //Large sectors at -ve Z (C-Side)
346 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2 || sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==-1){
347 double r_L_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
348 m_h_L_xy_C->Fill(p.x(),p.y());
349 m_h_L_rz_C->Fill(p.z(), r_L_C);
350 }
351 /*------------------------Large sectors both wedges Fill histos end---------------------------*/
352
353 }
354 return StatusCode::SUCCESS;
355}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
AtlasHitsVector< MMSimHit > MMSimHitCollection
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
CONT::const_iterator const_iterator
const_iterator begin() const
const_iterator end() const
SG::ReadHandleKey< MMSimHitCollection > m_readKey
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
TH2 * m_h_S1_xy_A
Some variables.
Gaudi::Property< std::string > m_path
virtual StatusCode initialize() override final
static const MicromegasHitIdHelper * GetHelper()
int GetSide(const int &hid) const
std::string GetStationName(const int &hid) const
Eigen::Matrix< double, 3, 1 > Vector3D
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
STL namespace.