CMS 3D CMS Logo

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