ATLAS Offline Software
StreamAuditorTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // StreamAuditorTool.cxx, (c) ATLAS Detector software
8 // Author: James Catmore (James.Catmore@cern.ch)
9 // Part of the DerivationFramework
10 // This tool keeps count of event selections in each stream, and provides
11 // a summary of overall counts and overlaps at the end. Tool must be
12 // passed to each instance of the derivation kernel
13 
15 #include <vector>
16 #include <string>
17 
18 
19 // Constructor
21  const std::string& n,
22  const IInterface* p ) :
23  AthAlgTool(t,n,p),
24  m_incidentSvc("IncidentSvc",n)
25  //m_algNames,
26  //m_algCounts,
27  //m_overlapCounts,
28  {
29  declareInterface<DerivationFramework::StreamAuditorTool>(this);
30  }
31 
32 // Destructor
34 }
35 
36 // Athena initialize and finalize
38 {
39  ATH_MSG_VERBOSE("initialize() ...");
40  // Get the incident service (so the tool knows when the end of an event is encountered)
41  if (m_incidentSvc.retrieve().isFailure()) {
42  ATH_MSG_FATAL("Could not retrieve IncidentService '" << m_incidentSvc << "'. Exiting.");
43  return StatusCode::FAILURE;
44  }
45  // register to the incident service: BeginEvent for TrackRecordCollection
46  m_incidentSvc->addListener( this, IncidentType::EndEvent);
47  m_totalEvents=0;
48 
49  return StatusCode::SUCCESS;
50 }
51 
53 {
54  ATH_MSG_INFO( "========================================================");
55  ATH_MSG_INFO( "|| SUMMARY OF THE DERIVATION FRAMEWORK STREAM AUDITOR ||");
56  ATH_MSG_INFO( "========================================================");
57  ATH_MSG_INFO( "Total number of events processed: " << m_totalEvents);
58  std::map<std::pair<std::string,std::string> , unsigned int>::iterator mapItr;
59  ATH_MSG_INFO( "Stream event overlaps follow:");
60  for (mapItr=m_overlapMap.begin(); mapItr!=m_overlapMap.end(); ++mapItr) {
61  ATH_MSG_INFO( ((*mapItr).first).first << " " << ((*mapItr).first).second << " " << (*mapItr).second);
62  }
63  ATH_MSG_INFO( "========================================================");
64  return StatusCode::SUCCESS;
65 }
66 
67 // Called by each instance of the kernel
69 {
70  // Build the name list
71  m_algNames[name]=0;
72 
73  // Build the overlap table
76  for (mapItrOuter=m_algNames.begin(); mapItrOuter!=m_algNames.end(); ++mapItrOuter) {
77  for (mapItrInner=mapItrOuter; mapItrInner!=m_algNames.end(); ++mapItrInner) {
78  std::pair<std::string,std::string> tmpPair;
79  tmpPair = std::make_pair( (*mapItrOuter).first, (*mapItrInner).first);
80  m_overlapMap[tmpPair]=0;
81  }
82  }
83 
84  return;
85 }
86 
87 // Called by kernel whenever an event is accepted
89 {
91  mapItr = m_algNames.find(name);
92  (*mapItr).second += 1;
93 
94  return;
95 }
96 
97 // framework handle - called whenever end-of-event incident encountered
99 
100  // check the incident type
101  if ( inc.type() == IncidentType::EndEvent ) {
102 
103  // Run if end of event
104  ++m_totalEvents;
107  std::map<std::pair<std::string,std::string> , unsigned int>::iterator olItr;
108  for (mapItrOuter=m_algNames.begin(); mapItrOuter!=m_algNames.end(); ++mapItrOuter) {
109  std::string outerString = (*mapItrOuter).first;
110  unsigned int outerCount = (*mapItrOuter).second;
111  for (mapItrInner=mapItrOuter; mapItrInner!=m_algNames.end(); ++mapItrInner) {
112  std::string innerString = (*mapItrInner).first;
113  unsigned int innerCount = (*mapItrInner).second;
114  for (olItr=m_overlapMap.begin(); olItr!=m_overlapMap.end(); ++olItr) {
115  if ( (((*olItr).first).first==outerString) && (((*olItr).first).second==innerString) && (innerCount==1 && outerCount==1) ) {
116  (*olItr).second += 1;
117  break;
118  }
119  }
120  }
121  }
123  for (mapItr=m_algNames.begin(); mapItr!=m_algNames.end(); ++mapItr) {
124  (*mapItr).second = 0;
125  }
126  }
127 
128  return;
129 }
130 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
DerivationFramework::StreamAuditorTool::eventAccepted
void eventAccepted(const std::string &)
Definition: StreamAuditorTool.cxx:88
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
DerivationFramework::StreamAuditorTool::~StreamAuditorTool
~StreamAuditorTool()
Destructor.
Definition: StreamAuditorTool.cxx:33
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
DerivationFramework::StreamAuditorTool::handle
void handle(const Incident &inc)
Definition: StreamAuditorTool.cxx:98
DerivationFramework::StreamAuditorTool::initialize
StatusCode initialize()
Definition: StreamAuditorTool.cxx:37
DerivationFramework::StreamAuditorTool::finalize
StatusCode finalize()
Definition: StreamAuditorTool.cxx:52
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
StreamAuditorTool.h
DerivationFramework::StreamAuditorTool::registerAlgorithmName
void registerAlgorithmName(const std::string &)
Register name of an algorithm.
Definition: StreamAuditorTool.cxx:68
DerivationFramework::StreamAuditorTool::StreamAuditorTool
StreamAuditorTool(const std::string &t, const std::string &n, const IInterface *p)
Constructor with parameters.
Definition: StreamAuditorTool.cxx:20
AthAlgTool
Definition: AthAlgTool.h:26