ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaMatchingToolTest.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
5// TrigEgammaMatchingToolTest.cxx
6
8#include "Gaudi/Property.h"
9using std::string;
10
11//**********************************************************************
12namespace Trig{
14 TrigEgammaMatchingToolTest(const std::string& name,
15 ISvcLocator* pSvcLocator )
16 : ::AthAlgorithm( name, pSvcLocator ),
17 m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"),
18 m_matchTool("Trig::TrigEgammaMatchingTool/TrigEgammaMatchingTool",this)
19 //m_matchTool2("TriggerMatchingTool/MatchingTool",this)
20 {
21 declareProperty("TrigEgammaMatchingTool",m_matchTool);
22 //declareProperty("TriggerMatchingTool",m_matchTool2);
23 declareProperty("TriggerList",m_triggerList);
24 declareProperty("CombinedTriggerList",m_cmbTriggerList);
25 }
26
27 //**********************************************************************
28
30
31 //**********************************************************************
32
34 ATH_MSG_INFO("Initializing " << name() << "...");
35 ATH_MSG_INFO("Retrieving tools...");
36 if ( (m_trigdec.retrieve()).isFailure() ){
37 ATH_MSG_ERROR("Could not retrieve Trigger Decision Tool! Can't work");
38 return StatusCode::FAILURE;
39 }
40 return StatusCode::SUCCESS;
41 }
42
43 //**********************************************************************
44
46 ATH_MSG_INFO ("Finalizing " << name() << "...");
47 for (auto iter = m_counterBits.begin(); iter != m_counterBits.end(); iter++) {
48 ATH_MSG_DEBUG(iter->first << " == " << iter->second);
49 }
50 for (auto iter = m_counterMatch3Bits.begin(); iter != m_counterMatch3Bits.end(); iter++) {
51 ATH_MSG_INFO("REGTEST: " << iter->first << " " << iter->second << " " << m_counterMatch2Bits[iter->first] << " " << m_counterMatch1Bits[iter->first] << " Generic match " << m_counterMatch4Bits[iter->first]);
52 }
53 for (auto iter = m_counterCmbMatchBits.begin(); iter != m_counterCmbMatchBits.end(); iter++) {
54 ATH_MSG_INFO("REGTEST: " << iter->first << " == " << iter->second);
55 }
56
57 return StatusCode::SUCCESS;
58 }
59
60 //**********************************************************************
61
62 void TrigEgammaMatchingToolTest::match(const std::string& trigger,const xAOD::Egamma *eg){
63
64
65 if (eg) {
66 if(m_matchTool->match(eg,trigger)){
67 ATH_MSG_DEBUG("REGTEST:: Method 1 Matched Electron with tool for " << trigger);
68 m_counterMatch1Bits[trigger]++;
69 }
70 else ATH_MSG_DEBUG("REGTEST::Fails method 1 " << trigger);
71#ifdef XAOD_ANALYSIS
72 const HLT::TriggerElement *finalFC;
73 if(m_matchTool->match(eg,trigger,finalFC)){
74 ATH_MSG_DEBUG("REGTEST:: Method 2 Matched Electron with tool for " << trigger);
75 if ( finalFC != NULL ){
76 if ( (m_trigdec->ancestor<xAOD::ElectronContainer>(finalFC)).te() != NULL ){
77 if( (m_trigdec->ancestor<xAOD::ElectronContainer>(finalFC)).te()->getActiveState()){
78 ATH_MSG_DEBUG("REGTEST::Passed Matching method 2 for " << trigger);
79 m_counterMatch2Bits[trigger]++;
80 }
81 else ATH_MSG_DEBUG("REGTEST::Fails method 2");
82 }
83 }
84 }
85#endif
86 if(m_matchTool->matchHLT(eg,trigger)){
87 ATH_MSG_DEBUG("REGTEST:: Method 3 Matched Electron with tool for " << trigger);
88 m_counterMatch3Bits[trigger]++;
89 }
90 else ATH_MSG_DEBUG("REGTEST::Fails method 3");
91 /*std::vector<const xAOD::IParticle *> reco;
92 reco.push_back(eg);
93 if(m_matchTool2->match(reco,trigger)){
94 ATH_MSG_DEBUG("REGTEST:: Generic Matched Electron with tool for " << trigger);
95 m_counterMatch4Bits[trigger]++;
96 }
97 else ATH_MSG_DEBUG("REGTEST::Fails generic tool");*/
98 }
99 else ATH_MSG_DEBUG("REGTEST: eg pointer null!");
100 }
101
103 ATH_MSG_INFO ("Executing " << name() << "...");
104 ATH_MSG_VERBOSE( "L1: " << m_trigdec->isPassed( "L1_.*" )
105 << ", L2: " << m_trigdec->isPassed( "L2_.*" )
106 << ", EF: " << m_trigdec->isPassed( "EF_.*" )
107 << ", HLT: " << m_trigdec->isPassed( "HLT_.*" ) );
108 auto chainGroups = m_trigdec->getChainGroup("HLT_e.*");
109
110 for(auto &trig : chainGroups->getListOfTriggers()) {
111 if(m_trigdec->isPassed(trig))
112 ATH_MSG_VERBOSE("Passed: " << trig);
113 m_counterBits[trig]+=m_trigdec->isPassed(trig);
114 }
115
116 //Check Containers
117
118 const xAOD::ElectronContainer *offElectrons = 0;
119 const xAOD::TauJetContainer *taus = 0;
120 const xAOD::MuonContainer *muons = 0;
121 if ( (evtStore()->retrieve(offElectrons,"Electrons")).isFailure() ){
122 ATH_MSG_DEBUG("Failed to retrieve offline Electrons ");
123 }
124 if ( (evtStore()->retrieve(taus,"")).isFailure() ){
125 ATH_MSG_DEBUG("Failed to retrieve offline Taus ");
126 }
127 if ( (evtStore()->retrieve(muons,"Muons")).isFailure() ){
128 ATH_MSG_DEBUG("Failed to retrieve offline Muons ");
129 }
130 if(offElectrons) ATH_MSG_INFO("Offline Electron container size " << offElectrons->size());
131 if(muons) ATH_MSG_INFO("Offline Muon container size " << muons->size());
132 if(taus) ATH_MSG_INFO("Offline Tau container size " << taus->size());
133 for(const auto &trigger : m_triggerList){
134 if(!offElectrons) continue;
135 for(const auto eg : *offElectrons){
136 match(trigger,eg);
137 } //End loop of offline electrons
138 } // End loop over trigger list
139
140 // Test combined triggers with generic tool
141 /*for(const auto &trigger : m_cmbTriggerList){
142 std::vector<const xAOD::IParticle *> reco;
143
144 for(const auto& eg : *offElectrons){
145 // e-e
146 for(const auto& eg2 : *offElectrons){
147 if(eg==eg2) continue;
148 reco.clear();
149 reco.push_back(eg);
150 reco.push_back(eg2);
151 if(m_matchTool2->match(reco,trigger)){
152 ATH_MSG_DEBUG("REGTEST::Passed combined matching method for " << trigger);
153 m_counterCmbMatchBits[trigger]++;
154 }
155 else ATH_MSG_DEBUG("REGTEST::Failed combined method for " << trigger);
156
157 }
158 // e-mu
159 if(muons){
160 for(const auto& mu : *muons){
161 reco.clear();
162 reco.push_back(eg);
163 reco.push_back(mu);
164 if(m_matchTool2->match(reco,trigger)) {
165 ATH_MSG_DEBUG("REGTEST::Passed combined matching method for " << trigger);
166 m_counterCmbMatchBits[trigger]++;
167 }
168 else ATH_MSG_DEBUG("REGTEST::Failed combined method for " << trigger);
169
170 }
171 }
172 // e-tau
173 if(taus){
174 for(const auto& tau : *taus){
175 reco.clear();
176 reco.push_back(eg);
177 reco.push_back(tau);
178 if(m_matchTool2->match(reco,trigger)){
179 ATH_MSG_DEBUG("REGTEST::Passed combined matching method for " << trigger);
180 m_counterCmbMatchBits[trigger]++;
181 }
182 else ATH_MSG_DEBUG("REGTEST::Failed combined method for " << trigger);
183
184 }
185 }
186 }
187 }*/
188
189
190 return StatusCode::SUCCESS;
191 } // End execute
192} //End namespace Trig
193//**********************************************************************
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
static Double_t taus
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
size_type size() const noexcept
Returns the number of elements in the collection.
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
std::map< std::string, int > m_counterCmbMatchBits
ToolHandle< ITrigEgammaMatchingTool > m_matchTool
std::map< std::string, int > m_counterMatch3Bits
StatusCode initialize()
Athena algorithm's Hooks.
void match(const std::string &, const xAOD::Egamma *)
TrigEgammaMatchingToolTest()
Default constructor:
std::map< std::string, int > m_counterMatch4Bits
std::vector< std::string > m_cmbTriggerList
std::map< std::string, int > m_counterMatch2Bits
std::map< std::string, int > m_counterMatch1Bits
std::map< std::string, int > m_counterBits
ToolHandle< Trig::TrigDecisionTool > m_trigdec
The common trigger namespace for trigger analysis tools.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
Egamma_v1 Egamma
Definition of the current "egamma version".
Definition Egamma.h:17
TauJetContainer_v3 TauJetContainer
Definition of the current "taujet container version".
MuonContainer_v1 MuonContainer
Definition of the current "Muon container version".