ATLAS Offline Software
RpvEgammaIDTool.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 // RpvEgammaIDTool.cxx, (c) ATLAS Detector software
8 // Straight copy of DerivationFrameworkEGamma/EGammaPassSelectionWrapper.cxx
9 // because DerivationFrameworkEGamma is not in AtlasProduction
10 // From DerivationFrameworkEGamma/EGammaPassSelectionWrapper.cxx:
11 // Author: James Catmore (James.Catmore@cern.ch)
12 // Wrapper around the passSelection() method of xAOD egamma
13 // Writes result to SG for later selection by string parser
14 
17 #include <vector>
18 #include <string>
19 
20 // Constructor
22  const std::string& n,
23  const IInterface* p ) :
24  AthAlgTool(t,n,p)
25  {
26  declareInterface<DerivationFramework::IAugmentationTool>(this);
27  declareProperty("SelectionVariable",m_selectionString);
28  }
29 
30 // Destructor
32 }
33 
34 // Athena initialize and finalize
36 {
37  ATH_MSG_VERBOSE("initialize() ...");
38  ATH_CHECK(m_collNameKey.initialize());
39  ATH_CHECK(m_egammaSelectionKey.initialize());
40  return StatusCode::SUCCESS;
41 }
43 {
44  ATH_MSG_VERBOSE("finalize() ...");
45  return StatusCode::SUCCESS;
46 }
47 
48 // Augmentation
50 {
51 
52  // Retrieve data
53  SG::ReadHandle<xAOD::EgammaContainer> egammas(m_collNameKey);
54  if( !egammas.isValid() ) {
55  ATH_MSG_ERROR("Couldn't retrieve e-gamma container with key: " << m_collNameKey);
56  return StatusCode::FAILURE;
57  }
58 
59  SG::WriteHandle< std::vector<int> > egammaSelection(m_egammaSelectionKey);
60  ATH_CHECK(egammaSelection.record(std::make_unique< std::vector<int> >()));
61 
62  // Loop over egammas, set decisions
63  for (xAOD::EgammaContainer::const_iterator eIt = egammas->begin(); eIt!=egammas->end(); ++eIt) {
64  bool val(0);
65  if ( (*eIt)->passSelection(val,m_selectionString) ) {
66  if (val) {egammaSelection->push_back(1);}
67  else {egammaSelection->push_back(0);}
68  }
69  else{
70  ATH_MSG_WARNING("Evident problem with quality flag " << m_selectionString << " so setting to false!");
71  egammaSelection->push_back(0);
72  }
73  }
74 
75  return StatusCode::SUCCESS;
76 
77 }
DerivationFramework::RpvEgammaIDTool::initialize
StatusCode initialize()
Definition: RpvEgammaIDTool.cxx:35
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
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
DerivationFramework::RpvEgammaIDTool::m_selectionString
std::string m_selectionString
Definition: RpvEgammaIDTool.h:53
DerivationFramework::RpvEgammaIDTool::RpvEgammaIDTool
RpvEgammaIDTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: RpvEgammaIDTool.cxx:21
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::RpvEgammaIDTool::~RpvEgammaIDTool
~RpvEgammaIDTool()
Destructor.
Definition: RpvEgammaIDTool.cxx:31
DerivationFramework::RpvEgammaIDTool::addBranches
virtual StatusCode addBranches() const
Check that the current event passes this filter.
Definition: RpvEgammaIDTool.cxx:49
EgammaContainer.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
beamspotman.n
n
Definition: beamspotman.py:731
RpvEgammaIDTool.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DerivationFramework::RpvEgammaIDTool::finalize
StatusCode finalize()
Definition: RpvEgammaIDTool.cxx:42
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
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
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.