ATLAS Offline Software
Loading...
Searching...
No Matches
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*/
14#include "CLHEP/Vector/LorentzVector.h"
15
16#include "TH1.h"
17#include "TTree.h"
18#include "TString.h"
19
20#include <algorithm>
21#include <math.h>
22#include <functional>
23#include <iostream>
24#include <stdio.h>
25
26
28 ATH_MSG_DEBUG( "Initializing sTGCHitAnalysis" );
29
30 // Grab the Ntuple and histogramming service for the tree
31 ATH_CHECK(m_readKey.initialize());
32
33
35
36 m_h_rz_A = new TH2D("h_stgc_rz_A","rz_A", 2000,6500., 8500., 1000, -5000., 5000.);
37 m_h_rz_A->StatOverflows();
38 ATH_CHECK(histSvc()->regHist(m_path + m_h_rz_A->GetName(), m_h_rz_A));
39
40 m_h_rz_C = new TH2D("h_stgc_rz_C","rz_C", 2000,-8500., -6500., 5000, 0., 5000.);
41 m_h_rz_C->StatOverflows();
42 ATH_CHECK(histSvc()->regHist(m_path + m_h_rz_C->GetName(), m_h_rz_C));
43
44 m_h_L_rz_A = new TH2D("h_stgc_L_rz_A","L_rz_A", 2000, 6500., 8500., 5000, 0., 5000.);
45 m_h_L_rz_A->StatOverflows();
46 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_rz_A->GetName(), m_h_L_rz_A));
47
48 m_h_L_rz_C = new TH2D("h_stgc_L_rz_C","L_rz_C", 2000,-8500., -6500., 5000, 0., 5000.);
49 m_h_L_rz_C->StatOverflows();
50 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_rz_C->GetName(), m_h_L_rz_C));
51
52 m_h_S_rz_A = new TH2D("h_stgc_S_rz_A","S_rz_A", 2000,6500., 8500., 5000, 0., 5000.);
53 m_h_S_rz_A->StatOverflows();
54 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_rz_A->GetName(), m_h_S_rz_A));
55
56 m_h_S_rz_C = new TH2D("h_stgc_S_rz_C","S_rz_C", 2000, -8500., -6500., 5000, 0., 5000.);
57 m_h_S_rz_C->StatOverflows();
58 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_rz_C->GetName(), m_h_S_rz_C));
59
60
61 m_h_xy_A = new TH2D("h_stgc_xy_A","xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
62 m_h_xy_A->StatOverflows();
63 ATH_CHECK(histSvc()->regHist(m_path + m_h_xy_A->GetName(), m_h_xy_A));
64
65 m_h_xy_C = new TH2D("h_stgc_xy_C","xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
66 m_h_xy_C->StatOverflows();
67 ATH_CHECK(histSvc()->regHist(m_path + m_h_xy_C->GetName(), m_h_xy_C));
68
69 m_h_L_xy_A = new TH2D("h_stgc_L_xy_A","L_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
70 m_h_L_xy_A->StatOverflows();
71 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_xy_A->GetName(), m_h_L_xy_A));
72
73 m_h_L_xy_C = new TH2D("h_stgc_L_xy_C","L_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
74 m_h_L_xy_C->StatOverflows();
75 ATH_CHECK(histSvc()->regHist(m_path + m_h_L_xy_C->GetName(), m_h_L_xy_C));
76
77 m_h_S_xy_A = new TH2D("h_stgc_S_xy_A","S_xy_A", 1200,-6000., 6000., 1200, -6000., 6000.);
78 m_h_S_xy_A->StatOverflows();
79 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_xy_A->GetName(), m_h_S_xy_A));
80
81 m_h_S_xy_C = new TH2D("h_stgc_S_xy_C","S_xy_C", 1200,-6000., 6000., 1200, -6000., 6000.);
82 m_h_S_xy_C->StatOverflows();
83 ATH_CHECK(histSvc()->regHist(m_path + m_h_S_xy_C->GetName(), m_h_S_xy_C));
84
85 m_h_r_A = new TH1D("h_stgc_r_A","r_A", 1000,0., 14000.);
86 m_h_r_A->StatOverflows();
87 ATH_CHECK(histSvc()->regHist(m_path + m_h_r_A->GetName(), m_h_r_A));
88
89 m_h_r_C = new TH1D("h_stgc_r_C","r_C", 1000,0., 14000.);
90 m_h_r_C->StatOverflows();
91 ATH_CHECK(histSvc()->regHist(m_path + m_h_r_C->GetName(), m_h_r_C));
92
93
94 return StatusCode::SUCCESS;
95}
96
98 ATH_MSG_DEBUG( "In sTGCHitAnalysis::execute()" );
99
100 const EventContext& ctx{Gaudi::Hive::currentContext()};
101 const sTGCSimHitCollection* p_collection{nullptr};
102 ATH_CHECK(SG::get(p_collection, m_readKey, ctx));
103 for (sTGCSimHitCollection::const_iterator i_hit = p_collection->begin(); i_hit != p_collection->end(); ++i_hit){
104
105 Amg::Vector3D p = (*i_hit).globalPosition();
106 //Get station names and make plots for each wedge
107 const sTgcHitIdHelper* hitHelper = sTgcHitIdHelper::GetHelper();
108 int simId = (*i_hit).sTGCId();
109 std::string sim_stationName = hitHelper->GetStationName(simId);
110
111 static const std::string QS1C("QS1C");
112 static const std::string QS2C("QS2C");
113 static const std::string QS3C("QS3C");
114 static const std::string QL1P("QL1P");
115 static const std::string QL2P("QL2P");
116 static const std::string QL3P("QL3P");
117
118 int sim_side = hitHelper->GetSide(simId);
119
120 if ( sim_side==1){ //Both sectors A side
121 double r_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
122 m_h_rz_A->Fill(p.z(), r_A);
123 m_h_xy_A->Fill(p.x(), p.y());
124 m_h_r_A->Fill(r_A);
125 }
126
127 if ( sim_side==-1){ //Both sectors C side
128 double r_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
129 m_h_rz_C->Fill(p.z(), r_C);
130 m_h_xy_C->Fill(p.x(), p.y());
131 m_h_r_C->Fill(r_C);
132 }
133
134 if ((sim_stationName==QS1C || sim_stationName==QS2C || sim_stationName==QS3C) && sim_side==1){ //Small sectors A side
135 double r_S_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
136 m_h_S_rz_A->Fill(p.z(), r_S_A);
137 m_h_S_xy_A->Fill(p.x(), p.y());
138 }
139
140 if ((sim_stationName==QS1C || sim_stationName==QS2C || sim_stationName==QS3C) && sim_side==-1){ //Small sectors C side
141 double r_S_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
142 m_h_S_rz_C->Fill(p.z(), r_S_C);
143 m_h_S_xy_C->Fill(p.x(), p.y());
144 }
145
146 if ((sim_stationName==QL1P || sim_stationName==QL2P || sim_stationName==QL3P) && sim_side==1){ //Large sectors A side
147 double r_L_A = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
148 m_h_L_rz_A->Fill(p.z(), r_L_A);
149 m_h_L_xy_A->Fill(p.x(), p.y());
150 }
151
152 if ((sim_stationName==QL1P || sim_stationName==QL2P || sim_stationName==QL3P) && sim_side==-1){ //Large sectors C side
153 double r_L_C = std::sqrt(p.x()*p.x()+p.y()*p.y()); //Evaluate r
154 m_h_L_rz_C->Fill(p.z(), r_L_C);
155 m_h_L_xy_C->Fill(p.x(), p.y());
156 }
157
158 }
159 return StatusCode::SUCCESS;
160}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
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
TH2 * m_h_S_rz_A
Some variables.
SG::ReadHandleKey< sTGCSimHitCollection > m_readKey
virtual StatusCode execute() override
virtual StatusCode initialize() override
Gaudi::Property< std::string > m_path
int GetSide(const int &hid) const
std::string GetStationName(const int &hid) const
static const sTgcHitIdHelper * GetHelper()
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.
AtlasHitsVector< sTGCSimHit > sTGCSimHitCollection