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 
34 
35 }
36 
38 }
39 
40 
42 
43 
44  metname = "MuonAlignmentSummary";
45 
46  LogTrace(metname)<<"[MuonAlignmentSummary] Parameters initialization";
47 
48 
49  if (doDT){
50  dbe->setCurrentFolder(topFolder.str()+"/DT");
51  hLocalPositionDT=dbe->book2D("hLocalPositionDT","Local DT position (cm) absolute MEAN residuals;Sector;;cm", 14,1, 15,40,0,40);
52  hLocalAngleDT=dbe->book2D("hLocalAngleDT","Local DT angle (rad) absolute MEAN residuals;Sector;;rad", 14,1, 15,40,0,40);
53  hLocalPositionRmsDT=dbe->book2D("hLocalPositionRmsDT","Local DT position (cm) RMS residuals;Sector;;cm", 14,1, 15,40,0,40);
54  hLocalAngleRmsDT=dbe->book2D("hLocalAngleRmsDT","Local DT angle (rad) RMS residuals;Sector;;rad", 14,1, 15,40,0,40);
55 
56  hLocalXMeanDT=dbe->book1D("hLocalXMeanDT","Distribution of absolute MEAN Local X (cm) residuals for DT;<X> (cm);number of chambers",100,0,meanPositionRange);
57  hLocalXRmsDT=dbe->book1D("hLocalXRmsDT","Distribution of RMS Local X (cm) residuals for DT;X RMS (cm);number of chambers", 100,0,rmsPositionRange);
58  hLocalYMeanDT=dbe->book1D("hLocalYMeanDT","Distribution of absolute MEAN Local Y (cm) residuals for DT;<Y> (cm);number of chambers", 100,0,meanPositionRange);
59  hLocalYRmsDT=dbe->book1D("hLocalYRmsDT","Distribution of RMS Local Y (cm) residuals for DT;Y RMS (cm);number of chambers", 100,0,rmsPositionRange);
60 
61  hLocalPhiMeanDT=dbe->book1D("hLocalPhiMeanDT","Distribution of absolute MEAN #phi (rad) residuals for DT;<#phi>(rad);number of chambers", 100,0,meanAngleRange);
62  hLocalPhiRmsDT=dbe->book1D("hLocalPhiRmsDT","Distribution of RMS #phi (rad) residuals for DT;#phi RMS (rad);number of chambers", 100,0,rmsAngleRange);
63  hLocalThetaMeanDT=dbe->book1D("hLocalThetaMeanDT","Distribution of absolute MEAN #theta (rad) residuals for DT;<#theta>(rad);number of chambers", 100,0,meanAngleRange);
64  hLocalThetaRmsDT=dbe->book1D("hLocalThetaRmsDT","Distribution of RMS #theta (rad) residuals for DT;#theta RMS (rad);number of chambers",100,0,rmsAngleRange);
65 
78 
79  }
80 
81  if (doCSC){
82 
83  dbe->setCurrentFolder(topFolder.str()+"/CSC");
84  hLocalPositionCSC=dbe->book2D("hLocalPositionCSC","Local CSC position (cm) absolute MEAN residuals;Sector;;cm",36,1,37,40,0,40);
85  hLocalAngleCSC=dbe->book2D("hLocalAngleCSC","Local CSC angle (rad) absolute MEAN residuals;Sector;;rad", 36,1,37,40,0,40);
86  hLocalPositionRmsCSC=dbe->book2D("hLocalPositionRmsCSC","Local CSC position (cm) RMS residuals;Sector;;cm", 36,1,37,40,0,40);
87  hLocalAngleRmsCSC=dbe->book2D("hLocalAngleRmsCSC","Local CSC angle (rad) RMS residuals;Sector;;rad", 36,1,37,40,0,40);
88 
89  hLocalXMeanCSC=dbe->book1D("hLocalXMeanCSC","Distribution of absolute MEAN Local X (cm) residuals for CSC;<X> (cm);number of chambers",100,0,meanPositionRange);
90  hLocalXRmsCSC=dbe->book1D("hLocalXRmsCSC","Distribution of RMS Local X (cm) residuals for CSC;X RMS (cm);number of chambers", 100,0,rmsPositionRange);
91  hLocalYMeanCSC=dbe->book1D("hLocalYMeanCSC","Distribution of absolute MEAN Local Y (cm) residuals for CSC;<Y> (cm);number of chambers", 100,0,meanPositionRange);
92  hLocalYRmsCSC=dbe->book1D("hLocalYRmsCSC","Distribution of RMS Local Y (cm) residuals for CSC;Y RMS (cm);number of chambers", 100,0,rmsPositionRange);
93 
94  hLocalPhiMeanCSC=dbe->book1D("hLocalPhiMeanCSC","Distribution of absolute MEAN #phi (rad) residuals for CSC;<#phi>(rad);number of chambers", 100,0,meanAngleRange);
95  hLocalPhiRmsCSC=dbe->book1D("hLocalPhiRmsCSC","Distribution of RMS #phi (rad) residuals for CSC;#phi RMS (rad);number of chambers", 100,0,rmsAngleRange);
96  hLocalThetaMeanCSC=dbe->book1D("hLocalThetaMeanCSC","Distribution of absolute MEAN #theta (rad) residuals for CSC;<#theta>(rad);number of chambers", 100,0,meanAngleRange);
97  hLocalThetaRmsCSC=dbe->book1D("hLocalThetaRmsCSC","Distribution of RMS #theta (rad) residuals for CSC;#theta RMS (rad);number of chambers",100,0,rmsAngleRange);
98 
104  hLocalXRmsCSC->Reset();
106  hLocalYRmsCSC->Reset();
111 
112 
113  }
114 }
115 
116 
118 
119 
120  LogTrace(metname)<<"[MuonAlignmentSummary] Saving the histos";
121 
122  char binLabel[15];
123 
124  for (int station=-4; station<5;station++){
125  if (doDT){
126  if(station>0){
127 
128  for(int wheel=-2;wheel<3;wheel++){
129 
130  for (int sector=1;sector<15;sector++){
131 
132  if(!((sector==13 || sector ==14) && station!=4)){
133 
134  std::stringstream Wheel; Wheel<<wheel;
135  std::stringstream Station; Station<<station;
136  std::stringstream Sector; Sector<<sector;
137 
138  std::string nameOfHistoLocalX="ResidualLocalX_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
139  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
140  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
141  std::string nameOfHistoLocalY= "ResidualLocalY_W"+Wheel.str()+"MB"+Station.str()+"S"+Sector.str();
142 
143  std::string path= topFolder.str()+
144  "/DT/Wheel"+Wheel.str()+
145  "/Station"+Station.str()+
146  "/Sector"+Sector.str()+"/";
147 
148  std::string histo = path+nameOfHistoLocalX;
149 
150  Int_t nstation=station - 1;
151  Int_t nwheel=wheel+2;
152  MonitorElement * localX =dbe->get(histo);
153  if(localX){
154 
155  Double_t Mean=localX->getMean();
156  Double_t Error=localX->getMeanError();
157 
158  Int_t ybin=1+nwheel*8+nstation*2;
159  hLocalPositionDT->setBinContent(sector,ybin,fabs(Mean));
160  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_X",wheel, station );
161  hLocalPositionDT->setBinLabel(ybin,binLabel,2);
162  hLocalPositionRmsDT->setBinContent(sector,ybin,Error);
163  hLocalPositionRmsDT->setBinLabel(ybin,binLabel,2);
164 
165  if(localX->getEntries()!=0){
166  hLocalXMeanDT->Fill(fabs(Mean));
167  hLocalXRmsDT->Fill(Error);}
168  }
169 
170  histo = path+nameOfHistoLocalPhi;
171  MonitorElement * localPhi = dbe->get(histo);
172  if(localPhi){
173 
174  Double_t Mean=localPhi->getMean();
175  Double_t Error=localPhi->getMeanError();
176 
177  Int_t ybin=1+nwheel*8+nstation*2;
178  hLocalAngleDT->setBinContent(sector,ybin,fabs(Mean));
179  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#phi", wheel,station );
180  hLocalAngleDT->setBinLabel(ybin,binLabel,2);
181  hLocalAngleRmsDT->setBinContent(sector,ybin,Error);
182  hLocalAngleRmsDT->setBinLabel(ybin,binLabel,2);
183 
184  if(localPhi->getEntries()!=0){
185  hLocalPhiMeanDT->Fill(fabs(Mean));
186  hLocalPhiRmsDT->Fill(Error);}
187  }
188 
189  if(station!=4){
190 
191  histo=path+nameOfHistoLocalY;
192  MonitorElement * localY = dbe->get(histo);
193  if(localY){
194 
195  Double_t Mean=localY->getMean();
196  Double_t Error=localY->getMeanError();
197 
198  Int_t ybin=2+nwheel*8+nstation*2;
199  hLocalPositionDT->setBinContent(sector,ybin,fabs(Mean));
200  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_Y", wheel,station );
201  hLocalPositionDT->setBinLabel(ybin,binLabel,2);
202  hLocalPositionRmsDT->setBinContent(sector,ybin,Error);
203  hLocalPositionRmsDT->setBinLabel(ybin,binLabel,2);
204  if(localY->getEntries()!=0){
205  hLocalYMeanDT->Fill(fabs(Mean));
206  hLocalYRmsDT->Fill(Error);}
207  }
208  histo = path+nameOfHistoLocalTheta;
209  MonitorElement * localTheta = dbe->get(histo);
210  if(localTheta){
211  Double_t Mean=localTheta->getMean();
212  Double_t Error=localTheta->getMeanError();
213 
214  Int_t ybin=2+nwheel*8+nstation*2;
215  hLocalAngleDT->setBinContent(sector,ybin,fabs(Mean));
216  snprintf(binLabel, sizeof(binLabel), "MB%d/%d_#theta",wheel,station );
217  hLocalAngleDT->setBinLabel(ybin,binLabel,2);
218  hLocalAngleRmsDT->setBinContent(sector,ybin,Error);
219  hLocalAngleRmsDT->setBinLabel(ybin,binLabel,2);
220  if(localTheta->getEntries()!=0){
221  hLocalThetaMeanDT->Fill(fabs(Mean));
222  hLocalThetaRmsDT->Fill(Error);}
223  }
224 
225  }// station != 4
226 
227  } //avoid non existing sectors
228  } //sector
229  } //wheel
230  } //station>0
231  }// doDT
232 
233  if (doCSC){
234  if(station!=0){
235 
236  for(int ring=1;ring<5;ring++){
237 
238  for(int chamber=1;chamber<37;chamber++){
239 
240  if( !( ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring==1 && chamber>18) ||
241  ((abs(station)==2 || abs(station)==3 || abs(station)==4) && ring>2)) ){
242  std::stringstream Ring; Ring<<ring;
243  std::stringstream Station; Station<<station;
244  std::stringstream Chamber; Chamber<<chamber;
245 
246  std::string nameOfHistoLocalX="ResidualLocalX_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
247  std::string nameOfHistoLocalPhi= "ResidualLocalPhi_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
248  std::string nameOfHistoLocalTheta= "ResidualLocalTheta_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
249  std::string nameOfHistoLocalY= "ResidualLocalY_ME"+Station.str()+"R"+Ring.str()+"C"+Chamber.str();
250 
251  std::string path = topFolder.str()+
252  "/CSC/Station"+Station.str()+
253  "/Ring"+Ring.str()+
254  "/Chamber"+Chamber.str()+"/";
255 
256  Int_t ybin=abs(station)*2+ring;
257  if(abs(station)==1) ybin=ring;
258  if (station>0) ybin=ybin+10;
259  else ybin = 11 -ybin;
260  std::string histo = path + nameOfHistoLocalX;
261  MonitorElement * localX = dbe->get(histo);
262  if(localX){
263 
264  Double_t Mean=localX->getMean();
265  Double_t Error=localX->getMeanError();
266 
267  Int_t ybin2=2*ybin-1;
268  hLocalPositionCSC->setBinContent(chamber,ybin2,fabs(Mean));
269  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_X", station,ring );
270  hLocalPositionCSC->setBinLabel(ybin2,binLabel,2);
271  hLocalPositionRmsCSC->setBinContent(chamber,ybin2,Error);
272  hLocalPositionRmsCSC->setBinLabel(ybin2,binLabel,2);
273  if(localX->getEntries()!=0){
274  hLocalXMeanCSC->Fill(fabs(Mean));
275  hLocalXRmsCSC->Fill(Error);}
276  }
277  histo = path + nameOfHistoLocalPhi;
278 
279  MonitorElement * localPhi = dbe->get(histo);
280  if(localPhi){
281 
282 
283  Double_t Mean=localPhi->getMean();
284  Double_t Error=localPhi->getMeanError();
285 
286  Int_t ybin2=2*ybin-1;
287  hLocalAngleCSC->setBinContent(chamber,ybin2,fabs(Mean));
288  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#phi", station,ring );
289  hLocalAngleCSC->setBinLabel(ybin2,binLabel,2);
290  hLocalAngleRmsCSC->setBinContent(chamber,ybin2,Error);
291  hLocalAngleRmsCSC->setBinLabel(ybin2,binLabel,2);
292  if(localPhi->getEntries()!=0){
293  hLocalPhiMeanCSC->Fill(fabs(Mean));
294  hLocalPhiRmsCSC->Fill(Error);}
295  }
296  histo = path + nameOfHistoLocalTheta;
297  MonitorElement * localTheta = dbe->get(histo);
298  if(localTheta){
299 
300 
301  Double_t Mean=localTheta->getMean();
302  Double_t Error=localTheta->getMeanError();
303 
304  Int_t ybin2=2*ybin;
305  hLocalAngleCSC->setBinContent(chamber,ybin2,fabs(Mean));
306  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_#theta", station,ring );
307  hLocalAngleCSC->setBinLabel(ybin2,binLabel,2);
308  hLocalAngleRmsCSC->setBinContent(chamber,ybin2,Error);
309  hLocalAngleRmsCSC->setBinLabel(ybin2,binLabel,2);
310  if(localTheta->getEntries()!=0){
311  hLocalThetaMeanCSC->Fill(fabs(Mean));
312  hLocalThetaRmsCSC->Fill(Error);}
313 
314  }
315  histo = path + nameOfHistoLocalY;
316 
317  MonitorElement * localY = dbe->get(histo);
318  if(localY){
319 
320  Double_t Mean=localY->getMean();
321  Double_t Error=localY->getMeanError();
322 
323  Int_t ybin2=2*ybin;
324  hLocalPositionCSC->setBinContent(chamber,ybin2,fabs(Mean));
325  snprintf(binLabel, sizeof(binLabel), "ME%d/%d_Y", station,ring );
326  hLocalPositionCSC->setBinLabel(ybin2,binLabel,2);
327  hLocalPositionRmsCSC->setBinContent(chamber,ybin2,Error);
328  hLocalPositionRmsCSC->setBinLabel(ybin2,binLabel,2);
329  if(localY->getEntries()!=0){
330  hLocalYMeanCSC->Fill(fabs(Mean));
331  hLocalYRmsCSC->Fill(Error);}
332  }
333  } //avoid non existing rings
334  } //chamber
335  } //ring
336  } // station!=0
337  }// doCSC
338 
339  } // loop on stations
340 
341 }
342 
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:954
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.
tuple path
else: Piece not in the list, fine.
MonitorElement * hLocalPositionRmsCSC
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
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:1708
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:1082
MonitorElement * hLocalPositionCSC
void Reset(void)
reset ME (ie. contents, errors, etc)
MonitorElement * hLocalAngleDT
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
Definition: Run.h:41