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
197 ATH_MSG_DEBUG( "In MMHitAnalysis::execute()" );
198
199
200 const EventContext& ctx{Gaudi::Hive::currentContext()};
201 const MMSimHitCollection* p_collection{nullptr};
202 ATH_CHECK(SG::get(p_collection, m_readKey, ctx));
203 for (MMSimHitCollection::const_iterator i_hit = p_collection->begin(); i_hit != p_collection->end(); ++i_hit){
204
205 Amg::Vector3D p = (*i_hit).globalPosition();
206 //Get station names and make plots for each sector
208 int simId = (*i_hit).MMId();
209 std::string sim_stationName = hitHelper->GetStationName(simId);
210 int sim_side = hitHelper->GetSide(simId);
211 //Declare station name strings
212 static const std::string s_m1s1("M1S1");
213 static const std::string s_m2s1("M2S1");
214 static const std::string s_m1s2("M1S2");
215 static const std::string s_m2s2("M2S2");
216 static const std::string s_m1l1("M1L1");
217 static const std::string s_m2l1("M2L1");
218 static const std::string s_m1l2("M1L2");
219 static const std::string s_m2l2("M2L2");
220
221 //Small sectors
222 /*-------------------------Wedge 1 Fill histos begin-------------------------*/
223 //M1S1 (Note: M1->Module 1, S1->Small sector wedge 1)
224
225 //Small sectors at +ve Z (A-Side)
226 if ((sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==1){
227 double r_S1_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
228 m_h_S1_xy_A->Fill(p.x(),p.y());
229 m_h_S1_rz_A->Fill(p.z(), r_S1_A);
230 m_h_S1_r_A->Fill(r_S1_A);
231 }
232
233 //Small sectors at -ve Z (C-Side)
234 if ((sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==-1){
235 double r_S1_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
236 m_h_S1_xy_C->Fill(p.x(),p.y());
237 m_h_S1_rz_C->Fill(p.z(), r_S1_C);
238 m_h_S1_r_C->Fill(r_S1_C);
239 }
240
241 /*------------------------Wedge 1 Fill histos end---------------------------*/
242
243 /*------------------------- Wedge 2 Fill histos begin-------------------------*/
244 //Small sectors at +ve Z (A-Side)
245 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2) && sim_side==1){
246 double r_S2_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
247 m_h_S2_xy_A->Fill(p.x(),p.y());
248 m_h_S2_rz_A->Fill(p.z(), r_S2_A);
249 m_h_S2_r_A->Fill(r_S2_A);
250 }
251
252 //Small sectors at -ve Z (C-Side)
253 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2) && sim_side==-1){
254 double r_S2_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
255 m_h_S2_xy_C->Fill(p.x(),p.y());
256 m_h_S2_rz_C->Fill(p.z(), r_S2_C);
257 m_h_S2_r_C->Fill(r_S2_C);
258 }
259
260 /*------------------------Wedge 2 Fill histos end---------------------------*/
261
262 /*------------------------- Small sectors both wedges Fill histos begin-------------------------*/
263 //Small sectors at +ve Z (A-Side)
264 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2 || sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==1){
265 double r_S_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
266 m_h_S_xy_A->Fill(p.x(),p.y());
267 m_h_S_rz_A->Fill(p.z(), r_S_A);
268 }
269
270 //Small sectors at -ve Z (C-Side)
271 if ((sim_stationName==s_m1s2 || sim_stationName==s_m2s2 || sim_stationName==s_m1s1 || sim_stationName==s_m2s1) && sim_side==-1){
272 double r_S_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
273 m_h_S_xy_C->Fill(p.x(),p.y());
274 m_h_S_rz_C->Fill(p.z(), r_S_C);
275 }
276 /*------------------------Small sectors both wedges Fill histos end---------------------------*/
277
278 //All sectors
279 /*-------------------------All sectors Fill histos begin-------------------------*/
280 //Sectors at +ve Z (A-Side)
281 if (sim_side==1){
282 double r_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
283 m_h_xy_A->Fill(p.x(),p.y());
284 m_h_rz_A->Fill(p.z(), r_A);
285 }
286
287 //Sectors at -ve Z (C-Side)
288 if (sim_side==-1){
289 double r_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
290 m_h_xy_C->Fill(p.x(),p.y());
291 m_h_rz_C->Fill(p.z(), r_C);
292 }
293 /*------------------------All sectors Fill histos end---------------------------*/
294
295 //Large sectors
296 /*-------------------------Wedge 1 Fill histos begin-------------------------*/
297 //M1L1 (Note: M1->Module 1, L1->Large sector wedge 1)
298
299 //Large sectors at +ve Z (A-Side)
300 if ((sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==1){
301 double r_L1_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
302 m_h_L1_xy_A->Fill(p.x(),p.y());
303 m_h_L1_rz_A->Fill(p.z(), r_L1_A);
304 m_h_L1_r_A->Fill(r_L1_A);
305 }
306
307 //Large sectors at -ve Z (C-Side)
308 if ((sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==-1){
309 double r_L1_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
310 m_h_L1_xy_C->Fill(p.x(),p.y());
311 m_h_L1_rz_C->Fill(p.z(), r_L1_C);
312 m_h_L1_r_C->Fill(r_L1_C);
313 }
314
315 /*------------------------Wedge 1 Fill histos end---------------------------*/
316
317 /*-------------------------Wedge 2 Fill histos begin-------------------------*/
318 //M1L1 (Note: M1->Module 1, L1->Large sector wedge 1)
319
320 //Large sectors at +ve Z (A-Side)
321 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2) && sim_side==1){
322 double r_L2_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
323 m_h_L2_xy_A->Fill(p.x(),p.y());
324 m_h_L2_rz_A->Fill(p.z(), r_L2_A);
325 m_h_L2_r_A->Fill(r_L2_A);
326 }
327
328 //Large sectors at -ve Z (C-Side)
329 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2) && sim_side==-1){
330 double r_L2_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
331 m_h_L2_xy_C->Fill(p.x(),p.y());
332 m_h_L2_rz_C->Fill(p.z(), r_L2_C);
333 m_h_L2_r_C->Fill(r_L2_C);
334 }
335
336 /*------------------------Wedge 2 Fill histos end---------------------------*/
337
338 /*------------------------- Large sectors both wedges Fill histos begin-------------------------*/
339 //Large sectors at +ve Z (A-Side)
340 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2 || sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==1){
341 double r_L_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
342 m_h_L_xy_A->Fill(p.x(),p.y());
343 m_h_L_rz_A->Fill(p.z(), r_L_A);
344 }
345
346 //Large sectors at -ve Z (C-Side)
347 if ((sim_stationName==s_m1l2 || sim_stationName==s_m2l2 || sim_stationName==s_m1l1 || sim_stationName==s_m2l1) && sim_side==-1){
348 double r_L_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
349 m_h_L_xy_C->Fill(p.x(),p.y());
350 m_h_L_rz_C->Fill(p.z(), r_L_C);
351 }
352 /*------------------------Large sectors both wedges Fill histos end---------------------------*/
353
354 }
355 return StatusCode::SUCCESS;
356}
#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
TH2 * m_h_S1_xy_A
Some variables.
Gaudi::Property< std::string > m_path
virtual StatusCode execute() override final
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.