10 #include <background/modules/BeamBkgHitRateMonitor/ARICHHitRateCounter.h> 
   13 #include <framework/logging/Logger.h> 
   22   namespace Background {
 
   24     void ARICHHitRateCounter::initialize(TTree* tree)
 
   30       tree->Branch(
"arich", &m_rates, 
"segmentRates[18]/F:averageRate/F:numEvents/I:valid/O");
 
   34       const int nModInRing[7] = {0, 42, 90, 144, 204, 270, 342};
 
   36       for (
int i = 0; i < 420; i++) {
 
   37         if (i == nModInRing[iRing + 1]) iRing++;
 
   38         int segment = (i - nModInRing[iRing]) / (7 + iRing);
 
   39         if (iRing > 0) segment += 6;
 
   40         if (iRing > 3) segment += 6;
 
   41         m_segmentMap[i] = segment;
 
   48     void ARICHHitRateCounter::clear()
 
   53     void ARICHHitRateCounter::accumulate(
unsigned timeStamp)
 
   56       if (not m_hits.isValid()) 
return;
 
   59       auto& rates = m_buffer[timeStamp];
 
   65       for (
const auto& hit : m_hits) {
 
   66         if (hit.getModule() < 1 || hit.getModule() > 420) 
continue;
 
   67         auto effi = m_modulesInfo->getChannelQE(hit.getModule(), hit.getChannel());
 
   68         float wt = std::min(1.0 / effi, 100.);
 
   69         rates.segmentRates[m_segmentMap[hit.getModule() - 1]] += wt;
 
   70         rates.averageRate += wt;
 
   78     void ARICHHitRateCounter::normalize(
unsigned timeStamp)
 
   81       m_rates = m_buffer[timeStamp];
 
   83       if (not m_rates.valid) 
return;
 
   89       if (m_channelMask.hasChanged()) setActiveHapds();
 
   91       for (
int iSegment = 0; iSegment < 18; iSegment++) {
 
   92         double nHapds = m_activeHapds[iSegment];
 
   93         if (nHapds > 0) m_rates.segmentRates[iSegment] /= nHapds;
 
   94         else m_rates.segmentRates[iSegment] = 0;
 
   96       m_rates.averageRate /= m_activeTotal;
 
   99     void ARICHHitRateCounter::setActiveHapds()
 
  101       for (
auto& nactive : m_activeHapds) nactive = 0;
 
  103       if (not m_channelMask.isValid()) {
 
  104         for (
unsigned imod = 1; imod < 421; imod++)  m_activeHapds[m_segmentMap[imod - 1]] += 1.;
 
  106         B2WARNING(
"ARICHHitRateCounter: no valid channel mask - all HAPDs set to active");
 
  110       int nactiveTotal = 0;
 
  111       for (
unsigned imod = 1; imod < 421; imod++) {
 
  113         for (
unsigned ichn = 0; ichn < 144; ichn++) {
 
  114           if (m_channelMask->isActive(imod, ichn)) nactive++;
 
  116         nactiveTotal += nactive;
 
  117         m_activeHapds[m_segmentMap[imod - 1]] += (float)nactive / 144.;
 
  119       m_activeTotal = (float)nactiveTotal / 144.;
 
Abstract base class for different kinds of events.