Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:08:57

0001 #include "TrackPlots.h"
0002 #include <vector>
0003 #include <string>
0004 #include <map>
0005 #include "TPad.h"
0006 #include "TFile.h"
0007 #include "TH2F.h"
0008 #include "TH1F.h"
0009 #include "TF1.h"
0010 #include "TProfile2D.h"
0011 #include "DPGAnalysis/SiStripTools/interface/CommonAnalyzer.h"
0012 #include "TCanvas.h"
0013 #include "TSystem.h"
0014 #include "TStyle.h"
0015 
0016 void TrackPlots(const char* fullname,
0017                 const char* module,
0018                 const char* label,
0019                 const char* postfix,
0020                 const char* shortname,
0021                 const char* outtrunk) {
0022   char modfull[300];
0023   sprintf(modfull, "%s%s", module, postfix);
0024   char labfull[300];
0025   sprintf(labfull, "%s%s", label, postfix);
0026 
0027   //  char fullname[300];
0028   //  sprintf(fullname,"rootfiles/Tracking_PFG_%s.root",filename);
0029 
0030   TFile ff(fullname);
0031 
0032   // Colliding events
0033 
0034   CommonAnalyzer castat(&ff, "", modfull);
0035 
0036   TH1F* ntrk = (TH1F*)castat.getObject("ntrk");
0037   if (ntrk) {
0038     ntrk->Draw();
0039     std::string plotfilename;
0040     plotfilename += outtrunk;
0041     plotfilename += shortname;
0042     plotfilename += "/ntrk_";
0043     plotfilename += labfull;
0044     plotfilename += "_";
0045     plotfilename += shortname;
0046     plotfilename += ".gif";
0047     gPad->Print(plotfilename.c_str());
0048     delete ntrk;
0049   }
0050   TH1F* pt = (TH1F*)castat.getObject("pt");
0051   if (pt) {
0052     pt->Draw();
0053     std::string plotfilename;
0054     plotfilename += outtrunk;
0055     plotfilename += shortname;
0056     plotfilename += "/pt_";
0057     plotfilename += labfull;
0058     plotfilename += "_";
0059     plotfilename += shortname;
0060     plotfilename += ".gif";
0061     gPad->SetLogy(1);
0062     gPad->Print(plotfilename.c_str());
0063     gPad->SetLogy(0);
0064     delete pt;
0065   }
0066   gStyle->SetOptStat(11);
0067   TProfile2D* ptphieta = (TProfile2D*)castat.getObject("ptphivseta");
0068   if (ptphieta) {
0069     ptphieta->Draw("colz");
0070     std::string plotfilename;
0071     plotfilename += outtrunk;
0072     plotfilename += shortname;
0073     plotfilename += "/ptphieta_";
0074     plotfilename += labfull;
0075     plotfilename += "_";
0076     plotfilename += shortname;
0077     plotfilename += ".gif";
0078     gPad->Print(plotfilename.c_str());
0079     delete ptphieta;
0080   }
0081   gStyle->SetOptStat(1111);
0082   TH1F* phi = (TH1F*)castat.getObject("phi");
0083   if (phi) {
0084     phi->Draw();
0085     std::string plotfilename;
0086     plotfilename += outtrunk;
0087     plotfilename += shortname;
0088     plotfilename += "/phi_";
0089     plotfilename += labfull;
0090     plotfilename += "_";
0091     plotfilename += shortname;
0092     plotfilename += ".gif";
0093     gPad->Print(plotfilename.c_str());
0094     delete phi;
0095   }
0096   TH1F* eta = (TH1F*)castat.getObject("eta");
0097   if (eta) {
0098     eta->Draw();
0099     std::string plotfilename;
0100     plotfilename += outtrunk;
0101     plotfilename += shortname;
0102     plotfilename += "/eta_";
0103     plotfilename += labfull;
0104     plotfilename += "_";
0105     plotfilename += shortname;
0106     plotfilename += ".gif";
0107     gPad->Print(plotfilename.c_str());
0108     delete eta;
0109   }
0110   gStyle->SetOptStat(11);
0111   TH2F* phieta = (TH2F*)castat.getObject("phivseta");
0112   if (phieta) {
0113     phieta->Draw("colz");
0114     std::string plotfilename;
0115     plotfilename += outtrunk;
0116     plotfilename += shortname;
0117     plotfilename += "/phieta_";
0118     plotfilename += labfull;
0119     plotfilename += "_";
0120     plotfilename += shortname;
0121     plotfilename += ".gif";
0122     gPad->Print(plotfilename.c_str());
0123     delete phieta;
0124     gStyle->SetOptStat(1111);
0125   }
0126   TH1F* nrhits = (TH1F*)castat.getObject("nrhits");
0127   if (nrhits) {
0128     nrhits->Draw();
0129     std::string plotfilename;
0130     plotfilename += outtrunk;
0131     plotfilename += shortname;
0132     plotfilename += "/nrhits_";
0133     plotfilename += labfull;
0134     plotfilename += "_";
0135     plotfilename += shortname;
0136     plotfilename += ".gif";
0137     gPad->Print(plotfilename.c_str());
0138     delete nrhits;
0139   }
0140   gStyle->SetOptStat(11);
0141   TProfile2D* nhitphieta = (TProfile2D*)castat.getObject("nhitphivseta");
0142   if (nhitphieta) {
0143     nhitphieta->Draw("colz");
0144     std::string plotfilename;
0145     plotfilename += outtrunk;
0146     plotfilename += shortname;
0147     plotfilename += "/nhitphieta_";
0148     plotfilename += labfull;
0149     plotfilename += "_";
0150     plotfilename += shortname;
0151     plotfilename += ".gif";
0152     gPad->Print(plotfilename.c_str());
0153     delete nhitphieta;
0154   }
0155   gStyle->SetOptStat(1111);
0156   TH1F* nlosthits = (TH1F*)castat.getObject("nlosthits");
0157   if (nlosthits) {
0158     nlosthits->Draw();
0159     std::string plotfilename;
0160     plotfilename += outtrunk;
0161     plotfilename += shortname;
0162     plotfilename += "/nlosthits_";
0163     plotfilename += labfull;
0164     plotfilename += "_";
0165     plotfilename += shortname;
0166     plotfilename += ".gif";
0167     gPad->Print(plotfilename.c_str());
0168     delete nlosthits;
0169   }
0170   TH1F* npixelhits = (TH1F*)castat.getObject("npixelhits");
0171   if (npixelhits) {
0172     npixelhits->Draw();
0173     std::string plotfilename;
0174     plotfilename += outtrunk;
0175     plotfilename += shortname;
0176     plotfilename += "/npixelhits_";
0177     plotfilename += labfull;
0178     plotfilename += "_";
0179     plotfilename += shortname;
0180     plotfilename += ".gif";
0181     gPad->Print(plotfilename.c_str());
0182     delete npixelhits;
0183   }
0184   TH1F* nstriphits = (TH1F*)castat.getObject("nstriphits");
0185   if (nstriphits) {
0186     nstriphits->Draw();
0187     std::string plotfilename;
0188     plotfilename += outtrunk;
0189     plotfilename += shortname;
0190     plotfilename += "/nstriphits_";
0191     plotfilename += labfull;
0192     plotfilename += "_";
0193     plotfilename += shortname;
0194     plotfilename += ".gif";
0195     gPad->Print(plotfilename.c_str());
0196     delete nstriphits;
0197   }
0198   TH1F* nrlayers = (TH1F*)castat.getObject("nlayers");
0199   if (nrlayers) {
0200     nrlayers->Draw();
0201     std::string plotfilename;
0202     plotfilename += outtrunk;
0203     plotfilename += shortname;
0204     plotfilename += "/nrlayers_";
0205     plotfilename += labfull;
0206     plotfilename += "_";
0207     plotfilename += shortname;
0208     plotfilename += ".gif";
0209     gPad->Print(plotfilename.c_str());
0210     delete nrlayers;
0211   }
0212   gStyle->SetOptStat(11);
0213   TProfile2D* nlayerphieta = (TProfile2D*)castat.getObject("nlayerphivseta");
0214   if (nlayerphieta) {
0215     nlayerphieta->Draw("colz");
0216     std::string plotfilename;
0217     plotfilename += outtrunk;
0218     plotfilename += shortname;
0219     plotfilename += "/nlayerphieta_";
0220     plotfilename += labfull;
0221     plotfilename += "_";
0222     plotfilename += shortname;
0223     plotfilename += ".gif";
0224     gPad->Print(plotfilename.c_str());
0225     delete nlayerphieta;
0226   }
0227   gStyle->SetOptStat(1111);
0228   TH1F* nlostlayers = (TH1F*)castat.getObject("nlostlayers");
0229   if (nlostlayers) {
0230     nlostlayers->Draw();
0231     std::string plotfilename;
0232     plotfilename += outtrunk;
0233     plotfilename += shortname;
0234     plotfilename += "/nlostlayers_";
0235     plotfilename += labfull;
0236     plotfilename += "_";
0237     plotfilename += shortname;
0238     plotfilename += ".gif";
0239     gPad->Print(plotfilename.c_str());
0240     delete nlostlayers;
0241   }
0242   TH1F* npixellayers = (TH1F*)castat.getObject("npixellayers");
0243   if (npixellayers) {
0244     npixellayers->Draw();
0245     std::string plotfilename;
0246     plotfilename += outtrunk;
0247     plotfilename += shortname;
0248     plotfilename += "/npixellayers_";
0249     plotfilename += labfull;
0250     plotfilename += "_";
0251     plotfilename += shortname;
0252     plotfilename += ".gif";
0253     gPad->Print(plotfilename.c_str());
0254     delete npixellayers;
0255   }
0256   TH1F* nstriplayers = (TH1F*)castat.getObject("nstriplayers");
0257   if (nstriplayers) {
0258     nstriplayers->Draw();
0259     std::string plotfilename;
0260     plotfilename += outtrunk;
0261     plotfilename += shortname;
0262     plotfilename += "/nstriplayers_";
0263     plotfilename += labfull;
0264     plotfilename += "_";
0265     plotfilename += shortname;
0266     plotfilename += ".gif";
0267     gPad->Print(plotfilename.c_str());
0268     delete nstriplayers;
0269   }
0270   TH1F* hhpfrac = (TH1F*)castat.getObject("hhpfrac");
0271   if (hhpfrac) {
0272     hhpfrac->Draw();
0273     std::string plotfilename;
0274     plotfilename += outtrunk;
0275     plotfilename += shortname;
0276     plotfilename += "/hhpfrac_";
0277     plotfilename += labfull;
0278     plotfilename += "_";
0279     plotfilename += shortname;
0280     plotfilename += ".gif";
0281     gPad->SetLogy(1);
0282     gPad->Print(plotfilename.c_str());
0283     gPad->SetLogy(0);
0284     delete hhpfrac;
0285   }
0286   TH1F* halgo = (TH1F*)castat.getObject("algo");
0287   if (halgo) {
0288     halgo->Draw();
0289     std::string plotfilename;
0290     plotfilename += outtrunk;
0291     plotfilename += shortname;
0292     plotfilename += "/halgo_";
0293     plotfilename += labfull;
0294     plotfilename += "_";
0295     plotfilename += shortname;
0296     plotfilename += ".gif";
0297     gPad->Print(plotfilename.c_str());
0298     delete halgo;
0299   }
0300   gStyle->SetOptStat(111);
0301   gStyle->SetOptFit(111);
0302   TProfile* hntrkvslumi = (TProfile*)castat.getObject("ntrkvslumi");
0303   if (hntrkvslumi && hntrkvslumi->GetEntries() > 0) {
0304     //  hntrkvslumi->Draw();
0305     hntrkvslumi->Fit("pol2", "", "", 0.5, 3.0);
0306     if (hntrkvslumi->GetFunction("pol2")) {
0307       hntrkvslumi->GetFunction("pol2")->SetLineColor(kBlack);
0308       hntrkvslumi->GetFunction("pol2")->SetLineWidth(1);
0309     }
0310     std::string plotfilename;
0311     plotfilename += outtrunk;
0312     plotfilename += shortname;
0313     plotfilename += "/hntrkvslumi_";
0314     plotfilename += labfull;
0315     plotfilename += "_";
0316     plotfilename += shortname;
0317     plotfilename += ".gif";
0318     gPad->Print(plotfilename.c_str());
0319   }
0320   gStyle->SetOptStat(1111);
0321 
0322   TH2D* hntrkvslumi2D = (TH2D*)castat.getObject("ntrkvslumi2D");
0323   if (hntrkvslumi2D && hntrkvslumi2D->GetEntries() > 0) {
0324     hntrkvslumi2D->Draw("colz");
0325     if (hntrkvslumi) {
0326       hntrkvslumi->SetMarkerStyle(20);
0327       hntrkvslumi->SetMarkerSize(.3);
0328       hntrkvslumi->Draw("same");
0329     }
0330     std::string plotfilename;
0331     plotfilename += outtrunk;
0332     plotfilename += shortname;
0333     plotfilename += "/hntrkvslumi2D_";
0334     plotfilename += labfull;
0335     plotfilename += "_";
0336     plotfilename += shortname;
0337     plotfilename += ".gif";
0338     gPad->SetLogz(1);
0339     gPad->Print(plotfilename.c_str());
0340     gPad->SetLogz(0);
0341     delete hntrkvslumi2D;
0342   }
0343   delete hntrkvslumi;
0344 }