CMS 3D CMS Logo

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