ATLAS Offline Software
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"
9 using std::string;
10 
11 //**********************************************************************
12 namespace 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);
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);
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);
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 //**********************************************************************
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
Trig::TrigEgammaMatchingToolTest::~TrigEgammaMatchingToolTest
~TrigEgammaMatchingToolTest()
Destructor:
Definition: TrigEgammaMatchingToolTest.cxx:29
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition: ParticleTest.py:29
Trig::TrigEgammaMatchingToolTest::m_counterMatch3Bits
std::map< std::string, int > m_counterMatch3Bits
Definition: TrigEgammaMatchingToolTest.h:56
Trig
The common trigger namespace for trigger analysis tools.
Definition: CaloTowerVecMon.h:44
Trig::TrigEgammaMatchingToolTest::m_counterMatch2Bits
std::map< std::string, int > m_counterMatch2Bits
Definition: TrigEgammaMatchingToolTest.h:55
Trig::TrigEgammaMatchingToolTest::finalize
StatusCode finalize()
Definition: TrigEgammaMatchingToolTest.cxx:45
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
Trig::TrigEgammaMatchingToolTest::match
void match(const std::string &, const xAOD::Egamma *)
Definition: TrigEgammaMatchingToolTest.cxx:62
Trig::TrigEgammaMatchingToolTest::m_trigdec
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Definition: TrigEgammaMatchingToolTest.h:45
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
Trig::TrigEgammaMatchingToolTest::m_counterCmbMatchBits
std::map< std::string, int > m_counterCmbMatchBits
Definition: TrigEgammaMatchingToolTest.h:53
Trig::TrigEgammaMatchingToolTest::TrigEgammaMatchingToolTest
TrigEgammaMatchingToolTest()
Default constructor:
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
Trig::TrigEgammaMatchingToolTest::m_counterMatch4Bits
std::map< std::string, int > m_counterMatch4Bits
Definition: TrigEgammaMatchingToolTest.h:57
AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Trig::TrigEgammaMatchingToolTest::m_counterBits
std::map< std::string, int > m_counterBits
Definition: TrigEgammaMatchingToolTest.h:52
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
HLT::TriggerElement
TriggerElement is the basic ingreedient of the interface between HLT algorithms and the navigation It...
Definition: TrigNavStructure/TrigNavStructure/TriggerElement.h:27
Trig::TrigEgammaMatchingToolTest::m_matchTool
ToolHandle< ITrigEgammaMatchingTool > m_matchTool
Definition: TrigEgammaMatchingToolTest.h:46
Trig::TrigEgammaMatchingToolTest::m_counterMatch1Bits
std::map< std::string, int > m_counterMatch1Bits
Definition: TrigEgammaMatchingToolTest.h:54
TrigEgammaMatchingToolTest.h
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
AthAlgorithm
Definition: AthAlgorithm.h:47
Trig::TrigEgammaMatchingToolTest::execute
StatusCode execute()
Definition: TrigEgammaMatchingToolTest.cxx:102
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Trig::TrigEgammaMatchingToolTest::m_triggerList
std::vector< std::string > m_triggerList
Definition: TrigEgammaMatchingToolTest.h:50
Trig::TrigEgammaMatchingToolTest::initialize
StatusCode initialize()
Athena algorithm's Hooks.
Definition: TrigEgammaMatchingToolTest.cxx:33
Trig::TrigEgammaMatchingToolTest::m_cmbTriggerList
std::vector< std::string > m_cmbTriggerList
Definition: TrigEgammaMatchingToolTest.h:51
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27