ATLAS Offline Software
Loading...
Searching...
No Matches
ManagedMonitorToolBase.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ManagedMonitorToolBase_CXX
6#define ManagedMonitorToolBase_CXX
7
9
10#include <cctype>
11#include <ctime>
12#include <sstream>
13
14#include "TGraph.h"
15#include "TH1.h"
16#include "TH2.h"
17#include "TTree.h"
18#include "TROOT.h"
19#include "TFile.h"
20#include "TEfficiency.h"
21#include "AthMonBench.h"
23
24#include "Gaudi/Interfaces/IOptionsSvc.h"
25#include "GaudiKernel/IHistogramSvc.h"
26#include "GaudiKernel/IMessageSvc.h"
27#include "GaudiKernel/ISvcLocator.h"
28#include "GaudiKernel/MsgStream.h"
29
32#include "GaudiKernel/ITHistSvc.h"
33
34
35//____________________________________________________________________
37public:
38 inline static std::atomic<ISvcLocator*> s_svcLocator{nullptr};
43 ~Imp() {}
44
45 //Data members:
47 //To warn against clients that reimplemented initialize without calling ManagedMonitorToolBase::initialze():
49
50 //Internal methods and data members for detailed CPU/mem monitoring:
66 void benchFinalReport();
67 void benchReset();
68};
69
73
74//____________________________________________________________________
76{
77 if (!m_doResourceMon)
78 return;
79 benchReset();
80 m_bench_book.startMeasurement();
81}
82
83//____________________________________________________________________
92
93//____________________________________________________________________
95{
96 if (!m_doResourceMon)
97 return;
98 m_bench_tmp.reset();
99 m_bench_tmp.startMeasurement();
100}
101
102//____________________________________________________________________
117
118//____________________________________________________________________
120{
121 if (!m_doResourceMon)
122 return;
123 m_bench_proc.startMeasurement();
124}
125
126//____________________________________________________________________
138
139//____________________________________________________________________
141{
142 if (!m_doResourceMon)
143 return;
145 m_bench_tmp.reset();
146 m_bench_book.reset();
147 m_bench_fillfirst.reset();
148 m_bench_fillall.reset();
149 m_bench_filllast.reset();
150 m_bench_proc.reset();
151 m_bench_total.reset();
152
153}
154
155//____________________________________________________________________
157{
158 if (!m_doResourceMon)
159 return;
160 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Result of dedicated mon-tool resource monitoring:"<<endmsg;
161 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Book : "<<m_bench_book << endmsg;
162 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> First Fill : "<<m_bench_fillfirst << endmsg;
163 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Last Fill : "<<m_bench_filllast << endmsg;
164 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Other Fills : "<<m_bench_fillall << endmsg;
165 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Proc : "<<m_bench_proc << endmsg;
166 m_bench_total.setUnitCount();//to avoid dividing by number of measurements
167 m_theclass->msg(AthMonBench::s_resourceMonThreshold) << "ResourceSummary --> Grand Total : "<<m_bench_total << endmsg;
168 //NB: Needs total also!
169}
170
171
172
176
177namespace {
178
179 std::string strToLower( const std::string& str );
180
181} // unnamed namespace
182
183static std::atomic<unsigned> s_mmtb_mongroup_ncopies=0;
186
187// *********************************************************************
188// Public Methods
189// *********************************************************************
190StatusCode
192regHist( TH1* h )
193{
194 if( m_tool != 0 ) {
195 std::string hName( h->GetName() );
196 m_map.emplace( hName, h );
197 return m_tool->regHist( h, *this );
198 }
199
200 return StatusCode::FAILURE;
201}
202
203StatusCode
205getHist( TH1*& h, const std::string& hName )
206{
207 if( m_tool != 0 ) {
208 return m_tool->getHist( h, hName, *this );
209 }
210
211 return StatusCode::FAILURE;
212}
213
214
215StatusCode
217getHist( TH2*& h, const std::string& hName )
218{
219 if( m_tool != 0 ) {
220 return m_tool->getHist( h, hName, *this );
221 }
222
223 return StatusCode::FAILURE;
224}
225
226
228 if( m_tool != 0 ) {
229 return m_tool->regEfficiency( e, *this );
230 }
231 return StatusCode::FAILURE;
232}
233
234
235StatusCode
237regGraph( TGraph* g )
238{
239 if( m_tool != 0 ) {
240 return m_tool->regGraph( g, *this );
241 }
242
243 return StatusCode::FAILURE;
244}
245
246
247StatusCode
249regTree( TTree* t )
250{
251 if( m_tool != 0 ) {
252 return m_tool->regTree( t, *this );
253 }
254
255 return StatusCode::FAILURE;
256}
257
258
259StatusCode
261writeAndDelete( TH1* h )
262{
263 if( m_tool != 0 ) {
264 std::string hName( h->GetName() );
265 m_map.erase( hName );
266 return m_tool->writeAndDelete( h, *this );
267 }
268
269 return StatusCode::FAILURE;
270}
271
272
273StatusCode
275deregHist( TH1* h )
276{
277 if( m_tool != 0 ) {
278 std::string hName( h->GetName() );
279 m_map.erase( hName );
280 return m_tool->deregHist( h );
281 }
282
283 return StatusCode::FAILURE;
284}
285
286
287StatusCode
289deregGraph( TGraph* g )
290{
291 if( m_tool != 0 ) {
292 return m_tool->deregGraph( g );
293 }
294
295 return StatusCode::FAILURE;
296}
297
298
299StatusCode
301deregObject( const std::string& objName )
302{
303 if( m_tool != 0 ) {
304 return m_tool->deregObject( objName, *this );
305 }
306
307 return StatusCode::FAILURE;
308}
309
310
311StatusCode
313deregAll()
314{
315 if( m_tool != 0 ) {
316 bool isSuccess(true);
317 StatusCode sc;
318
319 typedef HistMap_t::const_iterator MapIter_t;
320 MapIter_t mapEnd = m_map.end();
321 for( MapIter_t i = m_map.begin(); i != mapEnd; ++i ) {
322 sc = m_tool->deregHist( i->second );
323 if( !sc.isSuccess() )
324 isSuccess = false;
325 }
326
327 m_map.clear();
328
329 if( isSuccess )
330 return StatusCode::SUCCESS;
331 }
332
333 return StatusCode::FAILURE;
334}
335
336
338ManagedMonitorToolBase( const std::string & type, const std::string & name,
339 const IInterface* parent )
340 : AthAlgTool( type, name, parent )
341 , m_manager(0)
342 , m_managerNameProp("AthenaMonManager")
343 , m_fileKey("")
344 , m_dataTypeStr("userDefined")
345 , m_environmentStr("noOutput")
346 , m_detailLevel(1)
347 , m_dataType(AthenaMonManager::userDefined)
349 , m_streamNameFcn(0)
350 , m_THistSvc("THistSvc",name)
352 , m_path("")
353 , m_preScaleProp(0)
356 , m_useTrigger(false)
357 , m_lastLumiBlock(0)
358 , m_lastRun(0)
362 , m_nEvents(1)
364 , m_nLumiBlocks(1)
367 , m_useLumi(false)
369 , m_d(new Imp(this))
370{
371// ManagedMonitorToolBase_resetHistStatistics(this);
372 declareInterface<IMonitorToolBase>(this);
373 declareProperty( "ProcessNEvents", m_procNEventsProp );
374 declareProperty( "histoPathBase", m_path );
375 declareProperty( "PreScale", m_preScaleProp );
376 declareProperty( "TriggerChain", m_triggerChainProp );
377 declareProperty( "TriggerGroup", m_triggerGroupProp );
378
379 // If a class would like to associate itself to a manager but cannot actually
380 // be referenced by it, the manager name can be set explicitly. Otherwise,
381 // it is set automatically.
382 declareProperty( "ManagerName", m_managerNameProp );
383
384 // Enable luminosity tool?
385 declareProperty( "EnableLumi", m_useLumi );
386
387 // How detailed should the monitoring be?
389
390 // If we don't know how long an LB is, here's the default
391 declareProperty( "DefaultLBDuration", m_defaultLBDuration );
392
393 // Properties that are overridden in initialize()---settings via jobOptions are ignored!
394 declareProperty( "FileKey", m_fileKey );
395 declareProperty( "DataType", m_dataTypeStr );
396 declareProperty( "Environment", m_environmentStr );
397
398 if( !Imp::s_svcLocator )
399 Imp::s_svcLocator = svcLoc();
400
401 for (auto interval: { eventsBlock, lumiBlock, lowStat, run, all }) {
402 m_templateHistograms[interval] = std::vector< MgmtParams<TH1> >();
403 m_templateGraphs[interval] = std::vector< MgmtParams<TGraph> >();
404 m_templateTrees[interval] = std::vector< MgmtParams<TTree> >();
405 m_supportedIntervalsForRebooking.insert(interval);
406 }
407
408 newLowStatInterval = false;
409 newMedStatInterval = false;
410 newHigStatInterval = false;
411 newLowStat = false;
412 newLumiBlock = false;
413 newRun = false;
414 newEventsBlock = false;
415 endOfEventsBlock = false;
416 endOfLowStat = false;
417 endOfLumiBlock = false;
418 endOfRun = false;
419
420 m_newLowStatInterval = false;
421 m_newMedStatInterval = false;
422 m_newHigStatInterval = false;
423 m_newLowStat = false;
424 m_newLumiBlock = false;
425 m_newRun = false;
426 m_newEventsBlock = false;
427 m_endOfEventsBlock = false;
428 m_endOfLowStat = false;
429 m_endOfLumiBlock = false;
430 m_endOfRun = false;
431}
432
433
436{
437// ManagedMonitorToolBase_printHistStatistics(this);
438 delete m_streamNameFcn;
439
440 std::map<std::string,OutputMetadata*>::iterator mdend = m_metadataMap.end();
441 for( std::map<std::string,OutputMetadata*>::iterator i = m_metadataMap.begin();
442 i != mdend; ++i ) {
443 delete (i->second);
444 }
445 delete m_d;
446}
447
448
452{
453 if( m_streamNameFcn == 0 ) {
454 msg(MSG::ERROR) << "!! streamNameFunction() has not been initialized !!" << endmsg;
455 msg(MSG::ERROR) << " --> neither ManagedMonitorToolBase::initialize() nor" << endmsg;
456 msg(MSG::ERROR) << " --> ManagedMonitorToolBase::setMonManager() has been called." << endmsg;
457 msg(MSG::ERROR) << " --> Correct configuration cannot be guaranteed from this point." << endmsg;
459 }
460 return m_streamNameFcn;
461}
463
464/*
465std::string
466ManagedMonitorToolBase::
467levelOfDetailEnumToString( LevelOfDetail_t level, bool useOnlineConventions )
468{
469 std::string str("summary");
471 switch( level ) {
472 case transient:
473 str = "transient";
474 break;
475 case debug:
476 str = "debug";
477 break;
478 case expert:
479 str = "expert";
480 break;
481 case shift:
482 str = "shift";
483 break;
484 case summary:
485 default:
486 if(useOnlineConventions)
487 str = "runstat";
488 else
489 str = "summary";
490 }
491
492 if(useOnlineConventions)
493 str = strToUpper( str );
494
495 return str;
496}
497*/
498
499/*
500ManagedMonitorToolBase::LevelOfDetail_t
501ManagedMonitorToolBase::
502levelOfDetailStringToEnum( const std::string& str )
503{
504 std::string lcstr( strToLower(str) );
505
506 if( lcstr == "summary" || lcstr == "runstat" )
507 return summary;
508 else if( lcstr == "shift" )
509 return shift;
510 else if( lcstr == "expert" )
511 return expert;
512 else if( lcstr == "debug" )
513 return debug;
514 else if( lcstr == "transient" )
515 return transient;
516
517 // This is a static method (shared by all instances), so no "this" pointer
518 // is available (needed for msg). Have to use message service directly.
519 if( Imp::s_svcLocator!=0 ) {
520 IMessageSvc* ms(0);
521 StatusCode sc = Imp::s_svcLocator->service( "MessageSvc", ms, true );
522 if( sc.isSuccess() ) {
523 MsgStream log( ms, "ManagedMonitorToolBase::levelOfDetailStringToEnum()" );
524 log << MSG::WARNING << "Unknown ManagedMonitorToolBase::LevelOfDetail_t \""
525 << str << "\", returning \"transient\"" << endmsg;
526 }
527 }
528
529 return transient;
531*/
532
533
534std::string
537{
538 std::string str("file");
539
540 switch( interval ) {
541 case all:
542 str = "all";
543 break;
544 case fill:
545 str = "fill";
546 break;
547 case run:
548 str = "run";
549 break;
550 case lowStat:
551 str = "lowStat";
552 break;
553 case medStat:
554 str = "medStat";
555 break;
556 case higStat:
557 str = "higStat";
558 break;
559 case lumiBlock:
560 str = "lumiBlock";
561 break;
562 case eventsBlock:
563 str = "eventsBlock";
564 break;
565 case file:
566 str = "file";
567 break;
568 default:
569 str = "unknown";
570 }
571
572 return str;
573}
574
575
578intervalStringToEnum( const std::string& str )
579{
580 std::string lcstr( strToLower(str) );
581
582 if( lcstr == "all" )
583 return all;
584 else if( lcstr == "fill" )
585 return fill;
586 else if( lcstr == "run" )
587 return run;
588 else if( lcstr == "lowStat" )
589 return lowStat;
590 else if( lcstr == "medStat" )
591 return medStat;
592 else if( lcstr == "higStat" )
593 return higStat;
594 else if( lcstr == "lumiBlock" )
595 return lumiBlock;
596 else if( lcstr == "eventsBlock" )
597 return eventsBlock;
598 else if( lcstr == "file" )
599 return file;
600
601 if( Imp::s_svcLocator ) {
602 SmartIF<IMessageSvc> ms{Imp::s_svcLocator.load()->service( "MessageSvc" )};
603 if( ms.isValid() ) {
604 MsgStream log( ms, "ManagedMonitorToolBase::intervalStringToEnum()" );
605 log << MSG::WARNING << "Unknown ManagedMonitorToolBase::Interval_t \""
606 << str << "\", returning \"file\"" << endmsg;
607 }
608 }
609
610 return file;
611}
612
613
614StatusCode
617{
618 m_d->m_warnAboutMissingInitialize = false;
619
620 StatusCode sc = AthAlgTool::initialize();
621 if( !sc.isSuccess() )
622 return StatusCode::FAILURE;
623
624 ATH_MSG_DEBUG("ManagedMonitorToolBase::initialize():");
625
627
628 sc = m_THistSvc.retrieve();
629 if( !sc.isSuccess() ) {
630 msg(MSG::ERROR) << "!! Unable to locate the THistSvc service !!" << endmsg;
631 return sc;
632 }
633 ATH_MSG_DEBUG(" --> Found service \"THistSvc\"");
634
635 if( !m_trigDecTool.empty() ) {
636 sc = m_trigDecTool.retrieve();
637 if( !sc.isSuccess() ) {
638 msg(MSG::ERROR) << "!! Unable to retrieve the TrigDecisionTool !!" << endmsg;
639 return sc;
640 }
641 ATH_MSG_DEBUG(" --> Found AlgTool \"TrigDecisionTool\"");
642
643 if( !m_trigTranslator.empty() ) {
644 sc = m_trigTranslator.retrieve();
645 if ( !sc.isSuccess() ) {
646 ATH_MSG_ERROR(" Unable to retrieve the TrigTranslatorTool!" << endmsg);
647 return sc;
648 }
649 }
650
651 if(m_triggerChainProp!="") {
652 ATH_MSG_DEBUG(" --> Found nonempty trigger chain list");
654 if(!sc.isSuccess()) {
655 msg(MSG::WARNING) << "Error parsing the trigger chain list, using empty list" << endmsg;
656 m_vTrigChainNames.clear();
657 }
658 if (!m_trigTranslator.empty()) {
660 }
661 }
662 else {
663 ATH_MSG_DEBUG(" --> trigger chain list empty");
664 }
665 if(m_triggerGroupProp!="") {
666 ATH_MSG_DEBUG(" --> Found nonempty trigger group list");
668 if(!sc.isSuccess()) {
669 msg(MSG::WARNING) << "Error parsing the trigger group names list, using empty list" << endmsg;
670 m_vTrigGroupNames.clear();
671 }
672 if (!m_trigTranslator.empty()) {
674 }
675 }
676 else {
677 ATH_MSG_DEBUG(" --> trigger group list empty");
678 }
679 }
680 else {
681 ATH_MSG_DEBUG(" --> no trigger decision tool specified");
682 }
683
684 sc = m_DQFilterTools.retrieve();
685 if( !sc.isSuccess() ) {
686 ATH_MSG_ERROR("!! Unable to retrieve the Filter Tools !!");
687 return sc;
688 }
689
690 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc( "JobOptionsSvc", name() );
691 ATH_CHECK( joSvc.retrieve() );
692 ATH_MSG_DEBUG(" --> Found service \"JobOptionsSvc\"");
693
694 const std::string client( m_managerNameProp + "Properties" );
695 ATH_MSG_DEBUG(" --> Asking for properties " << client);
696
697 auto getProp = [this,&joSvc](std::string& var, const std::string& name) {
698 if (joSvc->has(name))
699 var = joSvc->get(name);
700 else
701 ATH_MSG_DEBUG("Cannot read " << name); // on purpose not an ERROR (will be set by setMonManager)
702 };
703 getProp( m_fileKey, client + ".FileKey");
704 getProp( m_dataTypeStr, client + ".DataType");
705 getProp( m_environmentStr, client + ".Environment");
706
707 ATH_MSG_DEBUG(" * Properties set from " << client << " to the values:\n"
708 << " FileKey: " << m_fileKey << "\n"
709 << " DataType: " << m_dataTypeStr << "\n"
710 << " Environment: " << m_environmentStr);
711
714
718
719 delete m_streamNameFcn;
721
722 ATH_MSG_DEBUG(" --> Exiting successfully");
723
724 return StatusCode::SUCCESS;
725}
726
727
728StatusCode
730bookHists()
731{
732 // The Run/LumiBlock numbers are not set when beginRun() is called. Therefore,
733 // book histograms on the first call to fillHists(), which is called from execute().
734 return StatusCode::SUCCESS;
735}
736
737
738StatusCode
740fillHists()
741{
742
743 if (m_d->m_warnAboutMissingInitialize) {
744 m_d->m_warnAboutMissingInitialize = false;
745 msg(MSG::WARNING) << "ManagedMonitorToolBase::initialize() never called from reimplementation!" << endmsg;
746 }
747
748
749 bool isNewEventsBlock = ( m_procNEventsProp > 0 && ((m_nEvents % m_procNEventsProp) == 1) && m_haveClearedLastEventBlock );
750 if (isNewEventsBlock) m_haveClearedLastEventBlock = false;
751
752 m_newLowStat = false;
753 m_newLumiBlock = false;
754 m_newRun = false;
755 newLowStat = false;
756 newLumiBlock = false;
757 newRun = false;
758
759 m_newLowStatInterval = false;
760 m_newMedStatInterval = false;
761 m_newHigStatInterval = false;
762 newLowStatInterval = false;
763 newMedStatInterval = false;
764 newHigStatInterval = false;
765
766 m_useTrigger = ( (m_triggerChainProp != "" || m_triggerGroupProp != "") && (!m_trigDecTool.empty()) );
767
768 if( m_manager != 0 ) {
769 m_newLumiBlock = ( (m_lastLumiBlock != m_manager->lumiBlockNumber()) || m_manager->forkedProcess());
770 m_newRun = ( m_lastRun != m_manager->runNumber() );
771 newLumiBlock = m_newLumiBlock;
772 newRun = m_newRun;
773
774 if(m_newRun) {
775 m_newLumiBlock = true;
776 newLumiBlock = m_newLumiBlock;
777 isNewEventsBlock = true;
778 }
779
780 m_newEventsBlock = isNewEventsBlock;
781 newEventsBlock = m_newEventsBlock;
782
783 if( m_newLumiBlock ) {
784 // check if a new LB interval has started
785 // lowest lumiBlockNumber() is 1
786 // m_lastLowStatInterval is -1 initially
787 int currentLB = m_manager->lumiBlockNumber();
788 int LBsLowStat = m_manager->getLBsLowStat();
789 int LBsMedStat = m_manager->getLBsMedStat();
790 int LBsHigStat = m_manager->getLBsHigStat();
791
792 if( LBsLowStat*LBsMedStat*LBsHigStat == 0) {
793 msg(MSG::WARNING) << "zero LBs requested for interval" << endmsg;
794 }
795 else {
796 if( ((currentLB-1)/LBsLowStat) != m_lastLowStatInterval ) m_newLowStatInterval = true;
797 if( ((currentLB-1)/LBsMedStat) != m_lastMedStatInterval ) m_newMedStatInterval = true;
798 if( ((currentLB-1)/LBsHigStat) != m_lastHigStatInterval ) m_newHigStatInterval = true;
799 newLowStatInterval = m_newLowStatInterval;
800 newMedStatInterval = m_newHigStatInterval;
801 newHigStatInterval = m_newHigStatInterval;
802 }
803 }
804
805 // Allow inheriting classes the option of using the lastLumiBloc/lastRun values
806 // before updating them
807 }
808
809
810 StatusCode sc0( StatusCode::SUCCESS );
811 StatusCode sc1( StatusCode::SUCCESS );
812 StatusCode sc2( StatusCode::SUCCESS );
813 StatusCode sc3( StatusCode::SUCCESS );
814
815 // Set end of LowStat, LumiBlock and Run variables
816 // These are needed to be used in procHistograms().
821 endOfEventsBlock = m_newEventsBlock;
822 endOfLowStat = m_newLowStatInterval;
823 endOfLumiBlock = m_newLumiBlock;
824 endOfRun = m_newRun;
825
826 // just duplicates m_newLowStatInterval
828 newLowStat = m_newLowStatInterval;
829
831 ATH_MSG_DEBUG("Interval transition processing");
832 // Process histograms from the previous lumiBlock/run
833 if( m_nEvents != 1 ) {
834 m_d->benchPreProcHistograms();
835 sc0 = procHistograms();
836 m_d->benchPostProcHistograms();
837 }
838 // Re-book new histograms
839 m_d->benchPreBookHistograms();
840
842 sc1 = bookHistograms();
844 } else {
845 std::vector<Interval_t> intervals_to_process;
846 if (m_newEventsBlock) intervals_to_process.push_back(eventsBlock);
847 if (m_newLumiBlock) intervals_to_process.push_back(lumiBlock);
848 if (m_newLowStatInterval) intervals_to_process.push_back(lowStat);
849 if (m_newRun) intervals_to_process.push_back(run);
850 for (const auto interval: intervals_to_process) {
852 sc1 = regManagedGraphs(m_templateGraphs[interval]);
853 sc1 = regManagedTrees(m_templateTrees[interval]);
854 }
855 }
856 for (const auto& interval: std::vector<Interval_t>{ eventsBlock, lumiBlock, lowStat, run }) {
857 for (const auto& it: m_templateHistograms[interval]) {
858 // is histogram too small in x axis for LB range?
859 if (it.m_group.histo_mgmt() == ATTRIB_X_VS_LB) {
860 //ATH_MSG_WARNING("We are rebinning for " << it.m_templateHist->GetName());
861 while ( it.m_templateHist->GetXaxis()->GetXmax() <= AthenaMonManager::lumiBlockNumber() ) {
862 it.m_templateHist->LabelsInflate("X");
863 }
864 }
865 }
866 for (auto& it: m_templateEfficiencies[interval]) {
867 if (it.m_group.histo_mgmt() == ATTRIB_X_VS_LB) {
868 // get the underlying passed and total TH1's from the TEfficiency
869 TH1* passedHist = it.m_templateHist->GetCopyPassedHisto();
870 TH1* totalHist = it.m_templateHist->GetCopyTotalHisto();
871 // inflate them until they exceed the lumi-block number
872 while (passedHist->GetXaxis()->GetXmax() <= AthenaMonManager::lumiBlockNumber() ) {
873 passedHist->LabelsInflate("X");
874 totalHist->LabelsInflate("X");
875 }
876 // Replace them in the TEfficiency. First one has force ("f") option, since the
877 // histograms will not be consistent. This is corrected in the next line, so we
878 // do check for consistency then.
879 it.m_templateHist->SetPassedHistogram(*passedHist, "f");
880 it.m_templateHist->SetTotalHistogram(*totalHist, " ");
881 delete passedHist; // not owned by THistSvc, so need to be deleted.
882 delete totalHist;
883 }
884 }
885 }
886
887 if (auto streamname = dynamic_cast<OfflineStream*>(streamNameFunction())) {
888 streamname->updateRunLB();
889 }
890
892
893 m_d->benchPostBookHistograms();
894
895 }//end if new RUN/LB/Block
896
897 // check filters
898 bool filterresult(true);
899 if (! m_DQFilterTools.empty()) {
900 ToolHandleArray<IDQFilterTool>::const_iterator ifilter(m_DQFilterTools.begin()), filterend(m_DQFilterTools.end());
901 for (; filterresult && (ifilter != filterend);
902 ++ifilter) {
903 filterresult = (filterresult && (*ifilter)->accept());
904 }
905 }
906
907
908 // ...and fill as normal
909 if(filterresult &&
913 ATH_MSG_DEBUG("Passed trigger, presumably");
914 m_d->benchPreFillHistograms();
915 fillHistograms().ignore();
917 m_d->benchPostFillHistograms();
918 ++m_nEvents;
919 } else { ATH_MSG_DEBUG("Failed trigger, presumably"); }
920
922 if( m_newLumiBlock && (m_nEventsIgnoreTrigger != 1) ) {
924 }
925 if( m_manager != 0 ) {
926 m_lastRun = m_manager->runNumber();
927 if( m_newLumiBlock ) {
928 m_lastLumiBlock = m_manager->lumiBlockNumber();
929
930 int LBsLowStat = m_manager->getLBsLowStat();
931 int LBsMedStat = m_manager->getLBsMedStat();
932 int LBsHigStat = m_manager->getLBsHigStat();
933 if( LBsLowStat*LBsMedStat*LBsHigStat > 0) {
937 }
938 }
939 }
940
941 return StatusCode::SUCCESS;
942}
943
944StatusCode
946registerMetadata(const std::string& streamName, const std::string& hName,
947 const MonGroup& group) {
949 TTree* metadata(0);
950 std::string mdStreamName( streamName );
951 size_t found=mdStreamName.rfind('/');
952
953 if ( found != std::string::npos )
954 mdStreamName.replace( found, mdStreamName.length(), "/metadata" );
955
956 MDMap_t::iterator i = m_metadataMap.find( mdStreamName );
957 if( i == m_metadataMap.end() ) {
958 metadata = new TTree( "metadata", "Monitoring Metadata" );
959 if (! metadata) return StatusCode::FAILURE;
960 StatusCode scmd = m_THistSvc->regTree( mdStreamName, metadata );
961 if (scmd == StatusCode::FAILURE) return StatusCode::FAILURE;
962 i = m_metadataMap.emplace( mdStreamName, new OutputMetadata(metadata) ).first;
963 }
964
965 i->second->fill( hName, group.interval(), group.chain(), group.merge() );
966 }
967 return StatusCode::SUCCESS;
968}
969
970StatusCode
972regManagedHistograms(std::vector< MgmtParams<TH1> >& templateHistograms)
973{
974 // The method registers histograms with the THistSvc and saves them to file.
975
976 // The funky business with registering and deregistering the histogram is needed
977 // to get the correct directory when saving histograms. THistSvc deals with ROOT
978 // to set up proper TDirectory, so we rely on it.
979 // E.g.
980 // m_THistSvc->regHist( streamName, h ): sets the correct TDirectory with streamName
981 // m_THistSvc->deReg( h ) - deregister from THistSvc otherwise THistSvc will try to save it
982 // at the end of execution
983 // use passownership of the histogram and save it to file
984 // m_manager->passOwnership( h, genericName );
985 // m_manager->writeAndDelete( genericName );
986 bool allIsOk = true;
987
988 for( std::vector< MgmtParams<TH1> >::iterator it = templateHistograms.begin(); it != templateHistograms.end(); ++it ) {
989 MonGroup& group = (*it).m_group;
990
991 // Get a handle to the histogram
992 TH1* theHist = (*it).m_templateHist;
993
994 // Clone the histogram
995 TH1* h = static_cast<TH1*>(theHist->Clone());
996 theHist->Reset();
997
998 // Get name
999 std::string hName = h->GetName();
1000
1001 // Get the streamName for the previous interval
1002 std::string streamName = streamNameFunction()->getStreamName( this, group, hName, true );
1003
1004 // Register the histogram with the THistSvc
1005 StatusCode sc1 = m_THistSvc->deReg( theHist );
1006 if (sc1 == StatusCode::FAILURE) allIsOk = false;
1007
1008 // Register clonned histogram under previous interval streamName
1009 StatusCode sc2 = m_THistSvc->regHist( streamName, h );
1010 if (sc2 == StatusCode::FAILURE) allIsOk = false;
1011
1012 if( m_manager != 0 ) {
1013 std::string genericName = NoOutputStream().getStreamName( this, group, hName );
1014 m_manager->passOwnership( h, genericName );
1015 m_manager->writeAndDelete( genericName );
1016 }
1017
1018 // Get streamName for the current interval
1019 streamName = streamNameFunction()->getStreamName( this, group, hName, false );
1020 // Register metadata information with the current interval streamname
1021 StatusCode smd = registerMetadata(streamName, hName, group);
1022 if (smd != StatusCode::SUCCESS) allIsOk = false;
1023
1024 // Re-register the original histogram with the current interval streamName
1025 StatusCode sc3 = m_THistSvc->regHist( streamName, theHist );
1026 if (sc3 == StatusCode::FAILURE) allIsOk = false;
1027
1028 }
1029
1030 if (!allIsOk) return StatusCode::FAILURE;
1031
1032 return StatusCode::SUCCESS;
1033}
1034
1035StatusCode
1037THistSvc_deReg_fixTGraph( TFile* file, TGraph* theGraph, std::string& directoryName)
1038{
1039 // THistSvc employs TDirectory Append method when registering TGraph.
1040 // When deReg is used to de-register TGraph object, THistSvc only removes the object
1041 // from its internal management but forgets to delete from TDirectory.
1042 // The current method fixes this problem by removing the TGraph object manually
1043 // after THistSvc->deReg(TGraph* obj) is called.
1044
1045 // Saves and restores gFile and gDirectory
1046 GlobalDirectoryRestore restore;
1047
1048 // This check is true when TGraph object is removed successfully
1049 bool graphRemoved = false;
1050
1051 file->cd("/");
1052 TDirectory* dir = file->GetDirectory(directoryName.c_str());
1053 if (dir != 0) {
1054 dir->cd();
1055 TObject* obj = dir->Remove(theGraph);
1056 if (obj != 0)
1057 graphRemoved = true;
1058 }
1059
1060 if (!graphRemoved) {
1061 return StatusCode::FAILURE;
1062 }
1063
1064 return StatusCode::SUCCESS;
1065}
1066
1067StatusCode
1069regManagedGraphs(std::vector< MgmtParams<TGraph> >& templateGraphs)
1070{
1071 // See the description for the regManagedHistograms method
1072 bool allIsOk = true;
1073
1074 for( std::vector< MgmtParams<TGraph> >::iterator it = templateGraphs.begin(); it != templateGraphs.end(); ++it ) {
1075 MonGroup group = (*it).m_group;
1076
1077 // Get a handle to the graph
1078 TGraph* theGraph = (*it).m_templateHist;
1079
1080 // Clone the graph
1081 TGraph* g = static_cast<TGraph*>(theGraph->Clone());
1082 theGraph->Set(0); // equivalent to Reset() for TH1
1083
1084 // Get name
1085 std::string gName = g->GetName();
1086
1087 // Get the streamName for the previous interval
1088 std::string streamName = streamNameFunction()->getStreamName( this, group, gName, true );
1089
1090 // De-register the original graph with the THistSvc
1091 StatusCode sc1 = m_THistSvc->deReg( theGraph );
1092 if (sc1 == StatusCode::FAILURE)
1093 allIsOk = false;
1094
1095 // *** begin ***
1096 // Fix THistSvc->deReg for TGraphs
1097 bool doneCleaning = false;
1098 std::string directoryName = streamNameFunction()->getDirectoryName( this, group, gName, true );
1099 TSeqCollection *filelist=gROOT->GetListOfFiles();
1100 for (int i=0; i<filelist->GetEntries(); i++) {
1101 ATH_MSG_DEBUG( "List of files: " << filelist->At(i)->GetName());
1102 TFile* file = static_cast<TFile*>(filelist->At(i));
1103 StatusCode sc2 = THistSvc_deReg_fixTGraph(file, theGraph, directoryName);
1104 if (sc2 == StatusCode::SUCCESS)
1105 doneCleaning = true;
1106 }
1107
1108 // Check if TGraph fix has been applied successfully
1109 if (!doneCleaning) {
1110 ATH_MSG_ERROR("THistSvc_deReg_fixTGraph: failed to apply TGraph fix for the THist Svc!");
1111 allIsOk = false;
1112 }
1113 // *** end ***
1114
1115 // Register clonned histogram under previous interval streamName
1116 StatusCode sc3 = m_THistSvc->regGraph( streamName, g );
1117 if (sc3 == StatusCode::FAILURE)
1118 allIsOk = false;
1119
1120 // Get streamName for the current interval
1121 streamName = streamNameFunction()->getStreamName( this, group, gName, false );
1122 // Register metadata information with the current interval streamname
1123 StatusCode smd = registerMetadata(streamName, gName, group);
1124 if (smd != StatusCode::SUCCESS)
1125 allIsOk = false;
1126
1127 // Re-register the original graph with the current interval streamName
1128 StatusCode sc4 = m_THistSvc->regGraph( streamName, theGraph );
1129 if (sc4 == StatusCode::FAILURE)
1130 allIsOk = false;
1131
1132 }
1133
1134 if (!allIsOk) return StatusCode::FAILURE;
1135
1136 return StatusCode::SUCCESS;
1137}
1138
1139StatusCode ManagedMonitorToolBase::regManagedEfficiencies(std::vector< MgmtParams<TEfficiency> >& templateEfficiencies) {
1140 bool allIsOk = true;
1141 for( auto& it : templateEfficiencies ) {
1142 // get components of MgmtParams and copy efficiency
1143 MonGroup group = it.m_group;
1144 TEfficiency* theEfficiency = it.m_templateHist;
1145 TEfficiency* e = static_cast<TEfficiency*>(theEfficiency->Clone());
1146 int nbins = theEfficiency->GetTotalHistogram()->GetNbinsX();
1147 int xlow = theEfficiency->GetTotalHistogram()->GetXaxis()->GetXmin();
1148 int xhigh = theEfficiency->GetTotalHistogram()->GetXaxis()->GetXmax();
1149 e->SetBins(nbins,xlow,xhigh); // reset histogram
1150 std::string name = e->GetName();
1151
1152 // make TGraph casts of TEfficiencies
1153 TGraph* theGraph = reinterpret_cast<TGraph*>(theEfficiency);
1154 TGraph* g = reinterpret_cast<TGraph*>(e);
1155
1156 // Get the streamName for the previous interval
1157 std::string streamName = streamNameFunction()->getStreamName( this, group, name, true );
1158
1159 // RE-REGISTER
1160 // 1) De-register the original graph with the THistSvc
1161 StatusCode sc1 = m_THistSvc->deReg( theGraph );
1162 if (sc1 == StatusCode::FAILURE) allIsOk = false;
1163 // 2) Fix THistSvc->deReg for TGraphs
1164 bool doneCleaning = false;
1165 std::string directoryName = streamNameFunction()->getDirectoryName( this, group, name, true );
1166 TSeqCollection *filelist=gROOT->GetListOfFiles();
1167 for (int i=0; i<filelist->GetEntries(); i++) {
1168 ATH_MSG_DEBUG( "List of files: " << filelist->At(i)->GetName());
1169 TFile* file = static_cast<TFile*>(filelist->At(i));
1170 StatusCode sc2 = THistSvc_deReg_fixTGraph(file, theGraph, directoryName);
1171 if (sc2 == StatusCode::SUCCESS) doneCleaning = true;
1172 }
1173 // 3) Check if TGraph fix has been applied successfully
1174 if (!doneCleaning) {
1175 ATH_MSG_ERROR("THistSvc_deReg_fixTGraph: failed to apply TGraph fix for the THist Svc!");
1176 allIsOk = false;
1177 }
1178 // 4) Register cloned histogram under previous interval streamName
1179 StatusCode sc3 = m_THistSvc->regGraph( streamName, g );
1180 if (sc3 == StatusCode::FAILURE)
1181 allIsOk = false;
1182
1183 // get streamname for interval
1184 streamName = streamNameFunction()->getStreamName( this, group, name, false );
1185 // store metadata
1186 StatusCode smd = registerMetadata(streamName, name, group);
1187 if (smd != StatusCode::SUCCESS) allIsOk = false;
1188 // Re-register the original graph
1189 StatusCode sc4 = m_THistSvc->regGraph( streamName, theGraph );
1190 if (sc4 == StatusCode::FAILURE) allIsOk = false;
1191 }
1192
1193 if (!allIsOk) return StatusCode::FAILURE;
1194 return StatusCode::SUCCESS;
1195}
1196
1197
1198StatusCode
1200regManagedTrees(std::vector< MgmtParams<TTree> >& templateTrees)
1201{
1202 // See the description for the regManagedHistograms method
1203 bool allIsOk = true;
1204
1205 for( std::vector< MgmtParams<TTree> >::iterator it = templateTrees.begin(); it != templateTrees.end(); ++it ) {
1206 MonGroup group = (*it).m_group;
1207
1208 // Get a handle to the original tree
1209 TTree* theTree = (*it).m_templateHist;
1210
1211 // Clone the tree
1212 TTree* t = static_cast<TTree*>(theTree->Clone());
1213 theTree->Reset();
1214
1215 // Dumping the tree
1216 std::string name = t->GetName();
1217
1218 // Get the streamName for the previous interval
1219 std::string streamName = streamNameFunction()->getStreamName( this, group, name, true );
1220
1221 // De-register original tree with the THistSvc
1222 StatusCode sc1 = m_THistSvc->deReg( theTree );
1223 if (sc1 == StatusCode::FAILURE) allIsOk = false;
1224
1225 // Register clonned tree under previous interval streamName
1226 StatusCode sc2 = m_THistSvc->regTree( streamName, t );
1227 if (sc2 == StatusCode::FAILURE) allIsOk = false;
1228
1229 if( m_manager != 0 ) {
1230 std::string genericName = NoOutputStream().getStreamName( this, group, name );
1231 m_manager->passOwnership( t, genericName );
1232 m_manager->writeAndDelete( genericName );
1233 }
1234
1235 // Get streamName for the current interval
1236 streamName = streamNameFunction()->getStreamName( this, group, name, false );
1237 // Register metadata information with the current interval streamname
1238 StatusCode smd = registerMetadata(streamName, name, group);
1239 if (smd != StatusCode::SUCCESS) allIsOk = false;
1240
1241 // Re-register the original graph with the current interval streamName
1242 StatusCode sc3 = m_THistSvc->regTree( streamName, theTree );
1243 if (sc3 == StatusCode::FAILURE) allIsOk = false;
1244
1245 }
1246
1247 if (!allIsOk) return StatusCode::FAILURE;
1248
1249 return StatusCode::SUCCESS;
1250}
1251
1252
1253StatusCode
1255finalHists()
1256{
1257
1258 // This assumes that the end of a file will naturally end a run, which is not always true.
1259 // A merging application run afterwards should be able to put parts of a run together.
1260 if( m_nEvents != 1 ) {
1261 m_d->benchPreProcHistograms();
1262
1263 // Set end flags for the LowStat, LumiBlock and Run variables.
1264 // This is needed to be used in the procHistograms method below.
1265 m_endOfEventsBlock = true;
1266 m_endOfLowStat = true;
1267 m_endOfLumiBlock = true;
1268 m_endOfRun = true;
1269 endOfEventsBlock = true;
1270 endOfLowStat = true;
1271 endOfLumiBlock = true;
1272 endOfRun = true;
1273
1274 StatusCode sc = procHistograms();
1275
1276 m_d->benchPostProcHistograms();
1277 return sc;
1278 }
1279 return StatusCode::SUCCESS;
1280}
1281
1282
1283StatusCode
1286{
1287 if( m_newEventsBlock ) { }
1288 if( m_newLumiBlock ) { }
1289 if( m_newRun ) { }
1290
1291 return StatusCode::SUCCESS;
1292}
1293
1294
1295StatusCode
1298{
1299
1300 return StatusCode::SUCCESS;
1301}
1302
1303StatusCode
1306{
1307 return StatusCode::SUCCESS;
1308}
1309
1310
1311StatusCode
1314{
1315 if( m_endOfEventsBlock ) { }
1316 if( m_endOfLowStat ) { }
1317 if( m_endOfLumiBlock ) { }
1318 if( m_endOfRun) { }
1319
1320 return StatusCode::SUCCESS;
1321}
1322
1323
1324void
1327{
1328 ATH_MSG_DEBUG( "ManagedMonitorToolBase::setMonManager():");
1329 m_manager = manager;
1330 if( m_manager != 0 ) {
1331 ATH_MSG_DEBUG( " --> Setting manager");
1332 m_managerNameProp = m_manager->name();
1333 m_fileKey = m_manager->fileKey();
1334 m_dataType = m_manager->dataType();
1335 m_environment = m_manager->environment();
1336 delete m_streamNameFcn;
1338 }
1339 ATH_MSG_DEBUG( " --> Exiting successfully");
1340}
1341
1342StatusCode
1344regHist( TH1* h, const std::string& system,
1345 Interval_t interval, MgmtAttr_t histo_mgmt, const std::string& chain, const std::string& merge )
1346{
1347 MonGroup group( this, system, interval, histo_mgmt, chain, merge );
1348 return regHist( h, group );
1349}
1350
1351StatusCode
1353regHist( TH1* h, const MonGroup& group )
1354{
1355// ManagedMonitorToolBase_addHistStatistics(this,h);
1356
1357 if (!h)
1358 return StatusCode::FAILURE;
1359
1360 // This part of the code deals with MANAGED type
1361 if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
1362 /*
1363 Create an unmanaged group based on the original MonGroup instance passed
1364 It is needed because managed histogram is presented as a number of unmanaged
1365 histograms (one per each interval)
1366 Update (PUEO) - I don't think it actually matters, and need to keep
1367 track of "proper" attribute for X_VS_LB
1368 */
1369
1370 if (group.histo_mgmt() == ATTRIB_X_VS_LB && group.merge().empty()) {
1371 ATH_MSG_WARNING("HEY! You're attempting to register " << h->GetName() << " as a per-LB histogram, but you're not setting the merge algorithm! This is a SUPER-BAD idea! Use \"merge\", at least.");
1372 }
1373
1374 if (m_supportedIntervalsForRebooking.count(group.interval())) {
1375 m_templateHistograms[group.interval()].push_back( MgmtParams<TH1>(h, group) );
1376 } else {
1377 ATH_MSG_ERROR("Attempt to book managed histogram " << h->GetName() << " with invalid interval type " << intervalEnumToString(group.interval()));
1378 return StatusCode::FAILURE;
1379 }
1380
1381 std::string hName = h->GetName();
1382 MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
1383 std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, hName, false );
1384 registerMetadata(streamName, hName, group).ignore();
1385 return m_THistSvc->regHist( streamName, h );
1386 }
1387
1388 // This part of the code deals with UNMANAGED type
1389 std::string hName = h->GetName();
1390
1391 if( m_manager != 0 ) {
1392 std::string genericName = NoOutputStream().getStreamName( this, group, hName );
1393 m_manager->writeAndDelete( genericName );
1394 m_manager->passOwnership( h, genericName );
1395 }
1396
1397 std::string streamName = streamNameFunction()->getStreamName( this, group, hName, false );
1398
1399 StatusCode smd = registerMetadata(streamName, hName, group);
1400 if (smd != StatusCode::SUCCESS) return StatusCode::FAILURE;
1401
1402 return m_THistSvc->regHist( streamName, h );
1403}
1404
1405
1406StatusCode
1408getHist( TH1*& h, const std::string& hName, const std::string& system,
1409 Interval_t interval )
1410{
1411 MonGroup group( this, system, interval );
1412 return getHist( h, hName, group );
1413}
1414
1415
1416StatusCode
1418getHist( TH1*& h, const std::string& hName, const MonGroup& group )
1419{
1420 std::string streamName = streamNameFunction()->getStreamName( this, group, hName );
1421 return m_THistSvc->getHist( streamName, h );
1422}
1423
1424
1425StatusCode
1427getHist( TH2*& h, const std::string& hName, const std::string& system,
1428 Interval_t interval )
1429{
1430 MonGroup group( this, system, interval );
1431 return getHist( h, hName, group );
1432}
1433
1434
1435StatusCode
1437getHist( TH2*& h, const std::string& hName, const MonGroup& group )
1438{
1439 std::string streamName = streamNameFunction()->getStreamName( this, group, hName );
1440 return m_THistSvc->getHist( streamName, h );
1441}
1442
1443
1444StatusCode ManagedMonitorToolBase::regEfficiency( TEfficiency* e, const MonGroup& group ) {
1445 if (!e)
1446 return StatusCode::FAILURE;
1447
1448 TGraph* g = reinterpret_cast<TGraph*>(e);
1449 std::string name = e->GetName();
1450
1451 // MANAGED
1452 if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
1453 // warn about not using merge algorithms
1454 if (group.histo_mgmt() == ATTRIB_X_VS_LB && group.merge().empty()) {
1455 ATH_MSG_WARNING("HEY! Attempting to register "<<name<<" as a per-LB histogram, but not setting the merge algorithm! Use \"merge\", at least.");
1456 }
1457 // add the efficiency to rebooking vector
1458 if (m_supportedIntervalsForRebooking.count(group.interval())) {
1459 m_templateEfficiencies[group.interval()].push_back( MgmtParams<TEfficiency>(e, group) );
1460 } else {
1461 ATH_MSG_ERROR("Attempt to book managed graph " << name << " with invalid interval type " << intervalEnumToString(group.interval()));
1462 return StatusCode::FAILURE;
1463 }
1464
1465 MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
1466 std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, name, false );
1467 registerMetadata(streamName, name, group).ignore();
1468 return m_THistSvc->regGraph( streamName, g );
1469 } else {
1470 // UNMANAGED
1471 if( m_manager != 0 ) {
1472 std::string genericName = NoOutputStream().getStreamName( this, group, name );
1473 m_manager->writeAndDelete( genericName );
1474 m_manager->passOwnership( e, genericName );
1475 }
1476
1477 std::string streamName = streamNameFunction()->getStreamName( this, group, name, false );
1478 StatusCode smd = registerMetadata(streamName, name, group);
1479 if (smd != StatusCode::SUCCESS)
1480 return StatusCode::FAILURE;
1481
1482 return m_THistSvc->regGraph( streamName, g );
1483 }
1484}
1485
1486
1487StatusCode
1489regGraph( TGraph* g, const std::string& system,
1490 Interval_t interval, MgmtAttr_t histo_mgmt, const std::string& chain, const std::string& merge )
1491{
1492 MonGroup group( this, system, interval, histo_mgmt, chain, merge );
1493 return regGraph( g, group );
1494}
1495
1496
1497StatusCode
1499regGraph( TGraph* g, const MonGroup& group )
1500{
1501 if (!g)
1502 return StatusCode::FAILURE;
1503
1504 // This part of the code deals with MANAGED type
1505 if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
1506 // Create an unmanaged group based on the original MonGroup instance passed
1507 // This is needed because managed graph is presented as a number of unmanaged
1508 // graphs (one per each interval)
1509 MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
1510
1511 if (m_supportedIntervalsForRebooking.count(group.interval())) {
1512 m_templateGraphs[group.interval()].push_back( MgmtParams<TGraph>(g, group_unmanaged) );
1513 } else {
1514 ATH_MSG_ERROR("Attempt to book managed graph " << g->GetName() << " with invalid interval type " << intervalEnumToString(group.interval()));
1515 return StatusCode::FAILURE;
1516 }
1517
1518 std::string name = g->GetName();
1519 std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, name, false );
1520 registerMetadata(streamName, name, group).ignore();
1521 return m_THistSvc->regGraph( streamName, g );
1522 //return m_THistSvc->regGraph( streamName );
1523 }
1524
1525 // This part of the code deals with UNMANAGED type
1526 std::string gName = g->GetName();
1527
1528 if( m_manager != 0 ) {
1529 std::string genericName = NoOutputStream().getStreamName( this, group, gName );
1530 m_manager->writeAndDelete( genericName );
1531 m_manager->passOwnership( g, genericName );
1532 }
1533
1534 std::string streamName = streamNameFunction()->getStreamName( this, group, gName, false );
1535
1536 StatusCode smd = registerMetadata(streamName, gName, group);
1537 if (smd != StatusCode::SUCCESS) return StatusCode::FAILURE;
1538
1539 return m_THistSvc->regGraph( streamName, g );
1540}
1541
1542
1543StatusCode
1545regTree( TTree* t, const std::string& system,
1546 Interval_t interval, MgmtAttr_t histo_mgmt, const std::string& chain, const std::string& merge )
1547{
1548 MonGroup group( this, system, interval, histo_mgmt, chain, merge );
1549 return regTree( t, group );
1550}
1551
1552
1553StatusCode
1555regTree( TTree* t, const MonGroup& group )
1556{
1557
1558 // This part of the code deals with MANAGED type
1559 if ( group.histo_mgmt() != ATTRIB_UNMANAGED ) {
1560 // Create an unmanaged group based on the original MonGroup instance passed
1561 // This is needed because managed tree is presented as a number of unmanaged
1562 // trees (one per each interval)
1563 MonGroup group_unmanaged( this, group.system(), group.interval(), ATTRIB_UNMANAGED, group.chain(), group.merge());
1564
1565 if (m_supportedIntervalsForRebooking.count(group.interval())) {
1566 m_templateTrees[group.interval()].push_back( MgmtParams<TTree>(t, group_unmanaged) );
1567 } else {
1568 ATH_MSG_ERROR("Attempt to book managed tree " << t->GetName() << " with invalid interval type " << intervalEnumToString(group.interval()));
1569 return StatusCode::FAILURE;
1570 }
1571
1572 std::string name = t->GetName();
1573 std::string genericName = NoOutputStream().getStreamName( this, group_unmanaged, name );
1574 std::string streamName = streamNameFunction()->getStreamName( this, group_unmanaged, name, false );
1575 registerMetadata(streamName, name, group).ignore();
1576 return m_THistSvc->regTree( streamName, t );
1577 }
1578
1579
1580 // This part of the code deals with UNMANAGED type
1581 std::string tName = t->GetName();
1582
1583 if( m_manager != 0 ) {
1584 std::string genericName = NoOutputStream().getStreamName( this, group, tName );
1585 m_manager->writeAndDelete( genericName );
1586 m_manager->passOwnership( t, genericName );
1587 }
1588
1589 std::string streamName = streamNameFunction()->getStreamName( this, group, tName, false );
1590
1591 StatusCode smd = registerMetadata(streamName, tName, group);
1592 if (smd != StatusCode::SUCCESS) return StatusCode::FAILURE;
1593
1594 return m_THistSvc->regTree( streamName, t );
1595}
1596
1597
1598StatusCode
1600writeAndDelete( TH1* h, const MonGroup& group ) {
1601 if (!h)
1602 return StatusCode::FAILURE;
1603
1604 std::string hName = h->GetName();
1605
1606 if( m_manager != 0 ) {
1607 std::string genericName = NoOutputStream().getStreamName( this, group, hName );
1608 m_manager->writeAndDelete( genericName );
1609 }
1610 return StatusCode::SUCCESS;
1611}
1612
1613
1614StatusCode
1616deregHist( TH1* h )
1617{
1618 return m_THistSvc->deReg( h );
1619}
1620
1621
1622StatusCode
1624deregGraph( TGraph* g )
1625{
1626 return m_THistSvc->deReg( g );
1627}
1628
1629
1630StatusCode
1632deregObject( const std::string& objName, const std::string& system,
1633 Interval_t interval )
1634{
1635 MonGroup group( this, system, interval );
1636 return deregObject( objName, group );
1637}
1638
1639
1640StatusCode
1642deregObject( const std::string& objName, const MonGroup& group )
1643{
1644 std::string streamName = streamNameFunction()->getStreamName( this, group, objName );
1645 return m_THistSvc->deReg( streamName );
1646}
1647
1648
1649StatusCode
1651setupOutputStreams( std::vector<std::string> )
1652{
1653 // All instances should write to the stream(s) defined by the
1654 // AthenaMonManager.
1655
1656 return StatusCode::SUCCESS;
1657}
1658
1659
1660StatusCode
1662runStat()
1663{
1664 return StatusCode::SUCCESS;
1665}
1666
1667
1668StatusCode
1670checkHists( bool )
1671{
1672 // Histograms will be checked using the data-quality monitoring framework (DQMF)
1673
1674 return StatusCode::SUCCESS;
1675}
1676
1677
1678bool
1681{
1682 if( m_preScaleProp > 1 ) {
1683 return ( (m_nEvents % m_preScaleProp) == 1 );
1684 }
1685 return true;
1686}
1687
1688
1689// Average mu, i.e. <mu>
1690float
1692lbAverageInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1693{
1694 if (!m_lumiDataKey.empty()) {
1696 return lumi->lbAverageInteractionsPerCrossing();
1697 } else {
1698 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageInteractionsPerCrossing() can't work properly! ");
1699 ATH_MSG_DEBUG("Warning: lbAverageInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1700 return -1.0;
1701 }
1702 // not reached
1703}
1704
1705// Instantaneous number of interactions, i.e. mu
1706float
1708lbInteractionsPerCrossing (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1709{
1710 if (!m_lumiDataKey.empty()) {
1712 float muToLumi = lumi->muToLumi();
1713 if (muToLumi > 0) {
1714 return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id()) / muToLumi;
1715 }
1716 return 0;
1717 } else {
1718 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbInteractionsPerCrossing() can't work properly! ");
1719 ATH_MSG_DEBUG("Warning: lbInteractionsPerCrossing() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1720 return -1.0;
1721 }
1722 // not reached
1723}
1724
1725// Average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1)
1726float
1728lbAverageLuminosity (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1729{
1730 if (!m_lumiDataKey.empty()) {
1732 return lumi->lbAverageLuminosity();
1733 } else {
1734 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageLuminosity() can't work properly! ");
1735 ATH_MSG_DEBUG("Warning: lbAverageLuminosity() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1736 return -1.0;
1737 }
1738 // not reached
1739}
1740
1741// Instantaneous luminosity
1742float
1744lbLuminosityPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1745{
1746 if (!m_lumiDataKey.empty()) {
1748 return lumi->lbLuminosityPerBCIDVector().at (ctx.eventID().bunch_crossing_id());
1749 } else {
1750 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbLuminosityPerBCID() can't work properly! ");
1751 ATH_MSG_DEBUG("Warning: lbLuminosityPerBCID() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1752 return -1.0;
1753 }
1754 // not reached
1755}
1756
1757
1758// Average luminosity livefraction
1759float
1761lbAverageLivefraction (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1762{
1764 return 1.0;
1765
1766 if (!m_trigLiveFractionDataKey.empty()) {
1768 return live->lbAverageLiveFraction();
1769 } else {
1770 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbAverageLivefraction() can't work properly! ");
1771 ATH_MSG_DEBUG("Warning: lbAverageLivefraction() - luminosity not availble (i.e. EnableLumi = False)");
1772 return -1.0;
1773 }
1774 // not reached
1775}
1776
1777// Live Fraction per Bunch Crossing ID
1778float
1780livefractionPerBCID (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1781{
1783 return 1.0;
1784
1785 if (!m_trigLiveFractionDataKey.empty()) {
1787 return live->l1LiveFractionVector().at (ctx.eventID().bunch_crossing_id());
1788 } else {
1789 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! livefractionPerBCID() can't work properly! ");
1790 ATH_MSG_DEBUG("Warning: livefractionPerBCID() - luminosity retrieved available (i.e. EnableLumi = False)");
1791 return -1.0;
1792 }
1793 // not reached
1794}
1795
1796// Average Integrated Luminosity Live Fraction
1797double
1799lbLumiWeight (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1800{
1801 if (!m_lumiDataKey.empty()) {
1803 } else{
1804 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbLumiWeight() can't work properly! ");
1805 ATH_MSG_DEBUG("Warning: lbLumiWeight() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1806 return -1.0;
1807 }
1808 // not reached
1809}
1810
1811
1812// Luminosity block time (in seconds)
1813double
1815lbDuration (const EventContext& ctx /*= Gaudi::Hive::currentContext()*/) const
1816{
1818 return m_defaultLBDuration;
1819 }
1820 if (!m_lbDurationDataKey.empty()) {
1822 return dur->lbDuration();
1823 } else {
1824 //ATH_MSG_FATAL("! Luminosity tool has been disabled ! lbDuration() can't work properly! ");
1825 ATH_MSG_DEBUG("Warning: lbDuration() - luminosity tools are not retrieved or turned on (i.e. EnableLumi = False)");
1826 return m_defaultLBDuration;
1827 }
1828 // not reached
1829}
1830
1831
1832// *********************************************************************
1833// Protected Methods
1834// *********************************************************************
1835
1837 OutputMetadata( TTree* metadata )
1838 : m_charArrSize(100)
1839 , m_metadata(metadata)
1840 , m_nameData(0)
1841 //, m_levelData(0)
1842 , m_intervalData(0)
1843 , m_triggerData(0)
1844 , m_mergeData(0)
1845{
1846 m_nameData = new char[m_charArrSize];
1847 //m_levelData = new char[m_charArrSize];
1848 m_intervalData = new char[m_charArrSize];
1849 m_triggerData = new char[m_charArrSize];
1850 m_mergeData = new char[m_charArrSize];
1851 m_metadata->Branch( "Name", m_nameData, "Name/C" );
1852 //m_metadata->Branch( "LevelOfDetail", m_levelData, "LevelOfDetail/C" );
1853 m_metadata->Branch( "Interval", m_intervalData, "Interval/C" );
1854 m_metadata->Branch( "TriggerChain", m_triggerData, "TriggerChain/C" );
1855 m_metadata->Branch( "MergeMethod", m_mergeData, "MergeMethod/C" );
1856}
1857
1858
1861{
1862 delete [] m_mergeData;
1863 delete [] m_triggerData;
1864 delete [] m_intervalData;
1865 //delete [] m_levelData;
1866 delete [] m_nameData;
1867}
1868
1869
1870void
1872fill( const std::string& name,
1873 //LevelOfDetail_t level,
1874 Interval_t interval,
1875 std::string trigger,
1876 std::string merge )
1877{
1878 // ROOT does not properly write empty strings to output files in all cases. I haven't reported
1879 // this to the ROOT developers yet because I don't have time to develope a simple test case
1880 // for them (independent of Atlas software).
1881 // --M.G.Wilson, 7 July 2008
1882 if( trigger.empty() )
1883 trigger = "<none>";
1884 if( merge.empty() )
1885 merge = "<default>";
1886
1887 copyString( m_nameData, name );
1888 //copyString( m_levelData, ManagedMonitorToolBase::levelOfDetailEnumToString( level ) );
1890 copyString( m_triggerData, trigger );
1892 m_metadata->Fill();
1893}
1894
1895
1896void
1898copyString( char* to, const std::string& from )
1899{
1900 int i = 0;
1901 const char* f = from.c_str();
1902 while( (++i < m_charArrSize) && ((*to++ = *f++) != 0) ) {};
1903 if( i == m_charArrSize ) {
1904 *to = 0;
1905 }
1906}
1907
1908
1909std::string
1911getStreamName( const ManagedMonitorToolBase*, const MonGroup& group, const std::string& objName, bool )
1912{
1913 std::ostringstream streamName;
1914
1915 streamName << "/" << m_fileKey << "/";
1916
1917 streamName << group.system() << "/" << objName;
1918 return streamName.str();
1919}
1920
1921std::string
1923getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, const bool usePreviousInterval )
1924{
1925 std::string streamName = getStreamName(tool, group, objName, usePreviousInterval);
1926 std::string root, rem;
1927 parseString(streamName, root, rem);
1928 // Remove object name at the end
1929 // to obtain directory path
1930 rem.erase(rem.rfind('/'), rem.length());
1931 return rem;
1932}
1933
1934
1935std::string
1937getStreamName( const ManagedMonitorToolBase*, const MonGroup& group, const std::string& objName, bool )
1938{
1939 std::ostringstream streamName;
1940 streamName << group.system() << "/" << objName;
1941 return streamName.str();
1942}
1943
1944
1945std::string
1947getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, const bool usePreviousInterval )
1948{
1949 return getStreamName(tool, group, objName, usePreviousInterval);
1950}
1951
1952std::string
1954getStreamName( const ManagedMonitorToolBase*, const MonGroup& group, const std::string& objName, bool )
1955{
1956 std::ostringstream streamName;
1957 //if( group.level() != ManagedMonitorToolBase::transient ) {
1958 // streamName << "/" << ManagedMonitorToolBase::levelOfDetailEnumToString( group.level(), true ) << "/";
1959 //}
1960 streamName << "/"; // slash is required for online environment;
1961 // otherwise the output histograms are placed in 'temp' subdirectory
1962
1963 streamName << group.system() << "/" << objName;
1964 return streamName.str();
1965}
1966
1967std::string
1969getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, const bool usePreviousInterval )
1970{
1971 return getStreamName(tool, group, objName, usePreviousInterval);
1972}
1973
1974void
1976getLBrange(int *start, int *end, int LB, int length) {
1977 if(start && end) {
1978 *start = ((LB-1)/length) * length + 1;
1979 *end = *start + length - 1;
1980 }
1981}
1982
1983std::string
1985getStreamName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, bool usePreviousInterval )
1986{
1987 std::ostringstream streamName;
1988
1989 //bool isTemp = ( group.level() == ManagedMonitorToolBase::transient );
1990 bool isTemp = false;
1991
1992 bool useRunFolders = group.interval() != all;
1993
1994 bool useLBFolders = ( useRunFolders )
1995 && ( group.interval() == ManagedMonitorToolBase::lumiBlock );
1996
1997 bool useLowStatInterval = ( useRunFolders )
1998 && ( group.interval() == ManagedMonitorToolBase::lowStat );
1999
2000 bool useMedStatInterval = ( useRunFolders )
2001 && ( group.interval() == ManagedMonitorToolBase::medStat );
2002
2003 bool useHigStatInterval = ( useRunFolders )
2004 && ( group.interval() == ManagedMonitorToolBase::higStat );
2005
2006 bool useEBFolders = ( group.interval() == ManagedMonitorToolBase::eventsBlock );
2007
2008 if( !isTemp ) {
2009 streamName << "/" << m_fileKey << "/";
2010 }
2011
2012 if( useRunFolders ) {
2013 if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::run) )
2014 streamName << "run_" << m_prev_run_number << "/";
2015 else
2016 streamName << "run_" << AthenaMonManager::runNumber() << "/";
2017 }
2018
2019 int currentLB = AthenaMonManager::lumiBlockNumber();
2020 if( useLBFolders ) {
2021 if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::lumiBlock) )
2022 streamName << "lb_" << m_prev_lumi_block << "/";
2023 else
2024 streamName << "lb_" << currentLB << "/";
2025 }
2026 else if( useLowStatInterval ) {
2027 int start, end;
2028 if (usePreviousInterval && (group.interval() == ManagedMonitorToolBase::lowStat) )
2030 else
2031 getLBrange(&start, &end, currentLB, AthenaMonManager::getLBsLowStat());
2032 streamName << "lowStat_LB" << start << "-" << end << "/";
2033 }
2034 else if( useMedStatInterval ) {
2035 int start, end;
2036 getLBrange(&start, &end, currentLB, AthenaMonManager::getLBsMedStat());
2037 streamName << "medStat_LB" << start << "-" << end << "/";
2038 }
2039 else if( useHigStatInterval ) {
2040 int start, end;
2041 getLBrange(&start, &end, currentLB, AthenaMonManager::getLBsHigStat());
2042 streamName << "higStat_LB" << start << "-" << end << "/";
2043 }
2044 else if( useEBFolders ) {
2045 // The number of events in an EventsBlock can vary for each ManagedMonitorToolBase object,
2046 // so there is no global way to determine when an EventsBlock has rolled over.
2047
2048 // determine an eventsBlock number
2049 long eventsBlockNumber = 1; // assign some dafault value
2050 long procNEventsProp = tool->get_procNEventsProp();
2051 unsigned int nEvents = tool->get_nEvents();
2052 if (procNEventsProp > 0) {
2053 eventsBlockNumber = (long) nEvents / procNEventsProp;
2054 if ((nEvents % procNEventsProp) != 0)
2055 eventsBlockNumber++;
2056 }
2057
2058 // lower eventsBlock number by 1 if usePreviousInterval is true;
2059 if (usePreviousInterval) {
2060 eventsBlockNumber--;
2061 }
2062
2063 streamName << "eb_" << eventsBlockNumber << "/";
2064 }
2065
2066 streamName << group.system() << "/" << objName;
2067
2068 return streamName.str();
2069}
2070
2071std::string
2073getDirectoryName( const ManagedMonitorToolBase* tool, const MonGroup& group, const std::string& objName, const bool usePreviousInterval )
2074{
2075 std::string streamName = getStreamName(tool, group, objName, usePreviousInterval);
2076 std::string root, rem;
2077 parseString(streamName, root, rem);
2078 // Remove object name at the end
2079 // to obtain directory path
2080 rem.erase(rem.rfind('/'), rem.length());
2081 return rem;
2082}
2083
2084void
2090
2091bool
2093trigChainsArePassed(std::vector<std::string>& vTrigNames)
2094{
2095 ATH_MSG_DEBUG( "ManagedMonitorToolBase::trigChainsArePassed:");
2096
2097 for(unsigned int i=0; i<vTrigNames.size(); i++) {
2098 if( m_trigDecTool->isPassed(vTrigNames[i]) ) {
2099 ATH_MSG_DEBUG( " + \"" << vTrigNames[i] << "\" passed, returning \'true\'");
2100 return true;
2101 }
2102 else {
2103 ATH_MSG_DEBUG( " - \"" << vTrigNames[i] << "\" did not pass");
2104 }
2105 }
2106
2107 return false;
2108}
2109
2110StatusCode
2112parseList(const std::string& line, std::vector<std::string>& result) {
2113 std::string item;
2114 std::stringstream ss(line);
2115
2116 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "ManagedMonitorToolBase::parseList:";
2117
2118 while ( std::getline(ss, item, ',') ) {
2119 std::stringstream iss(item); // remove
2120 iss >> item; // whitespace
2121 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " " << item;
2122 result.push_back(item);
2123 }
2124
2125 msg(MSG::DEBUG) << endmsg;
2126 return StatusCode::SUCCESS;
2127}
2128
2129void
2131updateTriggersForGroups(std::vector<std::string>& vTrigChainNames) {
2132 for (size_t i = 0; i < vTrigChainNames.size(); ++i) {
2133 std::string& thisName = vTrigChainNames[i];
2134 if (thisName.compare(0, 9, "CATEGORY_") ==0) {
2135 ATH_MSG_DEBUG("Found a trigger category: " << thisName << ". We will unpack it.");
2136 std::vector<std::string> triggers = m_trigTranslator->translate(thisName.substr(9,std::string::npos));
2137 std::ostringstream oss;
2138 oss << "(";
2139 for (size_t itrig = 0; itrig < triggers.size(); ++itrig) {
2140 if (itrig != 0) {
2141 oss << "|";
2142 }
2143 oss << triggers[itrig];
2144 }
2145 oss << ")";
2146 // replace with new value
2147 std::string newval = oss.str();
2148 ATH_MSG_DEBUG("Replaced with " << newval);
2149 vTrigChainNames[i] = std::move(newval);
2150 }
2151 }
2152}
2153
2156getNewStreamNameFcn() const
2157{
2158 StreamNameFcn* fcn(0);
2159
2160 switch( m_environment ) {
2162 fcn = new NoOutputStream();
2163 break;
2165 fcn = new OnlineStream();
2166 break;
2168 fcn = new DefaultStream( m_fileKey );
2169 break;
2175 default:
2177 }
2178
2179 return fcn;
2180}
2181
2182void
2184parseString(const std::string& streamName, std::string& root, std::string& rem) {
2185 std::string::size_type pos = streamName.find('/');
2186
2187 if (pos == std::string::npos) {
2188 root = "";
2189 rem = streamName;
2190 return;
2191 }
2192
2193 if (pos == 0) {
2194 parseString(streamName.substr(1,streamName.length()),root,rem);
2195 } else {
2196 root = streamName.substr(0,pos);
2197 rem = streamName.substr(pos+1,streamName.length());
2198 }
2199
2200}
2201
2202// *********************************************************************
2203// Private Methods
2204// *********************************************************************
2205
2206// GlobalDirectoryRestore ctor
2210 m_gd = gDirectory;
2211 m_gf = gFile;
2212}
2213
2214// GlobalDirectoryRestore dtor
2218 gDirectory = m_gd;
2219 gFile = m_gf;
2220}
2221
2222namespace {
2223
2224 std::string strToLower( const std::string& str )
2225 {
2226 std::string lstr(str);
2227 std::string::const_iterator from = str.begin();
2228 std::string::const_iterator strend = str.end();
2229 std::string::iterator to = lstr.begin();
2230 while( from != strend ) {
2231 *to++ = tolower(*from++);
2232 }
2233 return lstr;
2234 }
2235
2236
2237#if 0
2238 std::string strToUpper( const std::string& str )
2239 {
2240 std::string ustr(str);
2241 std::string::const_iterator from = str.begin();
2242 std::string::const_iterator strend = str.end();
2243 std::string::iterator to = ustr.begin();
2244 while( from != strend ) {
2245 *to++ = toupper(*from++);
2246 }
2247 return ustr;
2248 }
2249#endif
2250
2251} // unnamed namespace
2252
2253#endif
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
void tolower(std::string &s)
double length(const pvec &v)
static Double_t ss
static Double_t tc
static Double_t sc
static std::atomic< unsigned > s_mmtb_mongroup_ncopies
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Header file for AthHistogramAlgorithm.
static const MSG::Level s_resourceMonThreshold
Definition AthMonBench.h:28
An Algorithm that manages a set of modules, each inheriting from ManagedMonitorToolBase,...
static unsigned int getLBsLowStat()
static Environment_t envStringToEnum(const std::string &str)
Converts a string to an Environment_t of the same name.
static DataType_t dataTypeStringToEnum(const std::string &str)
Converts a string to a DataType_t of the same name.
static unsigned int getLBsHigStat()
static unsigned int getLBsMedStat()
static unsigned int lumiBlockNumber()
static unsigned int runNumber()
virtual std::string getStreamName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, bool usePreviousInterval=false)
A function that converts a MonGroup of logical parameters into a physical output stream name.
virtual std::string getDirectoryName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, const bool usePreviousInterval)
A function that returns TDirectory path in a file that corresponds to a given MonGroup and object nam...
ManagedMonitorToolBase * m_theclass
static std::atomic< ISvcLocator * > s_svcLocator
Imp(ManagedMonitorToolBase *tc)
A container of information describing a monitoring object.
StatusCode deregHist(TH1 *h)
De-registers a TH1 from the THistSvc, but does NOT delete the object.
StatusCode getHist(TH1 *&h, const std::string &hName)
Returns a TH1 via the pointer passed as the first argument.
StatusCode regHist(TH1 *h)
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
StatusCode deregObject(const std::string &objName)
De-registers a TObject from the THistSvc, but does NOT delete the object.
StatusCode writeAndDelete(TH1 *h)
Write and delete a histogram.
StatusCode deregAll()
De-registers all TH1 objects from the THistSvc, but does NOT delete the objects.
StatusCode regEfficiency(TEfficiency *e)
Registers a TEfficiency to be included in the output stream.
StatusCode regGraph(TGraph *g)
Registers a TGraph to be included in the output stream using logical parameters that describe the his...
StatusCode deregGraph(TGraph *g)
De-registers a TGraph from the THistSvc, but does NOT delete the object.
StatusCode regTree(TTree *t)
Registers a TTree to be included in the output stream using logical parameters that describe the hist...
virtual std::string getDirectoryName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, const bool usePreviousInterval)
A function that returns TDirectory path in a file that corresponds to a given MonGroup and object nam...
virtual std::string getStreamName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, bool usePreviousInterval=false)
A function that converts a MonGroup of logical parameters into a physical output stream name.
virtual std::string getDirectoryName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, const bool usePreviousInterval)
A function that returns TDirectory path in a file that corresponds to a given MonGroup and object nam...
virtual std::string getStreamName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, bool usePreviousInterval=false)
A function that converts a MonGroup of logical parameters into a physical output stream name.
virtual std::string getDirectoryName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, const bool usePreviousInterval)
A function that returns TDirectory path in a file that corresponds to a given MonGroup and object nam...
virtual std::string getStreamName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, bool usePreviousInterval=false)
A function that converts a MonGroup of logical parameters into a physical output stream name.
virtual void fill(const std::string &name, Interval_t interval, std::string trigger, std::string merge)
void copyString(char *to, const std::string &from)
A function-object base class allowing the specific implementation of getStreamName to be decided at r...
static void parseString(const std::string &streamName, std::string &root, std::string &rem)
A helper non-virtual function, parses id string.
virtual std::string getStreamName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, bool usePreviousInterval=false)=0
A function that converts a MonGroup of logical parameters into a physical output stream name.
virtual std::string getDirectoryName(const ManagedMonitorToolBase *tool, const MonGroup &group, const std::string &objName, const bool usePreviousInterval)=0
A function that returns TDirectory path in a file that corresponds to a given MonGroup and object nam...
SG::ReadCondHandleKey< LuminosityCondData > m_lumiDataKey
virtual StatusCode regHist(TH1 *h, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TH1 (including TH2, TH3, and TProfile) to be included in the output stream using logical ...
StatusCode regManagedTrees(std::vector< MgmtParams< TTree > > &templateTrees)
virtual StatusCode writeAndDelete(TH1 *h, const MonGroup &group)
Write out histogram and delete it.
ToolHandleArray< IDQFilterTool > m_DQFilterTools
virtual StatusCode setupOutputStreams(std::vector< std::string > Mapping=std::vector< std::string >())
This implementation does nothing—streams in this class should be managed by the AthenaMonManager.
virtual StatusCode deregHist(TH1 *h)
De-registers a TH1 from the THistSvc, but does NOT delete the object.
virtual StatusCode deregGraph(TGraph *g)
De-registers a TGraph from the THistSvc, but does NOT delete the object.
virtual float lbInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Instantaneous number of interactions, i.e.
StatusCode parseList(const std::string &, std::vector< std::string > &)
SG::ReadCondHandleKey< TrigLiveFractionCondData > m_trigLiveFractionDataKey
virtual StatusCode bookHistogramsRecurrent()
An inheriting class should either override this function, bookHists() or bookHistograms().
std::set< Interval_t > m_supportedIntervalsForRebooking
virtual float lbAverageLivefraction(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Average luminosity livefraction.
StatusCode THistSvc_deReg_fixTGraph(TFile *file, TGraph *theGraph, std::string &directoryName)
Fixes THistSvc->deReg(obj) when obj is TGraph instance.
std::vector< std::string > m_vTrigGroupNames
virtual StatusCode deregObject(const std::string &objName, const std::string &system, Interval_t interval)
De-registers a TObject from the THistSvc, but does NOT delete the object.
std::map< Interval_t, std::vector< MgmtParams< TH1 > > > m_templateHistograms
virtual StatusCode fillHistograms()
An inheriting class should either override this function or fillHists().
Interval_t
An enumeration describing how detailed a particular monitoring object is.
virtual StatusCode fillHists()
Calls fillHists( bool, bool, bool ); if an eventBlock,lumiBlock, or run has turned over,...
PublicToolHandle< Trig::ITrigDecisionTool > m_trigDecTool
StatusCode regManagedGraphs(std::vector< MgmtParams< TGraph > > &templateGraphs)
std::map< Interval_t, std::vector< MgmtParams< TGraph > > > m_templateGraphs
ServiceHandle< ITHistSvc > m_THistSvc
virtual float lbAverageLuminosity(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Average luminosity (in ub-1 s-1 => 10^30 cm-2 s-1)
PublicToolHandle< ITriggerTranslatorTool > m_trigTranslator
virtual StatusCode bookHists()
Calls bookHists( true, true, true ) and initializes lumiBlock and run numbers.
virtual StatusCode regTree(TTree *t, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TTree to be included in the output stream using logical parameters that describe it.
virtual StatusCode bookHistograms()
An inheriting class should either override this function or bookHists().
virtual StatusCode getHist(TH1 *&h, const std::string &hName, const std::string &system, Interval_t interval)
Returns a TH1 via the pointer passed as the first argument.
virtual float lbLuminosityPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Instantaneous luminosity.
ManagedMonitorToolBase(const std::string &type, const std::string &name, const IInterface *parent)
virtual float livefractionPerBCID(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Livefraction per bunch crossing ID.
SG::ReadCondHandleKey< LBDurationCondData > m_lbDurationDataKey
AthenaMonManager::Environment_t m_environment
StatusCode regManagedEfficiencies(std::vector< MgmtParams< TEfficiency > > &templateEfficiencies)
StatusCode registerMetadata(const std::string &streamName, const std::string &hName, const MonGroup &group)
MgmtAttr_t
An enumeration describing how the class handles the histogram.
virtual float lbAverageInteractionsPerCrossing(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Average mu, i.e.
virtual double lbLumiWeight(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Average Integrated Luminosity Live Fraction.
virtual StatusCode regGraph(TGraph *g, const std::string &system, Interval_t interval, MgmtAttr_t histo_mgmt=ATTRIB_MANAGED, const std::string &chain="", const std::string &merge="")
Registers a TGraph to be included in the output stream using logical parameters that describe the gra...
static Interval_t intervalStringToEnum(const std::string &str)
Converts a string to the corresponding Interval_t.
std::vector< std::string > m_vTrigChainNames
std::map< Interval_t, std::vector< MgmtParams< TTree > > > m_templateTrees
static std::string intervalEnumToString(Interval_t interval)
Converts a LevelOfDetail_t to a string of the same name.
virtual StatusCode finalHists()
Calls procHists( true, true, true ).
virtual void setMonManager(AthenaMonManager *manager)
Takes a pointer to a managing object to get information from it when needed.
virtual double lbDuration(const EventContext &ctx=Gaudi::Hive::currentContext()) const
Luminosity block time (in seconds)
virtual StreamNameFcn * getNewStreamNameFcn() const
virtual StatusCode checkHists(bool calledFromFinalize)
This implementation does nothing; equivalent functionality may be provided by procHists(....
virtual StreamNameFcn * streamNameFunction()
Returns the function object that converts logical paramters into a physical stream name.
void updateTriggersForGroups(std::vector< std::string > &)
AthenaMonManager::DataType_t m_dataType
virtual StatusCode runStat()
This implementation does nothing; equivalent functionality may be provided by procHists( true,...
virtual StatusCode regEfficiency(TEfficiency *e, const MonGroup &group)
Registers a TEfficiency to be included in the output stream using logical parameters that describe th...
std::map< Interval_t, std::vector< MgmtParams< TEfficiency > > > m_templateEfficiencies
virtual StatusCode procHistograms()
An inheriting class should either override this function or finalHists().
StatusCode regManagedHistograms(std::vector< MgmtParams< TH1 > > &templateHistograms)
virtual bool trigChainsArePassed(std::vector< std::string > &)
const int nEvents
CONT to(RANGE &&r)
Definition ranges.h:39
Definition merge.py:1
Definition run.py:1