CMS 3D CMS Logo

DTt0DBValidation.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 
19 
20 // Geometry
25 
26 // t0
29 
30 #include "TFile.h"
31 
32 #include <iomanip>
33 #include <sstream>
34 
35 using namespace edm;
36 using namespace std;
37 
39  metname_ = "InterChannelSynchDBValidation";
40  LogVerbatim(metname_) << "[DTt0DBValidation] Constructor called!";
41 
42  // Get the DQM needed services
44  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation");
45 
46  // Get dataBase label
47  labelDBRef_ = pset.getParameter<string>("labelDBRef");
48  labelDB_ = pset.getParameter<string>("labelDB");
49 
50  t0TestName_ = "t0DifferenceInRange";
51  if (pset.exists("t0TestName"))
52  t0TestName_ = pset.getParameter<string>("t0TestName");
53 
54  outputMEsInRootFile_ = false;
55  if (pset.exists("OutputFileName")) {
56  outputMEsInRootFile_ = true;
57  outputFileName_ = pset.getParameter<std::string>("OutputFileName");
58  }
59 }
60 
62 
64  metname_ = "InterChannelSynchDBValidation";
65  LogVerbatim(metname_) << "[DTt0DBValidation] Parameters initialization";
66 
67  ESHandle<DTT0> t0_Ref;
68  setup.get<DTT0Rcd>().get(labelDBRef_, t0_Ref);
69  tZeroRefMap_ = &*t0_Ref;
70  LogVerbatim(metname_) << "[DTt0DBValidation] reference T0 version: " << t0_Ref->version();
71 
73  setup.get<DTT0Rcd>().get(labelDB_, t0);
74  tZeroMap_ = &*t0;
75  LogVerbatim(metname_) << "[DTt0DBValidation] T0 to validate version: " << t0->version();
76 
77  // book&reset the summary histos
78  for (int wheel = -2; wheel <= 2; wheel++) {
80  wheelSummary_[wheel]->Reset();
81  }
82 
83  // Get the geometry
84  setup.get<MuonGeometryRecord>().get(dtGeom_);
85 
86  // Loop over Ref DB entries
87  for (DTT0::const_iterator tzero = tZeroRefMap_->begin(); tzero != tZeroRefMap_->end(); tzero++) {
88  // t0s and rms are TDC counts
89  // @@@ NEW DTT0 FORMAT
90  // DTWireId wireId((*tzero).first.wheelId,
91  // (*tzero).first.stationId,
92  // (*tzero).first.sectorId,
93  // (*tzero).first.slId,
94  // (*tzero).first.layerId,
95  // (*tzero).first.cellId);
96  int channelId = tzero->channelId;
97  if (channelId == 0)
98  continue;
99  DTWireId wireId(channelId);
100  // @@@ NEW DTT0 END
101  float t0mean;
102  float t0rms;
103  tZeroRefMap_->get(wireId, t0mean, t0rms, DTTimeUnits::counts);
104  LogTrace(metname_) << "Ref Wire: " << wireId << endl
105  << " T0 mean (TDC counts): " << t0mean << " T0_rms (TDC counts): " << t0rms;
106 
107  t0RefMap_[wireId].push_back(t0mean);
108  t0RefMap_[wireId].push_back(t0rms);
109  }
110 
111  // Loop over Ref DB entries
112  for (DTT0::const_iterator tzero = tZeroMap_->begin(); tzero != tZeroMap_->end(); tzero++) {
113  // t0s and rms are TDC counts
114  // @@@ NEW DTT0 FORMAT
115  // DTWireId wireId((*tzero).first.wheelId,
116  // (*tzero).first.stationId,
117  // (*tzero).first.sectorId,
118  // (*tzero).first.slId,
119  // (*tzero).first.layerId,
120  // (*tzero).first.cellId);
121  int channelId = tzero->channelId;
122  if (channelId == 0)
123  continue;
124  DTWireId wireId(channelId);
125  // @@@ NEW DTT0 END
126  float t0mean;
127  float t0rms;
128  tZeroMap_->get(wireId, t0mean, t0rms, DTTimeUnits::counts);
129  LogTrace(metname_) << "Wire: " << wireId << endl
130  << " T0 mean (TDC counts): " << t0mean << " T0_rms (TDC counts): " << t0rms;
131 
132  t0Map_[wireId].push_back(t0mean);
133  t0Map_[wireId].push_back(t0rms);
134  }
135 
136  double difference = 0;
137  for (map<DTWireId, vector<float>>::const_iterator theMap = t0RefMap_.begin(); theMap != t0RefMap_.end(); theMap++) {
138  if (t0Map_.find((*theMap).first) != t0Map_.end()) {
139  // Compute the difference
140  difference = t0Map_[(*theMap).first][0] - (*theMap).second[0];
141 
142  // book histo
143  DTLayerId layerId = (*theMap).first.layerId();
144  if (t0DiffHistos_.find(layerId) == t0DiffHistos_.end()) {
145  const DTTopology &dtTopo = dtGeom_->layer(layerId)->specificTopology();
146  const int firstWire = dtTopo.firstChannel();
147  const int lastWire = dtTopo.lastChannel();
148  bookHistos(layerId, firstWire, lastWire);
149  }
150 
151  LogTrace(metname_) << "Filling the histo for wire: " << (*theMap).first << " difference: " << difference;
152  t0DiffHistos_[layerId]->Fill((*theMap).first.wire(), difference);
153  }
154  } // Loop over the t0 map reference
155 }
156 
158  // Check the histos
159  string testCriterionName = t0TestName_;
160  for (map<DTLayerId, MonitorElement *>::const_iterator hDiff = t0DiffHistos_.begin(); hDiff != t0DiffHistos_.end();
161  hDiff++) {
162  const QReport *theDiffQReport = (*hDiff).second->getQReport(testCriterionName);
163  if (theDiffQReport) {
164  int xBin = ((*hDiff).first.station() - 1) * 12 + (*hDiff).first.layer() + 4 * ((*hDiff).first.superlayer() - 1);
165  if ((*hDiff).first.station() == 4 && (*hDiff).first.superlayer() == 3)
166  xBin = ((*hDiff).first.station() - 1) * 12 + (*hDiff).first.layer() + 4 * ((*hDiff).first.superlayer() - 2);
167 
168  int qReportStatus = theDiffQReport->getStatus() / 100;
169  wheelSummary_[(*hDiff).first.wheel()]->setBinContent(xBin, (*hDiff).first.sector(), qReportStatus);
170 
171  LogVerbatim(metname_) << "-------- layer: " << (*hDiff).first << " " << theDiffQReport->getMessage()
172  << " ------- " << theDiffQReport->getStatus() << " ------- " << setprecision(3)
173  << theDiffQReport->getQTresult();
174  vector<dqm::me_util::Channel> badChannels = theDiffQReport->getBadChannels();
175  for (vector<dqm::me_util::Channel>::iterator channel = badChannels.begin(); channel != badChannels.end();
176  channel++) {
177  LogVerbatim(metname_) << "layer: " << (*hDiff).first << " Bad channel: " << (*channel).getBin()
178  << " Contents : " << (*channel).getContents();
179 
180  // wheelSummary_[(*hDiff).first.wheel()]->Fill(xBin,(*hDiff).first.sector());
181  }
182  }
183  }
184 }
185 
187  // Write the histos on a file
188  if (outputMEsInRootFile_)
189  dbe_->save(outputFileName_);
190 }
191 
192 // Book a set of histograms for a given Layer
193 void DTt0DBValidation::bookHistos(DTLayerId lId, int firstWire, int lastWire) {
194  LogTrace(metname_) << " Booking histos for L: " << lId;
195 
196  // Compose the chamber name
197  stringstream wheel;
198  wheel << lId.superlayerId().chamberId().wheel();
199  stringstream station;
200  station << lId.superlayerId().chamberId().station();
201  stringstream sector;
202  sector << lId.superlayerId().chamberId().sector();
203  stringstream superLayer;
204  superLayer << lId.superlayerId().superlayer();
205  stringstream layer;
206  layer << lId.layer();
207 
208  string lHistoName = "_W" + wheel.str() + "_St" + station.str() + "_Sec" + sector.str() + "_SL" + superLayer.str() +
209  "_L" + layer.str();
210 
211  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation/Wheel" + wheel.str() + "/Station" + station.str() +
212  "/Sector" + sector.str() + "/SuperLayer" + superLayer.str());
213  // Create the monitor elements
214  MonitorElement *hDifference;
215  hDifference = dbe_->book1D("T0Difference" + lHistoName,
216  "difference between the two t0 values",
217  lastWire - firstWire + 1,
218  firstWire - 0.5,
219  lastWire + 0.5);
220 
221  t0DiffHistos_[lId] = hDifference;
222 }
223 
224 // Book the summary histos
226  dbe_->setCurrentFolder("DT/DtCalib/InterChannelSynchDBValidation");
227  stringstream wh;
228  wh << wheel;
229  wheelSummary_[wheel] = dbe_->book2D(
230  "SummaryWrongT0_W" + wh.str(), "W" + wh.str() + ": summary of wrong t0 differences", 44, 1, 45, 14, 1, 15);
231  wheelSummary_[wheel]->setBinLabel(1, "M1L1", 1);
232  wheelSummary_[wheel]->setBinLabel(2, "M1L2", 1);
233  wheelSummary_[wheel]->setBinLabel(3, "M1L3", 1);
234  wheelSummary_[wheel]->setBinLabel(4, "M1L4", 1);
235  wheelSummary_[wheel]->setBinLabel(5, "M1L5", 1);
236  wheelSummary_[wheel]->setBinLabel(6, "M1L6", 1);
237  wheelSummary_[wheel]->setBinLabel(7, "M1L7", 1);
238  wheelSummary_[wheel]->setBinLabel(8, "M1L8", 1);
239  wheelSummary_[wheel]->setBinLabel(9, "M1L9", 1);
240  wheelSummary_[wheel]->setBinLabel(10, "M1L10", 1);
241  wheelSummary_[wheel]->setBinLabel(11, "M1L11", 1);
242  wheelSummary_[wheel]->setBinLabel(12, "M1L12", 1);
243  wheelSummary_[wheel]->setBinLabel(13, "M2L1", 1);
244  wheelSummary_[wheel]->setBinLabel(14, "M2L2", 1);
245  wheelSummary_[wheel]->setBinLabel(15, "M2L3", 1);
246  wheelSummary_[wheel]->setBinLabel(16, "M2L4", 1);
247  wheelSummary_[wheel]->setBinLabel(17, "M2L5", 1);
248  wheelSummary_[wheel]->setBinLabel(18, "M2L6", 1);
249  wheelSummary_[wheel]->setBinLabel(19, "M2L7", 1);
250  wheelSummary_[wheel]->setBinLabel(20, "M2L8", 1);
251  wheelSummary_[wheel]->setBinLabel(21, "M2L9", 1);
252  wheelSummary_[wheel]->setBinLabel(22, "M2L10", 1);
253  wheelSummary_[wheel]->setBinLabel(23, "M2L11", 1);
254  wheelSummary_[wheel]->setBinLabel(24, "M2L12", 1);
255  wheelSummary_[wheel]->setBinLabel(25, "M3L1", 1);
256  wheelSummary_[wheel]->setBinLabel(26, "M3L2", 1);
257  wheelSummary_[wheel]->setBinLabel(27, "M3L3", 1);
258  wheelSummary_[wheel]->setBinLabel(28, "M3L4", 1);
259  wheelSummary_[wheel]->setBinLabel(29, "M3L5", 1);
260  wheelSummary_[wheel]->setBinLabel(30, "M3L6", 1);
261  wheelSummary_[wheel]->setBinLabel(31, "M3L7", 1);
262  wheelSummary_[wheel]->setBinLabel(32, "M3L8", 1);
263  wheelSummary_[wheel]->setBinLabel(33, "M3L9", 1);
264  wheelSummary_[wheel]->setBinLabel(34, "M3L10", 1);
265  wheelSummary_[wheel]->setBinLabel(35, "M3L11", 1);
266  wheelSummary_[wheel]->setBinLabel(36, "M3L12", 1);
267  wheelSummary_[wheel]->setBinLabel(37, "M4L1", 1);
268  wheelSummary_[wheel]->setBinLabel(38, "M4L2", 1);
269  wheelSummary_[wheel]->setBinLabel(39, "M4L3", 1);
270  wheelSummary_[wheel]->setBinLabel(40, "M4L4", 1);
271  wheelSummary_[wheel]->setBinLabel(41, "M4L5", 1);
272  wheelSummary_[wheel]->setBinLabel(42, "M4L6", 1);
273  wheelSummary_[wheel]->setBinLabel(43, "M4L7", 1);
274  wheelSummary_[wheel]->setBinLabel(44, "M4L8", 1);
275 }
T getParameter(std::string const &) const
void endRun(edm::Run const &, edm::EventSetup const &) override
const std::vector< DQMChannel > & getBadChannels() const
Definition: QReport.h:33
DTChamberId chamberId() const
Return the corresponding ChamberId.
bool exists(std::string const &parameterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
int layer() const
Return the layer number.
Definition: DTLayerId.h:53
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
Definition: DTLayerId.h:59
std::vector< DTT0Data >::const_iterator const_iterator
Access methods to data.
Definition: DTT0.h:140
int firstChannel() const
Returns the wire number of the first wire.
Definition: DTTopology.h:78
void bookHistos()
Definition: Histogram.h:33
int lastChannel() const
Returns the wire number of the last wire.
Definition: DTTopology.h:80
DTt0DBValidation(const edm::ParameterSet &pset)
Constructor.
void endJob() override
const std::string & getMessage() const
get message attached to test
Definition: QReport.h:24
#define LogTrace(id)
DQMStore * dbe_
~DTt0DBValidation() override
Destructor.
int superlayer() const
Return the superlayer number (deprecated method name)
void beginRun(const edm::Run &run, const edm::EventSetup &setup) override
Operations.
int getStatus() const
get test status (see Core/interface/QTestStatus.h)
Definition: QReport.h:16
Definition: DTT0Rcd.h:9
HLT enums.
int sector() const
Definition: DTChamberId.h:61
T get() const
Definition: EventSetup.h:71
void bookHistos(DTLayerId lId, int firstWire, int lastWire)
static const double tzero[3]
float getQTresult() const
get test result i.e. prob value
Definition: QReport.h:20
const std::string & version() const
access version
Definition: DTT0.cc:118
int station() const
Return the station number.
Definition: DTChamberId.h:51
int wheel() const
Return the wheel number.
Definition: DTChamberId.h:45
Definition: Run.h:45