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