ATLAS Offline Software
Loading...
Searching...
No Matches
TrigEgammaEmulationToolTest.cxx
Go to the documentation of this file.
1
2/*
3 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
4*/
5
6// TrigEgammaMatchingToolTest.cxx
7
9
10
11
12//**********************************************************************
13
14TrigEgammaEmulationToolTest::TrigEgammaEmulationToolTest(const std::string& name, ISvcLocator* pSvcLocator )
15 : AthMonitorAlgorithm( name, pSvcLocator ),
16 m_trigdec("Trig::TrigDecisionTool/TrigDecisionTool")
17{
18 declareProperty("MatchTool" , m_matchTool );
19 declareProperty("EmulatorTool" , m_emulatorTool );
20}
21
22//**********************************************************************
23
25
26//**********************************************************************
27
29
30 ATH_MSG_DEBUG("Initializing " << name() << "...");
32 ATH_MSG_DEBUG("Retrieving tools...");
33
34 ATH_CHECK(m_trigdec.retrieve());
35 ATH_CHECK(m_offElectronKey.initialize());
36 ATH_CHECK(m_offPhotonKey.initialize());
37 ATH_CHECK(m_matchTool.retrieve());
38 ATH_CHECK(m_emulatorTool.retrieve());
39
40 m_accept.addCut("L1Calo","");
41 m_accept.addCut("L2Calo","");
42 m_accept.addCut("L2","");
43 m_accept.addCut("EFCalo","");
44 m_accept.addCut("EFTrack","");
45 m_accept.addCut("HLT","");
46
47
48 return StatusCode::SUCCESS;
49}
50
51
52//**********************************************************************
53
54
55StatusCode TrigEgammaEmulationToolTest::fillHistograms( const EventContext &ctx ) const
56{
57 ATH_MSG_DEBUG("=============== Start Event ===============");
58
60 if( !eventInfo.isValid() ){
61 ATH_MSG_WARNING("Failed to retrieve EventInfo");
62 return StatusCode::SUCCESS;
63 }
64 if (eventInfo->errorState(xAOD::EventInfo::LAr) == xAOD::EventInfo::Error) {
65 ATH_MSG_WARNING("Event not passing LAr");
66 return StatusCode::SUCCESS;
67 }
68
70 if(!offElectrons.isValid())
71 {
72 ATH_MSG_WARNING("Failed to retrieve offline Electrons ");
73 return StatusCode::SUCCESS;
74 }
75
76 ATH_MSG_DEBUG( "Electron size is " << offElectrons->size() );
77
78 for (const auto &trigger : m_electronTriggerList)
79 {
80 auto info = getInfo(trigger);
81 ATH_MSG_DEBUG(trigger);
82 for (const auto el : *offElectrons)
83 {
84
85
86 ATH_MSG_DEBUG( "Offline Electron cluster object is "<< el->caloCluster());
87 const TrigCompositeUtils::Decision *dec=nullptr;
88 //m_matchTool->match(el,trigger,dec, TrigDefs::includeFailedDecisions);
89 m_matchTool->match(el,trigger,dec, TrigDefs::Physics);
90
91 if (!dec) {
92 ATH_MSG_DEBUG("e/g matching fail. skip...");
93 continue;
94 }
95
96 auto accept = setAccept(dec, info);
97 bool valid=false;
98 auto emu_accept = m_emulatorTool->emulate( dec, info.trigger, valid );
99
100 ATH_MSG_DEBUG( "trigger : " << info.trigger << " (tdt/emu)");
101 ATH_MSG_DEBUG( "L1Calo : " << accept.getCutResult(0) << " / " << emu_accept.getCutResult(0));
102 ATH_MSG_DEBUG( "L2Calo : " << accept.getCutResult(1) << " / " << emu_accept.getCutResult(1));
103 ATH_MSG_DEBUG( "L2 : " << accept.getCutResult(2) << " / " << emu_accept.getCutResult(2));
104 ATH_MSG_DEBUG( "EFCalo : " << accept.getCutResult(3) << " / " << emu_accept.getCutResult(3));
105 ATH_MSG_DEBUG( "EFTrack : " << accept.getCutResult(4) << " / " << emu_accept.getCutResult(4));
106 ATH_MSG_DEBUG( "HLT : " << accept.getCutResult(5) << " / " << emu_accept.getCutResult(5));
107
108 auto monGroup = getGroup( trigger );
109
110
111 // Fill trigger decision tool steps
112 if (accept.getCutResult(0)){
113 fillLabel(monGroup, "decisions", "L1Calo");
114 if (accept.getCutResult(1)){
115 fillLabel(monGroup, "decisions", "L2Calo");
116 if(accept.getCutResult(2)){
117 fillLabel(monGroup, "decisions", "L2");
118 if(accept.getCutResult(3)){
119 fillLabel(monGroup, "decisions", "EFCalo");
120 if(accept.getCutResult(5)){
121 fillLabel(monGroup, "decisions", "HLT");
122 }
123 }
124 }
125 }
126 }
127
128 // Fill emulation
129 if (emu_accept.getCutResult(0)){
130 fillLabel(monGroup, "emulations", "L1Calo");
131 if (emu_accept.getCutResult(1)){
132 fillLabel(monGroup, "emulations", "L2Calo");
133 if(emu_accept.getCutResult(2)){
134 fillLabel(monGroup, "emulations", "L2");
135 if(emu_accept.getCutResult(3)){
136 fillLabel(monGroup, "emulations", "EFCalo");
137 if(emu_accept.getCutResult(5)){
138 fillLabel(monGroup, "emulations", "HLT");
139 }
140 }
141 }
142 }
143 }
144
145
146
147
148 }
149 }
150
151
152 ATH_MSG_DEBUG("================= End Event =================");
153
154 return StatusCode::SUCCESS;
155}
156
157
158
159//**********************************************************************
160
161
162
164 const TrigEgammaEmulationToolTest::TrigInfo& info) const
165{
166
167 ATH_MSG_DEBUG("setAccept");
168 unsigned int condition=TrigDefs::includeFailedDecisions;
169
170 asg::AcceptData acceptData (&m_accept);
171 bool passedL1Calo=false;
172 bool passedL2Calo=false;
173 bool passedEFCalo=false;
174 bool passedL2=false;
175 bool passedEFTrk=false;
176 bool passedEF=false;
177
178 if (dec) {
179
180 auto trigger = info.trigger;
181 // Step 1
182 passedL1Calo = m_matchTool->ancestorPassed<TrigRoiDescriptorCollection>( dec , trigger , "initialRois", condition);
183
184 if( passedL1Calo ){ // HLT item get full decision
185 // Step 2
186 passedL2Calo = m_matchTool->ancestorPassed<xAOD::TrigEMClusterContainer>(dec, trigger, m_matchTool->key("FastCalo"), condition);
187
188 if(passedL2Calo){
189
190 // Step 3
191 if(info.type == "electron"){
192 std::string key = m_matchTool->key("FastElectrons");
193 if(info.lrt) key = m_matchTool->key("FastElectrons_LRT");
194 passedL2 = m_matchTool->ancestorPassed<xAOD::TrigElectronContainer>(dec, trigger, key, condition);
195 }else if(info.type == "photon"){
196 passedL2 = m_matchTool->ancestorPassed<xAOD::TrigPhotonContainer>(dec, trigger, m_matchTool->key("FastPhotons"), condition);
197 }
198
199 if(passedL2){
200
201
202 // Step 4
203 std::string key = m_matchTool->key("PrecisionCalo");
204 if(info.lrt) key = m_matchTool->key("PrecisionCalo_LRT");
205 passedEFCalo = m_matchTool->ancestorPassed<xAOD::CaloClusterContainer>(dec, trigger, key, condition);
206
207 if(passedEFCalo){
208
209 // Step 5
210 passedEFTrk=true;// Assume true for photons
211
212 // Step 6
213 if(info.type == "electron"){
214
215 if( info.etcut || info.idperf){// etcut or idperf
216 passedEF = true; // since we dont run the preciseElectron step
217 }else{
218 std::string key = m_matchTool->key("Electrons");
219 if(info.lrt) key = m_matchTool->key("Electrons_LRT");
220 if(info.gsf) key = m_matchTool->key("Electrons_GSF");
221 passedEF = m_matchTool->ancestorPassed<xAOD::ElectronContainer>(dec, trigger, key, condition);
222 }
223
224 }else if(info.type == "photon"){
225 if (info.etcut){
226 passedEF = true; // since we dont run the precisePhoton step
227 }else{
228 passedEF = m_matchTool->ancestorPassed<xAOD::PhotonContainer>(dec, trigger, m_matchTool->key("Photons"), condition);
229 }
230 }
231 } // EFCalo
232 }// L2
233 }// L2Calo
234 }// L2Calo
235
236 }
237
238 acceptData.setCutResult("L1Calo",passedL1Calo);
239 acceptData.setCutResult("L2Calo",passedL2Calo);
240 acceptData.setCutResult("L2",passedL2);
241 acceptData.setCutResult("EFCalo",passedEFCalo);
242 acceptData.setCutResult("EFTrack",passedEFTrk);
243 acceptData.setCutResult("HLT",passedEF);
244
245 ATH_MSG_DEBUG("Accept results:");
246 ATH_MSG_DEBUG("L1: "<< passedL1Calo);
247 ATH_MSG_DEBUG("L2Calo: " << passedL2Calo);
248 ATH_MSG_DEBUG("L2: "<< passedL2);
249 ATH_MSG_DEBUG("EFCalo: "<< passedEFCalo);
250 ATH_MSG_DEBUG("HLT: "<<passedEF);
251
252 return acceptData;
253}
254
255//**********************************************************************
256
257
259{
260 std::string type = "electron"; // default
261 std::vector<std::string> strs;
262 boost::split(strs,trigger,boost::is_any_of("_"));
263 if(boost::contains(trigger,"HLT_e")) type = "electron";
264 else if(boost::contains(trigger,"HLT_g")) type = "photon";
265 bool idperf = boost::contains(trigger, "idperf");
266 bool etcut = boost::contains(trigger, "etcut");
267 bool lrt = boost::contains(trigger, "lrt");
268 bool gsf = boost::contains(trigger, "gsf");
269 std::string str_thr = strs.at(1);
270 str_thr.erase(0, 1);
271 float et = atof(str_thr.c_str());
272
273 ATH_MSG_DEBUG("type : " << type );
274 ATH_MSG_DEBUG("idperf : " << (idperf?"Yes":"No"));
275 ATH_MSG_DEBUG("etcut : " << (etcut?"Yes":"No"));
276 ATH_MSG_DEBUG("gsf : " << (gsf?"Yes":"No"));
277 ATH_MSG_DEBUG("lrt : " << (lrt?"Yes":"No"));
278
279
280
281 return TrigEgammaEmulationToolTest::TrigInfo{trigger,type,et,etcut,idperf,gsf,lrt};
282}
283
284//**********************************************************************
285
286
287void TrigEgammaEmulationToolTest::fillLabel( const ToolHandle<GenericMonitoringTool>& groupHandle,
288 const std::string &histname,
289 const std::string &label ) const
290{
291 auto mon = Monitored::Scalar<std::string>( histname, label );
292 fill( groupHandle, mon );
293}
294
295
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
virtual StatusCode initialize() override
initialize
SG::ReadHandle< xAOD::EventInfo > GetEventInfo(const EventContext &) const
Return a ReadHandle for an EventInfo object (get run/event numbers, etc.)
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
Declare a monitored scalar variable.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
TrigEgammaEmulationToolTest(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
ToolHandle< Trig::TrigEgammaEmulationToolMT > m_emulatorTool
asg::AcceptData setAccept(const TrigCompositeUtils::Decision *dec, const TrigEgammaEmulationToolTest::TrigInfo &info) const
TrigEgammaEmulationToolTest::TrigInfo getInfo(std::string trigger) const
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
SG::ReadHandleKey< xAOD::ElectronContainer > m_offElectronKey
void fillLabel(const ToolHandle< GenericMonitoringTool > &groupHandle, const std::string &histname, const std::string &label) const
ToolHandle< Trig::TrigDecisionTool > m_trigdec
virtual StatusCode initialize() override
Athena algorithm's Hooks.
Gaudi::Property< std::vector< std::string > > m_electronTriggerList
SG::ReadHandleKey< xAOD::PhotonContainer > m_offPhotonKey
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition AcceptData.h:134
@ LAr
The LAr calorimeter.
@ Error
The sub-detector issued an error.
void fill(const ToolHandle< GenericMonitoringTool > &groupHandle, std::vector< std::reference_wrapper< Monitored::IMonitoredVariable > > &&variables) const
Fills a vector of variables to a group by reference.
std::string label(const std::string &format, int i)
Definition label.h:19
static const unsigned int includeFailedDecisions
Run3 synonym of alsoDeactivateTEs.
PhotonContainer_v1 PhotonContainer
Definition of the current "photon container version".
TrigElectronContainer_v1 TrigElectronContainer
Declare the latest version of the container.
ElectronContainer_v1 ElectronContainer
Definition of the current "electron container version".
TrigEMClusterContainer_v1 TrigEMClusterContainer
Define the latest version of the trigger EM cluster container.
TrigPhotonContainer_v1 TrigPhotonContainer
Declare the latest version of the container.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
Extra patterns decribing particle interation process.