ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
TestBeam
TBRec
src
CBNT_UpstreamMat.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
CBNT_UpstreamMat.h
"
6
7
#include "
StoreGate/StoreGateSvc.h
"
8
9
#include "GaudiKernel/MsgStream.h"
10
#include "
TrackRecord/TrackRecordCollection.h
"
11
12
13
using
CLHEP::Hep3Vector;
14
15
16
CBNT_UpstreamMat::CBNT_UpstreamMat
(
const
std::string & name, ISvcLocator * pSvcLocator) :
17
CBNT_TBRecBase
(
name
, pSvcLocator)
18
{
19
declareProperty(
"CollectionName"
,m_key);
20
m_notFound=
false
;
21
m_nElec = 0;
22
m_nPhot = 0;
23
m_ElecAng = 0;
24
m_ElecEne = 0;
25
m_PhotAng = 0;
26
m_PhotEne = 0;
27
}
28
29
30
CBNT_UpstreamMat::~CBNT_UpstreamMat
()
31
{}
32
33
34
StatusCode
CBNT_UpstreamMat::CBNT_initialize
() {
35
MsgStream log(msgSvc(), name());
36
37
addBranch
(
"UPSTREAMMAT/up_nElec"
,
m_nElec
,
"/l"
);
38
addBranch
(
"UPSTREAMMAT/up_nPhot"
,
m_nPhot
,
"/l"
);
39
40
addBranch
(
"UPSTREAMMAT/up_ElecEne"
,
m_ElecEne
);
41
addBranch
(
"UPSTREAMMAT/up_ElecAng"
,
m_ElecAng
);
42
43
addBranch
(
"UPSTREAMMAT/up_PhotEne"
,
m_PhotEne
);
44
addBranch
(
"UPSTREAMMAT/up_PhotAng"
,
m_PhotAng
);
45
46
return
StatusCode::SUCCESS;
47
}
48
49
StatusCode
CBNT_UpstreamMat::CBNT_execute
() {
50
MsgStream log(msgSvc(), name());
51
//Set to zero:
52
m_nElec
=0;
53
m_nPhot
=0;
54
55
if
(!
evtStore
()->
contains<TrackRecordCollection>
(
m_key
)) {
56
if
(!
m_notFound
) {
57
log << MSG::WARNING <<
"TrackRecordCollection with key "
<<
m_key
<<
" not found"
<<
endmsg
;
58
m_notFound
=
true
;
59
}
60
return
StatusCode::SUCCESS;
61
}
62
const
TrackRecordCollection
*trackRecordCollection(0);
63
ATH_CHECK
(
evtStore
()->retrieve(trackRecordCollection,
m_key
) );
64
65
for
(
const
TrackRecord
& trackRecord : *trackRecordCollection) {
66
const
int
pdgCode=trackRecord.GetPDGCode();
67
Hep3Vector p=trackRecord.GetMomentum();
68
double
pr=sqrt(p.y()*p.y()+p.z()*p.z());
69
double
alpha=atan(pr/p.x());
70
if
(pdgCode==22) {
//Photon
71
m_PhotEne
->push_back(trackRecord.GetEnergy());
72
m_PhotAng
->push_back(alpha);
//in radiants
73
m_nPhot
++;
74
}
75
else
if
(pdgCode==11 || pdgCode==-11) {
//Electron or photon
76
m_ElecEne
->push_back(trackRecord.GetEnergy());
77
m_ElecAng
->push_back(alpha);
//in radiants
78
m_nElec
++;
79
}
80
else
81
log << MSG::INFO <<
"Found particle code "
<< pdgCode <<
endmsg
;
82
}
//end loop over TrackRecords
83
84
return
StatusCode::SUCCESS;
85
}
86
87
StatusCode
CBNT_UpstreamMat::CBNT_finalize
() {
88
89
return
StatusCode::SUCCESS;
90
}
91
92
StatusCode
CBNT_UpstreamMat::CBNT_clear
() {
93
if
(
m_ElecEne
)
m_ElecEne
->clear();
94
if
(
m_ElecAng
)
m_ElecAng
->clear();
95
if
(
m_PhotEne
)
m_PhotEne
->clear();
96
if
(
m_PhotAng
)
m_PhotAng
->clear();
97
98
return
StatusCode::SUCCESS;
99
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
CBNT_UpstreamMat.h
StoreGateSvc.h
TrackRecordCollection.h
TrackRecordCollection
AtlasHitsVector< TrackRecord > TrackRecordCollection
Definition
TrackRecordCollection.h:12
AthCommonAlgorithm< Gaudi::Algorithm >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
CBNT_TBRecBase
Definition
CBNT_TBRecBase.h:21
CBNT_TBRecBase::addBranch
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
Definition
CBNT_TBRecBase.h:44
CBNT_UpstreamMat::m_key
std::string m_key
Definition
CBNT_UpstreamMat.h:22
CBNT_UpstreamMat::~CBNT_UpstreamMat
virtual ~CBNT_UpstreamMat()
Definition
CBNT_UpstreamMat.cxx:30
CBNT_UpstreamMat::m_notFound
bool m_notFound
Definition
CBNT_UpstreamMat.h:23
CBNT_UpstreamMat::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition
CBNT_UpstreamMat.cxx:87
CBNT_UpstreamMat::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition
CBNT_UpstreamMat.cxx:49
CBNT_UpstreamMat::m_PhotEne
std::vector< float > * m_PhotEne
Definition
CBNT_UpstreamMat.h:30
CBNT_UpstreamMat.CBNT_UpstreamMat
CBNT_UpstreamMat
Definition
CBNT_UpstreamMat.py:8
CBNT_UpstreamMat::m_ElecAng
std::vector< float > * m_ElecAng
Definition
CBNT_UpstreamMat.h:28
CBNT_UpstreamMat::m_ElecEne
std::vector< float > * m_ElecEne
Definition
CBNT_UpstreamMat.h:27
CBNT_UpstreamMat::m_nElec
long m_nElec
Definition
CBNT_UpstreamMat.h:26
CBNT_UpstreamMat::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition
CBNT_UpstreamMat.cxx:92
CBNT_UpstreamMat::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition
CBNT_UpstreamMat.cxx:34
CBNT_UpstreamMat::m_PhotAng
std::vector< float > * m_PhotAng
Definition
CBNT_UpstreamMat.h:31
CBNT_UpstreamMat::m_nPhot
long m_nPhot
Definition
CBNT_UpstreamMat.h:29
TrackRecord
Definition
TrackRecord.h:12
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
extractSporadic.name
name
Definition
extractSporadic.py:101
Generated on
for ATLAS Offline Software by
1.17.0