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:
DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 DTOccupancyTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTOccupancyTest ()
 Destructor. More...
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
 DQMEDHarvester (void)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void beginRun (edm::Run const &run, edm::EventSetup const &context)
 BeginRun. More...
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &)
 Endjob. More...
 
void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 DQM Client Diagnostic. More...
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Member Functions

void bookHistos (DQMStore::IBooker &, 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

bool bookingdone
 
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::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 39 of file DTOccupancyTest.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 32 of file DTOccupancyTest.cc.

References edm::ParameterSet::getUntrackedParameter(), and cmsHarvester::nevents.

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

Member Function Documentation

void DTOccupancyTest::beginRun ( edm::Run const &  run,
edm::EventSetup const &  context 
)
protectedvirtual

BeginRun.

Reimplemented from DQMEDHarvester.

Definition at line 65 of file DTOccupancyTest.cc.

References edm::EventSetup::get().

65  {
66 
67  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: BeginRun";
68 
69  // Get the geometry
70  context.get<MuonGeometryRecord>().get(muonGeom);
71 
72 }
edm::ESHandle< DTGeometry > muonGeom
void DTOccupancyTest::bookHistos ( DQMStore::IBooker ,
const int  wheelId,
std::string  folder,
std::string  histoTag 
)
private

book the summary histograms

Definition at line 209 of file DTOccupancyTest.cc.

References DQMStore::IBooker::book2D(), MonitorElement::setBinLabel(), and DQMStore::IBooker::setCurrentFolder().

210  {
211  // Set the current folder
212  stringstream wheel; wheel << wheelId;
213 
214  ibooker.setCurrentFolder(topFolder());
215 
216  // build the histo name
217  string histoName = histoTag + "_W" + wheel.str();
218 
219 
220  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") <<"[DTOccupancyTest]: booking wheel histo:"
221  << histoName
222  << " (tag "
223  << histoTag
224  << ") in: "
225  << topFolder() + "Wheel"+ wheel.str() + "/" + folder << endl;
226 
227  string histoTitle = "Occupancy summary WHEEL: "+wheel.str();
228  if(tpMode) {
229  histoTitle = "TP Occupancy summary WHEEL: "+wheel.str();
230  }
231 
232  wheelHistos[wheelId] = ibooker.book2D(histoName,histoTitle,12,1,13,4,1,5);
233  wheelHistos[wheelId]->setBinLabel(1,"MB1",2);
234  wheelHistos[wheelId]->setBinLabel(2,"MB2",2);
235  wheelHistos[wheelId]->setBinLabel(3,"MB3",2);
236  wheelHistos[wheelId]->setBinLabel(4,"MB4",2);
237  wheelHistos[wheelId]->setAxisTitle("sector",1);
238 }
std::map< int, MonitorElement * > wheelHistos
std::string topFolder() const
void DTOccupancyTest::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
protectedvirtual

Endjob.

Implements DQMEDHarvester.

Definition at line 195 of file DTOccupancyTest.cc.

195  {
196 
197  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] endjob called!";
198  if(writeRootFile) {
199  rootFile->cd();
200  ntuple->Write();
201  rootFile->Close();
202  }
203 }
void DTOccupancyTest::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
protectedvirtual

DQM Client Diagnostic.

Reimplemented from DQMEDHarvester.

Definition at line 74 of file DTOccupancyTest.cc.

References DQMStore::IBooker::book2D(), bookHistos(), chambers, DQMStore::IGetter::get(), MonitorElement::getFloatValue(), MonitorElement::getTH2F(), timingPdfMaker::histo, query::result, DTChamberId::sector(), MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), DTChamberId::station(), indexGen::title, and DTChamberId::wheel().

75  {
76  if (!bookingdone) {
77 
78  // Book the summary histos
79  // - one summary per wheel
80  for(int wh = -2; wh <= 2; ++wh) { // loop over wheels
81  bookHistos(ibooker,wh, string("Occupancies"), "OccupancySummary");
82  }
83 
84  ibooker.setCurrentFolder(topFolder());
85  string title = "Occupancy Summary";
86  if(tpMode) {
87  title = "Test Pulse Occupancy Summary";
88  }
89  // - global summary with alarms
90  summaryHisto = ibooker.book2D("OccupancySummary",title.c_str(),12,1,13,5,-2,3);
91  summaryHisto->setAxisTitle("sector",1);
92  summaryHisto->setAxisTitle("wheel",2);
93 
94  // - global summary with percentages
95  glbSummaryHisto = ibooker.book2D("OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
96  glbSummaryHisto->setAxisTitle("sector",1);
97  glbSummaryHisto->setAxisTitle("wheel",2);
98 
99 
100  // assign the name of the input histogram
102  nameMonitoredHisto = "OccupancyAllHits_perCh";
103  } else if(runOnNoiseOccupancies) {
104  nameMonitoredHisto = "OccupancyNoise_perCh";
105  } else if(runOnInTimeOccupancies) {
106  nameMonitoredHisto = "OccupancyInTimeHits_perCh";
107  } else { // default is AllHits histo
108  nameMonitoredHisto = "OccupancyAllHits_perCh";
109  }
110 
111  }
112  bookingdone = 1;
113 
114 
115  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest")
116  <<"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
117  lsCounter++;
118 
119 
120 
121  // Reset the global summary
122  summaryHisto->Reset();
124 
125  // Get all the DT chambers
126  vector<const DTChamber*> chambers = muonGeom->chambers();
127 
128  for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
129  chamber != chambers.end(); ++chamber) { // Loop over all chambers
130  DTChamberId chId = (*chamber)->id();
131 
132  MonitorElement * chamberOccupancyHisto = igetter.get(getMEName(nameMonitoredHisto, chId));
133 
134  // Run the tests on the plot for the various granularities
135  if(chamberOccupancyHisto != 0) {
136  // Get the 2D histo
137  TH2F* histo = chamberOccupancyHisto->getTH2F();
138  float chamberPercentage = 1.;
139  int result = runOccupancyTest(histo, chId, chamberPercentage);
140  int sector = chId.sector();
141 
142  if(sector == 13) {
143  sector = 4;
144  float resultSect4 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
145  if(resultSect4 > result) {
146  result = (int)resultSect4;
147  }
148  } else if(sector == 14) {
149  sector = 10;
150  float resultSect10 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
151  if(resultSect10 > result) {
152  result = (int)resultSect10;
153  }
154  }
155 
156  // the 2 MB4 of Sect 4 and 10 count as half a chamber
157  if((sector == 4 || sector == 10) && chId.station() == 4)
158  chamberPercentage = chamberPercentage/2.;
159 
160  wheelHistos[chId.wheel()]->setBinContent(sector, chId.station(),result);
161  if(result > summaryHisto->getBinContent(sector, chId.wheel()+3)) {
162  summaryHisto->setBinContent(sector, chId.wheel()+3, result);
163  }
164  glbSummaryHisto->Fill(sector, chId.wheel(), chamberPercentage*1./4.);
165  } else {
166  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
167  << getMEName(nameMonitoredHisto, chId) << " not found!" << endl;
168  }
169 
170  }
171 
172  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsDigi";
173 
174  MonitorElement * meProcEvts = igetter.get(nEvtsName);
175 
176  if (meProcEvts) {
177  int nProcEvts = meProcEvts->getFloatValue();
178  glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
179  summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
180  } else {
183  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
184  << nEvtsName << " not found!" << endl;
185  }
186 
187  // Fill the global summary
188  // Check for entire sectors off and report them on the global summary
189  //FIXME: TODO
190 
191  if(writeRootFile) ntuple->AutoSave("SaveSelf");
192 
193 }
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 * get(const std::string &path)
Definition: DQMStore.cc:302
MonitorElement * summaryHisto
std::string nameMonitoredHisto
void Fill(long long x)
void bookHistos(DQMStore::IBooker &, const int wheelId, std::string folder, std::string histoTag)
book the summary histograms
tuple result
Definition: query.py:137
std::string getMEName(std::string histoTag, const DTChamberId &chId)
Get the ME name.
double getFloatValue(void) const
bool runOnAllHitsOccupancies
void setEntries(double nentries)
set # of entries
edm::ESHandle< DTGeometry > muonGeom
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
double getBinContent(int binx) const
get content of bin (1-D)
int sector() const
Definition: DTChamberId.h:61
std::string topFolder() const
int station() const
Return the station number.
Definition: DTChamberId.h:51
TH2F * getTH2F(void) const
static char chambers[264][20]
Definition: ReadPGInfo.cc:243
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
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 242 of file DTOccupancyTest.cc.

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

242  {
243 
244  stringstream wheel; wheel << chId.wheel();
245  stringstream station; station << chId.station();
246  stringstream sector; sector << chId.sector();
247 
248 
249  string folderRoot = topFolder() + "Wheel" + wheel.str() +
250  "/Sector" + sector.str() +
251  "/Station" + station.str() + "/";
252 
253  string folder = "Occupancies/";
254 
255  // build the histo name
256  string histoName = histoTag
257  + "_W" + wheel.str()
258  + "_St" + station.str()
259  + "_Sec" + sector.str();
260 
261  string histoname = folderRoot + histoName;
262 
263  return histoname;
264 }
int sector() const
Definition: DTChamberId.h:61
std::string topFolder() const
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
int DTOccupancyTest::runOccupancyTest ( TH2F *  histo,
const DTChamberId chId,
float &  chamberPercentage 
)
private

Definition at line 276 of file DTOccupancyTest.cc.

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

277  {
278  int nBinsX = histo->GetNbinsX();
279 
280  // Reset the error flags
281  bool failSL = false;
282  bool failLayer = false;
283  bool failCells = false;
284 
285  // Check that the chamber has digis
286  if(histo->Integral() == 0) {
287  chamberPercentage = 0;
288  return 4;
289  }
290 
291  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << "--- Occupancy test for chamber: " << chId << endl;
292  // set the # of SLs
293  int nSL = 3;
294  if(chId.station() == 4) nSL = 2;
295 
296  //
297  float values[28];
298  if(writeRootFile) {
299  values[0] = lsCounter;
300  values[1] = chId.wheel();
301  values[2] = chId.station();
302  values[3] = chId.sector();
303  }
304 
305  // Compute the average occupancy per layer and its RMS
306  // we also look of the layer with the smallest RMS in order to find a reference value
307  // for the cell occupancy
308  double totalChamberOccupp = 0;
309  double squaredLayerOccupSum = 0;
310 
311  map<DTLayerId, pair<double, double> > averageCellOccupAndRMS;
312  map<DTLayerId, double> layerOccupancyMap;
313 
314  int index = 3;
315  for(int slay = 1; slay <= 3; ++slay) { // loop over SLs
316  // Skip layer 2 on MB4
317  if(chId.station() == 4 && slay == 2) {
318  if(writeRootFile) {
319  values[12] = -1;
320  values[13] = -1;
321  values[14] = -1;
322  values[15] = -1;
323  values[16] = -1;
324  values[17] = -1;
325  values[18] = -1;
326  values[19] = -1;
327  }
328  index = 19;
329  continue;
330  }
331  // check the SL occupancy
332  int binYlow = ((slay-1)*4)+1;
333  int binYhigh = binYlow+3;
334  double slInteg = histo->Integral(1,nBinsX,binYlow,binYhigh);
335  if(slInteg == 0) {
336  chamberPercentage = 1.-1./(float)nSL;
337  return 3;
338  }
339 
340  for(int lay = 1; lay <= 4; ++lay) { // loop over layers
341  DTLayerId layID(chId,slay,lay);
342 
343  int binY = binYlow+(lay-1);
344 
345  double layerInteg = histo->Integral(1,nBinsX,binY,binY);
346  squaredLayerOccupSum += layerInteg*layerInteg;
347  totalChamberOccupp+= layerInteg;
348 
349  layerOccupancyMap[layID] = layerInteg;
350 
351  // We look for the distribution of hits within the layer
352  int nWires = muonGeom->layer(layID)->specificTopology().channels();
353  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
354  double layerSquaredSum = 0;
355  // reset the alert bit in the plot (used by render plugins)
356  histo->SetBinContent(nBinsX+1,binY,0.);
357 
358  for(int cell = firstWire; cell != (nWires+firstWire); ++cell) { // loop over cells
359  double cellOccup = histo->GetBinContent(cell,binY);
360  layerSquaredSum+=cellOccup*cellOccup;
361  }
362 
363 
364 
365  // compute the average cell occpuancy and RMS
366  double averageCellOccup = layerInteg/nWires;
367  double averageSquaredCellOccup = layerSquaredSum/nWires;
368  double rmsCellOccup = sqrt(averageSquaredCellOccup - averageCellOccup*averageCellOccup);
369  averageCellOccupAndRMS[layID] = make_pair(averageCellOccup, rmsCellOccup);
370  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " " << layID
371  << " average cell occ.: " << averageCellOccup
372  << " RMS: " << rmsCellOccup << endl;
373  if(writeRootFile) {
374  index++;
375  values[index] = averageCellOccup;
376  index++;
377  values[index] = rmsCellOccup;
378  }
379  }
380  }
381 
382 
383  if(writeRootFile) ntuple->Fill(values);
384 
385  double minCellRMS = 99999999;
386  double referenceCellOccup = -1;
387 
389 
390  // find the cell reference value
391  for(map<DTLayerId, pair<double, double> >::const_iterator layAndValues = averageCellOccupAndRMS.begin();
392  layAndValues != averageCellOccupAndRMS.end(); layAndValues++) {
393  DTLayerId lid = (*layAndValues).first;
394 
395  double rms = (*layAndValues).second.second;
396  double lOcc = layerOccupancyMap[lid]; // FIXME: useless
397  double avCellOcc = (*layAndValues).second.first;
398  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " " << lid << " tot. occ: " << lOcc
399  << " average cell occ: " << avCellOcc
400  << " RMS: " << rms << endl;
401 
402  if(avCellOcc != 0) {
403  DTOccupancyPoint point(avCellOcc, rms, lid);
404  builder.addPoint(point);
405  } else {
406  if(monitoredLayers.find(lid) == monitoredLayers.end()) monitoredLayers.insert(lid);
407  }
408  }
409 
410  builder.buildClusters();
411  referenceCellOccup = builder.getBestCluster().averageMean();
412  minCellRMS = builder.getBestCluster().averageRMS();
413 
414  double safeFactor = 3.;
415 
416  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " Reference cell occup.: " << referenceCellOccup
417  << " RMS: " << minCellRMS << endl;
418 
419  int nFailingSLs = 0;
420 
421  // Check the layer occupancy
422  for(int slay = 1; slay <= 3; ++slay) { // loop over SLs
423  // Skip layer 2 on MB4
424  if(chId.station() == 4 && slay == 2) continue;
425 
426  int binYlow = ((slay-1)*4)+1;
427  int nFailingLayers = 0;
428 
429  for(int lay = 1; lay <= 4; ++lay) { // loop over layers
430  DTLayerId layID(chId,slay,lay);
431  int nWires = muonGeom->layer(layID)->specificTopology().channels();
432  int firstWire = muonGeom->layer(layID)->specificTopology().firstChannel();
433  int binY = binYlow+(lay-1);
434 
435  // compute the integral of the layer occupancy
436  double layerInteg = histo->Integral(1,nBinsX,binY,binY);
437 
438  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " layer: " << layID << " integral: " << layerInteg << endl;
439 
440  // Check if in the list of layers which are monitored
441  bool alreadyMonitored = false;
442  if(monitoredLayers.find(layID) != monitoredLayers.end()) alreadyMonitored = true;
443 
444 
445  if(layerInteg == 0) { // layer is dead (no need to go further
446  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " fail layer: no entries" << endl;
447  // Add it to the list of of monitored layers
448  if(!alreadyMonitored) monitoredLayers.insert(layID);
449  nFailingLayers++;
450  failLayer = true;
451  histo->SetBinContent(nBinsX+1,binY,-1.);
452  // go to next layer
453  continue;
454  }
455 
456  if(alreadyMonitored || builder.isProblematic(layID)) { // check the layer
457 
458  // Add it to the list of of monitored layers
459  if(monitoredLayers.find(layID) == monitoredLayers.end()) monitoredLayers.insert(layID);
460 
461  int totalDeadCells = 0;
462  int nDeadCellsInARow = 1;
463  int nDeadCellsInARowMax = 0;
464  int nCellsZeroCount = 0;
465  bool previousIsDead = false;
466 
467  int interDeadCells = 0;
468  for(int cell = firstWire; cell != (nWires+firstWire); ++cell) { // loop over cells
469  double cellOccup = histo->GetBinContent(cell,binY);
470  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " cell occup: " << cellOccup;
471  if(cellOccup == 0 || cellOccup < (referenceCellOccup-safeFactor*sqrt(referenceCellOccup))) {
472  if(cellOccup == 0) nCellsZeroCount++;
473  totalDeadCells++;
474  if(previousIsDead) nDeadCellsInARow++;
475  previousIsDead = true;
476  interDeadCells = 0;
477  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " below reference" << endl;
478  } else {
479  previousIsDead = false;
480  interDeadCells++;
481 
482  // 3 cells not dead between a group of dead cells don't break the count
483  if(interDeadCells > 3) {
484  if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
485  nDeadCellsInARow = 1;
486  }
487  }
488  }
489  if(nDeadCellsInARow > nDeadCellsInARowMax) nDeadCellsInARowMax = nDeadCellsInARow;
490  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " # wires: " << nWires
491  << " # cells 0 count: " << nCellsZeroCount
492  << " # dead cells in a row: " << nDeadCellsInARowMax
493  << " total # of dead cells: " << totalDeadCells;
494 
495  if((TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup)) < 10./(double)nWires &&
496  nDeadCellsInARowMax>= 10.) ||
497  (TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup)) < 0.5 &&
498  totalDeadCells > nWires/2.)) {
499  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " -> fail layer!" << endl;
500  nFailingLayers++;
501  failLayer = true;
502  histo->SetBinContent(nBinsX+1,binY,-1.);
503  } else if(referenceCellOccup > 10 &&
504  nCellsZeroCount > nWires/3. &&
505  (double)nCellsZeroCount/(double)nWires >
506  2.*TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup))) {
507  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " -> would fail cells!" << endl;
508  LogTrace("DTDQM|DTMonitorClient|DTOccupancyTest") << " # of cells with 0 count: " << nCellsZeroCount
509  << " # wires: " << nWires
510  << " erfc: "
511  << TMath::Erfc(referenceCellOccup/sqrt(referenceCellOccup))
512  << endl;
513  }
514  }
515  }
516  // Check if the whole layer is off
517  if( nFailingLayers == 4) {
518  nFailingSLs++;
519  failSL = true;
520  }
521  }
522 
523  // All the chamber is off
524  if(nFailingSLs == nSL) {
525  chamberPercentage = 0;
526  return 4;
527  } else {
528  chamberPercentage = 1.-(float)nFailingSLs/(float)nSL;
529  }
530 
531  // FIXME add check on cells
532  if(failSL) return 3;
533  if(failLayer) return 2;
534  if(failCells) return 1;
535 
536  return 0;
537 }
DTOccupancyCluster getBestCluster() const
get the cluster correspondig to &quot;normal&quot; cell occupancy.
double averageRMS() const
average RMS of the cell occpuancy distributions of the layers in the cluster
T sqrt(T t)
Definition: SSEVec.h:48
#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:61
bool isProblematic(DTLayerId layerId) const
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
*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 540 of file DTOccupancyTest.cc.

References AlCaHLTBitMon_QueryRunRegistry::string.

540  {
541  if(tpMode) return string("DT/10-TestPulses/");
542  return string("DT/01-Digi/");
543 }

Member Data Documentation

bool DTOccupancyTest::bookingdone
private

Definition at line 98 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::glbSummaryHisto
private

Definition at line 81 of file DTOccupancyTest.h.

int DTOccupancyTest::lsCounter
private

Definition at line 85 of file DTOccupancyTest.h.

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

Definition at line 83 of file DTOccupancyTest.h.

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

Definition at line 76 of file DTOccupancyTest.h.

std::string DTOccupancyTest::nameMonitoredHisto
private

Definition at line 96 of file DTOccupancyTest.h.

int DTOccupancyTest::nevents
private

Definition at line 74 of file DTOccupancyTest.h.

int DTOccupancyTest::nMinEvts
private

Definition at line 86 of file DTOccupancyTest.h.

TNtuple* DTOccupancyTest::ntuple
private

Definition at line 90 of file DTOccupancyTest.h.

TFile* DTOccupancyTest::rootFile
private

Definition at line 89 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnAllHitsOccupancies
private

Definition at line 93 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnInTimeOccupancies
private

Definition at line 95 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnNoiseOccupancies
private

Definition at line 94 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::summaryHisto
private

Definition at line 80 of file DTOccupancyTest.h.

bool DTOccupancyTest::tpMode
private

Definition at line 91 of file DTOccupancyTest.h.

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

Definition at line 79 of file DTOccupancyTest.h.

bool DTOccupancyTest::writeRootFile
private

Definition at line 88 of file DTOccupancyTest.h.