CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PrimaryVertexPlots.cc
Go to the documentation of this file.
1 #include "PrimaryVertexPlots.h"
2 #include <vector>
3 #include <algorithm>
4 #include <string>
5 #include <map>
6 #include <iostream>
7 #include "TPad.h"
8 #include "TH1D.h"
9 #include "TFile.h"
10 #include "TH2F.h"
11 #include "TH1F.h"
12 #include "TF1.h"
13 #include "TH1D.h"
14 #include "TProfile.h"
15 #include "TProfile2D.h"
17 #include "TCanvas.h"
18 #include "TSystem.h"
19 #include "TStyle.h"
20 #include "TCanvas.h"
21 #include "TGraphErrors.h"
22 
23 void PrimaryVertexPlots(const char* fullname,const char* module, const char* postfix, const char* label, const char* shortname, const char* outtrunk) {
24 
25  std::cout << shortname << module << postfix << label << std::endl;
26 
27  char modfull[300];
28  sprintf(modfull,"%s%s",module,postfix);
29  char labfull[300];
30  sprintf(labfull,"%s%s",label,postfix);
31 
32  char dirname[400];
33  sprintf(dirname,"%s",shortname);
34 
35  // char fullname[300];
36  // if(strlen(family)==0) { sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);}
37  // else { sprintf(fullname,"rootfiles/%s.root",dirname); }
38 
39 
40 
41  std::string workdir = outtrunk ;
42  workdir += dirname;
43  gSystem->cd(workdir.c_str());
44  gSystem->MakeDirectory(labfull);
45  // gSystem->cd("/afs/cern.ch/cms/tracking/output");
46 
47 
48  TFile ff(fullname);
49 
50  // Colliding events
51 
52 
53  CommonAnalyzer castat(&ff,"",modfull);
54 
55  char bsmodule[300];
56  sprintf(bsmodule,"beamspotanalyzer%s",postfix);
57  CommonAnalyzer cabs(&ff,"",bsmodule);
58  sprintf(bsmodule,"onlinebsanalyzer%s",postfix);
59  CommonAnalyzer cabsonl(&ff,"",bsmodule);
60  sprintf(bsmodule,"testbsanalyzer%s",postfix);
61  CommonAnalyzer cabstest(&ff,"",bsmodule);
62 
63 
64  std::cout << "ready" << std::endl;
65 
66  TH1F* ntrvtx = (TH1F*)castat.getObject("ntruevtx");
67  if(ntrvtx) {
68  ntrvtx->Draw();
69  gPad->SetLogy(1);
70  std::string plotfilename;
71  plotfilename += outtrunk;
72  plotfilename += dirname;
73  plotfilename += "/";
74  plotfilename += labfull;
75  plotfilename += "/ntrvtx_";
76  plotfilename += labfull;
77  plotfilename += "_";
78  plotfilename += dirname;
79  plotfilename += ".gif";
80  gPad->Print(plotfilename.c_str());
81  delete ntrvtx;
82  gPad->SetLogy(0);
83  }
84 
85  gStyle->SetOptStat(111);
86  gStyle->SetOptFit(111);
87  TProfile* ntrvtxvslumi = (TProfile*)castat.getObject("ntruevtxvslumi");
88  if(ntrvtxvslumi && ntrvtxvslumi->GetEntries()>0 ) {
89  // ntrvtxvslumi->Draw();
90  ntrvtxvslumi->Fit("pol2","","",0.5,3.0);
91  if(ntrvtxvslumi->GetFunction("pol2")) {
92  ntrvtxvslumi->GetFunction("pol2")->SetLineColor(kBlack);
93  ntrvtxvslumi->GetFunction("pol2")->SetLineWidth(1);
94  }
95  std::string plotfilename;
96  plotfilename += outtrunk;
97  plotfilename += dirname;
98  plotfilename += "/";
99  plotfilename += labfull;
100  plotfilename += "/ntrvtxvslumi_";
101  plotfilename += labfull;
102  plotfilename += "_";
103  plotfilename += dirname;
104  plotfilename += ".gif";
105  gPad->Print(plotfilename.c_str());
106  }
107 
108  gStyle->SetOptStat(1111);
109 
110  TH2D* ntrvtxvslumi2D = (TH2D*)castat.getObject("ntruevtxvslumi2D");
111  if(ntrvtxvslumi2D && ntrvtxvslumi2D->GetEntries()>0 ) {
112  ntrvtxvslumi2D->Draw("colz");
113  if(ntrvtxvslumi) {
114  ntrvtxvslumi->SetMarkerStyle(20);
115  ntrvtxvslumi->SetMarkerSize(.3);
116  ntrvtxvslumi->Draw("same");
117  }
118  std::string plotfilename;
119  plotfilename += outtrunk;
120  plotfilename += dirname;
121  plotfilename += "/";
122  plotfilename += labfull;
123  plotfilename += "/ntrvtxvslumi2D_";
124  plotfilename += labfull;
125  plotfilename += "_";
126  plotfilename += dirname;
127  plotfilename += ".gif";
128  gPad->SetLogz(1);
129  gPad->Print(plotfilename.c_str());
130  gPad->SetLogz(0);
131  delete ntrvtxvslumi2D;
132  }
133  delete ntrvtxvslumi;
134 
135  std::cout << "ready2" << std::endl;
136 
137  TH1F* ndofvtx = (TH1F*)castat.getObject("ndof");
138  if(ndofvtx) {
139  ndofvtx->Draw();
140  std::string plotfilename;
141  plotfilename += outtrunk;
142  plotfilename += dirname;
143  plotfilename += "/";
144  plotfilename += labfull;
145  plotfilename += "/ndofvtx_";
146  plotfilename += labfull;
147  plotfilename += "_";
148  plotfilename += dirname;
149  plotfilename += ".gif";
150  gPad->Print(plotfilename.c_str());
151  delete ndofvtx;
152  }
153 
154  TH1F* ntracksvtx = (TH1F*)castat.getObject("ntracks");
155  if(ntracksvtx) {
156  ntracksvtx->Draw();
157  std::string plotfilename;
158  plotfilename += outtrunk;
159  plotfilename += dirname;
160  plotfilename += "/";
161  plotfilename += labfull;
162  plotfilename += "/ntracksvtx_";
163  plotfilename += labfull;
164  plotfilename += "_";
165  plotfilename += dirname;
166  plotfilename += ".gif";
167  gPad->Print(plotfilename.c_str());
168  delete ntracksvtx;
169  }
170 
171  TH1F* aveweight = (TH1F*)castat.getObject("aveweight");
172  if(aveweight) {
173  aveweight->Draw();
174  std::string plotfilename;
175  plotfilename += outtrunk;
176  plotfilename += dirname;
177  plotfilename += "/";
178  plotfilename += labfull;
179  plotfilename += "/aveweight_";
180  plotfilename += labfull;
181  plotfilename += "_";
182  plotfilename += dirname;
183  plotfilename += ".gif";
184  gPad->Print(plotfilename.c_str());
185  delete aveweight;
186  }
187 
188  TProfile* aveweightvsvtxz = (TProfile*)castat.getObject("aveweightvsvtxz");
189  if(aveweightvsvtxz) {
190  aveweightvsvtxz->Draw();
191  aveweightvsvtxz->GetYaxis()->SetRangeUser(0.75,1.05);
192  std::string plotfilename;
193  plotfilename += outtrunk;
194  plotfilename += dirname;
195  plotfilename += "/";
196  plotfilename += labfull;
197  plotfilename += "/aveweightvsvtxz_";
198  plotfilename += labfull;
199  plotfilename += "_";
200  plotfilename += dirname;
201  plotfilename += ".gif";
202  gPad->Print(plotfilename.c_str());
203  delete aveweightvsvtxz;
204  }
205 
206  TProfile* ndofvsvtxz = (TProfile*)castat.getObject("ndofvsvtxz");
207  if(ndofvsvtxz) {
208  ndofvsvtxz->Draw();
209  std::string plotfilename;
210  plotfilename += outtrunk;
211  plotfilename += dirname;
212  plotfilename += "/";
213  plotfilename += labfull;
214  plotfilename += "/ndofvsvtxz_";
215  plotfilename += labfull;
216  plotfilename += "_";
217  plotfilename += dirname;
218  plotfilename += ".gif";
219  gPad->Print(plotfilename.c_str());
220  delete ndofvsvtxz;
221  }
222 
223  TProfile* ntracksvsvtxz = (TProfile*)castat.getObject("ntracksvsvtxz");
224  if(ntracksvsvtxz) {
225  ntracksvsvtxz->Draw();
226  std::string plotfilename;
227  plotfilename += outtrunk;
228  plotfilename += dirname;
229  plotfilename += "/";
230  plotfilename += labfull;
231  plotfilename += "/ntracksvsvtxz_";
232  plotfilename += labfull;
233  plotfilename += "_";
234  plotfilename += dirname;
235  plotfilename += ".gif";
236  gPad->Print(plotfilename.c_str());
237  delete ntracksvsvtxz;
238  }
239 
240  std::cout << "ready3" << std::endl;
241 
242  TH2F* ndofvsntrks = (TH2F*)castat.getObject("ndofvstracks");
243  if(ndofvsntrks) {
244  ndofvsntrks->Draw("colz");
245  gPad->SetLogz(1);
246  std::string plotfilename;
247  plotfilename += outtrunk;
248  plotfilename += dirname;
249  plotfilename += "/";
250  plotfilename += labfull;
251  plotfilename += "/ndofvsntrks_";
252  plotfilename += labfull;
253  plotfilename += "_";
254  plotfilename += dirname;
255  plotfilename += ".gif";
256  gPad->Print(plotfilename.c_str());
257  delete ndofvsntrks;
258  gPad->SetLogz(0);
259  }
260  std::cout << "ready4" << std::endl;
261 
262  TH1F* trkweights = (TH1F*)castat.getObject("weights");
263  if(trkweights) {
264  trkweights->Draw();
265  gPad->SetLogy(1);
266  std::string plotfilename;
267  plotfilename += outtrunk;
268  plotfilename += dirname;
269  plotfilename += "/";
270  plotfilename += labfull;
271  plotfilename += "/trkweights_";
272  plotfilename += labfull;
273  plotfilename += "_";
274  plotfilename += dirname;
275  plotfilename += ".gif";
276  gPad->Print(plotfilename.c_str());
277  delete trkweights;
278  gPad->SetLogy(0);
279  }
280 
281  {
282  TH1F* vtxx = (TH1F*)castat.getObject("vtxx");
283  if (vtxx) {
284  vtxx->Draw();
285  gPad->SetLogy(1);
286 
287  std::string plotfilename;
288  plotfilename += outtrunk;
289  plotfilename += dirname;
290  plotfilename += "/";
291  plotfilename += labfull;
292  plotfilename += "/pvtxx_";
293  plotfilename += labfull;
294  plotfilename += "_";
295  plotfilename += dirname;
296  plotfilename += ".gif";
297  gPad->Print(plotfilename.c_str());
298  delete vtxx;
299  gPad->SetLogy(0);
300  }
301 
302  TH1F* vtxy = (TH1F*)castat.getObject("vtxy");
303  if (vtxy) {
304  vtxy->Draw();
305  gPad->SetLogy(1);
306 
307  std::string plotfilename;
308  plotfilename += outtrunk;
309  plotfilename += dirname;
310  plotfilename += "/";
311  plotfilename += labfull;
312  plotfilename += "/pvtxy_";
313  plotfilename += labfull;
314  plotfilename += "_";
315  plotfilename += dirname;
316  plotfilename += ".gif";
317  gPad->Print(plotfilename.c_str());
318  delete vtxy;
319  gPad->SetLogy(0);
320  }
321 
322  TH1F* vtxz = (TH1F*)castat.getObject("vtxz");
323  if (vtxz) {
324  vtxz->Draw();
325  gPad->SetLogy(1);
326 
327  std::string plotfilename;
328  plotfilename += outtrunk;
329  plotfilename += dirname;
330  plotfilename += "/";
331  plotfilename += labfull;
332  plotfilename += "/pvtxz_";
333  plotfilename += labfull;
334  plotfilename += "_";
335  plotfilename += dirname;
336  plotfilename += ".gif";
337  gPad->Print(plotfilename.c_str());
338  delete vtxz;
339  gPad->SetLogy(0);
340  }
341  }
342 
343  std::cout << "ready4" << std::endl;
344 
345 
346  // Summary histograms
347  /*
348  TH1D* vtxxsum = new TH1D("vtxxsum","(BS-PV) Fitted X position vs run",10,0.,10.);
349  vtxxsum->SetBit(TH1::kCanRebin);
350  TH1D* vtxysum = new TH1D("vtxysum","(BS-PV) Fitted Y position vs run",10,0.,10.);
351  vtxysum->SetBit(TH1::kCanRebin);
352  TH1D* vtxzsum = new TH1D("vtxzsum","(BS-PV) Fitted Y position vs run",10,0.,10.);
353  vtxzsum->SetBit(TH1::kCanRebin);
354  */
355 
356  TH1D* vtxxmeansum = new TH1D("vtxxmeansum","PV mean X position vs run",10,0.,10.);
357  vtxxmeansum->SetBit(TH1::kCanRebin);
358  TH1D* vtxymeansum = new TH1D("vtxymeansum","PV mean Y position vs run",10,0.,10.);
359  vtxymeansum->SetBit(TH1::kCanRebin);
360  TH1D* vtxzmeansum = new TH1D("vtxzmeansum","PV mean Z position vs run",10,0.,10.);
361  vtxzmeansum->SetBit(TH1::kCanRebin);
362  TH1D* vtxzsigmasum = new TH1D("vtxzsigmasum","PV sigma Z position vs run",10,0.,10.);
363  vtxzsigmasum->SetBit(TH1::kCanRebin);
364 
365  std::vector<unsigned int> runs = castat.getRunList();
366  std::sort(runs.begin(),runs.end());
367 
368  {
369 
370  std::cout << "Found " << runs.size() << " runs" << std::endl;
371 
372  for(unsigned int i=0;i<runs.size();++i) {
373 
374  char runlabel[100];
375  sprintf(runlabel,"%d",runs[i]);
376  char runpath[100];
377  sprintf(runpath,"run_%d",runs[i]);
378  castat.setPath(runpath);
379  cabs.setPath(runpath);
380  cabsonl.setPath(runpath);
381  cabstest.setPath(runpath);
382  std::cout << runpath << std::endl;
383 
384  TH1F* vtxx = (TH1F*)castat.getObject("vtxxrun");
385  if (vtxx && vtxx->GetEntries()>0) {
386  vtxx->Draw();
387  gPad->SetLogy(1);
388 
389 
390  int bin = vtxxmeansum->Fill(runlabel,vtxx->GetMean());
391  vtxxmeansum->SetBinError(bin,vtxx->GetMeanError());
392 
393 
394  std::string plotfilename;
395  plotfilename += outtrunk;
396  plotfilename += dirname;
397  plotfilename += "/";
398  plotfilename += labfull;
399  plotfilename += "/pvtxx_";
400  plotfilename += labfull;
401  plotfilename += "_";
402  plotfilename += dirname;
403  plotfilename += "_";
404  plotfilename += runpath;
405  plotfilename += ".gif";
406  gPad->Print(plotfilename.c_str());
407  delete vtxx;
408  }
409  gPad->SetLogy(0);
410  TH1F* vtxy = (TH1F*)castat.getObject("vtxyrun");
411  if (vtxy && vtxy->GetEntries()>0) {
412  vtxy->Draw();
413  gPad->SetLogy(1);
414 
415  int bin = vtxymeansum->Fill(runlabel,vtxy->GetMean());
416  vtxymeansum->SetBinError(bin,vtxy->GetMeanError());
417 
418  std::string plotfilename;
419  plotfilename += outtrunk;
420  plotfilename += dirname;
421  plotfilename += "/";
422  plotfilename += labfull;
423  plotfilename += "/pvtxy_";
424  plotfilename += labfull;
425  plotfilename += "_";
426  plotfilename += dirname;
427  plotfilename += "_";
428  plotfilename += runpath;
429  plotfilename += ".gif";
430  gPad->Print(plotfilename.c_str());
431  delete vtxy;
432  }
433  gPad->SetLogy(0);
434  double vtxsigmazrunvalue = -1.; double vtxsigmazrunerror = -1.;
435  double vtxsigmazrunfitvalue = -1.; double vtxsigmazrunfiterror = -1.;
436  TH1F* vtxz = (TH1F*)castat.getObject("vtxzrun");
437  if (vtxz && vtxz->GetEntries()>0) {
438  vtxz->Fit("gaus","","",-3.*vtxz->GetRMS(),3.*vtxz->GetRMS());
439  // vtxz->Draw();
440  if(vtxz->GetFunction("gaus")) {
441  vtxz->GetFunction("gaus")->SetLineColor(kRed);
442  vtxz->GetFunction("gaus")->SetLineWidth(1);
443  vtxsigmazrunfitvalue = vtxz->GetFunction("gaus")->GetParameter(2);
444  vtxsigmazrunfiterror = vtxz->GetFunction("gaus")->GetParError(2);
445  }
446  gPad->SetLogy(1);
447 
448  int bin = vtxzmeansum->Fill(runlabel,vtxz->GetMean());
449  vtxzmeansum->SetBinError(bin,vtxz->GetMeanError());
450 
451  bin = vtxzsigmasum->Fill(runlabel,vtxz->GetRMS());
452  vtxzsigmasum->SetBinError(bin,vtxz->GetRMSError());
453 
454  vtxsigmazrunvalue = vtxz->GetRMS();
455  vtxsigmazrunerror = vtxz->GetRMSError();
456 
457  std::string plotfilename;
458  plotfilename += outtrunk;
459  plotfilename += dirname;
460  plotfilename += "/";
461  plotfilename += labfull;
462  plotfilename += "/pvtxz_";
463  plotfilename += labfull;
464  plotfilename += "_";
465  plotfilename += dirname;
466  plotfilename += "_";
467  plotfilename += runpath;
468  plotfilename += ".gif";
469  gPad->Print(plotfilename.c_str());
470  delete vtxz;
471  }
472  gPad->SetLogy(0);
473 
474 
475  TH1F* vtxxvsorb = (TH1F*)castat.getObject("vtxxvsorbrun");
476  TH1F* bsxvsorb = (TH1F*)cabs.getObject("bsxvsorbrun");
477  TH1F* onlbsxvsorb = (TH1F*)cabsonl.getObject("bsxvsorbrun");
478  TH1F* testbsxvsorb = (TH1F*)cabstest.getObject("bsxvsorbrun");
479  if (vtxxvsorb && vtxxvsorb->GetEntries()>0) {
480  // vtxxvsorb->GetYaxis()->SetRangeUser(0.0650,0.07);
481  vtxxvsorb->Draw();
482  if(bsxvsorb) {
483  bsxvsorb->SetMarkerColor(kGreen); bsxvsorb->SetLineColor(kGreen); bsxvsorb->SetLineWidth(2);
484  bsxvsorb->Draw("esame");
485  }
486  if(onlbsxvsorb) {
487  onlbsxvsorb->SetMarkerColor(kRed); onlbsxvsorb->SetLineColor(kRed);
488  onlbsxvsorb->Draw("esame");
489  }
490  if(testbsxvsorb) {
491  testbsxvsorb->SetMarkerColor(kBlue); testbsxvsorb->SetLineColor(kBlue);
492  testbsxvsorb->Draw("esame");
493  }
494  std::string plotfilename;
495  plotfilename += outtrunk;
496  plotfilename += dirname;
497  plotfilename += "/";
498  plotfilename += labfull;
499  plotfilename += "/pvtxxvsorb_";
500  plotfilename += labfull;
501  plotfilename += "_";
502  plotfilename += dirname;
503  plotfilename += "_";
504  plotfilename += runpath;
505  plotfilename += ".gif";
506  gPad->Print(plotfilename.c_str());
507  delete vtxxvsorb; delete bsxvsorb; delete onlbsxvsorb; delete testbsxvsorb;
508  }
509  TH1F* vtxyvsorb = (TH1F*)castat.getObject("vtxyvsorbrun");
510  TH1F* bsyvsorb = (TH1F*)cabs.getObject("bsyvsorbrun");
511  TH1F* onlbsyvsorb = (TH1F*)cabsonl.getObject("bsyvsorbrun");
512  TH1F* testbsyvsorb = (TH1F*)cabstest.getObject("bsyvsorbrun");
513  if (vtxyvsorb && vtxyvsorb->GetEntries()>0) {
514  // vtxyvsorb->GetYaxis()->SetRangeUser(0.0620,0.0670);
515  vtxyvsorb->Draw();
516  if(bsyvsorb) {
517  bsyvsorb->SetMarkerColor(kGreen); bsyvsorb->SetLineColor(kGreen); bsyvsorb->SetLineWidth(2);
518  bsyvsorb->Draw("esame");
519  }
520  if(onlbsyvsorb) {
521  onlbsyvsorb->SetMarkerColor(kRed); onlbsyvsorb->SetLineColor(kRed);
522  onlbsyvsorb->Draw("esame");
523  }
524  if(testbsyvsorb) {
525  testbsyvsorb->SetMarkerColor(kCyan); testbsyvsorb->SetLineColor(kCyan);
526  testbsyvsorb->Draw("esame");
527  }
528  std::string plotfilename;
529  plotfilename += outtrunk;
530  plotfilename += dirname;
531  plotfilename += "/";
532  plotfilename += labfull;
533  plotfilename += "/pvtxyvsorb_";
534  plotfilename += labfull;
535  plotfilename += "_";
536  plotfilename += dirname;
537  plotfilename += "_";
538  plotfilename += runpath;
539  plotfilename += ".gif";
540  gPad->Print(plotfilename.c_str());
541  delete vtxyvsorb; delete bsyvsorb; delete onlbsyvsorb; delete testbsyvsorb;
542  }
543  TH1F* vtxzvsorb = (TH1F*)castat.getObject("vtxzvsorbrun");
544  TH1F* bszvsorb = (TH1F*)cabs.getObject("bszvsorbrun");
545  TH1F* onlbszvsorb = (TH1F*)cabsonl.getObject("bszvsorbrun");
546  TH1F* testbszvsorb = (TH1F*)cabstest.getObject("bszvsorbrun");
547  if (vtxzvsorb && vtxzvsorb->GetEntries()>0) {
548  vtxzvsorb->Draw();
549  if(bszvsorb) {
550  bszvsorb->SetMarkerColor(kGreen); bszvsorb->SetLineColor(kGreen); bszvsorb->SetLineWidth(2);
551  bszvsorb->Draw("esame");
552  }
553  if(onlbszvsorb) {
554  onlbszvsorb->SetMarkerColor(kRed); onlbszvsorb->SetLineColor(kRed);
555  onlbszvsorb->Draw("esame");
556  }
557  if(testbszvsorb) {
558  testbszvsorb->SetMarkerColor(kCyan); testbszvsorb->SetLineColor(kCyan);
559  testbszvsorb->Draw("esame");
560  }
561  std::string plotfilename;
562  plotfilename += outtrunk;
563  plotfilename += dirname;
564  plotfilename += "/";
565  plotfilename += labfull;
566  plotfilename += "/pvtxzvsorb_";
567  plotfilename += labfull;
568  plotfilename += "_";
569  plotfilename += dirname;
570  plotfilename += "_";
571  plotfilename += runpath;
572  plotfilename += ".gif";
573  gPad->Print(plotfilename.c_str());
574  delete vtxzvsorb; delete bszvsorb; delete onlbszvsorb; delete testbszvsorb;
575  }
576 
577  TProfile* bssigmazvsorb = (TProfile*)cabs.getObject("bssigmazvsorbrun");
578  TProfile* onlbssigmazvsorb = (TProfile*)cabsonl.getObject("bssigmazvsorbrun");
579  TProfile* testbssigmazvsorb = (TProfile*)cabstest.getObject("bssigmazvsorbrun");
580  TGraphErrors gr;TGraphErrors grfit;
581  if ( bssigmazvsorb || onlbssigmazvsorb || testbssigmazvsorb) {
582  if(bssigmazvsorb) {
583  bssigmazvsorb->SetMarkerColor(kGreen); bssigmazvsorb->SetLineColor(kGreen); bssigmazvsorb->SetLineWidth(2);
584  bssigmazvsorb->Draw();
585  bssigmazvsorb->GetYaxis()->SetRangeUser(0.,7.);
586  if(vtxsigmazrunvalue >= 0.) {
587  // look for last filled bin
588  int lastbin= bssigmazvsorb->GetNbinsX()+1;
589  int firstbin= 1;
590  for(int ibin=bssigmazvsorb->GetNbinsX()+1;ibin>0;--ibin) {
591  if(bssigmazvsorb->GetBinEntries(ibin)!=0) {
592  lastbin=ibin;
593  break;
594  }
595  }
596  for(int ibin=1;ibin<=bssigmazvsorb->GetNbinsX()+1;++ibin) {
597  if(bssigmazvsorb->GetBinEntries(ibin)!=0) {
598  firstbin=ibin;
599  break;
600  }
601  }
602  gr.SetMarkerStyle(20);
603  gr.SetPoint(1,(bssigmazvsorb->GetBinCenter(firstbin)+bssigmazvsorb->GetBinCenter(lastbin))/2.,vtxsigmazrunvalue);
604  gr.SetPointError(1,(bssigmazvsorb->GetBinCenter(lastbin)-bssigmazvsorb->GetBinCenter(firstbin))/2.,vtxsigmazrunerror);
605  gr.Draw("p");
606  grfit.SetMarkerStyle(24);grfit.SetMarkerColor(kBlue);grfit.SetLineColor(kBlue);
607  grfit.SetPoint(1,(bssigmazvsorb->GetBinCenter(firstbin)+bssigmazvsorb->GetBinCenter(lastbin))/2.,vtxsigmazrunfitvalue);
608  grfit.SetPointError(1,(bssigmazvsorb->GetBinCenter(lastbin)-bssigmazvsorb->GetBinCenter(firstbin))/2.,vtxsigmazrunfiterror);
609  grfit.Draw("p");
610  }
611  }
612  if(onlbssigmazvsorb) {
613  onlbssigmazvsorb->SetMarkerColor(kRed); onlbssigmazvsorb->SetLineColor(kRed);
614  onlbssigmazvsorb->Draw("esame");
615  }
616  if(testbssigmazvsorb) {
617  testbssigmazvsorb->SetMarkerColor(kCyan); testbssigmazvsorb->SetLineColor(kCyan);
618  testbssigmazvsorb->Draw("esame");
619  }
620  std::string plotfilename;
621  plotfilename += outtrunk;
622  plotfilename += dirname;
623  plotfilename += "/";
624  plotfilename += labfull;
625  plotfilename += "/pvtxsigmazvsorb_";
626  plotfilename += labfull;
627  plotfilename += "_";
628  plotfilename += dirname;
629  plotfilename += "_";
630  plotfilename += runpath;
631  plotfilename += ".gif";
632  gPad->Print(plotfilename.c_str());
633  delete bssigmazvsorb; delete onlbssigmazvsorb; delete testbssigmazvsorb;
634  }
635 
636 
637 
638 
639 
640 
641  TProfile* nvtxvsorb = (TProfile*)castat.getObject("nvtxvsorbrun");
642  if(nvtxvsorb) {
643  nvtxvsorb->Draw();
644  std::string plotfilename;
645  plotfilename += outtrunk;
646  plotfilename += dirname;
647  plotfilename += "/";
648  plotfilename += labfull;
649  plotfilename += "/nvtxvsorb_";
650  plotfilename += labfull;
651  plotfilename += "_";
652  plotfilename += dirname;
653  plotfilename += "_";
654  plotfilename += runpath;
655  plotfilename += ".gif";
656  gPad->Print(plotfilename.c_str());
657  delete nvtxvsorb;
658  }
659 
660  TProfile* nvtxvsbx = (TProfile*)castat.getObject("nvtxvsbxrun");
661  if(nvtxvsbx) {
662  nvtxvsbx->SetLineColor(kRed); nvtxvsbx->SetMarkerColor(kRed); nvtxvsbx->SetMarkerStyle(20); nvtxvsbx->SetMarkerSize(.5);
663  nvtxvsbx->Draw();
664  std::string plotfilename;
665  plotfilename += outtrunk;
666  plotfilename += dirname;
667  plotfilename += "/";
668  plotfilename += labfull;
669  plotfilename += "/nvtxvsbx_";
670  plotfilename += labfull;
671  plotfilename += "_";
672  plotfilename += dirname;
673  plotfilename += "_";
674  plotfilename += runpath;
675  plotfilename += ".gif";
676  gPad->Print(plotfilename.c_str());
677  delete nvtxvsbx;
678  }
679 
680  TH2D* nvtxvsbxvsorb = (TH2D*)castat.getObject("nvtxvsbxvsorbrun");
681  if(nvtxvsbxvsorb) {
682 
683  nvtxvsbxvsorb->Draw("colz");
684  std::string plotfilename;
685  plotfilename += outtrunk;
686  plotfilename += dirname;
687  plotfilename += "/";
688  plotfilename += labfull;
689  plotfilename += "/nvtxvsbxvsorb_";
690  plotfilename += labfull;
691  plotfilename += "_";
692  plotfilename += dirname;
693  plotfilename += "_";
694  plotfilename += runpath;
695  plotfilename += ".gif";
696  gPad->Print(plotfilename.c_str());
697 
698  // slicing
699  std::string cname;
700  cname = "slice_run_";
701  cname += runpath;
702  new TCanvas(cname.c_str(),cname.c_str());
703  bool first=true;
704  int mcount=20;
705  int ccount=1;
706  for(unsigned int bx=1;bx<3564;++bx) {
707  char hname[300];
708  sprintf(hname,"bx_%d",bx);
709  TH1D* slice = nvtxvsbxvsorb->ProjectionY(hname,bx+1,bx+1);
710  // std::cout << "slice " << bx << " with pointer " << slice << std::endl;
711  if(slice) {
712  if(slice->GetEntries()) {
713  std::cout << "slice " << bx << " ready " << std::endl;
714  slice->SetMarkerStyle(mcount);
715  slice->SetMarkerColor(ccount);
716  slice->SetLineColor(ccount);
717  slice->SetMarkerSize(.4);
718  if(first) {slice->SetMaximum(4.); slice->Draw("e");}
719  else {slice->Draw("same");}
720  first=false;
721  ++mcount;
722  if(mcount==28) {mcount=20; ++ccount;}
723  }
724  }
725  }
726  // std::string plotfilename;
727  plotfilename = outtrunk;
728  plotfilename += dirname;
729  plotfilename += "/";
730  plotfilename += labfull;
731  plotfilename += "/nvtxvsorbsliced_";
732  plotfilename += labfull;
733  plotfilename += "_";
734  plotfilename += dirname;
735  plotfilename += "_";
736  plotfilename += runpath;
737  plotfilename += ".gif";
738  gPad->Print(plotfilename.c_str());
739 
740  delete nvtxvsbxvsorb;
741  }
742  }
743 
744  }
745  if(runs.size()) {
746  std::string plotfilename;
747 
748  plotfilename = outtrunk;
749  plotfilename += dirname;
750  plotfilename += "/";
751  plotfilename += labfull;
752  plotfilename += "/vtxxsum_";
753  plotfilename += labfull;
754  plotfilename += "_";
755  plotfilename += dirname;
756  plotfilename += ".gif";
757 
758  TCanvas * cwidevtxx = new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
759 
760  vtxxmeansum->GetYaxis()->SetRangeUser(.05,.15);
761  vtxxmeansum->GetYaxis()->SetTitle("x (cm)");
762  vtxxmeansum->Draw();
763  // vtxxmeansum->SetLineColor(kRed); vtxxmeansum->SetMarkerColor(kRed);
764  // vtxxmeansum->Draw("esame");
765  gPad->Print(plotfilename.c_str());
766  delete cwidevtxx;
767 
768  plotfilename = outtrunk;
769  plotfilename += dirname;
770  plotfilename += "/";
771  plotfilename += labfull;
772  plotfilename += "/vtxysum_";
773  plotfilename += labfull;
774  plotfilename += "_";
775  plotfilename += dirname;
776  plotfilename += ".gif";
777 
778  TCanvas * cwidevtxy = new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
779 
780  vtxymeansum->GetYaxis()->SetRangeUser(-0.05,.05);
781  vtxymeansum->GetYaxis()->SetTitle("y (cm)");
782  vtxymeansum->Draw();
783  // vtxymeansum->SetLineColor(kRed); vtxymeansum->SetMarkerColor(kRed);
784  // vtxymeansum->Draw("esame");
785  gPad->Print(plotfilename.c_str());
786  delete cwidevtxy;
787 
788  plotfilename = outtrunk;
789  plotfilename += dirname;
790  plotfilename += "/";
791  plotfilename += labfull;
792  plotfilename += "/vtxzsum_";
793  plotfilename += labfull;
794  plotfilename += "_";
795  plotfilename += dirname;
796  plotfilename += ".gif";
797 
798  TCanvas * cwidevtxz = new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
799 
800  vtxzmeansum->GetYaxis()->SetRangeUser(-2.,2.);
801  vtxzmeansum->GetYaxis()->SetTitle("z (cm)");
802  vtxzmeansum->Draw();
803  // vtxzmeansum->SetLineColor(kRed); vtxzmeansum->SetMarkerColor(kRed);
804  // vtxzmeansum->Draw("esame");
805  gPad->Print(plotfilename.c_str());
806  delete cwidevtxz;
807 
808  plotfilename = outtrunk;
809  plotfilename += dirname;
810  plotfilename += "/";
811  plotfilename += labfull;
812  plotfilename += "/vtxsigmazsum_";
813  plotfilename += labfull;
814  plotfilename += "_";
815  plotfilename += dirname;
816  plotfilename += ".gif";
817 
818  TCanvas * cwidevtxsigmaz = new TCanvas(plotfilename.c_str(),plotfilename.c_str(),1500,500);
819 
820  vtxzsigmasum->GetYaxis()->SetRangeUser(0.,15.);
821  vtxzsigmasum->GetYaxis()->SetTitle("z (cm)");
822  vtxzsigmasum->Draw();
823  // vtxzsigmasum->SetLineColor(kRed); vtxzsigmasum->SetMarkerColor(kRed);
824  // vtxzsigmasum->Draw("esame");
825  gPad->Print(plotfilename.c_str());
826  delete cwidevtxsigmaz;
827 
828  }
829  delete vtxxmeansum;
830  delete vtxymeansum;
831  delete vtxzmeansum;
832  delete vtxzsigmasum;
833 }
834 
int i
Definition: DBlmapReader.cc:9
TObject * getObject(const char *name) const
tuple runs
Definition: gather_cfg.py:87
bool first
Definition: L1TdeRCT.cc:75
void setPath(const char *path)
const std::vector< unsigned int > getRunList() const
tuple cout
Definition: gather_cfg.py:121
Definition: vlib.h:208
void PrimaryVertexPlots(const char *fullname, const char *module, const char *postfix, const char *label, const char *shortname, const char *outtrunk)