Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:34:21

0001 #include "PrimaryVertexPlots.h"
0002 #include <vector>
0003 #include <algorithm>
0004 #include <string>
0005 #include <map>
0006 #include <iostream>
0007 #include "TPad.h"
0008 #include "TH1D.h"
0009 #include "TFile.h"
0010 #include "TH2F.h"
0011 #include "TH1F.h"
0012 #include "TF1.h"
0013 #include "TH1D.h"
0014 #include "TProfile.h"
0015 #include "TProfile2D.h"
0016 #include "DPGAnalysis/SiStripTools/interface/CommonAnalyzer.h"
0017 #include "TCanvas.h"
0018 #include "TSystem.h"
0019 #include "TStyle.h"
0020 #include "TCanvas.h"
0021 #include "TGraphErrors.h"
0022 
0023 void PrimaryVertexPlots(const char* fullname,
0024                         const char* module,
0025                         const char* postfix,
0026                         const char* label,
0027                         const char* shortname,
0028                         const char* outtrunk) {
0029   std::cout << shortname << module << postfix << label << std::endl;
0030 
0031   char modfull[300];
0032   sprintf(modfull, "%s%s", module, postfix);
0033   char labfull[300];
0034   sprintf(labfull, "%s%s", label, postfix);
0035 
0036   char dirname[400];
0037   sprintf(dirname, "%s", shortname);
0038 
0039   //  char fullname[300];
0040   //  if(strlen(family)==0) {  sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);}
0041   //  else {  sprintf(fullname,"rootfiles/%s.root",dirname); }
0042 
0043   std::string workdir = outtrunk;
0044   workdir += dirname;
0045   gSystem->cd(workdir.c_str());
0046   gSystem->MakeDirectory(labfull);
0047   //  gSystem->cd("/afs/cern.ch/cms/tracking/output");
0048 
0049   TFile ff(fullname);
0050 
0051   // Colliding events
0052 
0053   CommonAnalyzer castat(&ff, "", modfull);
0054 
0055   char bsmodule[300];
0056   sprintf(bsmodule, "beamspotanalyzer%s", postfix);
0057   CommonAnalyzer cabs(&ff, "", bsmodule);
0058   sprintf(bsmodule, "onlinebsanalyzer%s", postfix);
0059   CommonAnalyzer cabsonl(&ff, "", bsmodule);
0060   sprintf(bsmodule, "testbsanalyzer%s", postfix);
0061   CommonAnalyzer cabstest(&ff, "", bsmodule);
0062 
0063   std::cout << "ready" << std::endl;
0064 
0065   TH1F* ntrvtx = (TH1F*)castat.getObject("ntruevtx");
0066   if (ntrvtx) {
0067     ntrvtx->Draw();
0068     gPad->SetLogy(1);
0069     std::string plotfilename;
0070     plotfilename += outtrunk;
0071     plotfilename += dirname;
0072     plotfilename += "/";
0073     plotfilename += labfull;
0074     plotfilename += "/ntrvtx_";
0075     plotfilename += labfull;
0076     plotfilename += "_";
0077     plotfilename += dirname;
0078     plotfilename += ".gif";
0079     gPad->Print(plotfilename.c_str());
0080     delete ntrvtx;
0081     gPad->SetLogy(0);
0082   }
0083 
0084   gStyle->SetOptStat(111);
0085   gStyle->SetOptFit(111);
0086   TProfile* ntrvtxvslumi = (TProfile*)castat.getObject("ntruevtxvslumi");
0087   if (ntrvtxvslumi && ntrvtxvslumi->GetEntries() > 0) {
0088     //  ntrvtxvslumi->Draw();
0089     ntrvtxvslumi->Fit("pol2", "", "", 0.5, 3.0);
0090     if (ntrvtxvslumi->GetFunction("pol2")) {
0091       ntrvtxvslumi->GetFunction("pol2")->SetLineColor(kBlack);
0092       ntrvtxvslumi->GetFunction("pol2")->SetLineWidth(1);
0093     }
0094     std::string plotfilename;
0095     plotfilename += outtrunk;
0096     plotfilename += dirname;
0097     plotfilename += "/";
0098     plotfilename += labfull;
0099     plotfilename += "/ntrvtxvslumi_";
0100     plotfilename += labfull;
0101     plotfilename += "_";
0102     plotfilename += dirname;
0103     plotfilename += ".gif";
0104     gPad->Print(plotfilename.c_str());
0105   }
0106 
0107   gStyle->SetOptStat(1111);
0108 
0109   TH2D* ntrvtxvslumi2D = (TH2D*)castat.getObject("ntruevtxvslumi2D");
0110   if (ntrvtxvslumi2D && ntrvtxvslumi2D->GetEntries() > 0) {
0111     ntrvtxvslumi2D->Draw("colz");
0112     if (ntrvtxvslumi) {
0113       ntrvtxvslumi->SetMarkerStyle(20);
0114       ntrvtxvslumi->SetMarkerSize(.3);
0115       ntrvtxvslumi->Draw("same");
0116     }
0117     std::string plotfilename;
0118     plotfilename += outtrunk;
0119     plotfilename += dirname;
0120     plotfilename += "/";
0121     plotfilename += labfull;
0122     plotfilename += "/ntrvtxvslumi2D_";
0123     plotfilename += labfull;
0124     plotfilename += "_";
0125     plotfilename += dirname;
0126     plotfilename += ".gif";
0127     gPad->SetLogz(1);
0128     gPad->Print(plotfilename.c_str());
0129     gPad->SetLogz(0);
0130     delete ntrvtxvslumi2D;
0131   }
0132   delete ntrvtxvslumi;
0133 
0134   std::cout << "ready2" << std::endl;
0135 
0136   TH1F* ndofvtx = (TH1F*)castat.getObject("ndof");
0137   if (ndofvtx) {
0138     ndofvtx->Draw();
0139     std::string plotfilename;
0140     plotfilename += outtrunk;
0141     plotfilename += dirname;
0142     plotfilename += "/";
0143     plotfilename += labfull;
0144     plotfilename += "/ndofvtx_";
0145     plotfilename += labfull;
0146     plotfilename += "_";
0147     plotfilename += dirname;
0148     plotfilename += ".gif";
0149     gPad->Print(plotfilename.c_str());
0150     delete ndofvtx;
0151   }
0152 
0153   TH1F* ntracksvtx = (TH1F*)castat.getObject("ntracks");
0154   if (ntracksvtx) {
0155     ntracksvtx->Draw();
0156     std::string plotfilename;
0157     plotfilename += outtrunk;
0158     plotfilename += dirname;
0159     plotfilename += "/";
0160     plotfilename += labfull;
0161     plotfilename += "/ntracksvtx_";
0162     plotfilename += labfull;
0163     plotfilename += "_";
0164     plotfilename += dirname;
0165     plotfilename += ".gif";
0166     gPad->Print(plotfilename.c_str());
0167     delete ntracksvtx;
0168   }
0169 
0170   TH1F* aveweight = (TH1F*)castat.getObject("aveweight");
0171   if (aveweight) {
0172     aveweight->Draw();
0173     std::string plotfilename;
0174     plotfilename += outtrunk;
0175     plotfilename += dirname;
0176     plotfilename += "/";
0177     plotfilename += labfull;
0178     plotfilename += "/aveweight_";
0179     plotfilename += labfull;
0180     plotfilename += "_";
0181     plotfilename += dirname;
0182     plotfilename += ".gif";
0183     gPad->Print(plotfilename.c_str());
0184     delete aveweight;
0185   }
0186 
0187   TProfile* aveweightvsvtxz = (TProfile*)castat.getObject("aveweightvsvtxz");
0188   if (aveweightvsvtxz) {
0189     aveweightvsvtxz->Draw();
0190     aveweightvsvtxz->GetYaxis()->SetRangeUser(0.75, 1.05);
0191     std::string plotfilename;
0192     plotfilename += outtrunk;
0193     plotfilename += dirname;
0194     plotfilename += "/";
0195     plotfilename += labfull;
0196     plotfilename += "/aveweightvsvtxz_";
0197     plotfilename += labfull;
0198     plotfilename += "_";
0199     plotfilename += dirname;
0200     plotfilename += ".gif";
0201     gPad->Print(plotfilename.c_str());
0202     delete aveweightvsvtxz;
0203   }
0204 
0205   TProfile* ndofvsvtxz = (TProfile*)castat.getObject("ndofvsvtxz");
0206   if (ndofvsvtxz) {
0207     ndofvsvtxz->Draw();
0208     std::string plotfilename;
0209     plotfilename += outtrunk;
0210     plotfilename += dirname;
0211     plotfilename += "/";
0212     plotfilename += labfull;
0213     plotfilename += "/ndofvsvtxz_";
0214     plotfilename += labfull;
0215     plotfilename += "_";
0216     plotfilename += dirname;
0217     plotfilename += ".gif";
0218     gPad->Print(plotfilename.c_str());
0219     delete ndofvsvtxz;
0220   }
0221 
0222   TProfile* ntracksvsvtxz = (TProfile*)castat.getObject("ntracksvsvtxz");
0223   if (ntracksvsvtxz) {
0224     ntracksvsvtxz->Draw();
0225     std::string plotfilename;
0226     plotfilename += outtrunk;
0227     plotfilename += dirname;
0228     plotfilename += "/";
0229     plotfilename += labfull;
0230     plotfilename += "/ntracksvsvtxz_";
0231     plotfilename += labfull;
0232     plotfilename += "_";
0233     plotfilename += dirname;
0234     plotfilename += ".gif";
0235     gPad->Print(plotfilename.c_str());
0236     delete ntracksvsvtxz;
0237   }
0238 
0239   std::cout << "ready3" << std::endl;
0240 
0241   TH2F* ndofvsntrks = (TH2F*)castat.getObject("ndofvstracks");
0242   if (ndofvsntrks) {
0243     ndofvsntrks->Draw("colz");
0244     gPad->SetLogz(1);
0245     std::string plotfilename;
0246     plotfilename += outtrunk;
0247     plotfilename += dirname;
0248     plotfilename += "/";
0249     plotfilename += labfull;
0250     plotfilename += "/ndofvsntrks_";
0251     plotfilename += labfull;
0252     plotfilename += "_";
0253     plotfilename += dirname;
0254     plotfilename += ".gif";
0255     gPad->Print(plotfilename.c_str());
0256     delete ndofvsntrks;
0257     gPad->SetLogz(0);
0258   }
0259   std::cout << "ready4" << std::endl;
0260 
0261   TH1F* trkweights = (TH1F*)castat.getObject("weights");
0262   if (trkweights) {
0263     trkweights->Draw();
0264     gPad->SetLogy(1);
0265     std::string plotfilename;
0266     plotfilename += outtrunk;
0267     plotfilename += dirname;
0268     plotfilename += "/";
0269     plotfilename += labfull;
0270     plotfilename += "/trkweights_";
0271     plotfilename += labfull;
0272     plotfilename += "_";
0273     plotfilename += dirname;
0274     plotfilename += ".gif";
0275     gPad->Print(plotfilename.c_str());
0276     delete trkweights;
0277     gPad->SetLogy(0);
0278   }
0279 
0280   {
0281     TH1F* vtxx = (TH1F*)castat.getObject("vtxx");
0282     if (vtxx) {
0283       vtxx->Draw();
0284       gPad->SetLogy(1);
0285 
0286       std::string plotfilename;
0287       plotfilename += outtrunk;
0288       plotfilename += dirname;
0289       plotfilename += "/";
0290       plotfilename += labfull;
0291       plotfilename += "/pvtxx_";
0292       plotfilename += labfull;
0293       plotfilename += "_";
0294       plotfilename += dirname;
0295       plotfilename += ".gif";
0296       gPad->Print(plotfilename.c_str());
0297       delete vtxx;
0298       gPad->SetLogy(0);
0299     }
0300 
0301     TH1F* vtxy = (TH1F*)castat.getObject("vtxy");
0302     if (vtxy) {
0303       vtxy->Draw();
0304       gPad->SetLogy(1);
0305 
0306       std::string plotfilename;
0307       plotfilename += outtrunk;
0308       plotfilename += dirname;
0309       plotfilename += "/";
0310       plotfilename += labfull;
0311       plotfilename += "/pvtxy_";
0312       plotfilename += labfull;
0313       plotfilename += "_";
0314       plotfilename += dirname;
0315       plotfilename += ".gif";
0316       gPad->Print(plotfilename.c_str());
0317       delete vtxy;
0318       gPad->SetLogy(0);
0319     }
0320 
0321     TH1F* vtxz = (TH1F*)castat.getObject("vtxz");
0322     if (vtxz) {
0323       vtxz->Draw();
0324       gPad->SetLogy(1);
0325 
0326       std::string plotfilename;
0327       plotfilename += outtrunk;
0328       plotfilename += dirname;
0329       plotfilename += "/";
0330       plotfilename += labfull;
0331       plotfilename += "/pvtxz_";
0332       plotfilename += labfull;
0333       plotfilename += "_";
0334       plotfilename += dirname;
0335       plotfilename += ".gif";
0336       gPad->Print(plotfilename.c_str());
0337       delete vtxz;
0338       gPad->SetLogy(0);
0339     }
0340   }
0341 
0342   std::cout << "ready4" << std::endl;
0343 
0344   // Summary histograms
0345   /*
0346   TH1D* vtxxsum = new TH1D("vtxxsum","(BS-PV) Fitted X position vs run",10,0.,10.);
0347   vtxxsum->SetCanExtend(TH1::kAllAxes);
0348   TH1D* vtxysum = new TH1D("vtxysum","(BS-PV) Fitted Y position vs run",10,0.,10.);
0349   vtxysum->SetCanExtend(TH1::kAllAxes);
0350   TH1D* vtxzsum = new TH1D("vtxzsum","(BS-PV) Fitted Y position vs run",10,0.,10.);
0351   vtxzsum->SetCanExtend(TH1::kAllAxes);
0352   */
0353 
0354   TH1D* vtxxmeansum = new TH1D("vtxxmeansum", "PV mean X position vs run", 10, 0., 10.);
0355   vtxxmeansum->SetCanExtend(TH1::kAllAxes);
0356   TH1D* vtxymeansum = new TH1D("vtxymeansum", "PV mean Y position vs run", 10, 0., 10.);
0357   vtxymeansum->SetCanExtend(TH1::kAllAxes);
0358   TH1D* vtxzmeansum = new TH1D("vtxzmeansum", "PV mean Z position vs run", 10, 0., 10.);
0359   vtxzmeansum->SetCanExtend(TH1::kAllAxes);
0360   TH1D* vtxzsigmasum = new TH1D("vtxzsigmasum", "PV sigma Z position vs run", 10, 0., 10.);
0361   vtxzsigmasum->SetCanExtend(TH1::kAllAxes);
0362 
0363   std::vector<unsigned int> runs = castat.getRunList();
0364   std::sort(runs.begin(), runs.end());
0365 
0366   {
0367     std::cout << "Found " << runs.size() << " runs" << std::endl;
0368 
0369     for (unsigned int i = 0; i < runs.size(); ++i) {
0370       char runlabel[100];
0371       sprintf(runlabel, "%d", runs[i]);
0372       char runpath[100];
0373       sprintf(runpath, "run_%d", runs[i]);
0374       castat.setPath(runpath);
0375       cabs.setPath(runpath);
0376       cabsonl.setPath(runpath);
0377       cabstest.setPath(runpath);
0378       std::cout << runpath << std::endl;
0379 
0380       TH1F* vtxx = (TH1F*)castat.getObject("vtxxrun");
0381       if (vtxx && vtxx->GetEntries() > 0) {
0382         vtxx->Draw();
0383         gPad->SetLogy(1);
0384 
0385         int bin = vtxxmeansum->Fill(runlabel, vtxx->GetMean());
0386         vtxxmeansum->SetBinError(bin, vtxx->GetMeanError());
0387 
0388         std::string plotfilename;
0389         plotfilename += outtrunk;
0390         plotfilename += dirname;
0391         plotfilename += "/";
0392         plotfilename += labfull;
0393         plotfilename += "/pvtxx_";
0394         plotfilename += labfull;
0395         plotfilename += "_";
0396         plotfilename += dirname;
0397         plotfilename += "_";
0398         plotfilename += runpath;
0399         plotfilename += ".gif";
0400         gPad->Print(plotfilename.c_str());
0401         delete vtxx;
0402       }
0403       gPad->SetLogy(0);
0404       TH1F* vtxy = (TH1F*)castat.getObject("vtxyrun");
0405       if (vtxy && vtxy->GetEntries() > 0) {
0406         vtxy->Draw();
0407         gPad->SetLogy(1);
0408 
0409         int bin = vtxymeansum->Fill(runlabel, vtxy->GetMean());
0410         vtxymeansum->SetBinError(bin, vtxy->GetMeanError());
0411 
0412         std::string plotfilename;
0413         plotfilename += outtrunk;
0414         plotfilename += dirname;
0415         plotfilename += "/";
0416         plotfilename += labfull;
0417         plotfilename += "/pvtxy_";
0418         plotfilename += labfull;
0419         plotfilename += "_";
0420         plotfilename += dirname;
0421         plotfilename += "_";
0422         plotfilename += runpath;
0423         plotfilename += ".gif";
0424         gPad->Print(plotfilename.c_str());
0425         delete vtxy;
0426       }
0427       gPad->SetLogy(0);
0428       double vtxsigmazrunvalue = -1.;
0429       double vtxsigmazrunerror = -1.;
0430       double vtxsigmazrunfitvalue = -1.;
0431       double vtxsigmazrunfiterror = -1.;
0432       TH1F* vtxz = (TH1F*)castat.getObject("vtxzrun");
0433       if (vtxz && vtxz->GetEntries() > 0) {
0434         vtxz->Fit("gaus", "", "", -3. * vtxz->GetRMS(), 3. * vtxz->GetRMS());
0435         //  vtxz->Draw();
0436         if (vtxz->GetFunction("gaus")) {
0437           vtxz->GetFunction("gaus")->SetLineColor(kRed);
0438           vtxz->GetFunction("gaus")->SetLineWidth(1);
0439           vtxsigmazrunfitvalue = vtxz->GetFunction("gaus")->GetParameter(2);
0440           vtxsigmazrunfiterror = vtxz->GetFunction("gaus")->GetParError(2);
0441         }
0442         gPad->SetLogy(1);
0443 
0444         int bin = vtxzmeansum->Fill(runlabel, vtxz->GetMean());
0445         vtxzmeansum->SetBinError(bin, vtxz->GetMeanError());
0446 
0447         bin = vtxzsigmasum->Fill(runlabel, vtxz->GetRMS());
0448         vtxzsigmasum->SetBinError(bin, vtxz->GetRMSError());
0449 
0450         vtxsigmazrunvalue = vtxz->GetRMS();
0451         vtxsigmazrunerror = vtxz->GetRMSError();
0452 
0453         std::string plotfilename;
0454         plotfilename += outtrunk;
0455         plotfilename += dirname;
0456         plotfilename += "/";
0457         plotfilename += labfull;
0458         plotfilename += "/pvtxz_";
0459         plotfilename += labfull;
0460         plotfilename += "_";
0461         plotfilename += dirname;
0462         plotfilename += "_";
0463         plotfilename += runpath;
0464         plotfilename += ".gif";
0465         gPad->Print(plotfilename.c_str());
0466         delete vtxz;
0467       }
0468       gPad->SetLogy(0);
0469 
0470       TH1F* vtxxvsorb = (TH1F*)castat.getObject("vtxxvsorbrun");
0471       TH1F* bsxvsorb = (TH1F*)cabs.getObject("bsxvsorbrun");
0472       TH1F* onlbsxvsorb = (TH1F*)cabsonl.getObject("bsxvsorbrun");
0473       TH1F* testbsxvsorb = (TH1F*)cabstest.getObject("bsxvsorbrun");
0474       if (vtxxvsorb && vtxxvsorb->GetEntries() > 0) {
0475         //  vtxxvsorb->GetYaxis()->SetRangeUser(0.0650,0.07);
0476         vtxxvsorb->Draw();
0477         if (bsxvsorb) {
0478           bsxvsorb->SetMarkerColor(kGreen);
0479           bsxvsorb->SetLineColor(kGreen);
0480           bsxvsorb->SetLineWidth(2);
0481           bsxvsorb->Draw("esame");
0482         }
0483         if (onlbsxvsorb) {
0484           onlbsxvsorb->SetMarkerColor(kRed);
0485           onlbsxvsorb->SetLineColor(kRed);
0486           onlbsxvsorb->Draw("esame");
0487         }
0488         if (testbsxvsorb) {
0489           testbsxvsorb->SetMarkerColor(kBlue);
0490           testbsxvsorb->SetLineColor(kBlue);
0491           testbsxvsorb->Draw("esame");
0492         }
0493         std::string plotfilename;
0494         plotfilename += outtrunk;
0495         plotfilename += dirname;
0496         plotfilename += "/";
0497         plotfilename += labfull;
0498         plotfilename += "/pvtxxvsorb_";
0499         plotfilename += labfull;
0500         plotfilename += "_";
0501         plotfilename += dirname;
0502         plotfilename += "_";
0503         plotfilename += runpath;
0504         plotfilename += ".gif";
0505         gPad->Print(plotfilename.c_str());
0506         delete vtxxvsorb;
0507         delete bsxvsorb;
0508         delete onlbsxvsorb;
0509         delete testbsxvsorb;
0510       }
0511       TH1F* vtxyvsorb = (TH1F*)castat.getObject("vtxyvsorbrun");
0512       TH1F* bsyvsorb = (TH1F*)cabs.getObject("bsyvsorbrun");
0513       TH1F* onlbsyvsorb = (TH1F*)cabsonl.getObject("bsyvsorbrun");
0514       TH1F* testbsyvsorb = (TH1F*)cabstest.getObject("bsyvsorbrun");
0515       if (vtxyvsorb && vtxyvsorb->GetEntries() > 0) {
0516         //  vtxyvsorb->GetYaxis()->SetRangeUser(0.0620,0.0670);
0517         vtxyvsorb->Draw();
0518         if (bsyvsorb) {
0519           bsyvsorb->SetMarkerColor(kGreen);
0520           bsyvsorb->SetLineColor(kGreen);
0521           bsyvsorb->SetLineWidth(2);
0522           bsyvsorb->Draw("esame");
0523         }
0524         if (onlbsyvsorb) {
0525           onlbsyvsorb->SetMarkerColor(kRed);
0526           onlbsyvsorb->SetLineColor(kRed);
0527           onlbsyvsorb->Draw("esame");
0528         }
0529         if (testbsyvsorb) {
0530           testbsyvsorb->SetMarkerColor(kCyan);
0531           testbsyvsorb->SetLineColor(kCyan);
0532           testbsyvsorb->Draw("esame");
0533         }
0534         std::string plotfilename;
0535         plotfilename += outtrunk;
0536         plotfilename += dirname;
0537         plotfilename += "/";
0538         plotfilename += labfull;
0539         plotfilename += "/pvtxyvsorb_";
0540         plotfilename += labfull;
0541         plotfilename += "_";
0542         plotfilename += dirname;
0543         plotfilename += "_";
0544         plotfilename += runpath;
0545         plotfilename += ".gif";
0546         gPad->Print(plotfilename.c_str());
0547         delete vtxyvsorb;
0548         delete bsyvsorb;
0549         delete onlbsyvsorb;
0550         delete testbsyvsorb;
0551       }
0552       TH1F* vtxzvsorb = (TH1F*)castat.getObject("vtxzvsorbrun");
0553       TH1F* bszvsorb = (TH1F*)cabs.getObject("bszvsorbrun");
0554       TH1F* onlbszvsorb = (TH1F*)cabsonl.getObject("bszvsorbrun");
0555       TH1F* testbszvsorb = (TH1F*)cabstest.getObject("bszvsorbrun");
0556       if (vtxzvsorb && vtxzvsorb->GetEntries() > 0) {
0557         vtxzvsorb->Draw();
0558         if (bszvsorb) {
0559           bszvsorb->SetMarkerColor(kGreen);
0560           bszvsorb->SetLineColor(kGreen);
0561           bszvsorb->SetLineWidth(2);
0562           bszvsorb->Draw("esame");
0563         }
0564         if (onlbszvsorb) {
0565           onlbszvsorb->SetMarkerColor(kRed);
0566           onlbszvsorb->SetLineColor(kRed);
0567           onlbszvsorb->Draw("esame");
0568         }
0569         if (testbszvsorb) {
0570           testbszvsorb->SetMarkerColor(kCyan);
0571           testbszvsorb->SetLineColor(kCyan);
0572           testbszvsorb->Draw("esame");
0573         }
0574         std::string plotfilename;
0575         plotfilename += outtrunk;
0576         plotfilename += dirname;
0577         plotfilename += "/";
0578         plotfilename += labfull;
0579         plotfilename += "/pvtxzvsorb_";
0580         plotfilename += labfull;
0581         plotfilename += "_";
0582         plotfilename += dirname;
0583         plotfilename += "_";
0584         plotfilename += runpath;
0585         plotfilename += ".gif";
0586         gPad->Print(plotfilename.c_str());
0587         delete vtxzvsorb;
0588         delete bszvsorb;
0589         delete onlbszvsorb;
0590         delete testbszvsorb;
0591       }
0592 
0593       TProfile* bssigmazvsorb = (TProfile*)cabs.getObject("bssigmazvsorbrun");
0594       TProfile* onlbssigmazvsorb = (TProfile*)cabsonl.getObject("bssigmazvsorbrun");
0595       TProfile* testbssigmazvsorb = (TProfile*)cabstest.getObject("bssigmazvsorbrun");
0596       TGraphErrors gr;
0597       TGraphErrors grfit;
0598       if (bssigmazvsorb || onlbssigmazvsorb || testbssigmazvsorb) {
0599         if (bssigmazvsorb) {
0600           bssigmazvsorb->SetMarkerColor(kGreen);
0601           bssigmazvsorb->SetLineColor(kGreen);
0602           bssigmazvsorb->SetLineWidth(2);
0603           bssigmazvsorb->Draw();
0604           bssigmazvsorb->GetYaxis()->SetRangeUser(0., 7.);
0605           if (vtxsigmazrunvalue >= 0.) {
0606             // look for last filled bin
0607             int lastbin = bssigmazvsorb->GetNbinsX() + 1;
0608             int firstbin = 1;
0609             for (int ibin = bssigmazvsorb->GetNbinsX() + 1; ibin > 0; --ibin) {
0610               if (bssigmazvsorb->GetBinEntries(ibin) != 0) {
0611                 lastbin = ibin;
0612                 break;
0613               }
0614             }
0615             for (int ibin = 1; ibin <= bssigmazvsorb->GetNbinsX() + 1; ++ibin) {
0616               if (bssigmazvsorb->GetBinEntries(ibin) != 0) {
0617                 firstbin = ibin;
0618                 break;
0619               }
0620             }
0621             gr.SetMarkerStyle(20);
0622             gr.SetPoint(1,
0623                         (bssigmazvsorb->GetBinCenter(firstbin) + bssigmazvsorb->GetBinCenter(lastbin)) / 2.,
0624                         vtxsigmazrunvalue);
0625             gr.SetPointError(1,
0626                              (bssigmazvsorb->GetBinCenter(lastbin) - bssigmazvsorb->GetBinCenter(firstbin)) / 2.,
0627                              vtxsigmazrunerror);
0628             gr.Draw("p");
0629             grfit.SetMarkerStyle(24);
0630             grfit.SetMarkerColor(kBlue);
0631             grfit.SetLineColor(kBlue);
0632             grfit.SetPoint(1,
0633                            (bssigmazvsorb->GetBinCenter(firstbin) + bssigmazvsorb->GetBinCenter(lastbin)) / 2.,
0634                            vtxsigmazrunfitvalue);
0635             grfit.SetPointError(1,
0636                                 (bssigmazvsorb->GetBinCenter(lastbin) - bssigmazvsorb->GetBinCenter(firstbin)) / 2.,
0637                                 vtxsigmazrunfiterror);
0638             grfit.Draw("p");
0639           }
0640         }
0641         if (onlbssigmazvsorb) {
0642           onlbssigmazvsorb->SetMarkerColor(kRed);
0643           onlbssigmazvsorb->SetLineColor(kRed);
0644           onlbssigmazvsorb->Draw("esame");
0645         }
0646         if (testbssigmazvsorb) {
0647           testbssigmazvsorb->SetMarkerColor(kCyan);
0648           testbssigmazvsorb->SetLineColor(kCyan);
0649           testbssigmazvsorb->Draw("esame");
0650         }
0651         std::string plotfilename;
0652         plotfilename += outtrunk;
0653         plotfilename += dirname;
0654         plotfilename += "/";
0655         plotfilename += labfull;
0656         plotfilename += "/pvtxsigmazvsorb_";
0657         plotfilename += labfull;
0658         plotfilename += "_";
0659         plotfilename += dirname;
0660         plotfilename += "_";
0661         plotfilename += runpath;
0662         plotfilename += ".gif";
0663         gPad->Print(plotfilename.c_str());
0664         delete bssigmazvsorb;
0665         delete onlbssigmazvsorb;
0666         delete testbssigmazvsorb;
0667       }
0668 
0669       TProfile* nvtxvsorb = (TProfile*)castat.getObject("nvtxvsorbrun");
0670       if (nvtxvsorb) {
0671         nvtxvsorb->Draw();
0672         std::string plotfilename;
0673         plotfilename += outtrunk;
0674         plotfilename += dirname;
0675         plotfilename += "/";
0676         plotfilename += labfull;
0677         plotfilename += "/nvtxvsorb_";
0678         plotfilename += labfull;
0679         plotfilename += "_";
0680         plotfilename += dirname;
0681         plotfilename += "_";
0682         plotfilename += runpath;
0683         plotfilename += ".gif";
0684         gPad->Print(plotfilename.c_str());
0685         delete nvtxvsorb;
0686       }
0687 
0688       TProfile* nvtxvsbx = (TProfile*)castat.getObject("nvtxvsbxrun");
0689       if (nvtxvsbx) {
0690         nvtxvsbx->SetLineColor(kRed);
0691         nvtxvsbx->SetMarkerColor(kRed);
0692         nvtxvsbx->SetMarkerStyle(20);
0693         nvtxvsbx->SetMarkerSize(.5);
0694         nvtxvsbx->Draw();
0695         std::string plotfilename;
0696         plotfilename += outtrunk;
0697         plotfilename += dirname;
0698         plotfilename += "/";
0699         plotfilename += labfull;
0700         plotfilename += "/nvtxvsbx_";
0701         plotfilename += labfull;
0702         plotfilename += "_";
0703         plotfilename += dirname;
0704         plotfilename += "_";
0705         plotfilename += runpath;
0706         plotfilename += ".gif";
0707         gPad->Print(plotfilename.c_str());
0708         delete nvtxvsbx;
0709       }
0710 
0711       TH2D* nvtxvsbxvsorb = (TH2D*)castat.getObject("nvtxvsbxvsorbrun");
0712       if (nvtxvsbxvsorb) {
0713         nvtxvsbxvsorb->Draw("colz");
0714         std::string plotfilename;
0715         plotfilename += outtrunk;
0716         plotfilename += dirname;
0717         plotfilename += "/";
0718         plotfilename += labfull;
0719         plotfilename += "/nvtxvsbxvsorb_";
0720         plotfilename += labfull;
0721         plotfilename += "_";
0722         plotfilename += dirname;
0723         plotfilename += "_";
0724         plotfilename += runpath;
0725         plotfilename += ".gif";
0726         gPad->Print(plotfilename.c_str());
0727 
0728         // slicing
0729         std::string cname;
0730         cname = "slice_run_";
0731         cname += runpath;
0732         new TCanvas(cname.c_str(), cname.c_str());
0733         bool first = true;
0734         int mcount = 20;
0735         int ccount = 1;
0736         for (unsigned int bx = 0; bx < 3564; ++bx) {
0737           char hname[300];
0738           sprintf(hname, "bx_%d", bx);
0739           TH1D* slice = nvtxvsbxvsorb->ProjectionY(hname, bx + 1, bx + 1);
0740           //      std::cout << "slice " << bx << " with pointer " << slice << std::endl;
0741           if (slice) {
0742             if (slice->GetEntries()) {
0743               std::cout << "slice " << bx << " ready " << std::endl;
0744               slice->SetMarkerStyle(mcount);
0745               slice->SetMarkerColor(ccount);
0746               slice->SetLineColor(ccount);
0747               slice->SetMarkerSize(.4);
0748               if (first) {
0749                 slice->SetMaximum(4.);
0750                 slice->Draw("e");
0751               } else {
0752                 slice->Draw("same");
0753               }
0754               first = false;
0755               ++mcount;
0756               if (mcount == 28) {
0757                 mcount = 20;
0758                 ++ccount;
0759               }
0760             }
0761           }
0762         }
0763         //  std::string plotfilename;
0764         plotfilename = outtrunk;
0765         plotfilename += dirname;
0766         plotfilename += "/";
0767         plotfilename += labfull;
0768         plotfilename += "/nvtxvsorbsliced_";
0769         plotfilename += labfull;
0770         plotfilename += "_";
0771         plotfilename += dirname;
0772         plotfilename += "_";
0773         plotfilename += runpath;
0774         plotfilename += ".gif";
0775         gPad->Print(plotfilename.c_str());
0776 
0777         delete nvtxvsbxvsorb;
0778       }
0779     }
0780   }
0781   if (!runs.empty()) {
0782     std::string plotfilename;
0783 
0784     plotfilename = outtrunk;
0785     plotfilename += dirname;
0786     plotfilename += "/";
0787     plotfilename += labfull;
0788     plotfilename += "/vtxxsum_";
0789     plotfilename += labfull;
0790     plotfilename += "_";
0791     plotfilename += dirname;
0792     plotfilename += ".gif";
0793 
0794     TCanvas* cwidevtxx = new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
0795 
0796     vtxxmeansum->GetYaxis()->SetRangeUser(.05, .15);
0797     vtxxmeansum->GetYaxis()->SetTitle("x (cm)");
0798     vtxxmeansum->Draw();
0799     //    vtxxmeansum->SetLineColor(kRed);    vtxxmeansum->SetMarkerColor(kRed);
0800     //    vtxxmeansum->Draw("esame");
0801     gPad->Print(plotfilename.c_str());
0802     delete cwidevtxx;
0803 
0804     plotfilename = outtrunk;
0805     plotfilename += dirname;
0806     plotfilename += "/";
0807     plotfilename += labfull;
0808     plotfilename += "/vtxysum_";
0809     plotfilename += labfull;
0810     plotfilename += "_";
0811     plotfilename += dirname;
0812     plotfilename += ".gif";
0813 
0814     TCanvas* cwidevtxy = new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
0815 
0816     vtxymeansum->GetYaxis()->SetRangeUser(-0.05, .05);
0817     vtxymeansum->GetYaxis()->SetTitle("y (cm)");
0818     vtxymeansum->Draw();
0819     //    vtxymeansum->SetLineColor(kRed);    vtxymeansum->SetMarkerColor(kRed);
0820     //    vtxymeansum->Draw("esame");
0821     gPad->Print(plotfilename.c_str());
0822     delete cwidevtxy;
0823 
0824     plotfilename = outtrunk;
0825     plotfilename += dirname;
0826     plotfilename += "/";
0827     plotfilename += labfull;
0828     plotfilename += "/vtxzsum_";
0829     plotfilename += labfull;
0830     plotfilename += "_";
0831     plotfilename += dirname;
0832     plotfilename += ".gif";
0833 
0834     TCanvas* cwidevtxz = new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
0835 
0836     vtxzmeansum->GetYaxis()->SetRangeUser(-2., 2.);
0837     vtxzmeansum->GetYaxis()->SetTitle("z (cm)");
0838     vtxzmeansum->Draw();
0839     //    vtxzmeansum->SetLineColor(kRed);    vtxzmeansum->SetMarkerColor(kRed);
0840     //    vtxzmeansum->Draw("esame");
0841     gPad->Print(plotfilename.c_str());
0842     delete cwidevtxz;
0843 
0844     plotfilename = outtrunk;
0845     plotfilename += dirname;
0846     plotfilename += "/";
0847     plotfilename += labfull;
0848     plotfilename += "/vtxsigmazsum_";
0849     plotfilename += labfull;
0850     plotfilename += "_";
0851     plotfilename += dirname;
0852     plotfilename += ".gif";
0853 
0854     TCanvas* cwidevtxsigmaz = new TCanvas(plotfilename.c_str(), plotfilename.c_str(), 1500, 500);
0855 
0856     vtxzsigmasum->GetYaxis()->SetRangeUser(0., 15.);
0857     vtxzsigmasum->GetYaxis()->SetTitle("z (cm)");
0858     vtxzsigmasum->Draw();
0859     //    vtxzsigmasum->SetLineColor(kRed);    vtxzsigmasum->SetMarkerColor(kRed);
0860     //    vtxzsigmasum->Draw("esame");
0861     gPad->Print(plotfilename.c_str());
0862     delete cwidevtxsigmaz;
0863   }
0864   delete vtxxmeansum;
0865   delete vtxymeansum;
0866   delete vtxzmeansum;
0867   delete vtxzsigmasum;
0868 }