ATLAS Offline Software
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 
14 TrigEgammaEmulationToolTest::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());
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 
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  }
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 
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 
287 void TrigEgammaEmulationToolTest::fillLabel( const ToolHandle<GenericMonitoringTool>& groupHandle,
288  const std::string &histname,
289  const std::string &label ) const
290 {
292  fill( groupHandle, mon );
293 }
294 
295 
grepfile.info
info
Definition: grepfile.py:38
TrigEgammaEmulationToolTest::m_trigdec
ToolHandle< Trig::TrigDecisionTool > m_trigdec
Definition: TrigEgammaEmulationToolTest.h:48
python.TIDAMonTool.monGroup
def monGroup(analysis_chain)
Definition: TIDAMonTool.py:297
et
Extra patterns decribing particle interation process.
TrigEgammaEmulationToolTest::m_electronTriggerList
Gaudi::Property< std::vector< std::string > > m_electronTriggerList
Definition: TrigEgammaEmulationToolTest.h:52
TrigEgammaEmulationToolTest::m_offElectronKey
SG::ReadHandleKey< xAOD::ElectronContainer > m_offElectronKey
Definition: TrigEgammaEmulationToolTest.h:55
xAOD::et
et
Definition: TrigEMCluster_v1.cxx:25
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
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
TrigEgammaEmulationToolTest::getInfo
TrigEgammaEmulationToolTest::TrigInfo getInfo(std::string trigger) const
Definition: TrigEgammaEmulationToolTest.cxx:258
CutsMETMaker::accept
StatusCode accept(const xAOD::Muon *mu)
Definition: CutsMETMaker.cxx:18
TrigEgammaEmulationToolTest::m_matchTool
ToolHandle< TrigEgammaMatchingToolMT > m_matchTool
Definition: TrigEgammaEmulationToolTest.h:49
LArG4GenerateShowerLib.condition
condition
Definition: LArG4GenerateShowerLib.py:19
TrigEgammaEmulationToolTest::m_offPhotonKey
SG::ReadHandleKey< xAOD::PhotonContainer > m_offPhotonKey
Definition: TrigEgammaEmulationToolTest.h:56
xAOD::EventInfo_v1::LAr
@ LAr
The LAr calorimeter.
Definition: EventInfo_v1.h:335
TrigEgammaEmulationToolTest::m_emulatorTool
ToolHandle< Trig::TrigEgammaEmulationToolMT > m_emulatorTool
Definition: TrigEgammaEmulationToolTest.h:50
xAOD::EventInfo_v1::Error
@ Error
The sub-detector issued an error.
Definition: EventInfo_v1.h:349
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:36
TrigEgammaEmulationToolTest::initialize
virtual StatusCode initialize() override
Athena algorithm's Hooks.
Definition: TrigEgammaEmulationToolTest.cxx:28
calibdata.valid
list valid
Definition: calibdata.py:45
PixelAthClusterMonAlgCfg.histname
histname
Definition: PixelAthClusterMonAlgCfg.py:106
TrigEgammaEmulationToolTest::TrigInfo
Definition: TrigEgammaEmulationToolTest.h:22
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
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigEgammaEmulationToolTest::fillHistograms
virtual StatusCode fillHistograms(const EventContext &ctx) const override
adds event to the monitoring histograms
Definition: TrigEgammaEmulationToolTest.cxx:55
AthMonitorAlgorithm::fill
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.
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
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
DataVector
Derived DataVector<T>.
Definition: DataVector.h:794
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TrigEgammaEmulationToolTest::~TrigEgammaEmulationToolTest
virtual ~TrigEgammaEmulationToolTest()
Destructor:
Definition: TrigEgammaEmulationToolTest.cxx:24
TrigEgammaEmulationToolTest::fillLabel
void fillLabel(const ToolHandle< GenericMonitoringTool > &groupHandle, const std::string &histname, const std::string &label) const
Definition: TrigEgammaEmulationToolTest.cxx:287
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:18
TrigEgammaEmulationToolTest::setAccept
asg::AcceptData setAccept(const TrigCompositeUtils::Decision *dec, const TrigEgammaEmulationToolTest::TrigInfo &info) const
Definition: TrigEgammaEmulationToolTest.cxx:163
asg::AcceptData::setCutResult
void setCutResult(const std::string &cutName, bool cutResult)
Set the result of a cut, based on the cut name (safer)
Definition: AcceptData.h:134
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
TrigRoiDescriptorCollection
Definition: TrigRoiDescriptorCollection.h:21
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TrigEgammaEmulationToolTest.h
plotBeamSpotMon.mon
mon
Definition: plotBeamSpotMon.py:67
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
TrigEgammaEmulationToolTest::TrigEgammaEmulationToolTest
TrigEgammaEmulationToolTest(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Definition: TrigEgammaEmulationToolTest.cxx:14
TrigEgammaEmulationToolTest::m_accept
asg::AcceptInfo m_accept
Definition: TrigEgammaEmulationToolTest.h:46
Monitored::Scalar
Declare a monitored scalar variable.
Definition: MonitoredScalar.h:34
asg::AcceptData
Definition: AcceptData.h:30
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
AthMonitorAlgorithm::getGroup
const ToolHandle< GenericMonitoringTool > & getGroup(const std::string &name) const
Get a specific monitoring tool from the tool handle array.
Definition: AthMonitorAlgorithm.cxx:164
asg::AcceptInfo::addCut
int addCut(const std::string &cutName, const std::string &cutDescription)
Add a cut; returning the cut position.
Definition: AcceptInfo.h:53
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37