ATLAS Offline Software
Loading...
Searching...
No Matches
ViewCreatorMuonSuperROITool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
9
12
13
15 const std::string& name,
16 const IInterface* parent)
17 : base_class(type, name, parent)
18{}
19
20
22 ATH_CHECK( m_roisWriteHandleKey.initialize() );
23
24 return StatusCode::SUCCESS;
25}
26
27
29 const EventContext& ctx ) const {
30
31 // ===================================================================================== //
32 // Create output RoI collection
33
35 // ===================================================================================== //
36
37 // Only expect one object in container
38 ATH_MSG_DEBUG("In MuonSuperROITool - got decisions, size: " << decisions.size());
39
40
41 // Create SuperRoI to merge the RoIs from each muon
42 std::unique_ptr<TrigRoiDescriptor> superRoI = std::make_unique<TrigRoiDescriptor>();
43 superRoI->setComposite(true);
44 superRoI->manageConstituents(false);
45
46 // loop over decision objects
47 for (TrigCompositeUtils::Decision* decision : decisions) {
48 ATH_MSG_DEBUG(" Check decisions object ");
49
50 ATH_MSG_DEBUG("PRINTING DECISION");
51 ATH_MSG_DEBUG( *decision );
52
53
54 // find the iParticle for this decision
55 const std::vector<TrigCompositeUtils::LinkInfo<xAOD::IParticleContainer>> myFeature = TrigCompositeUtils::findLinks<xAOD::IParticleContainer>(decision, m_iParticleLinkName, TrigDefs::lastFeatureOfType);
56
57 // there should be only one
58 if (myFeature.size() != 1) {
59 ATH_MSG_ERROR("Did not find exactly one most-recent xAOD::IParticle '" << m_iParticleLinkName << "' for Decision object index " << decision->index()
60 << ", found " << myFeature.size());
61 return StatusCode::FAILURE;
62 }
63
64 ATH_CHECK(myFeature.at(0).isValid());
65
66 // find the muon
67 const ElementLink<xAOD::IParticleContainer> p4EL = myFeature.at(0).link;
68 const xAOD::Muon* muon = dynamic_cast< const xAOD::Muon*>(*p4EL); //get muon of this found object
69
70 if (!( muon && muon->primaryTrackParticle()) ) {
71 ATH_MSG_ERROR("NO PRIMARY muon from decision object! " << myFeature.at(0).link);
72 return StatusCode::FAILURE;
73 }
74
75 ATH_MSG_DEBUG("MUON -- pt=" << muon->pt() <<
76 " eta=" << muon->eta() <<
77 " phi=" << muon->phi() );
78
79
80 double muonEta{muon->eta()}, muonPhi{muon->phi()};
81
82 double etaMinus = muonEta - m_roiEtaWidth;
83 double etaPlus = muonEta + m_roiEtaWidth;
84
85 double phiMinus = CxxUtils::wrapToPi( muonPhi - m_roiPhiWidth );
86 double phiPlus = CxxUtils::wrapToPi( muonPhi + m_roiPhiWidth );
87
88 double muonZed=0.;
89
90 std::unique_ptr<TrigRoiDescriptor> newROI = nullptr;
91
92 if ( muon->primaryTrackParticle() ) {
93 muonZed = muon->primaryTrackParticle()->z0() + muon->primaryTrackParticle()->vz();
94
95 // create ROIs
96 ATH_MSG_DEBUG("Adding RoI to RoI container");
97 ATH_MSG_DEBUG( "eta " << muonEta << " +/-" << m_roiEtaWidth << " phi " << muonPhi << " +/- " << m_roiPhiWidth << " zed " << muonZed << " +/- " << m_roiZedWidth);
98
99
100 double zMinus = muonZed - m_roiZedWidth;
101 double zPlus = muonZed + m_roiZedWidth;
102
103 zMinus = zMinus < -225. ? -225. : zMinus;
104 zPlus = zPlus > 225. ? 225. : zPlus;
105
106 ATH_MSG_DEBUG( "eta- " << etaMinus << " eta+ " << etaPlus << " phi- " << phiMinus << " phi+ " << phiPlus << " zed- " << zMinus << " zed+ " << zPlus);
107
108 superRoI->push_back( new TrigRoiDescriptor( muonEta, etaMinus, etaPlus,
109 muonPhi, phiMinus, phiPlus,
110 muonZed, zMinus, zPlus ) );
111
112 superRoI->manageConstituents(true);
113
114 } else {
115 ATH_MSG_DEBUG("Adding RoI to RoI container");
116 ATH_MSG_DEBUG( "eta " << muonEta << " +/-" << m_roiEtaWidth << " phi " << muonPhi << " +/- " << m_roiPhiWidth);
117 ATH_MSG_DEBUG( "eta- " << etaMinus << " eta+ " << etaPlus << " phi- " << phiMinus << " phi+ " << phiPlus);
118
119 superRoI->push_back( new TrigRoiDescriptor( muonEta, etaMinus, etaPlus,
120 muonPhi, phiMinus, phiPlus) );
121
122 superRoI->manageConstituents(true);
123
124 }
125
126
127 } //end loop over decisions
128
129
130
131 roisWriteHandle->push_back(superRoI.release());
133
134
135 for (TrigCompositeUtils::Decision* decision : decisions) {
136 decision->setObjectLink( TrigCompositeUtils::roiString(), roiEL );
137
138 ATH_MSG_DEBUG("PRINTING DECISION");
139 ATH_MSG_DEBUG( *decision );
140 }
141 return StatusCode::SUCCESS;
142}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Current TrigRoiDescriptor
virtual StatusCode attachROILinks(TrigCompositeUtils::DecisionContainer &decisions, const EventContext &ctx) const override
Tool interface method.
ViewCreatorMuonSuperROITool(const std::string &type, const std::string &name, const IInterface *parent)
Gaudi::Property< double > m_roiZedWidth
Gaudi::Property< double > m_roiEtaWidth
Gaudi::Property< std::string > m_iParticleLinkName
virtual StatusCode initialize() override
Gaudi::Property< double > m_roiPhiWidth
SG::WriteHandleKey< TrigRoiDescriptorCollection > m_roisWriteHandleKey
T wrapToPi(T phi)
Wrap angle in radians to [-pi, pi].
Definition phihelper.h:24
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()
void findLinks(const Decision *start, const std::string &linkName, std::vector< LinkInfo< T > > &links, unsigned int behaviour=TrigDefs::allFeaturesOfType, std::set< const xAOD::TrigComposite * > *fullyExploredFrom=nullptr)
search back the TC links for the object of type T linked to the one of TC (recursively) Populates pro...
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:
Helper for azimuthal angle calculations.