ATLAS Offline Software
sTGCHitAnalysis.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "sTGCHitAnalysis.h"
6 
7 
8 /*Includes specific to sTGCs*/
15 #include "CLHEP/Vector/LorentzVector.h"
16 
17 #include "TH1.h"
18 #include "TTree.h"
19 #include "TString.h"
20 
21 #include <algorithm>
22 #include <math.h>
23 #include <functional>
24 #include <iostream>
25 #include <stdio.h>
26 
27 using namespace std;
28 
29 sTGCHitAnalysis::sTGCHitAnalysis(const std::string& name, ISvcLocator* pSvcLocator)
30  : AthAlgorithm(name, pSvcLocator)
31  , m_h_S_rz_A(0)
32  , m_h_S_rz_C(0)
33  , m_h_S_xy_A(0)
34  , m_h_S_xy_C(0)
35  , m_h_L_rz_A(0)
36  , m_h_L_rz_C(0)
37  , m_h_L_xy_A(0)
38  , m_h_L_xy_C(0)
39  , m_h_rz_A(0)
40  , m_h_rz_C(0)
41  , m_h_xy_A(0)
42  , m_h_xy_C(0)
43  , m_h_r_A(0)
44  , m_h_r_C(0)
45  , m_ntupleFileName("sTGCHitAnalysis/ntuple/")
46  , m_path("/sTGCHitAnalysis/histos/")
47  , m_thistSvc("THistSvc", name)
48 {
49  declareProperty("NtupleFileName", m_ntupleFileName);
50  declareProperty("HistPath", m_path);
51 
52 }
53 
55  ATH_MSG_DEBUG( "Initializing sTGCHitAnalysis" );
56 
57  // Grab the Ntuple and histogramming service for the tree
58  CHECK(m_thistSvc.retrieve());
59 
60 
63  m_h_rz_A = new TH2D("h_stgc_rz_A","rz_A", 2000,6500., 8500., 1000, -5000., 5000.);
64  m_h_rz_A->StatOverflows();
65  CHECK(m_thistSvc->regHist(m_path + m_h_rz_A->GetName(), m_h_rz_A));
66 
67  m_h_rz_C = new TH2D("h_stgc_rz_C","rz_C", 2000,-8500., -6500., 5000, 0., 5000.);
68  m_h_rz_C->StatOverflows();
69  CHECK(m_thistSvc->regHist(m_path + m_h_rz_C->GetName(), m_h_rz_C));
70 
71  m_h_L_rz_A = new TH2D("h_stgc_L_rz_A","L_rz_A", 2000, 6500., 8500., 5000, 0., 5000.);
72  m_h_L_rz_A->StatOverflows();
73  CHECK(m_thistSvc->regHist(m_path + m_h_L_rz_A->GetName(), m_h_L_rz_A));
74 
75  m_h_L_rz_C = new TH2D("h_stgc_L_rz_C","L_rz_C", 2000,-8500., -6500., 5000, 0., 5000.);
76  m_h_L_rz_C->StatOverflows();
77  CHECK(m_thistSvc->regHist(m_path + m_h_L_rz_C->GetName(), m_h_L_rz_C));
78 
79  m_h_S_rz_A = new TH2D("h_stgc_S_rz_A","S_rz_A", 2000,6500., 8500., 5000, 0., 5000.);
80  m_h_S_rz_A->StatOverflows();
81  CHECK(m_thistSvc->regHist(m_path + m_h_S_rz_A->GetName(), m_h_S_rz_A));
82 
83  m_h_S_rz_C = new TH2D("h_stgc_S_rz_C","S_rz_C", 2000, -8500., -6500., 5000, 0., 5000.);
84  m_h_S_rz_C->StatOverflows();
85  CHECK(m_thistSvc->regHist(m_path + m_h_S_rz_C->GetName(), m_h_S_rz_C));
86 
87 
88  m_h_xy_A = new TH2D("h_stgc_xy_A","xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
89  m_h_xy_A->StatOverflows();
90  CHECK(m_thistSvc->regHist(m_path + m_h_xy_A->GetName(), m_h_xy_A));
91 
92  m_h_xy_C = new TH2D("h_stgc_xy_C","xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
93  m_h_xy_C->StatOverflows();
94  CHECK(m_thistSvc->regHist(m_path + m_h_xy_C->GetName(), m_h_xy_C));
95 
96  m_h_L_xy_A = new TH2D("h_stgc_L_xy_A","L_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
97  m_h_L_xy_A->StatOverflows();
98  CHECK(m_thistSvc->regHist(m_path + m_h_L_xy_A->GetName(), m_h_L_xy_A));
99 
100  m_h_L_xy_C = new TH2D("h_stgc_L_xy_C","L_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
101  m_h_L_xy_C->StatOverflows();
102  CHECK(m_thistSvc->regHist(m_path + m_h_L_xy_C->GetName(), m_h_L_xy_C));
103 
104  m_h_S_xy_A = new TH2D("h_stgc_S_xy_A","S_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
105  m_h_S_xy_A->StatOverflows();
106  CHECK(m_thistSvc->regHist(m_path + m_h_S_xy_A->GetName(), m_h_S_xy_A));
107 
108  m_h_S_xy_C = new TH2D("h_stgc_S_xy_C","S_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
109  m_h_S_xy_C->StatOverflows();
110  CHECK(m_thistSvc->regHist(m_path + m_h_S_xy_C->GetName(), m_h_S_xy_C));
111 
112  m_h_r_A = new TH1D("h_stgc_r_A","r_A", 1000,0., 14000.);
113  m_h_r_A->StatOverflows();
114  CHECK(m_thistSvc->regHist(m_path + m_h_r_A->GetName(), m_h_r_A));
115 
116  m_h_r_C = new TH1D("h_stgc_r_C","r_C", 1000,0., 14000.);
117  m_h_r_C->StatOverflows();
118  CHECK(m_thistSvc->regHist(m_path + m_h_r_C->GetName(), m_h_r_C));
119 
120 
121  return StatusCode::SUCCESS;
122 }
123 
125  ATH_MSG_DEBUG( "In sTGCHitAnalysis::execute()" );
126 
127  const sTGCSimHitCollection* p_collection;
128  if ((evtStore()->retrieve(p_collection,"sTGC_Hits"))==StatusCode::SUCCESS) {
129  for (sTGCSimHitCollection::const_iterator i_hit = p_collection->begin(); i_hit != p_collection->end(); ++i_hit){
130 
131  Amg::Vector3D p = (*i_hit).globalPosition();
132  //Get station names and make plots for each wedge
133  const sTgcHitIdHelper* hitHelper = sTgcHitIdHelper::GetHelper();
134  int simId = (*i_hit).sTGCId();
135  std::string sim_stationName = hitHelper->GetStationName(simId);
136 
137  static const std::string QS1C("QS1C");
138  static const std::string QS2C("QS2C");
139  static const std::string QS3C("QS3C");
140  static const std::string QL1P("QL1P");
141  static const std::string QL2P("QL2P");
142  static const std::string QL3P("QL3P");
143 
144  int sim_side = hitHelper->GetSide(simId);
145 
146  if ( sim_side==1){ //Both sectors A side
147  double r_A = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
148  m_h_rz_A->Fill(p.z(), r_A);
149  m_h_xy_A->Fill(p.x(), p.y());
150  m_h_r_A->Fill(r_A);
151  }
152 
153  if ( sim_side==-1){ //Both sectors C side
154  double r_C = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
155  m_h_rz_C->Fill(p.z(), r_C);
156  m_h_xy_C->Fill(p.x(), p.y());
157  m_h_r_C->Fill(r_C);
158  }
159 
160  if ((sim_stationName==QS1C || sim_stationName==QS2C || sim_stationName==QS3C) && sim_side==1){ //Small sectors A side
161  double r_S_A = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
162  m_h_S_rz_A->Fill(p.z(), r_S_A);
163  m_h_S_xy_A->Fill(p.x(), p.y());
164  }
165 
166  if ((sim_stationName==QS1C || sim_stationName==QS2C || sim_stationName==QS3C) && sim_side==-1){ //Small sectors C side
167  double r_S_C = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
168  m_h_S_rz_C->Fill(p.z(), r_S_C);
169  m_h_S_xy_C->Fill(p.x(), p.y());
170  }
171 
172  if ((sim_stationName==QL1P || sim_stationName==QL2P || sim_stationName==QL3P) && sim_side==1){ //Large sectors A side
173  double r_L_A = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
174  m_h_L_rz_A->Fill(p.z(), r_L_A);
175  m_h_L_xy_A->Fill(p.x(), p.y());
176  }
177 
178  if ((sim_stationName==QL1P || sim_stationName==QL2P || sim_stationName==QL3P) && sim_side==-1){ //Large sectors C side
179  double r_L_C = sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
180  m_h_L_rz_C->Fill(p.z(), r_L_C);
181  m_h_L_xy_C->Fill(p.x(), p.y());
182  }
183 
184  }
185  }
186  return StatusCode::SUCCESS;
187 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
sTGCHitAnalysis::m_h_L_xy_A
TH2 * m_h_L_xy_A
Definition: sTGCHitAnalysis.h:45
sTgcHitIdHelper::GetSide
int GetSide(const int &hid) const
Definition: sTgcHitIdHelper.cxx:83
sTGCHitAnalysis::m_h_S_xy_C
TH2 * m_h_S_xy_C
Definition: sTGCHitAnalysis.h:42
sTGCHitAnalysis::m_h_S_rz_A
TH2 * m_h_S_rz_A
Some variables.
Definition: sTGCHitAnalysis.h:39
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
sTgcReadoutElement.h
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
sTgcHitIdHelper::GetHelper
static const sTgcHitIdHelper * GetHelper()
Definition: sTgcHitIdHelper.cxx:24
AtlasHitsVector
Definition: AtlasHitsVector.h:33
sTGCSimHit.h
sTGCHitAnalysis::m_h_r_C
TH1 * m_h_r_C
Definition: sTGCHitAnalysis.h:52
GeoMuonHits.h
sTGCSimHitCollection.h
sTGCHitAnalysis.h
sTGCHitAnalysis::m_h_rz_C
TH2 * m_h_rz_C
Definition: sTGCHitAnalysis.h:48
sTGCHitAnalysis::m_ntupleFileName
std::string m_ntupleFileName
Definition: sTGCHitAnalysis.h:54
sTGCHitAnalysis::m_h_L_rz_C
TH2 * m_h_L_rz_C
Definition: sTGCHitAnalysis.h:44
AtlasHitsVector::begin
const_iterator begin() const
Definition: AtlasHitsVector.h:131
sTGCHitAnalysis::m_h_S_xy_A
TH2 * m_h_S_xy_A
Definition: sTGCHitAnalysis.h:41
AtlasHitsVector::const_iterator
CONT::const_iterator const_iterator
Definition: AtlasHitsVector.h:43
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
sTGCHitAnalysis::initialize
virtual StatusCode initialize()
Definition: sTGCHitAnalysis.cxx:54
sTGCHitAnalysis::execute
virtual StatusCode execute()
Definition: sTGCHitAnalysis.cxx:124
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
m_path
std::string m_path
the path being used
Definition: OutputStreamData.cxx:88
sTGCHitAnalysis::m_h_xy_A
TH2 * m_h_xy_A
Definition: sTGCHitAnalysis.h:49
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
sTGCHitAnalysis::m_path
std::string m_path
Definition: sTGCHitAnalysis.h:56
AthAlgorithm
Definition: AthAlgorithm.h:47
sTGCHitAnalysis::m_thistSvc
ServiceHandle< ITHistSvc > m_thistSvc
Definition: sTGCHitAnalysis.h:57
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
sTGCHitAnalysis::m_h_L_rz_A
TH2 * m_h_L_rz_A
Definition: sTGCHitAnalysis.h:43
sTgcHitIdHelper::GetStationName
std::string GetStationName(const int &hid) const
Definition: sTgcHitIdHelper.cxx:56
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
MuonDetectorManager.h
sTGCHitAnalysis::m_h_S_rz_C
TH2 * m_h_S_rz_C
Definition: sTGCHitAnalysis.h:40
sTGCHitAnalysis::m_h_rz_A
TH2 * m_h_rz_A
Definition: sTGCHitAnalysis.h:47
sTgcHitIdHelper
Definition: sTgcHitIdHelper.h:13
AtlasHitsVector::end
const_iterator end() const
Definition: AtlasHitsVector.h:134
sTGCHitAnalysis::m_h_L_xy_C
TH2 * m_h_L_xy_C
Definition: sTGCHitAnalysis.h:46
sTGCHitAnalysis::m_h_r_A
TH1 * m_h_r_A
Definition: sTGCHitAnalysis.h:51
sTGCHitAnalysis::sTGCHitAnalysis
sTGCHitAnalysis(const std::string &name, ISvcLocator *pSvcLocator)
Definition: sTGCHitAnalysis.cxx:29
sTGCHitAnalysis::m_h_xy_C
TH2 * m_h_xy_C
Definition: sTGCHitAnalysis.h:50
sTgcHitIdHelper.h