ATLAS Offline Software
Loading...
Searching...
No Matches
TruthHSRoISeedTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2020-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6// Implementation file for class TruthHSRoISeedTool
8// (c) ATLAS Detector software
10
11
13#include "TVector2.h"
14#include <map>
15
16
18// Constructor
20
22(const std::string& t,const std::string& n,const IInterface* p)
23 : base_class(t,n,p)
24{
25}
26
28// Initialization
30
32{
33 StatusCode sc = AlgTool::initialize();
34
35 ATH_CHECK( m_inputTruthEventsKey.initialize() );
36
37 return sc;
38}
39
41// Compute RoI
43
44std::vector<InDet::IZWindowRoISeedTool::ZWindow> InDet::TruthHSRoISeedTool::getRoIs(const EventContext& ctx) const
45{
46
47 // prepare output
48 std::vector<InDet::IZWindowRoISeedTool::ZWindow> listRoIs;
49 listRoIs.clear();
50
51 //retrieve truth collection
53 if (not truthEvents.isValid()) {
54 ATH_MSG_ERROR("Cannot retrieve xAOD truth event information. Bailing out with empty RoI list.");
55 return listRoIs;
56 }
57 ATH_MSG_DEBUG("xAOD Truth Event available!");
58
59 //get HS position
60 for (const xAOD::TruthEvent *evt : *truthEvents) {
61 const xAOD::TruthVertex *hsPos = evt->signalProcessVertex();
62 if (hsPos == nullptr) {
63 ATH_MSG_DEBUG("Invalid signal process vertex! Trying next TruthEvent.");
64 continue;
65 }
67 RoI.zReference = hsPos->z();
68 RoI.zWindow[0] = RoI.zReference - m_z0Window;
69 RoI.zWindow[1] = RoI.zReference + m_z0Window;
70 listRoIs.push_back(RoI);
71 ATH_MSG_DEBUG("Found RoI: " << RoI.zReference << " [" << RoI.zWindow[0] << ", " << RoI.zWindow[1] << "]");
72 //use only the first one
73 break;
74 }
75
76 return listRoIs;
77
78}
79
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
SG::ReadHandleKey< xAOD::TruthEventContainer > m_inputTruthEventsKey
virtual StatusCode initialize() override
virtual std::vector< ZWindow > getRoIs(const EventContext &ctx) const override
Compute RoI.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
float z() const
Vertex longitudinal distance along the beam line form the origin.
TruthVertex_v1 TruthVertex
Typedef to implementation.
Definition TruthVertex.h:15
TruthEvent_v1 TruthEvent
Typedef to implementation.
Definition TruthEvent.h:17