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 (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &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...
 
int getIntegral (TH2F *histo, int, int, int, int, bool)
 
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, mps_fire::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:301
MonitorElement * summaryHisto
std::string nameMonitoredHisto
tuple result
Definition: mps_fire.py:95
void Fill(long long x)
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.
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:273
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
int DTOccupancyTest::getIntegral ( TH2F *  histo,
int  firstBinX,
int  lastBinX,
int  firstBinY,
int  lastBinY,
bool  doall 
)
private

Definition at line 267 of file DTOccupancyTest.cc.

References i, and j.

267  {
268 
269  int sum = 0;
270  for (Int_t i = firstBinX; i < lastBinX+1; i++) {
271  for (Int_t j = firstBinY; j < lastBinY+1; j++) {
272 
273  if (histo->GetBinContent(i,j) >0){
274  if (!doall) return 1;
275  sum += histo->GetBinContent(i,j);
276  }
277  }
278  }
279 
280  return sum;
281 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
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 293 of file DTOccupancyTest.cc.

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

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

References AlCaHLTBitMon_QueryRunRegistry::string.

558  {
559  if(tpMode) return string("DT/10-TestPulses/");
560  return string("DT/01-Digi/");
561 }

Member Data Documentation

bool DTOccupancyTest::bookingdone
private

Definition at line 100 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::glbSummaryHisto
private

Definition at line 83 of file DTOccupancyTest.h.

int DTOccupancyTest::lsCounter
private

Definition at line 87 of file DTOccupancyTest.h.

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

Definition at line 85 of file DTOccupancyTest.h.

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

Definition at line 78 of file DTOccupancyTest.h.

std::string DTOccupancyTest::nameMonitoredHisto
private

Definition at line 98 of file DTOccupancyTest.h.

int DTOccupancyTest::nevents
private

Definition at line 76 of file DTOccupancyTest.h.

int DTOccupancyTest::nMinEvts
private

Definition at line 88 of file DTOccupancyTest.h.

TNtuple* DTOccupancyTest::ntuple
private

Definition at line 92 of file DTOccupancyTest.h.

TFile* DTOccupancyTest::rootFile
private

Definition at line 91 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnAllHitsOccupancies
private

Definition at line 95 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnInTimeOccupancies
private

Definition at line 97 of file DTOccupancyTest.h.

bool DTOccupancyTest::runOnNoiseOccupancies
private

Definition at line 96 of file DTOccupancyTest.h.

MonitorElement* DTOccupancyTest::summaryHisto
private

Definition at line 82 of file DTOccupancyTest.h.

bool DTOccupancyTest::tpMode
private

Definition at line 93 of file DTOccupancyTest.h.

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

Definition at line 81 of file DTOccupancyTest.h.

bool DTOccupancyTest::writeRootFile
private

Definition at line 90 of file DTOccupancyTest.h.