ATLAS Offline Software
Loading...
Searching...
No Matches
ViewCreatorCentredOnIParticleROITool.cxx
Go to the documentation of this file.
1
2/*
3Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
4*/
5
9#include "xAODMuon/Muon.h"
12
13using namespace TrigCompositeUtils;
14
15ViewCreatorCentredOnIParticleROITool::ViewCreatorCentredOnIParticleROITool(const std::string& type, const std::string& name, const IInterface* parent)
16 : base_class(type, name, parent)
17 {}
18
19
21 ATH_CHECK(m_roisWriteHandleKey.initialize());
22 return StatusCode::SUCCESS;
23}
24
25
28
29 for ( Decision* outputDecision : decisions ) {
30
31 std::set<const Decision*> cache;
32 std::vector<SG::sgkey_t> keys;
33 std::vector<uint32_t> clids;
34 std::vector<Decision::index_type> indices;
35 std::vector<const Decision*> sources;
36 typelessFindLinks(outputDecision, m_iParticleLinkName, keys, clids, indices, sources, TrigDefs::lastFeatureOfType, &cache);
37
38 //expect only one link per decision
39 if(keys.size()!=1){
40 ATH_MSG_ERROR("Did not find exactly one object having searched for a link named '"<<m_iParticleLinkName<<"'. Found "<<keys.size()<<" instead");
41 return StatusCode::FAILURE;
42 }
43
44 //first check if we've found a MET feature, and attach a FS RoI if so
46 ATH_MSG_DEBUG("Encountered a MET feature in the CentredOnIParticle ROITool. Cannot centre an ROI on this. Attaching a FullScan RoI");
47 roisWriteHandle->push_back( new TrigRoiDescriptor( RoiDescriptor::FULLSCAN ) );
48 const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
49 outputDecision->setObjectLink(roiString(), roiEL);
50 continue;
51 }
52
53 //If not MET, we should have an IParticle
54 const ElementLink<xAOD::IParticleContainer> p4EL(keys.at(0), indices.at(0), ctx);
55 ATH_CHECK(p4EL.isValid());
56
57 const double reta = (*p4EL)->eta();
58 const double retap = reta + m_roiEtaWidth;
59 const double retam = reta - m_roiEtaWidth;
60 const double rphi = (*p4EL)->phi();
61 const double rphip = rphi + m_roiPhiWidth;
62 const double rphim = rphi - m_roiPhiWidth;
63
64 TrigRoiDescriptor *newROI = nullptr;
65
66 if ( m_roiZedWidth >= 0 ) {
67
68 const xAOD::Muon* muon = dynamic_cast< const xAOD::Muon*>(*p4EL); //get muon of this found object
69 double zed0 = 0.0; //initialization
70
71 bool update_z_width = true;
72
73 if ( m_useZedPosition ) {
74 if ( muon && muon->primaryTrackParticle() ) {
75 zed0 = muon->primaryTrackParticle()->z0();
76 if ( m_useBeamspot ) zed0 += muon->primaryTrackParticle()->vz();
77 }
78 else update_z_width = false;
79 }
80
81 if ( update_z_width ) {
82
83 double zed0p = zed0 + m_roiZedWidth; // in mm
84 double zed0m = zed0 - m_roiZedWidth; // in mm
85
86 if ( m_roiZedSinThetaFlag ) {
88 double cosheta = std::cosh( (*p4EL)->eta() );
89 zed0p = zed0 + m_roiZedWidth*cosheta; // in mm
90 zed0m = zed0 - m_roiZedWidth*cosheta; // in mm
91 }
92
93 ATH_MSG_DEBUG( "New ROI for xAOD::Particle ET="<< (*p4EL)->p4().Et()
94 << " eta="<< (*p4EL)->eta() << " +- " << m_roiEtaWidth
95 << " phi="<< (*p4EL)->phi() << " +- " << m_roiPhiWidth
96 << " zed0="<< zed0 << " +- " << m_roiZedWidth );
97
98 newROI = new TrigRoiDescriptor( reta, retam, retap,
99 rphi, rphim, rphip,
100 zed0, zed0m, zed0p );
101 }
102 else {
103 newROI = new TrigRoiDescriptor( reta, retam, retap,
104 rphi, rphim, rphip);
105 }
106 }
107 else {
108 newROI = new TrigRoiDescriptor( reta, retam, retap,
109 rphi, rphim, rphip);
110 }
111
112 roisWriteHandle->push_back( newROI );
113
114 const ElementLink<TrigRoiDescriptorCollection> roiEL = ElementLink<TrigRoiDescriptorCollection>(*roisWriteHandle, roisWriteHandle->size() - 1, ctx);
115
116 outputDecision->setObjectLink(roiString(), roiEL);
117 }
118
119 return StatusCode::SUCCESS;
120}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
static constexpr bool FULLSCAN
convenient
nope - should be used for standalone also, perhaps need to protect the class def bits ifndef XAOD_ANA...
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
ViewCreatorCentredOnIParticleROITool(const std::string &type, const std::string &name, const IInterface *parent)
SG::WriteHandle< CONT > createAndStoreNoAux(const SG::WriteHandleKey< CONT > &key, const EventContext &ctx)
Creates and right away records the Container CONT with the key.
const std::string & roiString()
bool typelessFindLinks(const Decision *start, const std::string &linkName, std::vector< sgkey_t > &keyVec, std::vector< CLID > &clidVec, std::vector< Decision::index_type > &indexVec, std::vector< const Decision * > &sourceVec, const unsigned int behaviour, std::set< const Decision * > *fullyExploredFrom)
search back the TC links for the object of type T linked to the one of TC (recursively) Returns the l...
static const unsigned int lastFeatureOfType
Run 3 "enum". Only return the final feature along each route through the navigation.
Muon_v1 Muon
Reference the current persistent version: