ATLAS Offline Software
RpvElectronD0Tool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // RpvElectronD0Tool.cxx, (c) ATLAS Detector software
8 // Author: Mike Flowerdew (Michael.Flowerdew@cern.ch)
9 // Tool to write lepton d0 in a way accessible by derivation framwork tools
10 // Writes result to SG for later selection by string parser
11 
13 #include <vector>
14 #include <string>
15 
16 // Constructor
18  const std::string& n,
19  const IInterface* p ) :
20  AthAlgTool(t,n,p)
21  {
22  declareInterface<DerivationFramework::IAugmentationTool>(this);
23  }
24 
25 // Destructor
27 }
28 
29 // Athena initialize and finalize
31 {
32  ATH_MSG_VERBOSE("initialize() ...");
33  ATH_CHECK(m_collNameKey.initialize());
34  ATH_CHECK(m_electronsd0Key.initialize());
35  return StatusCode::SUCCESS;
36 }
38 {
39  ATH_MSG_VERBOSE("finalize() ...");
40  return StatusCode::SUCCESS;
41 }
42 
43 // Augmentation
45 {
46 
47  // Retrieve data
49  if( !electrons.isValid() ) {
50  ATH_MSG_ERROR("Couldn't retrieve e-gamma container with key: " << m_collNameKey);
51  return StatusCode::FAILURE;
52  }
53 
54  // Write decision to SG for access by downstream algs
55  SG::WriteHandle< std::vector<float> > d0vec(m_electronsd0Key);
56  ATH_CHECK(d0vec.record(std::make_unique< std::vector<float> >()));
57 
58  // Loop over electrons, set decisions
59  for (xAOD::ElectronContainer::const_iterator eIt = electrons->begin(); eIt!=electrons->end(); ++eIt) {
60 
61  float d0 = 9e99;
62  if (*eIt && (*eIt)->trackParticle()) d0 = (*eIt)->trackParticle()->d0();
63  else ATH_MSG_WARNING("Problem accessing electron track!");
64 
65  d0vec->push_back(d0);
66 
67  }
68 
69  return StatusCode::SUCCESS;
70 
71 }
72 
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
DerivationFramework::RpvElectronD0Tool::RpvElectronD0Tool
RpvElectronD0Tool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: RpvElectronD0Tool.cxx:17
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::RpvElectronD0Tool::finalize
StatusCode finalize()
Definition: RpvElectronD0Tool.cxx:37
RpvElectronD0Tool.h
DerivationFramework::RpvElectronD0Tool::~RpvElectronD0Tool
~RpvElectronD0Tool()
Destructor.
Definition: RpvElectronD0Tool.cxx:26
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TRT::Track::d0
@ d0
Definition: InnerDetector/InDetCalibEvent/TRT_CalibData/TRT_CalibData/TrackInfo.h:62
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
AthAlgTool
Definition: AthAlgTool.h:26
DerivationFramework::RpvElectronD0Tool::addBranches
virtual StatusCode addBranches() const
Check that the current event passes this filter.
Definition: RpvElectronD0Tool.cxx:44
DerivationFramework::RpvElectronD0Tool::initialize
StatusCode initialize()
Definition: RpvElectronD0Tool.cxx:30
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17