ATLAS Offline Software
TrigEgammaTLAPhotonHypoAlg.cxx
Go to the documentation of this file.
1 #include <algorithm>
5 #include "AthViews/ViewHelper.h"
6 //#include "xAODTrigger/TrigCompositeContainer.h"
14 
15 using namespace TrigCompositeUtils;
16 
18 
19 
20 TrigEgammaTLAPhotonHypoAlg::TrigEgammaTLAPhotonHypoAlg( const std::string& name, ISvcLocator* pSvcLocator ) :
21  :: HypoBase (name, pSvcLocator) {}
22 
23 
25 
26  ATH_CHECK( m_hypoTools.retrieve() );
27  ATH_CHECK( m_TLAPhotonsKey.initialize() );
28 
29  ATH_MSG_DEBUG("Initializing TrigEgammaTLAPhotonHypoAlg");
30  return StatusCode::SUCCESS;
31 
32 }
33 
34 StatusCode TrigEgammaTLAPhotonHypoAlg::execute( const EventContext& ctx) const
35 {
36  ATH_MSG_DEBUG("Executing " << name() << "...");
37 
38  ATH_MSG_DEBUG("Retrieving 'HLT' decision\" " << decisionInput().key() << "\"");
39 
40 
41  // create handles for TLA photons
43  //make the output photon container
44  ATH_CHECK(h_TLAPhotons.record(std::make_unique<xAOD::PhotonContainer>(),
45  std::make_unique<xAOD::PhotonAuxContainer>()));
46 
47 
48  // retrieves the HLT decision container for the TLA photons
49  auto previousDecisionHandle = SG::makeHandle(decisionInput(), ctx);
50  ATH_CHECK(previousDecisionHandle.isValid());
51 
52 
53  // get a pointer to the TLA Photons
54  ATH_MSG_DEBUG("Retrieving photons from the TLA container \"" <<m_TLAPhotonsKey << "\" ");
55 
56 
57  // creates (via SG handle) a DecisionContainer for the output decision
59  DecisionContainer* outputDecisions = outputHandle.ptr();
60 
61  // loops over previous decisions
62  int nDecision = 0;
63  for (const auto previousDecision : *previousDecisionHandle)
64  {
65 
66  // get photons from the decision
67  const xAOD::Photon *photonPrev = nullptr;
68  auto prevPhotons = TrigCompositeUtils::findLinks<xAOD::PhotonContainer>(previousDecision, TrigCompositeUtils::featureString(), TrigDefs::lastFeatureOfType);
69  ATH_MSG_DEBUG("This decision has " << prevPhotons.size() << " photons");
70 
71 
72  if (prevPhotons.size() != 1) {
73  ATH_MSG_ERROR("Did not locate exactly one photon for this Decision Object, found " << prevPhotons.size());
74  return StatusCode::FAILURE;
75  }
76 
77 
78  auto prevPhotonLink = prevPhotons.at(0).link;
79  ATH_CHECK(prevPhotonLink.isValid());
80  photonPrev = *prevPhotonLink;
81 
82  xAOD::Photon *copiedPhoton = new xAOD::Photon();
83  h_TLAPhotons->push_back(copiedPhoton);
84  *copiedPhoton = *photonPrev;
85 
86  // now go on with the normal Hypo, linking new decision with previous one
87  auto newDecision = newDecisionIn( outputDecisions, hypoAlgNodeName() );
88  TrigCompositeUtils::linkToPrevious( newDecision, previousDecision, ctx );
89  // do we need to re-link the feature?
90  newDecision->setObjectLink(featureString(), ElementLink<xAOD::PhotonContainer>(*h_TLAPhotons, h_TLAPhotons->size() - 1, ctx));
91 
92 
93  ATH_MSG_DEBUG("Copied photon with pT: " << copiedPhoton->pt() << " from decision " << nDecision);
94 
95 
96  }
97 
98 
99 
100  for (const auto& tool : m_hypoTools)
101  {
102  ATH_MSG_DEBUG("Now computing decision for HypoTool: " << tool->name());
103  ATH_CHECK(tool->decide(outputDecisions));
104  }
105 
106  ATH_CHECK( hypoBaseOutputProcessing(outputHandle ));
107 
108 
109  return StatusCode::SUCCESS;
110 }
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
TrigCompositeUtils::hypoAlgNodeName
const std::string & hypoAlgNodeName()
Definition: TrigCompositeUtilsRoot.cxx:906
TrigEgammaTLAPhotonHypoAlg::initialize
virtual StatusCode initialize() override
Definition: TrigEgammaTLAPhotonHypoAlg.cxx:24
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
TrigCompositeUtils.h
ViewHelper.h
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
TrigEgammaTLAPhotonHypoAlg.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
TrigEMClusterAuxContainer.h
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
TrigCompositeUtils::featureString
const std::string & featureString()
Definition: TrigCompositeUtilsRoot.cxx:886
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAOD::PhotonContainer
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/PhotonContainer.h:17
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
TrigEMClusterContainer.h
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
PhotonAuxContainer.h
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
xAOD::Photon_v1
Definition: Photon_v1.h:37
HLTIdentifier.h
TrigEgammaTLAPhotonHypoAlg::m_hypoTools
ToolHandleArray< TrigEgammaTLAPhotonHypoTool > m_hypoTools
Definition: TrigEgammaTLAPhotonHypoAlg.h:26
TrigEgammaTLAPhotonHypoAlg::execute
virtual StatusCode execute(const EventContext &context) const override
Definition: TrigEgammaTLAPhotonHypoAlg.cxx:34
xAOD::Egamma_v1::pt
virtual double pt() const override final
The transverse momentum ( ) of the particle.
Definition: Egamma_v1.cxx:65
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
IParticleHelpers.h
TrigEgammaTLAPhotonHypoAlg::m_TLAPhotonsKey
SG::WriteHandleKey< xAOD::PhotonContainer > m_TLAPhotonsKey
Definition: TrigEgammaTLAPhotonHypoAlg.h:31
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhotonContainer.h
TrigRoiDescriptorCollection.h
TrigEgammaTLAPhotonHypoAlg::TrigEgammaTLAPhotonHypoAlg
TrigEgammaTLAPhotonHypoAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigEgammaTLAPhotonHypoAlg.cxx:20
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37