CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ClusMultPlots.cc
Go to the documentation of this file.
1 #include "ClusMultPlots.h"
2 #include <iostream>
3 #include <algorithm>
4 #include <vector>
5 #include <string>
6 #include <map>
7 #include "TPad.h"
8 #include "TFile.h"
9 #include "TH2F.h"
10 #include "TH1F.h"
11 #include "TProfile.h"
12 #include "TGraph.h"
14 #include "TCanvas.h"
15 #include "TStyle.h"
16 
17 
18 void ClusMultPlots(const char* fullname, const char* pxmod, const char* strpmod, const char* corrmod,
19  const char* pxlabel, const char* strplabel, const char* corrlabel, const char* postfix, const char* shortname, const char* outtrunk) {
20 
21 
22  char pxmodfull[300];
23  sprintf(pxmodfull,"%s%s",pxmod,postfix);
24  char pxlabfull[300];
25  sprintf(pxlabfull,"%s%s",pxlabel,postfix);
26 
27  char strpmodfull[300];
28  sprintf(strpmodfull,"%s%s",strpmod,postfix);
29  char strplabfull[300];
30  sprintf(strplabfull,"%s%s",strplabel,postfix);
31 
32  char corrmodfull[300];
33  sprintf(corrmodfull,"%s%s",corrmod,postfix);
34  char corrlabfull[300];
35  sprintf(corrlabfull,"%s%s",corrlabel,postfix);
36 
37 
38  // char fullname[300];
39  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
40 
41 
42  TFile ff(fullname);
43 
44  gStyle->SetOptStat(111111);
45 
46 
47  CommonAnalyzer capixel(&ff,"",pxmodfull,"EventProcs/Pixel");
48 
49  TH1F* pixel = (TH1F*)capixel.getObject("nPixeldigi");
50  if(pixel) {
51  pixel->Draw();
52  gPad->SetLogy(1);
53  std::string plotfilename;
54  plotfilename += outtrunk;
55  plotfilename += shortname;
56  plotfilename += "/pixel";
57  plotfilename += pxlabfull;
58  plotfilename += "_";
59  plotfilename += shortname;
60  plotfilename += ".gif";
61  gPad->Print(plotfilename.c_str());
62  delete pixel;
63  gPad->SetLogy(0);
64  }
65 
66  capixel.setPath("VtxCorr/Pixel");
67 
68  TH2F* pixelvtx = (TH2F*)capixel.getObject("nPixeldigivsnvtx");
69  if(pixelvtx) {
70  pixelvtx->Draw("colz");
71  // TProfile* pixelvtxprof = pixelvtx->ProfileY("prof",1,-1,"");
72  TProfile* pixelvtxprof = pixelvtx->ProfileX("prof",1,-1,"");
73  pixelvtxprof->SetMarkerStyle(20);
74  pixelvtxprof->SetMarkerSize(.4);
75  /*
76  TGraph tmp;
77  for(unsigned bin=1;bin<pixelvtxprof->GetNbinsX()+1;++bin) {
78  // tmp.SetPoint(tmp.GetN(),pixelvtxprof->GetBinContent(bin),pixelvtxprof->GetBinCenter(bin));
79  tmp.SetPoint(tmp.GetN(),pixelvtxprof->GetBinCenter(bin),pixelvtxprof->GetBinContent(bin));
80  }
81  tmp.SetMarkerStyle(20);
82  tmp.Draw("p");
83  */
84  pixelvtxprof->Draw("esame");
85  gPad->SetLogz(1);
86  std::string plotfilename;
87  plotfilename += outtrunk;
88  plotfilename += shortname;
89  plotfilename += "/pixelvtx";
90  plotfilename += pxlabfull;
91  plotfilename += "_";
92  plotfilename += shortname;
93  plotfilename += ".gif";
94  gPad->Print(plotfilename.c_str());
95  delete pixelvtx;
96  gPad->SetLogz(0);
97  }
98 
99  CommonAnalyzer castrip(&ff,"",strpmodfull,"EventProcs/TK");
100 
101  TH1F* tk = (TH1F*)castrip.getObject("nTKdigi");
102  if(tk) {
103  tk->Draw();
104  gPad->SetLogy(1);
105  std::string plotfilename;
106  plotfilename += outtrunk;
107  plotfilename += shortname;
108  plotfilename += "/tk";
109  plotfilename += strplabfull;
110  plotfilename += "_";
111  plotfilename += shortname;
112  plotfilename += ".gif";
113  gPad->Print(plotfilename.c_str());
114  delete tk;
115  gPad->SetLogy(0);
116  }
117 
118  castrip.setPath("VtxCorr/TK");
119 
120  TH2F* tkvtx = (TH2F*)castrip.getObject("nTKdigivsnvtx");
121  if(tkvtx) {
122  tkvtx->Draw("colz");
123  // TProfile* tkvtxprof = tkvtx->ProfileY("prof2",1,-1,"");
124  TProfile* tkvtxprof = tkvtx->ProfileX("prof2",1,-1,"");
125  tkvtxprof->SetMarkerStyle(20);
126  tkvtxprof->SetMarkerSize(.4);
127  /*
128  cout << tkvtxprof->GetNbinsX() << " " << tkvtxprof->GetSize() << " " << tkvtxprof->GetXaxis()->GetXbins()->GetSize() << endl;
129  TGraph tmp;
130  for(unsigned bin=1;bin<tkvtxprof->GetNbinsX()+1;++bin) {
131  tmp.SetPoint(tmp.GetN(),tkvtxprof->GetBinContent(bin),tkvtxprof->GetBinCenter(bin));
132  }
133  tmp.SetMarkerStyle(20);
134  tmp.Draw("p");
135  */
136  tkvtxprof->Draw("esame");
137  gPad->SetLogz(1);
138  std::string plotfilename;
139  plotfilename += outtrunk;
140  plotfilename += shortname;
141  plotfilename += "/tkvtx";
142  plotfilename += strplabfull;
143  plotfilename += "_";
144  plotfilename += shortname;
145  plotfilename += ".gif";
146  gPad->Print(plotfilename.c_str());
147  delete tkvtx;
148  gPad->SetLogz(0);
149  }
150 
151 
152  CommonAnalyzer cacorr(&ff,"",corrmodfull,"");
153 
154 
155  TH1F* rat = (TH1F*)cacorr.getObject("PixelOverTK");
156  if(rat) {
157  rat->Draw();
158  gPad->SetLogy(1);
159  std::string plotfilename;
160  plotfilename += outtrunk;
161  plotfilename += shortname;
162  plotfilename += "/pixelovertk";
163  plotfilename += corrlabfull;
164  plotfilename += "_";
165  plotfilename += shortname;
166  plotfilename += ".gif";
167  gPad->Print(plotfilename.c_str());
168  delete rat;
169  gPad->SetLogy(0);
170  }
171 
172 
173  TH2F* mult2d = (TH2F*)cacorr.getObject("PixelVsTK");
174  if(mult2d) {
175  mult2d->Draw("colz");
176  gPad->SetLogz(1);
177  // mult2d->GetXaxis()->SetRangeUser(0.,30000);
178  // mult2d->GetYaxis()->SetRangeUser(0.,15000);
179  std::string plotfilename;
180  plotfilename += outtrunk;
181  plotfilename += shortname;
182  plotfilename += "/pixelvstk";
183  plotfilename += corrlabfull;
184  plotfilename += "_";
185  plotfilename += shortname;
186  plotfilename += ".gif";
187  gPad->Print(plotfilename.c_str());
188  delete mult2d;
189  gPad->SetLogz(0);
190  }
191 
192  gStyle->SetOptStat(1111);
193 
194  ff.Close();
195 }
196 
197 void ClusMultInvestPlots(const char* fullname, const char* mod, const char* label, const char* postfix, const char* subdet, const char* shortname, const char* outtrunk) {
198 
199 
200  char modfull[300];
201  sprintf(modfull,"%s%s",mod,postfix);
202  char labfull[300];
203  sprintf(labfull,"%s%s",label,postfix);
204 
205  // char fullname[300];
206  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
207 
208 
209  TFile ff(fullname);
210 
211  gStyle->SetOptStat(111111);
212 
213  char subdirname[300];
214  sprintf(subdirname,"EventProcs/%s",subdet);
215  char histname[300];
216  sprintf(histname,"n%sdigi",subdet);
217 
218  CommonAnalyzer ca(&ff,"",modfull,subdirname);
219 
220  TH1F* hist = (TH1F*)ca.getObject(histname);
221  if(hist) {
222  hist->Draw();
223  gPad->SetLogy(1);
224  std::string plotfilename;
225  plotfilename += outtrunk;
226  plotfilename += shortname;
227  plotfilename += "/";
228  plotfilename += subdet;
229  plotfilename += labfull;
230  plotfilename += "_";
231  plotfilename += shortname;
232  plotfilename += ".gif";
233  gPad->Print(plotfilename.c_str());
234  delete hist;
235  gPad->SetLogy(0);
236  }
237  gStyle->SetOptStat(1111);
238 
239  ff.Close();
240 }
241 
242 void ClusMultCorrPlots(const char* fullname, const char* mod, const char* label, const char* postfix, const char* shortname, const char* outtrunk) {
243 
244 
245  char modfull[300];
246  sprintf(modfull,"%s%s",mod,postfix);
247  char labfull[300];
248  sprintf(labfull,"%s%s",label,postfix);
249 
250 
251  // char fullname[300];
252  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
253 
254 
255  TFile ff(fullname);
256 
257  gStyle->SetOptStat(111111);
258 
259  CommonAnalyzer ca(&ff,"",modfull,"");
260 
261 
262  TH1F* rat = (TH1F*)ca.getObject("PixelOverTK");
263  if(rat) {
264  rat->Draw();
265  gPad->SetLogy(1);
266  std::string plotfilename;
267  plotfilename += outtrunk;
268  plotfilename += shortname;
269  plotfilename += "/pixelovertk";
270  plotfilename += labfull;
271  plotfilename += "_";
272  plotfilename += shortname;
273  plotfilename += ".gif";
274  gPad->Print(plotfilename.c_str());
275  delete rat;
276  gPad->SetLogy(0);
277  }
278 
279 
280  TH2F* mult2d = (TH2F*)ca.getObject("PixelVsTK");
281  if(mult2d) {
282  mult2d->Draw("colz");
283  gPad->SetLogz(1);
284  // mult2d->GetXaxis()->SetRangeUser(0.,30000);
285  // mult2d->GetYaxis()->SetRangeUser(0.,15000);
286  std::string plotfilename;
287  plotfilename += outtrunk;
288  plotfilename += shortname;
289  plotfilename += "/pixelvstk";
290  plotfilename += labfull;
291  plotfilename += "_";
292  plotfilename += shortname;
293  plotfilename += ".gif";
294  gPad->Print(plotfilename.c_str());
295  delete mult2d;
296  gPad->SetLogz(0);
297  }
298 
299  gStyle->SetOptStat(1111);
300 
301  ff.Close();
302 }
303 
304 void ClusMultVtxCorrPlots(const char* fullname, const char* mod, const char* label, const char* postfix, const char* subdet, const char* shortname, const char* outtrunk) {
305 
306 
307  char modfull[300];
308  sprintf(modfull,"%s%s",mod,postfix);
309  char labfull[300];
310  sprintf(labfull,"%s%s",label,postfix);
311 
312  // char fullname[300];
313  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
314 
315 
316  TFile ff(fullname);
317 
318  gStyle->SetOptStat(111111);
319 
320  char subdirname[300];
321  sprintf(subdirname,"VtxCorr/%s",subdet);
322  char histname[300];
323  sprintf(histname,"n%sdigivsnvtx",subdet);
324  char profname[300];
325  sprintf(profname,"n%sdigivsnvtxprof",subdet);
326 
327  CommonAnalyzer ca(&ff,"",modfull,subdirname);
328 
329 
330  TH2F* histvtx = (TH2F*)ca.getObject(histname);
331  if(histvtx) {
332  histvtx->Draw("colz");
333  // TProfile* histvtxprof = histvtx->ProfileY("prof",1,-1,"");
334  TProfile* histvtxprof = 0;
335  histvtxprof = (TProfile*)ca.getObject(profname);
336  if(histvtxprof==0) {
337  std::cout << "TProfile " << profname << " missing!" << std::endl;
338  histvtxprof = histvtx->ProfileX("prof",1,-1,"");
339  }
340  histvtxprof->SetMarkerStyle(20);
341  histvtxprof->SetMarkerSize(.4);
342  /*
343  TGraph tmp;
344  for(unsigned bin=1;bin<histvtxprof->GetNbinsX()+1;++bin) {
345  // tmp.SetPoint(tmp.GetN(),histvtxprof->GetBinContent(bin),histvtxprof->GetBinCenter(bin));
346  tmp.SetPoint(tmp.GetN(),histvtxprof->GetBinCenter(bin),histvtxprof->GetBinContent(bin));
347  }
348  tmp.SetMarkerStyle(20);
349  tmp.Draw("p");
350  */
351  histvtxprof->Draw("esame");
352  gPad->SetLogz(1);
353  std::string plotfilename;
354  plotfilename += outtrunk;
355  plotfilename += shortname;
356  plotfilename += "/";
357  plotfilename += subdet;
358  plotfilename += "vtx";
359  plotfilename += labfull;
360  plotfilename += "_";
361  plotfilename += shortname;
362  plotfilename += ".gif";
363  gPad->Print(plotfilename.c_str());
364  delete histvtx;
365  gPad->SetLogz(0);
366  }
367 
368  gStyle->SetOptStat(1111);
369 
370  ff.Close();
371 }
372 
373 void ClusMultLumiCorrPlots(const char* fullname, const char* mod, const char* label,const char* postfix, const char* subdet, const char* shortname, const char* outtrunk) {
374 
375 
376  char modfull[300];
377  sprintf(modfull,"%s%s",mod,postfix);
378  char labfull[300];
379  sprintf(labfull,"%s%s",label,postfix);
380 
381  // char fullname[300];
382  // sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
383 
384 
385  TFile ff(fullname);
386 
387  gStyle->SetOptStat(111111);
388 
389  char subdirname[300];
390  sprintf(subdirname,"LumiCorr/%s",subdet);
391  char histname[300];
392  sprintf(histname,"n%sdigivslumi",subdet);
393  char profname[300];
394  sprintf(profname,"n%sdigivslumiprof",subdet);
395 
396  CommonAnalyzer ca(&ff,"",modfull,subdirname);
397 
398 
399  TH2F* histlumi = (TH2F*)ca.getObject(histname);
400  if(histlumi) {
401  histlumi->Draw("colz");
402  // TProfile* histlumiprof = histlumi->ProfileY("prof",1,-1,"");
403  TProfile* histlumiprof = 0;
404  histlumiprof = (TProfile*)ca.getObject(profname);
405  if(histlumiprof==0) {
406  std::cout << "TProfile " << profname << " missing!" << std::endl;
407  histlumiprof = histlumi->ProfileX("prof",1,-1,"");
408  }
409  histlumiprof->SetMarkerStyle(20);
410  histlumiprof->SetMarkerSize(.4);
411  /*
412  TGraph tmp;
413  for(unsigned bin=1;bin<histlumiprof->GetNbinsX()+1;++bin) {
414  // tmp.SetPoint(tmp.GetN(),histlumiprof->GetBinContent(bin),histlumiprof->GetBinCenter(bin));
415  tmp.SetPoint(tmp.GetN(),histlumiprof->GetBinCenter(bin),histlumiprof->GetBinContent(bin));
416  }
417  tmp.SetMarkerStyle(20);
418  tmp.Draw("p");
419  */
420  histlumiprof->Draw("esame");
421  gPad->SetLogz(1);
422  std::string plotfilename;
423  plotfilename += outtrunk;
424  plotfilename += shortname;
425  plotfilename += "/";
426  plotfilename += subdet;
427  plotfilename += "lumi";
428  plotfilename += labfull;
429  plotfilename += "_";
430  plotfilename += shortname;
431  plotfilename += ".gif";
432  gPad->Print(plotfilename.c_str());
433  delete histlumi;
434  gPad->SetLogz(0);
435  }
436 
437  gStyle->SetOptStat(1111);
438 
439  ff.Close();
440 }
441 
TObject * getObject(const char *name) const
void ClusMultLumiCorrPlots(const char *fullname, const char *mod, const char *label, const char *postfix, const char *subdet, const char *shortname, const char *outtrunk)
void ClusMultPlots(const char *fullname, const char *pxmod, const char *strpmod, const char *corrmod, const char *pxlabel, const char *strplabel, const char *corrlabel, const char *postfix, const char *shortname, const char *outtrunk)
void ClusMultInvestPlots(const char *fullname, const char *mod, const char *label, const char *postfix, const char *subdet, const char *shortname, const char *outtrunk)
void ClusMultVtxCorrPlots(const char *fullname, const char *mod, const char *label, const char *postfix, const char *subdet, const char *shortname, const char *outtrunk)
void setPath(const char *path)
void ClusMultCorrPlots(const char *fullname, const char *mod, const char *label, const char *postfix, const char *shortname, const char *outtrunk)
tuple cout
Definition: gather_cfg.py:145
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4