ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
TrigSignatureMoni::RateHistogram Class Reference
Collaboration diagram for TrigSignatureMoni::RateHistogram:

Public Member Functions

 RateHistogram ()=default
 
 ~RateHistogram ()
 
StatusCode init (const std::string &histoName, const std::string &histoTitle, const int x, const int y, const std::string &registerPath, const ServiceHandle< ITHistSvc > &histSvc)
 
LockedHandle< TH2 > &getHistogram ATLAS_NOT_CONST_THREAD_SAFE () const
 
LockedHandle< TH2 > &getBuffer ATLAS_NOT_CONST_THREAD_SAFE () const
 
std::unique_ptr< Athena::AlgorithmTimer > & getTimer ()
 
void startTimer (unsigned int duration, unsigned int intervals)
 
void stopTimer ()
 
void fill (const double x, const double y) const
 

Private Member Functions

void updatePublished (unsigned int duration) const
 
void callback ()
 

Private Attributes

LockedHandle< TH2 > m_bufferHistogram ATLAS_THREAD_SAFE
 
LockedHandle< TH2 > m_histogram ATLAS_THREAD_SAFE
 
std::mutex m_mutex
 
std::unique_ptr< Athena::AlgorithmTimerm_timer
 
std::unique_ptr< TimeDividerm_timeDivider
 
unsigned int m_duration {0}
 

Detailed Description

Definition at line 50 of file TrigSignatureMoni.h.

Constructor & Destructor Documentation

◆ RateHistogram()

TrigSignatureMoni::RateHistogram::RateHistogram ( )
default

◆ ~RateHistogram()

TrigSignatureMoni::RateHistogram::~RateHistogram ( )

Definition at line 498 of file TrigSignatureMoni.cxx.

498  {
499  delete m_bufferHistogram.get();
500 }

Member Function Documentation

◆ ATLAS_NOT_CONST_THREAD_SAFE() [1/2]

LockedHandle<TH2>& getHistogram TrigSignatureMoni::RateHistogram::ATLAS_NOT_CONST_THREAD_SAFE ( ) const

◆ ATLAS_NOT_CONST_THREAD_SAFE() [2/2]

LockedHandle<TH2>& getBuffer TrigSignatureMoni::RateHistogram::ATLAS_NOT_CONST_THREAD_SAFE ( ) const

◆ callback()

void TrigSignatureMoni::RateHistogram::callback ( )
private

Definition at line 554 of file TrigSignatureMoni.cxx.

554  {
555  // Ask time divider if we need to switch to new interval
556  time_t t = time(0);
557  unsigned int newinterval;
558  unsigned int oldinterval;
559 
560  if (m_timeDivider->isPassed(t, newinterval, oldinterval)) {
562  }
563 
564  // Schedule itself in another 1/20 of the integration period in milliseconds
565  if (m_timer) m_timer->start(m_duration*50);
566 }

◆ fill()

void TrigSignatureMoni::RateHistogram::fill ( const double  x,
const double  y 
) const

Definition at line 526 of file TrigSignatureMoni.cxx.

526  {
527  m_bufferHistogram->Fill(x, y);
528 }

◆ getTimer()

std::unique_ptr< Athena::AlgorithmTimer > & TrigSignatureMoni::RateHistogram::getTimer ( )

Definition at line 522 of file TrigSignatureMoni.cxx.

522  {
523  return m_timer;
524 }

◆ init()

StatusCode TrigSignatureMoni::RateHistogram::init ( const std::string &  histoName,
const std::string &  histoTitle,
const int  x,
const int  y,
const std::string &  registerPath,
const ServiceHandle< ITHistSvc > &  histSvc 
)

Definition at line 502 of file TrigSignatureMoni.cxx.

503  {
504  std::unique_ptr<TH2> h = std::make_unique<TH2F>(histoName.c_str(), histoTitle.c_str(), x, 1, x + 1, y, 1, y + 1);
505  ATH_CHECK( histSvc->regShared( registerPath.c_str(), std::move(h), m_histogram));
506 
507  TH2I * hB = new TH2I( (histoName + "Buffer").c_str(), histoTitle.c_str(), x, 1, x + 1, y, 1, y + 1);
508  m_bufferHistogram.set(hB, &m_mutex);
509  m_bufferHistogram->SetDirectory(0);
510 
511  return StatusCode::SUCCESS;
512 }

◆ startTimer()

void TrigSignatureMoni::RateHistogram::startTimer ( unsigned int  duration,
unsigned int  intervals 
)

Definition at line 530 of file TrigSignatureMoni.cxx.

530  {
532  m_timeDivider = std::make_unique<TimeDivider>(intervals, duration, TimeDivider::seconds);
533  m_timer = std::make_unique<Athena::AlgorithmTimer>(duration*50, std::bind(&RateHistogram::callback, this));
534 }

◆ stopTimer()

void TrigSignatureMoni::RateHistogram::stopTimer ( )

Definition at line 536 of file TrigSignatureMoni.cxx.

536  {
537  if (m_timer) {
538  m_timer->stop();
539  time_t t = time(0);
540  unsigned int interval;
541  unsigned int duration = m_timeDivider->forcePassed(t, interval);
542  updatePublished(duration); // Divide by time that really passed not by interval duration
543  }
544 
545 }

◆ updatePublished()

void TrigSignatureMoni::RateHistogram::updatePublished ( unsigned int  duration) const
private

Definition at line 547 of file TrigSignatureMoni.cxx.

547  {
548  m_histogram->Reset("ICES");
549  m_histogram->Add(m_bufferHistogram.get(), 1./duration);
550  m_bufferHistogram->Reset("ICES");
551 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE [1/2]

LockedHandle<TH2> m_bufferHistogram TrigSignatureMoni::RateHistogram::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 84 of file TrigSignatureMoni.h.

◆ ATLAS_THREAD_SAFE [2/2]

LockedHandle<TH2> m_histogram TrigSignatureMoni::RateHistogram::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 85 of file TrigSignatureMoni.h.

◆ m_duration

unsigned int TrigSignatureMoni::RateHistogram::m_duration {0}
private

Definition at line 89 of file TrigSignatureMoni.h.

◆ m_mutex

std::mutex TrigSignatureMoni::RateHistogram::m_mutex
private

Definition at line 86 of file TrigSignatureMoni.h.

◆ m_timeDivider

std::unique_ptr<TimeDivider> TrigSignatureMoni::RateHistogram::m_timeDivider
private

Definition at line 88 of file TrigSignatureMoni.h.

◆ m_timer

std::unique_ptr<Athena::AlgorithmTimer> TrigSignatureMoni::RateHistogram::m_timer
private

Definition at line 87 of file TrigSignatureMoni.h.


The documentation for this class was generated from the following files:
TrigSignatureMoni::RateHistogram::m_timer
std::unique_ptr< Athena::AlgorithmTimer > m_timer
Definition: TrigSignatureMoni.h:87
TrigSignatureMoni::RateHistogram::m_duration
unsigned int m_duration
Definition: TrigSignatureMoni.h:89
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
x
#define x
getLatestRuns.interval
interval
Definition: getLatestRuns.py:24
MuonSegmentReaderConfig.histSvc
histSvc
Definition: MuonSegmentReaderConfig.py:96
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelAthHitMonAlgCfg.duration
duration
Definition: PixelAthHitMonAlgCfg.py:152
TrigSignatureMoni::RateHistogram::callback
void callback()
Definition: TrigSignatureMoni.cxx:554
TrigSignatureMoni::RateHistogram::m_timeDivider
std::unique_ptr< TimeDivider > m_timeDivider
Definition: TrigSignatureMoni.h:88
TimeDivider::seconds
@ seconds
Definition: TimeDivider.h:22
TrigSignatureMoni::RateHistogram::m_mutex
std::mutex m_mutex
Definition: TrigSignatureMoni.h:86
y
#define y
h
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
TrigSignatureMoni::RateHistogram::updatePublished
void updatePublished(unsigned int duration) const
Definition: TrigSignatureMoni.cxx:547