ATLAS Offline Software
Loading...
Searching...
No Matches
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
8
9#include "GaudiKernel/MsgStream.h"
11
12
13using CLHEP::Hep3Vector;
14
15
16CBNT_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
32
33
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
50 MsgStream log(msgSvc(), name());
51 //Set to zero:
52 m_nElec=0;
53 m_nPhot=0;
54
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
88
89 return StatusCode::SUCCESS;
90}
91
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}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
AtlasHitsVector< TrackRecord > TrackRecordCollection
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
virtual StatusCode CBNT_finalize() override
virtual StatusCode CBNT_execute() override
std::vector< float > * m_PhotEne
std::vector< float > * m_ElecAng
std::vector< float > * m_ElecEne
virtual StatusCode CBNT_clear() override
virtual StatusCode CBNT_initialize() override
std::vector< float > * m_PhotAng
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114