32 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: Constructor";
40 rootFile =
new TFile(
"DTOccupancyTest.root",
"RECREATE");
41 ntuple =
new TNtuple(
"OccupancyNtuple",
"OccupancyNtuple",
"ls:wh:st:se:lay1MeanCell:lay1RMS:lay2MeanCell:lay2RMS:lay3MeanCell:lay3RMS:lay4MeanCell:lay4RMS:lay5MeanCell:lay5RMS:lay6MeanCell:lay6RMS:lay7MeanCell:lay7RMS:lay8MeanCell:lay8RMS:lay9MeanCell:lay9RMS:lay10MeanCell:lay10RMS:lay11MeanCell:lay11RMS:lay12MeanCell:lay12RMS");
62 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" destructor called" << endl;
68 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: BeginRun";
81 for(
int wh = -2; wh <= 2; ++wh) {
82 bookHistos(ibooker,wh,
string(
"Occupancies"),
"OccupancySummary");
86 string title =
"Occupancy Summary";
88 title =
"Test Pulse Occupancy Summary";
91 summaryHisto = ibooker.
book2D(
"OccupancySummary",title.c_str(),12,1,13,5,-2,3);
93 summaryHisto->setAxisTitle(
"wheel",2);
96 glbSummaryHisto = ibooker.
book2D(
"OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
98 glbSummaryHisto->setAxisTitle(
"wheel",2);
102 if(runOnAllHitsOccupancies) {
103 nameMonitoredHisto =
"OccupancyAllHits_perCh";
104 }
else if(runOnNoiseOccupancies) {
105 nameMonitoredHisto =
"OccupancyNoise_perCh";
106 }
else if(runOnInTimeOccupancies) {
107 nameMonitoredHisto =
"OccupancyInTimeHits_perCh";
109 nameMonitoredHisto =
"OccupancyAllHits_perCh";
116 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest")
117 <<
"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
123 summaryHisto->Reset();
124 glbSummaryHisto->Reset();
130 vector<const DTChamber*>
chambers = muonGeom->chambers();
132 for(vector<const DTChamber*>::const_iterator
chamber = chambers.begin();
136 MonitorElement * chamberOccupancyHisto = igetter.
get(getMEName(nameMonitoredHisto, chId));
139 if(chamberOccupancyHisto != 0) {
142 float chamberPercentage = 1.;
143 int result = runOccupancyTest(histo, chId, chamberPercentage);
144 int sector = chId.
sector();
148 float resultSect4 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
149 if(resultSect4 > result) {
150 result = (
int)resultSect4;
152 }
else if(sector == 14) {
154 float resultSect10 = wheelHistos[chId.
wheel()]->getBinContent(sector, chId.
station());
155 if(resultSect10 > result) {
156 result = (
int)resultSect10;
161 if((sector == 4 || sector == 10) && chId.
station() == 4)
162 chamberPercentage = chamberPercentage/2.;
165 if(result > summaryHisto->getBinContent(sector, chId.
wheel()+3)) {
166 summaryHisto->setBinContent(sector, chId.
wheel()+3,
result);
168 glbSummaryHisto->Fill(sector, chId.
wheel(), chamberPercentage*1./4.);
170 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: " 171 << getMEName(nameMonitoredHisto, chId) <<
" not found!" << endl;
176 string nEvtsName =
"DT/EventInfo/Counters/nProcessedEventsDigi";
182 glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
183 summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
185 glbSummaryHisto->setEntries(nMinEvts +1);
186 summaryHisto->setEntries(nMinEvts + 1);
187 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] ME: " 188 << nEvtsName <<
" not found!" << endl;
195 if(writeRootFile)
ntuple->AutoSave(
"SaveSelf");
201 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest] endjob called!";
214 string folder,
string histoTag) {
216 stringstream
wheel; wheel << wheelId;
221 string histoName = histoTag +
"_W" + wheel.str();
224 LogVerbatim (
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"[DTOccupancyTest]: booking wheel histo:" 229 << topFolder() +
"Wheel"+ wheel.str() +
"/" + folder << endl;
231 string histoTitle =
"Occupancy summary WHEEL: "+wheel.str();
233 histoTitle =
"TP Occupancy summary WHEEL: "+wheel.str();
236 wheelHistos[wheelId] = ibooker.
book2D(histoName,histoTitle,12,1,13,4,1,5);
238 wheelHistos[wheelId]->setBinLabel(2,
"MB2",2);
239 wheelHistos[wheelId]->setBinLabel(3,
"MB3",2);
240 wheelHistos[wheelId]->setBinLabel(4,
"MB4",2);
241 wheelHistos[wheelId]->setAxisTitle(
"sector",1);
250 stringstream sector; sector << chId.
sector();
253 string folderRoot = topFolder() +
"Wheel" + wheel.str() +
254 "/Sector" + sector.str() +
255 "/Station" + station.str() +
"/";
257 string folder =
"Occupancies/";
260 string histoName = histoTag
262 +
"_St" + station.str()
263 +
"_Sec" + sector.str();
265 string histoname = folderRoot + histoName;
274 for (Int_t
i = firstBinX;
i < lastBinX+1;
i++) {
275 for (Int_t j = firstBinY; j < lastBinY+1; j++) {
277 if (histo->GetBinContent(
i,j) >0){
278 if (!doall)
return 1;
279 sum += histo->GetBinContent(
i,j);
298 float& chamberPercentage) {
299 int nBinsX = histo->GetNbinsX();
301 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
"--- Occupancy test for chamber: " << chId << endl;
303 int compDeadCell = 0;
307 for(
int slay = 1; slay <= 3; ++slay) {
308 int binYlow = ((slay-1)*4)+1;
310 if(chId.
station() == 4 && slay == 2)
continue;
311 for(
int lay = 1; lay <= 4; ++lay) {
313 int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
314 int nWires = muonGeom->layer(layID)->specificTopology().channels();
315 int binY = binYlow+(lay-1);
316 int totalDeadCells = 0;
317 int nDeadCellsInARow = 1;
318 int nDeadCellsInARowMax = 0;
319 int nCellsZeroCount = 0;
320 bool previousIsDead =
false;
322 int interDeadCells = 0;
326 for(
int cell = firstWire; cell != (nWires+firstWire); ++cell) {
327 double cellOccup = histo->GetBinContent(cell,binY);
328 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" cell occup: " << cellOccup;
329 totOccup += cellOccup;
339 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
340 nDeadCellsInARow = 1;
343 previousIsDead =
true;
345 LogTrace(
"DTDQM|DTMonitorClient|DTOccupancyTest") <<
" below reference" << endl;
347 previousIsDead =
false;
351 if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
353 compDeadCell += totalDeadCells;
354 if(nDeadCellsInARowMax >= 7.) {
355 histo->SetBinContent(nBinsX+1,binY,-1.);
361 nChannelTotal += totCell;
362 nChannelDead += compDeadCell;
363 chamberPercentage = 1.-(
float(compDeadCell)/totCell);
365 int min_occup = nZeroEvtsPC*20;
366 if (chId.
station() == 3) min_occup = nZeroEvtsPC*3;
367 if (chId.
station() == 2) min_occup = nZeroEvtsPC*8;
368 if ((chId.
station() == 4) && (chId.
sector() == 9)) min_occup = nZeroEvtsPC*3;
369 if ((chId.
station() == 4) && (chId.
sector() == 10)) min_occup = nZeroEvtsPC*3;
370 if ((chId.
station() == 4) && (chId.
sector() == 11)) min_occup = nZeroEvtsPC*3;
371 if ((chId.
station() == 4) && (chId.
sector() == 14)) min_occup = nZeroEvtsPC*3;
374 if (totOccup < min_occup)
return 4;
375 if (totOccup < nMinEvtsPC) chamberPercentage = 1.;
377 if (chamberPercentage < 0.2)
return 4;
378 if (chamberPercentage < 0.5)
return 3;
379 if (chamberPercentage < 0.75)
return 2;
380 if (chamberPercentage < 0.9)
return 1;
387 if(tpMode)
return string(
"DT/10-TestPulses/");
388 return string(
"DT/01-Digi/");
T getUntrackedParameter(std::string const &, T const &) const
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
DQM Client Diagnostic.
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage)
MonitorElement * get(const std::string &path)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &)
Endjob.
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
int getIntegral(TH2F *histo, int, int, int, int, bool)
virtual ~DTOccupancyTest()
Destructor.
DTOccupancyTest(const edm::ParameterSet &ps)
Constructor.
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
void beginRun(edm::Run const &run, edm::EventSetup const &context)
BeginRun.
double getFloatValue(void) const
void setCurrentFolder(const std::string &fullpath)
MonitorElement * book2D(Args &&...args)
std::string topFolder() const
int station() const
Return the station number.
TH2F * getTH2F(void) const
static char chambers[264][20]
int wheel() const
Return the wheel number.
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)