CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DTOccupancyTest Class Reference

#include <DTOccupancyTest.h>

Inheritance diagram for DTOccupancyTest:
edm::EDAnalyzer

Public Member Functions

 DTOccupancyTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTOccupancyTest ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Protected Member Functions

void analyze (const edm::Event &event, const edm::EventSetup &context)
 Analyze. More...
 
void beginJob ()
 BeginJob. More...
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 
void beginRun (edm::Run const &run, edm::EventSetup const &context)
 BeginRun. More...
 
void endJob ()
 Endjob. More...
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiSeg, edm::EventSetup const &context)
 DQM Client Diagnostic. More...
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Private Member Functions

void bookHistos (const int wheelId, std::string folder, std::string histoTag)
 book the summary histograms More...
 
std::string getMEName (std::string histoTag, const DTChamberId &chId)
 Get the ME name. More...
 
int runOccupancyTest (TH2F *histo, const DTChamberId &chId, float &chamberPercentage)
 
std::string topFolder () const
 

Private Attributes

DQMStoredbe
 
MonitorElementglbSummaryHisto
 
int lsCounter
 
std::set< DTLayerIdmonitoredLayers
 
edm::ESHandle< DTGeometrymuonGeom
 
std::string nameMonitoredHisto
 
int nevents
 
int nMinEvts
 
TNtuple * ntuple
 
TFile * rootFile
 
bool runOnAllHitsOccupancies
 
bool runOnInTimeOccupancies
 
bool runOnNoiseOccupancies
 
MonitorElementsummaryHisto
 
bool tpMode
 
std::map< int, MonitorElement * > wheelHistos
 
bool writeRootFile
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 35 of file DTOccupancyTest.h.

Constructor & Destructor Documentation

DTOccupancyTest::DTOccupancyTest ( const edm::ParameterSet ps)

Constructor.

Definition at line 33 of file DTOccupancyTest.cc.

References edm::ParameterSet::getUntrackedParameter(), and cppFunctionSkipper::operator.

33  {
34  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: Constructor";
35 
36  // Get the DQM service
38 
39  lsCounter = 0;
40 
41  writeRootFile = ps.getUntrackedParameter<bool>("writeRootFile", false);
42  if(writeRootFile) {
43  rootFile = new TFile("DTOccupancyTest.root","RECREATE");
44  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");
45  }
46 
47  // switch on the mode for running on test pulses (different top folder)
48  tpMode = ps.getUntrackedParameter<bool>("testPulseMode", false);
49 
50  runOnAllHitsOccupancies = ps.getUntrackedParameter<bool>("runOnAllHitsOccupancies", true);
51  runOnNoiseOccupancies = ps.getUntrackedParameter<bool>("runOnNoiseOccupancies", false);
52  runOnInTimeOccupancies = ps.getUntrackedParameter<bool>("runOnInTimeOccupancies", false);
53  nMinEvts = ps.getUntrackedParameter<int>("nEventsCert", 5000);
54 
55 }
T getUntrackedParameter(std::string const &, T const &) const
bool runOnAllHitsOccupancies
DTOccupancyTest::~DTOccupancyTest ( )
virtual

Destructor.

Definition at line 60 of file DTOccupancyTest.cc.

60  {
61  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << " destructor called" << endl;
62 
63 
64 }

Member Function Documentation

void DTOccupancyTest::analyze ( const edm::Event event,
const edm::EventSetup context 
)
protectedvirtual

Analyze.

Implements edm::EDAnalyzer.

Definition at line 132 of file DTOccupancyTest.cc.

References nevents.

132  {
133  nevents++;
134 // if(nevents%1000)
135 // LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: "<<nevents<<" events";
136 }
void DTOccupancyTest::beginJob ( void  )
protectedvirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 69 of file DTOccupancyTest.cc.

References bookHistos(), nevents, and indexGen::title.

69  {
70  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: BeginJob";
71 
72  // Event counter
73  nevents = 0;
74 
75  // Book the summary histos
76  // - one summary per wheel
77  for(int wh = -2; wh <= 2; ++wh) { // loop over wheels
78  bookHistos(wh, string("Occupancies"), "OccupancySummary");
79  }
80 
82  string title = "Occupancy Summary";
83  if(tpMode) {
84  title = "Test Pulse Occupancy Summary";
85  }
86  // - global summary with alarms
87  summaryHisto = dbe->book2D("OccupancySummary",title.c_str(),12,1,13,5,-2,3);
88  summaryHisto->setAxisTitle("sector",1);
89  summaryHisto->setAxisTitle("wheel",2);
90 
91  // - global summary with percentages
92  glbSummaryHisto = dbe->book2D("OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
93  glbSummaryHisto->setAxisTitle("sector",1);
94  glbSummaryHisto->setAxisTitle("wheel",2);
95 
96 
97  // assign the name of the input histogram
99  nameMonitoredHisto = "OccupancyAllHits_perCh";
100  } else if(runOnNoiseOccupancies) {
101  nameMonitoredHisto = "OccupancyNoise_perCh";
102  } else if(runOnInTimeOccupancies) {
103  nameMonitoredHisto = "OccupancyInTimeHits_perCh";
104  } else { // default is AllHits histo
105  nameMonitoredHisto = "OccupancyAllHits_perCh";
106  }
107 
108 }
MonitorElement * summaryHisto
std::string nameMonitoredHisto
bool runOnAllHitsOccupancies
void bookHistos(const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
std::string topFolder() const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
MonitorElement * glbSummaryHisto
void DTOccupancyTest::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 125 of file DTOccupancyTest.cc.

125  {
126  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") <<"[DTOccupancyTest]: Begin of LS transition";
127 }
void DTOccupancyTest::beginRun ( edm::Run const &  run,
edm::EventSetup const &  context 
)
protectedvirtual

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 113 of file DTOccupancyTest.cc.

References edm::EventSetup::get().

113  {
114 
115  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: BeginRun";
116 
117  // Get the geometry
118  context.get<MuonGeometryRecord>().get(muonGeom);
119 
120 }
edm::ESHandle< DTGeometry > muonGeom
void DTOccupancyTest::bookHistos ( const int  wheelId,
std::string  folder,
std::string  histoTag 
)
private

book the summary histograms

Definition at line 235 of file DTOccupancyTest.cc.

235  {
236  // Set the current folder
237  stringstream wheel; wheel << wheelId;
239 
240  // build the histo name
241  string histoName = histoTag + "_W" + wheel.str();
242 
243 
244  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") <<"[DTOccupancyTest]: booking wheel histo:"
245  << histoName
246  << " (tag "
247  << histoTag
248  << ") in: "
249  << topFolder() + "Wheel"+ wheel.str() + "/" + folder << endl;
250 
251  string histoTitle = "Occupancy summary WHEEL: "+wheel.str();
252  if(tpMode) {
253  histoTitle = "TP Occupancy summary WHEEL: "+wheel.str();
254  }
255  wheelHistos[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
256  wheelHistos[wheelId]->setBinLabel(1,"MB1",2);
257  wheelHistos[wheelId]->setBinLabel(2,"MB2",2);
258  wheelHistos[wheelId]->setBinLabel(3,"MB3",2);
259  wheelHistos[wheelId]->setBinLabel(4,"MB4",2);
260  wheelHistos[wheelId]->setAxisTitle("sector",1);
261 }
std::map< int, MonitorElement * > wheelHistos
std::string topFolder() const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void DTOccupancyTest::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 222 of file DTOccupancyTest.cc.

222  {
223 
224  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] endjob called!";
225  if(writeRootFile) {
226  rootFile->cd();
227  ntuple->Write();
228  rootFile->Close();
229  }
230 }
void DTOccupancyTest::endLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
protectedvirtual

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 141 of file DTOccupancyTest.cc.

References chambers, MonitorElement::getFloatValue(), MonitorElement::getTH2F(), interpolateCardsSimple::histo, query::result, DTChamberId::sector(), DTChamberId::station(), and DTChamberId::wheel().

141  {
142  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest")
143  <<"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
144  lsCounter++;
145 
146 
147 
148  // Reset the global summary
149  summaryHisto->Reset();
151 
152  // Get all the DT chambers
153  vector<DTChamber*> chambers = muonGeom->chambers();
154 
155  for(vector<DTChamber*>::const_iterator chamber = chambers.begin();
156  chamber != chambers.end(); ++chamber) { // Loop over all chambers
157  DTChamberId chId = (*chamber)->id();
158 
159  MonitorElement * chamberOccupancyHisto = dbe->get(getMEName(nameMonitoredHisto, chId));
160 
161  // Run the tests on the plot for the various granularities
162  if(chamberOccupancyHisto != 0) {
163  // Get the 2D histo
164  TH2F* histo = chamberOccupancyHisto->getTH2F();
165  float chamberPercentage = 1.;
166  int result = runOccupancyTest(histo, chId, chamberPercentage);
167  int sector = chId.sector();
168 
169  if(sector == 13) {
170  sector = 4;
171  float resultSect4 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
172  if(resultSect4 > result) {
173  result = (int)resultSect4;
174  }
175  } else if(sector == 14) {
176  sector = 10;
177  float resultSect10 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
178  if(resultSect10 > result) {
179  result = (int)resultSect10;
180  }
181  }
182 
183  // the 2 MB4 of Sect 4 and 10 count as half a chamber
184  if((sector == 4 || sector == 10) && chId.station() == 4)
185  chamberPercentage = chamberPercentage/2.;
186 
187  wheelHistos[chId.wheel()]->setBinContent(sector, chId.station(),result);
188  if(result > summaryHisto->getBinContent(sector, chId.wheel()+3)) {
189  summaryHisto->setBinContent(sector, chId.wheel()+3, result);
190  }
191  glbSummaryHisto->Fill(sector, chId.wheel(), chamberPercentage*1./4.);
192  } else {
193  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
194  << getMEName(nameMonitoredHisto, chId) << " not found!" << endl;
195  }
196 
197  }
198 
199  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsDigi";
200  MonitorElement * meProcEvts = dbe->get(nEvtsName);
201 
202  if (meProcEvts) {
203  int nProcEvts = meProcEvts->getFloatValue();
204  glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
205  summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
206  } else {
209  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
210  << nEvtsName << " not found!" << endl;
211  }
212 
213  // Fill the global summary
214  // Check for entire sectors off and report them on the global summary
215  //FIXME: TODO
216 
217  if(writeRootFile) ntuple->AutoSave("SaveSelf");
218 
219 }
void setBinContent(int binx, double content)
set content of bin (1-D)
std::map< int, MonitorElement * > wheelHistos
int runOccupancyTest(TH2F *histo, const DTChamberId &chId, float &chamberPercentage)
MonitorElement * summaryHisto
std::string nameMonitoredHisto
static char chambers[TOTALCHAMBERS][20]
Definition: ReadPGInfo.cc:243
void Fill(long long x)
tuple result
Definition: query.py:137
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
double getFloatValue(void) const
void setEntries(double nentries)
set # of entries
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
edm::ESHandle< DTGeometry > muonGeom
double getBinContent(int binx) const
get content of bin (1-D)
int sector() const
Definition: DTChamberId.h:63
int station() const
Return the station number.
Definition: DTChamberId.h:53
TH2F * getTH2F(void) const
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * glbSummaryHisto
string DTOccupancyTest::getMEName ( std::string  histoTag,
const DTChamberId chId 
)
private

Get the ME name.

Definition at line 265 of file DTOccupancyTest.cc.

References DTChamberId::sector(), DTChamberId::station(), relativeConstraints::station, and DTChamberId::wheel().

265  {
266 
267  stringstream wheel; wheel << chId.wheel();
268  stringstream station; station << chId.station();
269  stringstream sector; sector << chId.sector();
270 
271 
272  string folderRoot = topFolder() + "Wheel" + wheel.str() +
273  "/Sector" + sector.str() +
274  "/Station" + station.str() + "/";
275 
276  string folder = "Occupancies/";
277 
278  // build the histo name
279  string histoName = histoTag
280  + "_W" + wheel.str()
281  + "_St" + station.str()
282  + "_Sec" + sector.str();
283 
284  string histoname = folderRoot + histoName;
285 
286  return histoname;
287 }
int sector() const
Definition: DTChamberId.h:63
std::string topFolder() const
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
int DTOccupancyTest::runOccupancyTest ( TH2F *  histo,
const DTChamberId chId,
float &  chamberPercentage 
)
private

Definition at line 299 of file DTOccupancyTest.cc.

References DTOccupancyClusterBuilder::addPoint(), DTOccupancyCluster::averageMean(), DTOccupancyCluster::averageRMS(), DTOccupancyClusterBuilder::buildClusters(), DTOccupancyClusterBuilder::getBestCluster(), getHLTprescales::index, DTOccupancyClusterBuilder::isProblematic(), LogTrace, Association::map, point, plotscripts::rms(), DTChamberId::sector(), mathSSE::sqrt(), DTChamberId::station(), makeHLTPrescaleTable::values, and DTChamberId::wheel().

300  {
301  int nBinsX = histo->GetNbinsX();
302 
303  // Reset the error flags
304  bool failSL = false;
305  bool failLayer = false;
306  bool failCells = false;
307 
308  // Check that the chamber has digis
309  if(histo->Integral() == 0) {
310  chamberPercentage = 0;
311  return 4;
312  }
313 
314  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << "--- Occupancy test for chamber: " << chId << endl;
315  // set the # of SLs
316  int nSL = 3;
317  if(chId.station() == 4) nSL = 2;
318 
319  //
320  float values[28];
321  if(writeRootFile) {
322  values[0] = lsCounter;
323  values[1] = chId.wheel();
324  values[2] = chId.station();
325  values[3] = chId.sector();
326  }
327 
328  // Compute the average occupancy per layer and its RMS
329  // we also look of the layer with the smallest RMS in order to find a reference value
330  // for the cell occupancy
331  double totalChamberOccupp = 0;
332  double squaredLayerOccupSum = 0;
333 
334  map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
335  map<DTLayerId, double> layerOccupancyMap;
336 
337  int index = 3;
338  for(int slay = 1; slay <= 3; ++slay) { // loop over SLs
339  // Skip layer 2 on MB4
340  if(chId.station() == 4 && slay == 2) {
341  if(writeRootFile) {
342  values[12] = -1;
343  values[13] = -1;
344  values[14] = -1;
345  values[15] = -1;
346  values[16] = -1;
347  values[17] = -1;
348  values[18] = -1;
349  values[19] = -1;
350  }
351  index = 19;
352  continue;
353  }
354  // check the SL occupancy
355  int binYlow = ((slay-1)*4)+1;
356  int binYhigh = binYlow+3;
357  double slInteg = histo->Integral(1,nBinsX,binYlow,binYhigh);
358  if(slInteg == 0) {
359  chamberPercentage = 1.-1./(float)nSL;
360  return 3;
361  }
362 
363  for(int lay = 1; lay <= 4; ++lay) { // loop over layers
364  DTLayerId layID(chId,slay,lay);
365 
366  int binY = binYlow+(lay-1);
367 
368  double layerInteg = histo->Integral(1,nBinsX,binY,binY);
369  squaredLayerOccupSum += layerInteg*layerInteg;
370  totalChamberOccupp+= layerInteg;
371 
372  layerOccupancyMap[layID] = layerInteg;
373 
374  // We look for the distribution of hits within the layer
375  int nWires = muonGeom->layer(layID)->specificTopology().channels();
376  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
377  double layerSquaredSum = 0;
378  // reset the alert bit in the plot (used by render plugins)
379  histo->SetBinContent(nBinsX+1,binY,0.);
380 
381  for(int cell = firstWire; cell != (nWires+firstWire); ++cell) { // loop over cells
382  double cellOccup = histo->GetBinContent(cell,binY);
383  layerSquaredSum+=cellOccup*cellOccup;
384  }
385 
386 
387 
388  // compute the average cell occpuancy and RMS
389  double averageCellOccup = layerInteg/nWires;
390  double averageSquaredCellOccup = layerSquaredSum/nWires;
391  double rmsCellOccup = sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
392  averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
393  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " " << layID
394  << " average cell occ.: " << averageCellOccup
395  << " RMS: " << rmsCellOccup << endl;
396  if(writeRootFile) {
397  index++;
398  values[index] = averageCellOccup;
399  index++;
400  values[index] = rmsCellOccup;
401  }
402  }
403  }
404 
405 
406  if(writeRootFile) ntuple->Fill(values);
407 
408 // double averageLayerOcc = totalChamberOccupp/(nSL*4);
409 // double averageSquaredLayeroccup = squaredLayerOccupSum/(nSL*4);
410 // double layerOccupRMS = sqrt(averageSquaredLayeroccup - averageLayerOcc*averageLayerOcc);
411 
412  double minCellRMS = 99999999;
413  double referenceCellOccup = -1;
414 
416 
417  // find the cell reference value
418  for(map<DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
419  layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
420  DTLayerId lid = (*layAndValues).first;
421 
422  double rms = (*layAndValues).second.second;
423  double lOcc = layerOccupancyMap[lid]; // FIXME: useless
424  double avCellOcc = (*layAndValues).second.first;
425  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " " << lid << " tot. occ: " << lOcc
426  << " average cell occ: " << avCellOcc
427  << " RMS: " << rms << endl;
428 
429  if(avCellOcc != 0) {
430  DTOccupancyPoint point(avCellOcc, rms, lid);
431  builder.addPoint(point);
432  } else {
433  if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
434  }
435  }
436 
437  builder.buildClusters();
438  referenceCellOccup = builder.getBestCluster().averageMean();
439  minCellRMS = builder.getBestCluster().averageRMS();
440 
441 // set<DTLayerId> bestLayers getLayerIDs()
442 
443  double safeFactor = 3.;
444 // if(minCellRMS > referenceCellOccup) safeFactor = 5;
445 
446  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " Reference cell occup.: " << referenceCellOccup
447  << " RMS: " << minCellRMS << endl;
448 
449  // Set a warning for particularly high RMS: noise can "mask" dead channels
450 // bool rmsWarning = false;
451 // if(layerOccupRMS > averageLayerOcc) {
452 // cout << " Warning RMS is too big: monitoring all layers" << endl;
453 // rmsWarning = true;
454 // }
455 
456  int nFailingSLs = 0;
457 
458  // Check the layer occupancy
459  for(int slay = 1; slay <= 3; ++slay) { // loop over SLs
460  // Skip layer 2 on MB4
461  if(chId.station() == 4 && slay == 2) continue;
462 
463  int binYlow = ((slay-1)*4)+1;
464 // int binYhigh = binYlow+3;
465 
466 
467  int nFailingLayers = 0;
468 
469  for(int lay = 1; lay <= 4; ++lay) { // loop over layers
470  DTLayerId layID(chId,slay,lay);
471  int nWires = muonGeom->layer(layID)->specificTopology().channels();
472  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
473  int binY = binYlow+(lay-1);
474 
475  // compute the integral of the layer occupancy
476  double layerInteg = histo->Integral(1,nBinsX,binY,binY);
477 
478  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " layer: " << layID << " integral: " << layerInteg << endl;
479 
480  // Check if in the list of layers which are monitored
481  bool alreadyMonitored = false;
482  if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored = true;
483 
484 
485  if(layerInteg == 0) { // layer is dead (no need to go further
486  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " fail layer: no entries" << endl;
487  // Add it to the list of of monitored layers
488  if(!alreadyMonitored) monitoredLayers.insert(layID);
489  nFailingLayers++;
490  failLayer = true;
491  histo->SetBinContent(nBinsX+1,binY,-1.);
492  // go to next layer
493  continue;
494  }
495 
496 
497 
498 // double avCellOccInLayer = averageCellOccupAndRMS[layID].first;
499 // double cellOccupRMS = averageCellOccupAndRMS[layID].second;
500 // if(monitoredLayers.find(layID) != monitoredLayers.end() ||
501 // layerInteg == 0 ||
502 // layerInteg < (averageLayerOcc - 3*layerOccupRMS) ||
503 // cellOccupRMS > avCellOccInLayer ||
504 // avCellOccInLayer < referenceCellOccup/3.) { // check the layer
505 
506  if(alreadyMonitored || builder.isProblematic(layID)) { // check the layer
507 
508  // Add it to the list of of monitored layers
509  if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
510 
511 // if(layerInteg != 0) { // check # of dead cells
512  int totalDeadCells = 0;
513  int nDeadCellsInARow = 1;
514  int nDeadCellsInARowMax = 0;
515  int nCellsZeroCount = 0;
516  bool previousIsDead = false;
517 
518  int interDeadCells = 0;
519  for(int cell = firstWire; cell != (nWires+firstWire); ++cell) { // loop over cells
520  double cellOccup = histo->GetBinContent(cell,binY);
521  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " cell occup: " << cellOccup;
522  if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*sqrt(referenceCellOccup))) {
523  if(cellOccup == 0) nCellsZeroCount++;
524  totalDeadCells++;
525  if(previousIsDead) nDeadCellsInARow++;
526  previousIsDead = true;
527  interDeadCells = 0;
528  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " below reference" << endl;
529  } else {
530  previousIsDead = false;
531  interDeadCells++;
532 
533  // 3 cells not dead between a group of dead cells don't break the count
534  if(interDeadCells > 3) {
535  if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
536  nDeadCellsInARow = 1;
537  }
538  }
539  }
540  if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
541  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " # wires: " << nWires
542  << " # cells 0 count: " << nCellsZeroCount
543  << " # dead cells in a row: " << nDeadCellsInARowMax
544  << " total # of dead cells: " << totalDeadCells;
545 
546 
547  // Count dead cells
548 // if(TMath::Erf(referenceCellOccup/sqrt(referenceCellOccup)) > 2./3. &&
549 // nDeadCellsInARowMax > nWires/3.
550 // && nDeadCellsInARowMax < 2*nWires/3.) {
551 // cout << " -> fail cells!" << endl;
552 
553 // failCells = true;
554 // histo->SetBinContent(nBinsX+1,binY,-1.);
555 // } else
556  if((TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup)) < 10./(double)nWires &&
557  nDeadCellsInARowMax>= 10.) ||
558  (TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup)) < 0.5 &&
559  totalDeadCells > nWires/2.)) {
560  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " -> fail layer!" << endl;
561  nFailingLayers++;
562  failLayer = true;
563  histo->SetBinContent(nBinsX+1,binY,-1.);
564  } else if(referenceCellOccup > 10 &&
565  nCellsZeroCount > nWires/3. &&
566  (double)nCellsZeroCount/(double)nWires >
567  2.*TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup))) {
568  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " -> would fail cells!" << endl;
569  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " # of cells with 0 count: " << nCellsZeroCount
570  << " # wires: " << nWires
571  << " erfc: "
572  << TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup))
573  << endl;
574 // failCells = true;
575 // histo->SetBinContent(nBinsX+1,binY,-1.);
576  }
577 
578 // } else { // all layer is dead
579 // LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " fail layer: no entries" << endl;
580 // nFailingLayers++;
581 // failLayer = true;
582 // histo->SetBinContent(nBinsX+1,binY,-1.);
583 // }
584  }
585  }
586  // Check if the whole layer is off
587  if( nFailingLayers == 4) {
588  nFailingSLs++;
589  failSL = true;
590  }
591  }
592 
593  // All the chamber is off
594  if(nFailingSLs == nSL) {
595  chamberPercentage = 0;
596  return 4;
597  } else {
598  chamberPercentage = 1.-(float)nFailingSLs/(float)nSL;
599  }
600 
601  // FIXME add check on cells
602  if(failSL) return 3;
603  if(failLayer) return 2;
604  if(failCells) return 1;
605 
606  return 0;
607 }
DTOccupancyCluster getBestCluster() const
get the cluster correspondig to &quot;normal&quot; cell occupancy.
dictionary map
Definition: Association.py:205
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
T sqrt(T t)
Definition: SSEVec.h:46
#define LogTrace(id)
edm::ESHandle< DTGeometry > muonGeom
double averageMean() const
average cell occupancy of the layers in the cluster
void addPoint(const DTOccupancyPoint &point)
Add an occupancy point for a given layer.
void buildClusters()
build the clusters
std::set< DTLayerId > monitoredLayers
int sector() const
Definition: DTChamberId.h:63
bool isProblematic(DTLayerId layerId) const
int station() const
Return the station number.
Definition: DTChamberId.h:53
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:47
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
string DTOccupancyTest::topFolder ( ) const
private

Definition at line 610 of file DTOccupancyTest.cc.

610  {
611  if(tpMode) return string("DT/10-TestPulses/");
612  return string("DT/01-Digi/");
613 }

Member Data Documentation

DQMStore* DTOccupancyTest::dbe
private

Definition at line 80 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::glbSummaryHisto
private

Definition at line 87 of file DTOccupancyTest.h.

int DTOccupancyTest::lsCounter
private

Definition at line 91 of file DTOccupancyTest.h.

std::set<DTLayerId> DTOccupancyTest::monitoredLayers
private

Definition at line 89 of file DTOccupancyTest.h.

edm::ESHandle<DTGeometry> DTOccupancyTest::muonGeom
private

Definition at line 82 of file DTOccupancyTest.h.

std::string DTOccupancyTest::nameMonitoredHisto
private

Definition at line 102 of file DTOccupancyTest.h.

int DTOccupancyTest::nevents
private

Definition at line 78 of file DTOccupancyTest.h.

int DTOccupancyTest::nMinEvts
private

Definition at line 92 of file DTOccupancyTest.h.

TNtuple* DTOccupancyTest::ntuple
private

Definition at line 96 of file DTOccupancyTest.h.

TFile* DTOccupancyTest::rootFile
private

Definition at line 95 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnAllHitsOccupancies
private

Definition at line 99 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnInTimeOccupancies
private

Definition at line 101 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnNoiseOccupancies
private

Definition at line 100 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::summaryHisto
private

Definition at line 86 of file DTOccupancyTest.h.

bool DTOccupancyTest::tpMode
private

Definition at line 97 of file DTOccupancyTest.h.

std::map< int, MonitorElement* > DTOccupancyTest::wheelHistos
private

Definition at line 85 of file DTOccupancyTest.h.

bool DTOccupancyTest::writeRootFile
private

Definition at line 94 of file DTOccupancyTest.h.