ATLAS Offline Software
DQTDataFlowMonTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // ********************************************************************
6 //
7 // NAME: DQTDataFlowMonTool.cxx
8 // PACKAGE: DataQualityTools
9 //
10 // AUTHORS: Peter Onyisi (ponyisi@cern.ch)
11 //
12 //
13 // ********************************************************************
14 
16 
17 #include "TGraph.h"
18 
19 #include "GaudiKernel/MsgStream.h"
20 #include "GaudiKernel/ITHistSvc.h"
21 #include "StoreGate/ReadHandle.h"
22 
23 static const char* const envstrings[AthenaMonManager::altprod+1] = { "user", "noOutput", "online", "tier0",
24  "tier0Raw", "tier0ESD", "AOD", "altprod" };
25 static const char* const eventflagdets[] = { "Pixel", "SCT", "TRT",
26  "LAr", "Tile", "Muon",
27  "ForwardDet", "Core",
28  "Background", "Lumi"};
29 
30 using xAOD::EventInfo;
31 
32 //----------------------------------------------------------------------------------
34  const std::string & name,
35  const IInterface* parent)
37  m_releaseString(""),
38  m_releaseStageString(""),
39  m_events_lb(0),
40  m_release_stage_lowStat(0),
41  // m_eventflag_summary_lowStat(0),
42  // m_eventflag_summary_lb(0),
43  m_sumweights(0)
44 //----------------------------------------------------------------------------------
45 {
46  declareInterface<IMonitorToolBase>(this);
47  m_path = "GLOBAL/DQTDataFlow";
48  declareProperty("releaseString", m_releaseString);
49 
50  /*
51  for (int i=0; i < EventInfo::nDets; i++) {
52  m_eventflag_run[i] = 0;
53  m_eventflag_vec[i] = 0;
54  }
55  */
56 }
57 
58 //----------------------------------------------------------------------------------
60 //----------------------------------------------------------------------------------
61 {
62  /*
63  for (int i=0; i < EventInfo::nDets; i++) {
64  delete m_eventflag_vec[i];
65  m_eventflag_vec[i] = 0;
66  }
67  */
68 }
69 
70 //----------------------------------------------------------------------------------
72 //----------------------------------------------------------------------------------
73 {
76 }
77 
78 //----------------------------------------------------------------------------------
80 //----------------------------------------------------------------------------------
81 {
82  const EventContext& ctx = Gaudi::Hive::currentContext();
83  bool failure(false);
84 
85  if (m_releaseStageString == "") {
87  }
88 
89  ATH_MSG_DEBUG("in bookHistograms()");
90  ATH_MSG_DEBUG("Using base path " << m_path);
91 
92  MonGroup lb_hists( this, m_path, lumiBlock, ATTRIB_MANAGED );
93  MonGroup lowStat_alpha_hists( this, m_path, lowStat, ATTRIB_MANAGED );
94  MonGroup run_hists( this, m_path, run, ATTRIB_MANAGED );
95  MonGroup rolling_hists( this, m_path, run, ATTRIB_X_VS_LB, "", "merge" );
96 
97  //failure |= lb_hists.regHist(m_events_lb = TH1I_LW::create("events_lb", "Event Count", AthenaMonManager::altprod+1, -0.5, AthenaMonManager::altprod+0.5)).isFailure();
98  failure |= lb_hists.regHist(m_events_lb = new TH1I("events_lb", "Event Count", AthenaMonManager::altprod+1, -0.5, AthenaMonManager::altprod+0.5)).isFailure();
99 
100  if (m_events_lb) {
101  for (int i = 1; i <= AthenaMonManager::altprod+1; i++) {
102  m_events_lb->GetXaxis()->SetBinLabel(i, envstrings[i-1]);
103  }
104  }
105  //failure |= lowStat_alpha_hists.regHist(m_release_stage_lowStat = TH1I_LW::create("m_release_stage_lowStat", "Release - Event Count", AthenaMonManager::altprod+1, -0.5, AthenaMonManager::altprod+0.5)).isFailure();
106  failure |= lowStat_alpha_hists.regHist(m_release_stage_lowStat = new TH1I("m_release_stage_lowStat", "Release - Event Count", AthenaMonManager::altprod+1, -0.5, AthenaMonManager::altprod+0.5)).isFailure();
108  m_release_stage_lowStat->GetXaxis()->SetBinLabel(m_environment+1, m_releaseStageString.c_str());
109  }
110 
113  failure |= rolling_hists.regHist(m_sumweights = new TH1D("m_sumweights", "Sum of MC event weights", 50, 0.5, 50.5)).isFailure();
114  }
115 
116  if (failure) {return StatusCode::FAILURE;}
117  else {return StatusCode::SUCCESS;}
118 
119 }
120 
121 StatusCode
123 
124  bool failure(false);
125  MonGroup lowStat_hists( this, m_path, lowStat, ATTRIB_UNMANAGED );
126  MonGroup run_hists( this, m_path, run, ATTRIB_UNMANAGED );
127 
129  /*
130  if (newRunFlag()) {
131  for (int i=0; i < EventInfo::nDets; i++) {
132  m_eventflag_run[i] = new TGraph();
133  m_eventflag_run[i]->SetTitle((std::string("Nonzero Warning/Error Event Flags for ")
134  + eventflagdets[i]).c_str());
135  m_eventflag_run[i]->SetName((std::string("eventflag_run_")
136  + eventflagdets[i]).c_str());
137  failure |= run_hists.regGraph(m_eventflag_run[i]).isFailure();
138  delete m_eventflag_vec[i];
139  m_eventflag_vec[i] = new std::vector<EvFlagPt_t>;
140  m_eventflag_vec[i]->reserve(1000);
141  }
142  }
143  */
144 
146  //failure |= lowStat_hists.regHist(m_eventflag_summary_lowStat = TH2I_LW::create("eventflag_summary_lowStat", "Event Flag Summary", EventInfo::nDets+1, -0.5, EventInfo::nDets+0.5, 3, -0.5, 2.5)).isFailure();
147  failure |= lowStat_hists.regHist(m_eventflag_summary_lowStat = new TH2I("eventflag_summary_lowStat", "Event Flag Summary", EventInfo::nDets+1, -0.5, EventInfo::nDets+0.5, 3, -0.5, 2.5)).isFailure();
148 
150  m_eventflag_summary_lowStat->GetYaxis()->SetBinLabel(1, "OK");
151  m_eventflag_summary_lowStat->GetYaxis()->SetBinLabel(2, "Warning");
152  m_eventflag_summary_lowStat->GetYaxis()->SetBinLabel(3, "Error");
153  for (int i = 1; i <= EventInfo::nDets; i++) {
154  m_eventflag_summary_lowStat->GetXaxis()->SetBinLabel(i, eventflagdets[i-1]);
155  }
156  m_eventflag_summary_lowStat->GetXaxis()->SetBinLabel(EventInfo::nDets+1, "All");
157  }
158  }
159  }
160  //else if (isNewEventsBlock) {
161  // return StatusCode::SUCCESS;
162  //}
163  if (failure) {return StatusCode::FAILURE;}
164  else {return StatusCode::SUCCESS;}
165 }
166 
167 StatusCode
169 {
170  ATH_MSG_DEBUG("in fillHists()");
171  //StatusCode sc;
172 
173  m_events_lb->Fill(m_environment);
175 
178  if (! evtinfo.isValid()) {
179  ATH_MSG_ERROR("Could not retrieve EventInfo");
180  return StatusCode::FAILURE;
181  } else {
182  if (m_sumweights) {
183  m_sumweights->Fill(evtinfo->lumiBlock(), evtinfo->mcEventWeight());
184  }
186  for (int i = 0; i < EventInfo::nDets; i++) {
187  //unsigned int flag = evtinfo->eventFlags((EventInfo::EventFlagSubDet) i);
189  /*
190  if (flag != 0 && detstate > EventInfo::NotSet) {
191  m_eventflag_vec[i]->push_back(EvFlagPt_t(evtinfo->eventNumber(), flag));
192  }
193  */
194  if (detstate > worststate) worststate = detstate;
195  m_eventflag_summary_lowStat->Fill(i, detstate);
196  }
198  }
199  }
200  return StatusCode::SUCCESS;
201 }
202 
203 StatusCode
205 {
206  /*
207  if ( endOfLumiBlockFlag() || endOfRunFlag() ) {
208 
209  if (endOfRunFlag()) {
210  for (int i = 0; i < EventInfo::nDets; i++) {
211  if (! m_eventflag_vec[i]) { continue ; }
212  ATH_MSG_DEBUG("processing Histograms " << i);
213  m_eventflag_run[i]->Expand(m_eventflag_vec[i]->size(), 1);
214  for(unsigned int j=0; j<m_eventflag_vec[i]->size(); j++) {
215  EvFlagPt_t & pt = (*(m_eventflag_vec[i]))[j];
216  m_eventflag_run[i]->SetPoint(j, pt.first, pt.second);
217  }
218 
219  }
220  }
221 
222  ATH_MSG_DEBUG("in procHistograms()");
223  }
224  */
225  return StatusCode::SUCCESS;
226 }
227 
228 //----------------------------------------------------------------------------------
230 //----------------------------------------------------------------------------------
231 {
232  /*
233  ATH_MSG_DEBUG("in checkHists()");
234  */
235  return StatusCode::SUCCESS;
236 }
237 
DQTDataFlowMonTool::checkHists
virtual StatusCode checkHists(bool fromFinalize) override
This implementation does nothing; equivalent functionality may be provided by procHists(....
Definition: DQTDataFlowMonTool.cxx:229
ManagedMonitorToolBase::m_path
std::string m_path
Definition: ManagedMonitorToolBase.h:915
DQTDataFlowMonTool::m_eventflag_summary_lowStat
TH2I * m_eventflag_summary_lowStat
Definition: DQTDataFlowMonTool.h:58
DQTDataFlowMonTool::m_releaseString
std::string m_releaseString
Definition: DQTDataFlowMonTool.h:48
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition: IEventInfoCnvTool.h:17
ManagedMonitorToolBase::lumiBlock
@ lumiBlock
Definition: ManagedMonitorToolBase.h:114
DQTDataFlowMonTool::m_events_lb
TH1I * m_events_lb
Definition: DQTDataFlowMonTool.h:53
TH1I
Definition: rootspy.cxx:332
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
TH1D
Definition: rootspy.cxx:342
DQTDataFlowMonTool::procHistograms
virtual StatusCode procHistograms() override
An inheriting class should either override this function or finalHists().
Definition: DQTDataFlowMonTool.cxx:204
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition: EventInfo_v1.h:151
DQTDataFlowMonTool::m_sumweights
TH1D * m_sumweights
Definition: DQTDataFlowMonTool.h:61
EventInfo::nDets
@ nDets
Definition: EventInfo/EventInfo/EventInfo.h:54
DQTDataFlowMonTool::bookHistogramsRecurrent
virtual StatusCode bookHistogramsRecurrent() override
An inheriting class should either override this function, bookHists() or bookHistograms().
Definition: DQTDataFlowMonTool.cxx:122
EventInfo::EventFlagErrorState
EventFlagErrorState
Definition: EventInfo/EventInfo/EventInfo.h:59
ManagedMonitorToolBase::MonGroup
A container of information describing a monitoring object.
Definition: ManagedMonitorToolBase.h:138
DQTDataFlowMonTool::m_eventInfoKey
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Definition: DQTDataFlowMonTool.h:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
DataQualityFatherMonTool
Definition: DataQualityFatherMonTool.h:38
EventInfo::NotSet
@ NotSet
Definition: EventInfo/EventInfo/EventInfo.h:60
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
TH2I
Definition: rootspy.cxx:410
ManagedMonitorToolBase::newLowStatIntervalFlag
bool newLowStatIntervalFlag() const
Flag functions allowing clients to determine when to book new and process old histograms; values are ...
Definition: ManagedMonitorToolBase.h:849
ManagedMonitorToolBase::ATTRIB_UNMANAGED
@ ATTRIB_UNMANAGED
Definition: ManagedMonitorToolBase.h:131
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AthenaMonManager::tier0Raw
@ tier0Raw
Definition: AthenaMonManager.h:49
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
DQTDataFlowMonTool::initialize
virtual StatusCode initialize() override
Definition: DQTDataFlowMonTool.cxx:71
run
Definition: run.py:1
ManagedMonitorToolBase::ATTRIB_MANAGED
@ ATTRIB_MANAGED
Definition: ManagedMonitorToolBase.h:131
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::EventInfo_v1::lumiBlock
uint32_t lumiBlock() const
The current event's luminosity block number.
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
ManagedMonitorToolBase::MonGroup::regHist
StatusCode regHist(TH1 *h)
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
Definition: ManagedMonitorToolBase.cxx:195
ManagedMonitorToolBase::m_environment
AthenaMonManager::Environment_t m_environment
Definition: ManagedMonitorToolBase.h:902
DQTDataFlowMonTool::m_release_stage_lowStat
TH1I * m_release_stage_lowStat
Definition: DQTDataFlowMonTool.h:54
DQTDataFlowMonTool::fillHistograms
virtual StatusCode fillHistograms() override
An inheriting class should either override this function or fillHists().
Definition: DQTDataFlowMonTool.cxx:168
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
DQTDataFlowMonTool::m_releaseStageString
std::string m_releaseStageString
Definition: DQTDataFlowMonTool.h:49
DataQualityFatherMonTool::initialize
virtual StatusCode initialize()
Definition: DataQualityFatherMonTool.cxx:43
ManagedMonitorToolBase::lowStat
@ lowStat
Definition: ManagedMonitorToolBase.h:115
DQTDataFlowMonTool::bookHistograms
virtual StatusCode bookHistograms() override
An inheriting class should either override this function or bookHists().
Definition: DQTDataFlowMonTool.cxx:79
AthenaMonManager::altprod
@ altprod
Definition: AthenaMonManager.h:49
DQTDataFlowMonTool.h
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
xAOD::EventInfo_v1::errorState
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
Definition: EventInfo_v1.cxx:817
EventInfo::EventFlagSubDet
EventFlagSubDet
Definition: EventInfo/EventInfo/EventInfo.h:53
xAOD::EventInfo_v1::mcEventWeight
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Definition: EventInfo_v1.cxx:203
DQTDataFlowMonTool::~DQTDataFlowMonTool
virtual ~DQTDataFlowMonTool()
Definition: DQTDataFlowMonTool.cxx:59
ReadHandle.h
Handle class for reading from StoreGate.
ManagedMonitorToolBase::newLumiBlockFlag
bool newLumiBlockFlag() const
Definition: ManagedMonitorToolBase.h:853
ManagedMonitorToolBase::ATTRIB_X_VS_LB
@ ATTRIB_X_VS_LB
Definition: ManagedMonitorToolBase.h:131
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
DQTDataFlowMonTool::DQTDataFlowMonTool
DQTDataFlowMonTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: DQTDataFlowMonTool.cxx:33