CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
9 
10 
11 
13 
14  parameters = pSet;
15 
16  meanPositionRange = parameters.getUntrackedParameter<double>("meanPositionRange");
17  rmsPositionRange = parameters.getUntrackedParameter<double>("rmsPositionRange");
18  meanAngleRange = parameters.getUntrackedParameter<double>("meanAngleRange");
19  rmsAngleRange = parameters.getUntrackedParameter<double>("rmsAngleRange");
20 
21  doDT = parameters.getUntrackedParameter<bool>("doDT");
22  doCSC = parameters.getUntrackedParameter<bool>("doCSC");
23 
25  topFolder << MEFolderName+"Alignment/Muon";
26 
27  if (!(doDT || doCSC) ) {
28  edm::LogError("MuonAlignmentSummary") <<" Error!! At least one Muon subsystem (DT or CSC) must be monitorized!!" << std::endl;
29  edm::LogError("MuonAlignmentSummary") <<" Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
30  exit(1);
31  }
32 
33 }
34 
36 }
37 
38 
40 
41  metname = "MuonAlignmentSummary";
42 
43  LogTrace(metname)<<"[MuonAlignmentSummary] Parameters initialization";
44 
45 
46  if (doDT) {
47  ibooker.setCurrentFolder(topFolder.str() + "/DT");
48  hLocalPositionDT = ibooker.book2D("hLocalPositionDT",
49  "Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
50 
51  hLocalAngleDT = ibooker.book2D("hLocalAngleDT",
52  "Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
53 
54  hLocalPositionRmsDT = ibooker.book2D("hLocalPositionRmsDT",
55  "Local DT position (cm) RMS residuals;Sector;;cm", 14, 1, 15, 40, 0, 40);
56 
57  hLocalAngleRmsDT = ibooker.book2D("hLocalAngleRmsDT",
58  "Local DT angle (rad) RMS residuals;Sector;;rad", 14, 1, 15, 40, 0, 40);
59 
60  hLocalXMeanDT = ibooker.book1D("hLocalXMeanDT",
61  "Distribution of absolute MEAN Local X (cm) residuals for DT;<X> (cm);number of chambers", 100, 0, meanPositionRange);
62 
63  hLocalXRmsDT = ibooker.book1D("hLocalXRmsDT",
64  "Distribution of RMS Local X (cm) residuals for DT;X RMS (cm);number of chambers", 100, 0, rmsPositionRange);
65 
66  hLocalYMeanDT = ibooker.book1D("hLocalYMeanDT",
67  "Distribution of absolute MEAN Local Y (cm) residuals for DT;<Y> (cm);number of chambers", 100, 0, meanPositionRange);
68 
69  hLocalYRmsDT = ibooker.book1D("hLocalYRmsDT",
70  "Distribution of RMS Local Y (cm) residuals for DT;Y RMS (cm);number of chambers", 100, 0, rmsPositionRange);
71 
72  hLocalPhiMeanDT = ibooker.book1D("hLocalPhiMeanDT",
73  "Distribution of absolute MEAN #phi (rad) residuals for DT;<#phi>(rad);number of chambers", 100, 0, meanAngleRange);
74 
75  hLocalPhiRmsDT = ibooker.book1D("hLocalPhiRmsDT",
76  "Distribution of RMS #phi (rad) residuals for DT;#phi RMS (rad);number of chambers", 100, 0, rmsAngleRange);
77 
78  hLocalThetaMeanDT = ibooker.book1D("hLocalThetaMeanDT",
79  "Distribution of absolute MEAN #theta (rad) residuals for DT;<#theta>(rad);number of chambers", 100, 0, meanAngleRange);
80 
81  hLocalThetaRmsDT = ibooker.book1D("hLocalThetaRmsDT",
82  "Distribution of RMS #theta (rad) residuals for DT;#theta RMS (rad);number of chambers", 100, 0, rmsAngleRange);
83 
96 
97  }
98 
99  if (doCSC) {
100 
101  ibooker.setCurrentFolder(topFolder.str()+"/CSC");
102  hLocalPositionCSC = ibooker.book2D("hLocalPositionCSC",
103  "Local CSC position (cm) absolute MEAN residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
104 
105  hLocalAngleCSC = ibooker.book2D("hLocalAngleCSC",
106  "Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
107 
108  hLocalPositionRmsCSC = ibooker.book2D("hLocalPositionRmsCSC",
109  "Local CSC position (cm) RMS residuals;Sector;;cm", 36, 1, 37, 40, 0, 40);
110 
111  hLocalAngleRmsCSC = ibooker.book2D("hLocalAngleRmsCSC",
112  "Local CSC angle (rad) RMS residuals;Sector;;rad", 36, 1, 37, 40, 0, 40);
113 
114  hLocalXMeanCSC = ibooker.book1D("hLocalXMeanCSC",
115  "Distribution of absolute MEAN Local X (cm) residuals for CSC;<X> (cm);number of chambers", 100, 0, meanPositionRange);
116 
117  hLocalXRmsCSC = ibooker.book1D("hLocalXRmsCSC",
118  "Distribution of RMS Local X (cm) residuals for CSC;X RMS (cm);number of chambers", 100, 0, rmsPositionRange);
119 
120  hLocalYMeanCSC = ibooker.book1D("hLocalYMeanCSC",
121  "Distribution of absolute MEAN Local Y (cm) residuals for CSC;<Y> (cm);number of chambers", 100, 0, meanPositionRange);
122 
123  hLocalYRmsCSC = ibooker.book1D("hLocalYRmsCSC",
124  "Distribution of RMS Local Y (cm) residuals for CSC;Y RMS (cm);number of chambers", 100, 0, rmsPositionRange);
125 
126  hLocalPhiMeanCSC = ibooker.book1D("hLocalPhiMeanCSC",
127  "Distribution of absolute MEAN #phi (rad) residuals for CSC;<#phi>(rad);number of chambers", 100, 0, meanAngleRange);
128 
129  hLocalPhiRmsCSC = ibooker.book1D("hLocalPhiRmsCSC",
130  "Distribution of RMS #phi (rad) residuals for CSC;#phi RMS (rad);number of chambers", 100, 0, rmsAngleRange);
131 
132  hLocalThetaMeanCSC = ibooker.book1D("hLocalThetaMeanCSC",
133  "Distribution of absolute MEAN #theta (rad) residuals for CSC;<#theta>(rad);number of chambers", 100, 0, meanAngleRange);
134 
135  hLocalThetaRmsCSC = ibooker.book1D("hLocalThetaRmsCSC",
136  "Distribution of RMS #theta (rad) residuals for CSC;#theta RMS (rad);number of chambers", 100, 0, rmsAngleRange);
137 
143  hLocalXRmsCSC->Reset();
145  hLocalYRmsCSC->Reset();
150 
151  }
152 
153  LogTrace(metname)<<"[MuonAlignmentSummary] Saving the histos";
154 
155  char binLabel[15];
156 
157  for (int station = -4; station < 5; station++) {
158  if (doDT) {
159  if (station > 0) {
160 
161  for (int wheel = -2;wheel < 3; wheel++) {
162 
163  for (int sector = 1; sector < 15; sector++) {
164 
165  if (!((sector == 13 || sector == 14) && station != 4)) {
166 
167  std::stringstream Wheel; Wheel<<wheel;
168  std::stringstream Station; Station<<station;
169  std::stringstream Sector; Sector<<sector;
170 
171  std::string nameOfHistoLocalX="ResidualLocalX_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
172  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
173  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
174  std::string nameOfHistoLocalY= "ResidualLocalY_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
175 
176  std::string path= topFolder.str()+
177  "/DT/Wheel"+Wheel.str()+
178  "/Station"+Station.str()+
179  "/Sector"+Sector.str()+"/";
180 
181  std::string histo = path + nameOfHistoLocalX;
182 
183  Int_t nstation=station - 1;
184  Int_t nwheel=wheel+2;
185  MonitorElement * localX = igetter.get(histo);
186  if (localX) {
187 
188  Double_t Mean = localX->getMean();
189  Double_t Error = localX->getMeanError();
190 
191  Int_t ybin = 1 + nwheel * 8 + nstation * 2;
192  hLocalPositionDT->setBinContent(sector, ybin, fabs(Mean));
193  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_X", wheel, station);
194  hLocalPositionDT->setBinLabel(ybin, binLabel, 2);
195  hLocalPositionRmsDT->setBinContent(sector, ybin, Error);
196  hLocalPositionRmsDT->setBinLabel(ybin, binLabel, 2);
197 
198  if (localX->getEntries() != 0){
199  hLocalXMeanDT->Fill(fabs(Mean));
200  hLocalXRmsDT->Fill(Error);}
201  }
202 
203  histo = path+nameOfHistoLocalPhi;
204  MonitorElement * localPhi = igetter.get(histo);
205  if (localPhi) {
206 
207  Double_t Mean = localPhi->getMean();
208  Double_t Error = localPhi->getMeanError();
209 
210  Int_t ybin = 1 + nwheel * 8 + nstation * 2;
211  hLocalAngleDT->setBinContent(sector, ybin, fabs(Mean));
212  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#phi", wheel, station);
213  hLocalAngleDT->setBinLabel(ybin ,binLabel, 2);
214  hLocalAngleRmsDT->setBinContent(sector, ybin, Error);
215  hLocalAngleRmsDT->setBinLabel(ybin, binLabel, 2);
216 
217  if (localPhi->getEntries() != 0) {
218  hLocalPhiMeanDT->Fill(fabs(Mean));
219  hLocalPhiRmsDT->Fill(Error);}
220  }
221 
222  if (station != 4) {
223 
224  histo=path+nameOfHistoLocalY;
225  MonitorElement * localY = igetter.get(histo);
226  if (localY) {
227 
228  Double_t Mean = localY->getMean();
229  Double_t Error = localY->getMeanError();
230 
231  Int_t ybin = 2 + nwheel * 8 + nstation * 2;
232  hLocalPositionDT->setBinContent(sector,ybin,fabs(Mean));
233  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_Y", wheel, station);
234  hLocalPositionDT->setBinLabel(ybin, binLabel, 2);
235  hLocalPositionRmsDT->setBinContent(sector, ybin, Error);
236  hLocalPositionRmsDT->setBinLabel(ybin, binLabel, 2);
237  if (localY->getEntries() != 0) {
238  hLocalYMeanDT->Fill(fabs(Mean));
239  hLocalYRmsDT->Fill(Error);}
240  }
241  histo = path+nameOfHistoLocalTheta;
242  MonitorElement * localTheta = igetter.get(histo);
243  if (localTheta) {
244  Double_t Mean = localTheta->getMean();
245  Double_t Error = localTheta->getMeanError();
246 
247  Int_t ybin = 2 + nwheel * 8 + nstation * 2;
248  hLocalAngleDT->setBinContent(sector, ybin, fabs(Mean));
249  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#theta", wheel, station);
250  hLocalAngleDT->setBinLabel(ybin, binLabel, 2);
251  hLocalAngleRmsDT->setBinContent(sector, ybin, Error);
252  hLocalAngleRmsDT->setBinLabel(ybin, binLabel, 2);
253  if (localTheta->getEntries() != 0) {
254  hLocalThetaMeanDT->Fill(fabs(Mean));
255  hLocalThetaRmsDT->Fill(Error);}
256  }
257  }// station != 4
258  } //avoid non existing sectors
259  } //sector
260  } //wheel
261  } //station>0
262  }// doDT
263 
264  if (doCSC){
265  if (station != 0) {
266 
267  for (int ring = 1; ring < 5; ring++) {
268 
269  for (int chamber = 1; chamber < 37; chamber++){
270 
271  if ( !( ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring==1 && chamber>18) ||
272  ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring>2)) ) {
273  std::stringstream Ring; Ring<<ring;
274  std::stringstream Station; Station<<station;
275  std::stringstream Chamber; Chamber<<chamber;
276 
277  std::string nameOfHistoLocalX="ResidualLocalX_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
278  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
279  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
280  std::string nameOfHistoLocalY= "ResidualLocalY_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
281 
282  std::string path = topFolder.str()+
283  "/CSC/Station"+Station.str()+
284  "/Ring"+Ring.str()+
285  "/Chamber"+Chamber.str()+"/";
286 
287  Int_t ybin = abs(station) * 2 + ring;
288  if (abs(station) == 1) ybin = ring;
289  if (station > 0) ybin = ybin + 10;
290  else ybin = 11 - ybin;
291  std::string histo = path + nameOfHistoLocalX;
292  MonitorElement * localX = igetter.get(histo);
293  if (localX) {
294 
295  Double_t Mean=localX->getMean();
296  Double_t Error=localX->getMeanError();
297 
298  Int_t ybin2= 2 * ybin - 1;
299  hLocalPositionCSC->setBinContent(chamber,ybin2,fabs(Mean));
300  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_X", station, ring);
301  hLocalPositionCSC->setBinLabel(ybin2, binLabel, 2);
302  hLocalPositionRmsCSC->setBinContent(chamber, ybin2, Error);
303  hLocalPositionRmsCSC->setBinLabel(ybin2, binLabel, 2);
304  if (localX->getEntries() != 0) {
305  hLocalXMeanCSC->Fill(fabs(Mean));
306  hLocalXRmsCSC->Fill(Error);}
307  }
308  histo = path + nameOfHistoLocalPhi;
309 
310  MonitorElement * localPhi = igetter.get(histo);
311  if (localPhi) {
312 
313  Double_t Mean=localPhi->getMean();
314  Double_t Error=localPhi->getMeanError();
315 
316  Int_t ybin2 = 2 * ybin - 1;
317  hLocalAngleCSC->setBinContent(chamber, ybin2, fabs(Mean));
318  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#phi", station, ring);
319  hLocalAngleCSC->setBinLabel(ybin2, binLabel, 2);
320  hLocalAngleRmsCSC->setBinContent(chamber, ybin2, Error);
321  hLocalAngleRmsCSC->setBinLabel(ybin2, binLabel, 2);
322  if (localPhi->getEntries() != 0){
323  hLocalPhiMeanCSC->Fill(fabs(Mean));
324  hLocalPhiRmsCSC->Fill(Error);}
325  }
326  histo = path + nameOfHistoLocalTheta;
327  MonitorElement * localTheta = igetter.get(histo);
328  if (localTheta) {
329 
330  Double_t Mean = localTheta->getMean();
331  Double_t Error = localTheta->getMeanError();
332 
333  Int_t ybin2 = 2 * ybin;
334  hLocalAngleCSC->setBinContent(chamber, ybin2, fabs(Mean));
335  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#theta", station, ring);
336  hLocalAngleCSC->setBinLabel(ybin2, binLabel, 2);
337  hLocalAngleRmsCSC->setBinContent(chamber, ybin2, Error);
338  hLocalAngleRmsCSC->setBinLabel(ybin2, binLabel, 2);
339  if (localTheta->getEntries() != 0) {
340  hLocalThetaMeanCSC->Fill(fabs(Mean));
341  hLocalThetaRmsCSC->Fill(Error);}
342 
343  }
344  histo = path + nameOfHistoLocalY;
345 
346  MonitorElement * localY = igetter.get(histo);
347  if (localY) {
348 
349  Double_t Mean=localY->getMean();
350  Double_t Error=localY->getMeanError();
351 
352  Int_t ybin2 = 2 * ybin;
353  hLocalPositionCSC->setBinContent(chamber, ybin2, fabs(Mean));
354  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_Y", station, ring);
355  hLocalPositionCSC->setBinLabel(ybin2, binLabel, 2);
356  hLocalPositionRmsCSC->setBinContent(chamber, ybin2, Error);
357  hLocalPositionRmsCSC->setBinLabel(ybin2, binLabel, 2);
358  if (localY->getEntries() != 0) {
359  hLocalYMeanCSC->Fill(fabs(Mean));
360  hLocalYRmsCSC->Fill(Error);}
361  }
362  } //avoid non existing rings
363  } //chamber
364  } //ring
365  } // station!=0
366  }// doCSC
367  } // loop on stations
368 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
MonitorElement * hLocalPositionRmsDT
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 * hLocalAngleRmsDT
double getEntries(void) const
get # of entries
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double getMeanError(int axis=1) const
void Fill(long long x)
MonitorElement * hLocalYRmsDT
MuonAlignmentSummary(const edm::ParameterSet &)
Constructor.
virtual ~MuonAlignmentSummary()
Destructor.
MonitorElement * hLocalPositionRmsCSC
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::ParameterSet parameters
MonitorElement * hLocalThetaRmsDT
MonitorElement * hLocalAngleRmsCSC
MonitorElement * hLocalPhiMeanCSC
MonitorElement * hLocalYRmsCSC
MonitorElement * hLocalThetaRmsCSC
#define LogTrace(id)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
MonitorElement * hLocalXMeanCSC
MonitorElement * hLocalXRmsCSC
MonitorElement * hLocalThetaMeanCSC
MonitorElement * hLocalPhiRmsDT
MonitorElement * hLocalYMeanCSC
MonitorElement * hLocalThetaMeanDT
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
MonitorElement * hLocalPhiMeanDT
MonitorElement * hLocalAngleCSC
MonitorElement * hLocalPhiRmsCSC
MonitorElement * hLocalPositionDT
MonitorElement * hLocalXRmsDT
std::stringstream topFolder
MonitorElement * hLocalYMeanDT
MonitorElement * hLocalXMeanDT
MonitorElement * hLocalPositionCSC
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * hLocalAngleDT