ATLAS Offline Software
TauSelectionWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TauSelectionWrapper.cxx, (c) ATLAS Detector software
8 // Author: James Catmore (James.Catmore@cern.ch)
9 // Wrapper around the passSelection() method of xAOD egamma
10 // Writes result to SG for later selection by string parser
11 
14 #include <vector>
15 
16 // Constructor
18  const std::string& n,
19  const IInterface* p ) :
20  AthAlgTool(t,n,p),
21  m_isTauFlag(-1),
22  m_collName("TauRecContainer"),
23  m_sgKey("")
24  {
25  declareInterface<DerivationFramework::IAugmentationTool>(this);
26  declareProperty("IsTauFlag",m_isTauFlag);
27  declareProperty("CollectionName", m_collName);
28  declareProperty("StoreGateEntryName", m_sgKey);
29  }
30 
31 // Destructor
33 }
34 
35 // Athena initialize and finalize
37 {
38  if (m_isTauFlag==-1) {
39  ATH_MSG_ERROR("No tau flag variables for the tau selection wrapper tool!");
40  return StatusCode::FAILURE;
41  }
42  if (m_collName=="") {
43  ATH_MSG_ERROR("No tau container provided for the tau selection wrapper tool!");
44  return StatusCode::FAILURE;
45  }
46  if (m_sgKey=="") {
47  ATH_MSG_ERROR("No StoreGate key provided for the output of the tau selection wrapper tool!");
48  return StatusCode::FAILURE;
49  }
50  ATH_MSG_VERBOSE("initialize() ...");
51  return StatusCode::SUCCESS;
52 }
54 {
55  ATH_MSG_VERBOSE("finalize() ...");
56  return StatusCode::SUCCESS;
57 }
58 
59 // Augmentation
61 {
62 
63  // Retrieve data
64  const xAOD::TauJetContainer* taus = evtStore()->retrieve< const xAOD::TauJetContainer >( m_collName );
65  if( !taus ) {
66  ATH_MSG_ERROR("Couldn't retrieve tau container with key: " << m_collName);
67  return StatusCode::FAILURE;
68  }
69 
70  // Make vectors for the cut results
71  std::vector<int>* isTauSelectionResult = new std::vector<int>;
72  // Loop over taus, set decisions
74  for (xAOD::TauJetContainer::const_iterator tauIt = taus->begin(); tauIt!=taus->end(); ++tauIt) {
75  if ( (*tauIt)->isTau(isTauFlag) ) {isTauSelectionResult->push_back(1);}
76  else {isTauSelectionResult->push_back(0);}
77  }
78 
79  // Write decision to SG for access by downstream algs
80  if (evtStore()->contains<std::vector<int> >(m_sgKey)) {
81  ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_sgKey << " which already exists. Please use a different key");
82  delete isTauSelectionResult;
83  return StatusCode::FAILURE;
84  }
85  CHECK(evtStore()->record(isTauSelectionResult,m_sgKey));
86  return StatusCode::SUCCESS;
87 
88 }
89 
DerivationFramework::TauSelectionWrapper::finalize
StatusCode finalize()
Definition: TauSelectionWrapper.cxx:53
DataModel_detail::const_iterator
Const iterator class for DataVector/DataList.
Definition: DVLIterator.h:82
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TauSelectionWrapper.h
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
DerivationFramework::TauSelectionWrapper::m_sgKey
std::string m_sgKey
Definition: TauSelectionWrapper.h:48
DerivationFramework::TauSelectionWrapper::initialize
StatusCode initialize()
Definition: TauSelectionWrapper.cxx:36
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::TauSelectionWrapper::TauSelectionWrapper
TauSelectionWrapper(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: TauSelectionWrapper.cxx:17
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
DerivationFramework::TauSelectionWrapper::addBranches
virtual StatusCode addBranches() const
Check that the current event passes this filter.
Definition: TauSelectionWrapper.cxx:60
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
TauJetContainer.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
DerivationFramework::TauSelectionWrapper::m_collName
std::string m_collName
Definition: TauSelectionWrapper.h:47
DerivationFramework::TauSelectionWrapper::m_isTauFlag
int m_isTauFlag
Definition: TauSelectionWrapper.h:46
DataVector::end
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
xAOD::TauJetParameters::IsTauFlag
IsTauFlag
Enum for IsTau flags.
Definition: TauDefs.h:116
DerivationFramework::TauSelectionWrapper::~TauSelectionWrapper
~TauSelectionWrapper()
Destructor.
Definition: TauSelectionWrapper.cxx:32
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.