ATLAS Offline Software
TrigIDR4Mon.cxx
Go to the documentation of this file.
1 
12 // #include "TrigInDetAnalysis/Filter_AcceptAll.h"
13 
14 // #include "TrigInDetAnalysisUtils/Filters.h"
15 // #include "TrigInDetAnalysisUtils/Filter_Track.h"
16 // #include "TrigInDetAnalysisUtils/TagNProbe.h"
17 
22 
23 #include "TrigIDR4Mon.h"
24 
25 // #include <mutex>
26 
27 TrigIDR4Mon::TrigIDR4Mon( const std::string & name, ISvcLocator* pSvcLocator)
28  : AthMonitorAlgorithm(name, pSvcLocator),
29  m_tdt("Trig::TrigDecisionTool/TrigDecisionTool"),
30  m_buildNtuple(false),
31  m_initialisePerRun(true),
32  m_firstRun(true),
33  m_keepAllEvents(false),
34  m_fileopen(false),
35  m_useHighestPT(false),
36  m_vtxIndex(-1),
37  m_runPurity(false),
38  m_shifter(false),
39  m_sliceTag(""),
40  m_containTracks(false),
41  m_legacy(true),
42  m_fiducial_radius(32),
43  m_requireDecision(false),
44  m_filter_on_roi(false)
45 {
46  msg(MSG::INFO) << "TrigIDR4Mon::TrigIDR4Mon() compiled: " << __DATE__ << " " << __TIME__ << endmsg;
47 
48  declareProperty( "SliceTag", m_sliceTag = "" );
49 
50  declareProperty( "pTCut", m_pTCut = 0 );
51  declareProperty( "etaCut", m_etaCut = 5 );
52  declareProperty( "d0Cut", m_d0Cut = 1000 );
53  declareProperty( "z0Cut", m_z0Cut = 2000 );
54  declareProperty( "siHits", m_siHits = -1 );
55  m_pixHits=0;
56  m_sctHits=0;
57 
58  declareProperty( "trtHits", m_trtHits = -2 );
59  declareProperty( "strawHits", m_strawHits = -2 );
60 
61  declareProperty( "tauEtCutOffline", m_tauEtCutOffline = 0 );
62  declareProperty( "doTauThreeProng", m_doTauThreeProng = false);
63 
64  declareProperty( "pTCutOffline", m_pTCutOffline = 1000 );
65  declareProperty( "etaCutOffline", m_etaCutOffline = 2.5 );
66  declareProperty( "d0CutOffline", m_d0CutOffline = 1000 );
67  declareProperty( "mind0CutOffline", m_mind0CutOffline = 0 );
68  declareProperty( "z0CutOffline", m_z0CutOffline = 2000 );
69  declareProperty( "pixHitsOffline", m_pixHitsOffline = 2 ); // 1 <- old value ( 2 degrees of freedom = 1 cluster )
70  declareProperty( "sctHitsOffline", m_sctHitsOffline = 6 ); // 6 <- old value ( 6 clusters = 3 spacepoints )
71  declareProperty( "siHitsOffline", m_siHitsOffline = 8 );
72  declareProperty( "blayerHitsOffline", m_blayerHitsOffline = -1 ); // no requirement - in case IBL is off
73 
74  declareProperty( "pixHolesOffline", m_pixHolesOffline = 20 ); // essentially no limit
75  declareProperty( "sctHolesOffline", m_sctHolesOffline = 20 ); // essentially no limit
76  declareProperty( "siHolesOffline", m_siHolesOffline = 2 ); // npix holes + nsi holes <= 2 ( not degrees of freedom ! )
77 
78  declareProperty( "ContainTracks", m_containTracks = false ); // use only basic track containment
79  declareProperty( "FiducialRadius", m_fiducial_radius = 32 );
80 
81  declareProperty( "trtHitsOffline", m_trtHitsOffline = -2 );
82  declareProperty( "strawHitsOffline", m_strawHitsOffline = -2 );
83 
84  declareProperty( "matchR", m_matchR = 0.1 );
85  declareProperty( "matchPhi", m_matchPhi = 0.1 );
86 
87  declareProperty( "ntupleChainNames", m_ntupleChainNames );
88  declareProperty( "releaseMetaData", m_releaseMetaData );
89 
90  declareProperty( "buildNtuple", m_buildNtuple = false );
91 
92  declareProperty( "AnalysisConfig", m_analysis_config = "Ntuple");
93 
94  declareProperty( "SelectTruthPdgId", m_selectTruthPdgId = 0 );
95  declareProperty( "SelectParentTruthPdgId", m_selectParentTruthPdgId = 0 );
96 
97  declareProperty( "InitialisePerRun", m_initialisePerRun = false );
98  declareProperty( "KeepAllEvents", m_keepAllEvents = false );
99  declareProperty( "UseHighestPT", m_useHighestPT = false );
100  declareProperty( "VtxIndex", m_vtxIndex = -1 );
101 
102  declareProperty( "RunPurity", m_runPurity = false );
103  declareProperty( "Shifter", m_shifter = false );
104 
105  declareProperty( "GenericFlag", m_genericFlag = true );
106 
107  declareProperty( "Legacy", m_legacy = true );
108 
109  declareProperty( "outputFileName", m_outputFileName = "TrkNtuple.root" );
110 
111  declareProperty( "RequireDecision", m_requireDecision = false );
112 
113  declareProperty( "FilterOnRoi", m_filter_on_roi = false );
114 
115  msg(MSG::INFO) << "TrigIDR4Mon::TrigIDR4Mon() exiting " << gDirectory->GetName() << endmsg;
116 
117 }
118 
119 
120 
122 
123  // if ( m_fileopen ) {
124  // for ( unsigned i=0 ; i<m_sequences.size() ; i++ ) m_sequences[i]->finalize();
125  // for ( unsigned i=0 ; i<m_sequences.size() ; i++ ) delete m_sequences[i];
126  // m_fileopen = false;
127  // }
128 
129 }
130 
131 
132 
134 
135  msg(MSG::DEBUG) << " ----- enter initialize() ----- " << endmsg;
136 
137  msg(MSG::INFO) << "TrigIDR4Mon::initialize() " << gDirectory->GetName() << " " << m_sliceTag << endmsg;
138 
142 
143 #if 0
144  std::cout << "TrigIDR4Mon::name = " << name() << std::endl;
145  std::cout << "TrigIDR4Mon::SliceTag = " << m_sliceTag << std::endl;
146  std::cout << "TrigIDR4Mon::AnalysisConfig = " << m_analysis_config << std::endl;
147  std::cout << "TrigIDR4Mon::Legacy = " << m_legacy << std::endl;
148 #endif
149 
150  ATH_CHECK(m_monTools.retrieve());
151 
153 
158 
159  ATH_CHECK (m_trackdummykeys.initialize());
160  ATH_CHECK (m_vtxdummykeys.initialize());
161 
162  ATH_MSG_DEBUG( " ----- exit init() ----- " );
163 
165 
166 }
167 
168 
170 
171  ATH_MSG_DEBUG( " ----- enter book() ----- " );
172 
173  ATH_MSG_INFO( " TrigIDR4Mon::book() " << gDirectory->GetName() );
174 
176  // "^[[91;1m"
177  // "^[[m"
178 
179  ATH_MSG_INFO( "^[[91;1m" << name() << "\t:AnalysisConfig " << m_analysis_config << "^[[m" );
180 
181  ATH_MSG_INFO( "configuring chains: " << m_ntupleChainNames.size() << "\tmonTools: " << m_monTools.size() );
182 
183  std::string lastvtx = "";
184 
187 
188  std::vector<std::string> chains;
189 
190  chains.reserve( m_monTools.size() );
191 
194 
195  std::vector<ToolHandle<GenericMonitoringTool>*> monTools;
196  monTools.reserve(m_monTools.size());
197 
199 
200 
201  // sort out all the chain stuff
202 
203  while ( toolitr!=m_monTools.end() ) {
204 
206  ChainString chainName = (toolitr->name());
207 
208  ATH_MSG_INFO( "configuring chain: " << chainName.head() << "\t: " << chainName.tail() );
209 
211 
212  if ( chainName.head() == "" ) {
213 
214  std::string selectChain = chainName.raw();
215 
217 
219  // toolitr->setPath( m_sliceTag+"/"+chainName );
220 
221  if (std::find(chains.begin(), chains.end(), selectChain) == chains.end()) { // deduplicate
222  chains.push_back( selectChain );
223  monTools.push_back( &(*toolitr) );
224  }
225  }
226  else {
227 
229 
230  if ( chainName.head().find("HLT_")==std::string::npos ) {
231  // with the O2 optimisation that ATLAS uses, unevaluated pre- and postfix operators produce identical code - I prefer the postfix
232  //cppcheck-suppress postfixOperator
233  toolitr++;
234  continue;
235  }
236 
238 
239  std::string selectChain = chainName.head();
240 
242 
243  ATH_MSG_DEBUG( "checking chain: " << chainName.head() );
244 
245  if ( selectChain=="" ) {
246  msg(MSG::WARNING) << "^[[91;1m" << "No chain matched\tchain input " << chainName.head() << " : " << chainName.tail() << "^[[m"<< endmsg;
247  ++toolitr;
248  continue;
249  }
250 
251  std::string mchain = selectChain; //chainName.head();
252 
253  if ( chainName.tail()!="" ) mchain += "/"+chainName.tail();
254  if ( chainName.roi()!="" ) mchain += "_"+chainName.roi();
255  if ( chainName.vtx()!="" ) mchain += "_"+chainName.vtx();
256  if ( chainName.element()!="" ) mchain += "_"+chainName.element();
257  if ( chainName.extra()!="" ) mchain += "_"+chainName.extra();
258 
259  selectChain = chainName.subs( selectChain );
260 
261  if ( std::find(chains.begin(), chains.end(), selectChain) == chains.end() ) { // deduplicate
262  chains.push_back( selectChain );
263  monTools.push_back( &(*toolitr) );
264  }
265 
266  ++toolitr;
267  }
268 
269  }
270 
272 
273 
274  // ATH_MSG_DEBUG( " configured " << m_sequences.size() << " sequences" );
275 
276  ATH_MSG_DEBUG( " ----- exit book() ----- " );
277 
278  return StatusCode::SUCCESS;
279 
280 }
281 
282 
283 
284 
285 
286 //StatusCode TrigIDR4Mon::execute() {
287 StatusCode TrigIDR4Mon::fillHistograms(const EventContext &/*context*/) const {
288 
289  ATH_MSG_DEBUG( " ----- enter fill() ----- " );
290 
291  const Trig::ChainGroup* chainGroup = m_tdt->getChainGroup( "HLT_e.*" );
292  const std::vector<std::string> selectChains = chainGroup->getListOfTriggers();
293 
295  static std::once_flag flag;
296  std::call_once(flag, [&]() {
297  for ( unsigned i=0 ; i<selectChains.size() ; i++ ) {
298  ATH_MSG_DEBUG( "\tchain " << selectChains[i] << " from TDT" );
299  }
300 
301  for ( size_t i=selectChains.size() ; i-- ; ) {
302  if ( i>5 ) i=5;
303  ATH_MSG_INFO( "^[[91;1m" << "configured chain " << selectChains[i] << "^[[m" );
304  }
305  });
306 
307  if (msgLvl(MSG::DEBUG)) {
308  const std::vector<bool> isPassed = chainGroup->isPassedForEach();
309  for ( unsigned i=0 ; i<selectChains.size() ; i++ ) {
310  if ( isPassed[i] ) {
311  ATH_MSG_DEBUG( "chain " << selectChains[i] << "\tpass: " << isPassed[i] << "\tprescale: " << m_tdt->getPrescale(selectChains[i]) );
312  }
313  }
314  }
315 
316  // for ( unsigned i=0 ; i<m_sequences.size() ; i++ ) {
317  // m_sequences[i]->execute();
318  // }
319 
320  ATH_MSG_DEBUG(" ----- exit fill() ----- ");
321 
322  return StatusCode::SUCCESS;
323 }
324 
325 
326 
327 
328 
329 // bool newEventsBlock, bool newLumiBlock, bool newRun are protected varibales
330 // correctly set before this is called
332 
333  ATH_MSG_DEBUG( " ====== enter proc() ====== " );
334 
335 
336  ATH_MSG_DEBUG( " ====== exit proc() ====== " );
337 
338  return StatusCode::SUCCESS;
339 }
340 
341 
342 
343 
344 
345 
346 
347 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
testMuonHLTphase2.selectChains
selectChains
Definition: testMuonHLTphase2.py:47
TrigIDR4Mon::finalize
virtual StatusCode finalize() override
TrigIDR4Mon::m_ntupleChainNames
std::vector< std::string > m_ntupleChainNames
Definition: TrigIDR4Mon.h:105
TrigIDR4Mon::m_outputFileName
std::string m_outputFileName
Definition: TrigIDR4Mon.h:111
TrigIDR4Mon::m_blayerHitsOffline
int m_blayerHitsOffline
Definition: TrigIDR4Mon.h:83
TrigIDR4Mon::m_d0Cut
double m_d0Cut
Definition: TrigIDR4Mon.h:61
TrigIDR4Mon::m_selectParentTruthPdgId
int m_selectParentTruthPdgId
Definition: TrigIDR4Mon.h:121
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:138
TrigIDR4Mon::m_etaCut
double m_etaCut
Definition: TrigIDR4Mon.h:60
TrigIDR4Mon::fillHistograms
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
TrigIDR4Mon::m_sctHits
int m_sctHits
Definition: TrigIDR4Mon.h:66
TrigIDR4Mon::m_sctHolesOffline
int m_sctHolesOffline
Definition: TrigIDR4Mon.h:86
TrigIDR4Mon::m_analysis_config
std::string m_analysis_config
Definition: TrigIDR4Mon.h:110
AthCommonMsg< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
TrigIDR4Mon::m_releaseMetaData
std::string m_releaseMetaData
Definition: TrigIDR4Mon.h:106
TrigDecisionTool.h
TrigIDR4Mon::m_z0CutOffline
double m_z0CutOffline
Definition: TrigIDR4Mon.h:78
ChainString
Definition: ChainString.h:23
ChainGroup.h
TrigIDR4Mon::m_pTCutOffline
double m_pTCutOffline
Definition: TrigIDR4Mon.h:74
TrigIDR4Mon::m_pTCut
double m_pTCut
Definition: TrigIDR4Mon.h:59
TrigIDR4Mon::m_chainNames
std::vector< std::string > m_chainNames
do we need this ??? why not the base class ???
Definition: TrigIDR4Mon.h:104
TrigIDR4Mon::m_filter_on_roi
bool m_filter_on_roi
Definition: TrigIDR4Mon.h:156
AthMonitorAlgorithm
Base class for Athena Monitoring Algorithms.
Definition: AthMonitorAlgorithm.h:39
TrigIDR4Mon::m_trtHitsOffline
int m_trtHitsOffline
Definition: TrigIDR4Mon.h:89
TrigIDR4Mon::m_etaCutOffline
double m_etaCutOffline
Definition: TrigIDR4Mon.h:75
TrigIDR4Mon::m_strawHits
int m_strawHits
Definition: TrigIDR4Mon.h:69
TrigIDR4Mon::m_siHitsOffline
int m_siHitsOffline
Definition: TrigIDR4Mon.h:80
TrigIDR4Mon::m_siHits
int m_siHits
Definition: TrigIDR4Mon.h:64
TrigIDR4Mon::m_pixHits
int m_pixHits
Definition: TrigIDR4Mon.h:65
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
lumiFormat.i
int i
Definition: lumiFormat.py:85
TrigIDR4Mon::TrigIDR4Mon
TrigIDR4Mon(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TrigIDR4Mon.cxx:27
TrigIDR4Mon::m_sctHitsOffline
int m_sctHitsOffline
Definition: TrigIDR4Mon.h:82
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
TrigIDR4Mon::m_buildNtuple
bool m_buildNtuple
Definition: TrigIDR4Mon.h:108
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
TrigIDR4Mon::m_vtxIndex
int m_vtxIndex
if performing the vertex analysis, the index of the offline vertex to look for
Definition: TrigIDR4Mon.h:134
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition: AthCommonDataStore.h:145
master.flag
bool flag
Definition: master.py:29
TrigIDR4Mon::m_keepAllEvents
bool m_keepAllEvents
kepp events even if they fail the requested trigger chains
Definition: TrigIDR4Mon.h:124
TrigIDR4Mon::m_fiducial_radius
double m_fiducial_radius
ntuple building variables
Definition: TrigIDR4Mon.h:152
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TrigIDR4Mon::m_trackdummykeys
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_trackdummykeys
Definition: TrigIDR4Mon.h:160
TrigIDR4Mon::m_initialisePerRun
bool m_initialisePerRun
Definition: TrigIDR4Mon.h:115
TrigIDR4Mon::m_matchR
double m_matchR
Definition: TrigIDR4Mon.h:93
TrigIDR4Mon::m_doTauThreeProng
double m_doTauThreeProng
Definition: TrigIDR4Mon.h:73
TrigIDR4Mon::m_containTracks
bool m_containTracks
do we want basic, or rigorous roi track containment
Definition: TrigIDR4Mon.h:146
Trig::ChainGroup
Definition: ChainGroup.h:51
TrigIDR4Mon::m_tdt
ToolHandle< Trig::TrigDecisionTool > m_tdt
Definition: TrigIDR4Mon.h:96
TrigIDR4Mon::m_shifter
bool m_shifter
determine whether this should be treated as a shifter chain
Definition: TrigIDR4Mon.h:140
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
ChainString.h
TrigIDR4Mon::m_tauEtCutOffline
double m_tauEtCutOffline
Definition: TrigIDR4Mon.h:72
TrigIDR4Mon::m_strawHitsOffline
int m_strawHitsOffline
Definition: TrigIDR4Mon.h:90
TrigIDR4Mon.h
emacs: this is -*- c++ -*-
TrigIDR4Mon::m_vtxdummykeys
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_vtxdummykeys
Definition: TrigIDR4Mon.h:162
AthMonitorAlgorithm::initialize
virtual StatusCode initialize() override
initialize
Definition: AthMonitorAlgorithm.cxx:22
TrigIDR4Mon::m_trtHits
int m_trtHits
Definition: TrigIDR4Mon.h:68
python.copyTCTOutput.chains
chains
Definition: copyTCTOutput.py:78
TrigIDR4Mon::m_requireDecision
bool m_requireDecision
Definition: TrigIDR4Mon.h:154
TrigIDR4Mon::m_genericFlag
bool m_genericFlag
Definition: TrigIDR4Mon.h:113
TrigIDR4Mon::bookHistograms
virtual StatusCode bookHistograms()
Definition: TrigIDR4Mon.cxx:169
TrigIDR4Mon::m_pixHolesOffline
int m_pixHolesOffline
Definition: TrigIDR4Mon.h:85
TrigIDR4Mon::m_sliceTag
std::string m_sliceTag
additional string for the histogram directory
Definition: TrigIDR4Mon.h:143
TrigIDR4Mon::m_z0Cut
double m_z0Cut
Definition: TrigIDR4Mon.h:62
TrigIDR4Mon::m_pixHitsOffline
int m_pixHitsOffline
Definition: TrigIDR4Mon.h:81
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
TrigIDR4Mon::m_runPurity
bool m_runPurity
also run purity analyses
Definition: TrigIDR4Mon.h:137
Trig::ChainGroup::isPassedForEach
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
Definition: ChainGroup.cxx:193
DEBUG
#define DEBUG
Definition: page_access.h:11
python.TriggerAPI.TriggerAPISession.chainName
chainName
Definition: TriggerAPISession.py:426
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
TrigIDR4Mon::m_selectTruthPdgId
int m_selectTruthPdgId
Definition: TrigIDR4Mon.h:119
TrigIDR4Mon::m_monTools
ToolHandleArray< GenericMonitoringTool > m_monTools
Definition: TrigIDR4Mon.h:158
TrigIDR4Mon::m_matchPhi
double m_matchPhi
Definition: TrigIDR4Mon.h:94
TrigIDR4Mon::m_mind0CutOffline
double m_mind0CutOffline
Definition: TrigIDR4Mon.h:77
TrigIDR4Mon::~TrigIDR4Mon
virtual ~TrigIDR4Mon()
Definition: TrigIDR4Mon.cxx:121
TrigIDR4Mon::m_legacy
bool m_legacy
Definition: TrigIDR4Mon.h:148
Trig::ChainGroup::getListOfTriggers
std::vector< std::string > getListOfTriggers() const
Definition: ChainGroup.cxx:467
TrigIDR4Mon::initialize
virtual StatusCode initialize() override
initialize
Definition: TrigIDR4Mon.cxx:133
TrigIDR4Mon::m_siHolesOffline
int m_siHolesOffline
Definition: TrigIDR4Mon.h:87
TIDAHistogram.h
emacs: this is -* c++ -*-
TrigIDR4Mon::m_useHighestPT
bool m_useHighestPT
use only the highest pt tracks
Definition: TrigIDR4Mon.h:130
TrigIDR4Mon::m_d0CutOffline
double m_d0CutOffline
Definition: TrigIDR4Mon.h:76