ATLAS Offline Software
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 
11 using namespace Trig;
12 
13 
14 TrigEgammaMonitorPhotonAlgorithm::TrigEgammaMonitorPhotonAlgorithm( const std::string& name, ISvcLocator* pSvcLocator ):
16 {}
17 
19 {}
20 
21 
22 
24 {
25 
27 
28  ATH_CHECK(m_offPhotonKey.initialize());
29  ATH_CHECK(m_offPhotonIsolationKeys.initialize());
30  ATH_CHECK( m_eventInfoDecorKey.initialize() );
31 
32  for(auto& trigName : m_trigInputList)
33  {
34  if(getTrigInfoMap().count(trigName) != 0){
35  ATH_MSG_DEBUG("Trigger already booked, removing from trigger list " << trigName);
36  }else {
37  m_trigList.push_back(trigName);
38  setTrigInfo(trigName);
39  }
40  }
41 
42  return StatusCode::SUCCESS;
43 }
44 
45 
47 {
48  ATH_MSG_DEBUG("Executing TrigEgammaMonitorPhotonAlgorithm");
49 
50 
51  if(isHLTTruncated()){
52  ATH_MSG_DEBUG("HLTResult truncated, skip trigger analysis");
53  return StatusCode::SUCCESS;
54  }
55 
56  // Noise burst protection
58  ATH_CHECK(thisEvent.isValid());
60  ATH_MSG_DEBUG("LAr Noise Burst Veto, skip trigger analysis");
61  return StatusCode::SUCCESS;
62  }
63 
64  ATH_MSG_DEBUG("Chains for Analysis " << m_trigList);
65 
66  for(const auto& trigger : m_trigList){
67 
68  const TrigInfo info = getTrigInfo(trigger);
69  ATH_MSG_DEBUG("Start Chain Analysis ============================= " << trigger << " " << info.trigger);
70 
71  // Check if this trigger is in the bootstrap map
72  auto it = m_BSTrigMap.find(trigger);
73 
74  if ( it != m_BSTrigMap.end() ) {
75 
76  ATH_MSG_DEBUG( trigger << " is a bootstrapped trigger");
77 
78  std::string bootstrap = it->second;
79  ATH_MSG_DEBUG( "Bootstrapping " << trigger << " from " << bootstrap );
80 
81 
82  if (!tdt()->isPassed(bootstrap)){
83  ATH_MSG_DEBUG("Not passed BS trigger. Skipping! ========================== " << trigger);
84  continue;
85  } else {
86  ATH_MSG_DEBUG("BS trigger passed!");
87  }
88 
89  }
90 
91  std::vector< std::pair<std::shared_ptr<const xAOD::Egamma>, const TrigCompositeUtils::Decision * >> pairObjs;
92 
93  if ( executeNavigation( ctx,info,pairObjs).isFailure() )
94  {
95  ATH_MSG_DEBUG("executeNavigation Fails");
96  return StatusCode::SUCCESS;
97  }
98 
99  std::vector< std::pair<const xAOD::Egamma*, const TrigCompositeUtils::Decision*>> pairObjsRaw;
100  pairObjsRaw.reserve(pairObjs.size());
101  for (const auto& itr : pairObjs) {
102  pairObjsRaw.emplace_back(itr.first.get(), itr.second);
103  }
104 
105  fillDistributions( pairObjsRaw, info );
106  fillEfficiencies( pairObjsRaw, info );
107  fillResolutions( pairObjsRaw, info );
108 
109 
110  ATH_MSG_DEBUG("End Chain Analysis ============================= " << trigger);
111  } // End loop over trigger list
112 
113 
114  return StatusCode::SUCCESS;
115 }
116 
117 
118 
119 
120 
122  std::vector<std::pair<std::shared_ptr<const xAOD::Egamma>, const TrigCompositeUtils::Decision * >> &pairObjs)
123  const
124 {
125  ATH_MSG_DEBUG("Apply navigation selection for Photons");
126 
128 
129  if(!offPhotons.isValid())
130  {
131  ATH_MSG_DEBUG("Failed to retrieve offline photons ");
132  return StatusCode::FAILURE;
133  }
134  const std::string trigItem = info.trigger;
135  const float etthr = info.etthr;
136  const std::string pidName = info.pidname;
137  const std::string decorName="is"+pidName;
138 
139  for(const auto *const eg : *offPhotons ){
140  const TrigCompositeUtils::Decision *dec=nullptr;
141  if(!eg->caloCluster()){
142  ATH_MSG_DEBUG("No caloCluster");
143  continue;
144  }
145  if( !(getCluster_et(eg) > (etthr-5.)*Gaudi::Units::GeV)) continue; //Take 5 GeV below threshold
146  if(!info.etcut){
147  if(!eg->passSelection(m_photonPid)) {
148  ATH_MSG_DEBUG("Fails PhotonID: " << m_photonPid);
149  continue; // reject offline photons reproved by tight requiriment
150  }
151  }
153  if(!ApplyPhotonPid(eg,pidName)){
154  ATH_MSG_DEBUG("Fails PhotonID: "<< pidName << " Trigger: " << trigItem);
155  continue;
156  }
157  ATH_MSG_DEBUG("Passes PhotonID "<< pidName);
158  }
159  // default is false: if true, skip converted photons
160  if(m_doUnconverted){
161  if (eg->vertex()){
162  ATH_MSG_DEBUG("Removing converted photons, continuing...");
163  continue;
164  }
165  }
166  const auto ph = std::make_shared<const xAOD::Photon>(*eg);
167  SG::Decorator<bool> decor (decorName);
168  decor(*ph)=static_cast<bool>(true);
169  match()->match(ph.get(), trigItem, dec, TrigDefs::includeFailedDecisions);
170  //match()->match(ph, trigItem, dec);
171  pairObjs.emplace_back(ph, dec);
172  // }
173 
174  }
175 
176  ATH_MSG_DEBUG("BaseToolMT::Photon TEs " << pairObjs.size() << " found.");
177  return StatusCode::SUCCESS;
178 }
grepfile.info
info
Definition: grepfile.py:38
TrigEgammaMonitorAnalysisAlgorithm::fillEfficiencies
void fillEfficiencies(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * > > &, const TrigInfo &) const
Definition: TrigEgammaMonitorAnalysisAlgorithm.cxx:42
TrigEgammaMonitorPhotonAlgorithm::m_eventInfoDecorKey
SG::ReadDecorHandleKey< xAOD::EventInfo > m_eventInfoDecorKey
Definition: TrigEgammaMonitorPhotonAlgorithm.h:58
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
TrigEgammaMonitorPhotonAlgorithm::m_offPhotonKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_offPhotonKey
Event Wise offline PhotonContainer Access and end iterator.
Definition: TrigEgammaMonitorPhotonAlgorithm.h:55
TrigEgammaMonitorPhotonAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigEgammaMonitorPhotonAlgorithm.cxx:23
TrigEgammaMonitorBaseAlgorithm::getTrigInfoMap
const std::map< std::string, TrigInfo > & getTrigInfoMap()
Helper methods.
Definition: TrigEgammaMonitorBaseAlgorithm.h:127
ParticleTest.eg
eg
Definition: ParticleTest.py:29
TrigEgammaMonitorPhotonAlgorithm::m_photonPid
Gaudi::Property< std::string > m_photonPid
Photon pid word.
Definition: TrigEgammaMonitorPhotonAlgorithm.h:39
_triginfo
Definition: TrigEgammaMonitorBaseAlgorithm.h:42
Trig
The common trigger namespace for trigger analysis tools.
Definition: LArCellMonAlg.h:33
TrigEgammaMonitorPhotonAlgorithm::m_trigList
std::vector< std::string > m_trigList
List of triggers to study.
Definition: TrigEgammaMonitorPhotonAlgorithm.h:37
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
TrigEgammaMonitorBaseAlgorithm::ApplyPhotonPid
bool ApplyPhotonPid(const xAOD::Photon *eg, const std::string &) const
Get offline electron decision.
Definition: TrigEgammaMonitorBaseAlgorithm.cxx:91
TrigEgammaMonitorPhotonAlgorithm::m_forcePidSelection
Gaudi::Property< bool > m_forcePidSelection
force pid selection into photon navigation
Definition: TrigEgammaMonitorPhotonAlgorithm.h:51
TrigEgammaMonitorAnalysisAlgorithm::fillDistributions
void fillDistributions(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * > > &, const TrigInfo &) const
Definition: TrigEgammaMonitorAnalysisAlgorithm.cxx:407
skel.it
it
Definition: skel.GENtoEVGEN.py:396
TrigEgammaMonitorPhotonAlgorithm::executeNavigation
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
Definition: TrigEgammaMonitorPhotonAlgorithm.cxx:121
TrigEgammaMonitorPhotonAlgorithm::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TrigEgammaMonitorPhotonAlgorithm.cxx:46
TrigEgammaMonitorBaseAlgorithm::tdt
const ToolHandle< Trig::TrigDecisionTool > & tdt() const
Get the TDT
Definition: TrigEgammaMonitorBaseAlgorithm.h:133
TrigEgammaMonitorPhotonAlgorithm::m_doUnconverted
Gaudi::Property< bool > m_doUnconverted
doUnconverted analysis
Definition: TrigEgammaMonitorPhotonAlgorithm.h:41
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
LArEventBitInfo.h
TrigEgammaMonitorAnalysisAlgorithm::fillResolutions
void fillResolutions(const std::vector< std::pair< const xAOD::Egamma *, const TrigCompositeUtils::Decision * >> &pairObjs, const TrigInfo &info) const
*****************************************************************************************************...
Definition: TrigEgammaMonitorAnalysisAlgorithm.cxx:914
TrigEgammaMonitorPhotonAlgorithm::~TrigEgammaMonitorPhotonAlgorithm
virtual ~TrigEgammaMonitorPhotonAlgorithm() override
Definition: TrigEgammaMonitorPhotonAlgorithm.cxx:18
TrigEgammaMonitorBaseAlgorithm::isHLTTruncated
bool isHLTTruncated() const
Definition: TrigEgammaMonitorBaseAlgorithm.cxx:733
LArEventBitInfo::NOISEBURSTVETO
@ NOISEBURSTVETO
Definition: LArEventBitInfo.h:13
TrigEgammaMonitorBaseAlgorithm::getTrigInfo
TrigInfo getTrigInfo(const std::string &) const
Get the trigger info parsed from the chain name (only single lepton triggers)
Definition: TrigEgammaMonitorBaseAlgorithm.cxx:583
SG::Decorator< bool >
TrigEgammaMonitorBaseAlgorithm::setTrigInfo
void setTrigInfo(const std::string &)
Set the trigger info parsed from the chain name.
Definition: TrigEgammaMonitorBaseAlgorithm.cxx:591
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
AthMonitorAlgorithm::GetEventInfo
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
Definition: AthMonitorAlgorithm.cxx:107
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigEgammaMonitorPhotonAlgorithm::m_BSTrigMap
Gaudi::Property< std::map< std::string, std::string > > m_BSTrigMap
Definition: TrigEgammaMonitorPhotonAlgorithm.h:47
TrigEgammaMonitorAnalysisAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigEgammaMonitorAnalysisAlgorithm.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigEgammaMonitorPhotonAlgorithm::TrigEgammaMonitorPhotonAlgorithm
TrigEgammaMonitorPhotonAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigEgammaMonitorPhotonAlgorithm.cxx:14
TrigEgammaMonitorBaseAlgorithm::match
const ToolHandle< TrigEgammaMatchingToolMT > & match() const
Get the e/g match tool.
Definition: TrigEgammaMonitorBaseAlgorithm.h:135
TrigEgammaMonitorPhotonAlgorithm.h
TrigEgammaMonitorPhotonAlgorithm::m_offPhotonIsolationKeys
SG::ReadDecorHandleKeyArray< xAOD::PhotonContainer > m_offPhotonIsolationKeys
Ensure offline photon isolation decoration is retrieved after being created.
Definition: TrigEgammaMonitorPhotonAlgorithm.h:57
xAOD::EventInfo_v1::isEventFlagBitSet
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
Definition: EventInfo_v1.cxx:703
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
TrigEgammaMonitorAnalysisAlgorithm
Definition: TrigEgammaMonitorAnalysisAlgorithm.h:11
TrigEgammaMonitorPhotonAlgorithm::m_trigInputList
Gaudi::Property< std::vector< std::string > > m_trigInputList
List of triggers from menu.
Definition: TrigEgammaMonitorPhotonAlgorithm.h:43