15 #include "TProfile2D.h"
21 #include "TGraphErrors.h"
27 const char* shortname,
28 const char* outtrunk) {
32 sprintf(modfull,
"%s%s", module, postfix);
34 sprintf(labfull,
"%s%s",
label, postfix);
37 sprintf(
dirname,
"%s", shortname);
45 gSystem->cd(workdir.c_str());
46 gSystem->MakeDirectory(labfull);
56 sprintf(bsmodule,
"beamspotanalyzer%s", postfix);
58 sprintf(bsmodule,
"onlinebsanalyzer%s", postfix);
60 sprintf(bsmodule,
"testbsanalyzer%s", postfix);
65 TH1F* ntrvtx = (TH1F*)castat.
getObject(
"ntruevtx");
70 plotfilename += outtrunk;
73 plotfilename += labfull;
74 plotfilename +=
"/ntrvtx_";
75 plotfilename += labfull;
78 plotfilename +=
".gif";
79 gPad->Print(plotfilename.c_str());
84 gStyle->SetOptStat(111);
85 gStyle->SetOptFit(111);
86 TProfile* ntrvtxvslumi = (TProfile*)castat.
getObject(
"ntruevtxvslumi");
87 if (ntrvtxvslumi && ntrvtxvslumi->GetEntries() > 0) {
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);
95 plotfilename += outtrunk;
98 plotfilename += labfull;
99 plotfilename +=
"/ntrvtxvslumi_";
100 plotfilename += labfull;
103 plotfilename +=
".gif";
104 gPad->Print(plotfilename.c_str());
107 gStyle->SetOptStat(1111);
109 TH2D* ntrvtxvslumi2D = (TH2D*)castat.
getObject(
"ntruevtxvslumi2D");
110 if (ntrvtxvslumi2D && ntrvtxvslumi2D->GetEntries() > 0) {
111 ntrvtxvslumi2D->Draw(
"colz");
113 ntrvtxvslumi->SetMarkerStyle(20);
114 ntrvtxvslumi->SetMarkerSize(.3);
115 ntrvtxvslumi->Draw(
"same");
118 plotfilename += outtrunk;
121 plotfilename += labfull;
122 plotfilename +=
"/ntrvtxvslumi2D_";
123 plotfilename += labfull;
126 plotfilename +=
".gif";
128 gPad->Print(plotfilename.c_str());
130 delete ntrvtxvslumi2D;
136 TH1F* ndofvtx = (TH1F*)castat.
getObject(
"ndof");
140 plotfilename += outtrunk;
143 plotfilename += labfull;
144 plotfilename +=
"/ndofvtx_";
145 plotfilename += labfull;
148 plotfilename +=
".gif";
149 gPad->Print(plotfilename.c_str());
153 TH1F* ntracksvtx = (TH1F*)castat.
getObject(
"ntracks");
157 plotfilename += outtrunk;
160 plotfilename += labfull;
161 plotfilename +=
"/ntracksvtx_";
162 plotfilename += labfull;
165 plotfilename +=
".gif";
166 gPad->Print(plotfilename.c_str());
170 TH1F* aveweight = (TH1F*)castat.
getObject(
"aveweight");
174 plotfilename += outtrunk;
177 plotfilename += labfull;
178 plotfilename +=
"/aveweight_";
179 plotfilename += labfull;
182 plotfilename +=
".gif";
183 gPad->Print(plotfilename.c_str());
187 TProfile* aveweightvsvtxz = (TProfile*)castat.
getObject(
"aveweightvsvtxz");
188 if (aveweightvsvtxz) {
189 aveweightvsvtxz->Draw();
190 aveweightvsvtxz->GetYaxis()->SetRangeUser(0.75, 1.05);
192 plotfilename += outtrunk;
195 plotfilename += labfull;
196 plotfilename +=
"/aveweightvsvtxz_";
197 plotfilename += labfull;
200 plotfilename +=
".gif";
201 gPad->Print(plotfilename.c_str());
202 delete aveweightvsvtxz;
205 TProfile* ndofvsvtxz = (TProfile*)castat.
getObject(
"ndofvsvtxz");
209 plotfilename += outtrunk;
212 plotfilename += labfull;
213 plotfilename +=
"/ndofvsvtxz_";
214 plotfilename += labfull;
217 plotfilename +=
".gif";
218 gPad->Print(plotfilename.c_str());
222 TProfile* ntracksvsvtxz = (TProfile*)castat.
getObject(
"ntracksvsvtxz");
224 ntracksvsvtxz->Draw();
226 plotfilename += outtrunk;
229 plotfilename += labfull;
230 plotfilename +=
"/ntracksvsvtxz_";
231 plotfilename += labfull;
234 plotfilename +=
".gif";
235 gPad->Print(plotfilename.c_str());
236 delete ntracksvsvtxz;
241 TH2F* ndofvsntrks = (TH2F*)castat.
getObject(
"ndofvstracks");
243 ndofvsntrks->Draw(
"colz");
246 plotfilename += outtrunk;
249 plotfilename += labfull;
250 plotfilename +=
"/ndofvsntrks_";
251 plotfilename += labfull;
254 plotfilename +=
".gif";
255 gPad->Print(plotfilename.c_str());
261 TH1F* trkweights = (TH1F*)castat.
getObject(
"weights");
266 plotfilename += outtrunk;
269 plotfilename += labfull;
270 plotfilename +=
"/trkweights_";
271 plotfilename += labfull;
274 plotfilename +=
".gif";
275 gPad->Print(plotfilename.c_str());
281 TH1F* vtxx = (TH1F*)castat.
getObject(
"vtxx");
287 plotfilename += outtrunk;
290 plotfilename += labfull;
291 plotfilename +=
"/pvtxx_";
292 plotfilename += labfull;
295 plotfilename +=
".gif";
296 gPad->Print(plotfilename.c_str());
301 TH1F* vtxy = (TH1F*)castat.
getObject(
"vtxy");
307 plotfilename += outtrunk;
310 plotfilename += labfull;
311 plotfilename +=
"/pvtxy_";
312 plotfilename += labfull;
315 plotfilename +=
".gif";
316 gPad->Print(plotfilename.c_str());
321 TH1F* vtxz = (TH1F*)castat.
getObject(
"vtxz");
327 plotfilename += outtrunk;
330 plotfilename += labfull;
331 plotfilename +=
"/pvtxz_";
332 plotfilename += labfull;
335 plotfilename +=
".gif";
336 gPad->Print(plotfilename.c_str());
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);
364 std::sort(
runs.begin(),
runs.end());
367 std::cout <<
"Found " <<
runs.size() <<
" runs" << std::endl;
369 for (
unsigned int i = 0;
i <
runs.size(); ++
i) {
371 sprintf(runlabel,
"%d",
runs[
i]);
373 sprintf(runpath,
"run_%d",
runs[
i]);
380 TH1F* vtxx = (TH1F*)castat.
getObject(
"vtxxrun");
381 if (vtxx && vtxx->GetEntries() > 0) {
385 int bin = vtxxmeansum->Fill(runlabel, vtxx->GetMean());
386 vtxxmeansum->SetBinError(
bin, vtxx->GetMeanError());
389 plotfilename += outtrunk;
392 plotfilename += labfull;
393 plotfilename +=
"/pvtxx_";
394 plotfilename += labfull;
398 plotfilename += runpath;
399 plotfilename +=
".gif";
400 gPad->Print(plotfilename.c_str());
404 TH1F* vtxy = (TH1F*)castat.
getObject(
"vtxyrun");
405 if (vtxy && vtxy->GetEntries() > 0) {
409 int bin = vtxymeansum->Fill(runlabel, vtxy->GetMean());
410 vtxymeansum->SetBinError(
bin, vtxy->GetMeanError());
413 plotfilename += outtrunk;
416 plotfilename += labfull;
417 plotfilename +=
"/pvtxy_";
418 plotfilename += labfull;
422 plotfilename += runpath;
423 plotfilename +=
".gif";
424 gPad->Print(plotfilename.c_str());
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());
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);
444 int bin = vtxzmeansum->Fill(runlabel, vtxz->GetMean());
445 vtxzmeansum->SetBinError(
bin, vtxz->GetMeanError());
447 bin = vtxzsigmasum->Fill(runlabel, vtxz->GetRMS());
448 vtxzsigmasum->SetBinError(
bin, vtxz->GetRMSError());
450 vtxsigmazrunvalue = vtxz->GetRMS();
451 vtxsigmazrunerror = vtxz->GetRMSError();
454 plotfilename += outtrunk;
457 plotfilename += labfull;
458 plotfilename +=
"/pvtxz_";
459 plotfilename += labfull;
463 plotfilename += runpath;
464 plotfilename +=
".gif";
465 gPad->Print(plotfilename.c_str());
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) {
478 bsxvsorb->SetMarkerColor(kGreen);
479 bsxvsorb->SetLineColor(kGreen);
480 bsxvsorb->SetLineWidth(2);
481 bsxvsorb->Draw(
"esame");
484 onlbsxvsorb->SetMarkerColor(kRed);
485 onlbsxvsorb->SetLineColor(kRed);
486 onlbsxvsorb->Draw(
"esame");
489 testbsxvsorb->SetMarkerColor(kBlue);
490 testbsxvsorb->SetLineColor(kBlue);
491 testbsxvsorb->Draw(
"esame");
494 plotfilename += outtrunk;
497 plotfilename += labfull;
498 plotfilename +=
"/pvtxxvsorb_";
499 plotfilename += labfull;
503 plotfilename += runpath;
504 plotfilename +=
".gif";
505 gPad->Print(plotfilename.c_str());
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) {
519 bsyvsorb->SetMarkerColor(kGreen);
520 bsyvsorb->SetLineColor(kGreen);
521 bsyvsorb->SetLineWidth(2);
522 bsyvsorb->Draw(
"esame");
525 onlbsyvsorb->SetMarkerColor(kRed);
526 onlbsyvsorb->SetLineColor(kRed);
527 onlbsyvsorb->Draw(
"esame");
530 testbsyvsorb->SetMarkerColor(kCyan);
531 testbsyvsorb->SetLineColor(kCyan);
532 testbsyvsorb->Draw(
"esame");
535 plotfilename += outtrunk;
538 plotfilename += labfull;
539 plotfilename +=
"/pvtxyvsorb_";
540 plotfilename += labfull;
544 plotfilename += runpath;
545 plotfilename +=
".gif";
546 gPad->Print(plotfilename.c_str());
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) {
559 bszvsorb->SetMarkerColor(kGreen);
560 bszvsorb->SetLineColor(kGreen);
561 bszvsorb->SetLineWidth(2);
562 bszvsorb->Draw(
"esame");
565 onlbszvsorb->SetMarkerColor(kRed);
566 onlbszvsorb->SetLineColor(kRed);
567 onlbszvsorb->Draw(
"esame");
570 testbszvsorb->SetMarkerColor(kCyan);
571 testbszvsorb->SetLineColor(kCyan);
572 testbszvsorb->Draw(
"esame");
575 plotfilename += outtrunk;
578 plotfilename += labfull;
579 plotfilename +=
"/pvtxzvsorb_";
580 plotfilename += labfull;
584 plotfilename += runpath;
585 plotfilename +=
".gif";
586 gPad->Print(plotfilename.c_str());
593 TProfile* bssigmazvsorb = (TProfile*)cabs.
getObject(
"bssigmazvsorbrun");
594 TProfile* onlbssigmazvsorb = (TProfile*)cabsonl.
getObject(
"bssigmazvsorbrun");
595 TProfile* testbssigmazvsorb = (TProfile*)cabstest.
getObject(
"bssigmazvsorbrun");
598 if (bssigmazvsorb || onlbssigmazvsorb || testbssigmazvsorb) {
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.) {
607 int lastbin = bssigmazvsorb->GetNbinsX() + 1;
609 for (
int ibin = bssigmazvsorb->GetNbinsX() + 1; ibin > 0; --ibin) {
610 if (bssigmazvsorb->GetBinEntries(ibin) != 0) {
615 for (
int ibin = 1; ibin <= bssigmazvsorb->GetNbinsX() + 1; ++ibin) {
616 if (bssigmazvsorb->GetBinEntries(ibin) != 0) {
621 gr.SetMarkerStyle(20);
623 (bssigmazvsorb->GetBinCenter(firstbin) + bssigmazvsorb->GetBinCenter(lastbin)) / 2.,
626 (bssigmazvsorb->GetBinCenter(lastbin) - bssigmazvsorb->GetBinCenter(firstbin)) / 2.,
629 grfit.SetMarkerStyle(24);
630 grfit.SetMarkerColor(kBlue);
631 grfit.SetLineColor(kBlue);
633 (bssigmazvsorb->GetBinCenter(firstbin) + bssigmazvsorb->GetBinCenter(lastbin)) / 2.,
634 vtxsigmazrunfitvalue);
635 grfit.SetPointError(1,
636 (bssigmazvsorb->GetBinCenter(lastbin) - bssigmazvsorb->GetBinCenter(firstbin)) / 2.,
637 vtxsigmazrunfiterror);
641 if (onlbssigmazvsorb) {
642 onlbssigmazvsorb->SetMarkerColor(kRed);
643 onlbssigmazvsorb->SetLineColor(kRed);
644 onlbssigmazvsorb->Draw(
"esame");
646 if (testbssigmazvsorb) {
647 testbssigmazvsorb->SetMarkerColor(kCyan);
648 testbssigmazvsorb->SetLineColor(kCyan);
649 testbssigmazvsorb->Draw(
"esame");
652 plotfilename += outtrunk;
655 plotfilename += labfull;
656 plotfilename +=
"/pvtxsigmazvsorb_";
657 plotfilename += labfull;
661 plotfilename += runpath;
662 plotfilename +=
".gif";
663 gPad->Print(plotfilename.c_str());
664 delete bssigmazvsorb;
665 delete onlbssigmazvsorb;
666 delete testbssigmazvsorb;
669 TProfile* nvtxvsorb = (TProfile*)castat.
getObject(
"nvtxvsorbrun");
673 plotfilename += outtrunk;
676 plotfilename += labfull;
677 plotfilename +=
"/nvtxvsorb_";
678 plotfilename += labfull;
682 plotfilename += runpath;
683 plotfilename +=
".gif";
684 gPad->Print(plotfilename.c_str());
688 TProfile* nvtxvsbx = (TProfile*)castat.
getObject(
"nvtxvsbxrun");
690 nvtxvsbx->SetLineColor(kRed);
691 nvtxvsbx->SetMarkerColor(kRed);
692 nvtxvsbx->SetMarkerStyle(20);
693 nvtxvsbx->SetMarkerSize(.5);
696 plotfilename += outtrunk;
699 plotfilename += labfull;
700 plotfilename +=
"/nvtxvsbx_";
701 plotfilename += labfull;
705 plotfilename += runpath;
706 plotfilename +=
".gif";
707 gPad->Print(plotfilename.c_str());
711 TH2D* nvtxvsbxvsorb = (TH2D*)castat.
getObject(
"nvtxvsbxvsorbrun");
713 nvtxvsbxvsorb->Draw(
"colz");
715 plotfilename += outtrunk;
718 plotfilename += labfull;
719 plotfilename +=
"/nvtxvsbxvsorb_";
720 plotfilename += labfull;
724 plotfilename += runpath;
725 plotfilename +=
".gif";
726 gPad->Print(plotfilename.c_str());
730 cname =
"slice_run_";
732 new TCanvas(cname.c_str(), cname.c_str());
736 for (
unsigned int bx = 0;
bx < 3564; ++
bx) {
738 sprintf(hname,
"bx_%d",
bx);
739 TH1D*
slice = nvtxvsbxvsorb->ProjectionY(hname,
bx + 1,
bx + 1);
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);
749 slice->SetMaximum(4.);
764 plotfilename = outtrunk;
767 plotfilename += labfull;
768 plotfilename +=
"/nvtxvsorbsliced_";
769 plotfilename += labfull;
773 plotfilename += runpath;
774 plotfilename +=
".gif";
775 gPad->Print(plotfilename.c_str());
777 delete nvtxvsbxvsorb;
784 plotfilename = outtrunk;
787 plotfilename += labfull;
788 plotfilename +=
"/vtxxsum_";
789 plotfilename += labfull;
792 plotfilename +=
".gif";
794 TCanvas* cwidevtxx =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
796 vtxxmeansum->GetYaxis()->SetRangeUser(.05, .15);
797 vtxxmeansum->GetYaxis()->SetTitle(
"x (cm)");
801 gPad->Print(plotfilename.c_str());
804 plotfilename = outtrunk;
807 plotfilename += labfull;
808 plotfilename +=
"/vtxysum_";
809 plotfilename += labfull;
812 plotfilename +=
".gif";
814 TCanvas* cwidevtxy =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
816 vtxymeansum->GetYaxis()->SetRangeUser(-0.05, .05);
817 vtxymeansum->GetYaxis()->SetTitle(
"y (cm)");
821 gPad->Print(plotfilename.c_str());
824 plotfilename = outtrunk;
827 plotfilename += labfull;
828 plotfilename +=
"/vtxzsum_";
829 plotfilename += labfull;
832 plotfilename +=
".gif";
834 TCanvas* cwidevtxz =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
836 vtxzmeansum->GetYaxis()->SetRangeUser(-2., 2.);
837 vtxzmeansum->GetYaxis()->SetTitle(
"z (cm)");
841 gPad->Print(plotfilename.c_str());
844 plotfilename = outtrunk;
847 plotfilename += labfull;
848 plotfilename +=
"/vtxsigmazsum_";
849 plotfilename += labfull;
852 plotfilename +=
".gif";
854 TCanvas* cwidevtxsigmaz =
new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
856 vtxzsigmasum->GetYaxis()->SetRangeUser(0., 15.);
857 vtxzsigmasum->GetYaxis()->SetTitle(
"z (cm)");
858 vtxzsigmasum->Draw();
861 gPad->Print(plotfilename.c_str());
862 delete cwidevtxsigmaz;