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());
41  return StatusCode::SUCCESS;
42 }
43 
44 // =============================================================================
45 
47  ATH_MSG_DEBUG("Finalising " << name());
48  return StatusCode::SUCCESS;
49 }
50 
51 // =============================================================================
52 
53 StatusCode PEBInfoWriterAlg::execute(const EventContext& eventContext) const {
54  ATH_MSG_DEBUG("Executing " << name());
55 
56  // ---------------------------------------------------------------------------
57  // Common hypo start - retrieve previous decisions and record new container
58  // ---------------------------------------------------------------------------
59  // Retrieve previous decisions
60  SG::ReadHandle<DecisionContainer> previousDecisionsHandle = SG::makeHandle(decisionInput(), eventContext);
61  if (not previousDecisionsHandle.isValid()) { // Implicit
62  ATH_MSG_DEBUG("No implicit previous decisions with key " << decisionInput().key() << " - is this expected?");
63  return StatusCode::SUCCESS;
64  }
65  ATH_MSG_DEBUG("Running with " << previousDecisionsHandle->size() << " implicit previous decisions");
66 
67  // New output decisions
69  DecisionContainer* decisions = outputHandle.ptr();
70 
71  // ---------------------------------------------------------------------------
72  // Prepare new decision and hypo tool inputs
73  // ---------------------------------------------------------------------------
74  std::vector<PEBInfoWriterToolBase::Input> toolInputs;
75 
76  SG::ReadHandle<xAOD::EventInfo> eventInfo (m_eventInfoKey, eventContext);
77  const uint8_t tt = (uint8_t) eventInfo->level1TriggerType();
78 
79  size_t counter = 0;
80  for (const Decision* previousDecision: *previousDecisionsHandle) {
81  // Get RoI
82  auto roiELInfo = findLink<TrigRoiDescriptorCollection>(previousDecision, roiString());
83  auto roiEL = roiELInfo.link;
84  ATH_CHECK(roiEL.isValid());
85 
86  // Create new HypoAlg decision and link it to previousDecision
87  Decision* newd = newDecisionIn(decisions, previousDecision, hypoAlgNodeName(), eventContext);
88 
89  // Attach empty PEB Info lists to the new decision
90  ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::robListKey(), std::vector<uint32_t>()));
91  ATH_CHECK(newd->setDetail(PEBInfoWriterToolBase::subDetListKey(), std::vector<uint32_t>()));
92 
93  // Push_back to toolInput
94  toolInputs.emplace_back(newd, eventContext, roiEL, previousDecision, tt);
95 
96  // Link to feature. Dummy link here
97  ElementLink<DecisionContainer> dummyLink(*decisions, decisions->size()-1, eventContext);
98  newd->setObjectLink(featureString(), dummyLink);
99 
100  // Disable ComboHypo checks on the output of the final PEB step. All multiplicity cuts should be applied already.
101  newd->setDetail<int32_t>("noCombo", 1);
102 
103  ATH_MSG_DEBUG("RoI eta/phi = " << (*roiEL)->eta() << "/" << (*roiEL)->phi());
104  ATH_MSG_DEBUG("Added RoI, previous decision and dummy feature to new decision " << counter);
105  ++counter;
106 
107  }
108 
109  // ---------------------------------------------------------------------------
110  // Call the hypo tools
111  // ---------------------------------------------------------------------------
112  for (const auto& tool: m_hypoTools) {
113  ATH_MSG_DEBUG("Calling " << tool);
114  ATH_CHECK(tool->decide(toolInputs));
115  }
116 
117  // ---------------------------------------------------------------------------
118  // Print the passing decisions
119  // ---------------------------------------------------------------------------
120  ATH_CHECK(outputHandle.isValid());
121  ATH_MSG_DEBUG("Exit with " << outputHandle->size() << " decisions");
122  ATH_CHECK( hypoBaseOutputProcessing(outputHandle) );
123 
124  return StatusCode::SUCCESS;
125 }
TrigCompositeUtils::DecisionID
unsigned int DecisionID
Definition: TrigComposite_v1.h:27
TrigCompositeUtils::DecisionContainer
xAOD::TrigCompositeContainer DecisionContainer
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigCompositeContainer.h:21
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
TrigCompositeUtils.h
PEBInfoWriterAlg::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: PEBInfoWriterAlg.h:31
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:904
PEBInfoWriterToolBase::robListKey
static std::string robListKey()
Returns the key used to record/retrieve the ROB list.
Definition: PEBInfoWriterToolBase.h:61
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:46
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition: ReadCondHandle.h:270
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:63
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
xAOD::decisions
decisions
Definition: TrigComposite_v1.cxx:101
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:884
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
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:53
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
xAOD::EventInfo_v1::level1TriggerType
uint16_t level1TriggerType() const
The Level-1 trigger type.
PEBInfoWriterAlg.h
TrigCompositeUtils::roiString
const std::string & roiString()
Definition: TrigCompositeUtilsRoot.cxx:876
PEBInfoWriterAlg::m_hypoTools
ToolHandleArray< PEBInfoWriterToolBase > m_hypoTools
Definition: PEBInfoWriterAlg.h:30
test_pyathena.counter
counter
Definition: test_pyathena.py:15
TileDCSDataPlotter.tt
tt
Definition: TileDCSDataPlotter.py:874
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37