ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
Tools
HitAnalysis
src
AFPHitAnalysis.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 "
AFPHitAnalysis.h
"
6
7
#include "
StoreGate/ReadHandle.h
"
8
#include "
AFP_SimEv/AFP_SIDSimHit.h
"
9
10
11
12
13
StatusCode
AFPHitAnalysis::initialize
() {
14
ATH_MSG_DEBUG
(
"Initializing AFPHitAnalysis"
);
15
16
ATH_CHECK
(
m_readKey
.initialize());
18
m_h_hitID
=
new
TH1D(
"h_hitID"
,
"hitID"
,100, 0., 100.);
19
m_h_hitID
->StatOverflows();
20
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_hitID
->GetName(),
m_h_hitID
));
21
22
m_h_pdgID
=
new
TH1D(
"h_pdgID"
,
"pdgID"
, 200, -100,100);
23
m_h_pdgID
->StatOverflows();
24
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_pdgID
->GetName(),
m_h_pdgID
));
25
26
m_h_trackID
=
new
TH1D(
"h_trackID"
,
"trackID"
, 100, 0,100);
27
m_h_trackID
->StatOverflows();
28
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_trackID
->GetName(),
m_h_trackID
));
29
30
m_h_kine
=
new
TH1D(
"h_kine"
,
"kine"
, 100, 0,1000);
31
m_h_kine
->StatOverflows();
32
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_kine
->GetName(),
m_h_kine
));
33
34
m_h_edep
=
new
TH1D(
"h_edep"
,
"edep"
, 100, 0,1000);
35
m_h_edep
->StatOverflows();
36
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_edep
->GetName(),
m_h_edep
));
37
38
m_h_stepX
=
new
TH1D(
"h_stepX"
,
"stepX"
, 100, 0,1000);
39
m_h_stepX
->StatOverflows();
40
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_stepX
->GetName(),
m_h_stepX
));
41
42
m_h_stepY
=
new
TH1D(
"h_stepY"
,
"stepY"
, 100, 0,1000);
43
m_h_stepY
->StatOverflows();
44
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_stepY
->GetName(),
m_h_stepY
));
45
46
m_h_stepZ
=
new
TH1D(
"h_stepZ"
,
"stepZ"
, 100, 0,1000);
47
m_h_stepZ
->StatOverflows();
48
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_stepZ
->GetName(),
m_h_stepZ
));
49
50
m_h_stationID
=
new
TH1D(
"h_stationID"
,
"stationID"
, 50, 0,50);
51
m_h_stationID
->StatOverflows();
52
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_stationID
->GetName(),
m_h_stationID
));
53
54
m_h_detID
=
new
TH1D(
"h_detID"
,
"detID"
, 50, 0,50);
55
m_h_detID
->StatOverflows();
56
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_detID
->GetName(),
m_h_detID
));
57
58
m_h_pixelRow
=
new
TH1D(
"h_pixelRow"
,
"pixelRow"
, 20, 0,20);
59
m_h_pixelRow
->StatOverflows();
60
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_pixelRow
->GetName(),
m_h_pixelRow
));
61
62
m_h_pixelCol
=
new
TH1D(
"h_pixelCol"
,
"pixelCol"
, 20, 0,20);
63
m_h_pixelCol
->StatOverflows();
64
ATH_CHECK
(
histSvc
()->regHist(
m_path
+
m_h_pixelCol
->GetName(),
m_h_pixelCol
));
65
67
m_tree
=
new
TTree(
"AFP"
,
"AFP"
);
68
std::string fullNtupleName =
"/"
+
m_ntupleFileName
+
"/"
;
69
ATH_CHECK
(
histSvc
()->regTree(fullNtupleName,
m_tree
));
70
71
if
(
m_tree
){
72
m_tree
->Branch(
"hitID"
, &
m_hitID
);
73
m_tree
->Branch(
"pdgID"
, &
m_pdgID
);
74
m_tree
->Branch(
"trackID"
, &
m_trackID
);
75
m_tree
->Branch(
"kine"
, &
m_kine
);
76
m_tree
->Branch(
"edep"
, &
m_edep
);
77
m_tree
->Branch(
"stepX"
, &
m_stepX
);
78
m_tree
->Branch(
"stepY"
, &
m_stepY
);
79
m_tree
->Branch(
"stepZ"
, &
m_stepZ
);
80
m_tree
->Branch(
"stationID"
, &
m_stationID
);
81
m_tree
->Branch(
"detID"
, &
m_detID
);
82
m_tree
->Branch(
"pixelRow"
, &
m_pixelRow
);
83
m_tree
->Branch(
"pixelCol"
, &
m_pixelCol
);
84
}
85
86
ATH_MSG_INFO
(
"Exiting AFPHitAnalysis::initialize()"
);
87
88
return
StatusCode::SUCCESS;
89
}
90
91
92
StatusCode
AFPHitAnalysis::execute
(
const
EventContext& ctx) {
93
ATH_MSG_DEBUG
(
"In AFPHitAnalysis::execute()"
);
94
95
m_hitID
->clear();
96
m_pdgID
->clear();
97
m_trackID
->clear();
98
m_kine
->clear();
99
m_edep
->clear();
100
m_stepX
->clear();
101
m_stepY
->clear();
102
m_stepZ
->clear();
103
m_time
->clear();
104
m_stationID
->clear();
105
m_detID
->clear();
106
m_pixelRow
->clear();
107
m_pixelCol
->clear();
108
109
ATH_MSG_INFO
(
"AFPHitAnalysis tree branches cleared"
);
110
111
AFP_SIDSimHitConstIter
hi;
112
113
const
AFP_SIDSimHitCollection
* iter{
nullptr
};
114
ATH_CHECK
(
SG::get
(iter,
m_readKey
, ctx));
115
116
ATH_MSG_DEBUG
(
"AFP_SIDSSimHitCollection retrieved"
);
117
118
for
( hi=(*iter).begin(); hi != (*iter).end(); ++hi ) {
119
AFP_SIDSimHit
ghit(*hi);
120
m_h_hitID
->Fill(ghit.
m_nHitID
);
121
m_h_pdgID
->Fill(ghit.
m_nParticleEncoding
);
122
m_h_trackID
->Fill(ghit.
m_nTrackID
);
123
m_h_kine
->Fill(ghit.
m_fKineticEnergy
);
124
m_h_edep
->Fill(ghit.
m_fEnergyDeposit
);
125
m_h_stepX
->Fill(ghit.
m_fPostStepX
-ghit.
m_fPreStepX
);
126
m_h_stepY
->Fill(ghit.
m_fPostStepY
-ghit.
m_fPreStepY
);
127
m_h_stepX
->Fill(ghit.
m_fPostStepZ
-ghit.
m_fPreStepZ
);
128
m_h_time
->Fill(ghit.
m_fGlobalTime
);
129
m_h_stationID
->Fill(ghit.
m_nStationID
);
130
m_h_detID
->Fill(ghit.
m_nDetectorID
);
131
m_h_pixelRow
->Fill(ghit.
m_nPixelRow
);
132
m_h_pixelCol
->Fill(ghit.
m_nPixelCol
);
133
134
m_hitID
->push_back(ghit.
m_nHitID
);
135
m_pdgID
->push_back(ghit.
m_nParticleEncoding
);
136
m_trackID
->push_back(ghit.
m_nTrackID
);
137
m_kine
->push_back(ghit.
m_fKineticEnergy
);
138
m_edep
->push_back(ghit.
m_fEnergyDeposit
);
139
m_stepX
->push_back(ghit.
m_fPostStepX
-ghit.
m_fPreStepX
);
140
m_stepY
->push_back(ghit.
m_fPostStepY
-ghit.
m_fPreStepY
);
141
m_stepX
->push_back(ghit.
m_fPostStepZ
-ghit.
m_fPreStepZ
);
142
m_time
->push_back(ghit.
m_fGlobalTime
);
143
m_stationID
->push_back(ghit.
m_nStationID
);
144
m_detID
->push_back(ghit.
m_nDetectorID
);
145
m_pixelRow
->push_back(ghit.
m_nPixelRow
);
146
m_pixelCol
->push_back(ghit.
m_nPixelCol
);
147
}
148
149
if
(
m_tree
)
m_tree
->Fill();
150
151
return
StatusCode::SUCCESS;
152
}
AFPHitAnalysis.h
AFP_SIDSimHitConstIter
AtlasHitsVector< AFP_SIDSimHit >::const_iterator AFP_SIDSimHitConstIter
Definition
AFP_SIDSimHitCollection.h:15
AFP_SIDSimHitCollection
AtlasHitsVector< AFP_SIDSimHit > AFP_SIDSimHitCollection
Definition
AFP_SIDSimHitCollection.h:13
AFP_SIDSimHit.h
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
ReadHandle.h
Handle class for reading from StoreGate.
AFPHitAnalysis::m_stepZ
std::vector< float > * m_stepZ
Definition
AFPHitAnalysis.h:46
AFPHitAnalysis::m_h_pdgID
TH1 * m_h_pdgID
Definition
AFPHitAnalysis.h:26
AFPHitAnalysis::m_edep
std::vector< float > * m_edep
Definition
AFPHitAnalysis.h:43
AFPHitAnalysis::m_hitID
std::vector< float > * m_hitID
Definition
AFPHitAnalysis.h:39
AFPHitAnalysis::m_h_stationID
TH1 * m_h_stationID
Definition
AFPHitAnalysis.h:34
AFPHitAnalysis::initialize
virtual StatusCode initialize() override final
Definition
AFPHitAnalysis.cxx:13
AFPHitAnalysis::m_pixelCol
std::vector< int > * m_pixelCol
Definition
AFPHitAnalysis.h:51
AFPHitAnalysis::m_ntupleFileName
Gaudi::Property< std::string > m_ntupleFileName
Definition
AFPHitAnalysis.h:54
AFPHitAnalysis::m_pdgID
std::vector< float > * m_pdgID
Definition
AFPHitAnalysis.h:40
AFPHitAnalysis::execute
virtual StatusCode execute(const EventContext &ctx) override final
Execute method.
Definition
AFPHitAnalysis.cxx:92
AFPHitAnalysis::m_h_stepZ
TH1 * m_h_stepZ
Definition
AFPHitAnalysis.h:32
AFPHitAnalysis::m_readKey
SG::ReadHandleKey< AFP_SIDSimHitCollection > m_readKey
Definition
AFPHitAnalysis.h:56
AFPHitAnalysis::m_detID
std::vector< int > * m_detID
Definition
AFPHitAnalysis.h:49
AFPHitAnalysis::m_h_kine
TH1 * m_h_kine
Definition
AFPHitAnalysis.h:28
AFPHitAnalysis::m_stepY
std::vector< float > * m_stepY
Definition
AFPHitAnalysis.h:45
AFPHitAnalysis::m_h_pixelRow
TH1 * m_h_pixelRow
Definition
AFPHitAnalysis.h:36
AFPHitAnalysis::m_stationID
std::vector< int > * m_stationID
Definition
AFPHitAnalysis.h:48
AFPHitAnalysis::m_h_edep
TH1 * m_h_edep
Definition
AFPHitAnalysis.h:29
AFPHitAnalysis::m_stepX
std::vector< float > * m_stepX
Definition
AFPHitAnalysis.h:44
AFPHitAnalysis::m_h_stepY
TH1 * m_h_stepY
Definition
AFPHitAnalysis.h:31
AFPHitAnalysis::m_path
Gaudi::Property< std::string > m_path
Definition
AFPHitAnalysis.h:55
AFPHitAnalysis::m_trackID
std::vector< float > * m_trackID
Definition
AFPHitAnalysis.h:41
AFPHitAnalysis::m_h_pixelCol
TH1 * m_h_pixelCol
Definition
AFPHitAnalysis.h:37
AFPHitAnalysis::m_h_hitID
TH1 * m_h_hitID
Some histograms.
Definition
AFPHitAnalysis.h:25
AFPHitAnalysis::m_kine
std::vector< float > * m_kine
Definition
AFPHitAnalysis.h:42
AFPHitAnalysis::m_h_detID
TH1 * m_h_detID
Definition
AFPHitAnalysis.h:35
AFPHitAnalysis::m_h_trackID
TH1 * m_h_trackID
Definition
AFPHitAnalysis.h:27
AFPHitAnalysis::m_time
std::vector< float > * m_time
Definition
AFPHitAnalysis.h:47
AFPHitAnalysis::m_pixelRow
std::vector< int > * m_pixelRow
Definition
AFPHitAnalysis.h:50
AFPHitAnalysis::m_h_time
TH1 * m_h_time
Definition
AFPHitAnalysis.h:33
AFPHitAnalysis::m_tree
TTree * m_tree
Definition
AFPHitAnalysis.h:53
AFPHitAnalysis::m_h_stepX
TH1 * m_h_stepX
Definition
AFPHitAnalysis.h:30
AFP_SIDSimHit
Definition
AFP_SIDSimHit.h:9
AFP_SIDSimHit::m_nPixelCol
int m_nPixelCol
Definition
AFP_SIDSimHit.h:35
AFP_SIDSimHit::m_nDetectorID
int m_nDetectorID
Definition
AFP_SIDSimHit.h:31
AFP_SIDSimHit::m_nParticleEncoding
int m_nParticleEncoding
Definition
AFP_SIDSimHit.h:19
AFP_SIDSimHit::m_nStationID
int m_nStationID
Definition
AFP_SIDSimHit.h:30
AFP_SIDSimHit::m_fPostStepX
float m_fPostStepX
Definition
AFP_SIDSimHit.h:25
AFP_SIDSimHit::m_fPostStepZ
float m_fPostStepZ
Definition
AFP_SIDSimHit.h:27
AFP_SIDSimHit::m_fKineticEnergy
float m_fKineticEnergy
Definition
AFP_SIDSimHit.h:20
AFP_SIDSimHit::m_nTrackID
int m_nTrackID
Definition
AFP_SIDSimHit.h:18
AFP_SIDSimHit::m_fGlobalTime
float m_fGlobalTime
Definition
AFP_SIDSimHit.h:28
AFP_SIDSimHit::m_fEnergyDeposit
float m_fEnergyDeposit
Definition
AFP_SIDSimHit.h:21
AFP_SIDSimHit::m_nPixelRow
int m_nPixelRow
Definition
AFP_SIDSimHit.h:34
AFP_SIDSimHit::m_nHitID
int m_nHitID
Definition
AFP_SIDSimHit.h:17
AFP_SIDSimHit::m_fPreStepZ
float m_fPreStepZ
Definition
AFP_SIDSimHit.h:24
AFP_SIDSimHit::m_fPreStepX
float m_fPreStepX
Definition
AFP_SIDSimHit.h:22
AFP_SIDSimHit::m_fPostStepY
float m_fPostStepY
Definition
AFP_SIDSimHit.h:26
AFP_SIDSimHit::m_fPreStepY
float m_fPreStepY
Definition
AFP_SIDSimHit.h:23
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
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