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  * $Date: 2011/09/04 21:14:32 $
5  * $Revision: 1.7 $
6  * \author J. Fernandez - Univ. Oviedo <Javier.Fernandez@cern.ch>
7  */
8 
10 
11 
12 
13 
15 
16  parameters = pSet;
17 
18  meanPositionRange = parameters.getUntrackedParameter<double>("meanPositionRange");
19  rmsPositionRange = parameters.getUntrackedParameter<double>("rmsPositionRange");
20  meanAngleRange = parameters.getUntrackedParameter<double>("meanAngleRange");
21  rmsAngleRange = parameters.getUntrackedParameter<double>("rmsAngleRange");
22 
23  doDT = parameters.getUntrackedParameter<bool>("doDT");
24  doCSC = parameters.getUntrackedParameter<bool>("doCSC");
25 
27  topFolder << MEFolderName+"Alignment/Muon";
28 
29  if(!(doDT || doCSC) ) {
30  edm::LogError("MuonAlignmentSummary") <<" Error!! At least one Muon subsystem (DT or CSC) must be monitorized!!" << std::endl;
31  edm::LogError("MuonAlignmentSummary") <<" Please enable doDT or doCSC to True in your python cfg file!!!" << std::endl;
32  exit(1);
33  }
34 
36 
37 }
38 
40 }
41 
42 
44 
45 
46  metname = "MuonAlignmentSummary";
47 
48  LogTrace(metname)<<"[MuonAlignmentSummary] Parameters initialization";
49 
50 
51  if (doDT){
52  dbe->setCurrentFolder(topFolder.str()+"/DT");
53  hLocalPositionDT=dbe->book2D("hLocalPositionDT","Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14,1, 15,40,0,40);
54  hLocalAngleDT=dbe->book2D("hLocalAngleDT","Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14,1, 15,40,0,40);
55  hLocalPositionRmsDT=dbe->book2D("hLocalPositionRmsDT","Local DT position (cm) RMS residuals;Sector;;cm", 14,1, 15,40,0,40);
56  hLocalAngleRmsDT=dbe->book2D("hLocalAngleRmsDT","Local DT angle (rad) RMS residuals;Sector;;rad", 14,1, 15,40,0,40);
57 
58  hLocalXMeanDT=dbe->book1D("hLocalXMeanDT","Distribution of absolute MEAN Local X (cm) residuals for DT;<X> (cm);number of chambers",100,0,meanPositionRange);
59  hLocalXRmsDT=dbe->book1D("hLocalXRmsDT","Distribution of RMS Local X (cm) residuals for DT;X RMS (cm);number of chambers", 100,0,rmsPositionRange);
60  hLocalYMeanDT=dbe->book1D("hLocalYMeanDT","Distribution of absolute MEAN Local Y (cm) residuals for DT;<Y> (cm);number of chambers", 100,0,meanPositionRange);
61  hLocalYRmsDT=dbe->book1D("hLocalYRmsDT","Distribution of RMS Local Y (cm) residuals for DT;Y RMS (cm);number of chambers", 100,0,rmsPositionRange);
62 
63  hLocalPhiMeanDT=dbe->book1D("hLocalPhiMeanDT","Distribution of absolute MEAN #phi (rad) residuals for DT;<#phi>(rad);number of chambers", 100,0,meanAngleRange);
64  hLocalPhiRmsDT=dbe->book1D("hLocalPhiRmsDT","Distribution of RMS #phi (rad) residuals for DT;#phi RMS (rad);number of chambers", 100,0,rmsAngleRange);
65  hLocalThetaMeanDT=dbe->book1D("hLocalThetaMeanDT","Distribution of absolute MEAN #theta (rad) residuals for DT;<#theta>(rad);number of chambers", 100,0,meanAngleRange);
66  hLocalThetaRmsDT=dbe->book1D("hLocalThetaRmsDT","Distribution of RMS #theta (rad) residuals for DT;#theta RMS (rad);number of chambers",100,0,rmsAngleRange);
67 
80 
81  }
82 
83  if (doCSC){
84 
85  dbe->setCurrentFolder(topFolder.str()+"/CSC");
86  hLocalPositionCSC=dbe->book2D("hLocalPositionCSC","Local CSC position (cm) absolute MEAN residuals;Sector;;cm",36,1,37,40,0,40);
87  hLocalAngleCSC=dbe->book2D("hLocalAngleCSC","Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36,1,37,40,0,40);
88  hLocalPositionRmsCSC=dbe->book2D("hLocalPositionRmsCSC","Local CSC position (cm) RMS residuals;Sector;;cm", 36,1,37,40,0,40);
89  hLocalAngleRmsCSC=dbe->book2D("hLocalAngleRmsCSC","Local CSC angle (rad) RMS residuals;Sector;;rad", 36,1,37,40,0,40);
90 
91  hLocalXMeanCSC=dbe->book1D("hLocalXMeanCSC","Distribution of absolute MEAN Local X (cm) residuals for CSC;<X> (cm);number of chambers",100,0,meanPositionRange);
92  hLocalXRmsCSC=dbe->book1D("hLocalXRmsCSC","Distribution of RMS Local X (cm) residuals for CSC;X RMS (cm);number of chambers", 100,0,rmsPositionRange);
93  hLocalYMeanCSC=dbe->book1D("hLocalYMeanCSC","Distribution of absolute MEAN Local Y (cm) residuals for CSC;<Y> (cm);number of chambers", 100,0,meanPositionRange);
94  hLocalYRmsCSC=dbe->book1D("hLocalYRmsCSC","Distribution of RMS Local Y (cm) residuals for CSC;Y RMS (cm);number of chambers", 100,0,rmsPositionRange);
95 
96  hLocalPhiMeanCSC=dbe->book1D("hLocalPhiMeanCSC","Distribution of absolute MEAN #phi (rad) residuals for CSC;<#phi>(rad);number of chambers", 100,0,meanAngleRange);
97  hLocalPhiRmsCSC=dbe->book1D("hLocalPhiRmsCSC","Distribution of RMS #phi (rad) residuals for CSC;#phi RMS (rad);number of chambers", 100,0,rmsAngleRange);
98  hLocalThetaMeanCSC=dbe->book1D("hLocalThetaMeanCSC","Distribution of absolute MEAN #theta (rad) residuals for CSC;<#theta>(rad);number of chambers", 100,0,meanAngleRange);
99  hLocalThetaRmsCSC=dbe->book1D("hLocalThetaRmsCSC","Distribution of RMS #theta (rad) residuals for CSC;#theta RMS (rad);number of chambers",100,0,rmsAngleRange);
100 
106  hLocalXRmsCSC->Reset();
108  hLocalYRmsCSC->Reset();
113 
114 
115  }
116 }
117 
118 
120 
121 
122  LogTrace(metname)<<"[MuonAlignmentSummary] Saving the histos";
123 
124  char binLabel[15];
125 
126  for (int station=-4; station<5;station++){
127  if (doDT){
128  if(station>0){
129 
130  for(int wheel=-2;wheel<3;wheel++){
131 
132  for (int sector=1;sector<15;sector++){
133 
134  if(!((sector==13 || sector ==14) && station!=4)){
135 
136  std::stringstream Wheel; Wheel<<wheel;
137  std::stringstream Station; Station<<station;
138  std::stringstream Sector; Sector<<sector;
139 
140  std::string nameOfHistoLocalX="ResidualLocalX_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
141  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
142  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
143  std::string nameOfHistoLocalY= "ResidualLocalY_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
144 
145  std::string path= topFolder.str()+
146  "/DT/Wheel"+Wheel.str()+
147  "/Station"+Station.str()+
148  "/Sector"+Sector.str()+"/";
149 
150  std::string histo = path+nameOfHistoLocalX;
151 
152  Int_t nstation=station - 1;
153  Int_t nwheel=wheel+2;
154  MonitorElement * localX =dbe->get(histo);
155  if(localX){
156 
157  Double_t Mean=localX->getMean();
158  Double_t Error=localX->getMeanError();
159 
160  Int_t ybin=1+nwheel*8+nstation*2;
161  hLocalPositionDT->setBinContent(sector,ybin,fabs(Mean));
162  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_X",wheel, station );
163  hLocalPositionDT->setBinLabel(ybin,binLabel,2);
164  hLocalPositionRmsDT->setBinContent(sector,ybin,Error);
165  hLocalPositionRmsDT->setBinLabel(ybin,binLabel,2);
166 
167  if(localX->getEntries()!=0){
168  hLocalXMeanDT->Fill(fabs(Mean));
169  hLocalXRmsDT->Fill(Error);}
170  }
171 
172  histo = path+nameOfHistoLocalPhi;
173  MonitorElement * localPhi = dbe->get(histo);
174  if(localPhi){
175 
176  Double_t Mean=localPhi->getMean();
177  Double_t Error=localPhi->getMeanError();
178 
179  Int_t ybin=1+nwheel*8+nstation*2;
180  hLocalAngleDT->setBinContent(sector,ybin,fabs(Mean));
181  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#phi", wheel,station );
182  hLocalAngleDT->setBinLabel(ybin,binLabel,2);
183  hLocalAngleRmsDT->setBinContent(sector,ybin,Error);
184  hLocalAngleRmsDT->setBinLabel(ybin,binLabel,2);
185 
186  if(localPhi->getEntries()!=0){
187  hLocalPhiMeanDT->Fill(fabs(Mean));
188  hLocalPhiRmsDT->Fill(Error);}
189  }
190 
191  if(station!=4){
192 
193  histo=path+nameOfHistoLocalY;
194  MonitorElement * localY = dbe->get(histo);
195  if(localY){
196 
197  Double_t Mean=localY->getMean();
198  Double_t Error=localY->getMeanError();
199 
200  Int_t ybin=2+nwheel*8+nstation*2;
201  hLocalPositionDT->setBinContent(sector,ybin,fabs(Mean));
202  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_Y", wheel,station );
203  hLocalPositionDT->setBinLabel(ybin,binLabel,2);
204  hLocalPositionRmsDT->setBinContent(sector,ybin,Error);
205  hLocalPositionRmsDT->setBinLabel(ybin,binLabel,2);
206  if(localY->getEntries()!=0){
207  hLocalYMeanDT->Fill(fabs(Mean));
208  hLocalYRmsDT->Fill(Error);}
209  }
210  histo = path+nameOfHistoLocalTheta;
211  MonitorElement * localTheta = dbe->get(histo);
212  if(localTheta){
213  Double_t Mean=localTheta->getMean();
214  Double_t Error=localTheta->getMeanError();
215 
216  Int_t ybin=2+nwheel*8+nstation*2;
217  hLocalAngleDT->setBinContent(sector,ybin,fabs(Mean));
218  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#theta",wheel,station );
219  hLocalAngleDT->setBinLabel(ybin,binLabel,2);
220  hLocalAngleRmsDT->setBinContent(sector,ybin,Error);
221  hLocalAngleRmsDT->setBinLabel(ybin,binLabel,2);
222  if(localTheta->getEntries()!=0){
223  hLocalThetaMeanDT->Fill(fabs(Mean));
224  hLocalThetaRmsDT->Fill(Error);}
225  }
226 
227  }// station != 4
228 
229  } //avoid non existing sectors
230  } //sector
231  } //wheel
232  } //station>0
233  }// doDT
234 
235  if (doCSC){
236  if(station!=0){
237 
238  for(int ring=1;ring<5;ring++){
239 
240  for(int chamber=1;chamber<37;chamber++){
241 
242  if( !( ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring==1 && chamber>18) ||
243  ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring>2)) ){
244  std::stringstream Ring; Ring<<ring;
245  std::stringstream Station; Station<<station;
246  std::stringstream Chamber; Chamber<<chamber;
247 
248  std::string nameOfHistoLocalX="ResidualLocalX_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
249  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
250  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
251  std::string nameOfHistoLocalY= "ResidualLocalY_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
252 
253  std::string path = topFolder.str()+
254  "/CSC/Station"+Station.str()+
255  "/Ring"+Ring.str()+
256  "/Chamber"+Chamber.str()+"/";
257 
258  Int_t ybin=abs(station)*2+ring;
259  if(abs(station)==1) ybin=ring;
260  if (station>0) ybin=ybin+10;
261  else ybin = 11 -ybin;
262  std::string histo = path + nameOfHistoLocalX;
263  MonitorElement * localX = dbe->get(histo);
264  if(localX){
265 
266  Double_t Mean=localX->getMean();
267  Double_t Error=localX->getMeanError();
268 
269  Int_t ybin2=2*ybin-1;
270  hLocalPositionCSC->setBinContent(chamber,ybin2,fabs(Mean));
271  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_X", station,ring );
272  hLocalPositionCSC->setBinLabel(ybin2,binLabel,2);
273  hLocalPositionRmsCSC->setBinContent(chamber,ybin2,Error);
274  hLocalPositionRmsCSC->setBinLabel(ybin2,binLabel,2);
275  if(localX->getEntries()!=0){
276  hLocalXMeanCSC->Fill(fabs(Mean));
277  hLocalXRmsCSC->Fill(Error);}
278  }
279  histo = path + nameOfHistoLocalPhi;
280 
281  MonitorElement * localPhi = dbe->get(histo);
282  if(localPhi){
283 
284 
285  Double_t Mean=localPhi->getMean();
286  Double_t Error=localPhi->getMeanError();
287 
288  Int_t ybin2=2*ybin-1;
289  hLocalAngleCSC->setBinContent(chamber,ybin2,fabs(Mean));
290  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#phi", station,ring );
291  hLocalAngleCSC->setBinLabel(ybin2,binLabel,2);
292  hLocalAngleRmsCSC->setBinContent(chamber,ybin2,Error);
293  hLocalAngleRmsCSC->setBinLabel(ybin2,binLabel,2);
294  if(localPhi->getEntries()!=0){
295  hLocalPhiMeanCSC->Fill(fabs(Mean));
296  hLocalPhiRmsCSC->Fill(Error);}
297  }
298  histo = path + nameOfHistoLocalTheta;
299  MonitorElement * localTheta = dbe->get(histo);
300  if(localTheta){
301 
302 
303  Double_t Mean=localTheta->getMean();
304  Double_t Error=localTheta->getMeanError();
305 
306  Int_t ybin2=2*ybin;
307  hLocalAngleCSC->setBinContent(chamber,ybin2,fabs(Mean));
308  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#theta", station,ring );
309  hLocalAngleCSC->setBinLabel(ybin2,binLabel,2);
310  hLocalAngleRmsCSC->setBinContent(chamber,ybin2,Error);
311  hLocalAngleRmsCSC->setBinLabel(ybin2,binLabel,2);
312  if(localTheta->getEntries()!=0){
313  hLocalThetaMeanCSC->Fill(fabs(Mean));
314  hLocalThetaRmsCSC->Fill(Error);}
315 
316  }
317  histo = path + nameOfHistoLocalY;
318 
319  MonitorElement * localY = dbe->get(histo);
320  if(localY){
321 
322  Double_t Mean=localY->getMean();
323  Double_t Error=localY->getMeanError();
324 
325  Int_t ybin2=2*ybin;
326  hLocalPositionCSC->setBinContent(chamber,ybin2,fabs(Mean));
327  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_Y", station,ring );
328  hLocalPositionCSC->setBinLabel(ybin2,binLabel,2);
329  hLocalPositionRmsCSC->setBinContent(chamber,ybin2,Error);
330  hLocalPositionRmsCSC->setBinLabel(ybin2,binLabel,2);
331  if(localY->getEntries()!=0){
332  hLocalYMeanCSC->Fill(fabs(Mean));
333  hLocalYRmsCSC->Fill(Error);}
334  }
335  } //avoid non existing rings
336  } //chamber
337  } //ring
338  } // station!=0
339  }// doCSC
340 
341  } // loop on stations
342 
343 }
344 
void beginRun(edm::Run const &run, edm::EventSetup const &iSetup)
Inizialize parameters for histo binning.
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 * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:722
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)
#define abs(x)
Definition: mlp_lapack.h:159
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
edm::ParameterSet parameters
MonitorElement * hLocalThetaRmsDT
MonitorElement * hLocalAngleRmsCSC
MonitorElement * hLocalPhiMeanCSC
MonitorElement * hLocalYRmsCSC
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1473
MonitorElement * hLocalThetaRmsCSC
#define LogTrace(id)
MonitorElement * hLocalXMeanCSC
MonitorElement * hLocalXRmsCSC
MonitorElement * hLocalThetaMeanCSC
MonitorElement * hLocalPhiRmsDT
MonitorElement * hLocalYMeanCSC
MonitorElement * hLocalThetaMeanDT
void endRun(edm::Run const &run, edm::EventSetup const &iSetup)
Save the histos.
MonitorElement * hLocalPhiMeanDT
MonitorElement * hLocalAngleCSC
MonitorElement * hLocalPhiRmsCSC
MonitorElement * hLocalPositionDT
MonitorElement * hLocalXRmsDT
std::stringstream topFolder
MonitorElement * hLocalYMeanDT
MonitorElement * hLocalXMeanDT
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:850
MonitorElement * hLocalPositionCSC
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * hLocalAngleDT
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
Definition: Run.h:36