ATLAS Offline Software
PEBInfoWriterAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // Trigger includes
6 #include "PEBInfoWriterAlg.h"
8 
9 // TrigCompositeUtils types used here
15 
16 // TrigCompositeUtils methods used here
25 
26 // =============================================================================
27 
28 PEBInfoWriterAlg::PEBInfoWriterAlg(const std::string& name, ISvcLocator* pSvcLocator)
29 : ::HypoBase(name, pSvcLocator) {}
30 
31 // =============================================================================
32 
34 
35 // =============================================================================
36 
38  ATH_MSG_DEBUG("Initialising " << name());
39  ATH_CHECK(m_hypoTools.retrieve());
40  return StatusCode::SUCCESS;
41 }
42 
43 // =============================================================================
44 
46  ATH_MSG_DEBUG("Finalising " << name());
47  return StatusCode::SUCCESS;
48 }
49 
50 // =============================================================================
51 
52 StatusCode PEBInfoWriterAlg::execute(const EventContext& eventContext) const {
53  ATH_MSG_DEBUG("Executing " << name());
54 
55  // ---------------------------------------------------------------------------
56  // Common hypo start - retrieve previous decisions and record new container
57  // ---------------------------------------------------------------------------
58  // Retrieve previous decisions
59  SG::ReadHandle<DecisionContainer> previousDecisionsHandle = SG::makeHandle(decisionInput(), eventContext);
60  if (not previousDecisionsHandle.isValid()) { // Implicit
61  ATH_MSG_DEBUG("No implicit previous decisions with key " << decisionInput().key() << " - is this expected?");
62  return StatusCode::SUCCESS;
63  }
64  ATH_MSG_DEBUG("Running with " << previousDecisionsHandle->size() << " implicit previous decisions");
65 
66  // New output decisions
68  DecisionContainer* decisions = outputHandle.ptr();
69 
70  // ---------------------------------------------------------------------------
71  // Prepare new decision and hypo tool inputs
72  // ---------------------------------------------------------------------------
73  std::vector<PEBInfoWriterToolBase::Input> toolInputs;
74  size_t counter = 0;
75  for (const Decision* previousDecision: *previousDecisionsHandle) {
76  // Get RoI
77  auto roiELInfo = findLink<TrigRoiDescriptorCollection>(previousDecision, roiString());
78  auto roiEL = roiELInfo.link;
79  ATH_CHECK(roiEL.isValid());
80 
81  // Create new HypoAlg decision and link it to previousDecision
82  Decision* newd = newDecisionIn(decisions, previousDecision, hypoAlgNodeName(), eventContext);
83 
84  // Attach empty PEB Info lists to the new decision
85  ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::robListKey(), std::vector<uint32_t>()));
86  ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::subDetListKey(), std::vector<uint32_t>()));
87 
88  // Push_back to toolInput
89  toolInputs.emplace_back(newd, eventContext, roiEL, previousDecision);
90 
91  // Link to feature. Dummy link here
92  ElementLink<DecisionContainer> dummyLink(*decisions, decisions->size()-1, eventContext);
93  newd->setObjectLink(featureString(), dummyLink);
94 
95  // Disable ComboHypo checks on the output of the final PEB step. All multiplicity cuts should be applied already.
96  newd->setDetail<int32_t>("noCombo", 1);
97 
98  ATH_MSG_DEBUG("RoI eta/phi = " << (*roiEL)->eta() << "/" << (*roiEL)->phi());
99  ATH_MSG_DEBUG("Added RoI, previous decision and dummy feature to new decision " << counter);
100  ++counter;
101  }
102 
103  // ---------------------------------------------------------------------------
104  // Call the hypo tools
105  // ---------------------------------------------------------------------------
106  for (const auto& tool: m_hypoTools) {
107  ATH_MSG_DEBUG("Calling " << tool);
108  ATH_CHECK(tool->decide(toolInputs));
109  }
110 
111  // ---------------------------------------------------------------------------
112  // Print the passing decisions
113  // ---------------------------------------------------------------------------
114  ATH_CHECK(outputHandle.isValid());
115  ATH_MSG_DEBUG("Exit with " << outputHandle->size() << " decisions");
116  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
117 
118  return StatusCode::SUCCESS;
119 }
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
TrigCompositeUtils.h
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
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
PEBInfoWriterToolBase::robListKey
static std::string robListKey()
Returns the key used to record/retrieve the ROB list.
Definition: PEBInfoWriterToolBase.h:57
PEBInfoWriterAlg::initialize
virtual StatusCode initialize() override
Definition: PEBInfoWriterAlg.cxx:37
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
PEBInfoWriterAlg::finalize
virtual StatusCode finalize() override
Definition: PEBInfoWriterAlg.cxx:45
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:269
PEBInfoWriterAlg::PEBInfoWriterAlg
PEBInfoWriterAlg(const std::string &name, ISvcLocator *svcLoc)
Standard constructor.
Definition: PEBInfoWriterAlg.cxx:28
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
PEBInfoWriterToolBase::subDetListKey
static std::string subDetListKey()
Returns the key used to record/retrieve the SubDet list.
Definition: PEBInfoWriterToolBase.h:59
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:81
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
HypoBase
Hypothesis algorithms take the output of reco algorithms and the decision from the preceeding InputMa...
Definition: HypoBase.h:13
TrigCompositeUtils::Decision
xAOD::TrigComposite Decision
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:20
PEBInfoWriterAlg::~PEBInfoWriterAlg
virtual ~PEBInfoWriterAlg()
Standard destructor.
Definition: PEBInfoWriterAlg.cxx:33
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
TrigCompositeUtils::linkToPrevious
void linkToPrevious(Decision *d, const std::string &previousCollectionKey, size_t previousIndex)
Links to the previous object, location of previous 'seed' decision supplied by hand.
Definition: TrigCompositeUtilsRoot.cxx:139
PEBInfoWriterAlg::execute
virtual StatusCode execute(const EventContext &eventContext) const override
Definition: PEBInfoWriterAlg.cxx:52
TrigCompositeUtils::LinkInfo
Helper to keep a Decision object, ElementLink and ActiveState (with respect to some requested ChainGr...
Definition: LinkInfo.h:28
TrigCompositeUtils::DecisionIDContainer
std::set< DecisionID > DecisionIDContainer
Definition: TrigComposite_v1.h:28
TrigCompositeUtils::findLink
LinkInfo< T > findLink(const Decision *start, const std::string &linkName, const bool suppressMultipleLinksWarning=false)
Perform a recursive search for ElementLinks of type T and name 'linkName', starting from Decision obj...
TrigCompositeUtils::decisionIDs
void decisionIDs(const Decision *d, DecisionIDContainer &destination)
Extracts DecisionIDs stored in the Decision object.
Definition: TrigCompositeUtilsRoot.cxx:67
PEBInfoWriterAlg.h
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:878
PEBInfoWriterAlg::m_hypoTools
ToolHandleArray< PEBInfoWriterToolBase > m_hypoTools
Definition: PEBInfoWriterAlg.h:27
test_pyathena.counter
counter
Definition: test_pyathena.py:15
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37