ATLAS Offline Software
TrigMissingETHypoAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 #include "TrigMissingETHypoAlg.h"
5 
6 #include "Gaudi/Property.h"
9 
10 using namespace TrigCompositeUtils;
12 
14  ISvcLocator* pSvcLocator ) :
15  ::HypoBase( name, pSvcLocator ) {}
16 
17 
19 
20  CHECK( m_hypoTools.retrieve() );
21  CHECK( m_metKey.initialize() );
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode TrigMissingETHypoAlg::execute( const EventContext& context ) const {
26  ATH_MSG_DEBUG ( "Executing " << name() << "..." );
27 
28  // read in the met container
29  auto h_met = SG::makeHandle(m_metKey, context );
30  ATH_MSG_DEBUG("Retrieving MET from: " << h_met.key());
31  ATH_CHECK(h_met.isValid());
32  const TrigMissingETContainer* metContainer = h_met.get();
33 
34  ATH_MSG_DEBUG("The MET value is " << round(std::hypot((*metContainer)[0]->ex(), (*metContainer)[0]->ey())/1000.0 ));
35 
36  // read in the previous Decisions made before running this hypo Alg.
37  auto h_prevDecisions = SG::makeHandle(decisionInput(), context );
38  if( not h_prevDecisions.isValid() ) {//implicit
39  ATH_MSG_ERROR( "No implicit RH for previous decisions "<< decisionInput().key()<<". Check the input decisions key?" );
40  return StatusCode::FAILURE;
41  }
42  ATH_MSG_DEBUG( "Decisions being read from " << decisionInput().key() );
43  ATH_MSG_DEBUG( "Running with "<< h_prevDecisions->size() <<" implicit ReadHandles for previous decisions");
44  auto prevDecisions = h_prevDecisions.get();
45 
46  // Make a new Decisions container which will contain the new Decision object created by this hypo.
47  // (Creating a single output as executing on a single MET value)
49  DecisionContainer* newDecisions = outputHandle.ptr();
50 
51  // Make trigger decisions and save to "newDecisions"
52  ATH_CHECK(decide(metContainer, newDecisions, prevDecisions, context));
53 
54  // Common debug printing
55  ATH_CHECK(hypoBaseOutputProcessing(outputHandle));
56 
57  return StatusCode::SUCCESS;
58 }
59 
60 
61 
64  const DecisionContainer* oldDecisions,
65  const EventContext& context) const{
66 
67  ATH_MSG_DEBUG("Executing decide() of " << name() );
68  if (oldDecisions->size() != 1) {
69  ATH_MSG_ERROR("TrigMissingETHypoAlg requires there to be exactly one previous Decision object, but found " << oldDecisions->size());
70  return StatusCode::FAILURE;
71  }
72  const Decision* previousDecision = oldDecisions->at(0);
73 
74  if (metContainer->size()==0){
75  ATH_MSG_ERROR("There are no TrigEFMissingET objects in the MET container" );
76  return StatusCode::FAILURE;
77  } else if (metContainer->size()>1) {
78  ATH_MSG_ERROR("There is more than one TrigEFMissingET object in the MET container");
79  return StatusCode::FAILURE;
80  }
81 
82  // Create output Decision object, link it to prevDecision & its "feature"
83  auto newDecision = TrigCompositeUtils::newDecisionIn(newDecisions, previousDecision, hypoAlgNodeName(), context);
85  newDecision->setObjectLink<xAOD::TrigMissingETContainer>(featureString(), metElementLink);
86 
87  // Get set of active chains
88  const TrigCompositeUtils::DecisionIDContainer previousDecisionIDs{
89  TrigCompositeUtils::decisionIDs(previousDecision).begin(),
90  TrigCompositeUtils::decisionIDs(previousDecision).end()
91  };
92 
93  //bool allPassed = true;
94  for (const auto& tool: m_hypoTools) {
95  auto decisionId = tool->getId();
96  ATH_MSG_DEBUG( "About to decide for " << tool->name() );
97  if (TrigCompositeUtils::passed(decisionId.numeric(), previousDecisionIDs)){
98  ATH_MSG_DEBUG("Passed previous trigger step");
99  bool pass;
100  ATH_CHECK(tool->decide(metContainer, pass));
101  if (pass) {
102  ATH_MSG_DEBUG("Passed " << tool->name() );
103  TrigCompositeUtils::addDecisionID(decisionId, newDecision);
104  } else ATH_MSG_DEBUG("Didn't pass " << tool->name() );
105  } else ATH_MSG_DEBUG("Didn't pass previous trigger step");
106  }
107 
108  return StatusCode::SUCCESS;
109 }
110 
TrigMissingETHypoAlg::m_hypoTools
ToolHandleArray< ITrigMissingETHypoTool > m_hypoTools
Definition: TrigMissingETHypoAlg.h:38
TrigCompositeUtils::passed
bool passed(DecisionID id, const DecisionIDContainer &idSet)
checks if required decision ID is in the set of IDs in the container
Definition: TrigCompositeUtilsRoot.cxx:117
TrigCompositeUtils::newDecisionIn
Decision * newDecisionIn(DecisionContainer *dc, const std::string &name)
Helper method to create a Decision object, place it in the container and return a pointer to it.
Definition: TrigCompositeUtilsRoot.cxx:46
xAOD::TrigMissingETContainer
TrigMissingETContainer_v1 TrigMissingETContainer
DataVector of TrigMissingET - the current version.
Definition: Event/xAOD/xAODTrigMissingET/xAODTrigMissingET/TrigMissingETContainer.h:13
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:904
TrigCompositeUtils::addDecisionID
void addDecisionID(DecisionID id, Decision *d)
Appends the decision (given as ID) to the decision object.
Definition: TrigCompositeUtilsRoot.cxx:61
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
TrigMissingETContainer
Definition: Trigger/TrigEvent/TrigMissingEtEvent/TrigMissingEtEvent/TrigMissingETContainer.h:12
DataVector::get
const T * get(size_type n) const
Access an element, as an rvalue.
HypoBase::decisionInput
const SG::ReadHandleKey< TrigCompositeUtils::DecisionContainer > & decisionInput() const
methods for derived classes to access handles of the base class input other read/write handles may be...
Definition: HypoBase.cxx:16
TrigCompositeUtils::createAndStore
SG::WriteHandle< DecisionContainer > createAndStore(const SG::WriteHandleKey< DecisionContainer > &key, const EventContext &ctx)
Creates and right away records the DecisionContainer with the key.
Definition: TrigCompositeUtilsRoot.cxx:30
HypoBase::decisionOutput
const SG::WriteHandleKey< TrigCompositeUtils::DecisionContainer > & decisionOutput() const
methods for derived classes to access handles of the base class output other read/write handles may b...
Definition: HypoBase.cxx:20
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
TrigCompositeUtils.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
HypoBase::hypoBaseOutputProcessing
StatusCode hypoBaseOutputProcessing(SG::WriteHandle< TrigCompositeUtils::DecisionContainer > &outputHandle, MSG::Level lvl=MSG::DEBUG) const
Base class function to be called once slice specific code has finished. Handles debug printing and va...
Definition: HypoBase.cxx:33
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigMissingETHypoAlg::TrigMissingETHypoAlg
TrigMissingETHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigMissingETHypoAlg.cxx:13
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
TrigMissingETHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigMissingETHypoAlg.cxx:18
TrigMissingETHypoAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
TrigMissingETHypoAlg::m_metKey
SG::ReadHandleKey< xAOD::TrigMissingETContainer > m_metKey
Definition: TrigMissingETHypoAlg.h:41
TrigMissingETHypoAlg::decide
StatusCode decide(const xAOD::TrigMissingETContainer *metContainer, TrigCompositeUtils::DecisionContainer *newDecisions, const TrigCompositeUtils::DecisionContainer *oldDecisions, const EventContext &context) const
Definition: TrigMissingETHypoAlg.cxx:62
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
HLTIdentifier.h
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
TrigMissingETHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigMissingETHypoAlg.cxx:25
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37