ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaMonitorTopoAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <utility>
6
10
11using namespace Trig;
12
13
14TrigEgammaMonitorTopoAlgorithm::TrigEgammaMonitorTopoAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ):
15 TrigEgammaMonitorBaseAlgorithm( name, pSvcLocator )
16{}
17
19
22
24
26{
27 ATH_MSG_INFO("TrigEgammaMonitorTopoAlgorithm::initialize()...");
28
30
31 ATH_CHECK(m_offElectronKey.initialize());
32 ATH_CHECK(m_offPhotonKey.initialize());
33
34 return StatusCode::SUCCESS;
35}
36
38
39StatusCode TrigEgammaMonitorTopoAlgorithm::fillHistograms( const EventContext& ctx ) const
40{
41
42 ATH_MSG_DEBUG("Executing TrigEgammaMonitorTopoAlgorithm");
43
44 if(isHLTTruncated()){
45 ATH_MSG_DEBUG("HLTResult truncated, skip trigger analysis");
46 return StatusCode::SUCCESS;
47 }
48
49 // Open the offline electron container
52
53 if(!offElectrons.isValid())
54 {
55 ATH_MSG_DEBUG("Failed to retrieve offline Electrons ");
56 return StatusCode::SUCCESS;
57 }
58
59 if(!offPhotons.isValid())
60 {
61 ATH_MSG_DEBUG("Failed to retrieve offline Photons ");
62 return StatusCode::SUCCESS;
63 }
64
65 const std::string numeratorStr{"trigger_num"};
66 const std::string denominatorStr{"trigger_den"};
67 const std::string key0Str{"leg0_key"};
68 const std::string key1Str{"leg1_key"};
69 for ( auto &d : m_trigListConfig)
70 {
71 std::string trigger_num = d.at(numeratorStr);
72 std::string trigger_den = d.at(denominatorStr);
73
74 const auto & monGroup_online = getGroup( trigger_num + "_Efficiency_HLT" );
75 const auto & monGroup_offline = getGroup( trigger_num + "_Efficiency_Offline" );
76
77 std::vector<float> mass_vec, mass_off_vec, match_mass_vec, match_mass_off_vec;
78 std::vector<float> dphi_vec, dphi_off_vec, match_dphi_vec, match_dphi_off_vec;
79
80 auto mass_col = Monitored::Collection( "mass" , mass_vec );
81 auto mass_off_col = Monitored::Collection( "mass" , mass_off_vec );
82 auto match_mass_col = Monitored::Collection( "match_mass" , match_mass_vec );
83 auto match_mass_off_col = Monitored::Collection( "match_mass" , match_mass_off_vec );
84 auto dphi_col = Monitored::Collection( "dphi" , dphi_vec );
85 auto dphi_off_col = Monitored::Collection( "dphi" , dphi_off_vec );
86 auto match_dphi_col = Monitored::Collection( "match_dphi" , match_dphi_vec );
87 auto match_dphi_off_col = Monitored::Collection( "match_dphi" , match_dphi_off_vec );
88
89
90 std::vector<Legs> legs_den_vec, legs_num_vec;
91 const auto & k0 = d.at(key0Str);
92 const auto & k1 = d.at(key1Str);
93 make_legs( trigger_num , k0, k1, legs_num_vec);
94 make_legs( trigger_den , k0, k1, legs_den_vec);
95
96
97 // Fill denominator histograms
98 for (auto &legs : legs_den_vec){
99 // Fill online mass
100 if( legs.leg0 && legs.leg1 ){
101 mass_vec.push_back( (legs.leg0->p4() + legs.leg1->p4()).M() );
102 dphi_vec.push_back( legs.leg0->p4().DeltaPhi(legs.leg1->p4()) );
103
104 const xAOD::IParticle *leg0_off, *leg1_off =nullptr;
105 if( match( *offElectrons, legs.leg0, leg0_off) &&
106 match( *offElectrons, legs.leg1, leg1_off))
107 {
108 if (! (leg0_off == leg1_off)){ // should not be the same electron
109 mass_off_vec.push_back( (leg0_off->p4() + leg1_off->p4()).M() );
110 dphi_off_vec.push_back( leg0_off->p4().DeltaPhi(leg1_off->p4()) );
111 }
112 }
113 }
114 } // Loop over denominator legs
115
116
117 // Fill denominator histograms
118 for (auto &legs : legs_num_vec){
119
120 // Fill online mass
121 if( legs.leg0 && legs.leg1 ){
122 match_mass_vec.push_back( (legs.leg0->p4() + legs.leg1->p4()).M() );
123 match_dphi_vec.push_back( legs.leg0->p4().DeltaPhi(legs.leg1->p4()) );
124
125 const xAOD::IParticle *leg0_off, *leg1_off =nullptr;
126 if( match( *offElectrons, legs.leg0, leg0_off) &&
127 match( *offElectrons, legs.leg1, leg1_off))
128 {
129 if (! (leg0_off == leg1_off)){ // should not be the same electron
130 match_mass_off_vec.push_back( (leg0_off->p4() + leg1_off->p4()).M() );
131 match_dphi_off_vec.push_back( leg0_off->p4().DeltaPhi(leg1_off->p4()) );
132 }
133 }
134 }
135
136 }// Loop over numerator legs
137
138 fill(monGroup_online, mass_col, match_mass_col, dphi_col, match_dphi_col);
139 fill(monGroup_offline, mass_off_col, match_mass_off_col, dphi_off_col, match_dphi_off_col);
140
141 }// Loop over all triggers
142
143 return StatusCode::SUCCESS;
144}
145
147
149 const xAOD::IParticle *part_on ,
150 const xAOD::IParticle *&part_off) const
151{
152 part_off=nullptr;
153 float min_deltaR = 999;
154 for (auto part : container){
155 float dR = part_on->p4().DeltaR(part->p4());
156 if ( dR < min_deltaR ){
157 part_off = part;
158 min_deltaR = dR;
159 }
160 }
161 return ( (min_deltaR < m_dR) && part_off);
162}
163
165
166void TrigEgammaMonitorTopoAlgorithm::make_legs( const std::string& trigger,
167 std::string key_leg0,
168 std::string key_leg1,
169 std::vector<Legs> &legs_vec ) const
170{
171 // Configure TDT to get each leg. only electrons that fired this triggers (e.g: e26_lhtight_e15_etcut_(Zee))
172 // are retrieved (passed by HLT and has at least one Electron online object)
174 frd_leg0.reset();
175 frd_leg0.setChainGroup(trigger);
176 frd_leg0.setCondition(TrigDefs::Physics); // Only fired trigger
177 frd_leg0.setRequireSGKey( TrigEgammaMonitorBaseAlgorithm::match()->key(std::move(key_leg0)));
178 frd_leg0.setRestrictRequestToLeg(0);
179
181 frd_leg1.reset();
182 frd_leg1.setChainGroup(trigger);
183 frd_leg1.setCondition(TrigDefs::Physics); // Only fired trigger
184 frd_leg1.setRequireSGKey( TrigEgammaMonitorBaseAlgorithm::match()->key(std::move(key_leg1)));
185 frd_leg1.setRestrictRequestToLeg(1);
186
187 // Get all combinations given by the L1
188 auto vec_leg0=tdt()->features<xAOD::IParticleContainer>(frd_leg0);
189 auto vec_leg1=tdt()->features<xAOD::IParticleContainer>(frd_leg1);
190
191 ATH_MSG_DEBUG("We have " << vec_leg0.size() << " combinations for leg0 from " << trigger);
192 ATH_MSG_DEBUG("We have " << vec_leg1.size() << " combinations for leg1 from " << trigger);
193
194 for ( auto & leg0_feat : vec_leg0){
195
196 for ( auto & leg1_feat : vec_leg1){
197 // Check if all links are valid
198 if ( !leg0_feat.isValid() || !leg1_feat.isValid() )
199 continue;
200 //auto leg0 = static_cast<xAOD::Egamma>(*leg0_feat.link);
201 //auto leg1 = static_cast<xAOD::Egamma>(*leg1_feat.link);
202 auto leg0 = (*leg0_feat.link);
203 auto leg1 = (*leg1_feat.link);
204
205 if (leg0 == leg1) continue;
206
207 legs_vec.push_back( Legs{leg0 , leg1} );
208 } // Loop over leg 1
209 } // Loop over leg 0
210}
211
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_INFO(x,...)
const ToolHandle< GenericMonitoringTool > & getGroup(std::string_view name) const
Get a specific monitoring tool from the tool handle array.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigEgammaMonitorBaseAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
Get the e/g match tool.
float dR(const float, const float, const float, const float) const
Get delta R.
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
Get the TDT.
virtual StatusCode initialize() override
initialize
virtual StatusCode fillHistograms(const EventContext &ctx) const override
=========================================================================
TrigEgammaMonitorTopoAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< float > m_dR
Min Delta R between online and offline.
bool match(const xAOD::IParticleContainer &container, const xAOD::IParticle *part_on, const xAOD::IParticle *&part_off) const
=========================================================================
virtual ~TrigEgammaMonitorTopoAlgorithm() override
=========================================================================
SG::ReadHandleKey< xAOD::PhotonContainer > m_offPhotonKey
void make_legs(const std::string &trigger, std::string key_leg0, std::string key_leg1, std::vector< Legs > &) const
Get all combinations.
Gaudi::Property< std::vector< std::map< std::string, std::string > > > m_trigListConfig
List of configurations.
SG::ReadHandleKey< xAOD::ElectronContainer > m_offElectronKey
Event Wise offline ElectronContainer Access and end iterator.
virtual StatusCode initialize() override
=========================================================================
FeatureRequestDescriptor & setCondition(const unsigned int condition)
Set the Condition: TrigDefs::Physics - (default), only returns features from paths through the naviga...
void reset()
Reset the FeatureRequestDescriptor to its default configuration.
FeatureRequestDescriptor & setChainGroup(const std::string &chainGroupName)
Set the desired Chain or Chain Group.
FeatureRequestDescriptor & setRestrictRequestToLeg(const int restrictToLegIndex)
Set to -1 by default, indicating that all legs of multi-leg chains are searched.
FeatureRequestDescriptor & setRequireSGKey(const std::string &containerSGKey)
Set the StoreGate key filter.
Class providing the definition of the 4-vector interface.
virtual FourMom_t p4() const =0
The full 4-momentum of the particle.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
ValuesCollection< T > Collection(std::string name, const T &collection)
Declare a monitored (double-convertible) collection.
The common trigger namespace for trigger analysis tools.
DataVector< IParticle > IParticleContainer
Simple convenience declaration of IParticleContainer.