ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Tools
HitAnalysis
src
TrackRecordAnalysis.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 "
TrackRecordAnalysis.h
"
6
7
// Section of includes for TrackRecord tests
8
#include "
TrackRecord/TrackRecord.h
"
9
#include "CLHEP/Vector/LorentzVector.h"
10
#include "
StoreGate/ReadHandle.h
"
11
12
13
StatusCode
TrackRecordAnalysis::initialize
() {
14
ATH_MSG_DEBUG
(
"Initializing TrackRecordAnalysis"
);
15
16
std::string detName =
"CaloEntry"
;
17
std::string ntupName =
"TrackRecordCaloEntry"
;
18
ATH_CHECK
(
m_readKey
.initialize());
19
if
(
m_readKey
.key() ==
"CaloEntryLayer"
) {
20
detName=
"CaloEntry"
;
21
ntupName=
"TrackRecordCaloEntry"
;
22
}
23
else
if
(
m_readKey
.key( )==
"MuonEntryLayer"
) {
24
detName=
"MuonEntry"
;
25
ntupName=
"TrackRecordMuonEntry"
;
26
}
27
else
if
(
m_readKey
.key() ==
"MuonExitLayer"
) {
28
detName=
"MuonExit"
;
29
ntupName=
"TrackRecordMuonExit"
;
30
}
31
else
{
32
ATH_MSG_ERROR
(
"TrackRecordAnalysis for "
<< name() <<
"not supported !!! \n"
);
33
return
StatusCode::FAILURE;
34
}
35
36
37
float
x_down = -5000;
38
float
x_up = 5000;
39
float
radius = 4500;
40
float
eta_down = -5.8;
41
float
eta_up = 5.8;
42
float
z_down = -7000;
43
float
z_up = 7000;
44
if
(detName ==
"CaloEntry"
) {
45
x_down = -1180;
46
x_up = 1180;
47
radius = 1200;
48
eta_down = - 5.6;
49
eta_up = 5.6;
50
z_down = -3700;
51
z_up = 3700;
52
}
53
55
m_h_hits_x
=
new
TH1D((detName+
"_x"
).c_str(),
"hits_x"
, 100,x_down, x_up);
56
m_h_hits_x
->StatOverflows();
57
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_x
->GetName(),
m_h_hits_x
));
58
59
m_h_hits_y
=
new
TH1D((detName+
"_y"
).c_str(),
"hits_y"
, 100,x_down,x_up);
60
m_h_hits_y
->StatOverflows();
61
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_y
->GetName(),
m_h_hits_y
));
62
63
m_h_hits_z
=
new
TH1D((detName+
"_z"
).c_str(),
"hits_z"
, 100,z_down,z_up);
64
m_h_hits_z
->StatOverflows();
65
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_z
->GetName(),
m_h_hits_z
));
66
67
m_h_hits_r
=
new
TH1D((detName+
"_r"
).c_str(),
"hits_r"
, 100,0,radius);
68
m_h_hits_r
->StatOverflows();
69
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_r
->GetName(),
m_h_hits_r
));
70
71
m_h_xy
=
new
TH2D((detName+
"_xy"
).c_str(),
"xy"
, 100,x_down,x_up,100, x_down, x_up);
72
m_h_xy
->StatOverflows();
73
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_xy
->GetName(),
m_h_xy
));
74
75
m_h_zr
=
new
TH2D((detName+
"_zr"
).c_str(),
"zr"
, 100,z_down,z_up,100, 0., radius);
76
m_h_zr
->StatOverflows();
77
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_zr
->GetName(),
m_h_zr
));
78
79
m_h_hits_eta
=
new
TH1D((detName+
"_eta"
).c_str(),
"hits_eta"
, 100,eta_down,eta_up);
80
m_h_hits_eta
->StatOverflows();
81
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_eta
->GetName(),
m_h_hits_eta
));
82
83
m_h_hits_phi
=
new
TH1D((detName+
"_phi"
).c_str(),
"hits_phi"
, 100,-3.1416,3.1416);
84
m_h_hits_phi
->StatOverflows();
85
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_phi
->GetName(),
m_h_hits_phi
));
86
87
m_h_hits_px
=
new
TH1D((detName+
"_px"
).c_str(),
"Px"
, 100, -1500, 1500);
88
m_h_hits_px
->StatOverflows();
89
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_px
->GetName(),
m_h_hits_px
));
90
91
m_h_hits_py
=
new
TH1D((detName+
"_py"
).c_str(),
"Py"
, 100,-1500,1500);
92
m_h_hits_py
->StatOverflows();
93
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_py
->GetName(),
m_h_hits_py
));
94
95
m_h_hits_pz
=
new
TH1D((detName+
"_pz"
).c_str(),
"Pz"
, 100,-1500,1500);
96
m_h_hits_pz
->StatOverflows();
97
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_pz
->GetName(),
m_h_hits_pz
));
98
99
m_h_hits_pt
=
new
TH1D((detName+
"_pt"
).c_str(),
"hits_pt"
, 100,0,2500);
100
m_h_hits_pt
->StatOverflows();
101
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hits_pt
->GetName(),
m_h_hits_pt
));
102
103
m_h_time
=
new
TH1D((detName+
"_time"
).c_str(),
"time"
, 100,0, 250);
104
m_h_time
->StatOverflows();
105
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_time
->GetName(),
m_h_time
));
106
107
m_h_edep
=
new
TH1D((detName+
"_edep"
).c_str(),
"energy"
, 100,0,7500);
108
m_h_edep
->StatOverflows();
109
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_edep
->GetName(),
m_h_edep
));
110
111
m_h_pdg
=
new
TH1D((detName+
"_pdg"
).c_str(),
"pdg"
, 100,-1000,1000);
112
m_h_pdg
->StatOverflows();
113
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_pdg
->GetName(),
m_h_pdg
));
114
116
m_tree
=
new
TTree(ntupName.c_str(), ntupName.c_str());
117
std::string fullNtupleName =
"/"
+
m_ntupleFileName
+
"/"
+ detName;
118
ATH_CHECK
(
histSvc
()->regTree(fullNtupleName,
m_tree
));
119
120
m_tree
->Branch(
"x"
, &
m_x
);
121
m_tree
->Branch(
"y"
, &
m_y
);
122
m_tree
->Branch(
"z"
, &
m_z
);
123
m_tree
->Branch(
"r"
, &
m_r
);
124
m_tree
->Branch(
"eta"
, &
m_eta
);
125
m_tree
->Branch(
"phi"
, &
m_phi
);
126
m_tree
->Branch(
"px"
, &
m_px
);
127
m_tree
->Branch(
"py"
, &
m_py
);
128
m_tree
->Branch(
"pz"
, &
m_pz
);
129
m_tree
->Branch(
"pt"
, &
m_pt
);
130
m_tree
->Branch(
"time"
, &
m_time
);
131
m_tree
->Branch(
"energy"
, &
m_edep
);
132
m_tree
->Branch(
"pdg"
, &
m_pdg
);
133
134
return
StatusCode::SUCCESS;
135
}
136
137
138
StatusCode
TrackRecordAnalysis::execute
(
const
EventContext& ctx) {
139
ATH_MSG_DEBUG
(
"In TrackRecordAnalysis::execute()"
);
140
141
m_x
->clear();
142
m_y
->clear();
143
m_z
->clear();
144
m_r
->clear();
145
m_eta
->clear();
146
m_phi
->clear();
147
m_px
->clear();
148
m_py
->clear();
149
m_pz
->clear();
150
m_pt
->clear();
151
m_time
->clear();
152
m_edep
->clear();
153
m_pdg
->clear();
154
155
const
TrackRecordCollection
* TRcoll{
nullptr
};
156
ATH_CHECK
(
SG::get
(TRcoll,
m_readKey
,ctx));
157
for
(
TrackRecordCollection::const_iterator
track = TRcoll->
begin
(); track != TRcoll->
end
(); ++track) {
158
//TrackRecordCollection::const_iterator track;
159
//for(auto track : *TRcoll){
160
//std::cout<<"Entra en el loop"<<std::endl;
161
162
CLHEP::Hep3Vector p =(*track).GetPosition();
163
m_h_hits_x
->Fill(p.x());
164
m_h_hits_y
->Fill(p.y());
165
m_h_hits_z
->Fill(p.z());
166
m_h_hits_r
->Fill(p.perp());
167
m_h_xy
->Fill(p.x(), p.y());
168
m_h_zr
->Fill(p.z(),p.perp());
169
m_h_hits_eta
->Fill(p.eta());
170
m_h_hits_phi
->Fill(p.phi());
171
172
CLHEP::Hep3Vector mom = (*track).GetMomentum();
173
m_h_hits_px
->Fill(mom.x());
174
m_h_hits_py
->Fill(mom.y());
175
m_h_hits_pz
->Fill(mom.z());
176
m_h_hits_pt
->Fill(mom.perp());
177
m_h_edep
->Fill((*track).GetEnergy());
178
m_h_time
->Fill((*track).GetTime());
179
m_h_pdg
->Fill((*track).GetPDGCode());
180
181
m_x
->push_back(p.x());
182
m_y
->push_back(p.y());
183
m_z
->push_back(p.z());
184
m_r
->push_back(p.perp());
185
m_eta
->push_back(p.eta());
186
m_phi
->push_back(p.phi());
187
m_px
->push_back(mom.x());
188
m_py
->push_back(mom.y());
189
m_pz
->push_back(mom.z());
190
m_pt
->push_back(mom.perp());
191
m_edep
->push_back((*track).GetEnergy());
192
m_time
->push_back((*track).GetTime());
193
m_pdg
->push_back((*track).GetPDGCode());
194
}
// End while hits
195
196
m_tree
->Fill();
197
198
return
StatusCode::SUCCESS;
199
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
TrackRecordAnalysis.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
TrackRecord.h
AthHistogramAlgorithm::histSvc
const ServiceHandle< ITHistSvc > & histSvc() const
The standard THistSvc (for writing histograms and TTrees and more to a root file) Returns (kind of) a...
Definition
AthHistogramAlgorithm.h:113
AtlasHitsVector< TrackRecord >::const_iterator
CONT::const_iterator const_iterator
Definition
AtlasHitsVector.h:42
AtlasHitsVector::begin
const_iterator begin() const
Definition
AtlasHitsVector.h:130
AtlasHitsVector::end
const_iterator end() const
Definition
AtlasHitsVector.h:133
TrackRecordAnalysis::m_h_hits_y
TH1 * m_h_hits_y
Definition
TrackRecordAnalysis.h:26
TrackRecordAnalysis::m_h_zr
TH2 * m_h_zr
Definition
TrackRecordAnalysis.h:30
TrackRecordAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition
TrackRecordAnalysis.h:59
TrackRecordAnalysis::m_pdg
std::vector< float > * m_pdg
Definition
TrackRecordAnalysis.h:53
TrackRecordAnalysis::m_h_hits_eta
TH1 * m_h_hits_eta
Definition
TrackRecordAnalysis.h:31
TrackRecordAnalysis::m_edep
std::vector< float > * m_edep
Definition
TrackRecordAnalysis.h:52
TrackRecordAnalysis::m_h_hits_py
TH1 * m_h_hits_py
Definition
TrackRecordAnalysis.h:34
TrackRecordAnalysis::m_h_pdg
TH1 * m_h_pdg
Definition
TrackRecordAnalysis.h:39
TrackRecordAnalysis::m_y
std::vector< float > * m_y
Definition
TrackRecordAnalysis.h:42
TrackRecordAnalysis::m_h_xy
TH2 * m_h_xy
Definition
TrackRecordAnalysis.h:29
TrackRecordAnalysis::m_ntupleFileName
Gaudi::Property< std::string > m_ntupleFileName
Definition
TrackRecordAnalysis.h:58
TrackRecordAnalysis::m_x
std::vector< float > * m_x
Definition
TrackRecordAnalysis.h:41
TrackRecordAnalysis::m_pt
std::vector< float > * m_pt
Definition
TrackRecordAnalysis.h:50
TrackRecordAnalysis::m_px
std::vector< float > * m_px
Definition
TrackRecordAnalysis.h:47
TrackRecordAnalysis::m_h_hits_pz
TH1 * m_h_hits_pz
Definition
TrackRecordAnalysis.h:35
TrackRecordAnalysis::m_time
std::vector< float > * m_time
Definition
TrackRecordAnalysis.h:51
TrackRecordAnalysis::m_h_hits_x
TH1 * m_h_hits_x
Some variables.
Definition
TrackRecordAnalysis.h:25
TrackRecordAnalysis::execute
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
Definition
TrackRecordAnalysis.cxx:138
TrackRecordAnalysis::m_h_hits_z
TH1 * m_h_hits_z
Definition
TrackRecordAnalysis.h:27
TrackRecordAnalysis::m_eta
std::vector< float > * m_eta
Definition
TrackRecordAnalysis.h:45
TrackRecordAnalysis::m_h_time
TH1 * m_h_time
Definition
TrackRecordAnalysis.h:37
TrackRecordAnalysis::m_h_edep
TH1 * m_h_edep
Definition
TrackRecordAnalysis.h:38
TrackRecordAnalysis::m_r
std::vector< float > * m_r
Definition
TrackRecordAnalysis.h:44
TrackRecordAnalysis::m_h_hits_pt
TH1 * m_h_hits_pt
Definition
TrackRecordAnalysis.h:36
TrackRecordAnalysis::m_readKey
SG::ReadHandleKey< TrackRecordCollection > m_readKey
Definition
TrackRecordAnalysis.h:55
TrackRecordAnalysis::m_z
std::vector< float > * m_z
Definition
TrackRecordAnalysis.h:43
TrackRecordAnalysis::m_h_hits_r
TH1 * m_h_hits_r
Definition
TrackRecordAnalysis.h:28
TrackRecordAnalysis::m_py
std::vector< float > * m_py
Definition
TrackRecordAnalysis.h:48
TrackRecordAnalysis::m_h_hits_px
TH1 * m_h_hits_px
Definition
TrackRecordAnalysis.h:33
TrackRecordAnalysis::initialize
virtual StatusCode initialize() override
Definition
TrackRecordAnalysis.cxx:13
TrackRecordAnalysis::m_phi
std::vector< float > * m_phi
Definition
TrackRecordAnalysis.h:46
TrackRecordAnalysis::m_h_hits_phi
TH1 * m_h_hits_phi
Definition
TrackRecordAnalysis.h:32
TrackRecordAnalysis::m_tree
TTree * m_tree
Definition
TrackRecordAnalysis.h:57
TrackRecordAnalysis::m_pz
std::vector< float > * m_pz
Definition
TrackRecordAnalysis.h:49
SG::get
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
Definition
ReadCondHandle.h:282
Generated on
for ATLAS Offline Software by
1.17.0