ATLAS Offline Software
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 
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 
31 {}
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 
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 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CBNT_UpstreamMat::m_key
std::string m_key
Definition: CBNT_UpstreamMat.h:22
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
CBNT_UpstreamMat::m_notFound
bool m_notFound
Definition: CBNT_UpstreamMat.h:23
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CBNT_UpstreamMat.h
AtlasHitsVector
Definition: AtlasHitsVector.h:33
CBNT_UpstreamMat::m_ElecEne
std::vector< float > * m_ElecEne
Definition: CBNT_UpstreamMat.h:27
CBNT_UpstreamMat::m_PhotAng
std::vector< float > * m_PhotAng
Definition: CBNT_UpstreamMat.h:31
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
CBNT_UpstreamMat::CBNT_execute
virtual StatusCode CBNT_execute() override
Definition: CBNT_UpstreamMat.cxx:49
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
CBNT_TBRecBase
Definition: CBNT_TBRecBase.h:21
StdJOSetup.msgSvc
msgSvc
Provide convenience handles for various services.
Definition: StdJOSetup.py:36
CBNT_UpstreamMat::CBNT_finalize
virtual StatusCode CBNT_finalize() override
Definition: CBNT_UpstreamMat.cxx:87
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CBNT_TBRecBase::addBranch
void addBranch(const std::string &branchname, T &obj, const std::string &leaflist)
Definition: CBNT_TBRecBase.h:44
TileDCSDataPlotter.pr
pr
Definition: TileDCSDataPlotter.py:922
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CBNT_UpstreamMat::m_PhotEne
std::vector< float > * m_PhotEne
Definition: CBNT_UpstreamMat.h:30
CBNT_UpstreamMat::m_nPhot
long m_nPhot
Definition: CBNT_UpstreamMat.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrackRecordCollection.h
CBNT_UpstreamMat::CBNT_initialize
virtual StatusCode CBNT_initialize() override
Definition: CBNT_UpstreamMat.cxx:34
CBNT_UpstreamMat::m_nElec
long m_nElec
Definition: CBNT_UpstreamMat.h:26
TrackRecord
Definition: TrackRecord.h:10
CBNT_UpstreamMat::CBNT_clear
virtual StatusCode CBNT_clear() override
Definition: CBNT_UpstreamMat.cxx:92
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
CBNT_UpstreamMat::m_ElecAng
std::vector< float > * m_ElecAng
Definition: CBNT_UpstreamMat.h:28
CBNT_UpstreamMat.CBNT_UpstreamMat
CBNT_UpstreamMat
Definition: CBNT_UpstreamMat.py:8
StoreGateSvc.h
CBNT_UpstreamMat::~CBNT_UpstreamMat
virtual ~CBNT_UpstreamMat()
Definition: CBNT_UpstreamMat.cxx:30