FEBRatesByDiblock.cxx
Go to the documentation of this file.
2 #include <iostream>
3 #include <cmath>
4 #include "TH1F.h"
5 #include "TH2F.h"
6 #include "DAQChannelMap/HardwareDisplay.h"
13 
14 using namespace om;
15 
18  fHwMap(new daqchannelmap::HardwareDisplay)
19 {
22 
24 
25  for(unsigned int i = 0; i < numDB; ++i) {
26  fFEBRatesDB[i] = 0;
27  fFEBHitsDB[i] = 0;
28  }
29 
30  fRecordedTime = h.GetTH1F("RecordedTime");
31  fHitMapEvtCount = h.GetTH1F("HitMapEvtCount");
32  fDCMRates = h.GetTH2F("DCMRatesVsHour");
33  fDCMHits = h.GetTH2F("DCMHitsVsHour");
34  fEmptyDCMs = h.GetTH2F("EmptyDCMsVsHour");
35  fLiveTime = h.GetTH1F("LiveTimeVsHour");
36 
37  fDCMs.clear();
38  fDCMs.resize(fDCMpDB*(fHwMap->fNdiblocks)+1);
39 
40  fLastTime = time(0);
41 }
42 
43 //......................................................................
44 
46  if(fHwMap) {delete fHwMap; fHwMap = 0;}
47 }
48 
49 //......................................................................
50 
52  const DataBlockSummary& dbs,
53  const MicroSliceSummary& mss,
54  const NanoSliceSummary& nss)
55 {
57 
58  static unsigned int lastRun=0, lastEvent=0;
59  static const double secPerRange = 5E-7; // fRange is in units of 500nsec
60 
61  // Don't do the standard histogram filling if this is the VERY start of
62  // OnMon running.
63  static bool start = true;
64 
65  if((lastRun!=r.fRun || lastEvent!=r.fEvent) && !start) {
66 
67  double recordedSec = (fRecordedTime->Integral())*secPerRange;
68  double nEvents = fHitMapEvtCount->Integral();
69 
70  // Update empty DCMs plot and reset the list of DCMs
71  for(unsigned int i = 1; i <= fDCMpDB*(fHwMap->fNdiblocks); ++i)
72  if(fDCMs[i] == 0) fEmptyDCMs->Fill(r.fHour,i);
73 
74  fDCMs.clear();
75  fDCMs.resize(fDCMpDB*(fHwMap->fNdiblocks)+1);
76 
77 
78 
79  // Get the current UNIX time in seconds
80  time_t t = time(0);
81 
82  // only update the rate plots every 120 seconds
83  if((int)nEvents%1000 == 0 && recordedSec != 0.0){
84  fLastTime = t;
85  this->UpdateRatePlots();
86  }
87 
88  double range = (double)r.fRange;
89 
90  // Adjust the range due to the fact that we always get any micro blocks
91  // that touch the edge of the trigger range.
92  range = 100.0*floor(range/100.0)+100.0;
93 
94  fLiveTime->Fill(r.fHour,range);
95 
96  }
97 
98  lastRun = r.fRun;
99  lastEvent = r.fEvent;
100  start = false;
101 
102  if(fFEBHitsDB[mss.fDiblock] == 0) {
103  char histoname[64];
104  sprintf(histoname,"FEBHitsVsHourDB_%.2u",mss.fDiblock);
105  fFEBHitsDB[mss.fDiblock] = h.GetTH2F(histoname);
106  }
107 
108  if(fFEBRatesDB[mss.fDiblock] == 0) {
109  char histoname[64];
110  sprintf(histoname,"FEBRatesVsHourDB_%.2u",mss.fDiblock);
111  fFEBRatesDB[mss.fDiblock] = h.GetTH2F(histoname);
112  }
113 
114  // Fill the FEB hit plot
115  fFEBHitsDB[mss.fDiblock]->Fill(r.fHour,(mss.fDCM-1)*64+nss.fFEB);
116 
117  // Fill the DCM hit plot
118  fDCMHits->Fill(r.fHour,(mss.fDiblock-1)*fDCMpDB+mss.fDCM);
119 
120  // Record if this DCM has reported yet or not
121  fDCMs[(mss.fDiblock-1)*fDCMpDB+mss.fDCM] = 1;
122 
123 }
124 
125 //......................................................................
126 
128 
129  static const double secPerRange = 5E-7; // fRange is in units of 500nsec
130 
131  //
132  // Compute FEB rates
133  //
134  for(unsigned int db = 0; db < numDB; ++db) {
135 
136  if(fFEBHitsDB[db] == 0) continue;
137 
138  unsigned int nx = fFEBHitsDB[db]->GetNbinsX();
139  unsigned int ny = fFEBHitsDB[db]->GetNbinsY();
140 
141  for(unsigned int i = 1; i <= nx; ++i) {
142 
143  unsigned int tbin = fLiveTime->GetBin(i);
144  double time = (fLiveTime->GetBinContent(tbin))*secPerRange;
145 
146  if(time == 0.0) continue;
147 
148  for(unsigned int j = 1; j <= ny; ++j) {
149 
150  unsigned int hbin = fFEBHitsDB[db]->GetBin(i,j);
151  double content = fFEBHitsDB[db]->GetBinContent(hbin);
152 
153  fFEBRatesDB[db]->SetBinContent(hbin,content/time);
154 
155  } // end loop over j
156  } // end loop over i
157 
158  } // end loop over db
159 
160 
161 
162  //
163  // Compute DCM rates
164  //
165  unsigned int nx = fDCMHits->GetNbinsX();
166  unsigned int ny = fDCMHits->GetNbinsY();
167 
168  for(unsigned int i = 1; i <= nx; ++i) {
169 
170  unsigned int tbin = fLiveTime->GetBin(i);
171  double time = (fLiveTime->GetBinContent(tbin))*secPerRange;
172 
173  if(time == 0.0) continue;
174 
175  for(unsigned int j = 1; j <= ny; ++j) {
176 
177  unsigned int hbin = fDCMHits->GetBin(i,j);
178  double content = fDCMHits->GetBinContent(hbin);
179 
180  fDCMRates->SetBinContent(hbin,content/time);
181 
182  } // end loop over j
183  } // end loop over i
184 
185 }
186 
187 
188 ////////////////////////////////////////////////////////////////////////
unsigned int fDCM
DCM ID.
unsigned int fDiblock
Diblock ID.
TH1F * GetTH1F(const char *nm)
Definition: HistoSet.cxx:68
unsigned int fNdcmSide
Number of DMC&#39;s per diblock on side of detector.
virtual void GetNanoSliceSummary(const RawEventSummary &r, const DataBlockSummary &dbs, const MicroSliceSummary &mss, const NanoSliceSummary &nss)
Interface to the nanoslice summary.
::xsd::cxx::tree::time< char, simple_type > time
Definition: Database.h:194
All the interesting event-level data.
unsigned int fEvent
Event nunber.
unsigned int fRange
Trigger length in units of 500 nsec.
static const unsigned int numDB
unsigned int fNdiblocks
Number of diblocks in detector.
std::vector< unsigned int > fDCMs
Float_t E
Definition: plot.C:20
TH2F * GetTH2F(const char *nm)
Definition: HistoSet.cxx:89
float fHour
A fractional hour of the day.
unsigned int fRun
Run number.
unsigned int fNdcmTop
Number of DMC&#39;s per diblock on top of detector.
const double j
Definition: BetheBloch.cxx:29
A simple object that conatins all the global settings.
daqchannelmap::HardwareDisplay * fHwMap
fvar< T > floor(const fvar< T > &x)
Definition: floor.hpp:11
TRandom3 r(0)
unsigned int fFEB
FEB number of nanoslice (aka "hit")
static HistoSet & Instance()
Definition: HistoSet.cxx:24
Hold the collection of histograms created by the producer.
All the interesting event-level data.
static Settings & Instance()
Definition: Settings.cxx:12
Online Monitoring package header.
All the interesting event-level data.