ATLAS Offline Software
TauSelectionWrapper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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 #include <string>
16 
17 // Constructor
19  const std::string& n,
20  const IInterface* p ) :
21  AthAlgTool(t,n,p),
22  m_isTauFlag(-1),
23  m_collName("TauRecContainer"),
24  m_sgKey("")
25  {
26  declareInterface<DerivationFramework::IAugmentationTool>(this);
27  declareProperty("IsTauFlag",m_isTauFlag);
28  declareProperty("CollectionName", m_collName);
29  declareProperty("StoreGateEntryName", m_sgKey);
30  }
31 
32 // Destructor
34 }
35 
36 // Athena initialize and finalize
38 {
39  if (m_isTauFlag==-1) {
40  ATH_MSG_ERROR("No tau flag variables for the tau selection wrapper tool!");
41  return StatusCode::FAILURE;
42  }
43  if (m_collName=="") {
44  ATH_MSG_ERROR("No tau container provided for the tau selection wrapper tool!");
45  return StatusCode::FAILURE;
46  }
47  if (m_sgKey=="") {
48  ATH_MSG_ERROR("No StoreGate key provided for the output of the tau selection wrapper tool!");
49  return StatusCode::FAILURE;
50  }
51  ATH_MSG_VERBOSE("initialize() ...");
52  return StatusCode::SUCCESS;
53 }
55 {
56  ATH_MSG_VERBOSE("finalize() ...");
57  return StatusCode::SUCCESS;
58 }
59 
60 // Augmentation
62 {
63 
64  // Retrieve data
65  const xAOD::TauJetContainer* taus = evtStore()->retrieve< const xAOD::TauJetContainer >( m_collName );
66  if( !taus ) {
67  ATH_MSG_ERROR("Couldn't retrieve tau container with key: " << m_collName);
68  return StatusCode::FAILURE;
69  }
70 
71  // Make vectors for the cut results
72  std::vector<int>* isTauSelectionResult = new std::vector<int>;
73  // Loop over taus, set decisions
75  for (xAOD::TauJetContainer::const_iterator tauIt = taus->begin(); tauIt!=taus->end(); ++tauIt) {
76  if ( (*tauIt)->isTau(isTauFlag) ) {isTauSelectionResult->push_back(1);}
77  else {isTauSelectionResult->push_back(0);}
78  }
79 
80  // Write decision to SG for access by downstream algs
81  if (evtStore()->contains<std::vector<int> >(m_sgKey)) {
82  ATH_MSG_ERROR("Tool is attempting to write a StoreGate key " << m_sgKey << " which already exists. Please use a different key");
83  delete isTauSelectionResult;
84  return StatusCode::FAILURE;
85  }
86  CHECK(evtStore()->record(isTauSelectionResult,m_sgKey));
87  return StatusCode::SUCCESS;
88 
89 }
90 
DerivationFramework::TauSelectionWrapper::finalize
StatusCode finalize()
Definition: TauSelectionWrapper.cxx:54
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:37
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:18
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:61
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:581
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:33
AthAlgTool
Definition: AthAlgTool.h:26
DataVector::begin
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.