CMS 3D CMS Logo

DTnoiseDBValidation.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * \author G. Mila - INFN Torino
6  */
7 
9 
10 // Framework
15 
18 
19 // Geometry
24 
25 // Noise record
27 
28 #include "TFile.h"
29 #include "TH1F.h"
30 #include <cmath>
31 #include <cstdio>
32 #include <sstream>
33 
34 using namespace edm;
35 using namespace std;
36 
38  : labelDBRef_(esConsumes(edm::ESInputTag("", pset.getParameter<string>("labelDBRef")))),
39  labelDB_(esConsumes(edm::ESInputTag("", pset.getParameter<string>("labelDB")))),
40  muonGeomToken_(esConsumes<edm::Transition::BeginRun>()) {
41  LogVerbatim("NoiseDBValidation") << "[DTnoiseDBValidation] Constructor called!";
42 
43  // Get the DQM needed services
44  dbe_ = edm::Service<DQMStore>().operator->();
45  dbe_->setCurrentFolder("DT/DtCalib/NoiseDBValidation");
46 
47  diffTestName_ = "noiseDifferenceInRange";
48  if (pset.exists("diffTestName"))
49  diffTestName_ = pset.getParameter<string>("diffTestName");
50 
51  wheelTestName_ = "noiseWheelOccInRange";
52  if (pset.exists("wheelTestName"))
53  wheelTestName_ = pset.getParameter<string>("wheelTestName");
54 
55  stationTestName_ = "noiseStationOccInRange";
56  if (pset.exists("stationTestName"))
57  stationTestName_ = pset.getParameter<string>("stationTestName");
58 
59  sectorTestName_ = "noiseSectorOccInRange";
60  if (pset.exists("sectorTestName"))
61  sectorTestName_ = pset.getParameter<string>("sectorTestName");
62 
63  layerTestName_ = "noiseLayerOccInRange";
64  if (pset.exists("layerTestName"))
65  layerTestName_ = pset.getParameter<string>("layerTestName");
66 
67  outputMEsInRootFile_ = false;
68  if (pset.exists("OutputFileName")) {
69  outputMEsInRootFile_ = true;
70  outputFileName_ = pset.getParameter<std::string>("OutputFileName");
71  }
72 }
73 
75 
77  noiseRefMap_ = &setup.getData(labelDBRef_);
78 
79  noiseMap_ = &setup.getData(labelDB_);
80  ;
81 
82  // Get the geometry
83  dtGeom = &setup.getData(muonGeomToken_);
84 
85  LogVerbatim("NoiseDBValidation") << "[DTnoiseDBValidation] Parameters initialization";
86 
87  noisyCellsRef_ = 0;
88  noisyCellsValid_ = 0;
89 
90  // Histo booking
91  diffHisto_ =
92  dbe_->book1D("noisyCellDiff", "percentual (wrt the previous db) total number of noisy cells", 1, 0.5, 1.5);
93  diffHisto_->setBinLabel(1, "Diff");
94  wheelHisto_ = dbe_->book1D("wheelOccupancy", "percentual noisy cells occupancy per wheel", 5, -2.5, 2.5);
95  wheelHisto_->setBinLabel(1, "Wh-2");
96  wheelHisto_->setBinLabel(2, "Wh-1");
97  wheelHisto_->setBinLabel(3, "Wh0");
98  wheelHisto_->setBinLabel(4, "Wh1");
99  wheelHisto_->setBinLabel(5, "Wh2");
100  stationHisto_ = dbe_->book1D("stationOccupancy", "percentual noisy cells occupancy per station", 4, 0.5, 4.5);
101  stationHisto_->setBinLabel(1, "St1");
102  stationHisto_->setBinLabel(2, "St2");
103  stationHisto_->setBinLabel(3, "St3");
104  stationHisto_->setBinLabel(4, "St4");
105  sectorHisto_ = dbe_->book1D("sectorOccupancy", "percentual noisy cells occupancy per sector", 12, 0.5, 12.5);
106  sectorHisto_->setBinLabel(1, "Sect1");
107  sectorHisto_->setBinLabel(2, "Sect2");
108  sectorHisto_->setBinLabel(3, "Sect3");
109  sectorHisto_->setBinLabel(4, "Sect4");
110  sectorHisto_->setBinLabel(5, "Sect5");
111  sectorHisto_->setBinLabel(6, "Sect6");
112  sectorHisto_->setBinLabel(7, "Sect7");
113  sectorHisto_->setBinLabel(8, "Sect8");
114  sectorHisto_->setBinLabel(9, "Sect9");
115  sectorHisto_->setBinLabel(10, "Sect10");
116  sectorHisto_->setBinLabel(11, "Sect11");
117  sectorHisto_->setBinLabel(12, "Sect12");
118  layerHisto_ = dbe_->book1D("layerOccupancy", "percentual noisy cells occupancy per layer", 3, 0.5, 3.5);
119  layerHisto_->setBinLabel(1, "First 10 bins");
120  layerHisto_->setBinLabel(2, "Middle bins");
121  layerHisto_->setBinLabel(3, "Last 10 bins");
122 
123  // map initialization
124  map<int, int> whMap;
125  whMap.clear();
126  map<int, int> stMap;
127  stMap.clear();
128  map<int, int> sectMap;
129  sectMap.clear();
130  map<int, int> layerMap;
131  layerMap.clear();
132 
133  // Loop over reference DB entries
135  DTWireId wireId((*noise).first.wheelId,
136  (*noise).first.stationId,
137  (*noise).first.sectorId,
138  (*noise).first.slId,
139  (*noise).first.layerId,
140  (*noise).first.cellId);
141  LogVerbatim("NoiseDBValidation") << "Ref. noisy wire: " << wireId;
142  ++noisyCellsRef_;
143  }
144 
145  // Loop over validation DB entries
147  DTWireId wireId((*noise).first.wheelId,
148  (*noise).first.stationId,
149  (*noise).first.sectorId,
150  (*noise).first.slId,
151  (*noise).first.layerId,
152  (*noise).first.cellId);
153  LogVerbatim("NoiseDBValidation") << "Valid. noisy wire: " << wireId;
155 
156  whMap[(*noise).first.wheelId]++;
157  stMap[(*noise).first.stationId]++;
158  sectMap[(*noise).first.sectorId]++;
159 
160  const DTTopology &dtTopo = dtGeom->layer(wireId.layerId())->specificTopology();
161  const int lastWire = dtTopo.lastChannel();
162  if ((*noise).first.cellId <= 10)
163  layerMap[1]++;
164  if ((*noise).first.cellId > 10 && (*noise).first.cellId < (lastWire - 10))
165  layerMap[2]++;
166  if ((*noise).first.cellId >= (lastWire - 10))
167  layerMap[3]++;
168 
169  const DTChamberId chId = wireId.layerId().superlayerId().chamberId();
170  if (noiseHistoMap_.find(chId) == noiseHistoMap_.end())
171  bookHisto(chId);
172  int binNumber = 4 * (wireId.superLayer() - 1) + wireId.layer();
173  noiseHistoMap_[chId]->Fill(wireId.wire(), binNumber);
174  }
175 
176  // histo filling
177  double scale = 1 / double(noisyCellsRef_);
179 
180  scale = 1 / double(noisyCellsValid_);
181  for (map<int, int>::const_iterator wheel = whMap.begin(); wheel != whMap.end(); wheel++) {
182  wheelHisto_->Fill((*wheel).first, ((*wheel).second) * scale);
183  }
184  for (map<int, int>::const_iterator station = stMap.begin(); station != stMap.end(); station++) {
185  stationHisto_->Fill((*station).first, ((*station).second) * scale);
186  }
187  for (map<int, int>::const_iterator sector = sectMap.begin(); sector != sectMap.end(); sector++) {
188  sectorHisto_->Fill((*sector).first, ((*sector).second) * scale);
189  }
190  for (map<int, int>::const_iterator layer = layerMap.begin(); layer != layerMap.end(); layer++) {
191  layerHisto_->Fill((*layer).first, ((*layer).second) * scale);
192  }
193 }
194 
196  // test on difference histo
197  // string testCriterionName;
198  // testCriterionName =
199  // parameters.getUntrackedParameter<string>("diffTestName","noiseDifferenceInRange");
200  const QReport *theDiffQReport = diffHisto_->getQReport(diffTestName_);
201  if (theDiffQReport) {
202  vector<dqm::me_util::Channel> badChannels = theDiffQReport->getBadChannels();
203  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
204  channel++) {
205  LogWarning("NoiseDBValidation") << " Bad partial difference of noisy channels! Contents : "
206  << (*channel).getContents();
207  }
208  }
209  // testCriterionName =
210  // parameters.getUntrackedParameter<string>("wheelTestName","noiseWheelOccInRange");
211  const QReport *theDiffQReport2 = wheelHisto_->getQReport(wheelTestName_);
212  if (theDiffQReport2) {
213  vector<dqm::me_util::Channel> badChannels = theDiffQReport2->getBadChannels();
214  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
215  channel++) {
216  int wheel = (*channel).getBin() - 3;
217  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for wheel : " << wheel
218  << " Contents : " << (*channel).getContents();
219  }
220  }
221  // testCriterionName =
222  // parameters.getUntrackedParameter<string>("stationTestName","noiseStationOccInRange");
223  const QReport *theDiffQReport3 = stationHisto_->getQReport(stationTestName_);
224  if (theDiffQReport3) {
225  vector<dqm::me_util::Channel> badChannels = theDiffQReport3->getBadChannels();
226  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
227  channel++) {
228  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for station : " << (*channel).getBin()
229  << " Contents : " << (*channel).getContents();
230  }
231  }
232  // testCriterionName =
233  // parameters.getUntrackedParameter<string>("sectorTestName","noiseSectorOccInRange");
234  const QReport *theDiffQReport4 = sectorHisto_->getQReport(sectorTestName_);
235  if (theDiffQReport4) {
236  vector<dqm::me_util::Channel> badChannels = theDiffQReport4->getBadChannels();
237  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
238  channel++) {
239  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for sector : " << (*channel).getBin()
240  << " Contents : " << (*channel).getContents();
241  }
242  }
243  // testCriterionName =
244  // parameters.getUntrackedParameter<string>("layerTestName","noiseLayerOccInRange");
245  const QReport *theDiffQReport5 = layerHisto_->getQReport(layerTestName_);
246  if (theDiffQReport5) {
247  vector<dqm::me_util::Channel> badChannels = theDiffQReport5->getBadChannels();
248  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
249  channel++) {
250  if ((*channel).getBin() == 1)
251  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for the first 10 wires! Contents : "
252  << (*channel).getContents();
253  if ((*channel).getBin() == 2)
254  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for the middle wires! Contents : "
255  << (*channel).getContents();
256  if ((*channel).getBin() == 3)
257  LogWarning("NoiseDBValidation") << " Bad percentual occupancy for the last 10 wires! Contents : "
258  << (*channel).getContents();
259  }
260  }
261 }
262 
264  // Write the histos in a ROOT file
267 }
268 
270  stringstream histoName;
271  histoName << "NoiseOccupancy"
272  << "_W" << chId.wheel() << "_St" << chId.station() << "_Sec" << chId.sector();
273 
274  if (noiseHistoMap_.find(chId) == noiseHistoMap_.end()) { // Redundant check
275  // Get the chamber from the geometry
276  int nWiresMax = 0;
277  const DTChamber *dtchamber = dtGeom->chamber(chId);
278  const vector<const DTSuperLayer *> &superlayers = dtchamber->superLayers();
279 
280  // Loop over layers and find the max # of wires
281  for (vector<const DTSuperLayer *>::const_iterator sl = superlayers.begin(); sl != superlayers.end();
282  ++sl) { // loop over SLs
283  vector<const DTLayer *> layers = (*sl)->layers();
284  for (vector<const DTLayer *>::const_iterator lay = layers.begin(); lay != layers.end();
285  ++lay) { // loop over layers
286  int nWires = (*lay)->specificTopology().channels();
287  if (nWires > nWiresMax)
288  nWiresMax = nWires;
289  }
290  }
291 
292  noiseHistoMap_[chId] = dbe_->book2D(histoName.str(), "Noise occupancy", nWiresMax, 1, (nWiresMax + 1), 12, 1, 13);
293  for (int i_sl = 1; i_sl <= 3; ++i_sl) {
294  for (int i_lay = 1; i_lay <= 4; ++i_lay) {
295  int binNumber = 4 * (i_sl - 1) + i_lay;
296  stringstream label;
297  label << "SL" << i_sl << ": L" << i_lay;
298  noiseHistoMap_[chId]->setBinLabel(binNumber, label.str(), 2);
299  }
300  }
301  }
302 }
DTnoiseDBValidation::sectorTestName_
std::string sectorTestName_
Definition: DTnoiseDBValidation.h:56
DTWireId::wire
int wire() const
Return the wire number.
Definition: DTWireId.h:42
edm::ESInputTag
Definition: ESInputTag.h:87
MessageLogger.h
DTnoiseDBValidation::DTnoiseDBValidation
DTnoiseDBValidation(const edm::ParameterSet &pset)
Constructor.
Definition: DTnoiseDBValidation.cc:37
L1EGammaCrystalsEmulatorProducer_cfi.scale
scale
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:10
DTnoiseDBValidation::noiseHistoMap_
std::map< DTChamberId, MonitorElement * > noiseHistoMap_
Definition: DTnoiseDBValidation.h:78
ESHandle.h
DTnoiseDBValidation::bookHisto
void bookHisto(const DTChamberId &)
Definition: DTnoiseDBValidation.cc:269
edm::Run
Definition: Run.h:45
DTLayerId.h
relativeConstraints.station
station
Definition: relativeConstraints.py:67
edm
HLT enums.
Definition: AlignableModifier.h:19
DTnoiseDBValidation::diffHisto_
MonitorElement * diffHisto_
Definition: DTnoiseDBValidation.h:73
DTChamber
Definition: DTChamber.h:24
DTnoiseDBValidation::muonGeomToken_
edm::ESGetToken< DTGeometry, MuonGeometryRecord > muonGeomToken_
Definition: DTnoiseDBValidation.h:62
DQMStore.h
DTnoiseDBValidation::endJob
void endJob() override
Definition: DTnoiseDBValidation.cc:263
DTnoiseDBValidation::dtGeom
const DTGeometry * dtGeom
Definition: DTnoiseDBValidation.h:63
DTnoiseDBValidation::endRun
void endRun(edm::Run const &, edm::EventSetup const &) override
Definition: DTnoiseDBValidation.cc:195
DTnoiseDBValidation::layerHisto_
MonitorElement * layerHisto_
Definition: DTnoiseDBValidation.h:77
DTSuperLayerId::superLayer
int superLayer() const
Return the superlayer number.
Definition: DTSuperLayerId.h:39
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
DTnoiseDBValidation::diffTestName_
std::string diffTestName_
Definition: DTnoiseDBValidation.h:56
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
DTGeometry::chamber
const DTChamber * chamber(const DTChamberId &id) const
Return a DTChamber given its id.
Definition: DTGeometry.cc:90
DTStatusFlag::begin
const_iterator begin() const
Definition: DTStatusFlag.cc:294
DTnoiseDBValidation::noiseRefMap_
const DTStatusFlag * noiseRefMap_
Definition: DTnoiseDBValidation.h:67
DTTopology
Definition: DTTopology.h:28
DTnoiseDBValidation::stationHisto_
MonitorElement * stationHisto_
Definition: DTnoiseDBValidation.h:75
DTWireId
Definition: DTWireId.h:12
DTnoiseDBValidation::noiseMap_
const DTStatusFlag * noiseMap_
Definition: DTnoiseDBValidation.h:66
Service.h
dqm::impl::MonitorElement::Fill
void Fill(long long x)
Definition: MonitorElement.h:290
DTStatusFlag::const_iterator
std::vector< std::pair< DTStatusFlagId, DTStatusFlagData > >::const_iterator const_iterator
Access methods to data.
Definition: DTStatusFlag.h:192
DTnoiseDBValidation::~DTnoiseDBValidation
~DTnoiseDBValidation() override
Destructor.
Definition: DTnoiseDBValidation.cc:74
dqm::implementation::DQMStore::setCurrentFolder
void setCurrentFolder(std::string const &fullpath) override
Definition: DQMStore.h:569
DTnoiseDBValidation::outputFileName_
std::string outputFileName_
Definition: DTnoiseDBValidation.h:59
MonitorElementData::QReport::getBadChannels
const std::vector< DQMChannel > & getBadChannels() const
Definition: MonitorElementCollection.h:116
DTnoiseDBValidation::labelDB_
edm::ESGetToken< DTStatusFlag, DTStatusFlagRcd > labelDB_
Definition: DTnoiseDBValidation.h:53
dqm::implementation::DQMStore::save
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:784
DTStatusFlag.h
DTnoiseDBValidation::outputMEsInRootFile_
bool outputMEsInRootFile_
Definition: DTnoiseDBValidation.h:58
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
DTGeometry.h
dqm::impl::MonitorElement::getQReport
const MonitorElementData::QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
Definition: MonitorElement.cc:472
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Transition
Transition
Definition: Transition.h:12
DTGeometry::layer
const DTLayer * layer(const DTLayerId &id) const
Return a layer given its id.
Definition: DTGeometry.cc:96
Event.h
DTSuperLayerId::chamberId
DTChamberId chamberId() const
Return the corresponding ChamberId.
Definition: DTSuperLayerId.h:45
plotT0FromHistos.binNumber
def binNumber(station, sl)
Definition: plotT0FromHistos.py:6
MonitorElementData::QReport
Definition: MonitorElementCollection.h:55
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
edm::Service
Definition: Service.h:30
DTnoiseDBValidation::noisyCellsValid_
int noisyCellsValid_
Definition: DTnoiseDBValidation.h:71
dqm::impl::MonitorElement::setBinLabel
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
Definition: MonitorElement.cc:762
DTChamber::superLayers
const std::vector< const DTSuperLayer * > & superLayers() const
Return the superlayers in the chamber.
Definition: DTChamber.cc:51
DTnoiseDBValidation::layerTestName_
std::string layerTestName_
Definition: DTnoiseDBValidation.h:56
DTnoiseDBValidation::sectorHisto_
MonitorElement * sectorHisto_
Definition: DTnoiseDBValidation.h:76
edm::EventSetup
Definition: EventSetup.h:58
DTnoiseDBValidation.h
gpuVertexFinder::noise
__shared__ int noise
Definition: gpuFitVertices.h:50
DTStatusFlag::end
const_iterator end() const
Definition: DTStatusFlag.cc:296
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTnoiseDBValidation::stationTestName_
std::string stationTestName_
Definition: DTnoiseDBValidation.h:56
DTTopology::lastChannel
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:81
DTnoiseDBValidation::wheelTestName_
std::string wheelTestName_
Definition: DTnoiseDBValidation.h:56
DTnoiseDBValidation::labelDBRef_
edm::ESGetToken< DTStatusFlag, DTStatusFlagRcd > labelDBRef_
Definition: DTnoiseDBValidation.h:52
DTChamberId::sector
int sector() const
Definition: DTChamberId.h:49
std
Definition: JetResolutionObject.h:76
writedatasetfile.run
run
Definition: writedatasetfile.py:27
DTWireId.h
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
edm::Transition::BeginRun
dqm::implementation::IBooker::book2D
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:177
DTnoiseDBValidation::beginRun
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
Operations.
Definition: DTnoiseDBValidation.cc:76
DTLayerId::superlayerId
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:45
HltBtagPostValidation_cff.histoName
histoName
Definition: HltBtagPostValidation_cff.py:17
EventSetup.h
DTWireId::layerId
DTLayerId layerId() const
Return the corresponding LayerId.
Definition: DTWireId.h:45
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
DTChamberId
Definition: DTChamberId.h:14
DeDxTools::esConsumes
ESGetTokenH3DDVariant esConsumes(std::string const &Reccord, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
DTLayerId::layer
int layer() const
Return the layer number.
Definition: DTLayerId.h:42
DTnoiseDBValidation::dbe_
DQMStore * dbe_
Definition: DTnoiseDBValidation.h:50
DTTopology.h
DTChamberId::wheel
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:39
label
const char * label
Definition: PFTauDecayModeTools.cc:11
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
DTChamberId::station
int station() const
Return the station number.
Definition: DTChamberId.h:42
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqm::implementation::IBooker::book1D
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
DTnoiseDBValidation::wheelHisto_
MonitorElement * wheelHisto_
Definition: DTnoiseDBValidation.h:74
DTnoiseDBValidation::noisyCellsRef_
int noisyCellsRef_
Definition: DTnoiseDBValidation.h:70