CMS 3D CMS Logo

MuonAlignmentSummary.cc
Go to the documentation of this file.
1 /*
2  * DQM client for muon alignment summary
3  *
4  * \author J. Fernandez - Univ. Oviedo <Javier.Fernandez@cern.ch>
5  */
6 
8 
10  parameters = pSet;
11 
12  meanPositionRange = parameters.getUntrackedParameter<double>("meanPositionRange");
13  rmsPositionRange = parameters.getUntrackedParameter<double>("rmsPositionRange");
14  meanAngleRange = parameters.getUntrackedParameter<double>("meanAngleRange");
15  rmsAngleRange = parameters.getUntrackedParameter<double>("rmsAngleRange");
16 
17  doDT = parameters.getUntrackedParameter<bool>("doDT");
18  doCSC = parameters.getUntrackedParameter<bool>("doCSC");
19 
20  MEFolderName = parameters.getParameter<std::string>("FolderName");
21  topFolder << MEFolderName + "Alignment/Muon";
22 
23  if (!(doDT || doCSC)) {
24  edm::LogError("MuonAlignmentSummary") << " Error!! At least one Muon subsystem (DT or CSC) must be "
25  "monitorized!!"
26  << std::endl;
27  edm::LogError("MuonAlignmentSummary")
28  << " Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
29  exit(1);
30  }
31 }
32 
34 
36  metname = "MuonAlignmentSummary";
37 
38  LogTrace(metname) << "[MuonAlignmentSummary] Parameters initialization";
39 
40  if (doDT) {
41  ibooker.setCurrentFolder(topFolder.str() + "/DT");
42  hLocalPositionDT = ibooker.book2D(
43  "hLocalPositionDT", "Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
44 
45  hLocalAngleDT = ibooker.book2D(
46  "hLocalAngleDT", "Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
47 
49  ibooker.book2D("hLocalPositionRmsDT", "Local DT position (cm) RMS residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
50 
52  ibooker.book2D("hLocalAngleRmsDT", "Local DT angle (rad) RMS residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
53 
54  hLocalXMeanDT = ibooker.book1D("hLocalXMeanDT",
55  "Distribution of absolute MEAN Local X (cm) residuals "
56  "for DT;<X> (cm);number of chambers",
57  100,
58  0,
60 
61  hLocalXRmsDT = ibooker.book1D("hLocalXRmsDT",
62  "Distribution of RMS Local X (cm) residuals "
63  "for DT;X RMS (cm);number of chambers",
64  100,
65  0,
67 
68  hLocalYMeanDT = ibooker.book1D("hLocalYMeanDT",
69  "Distribution of absolute MEAN Local Y (cm) residuals "
70  "for DT;<Y> (cm);number of chambers",
71  100,
72  0,
74 
75  hLocalYRmsDT = ibooker.book1D("hLocalYRmsDT",
76  "Distribution of RMS Local Y (cm) residuals "
77  "for DT;Y RMS (cm);number of chambers",
78  100,
79  0,
81 
82  hLocalPhiMeanDT = ibooker.book1D("hLocalPhiMeanDT",
83  "Distribution of absolute MEAN #phi (rad) residuals for "
84  "DT;<#phi>(rad);number of chambers",
85  100,
86  0,
88 
89  hLocalPhiRmsDT = ibooker.book1D("hLocalPhiRmsDT",
90  "Distribution of RMS #phi (rad) residuals "
91  "for DT;#phi RMS (rad);number of chambers",
92  100,
93  0,
95 
96  hLocalThetaMeanDT = ibooker.book1D("hLocalThetaMeanDT",
97  "Distribution of absolute MEAN #theta (rad) residuals "
98  "for DT;<#theta>(rad);number of chambers",
99  100,
100  0,
102 
103  hLocalThetaRmsDT = ibooker.book1D("hLocalThetaRmsDT",
104  "Distribution of RMS #theta (rad) residuals for "
105  "DT;#theta RMS (rad);number of chambers",
106  100,
107  0,
108  rmsAngleRange);
109 
111  hLocalAngleDT->Reset();
114  hLocalXMeanDT->Reset();
115  hLocalXRmsDT->Reset();
116  hLocalYMeanDT->Reset();
117  hLocalYRmsDT->Reset();
122  }
123 
124  if (doCSC) {
125  ibooker.setCurrentFolder(topFolder.str() + "/CSC");
126  hLocalPositionCSC = ibooker.book2D(
127  "hLocalPositionCSC", "Local CSC position (cm) absolute MEAN residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
128 
129  hLocalAngleCSC = ibooker.book2D(
130  "hLocalAngleCSC", "Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
131 
132  hLocalPositionRmsCSC = ibooker.book2D(
133  "hLocalPositionRmsCSC", "Local CSC position (cm) RMS residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
134 
136  ibooker.book2D("hLocalAngleRmsCSC", "Local CSC angle (rad) RMS residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
137 
138  hLocalXMeanCSC = ibooker.book1D("hLocalXMeanCSC",
139  "Distribution of absolute MEAN Local X (cm) residuals "
140  "for CSC;<X> (cm);number of chambers",
141  100,
142  0,
144 
145  hLocalXRmsCSC = ibooker.book1D("hLocalXRmsCSC",
146  "Distribution of RMS Local X (cm) residuals "
147  "for CSC;X RMS (cm);number of chambers",
148  100,
149  0,
151 
152  hLocalYMeanCSC = ibooker.book1D("hLocalYMeanCSC",
153  "Distribution of absolute MEAN Local Y (cm) residuals "
154  "for CSC;<Y> (cm);number of chambers",
155  100,
156  0,
158 
159  hLocalYRmsCSC = ibooker.book1D("hLocalYRmsCSC",
160  "Distribution of RMS Local Y (cm) residuals "
161  "for CSC;Y RMS (cm);number of chambers",
162  100,
163  0,
165 
166  hLocalPhiMeanCSC = ibooker.book1D("hLocalPhiMeanCSC",
167  "Distribution of absolute MEAN #phi (rad) residuals for "
168  "CSC;<#phi>(rad);number of chambers",
169  100,
170  0,
172 
173  hLocalPhiRmsCSC = ibooker.book1D("hLocalPhiRmsCSC",
174  "Distribution of RMS #phi (rad) residuals for CSC;#phi "
175  "RMS (rad);number of chambers",
176  100,
177  0,
178  rmsAngleRange);
179 
180  hLocalThetaMeanCSC = ibooker.book1D("hLocalThetaMeanCSC",
181  "Distribution of absolute MEAN #theta (rad) residuals "
182  "for CSC;<#theta>(rad);number of chambers",
183  100,
184  0,
186 
187  hLocalThetaRmsCSC = ibooker.book1D("hLocalThetaRmsCSC",
188  "Distribution of RMS #theta (rad) residuals for "
189  "CSC;#theta RMS (rad);number of chambers",
190  100,
191  0,
192  rmsAngleRange);
193 
199  hLocalXRmsCSC->Reset();
201  hLocalYRmsCSC->Reset();
206  }
207 
208  LogTrace(metname) << "[MuonAlignmentSummary] Saving the histos";
209 
210  char binLabel[40];
211 
212  for (int station = -4; station < 5; station++) {
213  if (doDT) {
214  if (station > 0) {
215  for (int wheel = -2; wheel < 3; wheel++) {
216  for (int sector = 1; sector < 15; sector++) {
217  if (!((sector == 13 || sector == 14) && station != 4)) {
218  std::stringstream Wheel;
219  Wheel << wheel;
220  std::stringstream Station;
221  Station << station;
222  std::stringstream Sector;
223  Sector << sector;
224 
225  std::string nameOfHistoLocalX =
226  "ResidualLocalX_W" + Wheel.str() + "MB" + Station.str() + "S" + Sector.str();
227  std::string nameOfHistoLocalPhi =
228  "ResidualLocalPhi_W" + Wheel.str() + "MB" + Station.str() + "S" + Sector.str();
229  std::string nameOfHistoLocalTheta =
230  "ResidualLocalTheta_W" + Wheel.str() + "MB" + Station.str() + "S" + Sector.str();
231  std::string nameOfHistoLocalY =
232  "ResidualLocalY_W" + Wheel.str() + "MB" + Station.str() + "S" + Sector.str();
233 
234  std::string path = topFolder.str() + "/DT/Wheel" + Wheel.str() + "/Station" + Station.str() + "/Sector" +
235  Sector.str() + "/";
236 
237  std::string histo = path + nameOfHistoLocalX;
238 
239  Int_t nstation = station - 1;
240  Int_t nwheel = wheel + 2;
241  MonitorElement *localX = igetter.get(histo);
242  if (localX) {
243  Double_t Mean = localX->getMean();
244  Double_t Error = localX->getMeanError();
245 
246  Int_t ybin = 1 + nwheel * 8 + nstation * 2;
247  hLocalPositionDT->setBinContent(sector, ybin, fabs(Mean));
248  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_X", wheel, station);
249  hLocalPositionDT->setBinLabel(ybin, binLabel, 2);
250  hLocalPositionRmsDT->setBinContent(sector, ybin, Error);
251  hLocalPositionRmsDT->setBinLabel(ybin, binLabel, 2);
252 
253  if (localX->getEntries() != 0) {
254  hLocalXMeanDT->Fill(fabs(Mean));
255  hLocalXRmsDT->Fill(Error);
256  }
257  }
258 
259  histo = path + nameOfHistoLocalPhi;
260  MonitorElement *localPhi = igetter.get(histo);
261  if (localPhi) {
262  Double_t Mean = localPhi->getMean();
263  Double_t Error = localPhi->getMeanError();
264 
265  Int_t ybin = 1 + nwheel * 8 + nstation * 2;
266  hLocalAngleDT->setBinContent(sector, ybin, fabs(Mean));
267  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#phi", wheel, station);
268  hLocalAngleDT->setBinLabel(ybin, binLabel, 2);
269  hLocalAngleRmsDT->setBinContent(sector, ybin, Error);
270  hLocalAngleRmsDT->setBinLabel(ybin, binLabel, 2);
271 
272  if (localPhi->getEntries() != 0) {
273  hLocalPhiMeanDT->Fill(fabs(Mean));
274  hLocalPhiRmsDT->Fill(Error);
275  }
276  }
277 
278  if (station != 4) {
279  histo = path + nameOfHistoLocalY;
280  MonitorElement *localY = igetter.get(histo);
281  if (localY) {
282  Double_t Mean = localY->getMean();
283  Double_t Error = localY->getMeanError();
284 
285  Int_t ybin = 2 + nwheel * 8 + nstation * 2;
286  hLocalPositionDT->setBinContent(sector, ybin, fabs(Mean));
287  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_Y", wheel, station);
288  hLocalPositionDT->setBinLabel(ybin, binLabel, 2);
289  hLocalPositionRmsDT->setBinContent(sector, ybin, Error);
290  hLocalPositionRmsDT->setBinLabel(ybin, binLabel, 2);
291  if (localY->getEntries() != 0) {
292  hLocalYMeanDT->Fill(fabs(Mean));
293  hLocalYRmsDT->Fill(Error);
294  }
295  }
296  histo = path + nameOfHistoLocalTheta;
297  MonitorElement *localTheta = igetter.get(histo);
298  if (localTheta) {
299  Double_t Mean = localTheta->getMean();
300  Double_t Error = localTheta->getMeanError();
301 
302  Int_t ybin = 2 + nwheel * 8 + nstation * 2;
303  hLocalAngleDT->setBinContent(sector, ybin, fabs(Mean));
304  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#theta", wheel, station);
305  hLocalAngleDT->setBinLabel(ybin, binLabel, 2);
306  hLocalAngleRmsDT->setBinContent(sector, ybin, Error);
307  hLocalAngleRmsDT->setBinLabel(ybin, binLabel, 2);
308  if (localTheta->getEntries() != 0) {
309  hLocalThetaMeanDT->Fill(fabs(Mean));
310  hLocalThetaRmsDT->Fill(Error);
311  }
312  }
313  } // station != 4
314  } // avoid non existing sectors
315  } // sector
316  } // wheel
317  } // station>0
318  } // doDT
319 
320  if (doCSC) {
321  if (station != 0) {
322  for (int ring = 1; ring < 5; ring++) {
323  for (int chamber = 1; chamber < 37; chamber++) {
324  if (!(((abs(station) == 2 || abs(station) == 3 || abs(station) == 4) && ring == 1 && chamber > 18) ||
325  ((abs(station) == 2 || abs(station) == 3 || abs(station) == 4) && ring > 2))) {
326  std::stringstream Ring;
327  Ring << ring;
328  std::stringstream Station;
329  Station << station;
330  std::stringstream Chamber;
331  Chamber << chamber;
332 
333  std::string nameOfHistoLocalX =
334  "ResidualLocalX_ME" + Station.str() + "R" + Ring.str() + "C" + Chamber.str();
335  std::string nameOfHistoLocalPhi =
336  "ResidualLocalPhi_ME" + Station.str() + "R" + Ring.str() + "C" + Chamber.str();
337  std::string nameOfHistoLocalTheta =
338  "ResidualLocalTheta_ME" + Station.str() + "R" + Ring.str() + "C" + Chamber.str();
339  std::string nameOfHistoLocalY =
340  "ResidualLocalY_ME" + Station.str() + "R" + Ring.str() + "C" + Chamber.str();
341 
342  std::string path = topFolder.str() + "/CSC/Station" + Station.str() + "/Ring" + Ring.str() + "/Chamber" +
343  Chamber.str() + "/";
344 
345  Int_t ybin = abs(station) * 2 + ring;
346  if (abs(station) == 1)
347  ybin = ring;
348  if (station > 0)
349  ybin = ybin + 10;
350  else
351  ybin = 11 - ybin;
352  std::string histo = path + nameOfHistoLocalX;
353  MonitorElement *localX = igetter.get(histo);
354  if (localX) {
355  Double_t Mean = localX->getMean();
356  Double_t Error = localX->getMeanError();
357 
358  Int_t ybin2 = 2 * ybin - 1;
359  hLocalPositionCSC->setBinContent(chamber, ybin2, fabs(Mean));
360  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_X", station, ring);
361  hLocalPositionCSC->setBinLabel(ybin2, binLabel, 2);
362  hLocalPositionRmsCSC->setBinContent(chamber, ybin2, Error);
363  hLocalPositionRmsCSC->setBinLabel(ybin2, binLabel, 2);
364  if (localX->getEntries() != 0) {
365  hLocalXMeanCSC->Fill(fabs(Mean));
366  hLocalXRmsCSC->Fill(Error);
367  }
368  }
369  histo = path + nameOfHistoLocalPhi;
370 
371  MonitorElement *localPhi = igetter.get(histo);
372  if (localPhi) {
373  Double_t Mean = localPhi->getMean();
374  Double_t Error = localPhi->getMeanError();
375 
376  Int_t ybin2 = 2 * ybin - 1;
377  hLocalAngleCSC->setBinContent(chamber, ybin2, fabs(Mean));
378  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#phi", station, ring);
379  hLocalAngleCSC->setBinLabel(ybin2, binLabel, 2);
380  hLocalAngleRmsCSC->setBinContent(chamber, ybin2, Error);
381  hLocalAngleRmsCSC->setBinLabel(ybin2, binLabel, 2);
382  if (localPhi->getEntries() != 0) {
383  hLocalPhiMeanCSC->Fill(fabs(Mean));
384  hLocalPhiRmsCSC->Fill(Error);
385  }
386  }
387  histo = path + nameOfHistoLocalTheta;
388  MonitorElement *localTheta = igetter.get(histo);
389  if (localTheta) {
390  Double_t Mean = localTheta->getMean();
391  Double_t Error = localTheta->getMeanError();
392 
393  Int_t ybin2 = 2 * ybin;
394  hLocalAngleCSC->setBinContent(chamber, ybin2, fabs(Mean));
395  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#theta", station, ring);
396  hLocalAngleCSC->setBinLabel(ybin2, binLabel, 2);
397  hLocalAngleRmsCSC->setBinContent(chamber, ybin2, Error);
398  hLocalAngleRmsCSC->setBinLabel(ybin2, binLabel, 2);
399  if (localTheta->getEntries() != 0) {
400  hLocalThetaMeanCSC->Fill(fabs(Mean));
401  hLocalThetaRmsCSC->Fill(Error);
402  }
403  }
404  histo = path + nameOfHistoLocalY;
405 
406  MonitorElement *localY = igetter.get(histo);
407  if (localY) {
408  Double_t Mean = localY->getMean();
409  Double_t Error = localY->getMeanError();
410 
411  Int_t ybin2 = 2 * ybin;
412  hLocalPositionCSC->setBinContent(chamber, ybin2, fabs(Mean));
413  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_Y", station, ring);
414  hLocalPositionCSC->setBinLabel(ybin2, binLabel, 2);
415  hLocalPositionRmsCSC->setBinContent(chamber, ybin2, Error);
416  hLocalPositionRmsCSC->setBinLabel(ybin2, binLabel, 2);
417  if (localY->getEntries() != 0) {
418  hLocalYMeanCSC->Fill(fabs(Mean));
419  hLocalYRmsCSC->Fill(Error);
420  }
421  }
422  } // avoid non existing rings
423  } // chamber
424  } // ring
425  } // station!=0
426  } // doCSC
427  } // loop on stations
428 }
edm::ErrorSummaryEntry Error
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
MonitorElement * hLocalPositionRmsDT
MonitorElement * hLocalAngleRmsDT
constexpr uint16_t localY(uint16_t py)
void Fill(long long x)
MonitorElement * hLocalYRmsDT
virtual void Reset()
reset ME (ie. contents, errors, etc)
MuonAlignmentSummary(const edm::ParameterSet &)
Constructor.
MonitorElement * hLocalPositionRmsCSC
virtual double getEntries() const
get # of entries
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
MonitorElement * hLocalThetaRmsDT
MonitorElement * hLocalAngleRmsCSC
MonitorElement * hLocalPhiMeanCSC
MonitorElement * hLocalYRmsCSC
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)
MonitorElement * hLocalThetaRmsCSC
#define LogTrace(id)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
~MuonAlignmentSummary() override
Destructor.
MonitorElement * hLocalXMeanCSC
MonitorElement * hLocalXRmsCSC
MonitorElement * hLocalThetaMeanCSC
MonitorElement * hLocalPhiRmsDT
MonitorElement * hLocalYMeanCSC
MonitorElement * hLocalThetaMeanDT
virtual double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
constexpr uint16_t localX(uint16_t px)
virtual double getMeanError(int axis=1) const
MonitorElement * hLocalPhiMeanDT
MonitorElement * hLocalAngleCSC
MonitorElement * hLocalPhiRmsCSC
MonitorElement * hLocalPositionDT
MonitorElement * hLocalXRmsDT
std::stringstream topFolder
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Definition: DQMStore.cc:266
MonitorElement * hLocalYMeanDT
MonitorElement * hLocalXMeanDT
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437
MonitorElement * hLocalPositionCSC
MonitorElement * hLocalAngleDT
def exit(msg="")