ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaMonitorPhotonAlgorithm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
9
10
11using namespace Trig;
12
13
14TrigEgammaMonitorPhotonAlgorithm::TrigEgammaMonitorPhotonAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ):
15 TrigEgammaMonitorAnalysisAlgorithm( name, pSvcLocator )
16{
17}
18
21
22
23
25{
26
28
29 ATH_CHECK(m_offPhotonKey.initialize());
31 ATH_CHECK( m_eventInfoDecorKey.initialize() );
32
33 for(auto& trigName : m_trigInputList)
34 {
35 if(getTrigInfoMap().count(trigName) != 0){
36 ATH_MSG_DEBUG("Trigger already booked, removing from trigger list " << trigName);
37 }else {
38 m_trigList.push_back(trigName);
39 setTrigInfo(trigName);
40 }
41 }
42
43 return StatusCode::SUCCESS;
44}
45
46
47StatusCode TrigEgammaMonitorPhotonAlgorithm::fillHistograms( const EventContext& ctx ) const
48{
49 ATH_MSG_DEBUG("Executing TrigEgammaMonitorPhotonAlgorithm");
50
51
52 if(isHLTTruncated()){
53 ATH_MSG_DEBUG("HLTResult truncated, skip trigger analysis");
54 return StatusCode::SUCCESS;
55 }
56
57 // Noise burst protection
59 ATH_CHECK(thisEvent.isValid());
60 if ( thisEvent->isEventFlagBitSet(xAOD::EventInfo::LAr,LArEventBitInfo::NOISEBURSTVETO)) {
61 ATH_MSG_DEBUG("LAr Noise Burst Veto, skip trigger analysis");
62 return StatusCode::SUCCESS;
63 }
64
65 ATH_MSG_DEBUG("Chains for Analysis " << m_trigList);
66
67 for(const auto& trigger : m_trigList){
68
69 const TrigInfo info = getTrigInfo(trigger);
70 ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger << " " << info.trigger);
71
72 // Check if this trigger is in the bootstrap map
73 auto it = m_BSTrigMap.find(trigger);
74
75 if ( it != m_BSTrigMap.end() ) {
76
77 ATH_MSG_DEBUG( trigger << " is a bootstrapped trigger");
78
79 std::string bootstrap = it->second;
80 ATH_MSG_DEBUG( "Bootstrapping " << trigger << " from " << bootstrap );
81
82
83 if (!tdt()->isPassed(bootstrap)){
84 ATH_MSG_DEBUG("Not passed BS trigger. Skipping! ========================== " << trigger);
85 continue;
86 } else {
87 ATH_MSG_DEBUG("BS trigger passed!");
88 }
89
90 }
91
92 std::vector< std::pair<std::shared_ptr<const xAOD::Egamma>, const TrigCompositeUtils::Decision * >> pairObjs;
93
94 if ( executeNavigation( ctx,info,pairObjs).isFailure() )
95 {
96 ATH_MSG_DEBUG("executeNavigation Fails");
97 return StatusCode::SUCCESS;
98 }
99
100 std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> pairObjsRaw;
101 pairObjsRaw.reserve(pairObjs.size());
102 for (const auto& itr : pairObjs) {
103 pairObjsRaw.emplace_back(itr.first.get(), itr.second);
104 }
105
106 fillDistributions( pairObjsRaw, info );
107 fillEfficiencies( pairObjsRaw, info, m_onlyHLT );
108 fillResolutions( pairObjsRaw, info );
109
110
111 ATH_MSG_DEBUG("End Chain Analysis ============================= " << trigger);
112 } // End loop over trigger list
113
114
115 return StatusCode::SUCCESS;
116}
117
118
119
120
121
122StatusCode TrigEgammaMonitorPhotonAlgorithm::executeNavigation( const EventContext& ctx, const TrigInfo& info,
123 std::vector<std::pair<std::shared_ptr<const xAOD::Egamma>, const TrigCompositeUtils::Decision * >> &pairObjs)
124 const
125{
126 ATH_MSG_DEBUG("Apply navigation selection for Photons");
127
129
130 if(!offPhotons.isValid())
131 {
132 ATH_MSG_DEBUG("Failed to retrieve offline photons ");
133 return StatusCode::FAILURE;
134 }
135 const std::string trigItem = info.trigger;
136 const float etthr = info.etthr;
137 const std::string pidName = info.pidname;
138 const std::string decorName="is"+pidName;
139
140 for(const auto *const eg : *offPhotons ){
141 const TrigCompositeUtils::Decision *dec=nullptr;
142 if(!eg->caloCluster()){
143 ATH_MSG_DEBUG("No caloCluster");
144 continue;
145 }
146 if( !(getCluster_et(eg) > (etthr-5.)*Gaudi::Units::GeV)) continue; //Take 5 GeV below threshold
147 if(!info.etcut){
148 if(!eg->passSelection(m_photonPid)) {
149 ATH_MSG_DEBUG("Fails PhotonID: " << m_photonPid);
150 continue; // reject offline photons reproved by tight requiriment
151 }
152 }
154 if(!ApplyPhotonPid(eg,pidName)){
155 ATH_MSG_DEBUG("Fails PhotonID: "<< pidName << " Trigger: " << trigItem);
156 continue;
157 }
158 ATH_MSG_DEBUG("Passes PhotonID "<< pidName);
159 }
160 // default is false: if true, skip converted photons
161 if(m_doUnconverted){
162 if (eg->vertex()){
163 ATH_MSG_DEBUG("Removing converted photons, continuing...");
164 continue;
165 }
166 }
167 const auto ph = std::make_shared<const xAOD::Photon>(*eg);
168 SG::Decorator<bool> decor (decorName);
169 decor(*ph)=static_cast<bool>(true);
170 match()->match(ph.get(), trigItem, dec, TrigDefs::includeFailedDecisions);
171 //match()->match(ph, trigItem, dec);
172 pairObjs.emplace_back(ph, dec);
173 // }
174
175 }
176
177 ATH_MSG_DEBUG("BaseToolMT::Photon TEs " << pairObjs.size() << " found.");
178 return StatusCode::SUCCESS;
179}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Helper class to provide constant type-safe access to aux data.
Handle class for reading a decoration on an object.
struct _triginfo TrigInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Helper class to provide type-safe access to aux data.
Definition Decorator.h:59
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual StatusCode initialize() override
initialize
TrigEgammaMonitorAnalysisAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
void fillEfficiencies(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * > > &, const TrigInfo &, const bool) const
void fillResolutions(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * > > &pairObjs, const TrigInfo &info) const
*****************************************************************************************************...
void fillDistributions(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * > > &, const TrigInfo &) const
bool ApplyPhotonPid(const xAOD::Photon *eg, const std::string &) const
Get offline electron decision.
const std::map< std::string, TrigInfo > & getTrigInfoMap()
Helper methods.
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
Get the e/g match tool.
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
Get the TDT.
TrigInfo getTrigInfo(const std::string &) const
Get the trigger info parsed from the chain name (only single lepton triggers)
void setTrigInfo(const std::string &)
Set the trigger info parsed from the chain name.
Gaudi::Property< bool > m_forcePidSelection
force pid selection into photon navigation
Gaudi::Property< bool > m_doUnconverted
doUnconverted analysis
StatusCode executeNavigation(const EventContext &ctx, const TrigInfo &info, std::vector< std::pair< std::shared_ptr< const xAOD::Egamma >, const TrigCompositeUtils::Decision * > > &) const
navigation method called by executeNavigation
Gaudi::Property< std::map< std::string, std::string > > m_BSTrigMap
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
virtual StatusCode initialize() override
initialize
std::vector< std::string > m_trigList
List of triggers to study.
Gaudi::Property< std::vector< std::string > > m_trigInputList
List of triggers from menu.
Gaudi::Property< std::string > m_photonPid
Photon pid word.
SG::ReadDecorHandleKeyArray< xAOD::PhotonContainer > m_offPhotonIsolationKeys
Ensure offline photon isolation decoration is retrieved after being created.
SG::ReadHandleKey< xAOD::PhotonContainer > m_offPhotonKey
Event Wise offline PhotonContainer Access and end iterator.
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
TrigEgammaMonitorPhotonAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_onlyHLT
Compute only final HLT decision.
@ LAr
The LAr calorimeter.
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
static const unsigned int includeFailedDecisions
Run3 synonym of alsoDeactivateTEs.
The common trigger namespace for trigger analysis tools.