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