test
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 edm::EDConsumerBase

Public Member Functions

 DTOccupancyTest (const edm::ParameterSet &ps)
 Constructor. More...
 
virtual ~DTOccupancyTest ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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::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 (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
 
- 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 33 of file DTOccupancyTest.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 31 of file DTOccupancyTest.cc.

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

31  {
32  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: Constructor";
33 
34  // 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 }
T getUntrackedParameter(std::string const &, T const &) const
bool runOnAllHitsOccupancies
DTOccupancyTest::~DTOccupancyTest ( )
virtual

Destructor.

Definition at line 58 of file DTOccupancyTest.cc.

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

Member Function Documentation

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

Analyze.

Implements edm::EDAnalyzer.

Definition at line 130 of file DTOccupancyTest.cc.

References nevents.

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 67 of file DTOccupancyTest.cc.

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

67  {
68  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest]: BeginJob";
69 
70  // Event counter
71  nevents = 0;
72 
73  // Book the summary histos
74  // - one summary per wheel
75  for(int wh = -2; wh <= 2; ++wh) { // loop over wheels
76  bookHistos(wh, string("Occupancies"), "OccupancySummary");
77  }
78 
80  string title = "Occupancy Summary";
81  if(tpMode) {
82  title = "Test Pulse Occupancy Summary";
83  }
84  // - global summary with alarms
85  summaryHisto = dbe->book2D("OccupancySummary",title.c_str(),12,1,13,5,-2,3);
86  summaryHisto->setAxisTitle("sector",1);
87  summaryHisto->setAxisTitle("wheel",2);
88 
89  // - global summary with percentages
90  glbSummaryHisto = dbe->book2D("OccupancyGlbSummary",title.c_str(),12,1,13,5,-2,3);
91  glbSummaryHisto->setAxisTitle("sector",1);
92  glbSummaryHisto->setAxisTitle("wheel",2);
93 
94 
95  // assign the name of the input histogram
97  nameMonitoredHisto = "OccupancyAllHits_perCh";
98  } else if(runOnNoiseOccupancies) {
99  nameMonitoredHisto = "OccupancyNoise_perCh";
100  } else if(runOnInTimeOccupancies) {
101  nameMonitoredHisto = "OccupancyInTimeHits_perCh";
102  } else { // default is AllHits histo
103  nameMonitoredHisto = "OccupancyAllHits_perCh";
104  }
105 
106 }
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:1082
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:667
MonitorElement * glbSummaryHisto
void DTOccupancyTest::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiSeg,
edm::EventSetup const &  context 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 123 of file DTOccupancyTest.cc.

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

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 111 of file DTOccupancyTest.cc.

References edm::EventSetup::get().

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

book the summary histograms

Definition at line 233 of file DTOccupancyTest.cc.

233  {
234  // Set the current folder
235  stringstream wheel; wheel << wheelId;
237 
238  // build the histo name
239  string histoName = histoTag + "_W" + wheel.str();
240 
241 
242  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") <<"[DTOccupancyTest]: booking wheel histo:"
243  << histoName
244  << " (tag "
245  << histoTag
246  << ") in: "
247  << topFolder() + "Wheel"+ wheel.str() + "/" + folder << endl;
248 
249  string histoTitle = "Occupancy summary WHEEL: "+wheel.str();
250  if(tpMode) {
251  histoTitle = "TP Occupancy summary WHEEL: "+wheel.str();
252  }
253  wheelHistos[wheelId] = dbe->book2D(histoName,histoTitle,12,1,13,4,1,5);
254  wheelHistos[wheelId]->setBinLabel(1,"MB1",2);
255  wheelHistos[wheelId]->setBinLabel(2,"MB2",2);
256  wheelHistos[wheelId]->setBinLabel(3,"MB3",2);
257  wheelHistos[wheelId]->setBinLabel(4,"MB4",2);
258  wheelHistos[wheelId]->setAxisTitle("sector",1);
259 }
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:1082
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
void DTOccupancyTest::endJob ( void  )
protectedvirtual

Endjob.

Reimplemented from edm::EDAnalyzer.

Definition at line 220 of file DTOccupancyTest.cc.

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

DQM Client Diagnostic.

Reimplemented from edm::EDAnalyzer.

Definition at line 139 of file DTOccupancyTest.cc.

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

139  {
140  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest")
141  <<"[DTOccupancyTest]: End of LS transition, performing the DQM client operation";
142  lsCounter++;
143 
144 
145 
146  // Reset the global summary
147  summaryHisto->Reset();
149 
150  // Get all the DT chambers
151  vector<const DTChamber*> chambers = muonGeom->chambers();
152 
153  for(vector<const DTChamber*>::const_iterator chamber = chambers.begin();
154  chamber != chambers.end(); ++chamber) { // Loop over all chambers
155  DTChamberId chId = (*chamber)->id();
156 
157  MonitorElement * chamberOccupancyHisto = dbe->get(getMEName(nameMonitoredHisto, chId));
158 
159  // Run the tests on the plot for the various granularities
160  if(chamberOccupancyHisto != 0) {
161  // Get the 2D histo
162  TH2F* histo = chamberOccupancyHisto->getTH2F();
163  float chamberPercentage = 1.;
164  int result = runOccupancyTest(histo, chId, chamberPercentage);
165  int sector = chId.sector();
166 
167  if(sector == 13) {
168  sector = 4;
169  float resultSect4 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
170  if(resultSect4 > result) {
171  result = (int)resultSect4;
172  }
173  } else if(sector == 14) {
174  sector = 10;
175  float resultSect10 = wheelHistos[chId.wheel()]->getBinContent(sector, chId.station());
176  if(resultSect10 > result) {
177  result = (int)resultSect10;
178  }
179  }
180 
181  // the 2 MB4 of Sect 4 and 10 count as half a chamber
182  if((sector == 4 || sector == 10) && chId.station() == 4)
183  chamberPercentage = chamberPercentage/2.;
184 
185  wheelHistos[chId.wheel()]->setBinContent(sector, chId.station(),result);
186  if(result > summaryHisto->getBinContent(sector, chId.wheel()+3)) {
187  summaryHisto->setBinContent(sector, chId.wheel()+3, result);
188  }
189  glbSummaryHisto->Fill(sector, chId.wheel(), chamberPercentage*1./4.);
190  } else {
191  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
192  << getMEName(nameMonitoredHisto, chId) << " not found!" << endl;
193  }
194 
195  }
196 
197  string nEvtsName = "DT/EventInfo/Counters/nProcessedEventsDigi";
198  MonitorElement * meProcEvts = dbe->get(nEvtsName);
199 
200  if (meProcEvts) {
201  int nProcEvts = meProcEvts->getFloatValue();
202  glbSummaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
203  summaryHisto->setEntries(nProcEvts < nMinEvts ? 10. : nProcEvts);
204  } else {
207  LogVerbatim ("DTDQM|DTMonitorClient|DTOccupancyTest") << "[DTOccupancyTest] ME: "
208  << nEvtsName << " not found!" << endl;
209  }
210 
211  // Fill the global summary
212  // Check for entire sectors off and report them on the global summary
213  //FIXME: TODO
214 
215  if(writeRootFile) ntuple->AutoSave("SaveSelf");
216 
217 }
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
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:1708
edm::ESHandle< DTGeometry > muonGeom
double getBinContent(int binx) const
get content of bin (1-D)
int sector() const
Definition: DTChamberId.h:61
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 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 263 of file DTOccupancyTest.cc.

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

263  {
264 
265  stringstream wheel; wheel << chId.wheel();
266  stringstream station; station << chId.station();
267  stringstream sector; sector << chId.sector();
268 
269 
270  string folderRoot = topFolder() + "Wheel" + wheel.str() +
271  "/Sector" + sector.str() +
272  "/Station" + station.str() + "/";
273 
274  string folder = "Occupancies/";
275 
276  // build the histo name
277  string histoName = histoTag
278  + "_W" + wheel.str()
279  + "_St" + station.str()
280  + "_Sec" + sector.str();
281 
282  string histoname = folderRoot + histoName;
283 
284  return histoname;
285 }
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 297 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().

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

References AlCaHLTBitMon_QueryRunRegistry::string.

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

Member Data Documentation

DQMStore* DTOccupancyTest::dbe
private

Definition at line 78 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::glbSummaryHisto
private

Definition at line 85 of file DTOccupancyTest.h.

int DTOccupancyTest::lsCounter
private

Definition at line 89 of file DTOccupancyTest.h.

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

Definition at line 87 of file DTOccupancyTest.h.

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

Definition at line 80 of file DTOccupancyTest.h.

std::string DTOccupancyTest::nameMonitoredHisto
private

Definition at line 100 of file DTOccupancyTest.h.

int DTOccupancyTest::nevents
private

Definition at line 76 of file DTOccupancyTest.h.

int DTOccupancyTest::nMinEvts
private

Definition at line 90 of file DTOccupancyTest.h.

TNtuple* DTOccupancyTest::ntuple
private

Definition at line 94 of file DTOccupancyTest.h.

TFile* DTOccupancyTest::rootFile
private

Definition at line 93 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnAllHitsOccupancies
private

Definition at line 97 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnInTimeOccupancies
private

Definition at line 99 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnNoiseOccupancies
private

Definition at line 98 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::summaryHisto
private

Definition at line 84 of file DTOccupancyTest.h.

bool DTOccupancyTest::tpMode
private

Definition at line 95 of file DTOccupancyTest.h.

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

Definition at line 83 of file DTOccupancyTest.h.

bool DTOccupancyTest::writeRootFile
private

Definition at line 92 of file DTOccupancyTest.h.