ATLAS Offline Software
TrigEgammaMatchingToolMTTest.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 
8 
9 
10 using namespace TrigCompositeUtils;
11 
12 
13 
14 TrigEgammaMatchingToolMTTest::TrigEgammaMatchingToolMTTest(const std::string& name, ISvcLocator* pSvcLocator )
15  : AthMonitorAlgorithm( name, pSvcLocator ),
16  m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool"),
17  m_matchTool("Trig::TrigEgammaMatchingTool/TrigEgammaMatchingToolMT",this)
18 
19 {
20  declareProperty("TrigEgammaMatchingToolMT",m_matchTool);
21  declareProperty("TriggerList",m_triggerList);
22 }
23 
24 
25 
26 //**********************************************************************
27 
29 
30  ATH_MSG_INFO("Initializing " << name() << "...");
31 
32  ATH_CHECK( m_trigdec.retrieve() );
33  ATH_CHECK( m_matchTool.retrieve());
35 
36 
37 
38  return StatusCode::SUCCESS;
39 }
40 
41 
42 
43 //**********************************************************************
44 
45 void TrigEgammaMatchingToolMTTest::inspect(const std::string& trigger,const xAOD::Egamma *eg) const {
46 
47  if (eg) {
48 
49  ATH_MSG_INFO("Getting all associated objects for " << trigger);
50 
51  const TrigCompositeUtils::Decision *dec=nullptr;
52 
53  m_matchTool->match( eg, trigger , dec);
54 
55  if ( dec )
56  {
57  ATH_MSG_INFO( "Matched!");
58 
59 
60  auto l1_link = m_matchTool->getFeature<TrigRoiDescriptorCollection>(dec, trigger);
61  auto emCluster_link = m_matchTool->getFeature<xAOD::TrigEMClusterContainer>( dec , trigger);
62  auto trig_el_links = m_matchTool->getFeatures<xAOD::TrigElectronContainer>( dec, trigger );
63  auto cl_links = m_matchTool->getFeatures<xAOD::CaloClusterContainer>( dec , trigger);
64  auto el_links = m_matchTool->getFeatures<xAOD::ElectronContainer>( dec , trigger);
65 
66  if( l1_link.isValid() ){
67  ATH_MSG_INFO( "We found the Roi object link" );
68  // Let's get the EMTau
69  auto l1 = m_matchTool->getL1Feature( l1_link.source );
70  if(l1)
71  ATH_MSG_INFO( "We found the EmTau object" );
72  ATH_MSG_INFO( "L1 object state is assigned as " << (l1_link.state==ActiveState::ACTIVE ? "Active" : "Not active") );
73  }
74 
75  if( emCluster_link.isValid() ){
76  ATH_MSG_INFO( "We found the EmCluster object link" );
77  ATH_MSG_INFO( "L2Calo object state is assigned as " << (emCluster_link.state==ActiveState::ACTIVE ? "Active" : "Not active") );
78  }
79 
80  if (trig_el_links.size() > 0){
81  ATH_MSG_INFO ( "We found " << trig_el_links.size() << " TrigElectron link objects for this decision souce." );
82  for ( auto featLinkInfo : trig_el_links ){
83  ATH_MSG_INFO( "L2Electron object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") );
84  }
85  }
86 
87  if (cl_links.size() > 0){
88  ATH_MSG_INFO ( "We found " << cl_links.size() << " CaloCluster link objects for this decision souce." );
89  for ( auto featLinkInfo : cl_links ){
90  ATH_MSG_INFO( "EFCalo object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") );
91  }
92  }
93 
94  if (el_links.size() > 0){
95  ATH_MSG_INFO ( "We found " << el_links.size() << " CaloCluster link objects for this decision souce." );
96  for ( auto featLinkInfo : el_links ){
97  ATH_MSG_INFO( "EFCalo object state is assigned as " << (featLinkInfo.state==ActiveState::ACTIVE ? "Active" : "Not active") );
98  }
99  }
100 
101 
102  bool passedHLT = m_matchTool->ancestorPassed<xAOD::ElectronContainer> (dec, trigger , "HLT_egamma_Electrons");
103  bool passedEFCalo = m_matchTool->ancestorPassed<xAOD::CaloClusterContainer> (dec, trigger , "HLT_CaloEMClusters");
104  bool passedL2 = m_matchTool->ancestorPassed<xAOD::TrigElectronContainer> (dec, trigger , "HLT_FastElectrons");
105  bool passedL2Calo = m_matchTool->ancestorPassed<xAOD::TrigEMClusterContainer> (dec, trigger , "HLT_FastCaloEMClusters");
106  bool passedL1Calo = m_matchTool->ancestorPassed<TrigRoiDescriptorCollection> (dec, trigger , "initialRois");
107 
108  ATH_MSG_INFO( "L1Calo passed : "<< passedL1Calo );
109  ATH_MSG_INFO( "L2Calo passed : "<< passedL2Calo );
110  ATH_MSG_INFO( "L2 passed : "<< passedL2 );
111  ATH_MSG_INFO( "EFCalo passed : "<< passedEFCalo );
112  ATH_MSG_INFO( "HLT passed : "<< passedHLT );
113 
114  }else{
115  ATH_MSG_INFO( "Not Matched! There is no Dec object for this trigger " << trigger );
116  }
117 
118  }
119  else ATH_MSG_INFO("REGTEST: eg pointer null!");
120 }
121 
122 
123 //**********************************************************************
124 
125 StatusCode TrigEgammaMatchingToolMTTest::fillHistograms( const EventContext& ctx ) const {
126 
127  ATH_MSG_INFO ("Fill histograms " << name() << "...");
128 
129 
131 
132  if( !el_cont.isValid() ){
133  ATH_MSG_WARNING("Container "<< m_electronKey << " does not exist or is empty");
134  return StatusCode::SUCCESS;
135  }
136 
137 
138  ATH_MSG_INFO("Offline Electron container size " << el_cont->size());
139 
140  for(const auto &trigger : m_triggerList){
141  for(const auto eg : *el_cont){
142  ATH_MSG_INFO("REGTEST:: Electron offline (eta="<<eg->eta()<<",phi="<<eg->phi()<<")");
143  inspect(trigger,eg);
144 
145  } //End loop of offline electrons
146  } // End loop over trigger list
147 
148 
149 
150  return StatusCode::SUCCESS;
151 } // End execute
152 
153 
154 
155 
156 
157 
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ParticleTest.eg
eg
Definition: ParticleTest.py:29
TrigEgammaMatchingToolMTTest.h
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TrigEgammaMatchingToolMTTest::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigEgammaMatchingToolMTTest.cxx:28
TrigCompositeUtils.h
xAOD::Egamma_v1
Definition: Egamma_v1.h:56
TrigEgammaMatchingToolMTTest::m_electronKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_electronKey
Definition: TrigEgammaMatchingToolMTTest.h:31
TrigEgammaMatchingToolMTTest::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TrigEgammaMatchingToolMTTest.cxx:125
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
DataVector
Derived DataVector<T>.
Definition: DataVector.h:581
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigEgammaMatchingToolMTTest::inspect
void inspect(const std::string &, const xAOD::Egamma *) const
Definition: TrigEgammaMatchingToolMTTest.cxx:45
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigEgammaMatchingToolMTTest::m_triggerList
std::vector< std::string > m_triggerList
Definition: TrigEgammaMatchingToolMTTest.h:37
TrigEgammaMatchingToolMTTest::m_matchTool
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
Definition: TrigEgammaMatchingToolMTTest.h:34
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
TrigCompositeUtils
Definition: Event/xAOD/xAODTrigger/xAODTrigger/TrigComposite.h:19
ACTIVE
@ ACTIVE
Definition: ZdcID.h:21
TrigEgammaMatchingToolMTTest::m_trigdec
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Definition: TrigEgammaMatchingToolMTTest.h:33
skel.l1
l1
Definition: skel.GENtoEVGEN.py:425
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
PhysDESDM_Quirks.trigger
trigger
Definition: PhysDESDM_Quirks.py:27
TrigEgammaMatchingToolMTTest::TrigEgammaMatchingToolMTTest
TrigEgammaMatchingToolMTTest(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigEgammaMatchingToolMTTest.cxx:14