Belle II Software development
TOPHitRateCounter Class Reference

Class for monitoring beam background hit rates of TOP. More...

#include <TOPHitRateCounter.h>

Inheritance diagram for TOPHitRateCounter:
HitRateBase

Classes

struct  TreeStruct
 tree structure More...
 

Public Member Functions

 TOPHitRateCounter (double timeOffset, double timeWindow)
 Constructor.
 
virtual void initialize (TTree *tree) override
 Class initializer: set branch addresses and other staf.
 
virtual void clear () override
 Clear time-stamp buffer to prepare for 'accumulate'.
 
virtual void accumulate (unsigned timeStamp) override
 Accumulate hits.
 
virtual void normalize (unsigned timeStamp) override
 Normalize accumulated hits (e.g.
 

Private Member Functions

void setActiveFractions ()
 Sets fractions of active channels.
 

Private Attributes

double m_timeOffset = 0
 time offset of hits [ns]
 
double m_timeWindow = 0
 time window in which to count hits [ns]
 
TreeStruct m_rates
 tree variables
 
std::map< unsigned, TreeStructm_buffer
 average rates in time stamps
 
StoreArray< TOPDigitm_digits
 collection of digits
 
DBObjPtr< TOPCalChannelMaskm_channelMask
 channel mask
 
TH1F * m_hits = 0
 time distribution of hits in wide range
 
TH1F * m_hitsInWindow = 0
 time distribution of hits inside timeWindow
 
double m_activeFractions [16] = {0}
 fractions of active channels in slots
 
double m_activeTotal = 0
 total fraction of active channels
 

Detailed Description

Class for monitoring beam background hit rates of TOP.

Hit rates are given in MHz per PMT and are already corrected for different pixel efficiencies and masked-out pixels.

Definition at line 33 of file TOPHitRateCounter.h.

Constructor & Destructor Documentation

◆ TOPHitRateCounter()

TOPHitRateCounter ( double  timeOffset,
double  timeWindow 
)
inline

Constructor.

Parameters
timeOffsettime offset to be subtracted from hit times [ns]
timeWindowtime window (full size) in which to count hits [ns]

Definition at line 63 of file TOPHitRateCounter.h.

63 :
64 m_timeOffset(timeOffset), m_timeWindow(timeWindow)
65 {}
double m_timeWindow
time window in which to count hits [ns]
double m_timeOffset
time offset of hits [ns]

Member Function Documentation

◆ accumulate()

void accumulate ( unsigned  timeStamp)
overridevirtual

Accumulate hits.

Parameters
timeStamptime stamp

Implements HitRateBase.

Definition at line 56 of file TOPHitRateCounter.cc.

57 {
58 // check if data are available
59 if (not m_digits.isValid()) return;
60
61 // get buffer element
62 auto& rates = m_buffer[timeStamp];
63
64 // increment event counter
65 rates.numEvents++;
66
67 // accumulate hits (weighted by efficiency correction)
68 const auto* topgp = TOP::TOPGeometryPar::Instance();
69 for (const auto& digit : m_digits) {
70 if (digit.getHitQuality() != TOPDigit::c_Good) continue;
71 m_hits->Fill(digit.getTime());
72
73 if (fabs(digit.getTime() - m_timeOffset) > m_timeWindow / 2) continue;
74 m_hitsInWindow->Fill(digit.getTime());
75
76 auto effi = topgp->getRelativePixelEfficiency(digit.getModuleID(),
77 digit.getPixelID());
78 float wt = std::min(1.0 / effi, 10.0);
79 rates.slotRates[digit.getModuleID() - 1] += wt;
80 rates.averageRate += wt;
81 }
82
83 // set flag to true to indicate the rates are valid
84 rates.valid = true;
85
86 }
std::map< unsigned, TreeStruct > m_buffer
average rates in time stamps
TH1F * m_hitsInWindow
time distribution of hits inside timeWindow
StoreArray< TOPDigit > m_digits
collection of digits
TH1F * m_hits
time distribution of hits in wide range
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.

◆ clear()

void clear ( )
overridevirtual

Clear time-stamp buffer to prepare for 'accumulate'.

Implements HitRateBase.

Definition at line 51 of file TOPHitRateCounter.cc.

52 {
53 m_buffer.clear();
54 }

◆ initialize()

void initialize ( TTree *  tree)
overridevirtual

Class initializer: set branch addresses and other staf.

Parameters
treea valid TTree pointer

Implements HitRateBase.

Definition at line 28 of file TOPHitRateCounter.cc.

29 {
30 // register collection(s) as optional, your detector might be excluded in DAQ
31 m_digits.isOptional();
32
33 // set branch address
34 tree->Branch("top", &m_rates, "slotRates[16]/F:averageRate/F:numEvents/I:valid/O");
35
36 // create control histograms
37 m_hits = new TH1F("top_hits", "time distribution of hits; digit.time [ns]",
38 1000, -500, 500);
39 m_hitsInWindow = new TH1F("top_hitsInWindow",
40 "time distribution of hits; digit.time [ns]",
41 100, m_timeOffset - m_timeWindow / 2,
43
44 // check parameters
45 if (m_timeWindow <= 0) B2FATAL("invalid time window for TOP: " << m_timeWindow);
46
47 // set fractions of active channels
49 }
void setActiveFractions()
Sets fractions of active channels.

◆ normalize()

void normalize ( unsigned  timeStamp)
overridevirtual

Normalize accumulated hits (e.g.

transform to rates) and prepare for TTree::Fill

Parameters
timeStamptime stamp

Implements HitRateBase.

Definition at line 88 of file TOPHitRateCounter.cc.

89 {
90 // copy buffer element
91 m_rates = m_buffer[timeStamp];
92
93 if (not m_rates.valid) return;
94
95 // normalize
97
98 // convert rates to [MHz/PMT]
99 for (auto& slotRate : m_rates.slotRates) {
100 slotRate /= m_timeWindow / Unit::us * 32; // 32 PMT's per slot
101 }
102 m_rates.averageRate /= m_timeWindow / Unit::us * 32 * 16; // 16 slots
103
104 // check if DB object has changed and if so set fractions of active channels
105 if (m_channelMask.hasChanged()) setActiveFractions();
106
107 // correct rates for masked-out channels
108 for (int m = 0; m < 16; m++) {
109 double fraction = m_activeFractions[m];
110 if (fraction > 0) {
111 m_rates.slotRates[m] /= fraction;
112 } else {
113 m_rates.slotRates[m] = 0;
114 }
115 }
116 m_rates.averageRate /= m_activeTotal; // we don't expect full TOP to be masked-out
117
118 }
DBObjPtr< TOPCalChannelMask > m_channelMask
channel mask
double m_activeTotal
total fraction of active channels
double m_activeFractions[16]
fractions of active channels in slots
static const double us
[microsecond]
Definition: Unit.h:97
float slotRates[16]
hit rates per PMT of the modules (slots) [MHz]
float averageRate
average hit rate per PMT [MHz]
void normalize()
normalize accumulated hits to single event

◆ setActiveFractions()

void setActiveFractions ( )
private

Sets fractions of active channels.

Definition at line 120 of file TOPHitRateCounter.cc.

121 {
122 if (not m_channelMask.isValid()) {
123 for (auto& fraction : m_activeFractions) fraction = 1;
124 m_activeTotal = 1;
125 B2WARNING("TOPHitRateCounter: no valid channel mask - active fractions set to 1");
126 return;
127 }
128
129 for (int m = 0; m < 16; m++) {
130 m_activeFractions[m] = m_channelMask->getActiveFraction(m + 1);
131 }
132 m_activeTotal = m_channelMask->getActiveFraction();
133
134 }

Member Data Documentation

◆ m_activeFractions

double m_activeFractions[16] = {0}
private

fractions of active channels in slots

Definition at line 118 of file TOPHitRateCounter.h.

◆ m_activeTotal

double m_activeTotal = 0
private

total fraction of active channels

Definition at line 119 of file TOPHitRateCounter.h.

◆ m_buffer

std::map<unsigned, TreeStruct> m_buffer
private

average rates in time stamps

Definition at line 105 of file TOPHitRateCounter.h.

◆ m_channelMask

DBObjPtr<TOPCalChannelMask> m_channelMask
private

channel mask

Definition at line 111 of file TOPHitRateCounter.h.

◆ m_digits

StoreArray<TOPDigit> m_digits
private

collection of digits

Definition at line 108 of file TOPHitRateCounter.h.

◆ m_hits

TH1F* m_hits = 0
private

time distribution of hits in wide range

Definition at line 114 of file TOPHitRateCounter.h.

◆ m_hitsInWindow

TH1F* m_hitsInWindow = 0
private

time distribution of hits inside timeWindow

Definition at line 115 of file TOPHitRateCounter.h.

◆ m_rates

TreeStruct m_rates
private

tree variables

Definition at line 102 of file TOPHitRateCounter.h.

◆ m_timeOffset

double m_timeOffset = 0
private

time offset of hits [ns]

Definition at line 98 of file TOPHitRateCounter.h.

◆ m_timeWindow

double m_timeWindow = 0
private

time window in which to count hits [ns]

Definition at line 99 of file TOPHitRateCounter.h.


The documentation for this class was generated from the following files: