ATLAS Offline Software
Loading...
Searching...
No Matches
TrigIDR4Mon.cxx
Go to the documentation of this file.
1
11
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
27TrigIDR4Mon::TrigIDR4Mon( const std::string & name, ISvcLocator* pSvcLocator)
28 : AthMonitorAlgorithm(name, pSvcLocator),
29 m_tdt("Trig::TrigDecisionTool/TrigDecisionTool"),
30 m_buildNtuple(false),
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),
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
198 ToolHandleArray<GenericMonitoringTool>::iterator toolitr = m_monTools.begin();;
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
271 m_chainNames = chains;
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() {
287StatusCode 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
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
emacs: this is -* c++ -*-
emacs: this is -*- c++ -*-
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const std::string & extra() const
Definition ChainString.h:38
const std::string & roi() const
Definition ChainString.h:35
std::string subs(std::string s) const
const std::string & raw() const
Definition ChainString.h:42
const std::string & head() const
Definition ChainString.h:33
const std::string & tail() const
Definition ChainString.h:34
const std::string & vtx() const
Definition ChainString.h:36
const std::string & element() const
Definition ChainString.h:37
int m_sctHolesOffline
Definition TrigIDR4Mon.h:86
double m_etaCutOffline
Definition TrigIDR4Mon.h:75
ToolHandle< Trig::TrigDecisionTool > m_tdt
Definition TrigIDR4Mon.h:96
double m_fiducial_radius
ntuple building variables
int m_trtHitsOffline
Definition TrigIDR4Mon.h:89
ToolHandleArray< GenericMonitoringTool > m_monTools
int m_vtxIndex
if performing the vertex analysis, the index of the offline vertex to look for
bool m_requireDecision
int m_selectParentTruthPdgId
int m_blayerHitsOffline
Definition TrigIDR4Mon.h:83
SG::ReadHandleKeyArray< xAOD::VertexContainer > m_vtxdummykeys
int m_siHitsOffline
Definition TrigIDR4Mon.h:80
SG::ReadHandleKeyArray< xAOD::TrackParticleContainer > m_trackdummykeys
std::string m_releaseMetaData
virtual StatusCode fillHistograms(const EventContext &context) const override
adds event to the monitoring histograms
bool m_buildNtuple
double m_z0Cut
Definition TrigIDR4Mon.h:62
std::string m_analysis_config
std::string m_sliceTag
additional string for the histogram directory
virtual ~TrigIDR4Mon()
double m_pTCut
Definition TrigIDR4Mon.h:59
bool m_fileopen
if an ntple file open?
double m_pTCutOffline
Definition TrigIDR4Mon.h:74
bool m_initialisePerRun
virtual StatusCode bookHistograms()
int m_pixHitsOffline
Definition TrigIDR4Mon.h:81
double m_mind0CutOffline
Definition TrigIDR4Mon.h:77
double m_tauEtCutOffline
Definition TrigIDR4Mon.h:72
std::string m_outputFileName
bool m_filter_on_roi
std::vector< std::string > m_chainNames
do we need this ??? why not the base class ???
bool m_shifter
determine whether this should be treated as a shifter chain
int m_selectTruthPdgId
std::vector< std::string > m_ntupleChainNames
double m_z0CutOffline
Definition TrigIDR4Mon.h:78
double m_doTauThreeProng
Definition TrigIDR4Mon.h:73
int m_siHolesOffline
Definition TrigIDR4Mon.h:87
virtual StatusCode finalize() override
virtual StatusCode initialize() override
initialize
double m_matchR
Definition TrigIDR4Mon.h:93
bool m_runPurity
also run purity analyses
bool m_genericFlag
double m_d0CutOffline
Definition TrigIDR4Mon.h:76
bool m_keepAllEvents
kepp events even if they fail the requested trigger chains
int m_pixHolesOffline
Definition TrigIDR4Mon.h:85
bool m_containTracks
do we want basic, or rigorous roi track containment
double m_matchPhi
Definition TrigIDR4Mon.h:94
TrigIDR4Mon(const std::string &name, ISvcLocator *pSvcLocator)
int m_strawHitsOffline
Definition TrigIDR4Mon.h:90
double m_etaCut
Definition TrigIDR4Mon.h:60
bool m_useHighestPT
use only the highest pt tracks
double m_d0Cut
Definition TrigIDR4Mon.h:61
int m_sctHitsOffline
Definition TrigIDR4Mon.h:82
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
std::vector< std::string > getListOfTriggers() const