Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 void TracksCompareChain()
0002 {
0003 
0004  gROOT ->Reset();
0005  // gROOT ->SetBatch();
0006  gROOT->SetStyle("Plain");
0007 
0008  char*  rfilename = "validationPlots.root";//new release is in red
0009  char*  sfilename = "../validationPlots.root";//reference is in blue
0010 
0011  delete gROOT->GetListOfFiles()->FindObject(rfilename);
0012  delete gROOT->GetListOfFiles()->FindObject(sfilename); 
0013 
0014  TText* te = new TText();
0015  TFile * rfile = new TFile(rfilename);
0016  TDirectory * rdir=gDirectory; 
0017  TFile * sfile = new TFile(sfilename);
0018  TDirectory * sdir=gDirectory; 
0019 
0020  if(rfile->cd("DQMData/Run 1/RecoTrackV"))rfile->cd("DQMData/Run 1/RecoTrackV/Run summary/Track");
0021  else rfile->cd("DQMData/RecoTrackV/Track");
0022  rdir=gDirectory;
0023 
0024  if(sfile->cd("DQMData/Run 1/RecoTrackV"))sfile->cd("DQMData/Run 1/RecoTrackV/Run summary/Track");
0025  else sfile->cd("DQMData/RecoTrackV/Track");
0026  sdir=gDirectory; 
0027 
0028 
0029  TString collnamerCTF = "general";//cutsReco
0030  TString collnamesCTF = "general";//cutsReco
0031  // TString collnamesCTF = "cutsReco";
0032  TString collnamerRS = "cutsRS";
0033  TString collnamesRS = "cutsRS";
0034  
0035  TString assocnamesCTF1 = "trackingParticleRecoAsssociation";//AssociatorByHits
0036  //TString assocnamesCTF1 = "trackingParticleRecoAsssociation";//AssociatorByHits
0037  // TString assocnamerCTF1 = "AssociatorByHits";
0038   TString assocnamerCTF1 = "AssociatorByHits";
0039  TString assocnamerRS1 = "AssociatorByHits";
0040  TString assocnamesRS1 = "AssociatorByHits";
0041  TString assocnamerCTF2 = "AssociatorByChi2";
0042  TString assocnamesCTF2 = "AssociatorByChi2";
0043  TString assocnamerRS2 = "AssociatorByChi2";
0044  TString assocnamesRS2 = "AssociatorByChi2";
0045 
0046  // create an iterator to loop through all objects(keys) in the  file
0047  //get release name
0048  TIter nextkey(rfile -> GetListOfKeys());
0049  TObjString *newRel;
0050  while (key = (TKey*)nextkey()) {
0051    obj = key -> ReadObj();  //use ReadObj, not Read
0052    
0053    if (obj->InheritsFrom("TObjString") ) {  //instead of obj->IsA
0054      newRel = (TObjString *) obj;
0055      newRel->Print();
0056    }
0057  }
0058  
0059  TIter nextkey(sfile -> GetListOfKeys());
0060  TObjString *refRel;
0061  while (key = (TKey*)nextkey()) {
0062    obj = key -> ReadObj();  //use ReadObj, not Read
0063    
0064    if (obj->InheritsFrom("TObjString") ) {  //instead of obj->IsA
0065      refRel = (TObjString *) obj;
0066      refRel->Print();
0067    }
0068  }
0069  TLatex thistext;
0070  thistext.SetTextSize(0.02);
0071  char relinfo[200];
0072  sprintf(relinfo,"RED histograms = %s *** BLUE Histograms = %s", newRel->GetName(), refRel->GetName());
0073  
0074  gROOT->ProcessLine(".x HistoCompare_Tracks.C");
0075  HistoCompare_Tracks * myPV = new HistoCompare_Tracks();
0076 
0077  TCanvas *canvas;
0078 
0079  TH1F *sh1,*rh1;
0080  TH1F *sc1,*rc1;
0081  TH1F *sh2,*rh2;
0082  TH1F *sc2,*rc2;
0083  TH1F *sh3,*rh3;
0084  TH1F *sc3,*rc3;
0085 
0086  bool hit=1;
0087  bool chi2=0;
0088  bool ctf=1;
0089  bool rs=0;
0090 
0091  //////////////////////////////////////
0092  /////////// CTF //////////////////////
0093  //////////////////////////////////////
0094  if (ctf){
0095 //    string rdirName,sdirName;
0096 //    if(rdir->cd("cutsReco_AssociatorByHits"))rdirName="cutsReco";
0097 //    else if(rdir->cd("general_AssociatorByHits"))rdirName="general";
0098 //    else rdirName="cutsCKF";
0099 //    if(sdir->cd("cutsReco_AssociatorByHits"))sdirName="cutsReco";
0100 //    else if(sdir->cd("general_AssociatorByHits"))sdirName="general";
0101 //    else sdirName="cutsCKF";
0102 //    //efficiency&fakerate
0103 //    cout<<rdir->GetPath()<<endl;
0104 //    cout<<sdir->GetPath()<<endl;
0105 //    cout<<sdir->ls()<<endl;
0106    cout<<collnamerCTF+"_"+assocnamerCTF1+"/effic"<<endl;
0107    rdir->ls();
0108    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/effic",rh1);
0109    sdir->ls();
0110    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/effic",sh1);
0111    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/effic",rc1);
0112    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/effic",sc1);
0113    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/fakerate",rh2);
0114    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/fakerate",sh2);
0115    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/fakerate",rc2);
0116    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/fakerate",sc2);
0117 
0118    canvas = new TCanvas("Tracks1","Tracks: efficiency & fakerate",1000,1000);
0119    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0120    title->Draw();
0121    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0122    graphPad->Draw();
0123    graphPad->cd();
0124 
0125    if (hit) rh1->GetYaxis()->SetRangeUser(0.7,1.025);
0126    //   if (hit) sh1->GetYaxis()->SetRangeUser(0.7,1.025);
0127    if (chi2)rc1->GetYaxis()->SetRangeUser(0.7,1.025);
0128    if (chi2)sc1->GetYaxis()->SetRangeUser(0.7,1.025);
0129 
0130    if (hit&&chi2){
0131      char * option = "UU";
0132      double  startingY = -1;
0133      double  startingX = .1;
0134      bool fit = false;
0135 
0136      graphPad->Divide(2,2);
0137      graphPad->cd(1);
0138      rh1->SetLineColor(2);
0139      sh1->SetLineColor(4);
0140      sh1->SetLineStyle(1);
0141      setStats(rh1,sh1, startingY, startingX, fit);
0142      rh1->Draw();
0143      sh1->Draw("sames");
0144      myPV->PVCompute(rh1, sh1, te, option );
0145      
0146      graphPad->cd(2);
0147      rc1->SetLineColor(2);
0148      sc1->SetLineColor(4);
0149      sc1->SetLineStyle(2);
0150      setStats(rc1,sc1, startingY, startingX, fit);
0151      rc1->Draw();
0152      sc1->Draw("sames");
0153      myPV->PVCompute(rc1, sc1, te, option );
0154      
0155      graphPad->cd(3);
0156      rh2->SetLineColor(2);
0157      sh2->SetLineColor(4);
0158      sh2->SetLineStyle(2);
0159      setStats(rh2,sh2, startingY, startingX, fit);
0160      rh2->Draw();
0161      sh2->Draw("sames");
0162      myPV->PVCompute(rh2, sh2, te, option );
0163      
0164      graphPad->cd(4);
0165      rc2->SetLineColor(2);
0166      sc2->SetLineColor(4);
0167      sc2->SetLineStyle(2);
0168      setStats(rc2,sc2, startingY, startingX, fit);
0169      rc2->Draw();
0170      sc2->Draw("sames");
0171      myPV->PVCompute(rc2, sc2, te, option );
0172      
0173      //     canvas->cd(0);
0174      //    thistext.DrawLatex(0.1, 0.01, mytext);
0175      
0176    }else if (hit){  
0177      char * option = "UU";
0178      double  startingY = -1;
0179      double  startingX = .1;
0180      bool fit = false;
0181 
0182      graphPad->Divide(1,2);
0183      
0184      graphPad->cd(1);
0185      rh1->SetLineColor(2);
0186      sh1->SetLineColor(4);
0187      sh1->SetLineStyle(2);
0188      setStats(rh1,sh1, startingY, startingX, fit);
0189      rh1->Draw();
0190      sh1->Draw("sames");
0191      myPV->PVCompute(rh1, sh1, te, option );
0192      
0193      graphPad->cd(2);
0194      rh2->SetLineColor(2);
0195      sh2->SetLineColor(4);
0196      sh2->SetLineStyle(2);
0197      setStats(rh2,sh2, startingY, startingX, fit);
0198      rh2->Draw();
0199      sh2->Draw("sames");
0200      myPV->PVCompute(rh2, sh2, te, option );  
0201   
0202    }else if (chi2){ 
0203      char * option = "UU";
0204      double  startingY = -1;
0205      double  startingX = .1;
0206      bool fit = false;
0207 
0208      graphPad->Divide(1,2);
0209      
0210      graphPad->cd(1);
0211      rh1->SetLineColor(2);
0212      sh1->SetLineColor(4);
0213      sh1->SetLineStyle(2);
0214      setStats(rh1,sh1, startingY, startingX, fit);
0215      rh1->Draw();
0216      sh1->Draw("sames");
0217      myPV->PVCompute(rh1, sh1, te, option );
0218      
0219      graphPad->cd(2);
0220      rh2->SetLineColor(2);
0221      sh2->SetLineColor(4);
0222      sh2->SetLineStyle(2);
0223      setStats(rh2,sh2, startingY, startingX, fit);
0224      rh2->Draw();
0225      sh2->Draw("sames");
0226      myPV->PVCompute(rh2, sh2, te, option );  
0227      
0228    }
0229 
0230    canvas->Print("ctf_effic_fake.eps");
0231    canvas->Print("ctf_effic_fake.gif");
0232 
0233    //chi2&chi2 probability
0234    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/chi2",rh1);
0235    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/chi2",sh1);
0236    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/chi2",rc1);
0237    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/chi2",sc1);
0238    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/chi2_prob",rh2);
0239    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/chi2_prob",sh2);
0240    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/chi2_prob",rc2);
0241    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/chi2_prob",sc2);
0242 
0243    canvas = new TCanvas("Tracks2","Tracks: chi2 & chi2 probability",1000,1000);
0244    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0245    title->Draw();
0246    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0247    graphPad->Draw();
0248    graphPad->cd();
0249 
0250    if (hit){
0251      NormalizeHistograms(rh1,sh1);
0252      NormalizeHistograms(rh2,sh2);
0253      fixRangeY(rh1,sh1);
0254      fixRangeY(rh2,sh2);
0255    }
0256    if (chi2){
0257      NormalizeHistograms(rc1,sc1);
0258      NormalizeHistograms(rc2,sc2);
0259      fixRangeY(rc1,sc1);
0260      fixRangeY(rc2,sc2);
0261    }
0262    
0263    if (hit&&chi2){
0264      char * option = "UUNORM";
0265      double  startingY = 0.4;
0266      double  startingX = 0.7;
0267      bool fit = false;
0268 
0269      graphPad->Divide(2,2);
0270 
0271      graphPad->cd(1);
0272      rh1->SetLineColor(2);
0273      sh1->SetLineColor(4);
0274      sh1->SetLineStyle(1);
0275      setStats(rh1,sh1, startingY, startingX, fit);
0276      rh1->Draw();
0277      sh1->Draw("sames");
0278      myPV->PVCompute(rh1, sh1, te, option );
0279      
0280      graphPad->cd(2);
0281      rc1->SetLineColor(2);
0282      sc1->SetLineColor(4);
0283      sc1->SetLineStyle(2);
0284      setStats(rc1,sc1, startingY, startingX, fit);
0285      rc1->Draw();
0286      sc1->Draw("sames");
0287      myPV->PVCompute(rc1, sc1, te, option );
0288      
0289      graphPad->cd(3);
0290      rh2->SetLineColor(2);
0291      sh2->SetLineColor(4);
0292      sh2->SetLineStyle(2);
0293      setStats(rh2,sh2, startingY, startingX, fit);
0294      rh2->Draw();
0295      sh2->Draw("sames");
0296      myPV->PVCompute(rh2, sh2, te, option );
0297      
0298      graphPad->cd(4);
0299      rc2->SetLineColor(2);
0300      sc2->SetLineColor(4);
0301      sc2->SetLineStyle(2);
0302      setStats(rc2,sc2, startingY, startingX, fit);
0303      rc2->Draw();
0304      sc2->Draw("sames");
0305      myPV->PVCompute(rc2, sc2, te, option );
0306      
0307    }else if (hit){  
0308      char * option = "UUNORM";
0309      double  startingY = 0.4;
0310      double  startingX = 0.7;
0311      bool fit = false;
0312 
0313      graphPad->Divide(1,2);
0314      
0315      graphPad->cd(1);
0316      rh1->SetLineColor(2);
0317      sh1->SetLineColor(4);
0318      sh1->SetLineStyle(2);
0319      setStats(rh1,sh1, startingY, startingX, fit);
0320      rh1->Draw();
0321      sh1->Draw("sames");
0322      myPV->PVCompute(rh1, sh1, te, option );
0323      
0324      graphPad->cd(2);
0325      rh2->SetLineColor(2);
0326      sh2->SetLineColor(4);
0327      sh2->SetLineStyle(2);
0328      setStats(rh2,sh2, startingY, startingX, fit);
0329      rh2->Draw();
0330      sh2->Draw("sames");
0331      myPV->PVCompute(rh2, sh2, te, option );  
0332   
0333    }else if (chi2){ 
0334      char * option = "UUNORM";
0335      double  startingY = 0.4;
0336      double  startingX = 0.7;
0337      bool fit = false;
0338 
0339      graphPad->Divide(1,2);
0340      
0341      graphPad->cd(1);
0342      rh1->SetLineColor(2);
0343      sh1->SetLineColor(4);
0344      sh1->SetLineStyle(2);
0345      setStats(rh1,sh1, startingY, startingX, fit);
0346      rh1->Draw();
0347      sh1->Draw("sames");
0348      myPV->PVCompute(rh1, sh1, te, option );
0349      
0350      graphPad->cd(2);
0351      rh2->SetLineColor(2);
0352      sh2->SetLineColor(4);
0353      sh2->SetLineStyle(2);
0354      setStats(rh2,sh2, startingY, startingX, fit);
0355      rh2->Draw();
0356      sh2->Draw("sames");
0357      myPV->PVCompute(rh2, sh2, te, option );  
0358      
0359    }
0360 
0361    canvas->Print("ctf_chi2_chi2prob.eps");
0362    canvas->Print("ctf_chi2_chi2prob.gif");
0363 
0364    //meanchi2 and #hits vs eta
0365    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/nhits_vs_eta_pfx",(TProfile *)rh1);
0366    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/hits_eta",sh1);
0367    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/nhits_vs_eta_pfx",(TProfile *)rc1);
0368    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/hits_eta",sc1);
0369    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/chi2_vs_eta_pfx",(TProfile *)rh2);
0370    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/chi2mean",sh2);
0371    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/chi2_vs_eta_pfx",(TProfile *)rc2);
0372    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/chi2mean",sc2);
0373    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/nlosthits_vs_eta_pfx",(TProfile *)rh3);
0374    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/losthits_eta",sh3);
0375    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/nlosthits_vs_eta_pfx",(TProfile *)rc3);
0376    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/losthits_eta",sc3);
0377 
0378    canvas = new TCanvas("Tracks3","Tracks: chi2 and #hits vs eta",1000,1000);
0379    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0380    title->Draw();
0381    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0382    graphPad->Draw();
0383    graphPad->cd();
0384 
0385    //fixRangeY(rh1,sh1);
0386    //fixRangeY(rc1,sc1);
0387    if (hit) fixRangeY(rh2,sh2);
0388    if (chi2)fixRangeY(rc2,sc2);
0389 
0390 
0391    if (hit&&chi2){
0392      char * option = "UU";
0393      double  startingY = -1;
0394      double  startingX = .1;
0395      bool fit = false;
0396 
0397      graphPad->Divide(2,3);
0398 
0399      graphPad->cd(1);
0400      rh1->SetLineColor(2);
0401      sh1->SetLineColor(4);
0402      sh1->SetLineStyle(1);
0403      setStats(rh1,sh1, startingY, startingX, fit);
0404      rh1->Draw();
0405      sh1->Draw("sames");
0406      myPV->PVCompute(rh1, sh1, te, option );
0407      
0408      graphPad->cd(2);
0409      rc1->SetLineColor(2);
0410      sc1->SetLineColor(4);
0411      sc1->SetLineStyle(2);
0412      setStats(rc1,sc1, startingY, startingX, fit);
0413      rc1->Draw();
0414      sc1->Draw("sames");
0415      myPV->PVCompute(rc1, sc1, te, option );
0416      
0417      graphPad->cd(3);
0418      rh2->SetLineColor(2);
0419      sh2->SetLineColor(4);
0420      sh2->SetLineStyle(2);
0421      setStats(rh2,sh2, startingY, startingX, fit);
0422      rh2->Draw();
0423      sh2->Draw("sames");
0424      myPV->PVCompute(rh2, sh2, te, option );
0425      
0426      graphPad->cd(4);
0427      rc2->SetLineColor(2);
0428      sc2->SetLineColor(4);
0429      sc2->SetLineStyle(2);
0430      setStats(rc2,sc2, startingY, startingX, fit);
0431      rc2->Draw();
0432      sc2->Draw("sames");
0433      myPV->PVCompute(rc2, sc2, te, option );
0434 
0435      graphPad->cd(5);
0436      rh3->SetLineColor(2);
0437      sh3->SetLineColor(4);
0438      sh3->SetLineStyle(2);
0439      setStats(rh3,sh3, startingY, startingX, fit);
0440      rh3->Draw();
0441      sh3->Draw("sames");
0442      myPV->PVCompute(rh3, sh3, te, option );
0443   
0444      graphPad->cd(6);
0445      rc3->SetLineColor(2);
0446      sc3->SetLineColor(4);
0447      sc3->SetLineStyle(2);
0448      setStats(rc3,sc3, startingY, startingX, fit);
0449      rc3->Draw();
0450      sc3->Draw("sames");
0451      myPV->PVCompute(rc3, sc3, te, option );
0452      
0453    }else if (hit){  
0454      char * option = "UU";
0455      double  startingY = -1;
0456      double  startingX = .1;
0457      bool fit = false;
0458 
0459      graphPad->Divide(1,3);
0460      
0461      graphPad->cd(1);
0462      rh1->SetLineColor(2);
0463      sh1->SetLineColor(4);
0464      sh1->SetLineStyle(2);
0465      setStats(rh1,sh1, startingY, startingX, fit);
0466      rh1->Draw();
0467      sh1->Draw("sames");
0468      myPV->PVCompute(rh1, sh1, te, option );
0469      
0470      graphPad->cd(2);
0471      rh2->SetLineColor(2);
0472      sh2->SetLineColor(4);
0473      sh2->SetLineStyle(2);
0474      setStats(rh2,sh2, startingY, startingX, fit);
0475      rh2->Draw();
0476      sh2->Draw("sames");
0477      myPV->PVCompute(rh2, sh2, te, option );  
0478 
0479      graphPad->cd(3);
0480      rh3->SetLineColor(2);
0481      sh3->SetLineColor(4);
0482      sh3->SetLineStyle(2);
0483      setStats(rh3,sh3, startingY, startingX, fit);
0484      rh3->Draw();
0485      sh3->Draw("sames");
0486      myPV->PVCompute(rh3, sh3, te, option );
0487      
0488    }else if (chi2){ 
0489      char * option = "UU";
0490      double  startingY = -1;
0491      double  startingX = .1;
0492      bool fit = false;
0493 
0494      graphPad->Divide(1,3);
0495      
0496      graphPad->cd(1);
0497      rh1->SetLineColor(2);
0498      sh1->SetLineColor(4);
0499      sh1->SetLineStyle(2);
0500      setStats(rh1,sh1, startingY, startingX, fit);
0501      rh1->Draw();
0502      sh1->Draw("sames");
0503      myPV->PVCompute(rh1, sh1, te, option );
0504      
0505      graphPad->cd(2);
0506      rh2->SetLineColor(2);
0507      sh2->SetLineColor(4);
0508      sh2->SetLineStyle(2);
0509      setStats(rh2,sh2, startingY, startingX, fit);
0510      rh2->Draw();
0511      sh2->Draw("sames");
0512      myPV->PVCompute(rh2, sh2, te, option );  
0513      
0514      graphPad->cd(3);
0515      rh3->SetLineColor(2);
0516      sh3->SetLineColor(4);
0517      sh3->SetLineStyle(2);
0518      setStats(rh3,sh3, startingY, startingX, fit);
0519      rh3->Draw();
0520      sh3->Draw("sames");
0521      myPV->PVCompute(rh3, sh3, te, option );
0522      
0523    }
0524    
0525    canvas->Print("ctf_hitseta_chi2mean.eps");
0526    canvas->Print("ctf_hitseta_chi2mean.gif");
0527 
0528    //pull Pt, Qoverp, Phi
0529    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullPt",rh1);
0530    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullPt",sh1);
0531    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullPt",rc1);
0532    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullPt",sc1);
0533    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullQoverp",rh2);
0534    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullQoverp",sh2);
0535    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullQoverp",rc2);
0536    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullQoverp",sc2);
0537    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullPhi",rh3);
0538    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullPhi",sh3);
0539    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullPhi",rc3);
0540    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullPhi",sc3);
0541 
0542    canvas = new TCanvas("Tracks4","Tracks: pull of Pt, Qoverp and Phi",1000,1000);
0543    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0544    title->Draw();
0545    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0546    graphPad->Draw();
0547    graphPad->cd();
0548 
0549    if (hit){
0550      NormalizeHistograms(rh1,sh1);
0551      NormalizeHistograms(rh2,sh2);
0552      NormalizeHistograms(rh3,sh3);
0553    }
0554    if (chi2){
0555      NormalizeHistograms(rc1,sc1);
0556      NormalizeHistograms(rc2,sc2);
0557      NormalizeHistograms(rc3,sc3);
0558    }
0559 
0560    if (hit&&chi2){   
0561      char * option = "UUNORM";
0562      double  startingY = 0.4;
0563      double  startingX = 0.1;
0564      bool fit = true;
0565 
0566      graphPad->Divide(2,3);
0567      
0568      graphPad->cd(1);
0569      rh1->SetLineColor(2);
0570      sh1->SetLineColor(4);
0571      sh1->SetLineStyle(2);
0572      setStats(rh1,sh1, startingY, startingX, fit);
0573      rh1->Draw();
0574      sh1->Draw("sames");
0575      myPV->PVCompute(rh1, sh1, te, option );
0576      
0577      graphPad->cd(2);
0578      rc1->SetLineColor(2);
0579      sc1->SetLineColor(4);
0580      sc1->SetLineStyle(2);
0581      setStats(rc1,sc1, startingY, startingX, fit);
0582      rc1->Draw();
0583      sc1->Draw("sames");
0584      myPV->PVCompute(rc1, sc1, te, option );
0585      
0586      graphPad->cd(3);
0587      rh2->SetLineColor(2);
0588      sh2->SetLineColor(4);
0589      sh2->SetLineStyle(2);
0590      setStats(rh2,sh2, startingY, startingX, fit);
0591      rh2->Draw();
0592      sh2->Draw("sames");
0593      myPV->PVCompute(rh2, sh2, te, option );
0594      
0595      graphPad->cd(4);
0596      rc2->SetLineColor(2);
0597      sc2->SetLineColor(4);
0598      sc2->SetLineStyle(2);
0599      setStats(rc2,sc2, startingY, startingX, fit);
0600      rc2->Draw();
0601      sc2->Draw("sames");
0602      myPV->PVCompute(rc2, sc2, te, option );
0603      
0604      graphPad->cd(5);
0605      rh3->SetLineColor(2);
0606      sh3->SetLineColor(4);
0607      sh3->SetLineStyle(2);
0608      setStats(rh3,sh3, startingY, startingX, fit);
0609      rh3->Draw();
0610      sh3->Draw("sames");
0611      myPV->PVCompute(rh3, sh3, te, option );
0612      
0613      graphPad->cd(6);
0614      rc3->SetLineColor(2);
0615      sc3->SetLineColor(4);
0616      sc3->SetLineStyle(2);
0617      setStats(rc3,sc3, startingY, startingX, fit);
0618      rc3->Draw();
0619      sc3->Draw("sames");
0620      myPV->PVCompute(rc3, sc3, te, option );
0621    }else if (hit){ 
0622      char * option = "UUNORM";
0623      double  startingY = 0.4;
0624      double  startingX = 0.1;
0625      bool fit = true;
0626 
0627      graphPad->Divide(1,3);
0628      
0629      graphPad->cd(1);
0630      rh1->SetLineColor(2);
0631      sh1->SetLineColor(4);
0632      sh1->SetLineStyle(2);
0633      setStats(rh1,sh1, startingY, startingX, fit);
0634      rh1->Draw();
0635      sh1->Draw("sames");
0636      myPV->PVCompute(rh1, sh1, te, option );
0637      
0638      graphPad->cd(2);
0639      rh2->SetLineColor(2);
0640      sh2->SetLineColor(4);
0641      sh2->SetLineStyle(2);
0642      setStats(rh2,sh2, startingY, startingX, fit);
0643      rh2->Draw();
0644      sh2->Draw("sames");
0645      myPV->PVCompute(rh2, sh2, te, option );
0646      
0647      graphPad->cd(3);
0648      rh3->SetLineColor(2);
0649      sh3->SetLineColor(4);
0650      sh3->SetLineStyle(2);
0651      setStats(rh3,sh3, startingY, startingX, fit);
0652      rh3->Draw();
0653      sh3->Draw("sames");
0654      myPV->PVCompute(rh3, sh3, te, option );
0655    }else if (chi2){
0656      char * option = "UUNORM";
0657      double  startingY = 0.4;
0658      double  startingX = 0.1;
0659      bool fit = true;
0660      
0661      graphPad->Divide(1,3);
0662      
0663      graphPad->cd(1);
0664      rh1->SetLineColor(2);
0665      sh1->SetLineColor(4);
0666      sh1->SetLineStyle(2);
0667      setStats(rh1,sh1, startingY, startingX, fit);
0668      rh1->Draw();
0669      sh1->Draw("sames");
0670      myPV->PVCompute(rh1, sh1, te, option );
0671      
0672      graphPad->cd(2);
0673      rh2->SetLineColor(2);
0674      sh2->SetLineColor(4);
0675      sh2->SetLineStyle(2);
0676      setStats(rh2,sh2, startingY, startingX, fit);
0677      rh2->Draw();
0678      sh2->Draw("sames");
0679      myPV->PVCompute(rh2, sh2, te, option );
0680      
0681      graphPad->cd(3);
0682      rh3->SetLineColor(2);
0683      sh3->SetLineColor(4);
0684      sh3->SetLineStyle(2);
0685      setStats(rh3,sh3, startingY, startingX, fit);
0686      rh3->Draw();
0687      sh3->Draw("sames");
0688      myPV->PVCompute(rh3, sh3, te, option );
0689    }
0690    
0691    canvas->Print("ctf_pullPt_Qoverp_Phi.eps");
0692    canvas->Print("ctf_pullPt_Qoverp_Phi.gif");
0693 
0694    //pull Dxy, Dz, Theta
0695    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullDxy",rh1);
0696    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullDxy",sh1);
0697    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullDxy",rc1);
0698    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullDxy",sc1);
0699    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullDz",rh2);
0700    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullDz",sh2);
0701    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullDz",rc2);
0702    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullDz",sc2);
0703    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/pullTheta",rh3);
0704    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/pullTheta",sh3);
0705    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/pullTheta",rc3);
0706    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/pullTheta",sc3);
0707 
0708    canvas = new TCanvas("Tracks5","Tracks: pull of Dxy, Dz, Theta",1000,1000);
0709    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0710    title->Draw();
0711    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0712    graphPad->Draw();
0713    graphPad->cd();
0714 
0715    if (hit){
0716      NormalizeHistograms(rh1,sh1);
0717      NormalizeHistograms(rh2,sh2);
0718      NormalizeHistograms(rh3,sh3);
0719    }
0720    if (chi2){
0721      NormalizeHistograms(rc1,sc1);
0722      NormalizeHistograms(rc2,sc2);
0723      NormalizeHistograms(rc3,sc3);
0724    }
0725 
0726    if (hit&&chi2){   
0727      char * option = "UUNORM";
0728      double  startingY = 0.4;
0729      double  startingX = 0.1;
0730      bool fit = true;
0731 
0732      graphPad->Divide(2,3);
0733      
0734      graphPad->cd(1);
0735      rh1->SetLineColor(2);
0736      sh1->SetLineColor(4);
0737      sh1->SetLineStyle(2);
0738      setStats(rh1,sh1, startingY, startingX, fit);
0739      rh1->Draw();
0740      sh1->Draw("sames");
0741      myPV->PVCompute(rh1, sh1, te, option );
0742      
0743      graphPad->cd(2);
0744      rc1->SetLineColor(2);
0745      sc1->SetLineColor(4);
0746      sc1->SetLineStyle(2);
0747      setStats(rc1,sc1, startingY, startingX, fit);
0748      rc1->Draw();
0749      sc1->Draw("sames");
0750      myPV->PVCompute(rc1, sc1, te, option );
0751      
0752      graphPad->cd(3);
0753      rh2->SetLineColor(2);
0754      sh2->SetLineColor(4);
0755      sh2->SetLineStyle(2);
0756      setStats(rh2,sh2, startingY, startingX, fit);
0757      rh2->Draw();
0758      sh2->Draw("sames");
0759      myPV->PVCompute(rh2, sh2, te, option );
0760      
0761      graphPad->cd(4);
0762      rc2->SetLineColor(2);
0763      sc2->SetLineColor(4);
0764      sc2->SetLineStyle(2);
0765      setStats(rc2,sc2, startingY, startingX, fit);
0766      rc2->Draw();
0767      sc2->Draw("sames");
0768      myPV->PVCompute(rc2, sc2, te, option );
0769      
0770      graphPad->cd(5);
0771      rh3->SetLineColor(2);
0772      sh3->SetLineColor(4);
0773      sh3->SetLineStyle(2);
0774      setStats(rh3,sh3, startingY, startingX, fit);
0775      rh3->Draw();
0776      sh3->Draw("sames");
0777      myPV->PVCompute(rh3, sh3, te, option );
0778      
0779      graphPad->cd(6);
0780      rc3->SetLineColor(2);
0781      sc3->SetLineColor(4);
0782      sc3->SetLineStyle(2);
0783      setStats(rc3,sc3, startingY, startingX, fit);
0784      rc3->Draw();
0785      sc3->Draw("sames");
0786      myPV->PVCompute(rc3, sc3, te, option );
0787    }else if (hit){ 
0788      char * option = "UUNORM";
0789      double  startingY = 0.4;
0790      double  startingX = 0.1;
0791      bool fit = true;
0792 
0793      graphPad->Divide(1,3);
0794      
0795      graphPad->cd(1);
0796      rh1->SetLineColor(2);
0797      sh1->SetLineColor(4);
0798      sh1->SetLineStyle(2);
0799      setStats(rh1,sh1, startingY, startingX, fit);
0800      rh1->Draw();
0801      sh1->Draw("sames");
0802      myPV->PVCompute(rh1, sh1, te, option );
0803      
0804      graphPad->cd(2);
0805      rh2->SetLineColor(2);
0806      sh2->SetLineColor(4);
0807      sh2->SetLineStyle(2);
0808      setStats(rh2,sh2, startingY, startingX, fit);
0809      rh2->Draw();
0810      sh2->Draw("sames");
0811      myPV->PVCompute(rh2, sh2, te, option );
0812      
0813      graphPad->cd(3);
0814      rh3->SetLineColor(2);
0815      sh3->SetLineColor(4);
0816      sh3->SetLineStyle(2);
0817      setStats(rh3,sh3, startingY, startingX, fit);
0818      rh3->Draw();
0819      sh3->Draw("sames");
0820      myPV->PVCompute(rh3, sh3, te, option );
0821    }else if (chi2){
0822      char * option = "UUNORM";
0823      double  startingY = 0.4;
0824      double  startingX = 0.1;
0825      bool fit = true;
0826      
0827      graphPad->Divide(1,3);
0828      
0829      graphPad->cd(1);
0830      rh1->SetLineColor(2);
0831      sh1->SetLineColor(4);
0832      sh1->SetLineStyle(2);
0833      setStats(rh1,sh1, startingY, startingX, fit);
0834      rh1->Draw();
0835      sh1->Draw("sames");
0836      myPV->PVCompute(rh1, sh1, te, option );
0837      
0838      graphPad->cd(2);
0839      rh2->SetLineColor(2);
0840      sh2->SetLineColor(4);
0841      sh2->SetLineStyle(2);
0842      setStats(rh2,sh2, startingY, startingX, fit);
0843      rh2->Draw();
0844      sh2->Draw("sames");
0845      myPV->PVCompute(rh2, sh2, te, option );
0846      
0847      graphPad->cd(3);
0848      rh3->SetLineColor(2);
0849      sh3->SetLineColor(4);
0850      sh3->SetLineStyle(2);
0851      setStats(rh3,sh3, startingY, startingX, fit);
0852      rh3->Draw();
0853      sh3->Draw("sames");
0854      myPV->PVCompute(rh3, sh3, te, option );
0855    }
0856    
0857    canvas->Print("ctf_pullDxy_Dz_Theta.eps");
0858    canvas->Print("ctf_pullDxy_Dz_Theta.gif");
0859 
0860    //resolution Pt, Phi
0861    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/ptres_vs_eta_Sigma",rh1);
0862    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/sigmapt",sh1);
0863    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/ptres_vs_eta_Sigma",rc1);
0864    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/sigmapt",sc1);
0865    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/phires_vs_eta_Sigma",rh2);
0866    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/sigmaphi",sh2);
0867    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/phires_vs_eta_Sigma",rc2);
0868    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/sigmaphi",sc2);
0869 
0870    canvas = new TCanvas("Tracks6","Tracks: Pt and Phi resolution",1000,1000);
0871    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0872    title->Draw();
0873    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0874    graphPad->Draw();
0875    graphPad->cd();
0876 
0877    if (hit&&chi2){
0878      char * option = "UU";
0879      double  startingY = -1;
0880      double  startingX = .1;
0881      bool fit = false;
0882 
0883      graphPad->Divide(2,2);
0884 
0885      graphPad->cd(1);
0886      rh1->SetLineColor(2);
0887      sh1->SetLineColor(4);
0888      sh1->SetLineStyle(1);
0889      setStats(rh1,sh1, startingY, startingX, fit);
0890      rh1->Draw();
0891      sh1->Draw("sames");
0892      myPV->PVCompute(rh1, sh1, te, option );
0893      
0894      graphPad->cd(2);
0895      rc1->SetLineColor(2);
0896      sc1->SetLineColor(4);
0897      sc1->SetLineStyle(2);
0898      setStats(rc1,sc1, startingY, startingX, fit);
0899      rc1->Draw();
0900      sc1->Draw("sames");
0901      myPV->PVCompute(rc1, sc1, te, option );
0902      
0903      graphPad->cd(3);
0904      rh2->SetLineColor(2);
0905      sh2->SetLineColor(4);
0906      sh2->SetLineStyle(2);
0907      setStats(rh2,sh2, startingY, startingX, fit);
0908      rh2->Draw();
0909      sh2->Draw("sames");
0910      myPV->PVCompute(rh2, sh2, te, option );
0911      
0912      graphPad->cd(4);
0913      rc2->SetLineColor(2);
0914      sc2->SetLineColor(4);
0915      sc2->SetLineStyle(2);
0916      setStats(rc2,sc2, startingY, startingX, fit);
0917      rc2->Draw();
0918      sc2->Draw("sames");
0919      myPV->PVCompute(rc2, sc2, te, option );
0920      
0921    }else if (hit){  
0922      char * option = "UU";
0923      double  startingY = -1;
0924      double  startingX = .1;
0925      bool fit = false;
0926 
0927      graphPad->Divide(1,2);
0928      
0929      graphPad->cd(1);
0930      rh1->SetLineColor(2);
0931      sh1->SetLineColor(4);
0932      sh1->SetLineStyle(2);
0933      setStats(rh1,sh1, startingY, startingX, fit);
0934      rh1->Draw();
0935      sh1->Draw("sames");
0936      myPV->PVCompute(rh1, sh1, te, option );
0937      
0938      graphPad->cd(2);
0939      rh2->SetLineColor(2);
0940      sh2->SetLineColor(4);
0941      sh2->SetLineStyle(2);
0942      setStats(rh2,sh2, startingY, startingX, fit);
0943      rh2->Draw();
0944      sh2->Draw("sames");
0945      myPV->PVCompute(rh2, sh2, te, option );  
0946   
0947    }else if (chi2){ 
0948      char * option = "UU";
0949      double  startingY = -1;
0950      double  startingX = .1;
0951      bool fit = false;
0952 
0953      graphPad->Divide(1,2);
0954      
0955      graphPad->cd(1);
0956      rh1->SetLineColor(2);
0957      sh1->SetLineColor(4);
0958      sh1->SetLineStyle(2);
0959      setStats(rh1,sh1, startingY, startingX, fit);
0960      rh1->Draw();
0961      sh1->Draw("sames");
0962      myPV->PVCompute(rh1, sh1, te, option );
0963      
0964      graphPad->cd(2);
0965      rh2->SetLineColor(2);
0966      sh2->SetLineColor(4);
0967      sh2->SetLineStyle(2);
0968      setStats(rh2,sh2, startingY, startingX, fit);
0969      rh2->Draw();
0970      sh2->Draw("sames");
0971      myPV->PVCompute(rh2, sh2, te, option );  
0972      
0973    }
0974 
0975    canvas->Print("ctf_resolPt_Phi.eps");
0976    canvas->Print("ctf_resolPt_Phi.gif");
0977 
0978    //resolution Dxy, Dz, Theta
0979    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/dxyres_vs_eta_Sigma",rh1);
0980    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/sigmadxy",sh1);
0981    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/dxyres_vs_eta_Sigma",rc1);
0982    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/sigmadxy",sc1);
0983    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/dzres_vs_eta_Sigma",rh2);
0984    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/sigmadz",sh2);
0985    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/dzres_vs_eta_Sigma",rc2);
0986    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/sigmadz",sc2);
0987    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF1+"/cotThetares_vs_eta_Sigma",rh3);
0988    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF1+"/sigmacotTheta",sh3);
0989    rdir->GetObject(collnamerCTF+"_"+assocnamerCTF2+"/cotThetares_vs_eta_Sigma",rc3);
0990    sdir->GetObject(collnamesCTF+"_"+assocnamesCTF2+"/sigmacotTheta",sc3);
0991 
0992    canvas = new TCanvas("Tracks7","Tracks: Dxy, Dz, Theta resolution",1000,1000);
0993    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
0994    title->Draw();
0995    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
0996    graphPad->Draw();
0997    graphPad->cd();
0998 
0999    if (hit&&chi2){   
1000      char * option = "UU";
1001      double  startingY = -1;
1002      double  startingX = 0.1;
1003      bool fit = true;
1004 
1005      graphPad->Divide(2,3);
1006      
1007      graphPad->cd(1);
1008      rh1->SetLineColor(2);
1009      sh1->SetLineColor(4);
1010      sh1->SetLineStyle(2);
1011      setStats(rh1,sh1, startingY, startingX, fit);
1012      rh1->Draw();
1013      sh1->Draw("sames");
1014      myPV->PVCompute(rh1, sh1, te, option );
1015      
1016      graphPad->cd(2);
1017      rc1->SetLineColor(2);
1018      sc1->SetLineColor(4);
1019      sc1->SetLineStyle(2);
1020      setStats(rc1,sc1, startingY, startingX, fit);
1021      rc1->Draw();
1022      sc1->Draw("sames");
1023      myPV->PVCompute(rc1, sc1, te, option );
1024      
1025      graphPad->cd(3);
1026      rh2->SetLineColor(2);
1027      sh2->SetLineColor(4);
1028      sh2->SetLineStyle(2);
1029      setStats(rh2,sh2, startingY, startingX, fit);
1030      rh2->Draw();
1031      sh2->Draw("sames");
1032      myPV->PVCompute(rh2, sh2, te, option );
1033      
1034      graphPad->cd(4);
1035      rc2->SetLineColor(2);
1036      sc2->SetLineColor(4);
1037      sc2->SetLineStyle(2);
1038      setStats(rc2,sc2, startingY, startingX, fit);
1039      rc2->Draw();
1040      sc2->Draw("sames");
1041      myPV->PVCompute(rc2, sc2, te, option );
1042      
1043      graphPad->cd(5);
1044      rh3->SetLineColor(2);
1045      sh3->SetLineColor(4);
1046      sh3->SetLineStyle(2);
1047      setStats(rh3,sh3, startingY, startingX, fit);
1048      rh3->Draw();
1049      sh3->Draw("sames");
1050      myPV->PVCompute(rh3, sh3, te, option );
1051      
1052      graphPad->cd(6);
1053      rc3->SetLineColor(2);
1054      sc3->SetLineColor(4);
1055      sc3->SetLineStyle(2);
1056      setStats(rc3,sc3, startingY, startingX, fit);
1057      rc3->Draw();
1058      sc3->Draw("sames");
1059      myPV->PVCompute(rc3, sc3, te, option );
1060    }else if (hit){ 
1061      char * option = "UU";
1062      double  startingY = -1;
1063      double  startingX = 0.1;
1064      bool fit = true;
1065 
1066      graphPad->Divide(1,3);
1067      
1068      graphPad->cd(1);
1069      rh1->SetLineColor(2);
1070      sh1->SetLineColor(4);
1071      sh1->SetLineStyle(2);
1072      setStats(rh1,sh1, startingY, startingX, fit);
1073      rh1->Draw();
1074      sh1->Draw("sames");
1075      myPV->PVCompute(rh1, sh1, te, option );
1076      
1077      graphPad->cd(2);
1078      rh2->SetLineColor(2);
1079      sh2->SetLineColor(4);
1080      sh2->SetLineStyle(2);
1081      setStats(rh2,sh2, startingY, startingX, fit);
1082      rh2->Draw();
1083      sh2->Draw("sames");
1084      myPV->PVCompute(rh2, sh2, te, option );
1085      
1086      graphPad->cd(3);
1087      rh3->SetLineColor(2);
1088      sh3->SetLineColor(4);
1089      sh3->SetLineStyle(2);
1090      setStats(rh3,sh3, startingY, startingX, fit);
1091      rh3->Draw();
1092      sh3->Draw("sames");
1093      myPV->PVCompute(rh3, sh3, te, option );
1094    }else if (chi2){
1095      char * option = "UU";
1096      double  startingY = -1;
1097      double  startingX = 0.1;
1098      bool fit = true;
1099      
1100      graphPad->Divide(1,3);
1101      
1102      graphPad->cd(1);
1103      rh1->SetLineColor(2);
1104      sh1->SetLineColor(4);
1105      sh1->SetLineStyle(2);
1106      setStats(rh1,sh1, startingY, startingX, fit);
1107      rh1->Draw();
1108      sh1->Draw("sames");
1109      myPV->PVCompute(rh1, sh1, te, option );
1110      
1111      graphPad->cd(2);
1112      rh2->SetLineColor(2);
1113      sh2->SetLineColor(4);
1114      sh2->SetLineStyle(2);
1115      setStats(rh2,sh2, startingY, startingX, fit);
1116      rh2->Draw();
1117      sh2->Draw("sames");
1118      myPV->PVCompute(rh2, sh2, te, option );
1119      
1120      graphPad->cd(3);
1121      rh3->SetLineColor(2);
1122      sh3->SetLineColor(4);
1123      sh3->SetLineStyle(2);
1124      setStats(rh3,sh3, startingY, startingX, fit);
1125      rh3->Draw();
1126      sh3->Draw("sames");
1127      myPV->PVCompute(rh3, sh3, te, option );
1128    }
1129    
1130    canvas->Print("ctf_resolDxy_Dz_Theta.eps");
1131    canvas->Print("ctf_resolDxy_Dz_Theta.gif");
1132  }
1133 
1134 
1135 
1136  //////////////////////////////////////
1137  /////////// RS //////////////////////
1138  //////////////////////////////////////
1139  if (rs){
1140    //efficiency&fakerate
1141    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/effic",rh1);
1142    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/effic",sh1);
1143    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/effic",rc1);
1144    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/effic",sc1);
1145    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/fakerate",rh2);
1146    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/fakerate",sh2);
1147    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/fakerate",rc2);
1148    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/fakerate",sc2);
1149 
1150    canvas = new TCanvas("Tracks8","Tracks: efficiency & fakerate",1000,1000);
1151    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1152    title->Draw();
1153    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1154    graphPad->Draw();
1155    graphPad->cd();
1156 
1157    if (hit) rh1->GetYaxis()->SetRangeUser(0.7,1.025);
1158    if (hit) sh1->GetYaxis()->SetRangeUser(0.7,1.025);
1159    if (chi2)rc1->GetYaxis()->SetRangeUser(0.7,1.025);
1160    if (chi2)sc1->GetYaxis()->SetRangeUser(0.7,1.025);
1161 
1162    if (hit&&chi2){
1163      char * option = "UU";
1164      double  startingY = -1;
1165      double  startingX = .1;
1166      bool fit = false;
1167 
1168      graphPad->Divide(2,2);
1169 
1170      graphPad->cd(1);
1171      rh1->SetLineColor(2);
1172      sh1->SetLineColor(4);
1173      sh1->SetLineStyle(1);
1174      setStats(rh1,sh1, startingY, startingX, fit);
1175      rh1->Draw();
1176      sh1->Draw("sames");
1177      myPV->PVCompute(rh1, sh1, te, option );
1178      
1179      graphPad->cd(2);
1180      rc1->SetLineColor(2);
1181      sc1->SetLineColor(4);
1182      sc1->SetLineStyle(2);
1183      setStats(rc1,sc1, startingY, startingX, fit);
1184      rc1->Draw();
1185      sc1->Draw("sames");
1186      myPV->PVCompute(rc1, sc1, te, option );
1187      
1188      graphPad->cd(3);
1189      rh2->SetLineColor(2);
1190      sh2->SetLineColor(4);
1191      sh2->SetLineStyle(2);
1192      setStats(rh2,sh2, startingY, startingX, fit);
1193      rh2->Draw();
1194      sh2->Draw("sames");
1195      myPV->PVCompute(rh2, sh2, te, option );
1196      
1197      graphPad->cd(4);
1198      rc2->SetLineColor(2);
1199      sc2->SetLineColor(4);
1200      sc2->SetLineStyle(2);
1201      setStats(rc2,sc2, startingY, startingX, fit);
1202      rc2->Draw();
1203      sc2->Draw("sames");
1204      myPV->PVCompute(rc2, sc2, te, option );
1205      
1206    }else if (hit){  
1207      char * option = "UU";
1208      double  startingY = -1;
1209      double  startingX = .1;
1210      bool fit = false;
1211 
1212      graphPad->Divide(1,2);
1213      
1214      graphPad->cd(1);
1215      rh1->SetLineColor(2);
1216      sh1->SetLineColor(4);
1217      sh1->SetLineStyle(2);
1218      setStats(rh1,sh1, startingY, startingX, fit);
1219      rh1->Draw();
1220      sh1->Draw("sames");
1221      myPV->PVCompute(rh1, sh1, te, option );
1222      
1223      graphPad->cd(2);
1224      rh2->SetLineColor(2);
1225      sh2->SetLineColor(4);
1226      sh2->SetLineStyle(2);
1227      setStats(rh2,sh2, startingY, startingX, fit);
1228      rh2->Draw();
1229      sh2->Draw("sames");
1230      myPV->PVCompute(rh2, sh2, te, option );  
1231   
1232    }else if (chi2){ 
1233      char * option = "UU";
1234      double  startingY = -1;
1235      double  startingX = .1;
1236      bool fit = false;
1237 
1238      graphPad->Divide(1,2);
1239      
1240      graphPad->cd(1);
1241      rh1->SetLineColor(2);
1242      sh1->SetLineColor(4);
1243      sh1->SetLineStyle(2);
1244      setStats(rh1,sh1, startingY, startingX, fit);
1245      rh1->Draw();
1246      sh1->Draw("sames");
1247      myPV->PVCompute(rh1, sh1, te, option );
1248      
1249      graphPad->cd(2);
1250      rh2->SetLineColor(2);
1251      sh2->SetLineColor(4);
1252      sh2->SetLineStyle(2);
1253      setStats(rh2,sh2, startingY, startingX, fit);
1254      rh2->Draw();
1255      sh2->Draw("sames");
1256      myPV->PVCompute(rh2, sh2, te, option );  
1257      
1258    }
1259 
1260    canvas->Print("rs_effic_fake.eps");
1261    canvas->Print("rs_effic_fake.gif");
1262 
1263    //chi2&chi2 probability
1264    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/chi2",rh1);
1265    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/chi2",sh1);
1266    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/chi2",rc1);
1267    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/chi2",sc1);
1268    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/chi2_prob",rh2);
1269    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/chi2_prob",sh2);
1270    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/chi2_prob",rc2);
1271    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/chi2_prob",sc2);
1272 
1273    canvas = new TCanvas("Tracks9","Tracks: chi2 & chi2 probability",1000,1000);
1274    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1275    title->Draw();
1276    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1277    graphPad->Draw();
1278    graphPad->cd();
1279 
1280    if (hit) { 
1281      NormalizeHistograms(rh1,sh1);
1282      NormalizeHistograms(rh2,sh2);
1283      fixRangeY(rh1,sh1);
1284      fixRangeY(rh2,sh2);
1285    }
1286    if (chi2) {
1287      NormalizeHistograms(rc1,sc1);
1288      NormalizeHistograms(rc2,sc2);
1289      fixRangeY(rc1,sc1);
1290      fixRangeY(rc2,sc2);
1291    }
1292 
1293    fixRangeY(rh1,sh1);
1294    fixRangeY(rc1,sc1);
1295    fixRangeY(rh2,sh2);
1296    fixRangeY(rc2,sc2);
1297 
1298    if (hit&&chi2){
1299      char * option = "UUNORM";
1300      double  startingY = 0.4;
1301      double  startingX = 0.7;
1302      bool fit = false;
1303 
1304      graphPad->Divide(2,2);
1305 
1306      graphPad->cd(1);
1307      rh1->SetLineColor(2);
1308      sh1->SetLineColor(4);
1309      sh1->SetLineStyle(1);
1310      setStats(rh1,sh1, startingY, startingX, fit);
1311      rh1->Draw();
1312      sh1->Draw("sames");
1313      myPV->PVCompute(rh1, sh1, te, option );
1314      
1315      graphPad->cd(2);
1316      rc1->SetLineColor(2);
1317      sc1->SetLineColor(4);
1318      sc1->SetLineStyle(2);
1319      setStats(rc1,sc1, startingY, startingX, fit);
1320      rc1->Draw();
1321      sc1->Draw("sames");
1322      myPV->PVCompute(rc1, sc1, te, option );
1323      
1324      graphPad->cd(3);
1325      rh2->SetLineColor(2);
1326      sh2->SetLineColor(4);
1327      sh2->SetLineStyle(2);
1328      setStats(rh2,sh2, startingY, startingX, fit);
1329      rh2->Draw();
1330      sh2->Draw("sames");
1331      myPV->PVCompute(rh2, sh2, te, option );
1332      
1333      graphPad->cd(4);
1334      rc2->SetLineColor(2);
1335      sc2->SetLineColor(4);
1336      sc2->SetLineStyle(2);
1337      setStats(rc2,sc2, startingY, startingX, fit);
1338      rc2->Draw();
1339      sc2->Draw("sames");
1340      myPV->PVCompute(rc2, sc2, te, option );
1341      
1342    }else if (hit){  
1343      char * option = "UUNORM";
1344      double  startingY = 0.4;
1345      double  startingX = 0.7;
1346      bool fit = false;
1347 
1348      graphPad->Divide(1,2);
1349      
1350      graphPad->cd(1);
1351      rh1->SetLineColor(2);
1352      sh1->SetLineColor(4);
1353      sh1->SetLineStyle(2);
1354      setStats(rh1,sh1, startingY, startingX, fit);
1355      rh1->Draw();
1356      sh1->Draw("sames");
1357      myPV->PVCompute(rh1, sh1, te, option );
1358      
1359      graphPad->cd(2);
1360      rh2->SetLineColor(2);
1361      sh2->SetLineColor(4);
1362      sh2->SetLineStyle(2);
1363      setStats(rh2,sh2, startingY, startingX, fit);
1364      rh2->Draw();
1365      sh2->Draw("sames");
1366      myPV->PVCompute(rh2, sh2, te, option );  
1367   
1368    }else if (chi2){ 
1369      char * option = "UUNORM";
1370      double  startingY = 0.4;
1371      double  startingX = 0.7;
1372      bool fit = false;
1373 
1374      graphPad->Divide(1,2);
1375      
1376      graphPad->cd(1);
1377      rh1->SetLineColor(2);
1378      sh1->SetLineColor(4);
1379      sh1->SetLineStyle(2);
1380      setStats(rh1,sh1, startingY, startingX, fit);
1381      rh1->Draw();
1382      sh1->Draw("sames");
1383      myPV->PVCompute(rh1, sh1, te, option );
1384      
1385      graphPad->cd(2);
1386      rh2->SetLineColor(2);
1387      sh2->SetLineColor(4);
1388      sh2->SetLineStyle(2);
1389      setStats(rh2,sh2, startingY, startingX, fit);
1390      rh2->Draw();
1391      sh2->Draw("sames");
1392      myPV->PVCompute(rh2, sh2, te, option );  
1393      
1394    }
1395 
1396    canvas->Print("rs_chi2_chi2prob.eps");
1397    canvas->Print("rs_chi2_chi2prob.gif");
1398 
1399    //meanchi2 and #hits vs eta
1400    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/hits_eta",rh1);
1401    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/hits_eta",sh1);
1402    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/hits_eta",rc1);
1403    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/hits_eta",sc1);
1404    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/chi2mean",rh2);
1405    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/chi2mean",sh2);
1406    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/chi2mean",rc2);
1407    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/chi2mean",sc2);
1408    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/losthits_eta",rh3);
1409    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/losthits_eta",sh3);
1410    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/losthits_eta",rc3);
1411    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/losthits_eta",sc3);
1412 
1413    canvas = new TCanvas("Tracks10","Tracks: chi2 and #hits vs eta",1000,1000);
1414    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1415    title->Draw();
1416    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1417    graphPad->Draw();
1418    graphPad->cd();
1419 
1420    if (hit) fixRangeY(rh2,sh2);
1421    if (chi2) fixRangeY(rc2,sc2);
1422 
1423    if (hit&&chi2){
1424      char * option = "UU";
1425      double  startingY = -1;
1426      double  startingX = .1;
1427      bool fit = false;
1428      
1429      graphPad->Divide(2,3);
1430      
1431      graphPad->cd(1);
1432      rh1->SetLineColor(2);
1433      sh1->SetLineColor(4);
1434      sh1->SetLineStyle(1);
1435      setStats(rh1,sh1, startingY, startingX, fit);
1436      rh1->Draw();
1437      sh1->Draw("sames");
1438      myPV->PVCompute(rh1, sh1, te, option );
1439      
1440      graphPad->cd(2);
1441      rc1->SetLineColor(2);
1442      sc1->SetLineColor(4);
1443      sc1->SetLineStyle(2);
1444      setStats(rc1,sc1, startingY, startingX, fit);
1445      rc1->Draw();
1446      sc1->Draw("sames");
1447      myPV->PVCompute(rc1, sc1, te, option );
1448      
1449      graphPad->cd(3);
1450      rh2->SetLineColor(2);
1451      sh2->SetLineColor(4);
1452      sh2->SetLineStyle(2);
1453      setStats(rh2,sh2, startingY, startingX, fit);
1454      rh2->Draw();
1455      sh2->Draw("sames");
1456      myPV->PVCompute(rh2, sh2, te, option );
1457      
1458      graphPad->cd(4);
1459      rc2->SetLineColor(2);
1460      sc2->SetLineColor(4);
1461      sc2->SetLineStyle(2);
1462      setStats(rc2,sc2, startingY, startingX, fit);
1463      rc2->Draw();
1464      sc2->Draw("sames");
1465      myPV->PVCompute(rc2, sc2, te, option );
1466      
1467      graphPad->cd(5);
1468      rh3->SetLineColor(2);
1469      sh3->SetLineColor(4);
1470      sh3->SetLineStyle(2);
1471      setStats(rh3,sh3, startingY, startingX, fit);
1472      rh3->Draw();
1473      sh3->Draw("sames");
1474      myPV->PVCompute(rh3, sh3, te, option );
1475   
1476      graphPad->cd(6);
1477      rc3->SetLineColor(2);
1478      sc3->SetLineColor(4);
1479      sc3->SetLineStyle(2);
1480      setStats(rc3,sc3, startingY, startingX, fit);
1481      rc3->Draw();
1482      sc3->Draw("sames");
1483      myPV->PVCompute(rc3, sc3, te, option );
1484      
1485    }else if (hit){  
1486      char * option = "UU";
1487      double  startingY = -1;
1488      double  startingX = .1;
1489      bool fit = false;
1490      
1491      graphPad->Divide(1,3);
1492      
1493      graphPad->cd(1);
1494      rh1->SetLineColor(2);
1495      sh1->SetLineColor(4);
1496      sh1->SetLineStyle(2);
1497      setStats(rh1,sh1, startingY, startingX, fit);
1498      rh1->Draw();
1499      sh1->Draw("sames");
1500      myPV->PVCompute(rh1, sh1, te, option );
1501      
1502      graphPad->cd(2);
1503      rh2->SetLineColor(2);
1504      sh2->SetLineColor(4);
1505      sh2->SetLineStyle(2);
1506      setStats(rh2,sh2, startingY, startingX, fit);
1507      rh2->Draw();
1508      sh2->Draw("sames");
1509      myPV->PVCompute(rh2, sh2, te, option );  
1510 
1511      graphPad->cd(3);
1512      rh3->SetLineColor(2);
1513      sh3->SetLineColor(4);
1514      sh3->SetLineStyle(2);
1515      setStats(rh3,sh3, startingY, startingX, fit);
1516      rh3->Draw();
1517      sh3->Draw("sames");
1518      myPV->PVCompute(rh3, sh3, te, option );     
1519      
1520    }else if (chi2){ 
1521      char * option = "UU";
1522      double  startingY = -1;
1523      double  startingX = .1;
1524      bool fit = false;
1525      
1526      graphPad->Divide(1,3);
1527      
1528      graphPad->cd(1);
1529      rh1->SetLineColor(2);
1530      sh1->SetLineColor(4);
1531      sh1->SetLineStyle(2);
1532      setStats(rh1,sh1, startingY, startingX, fit);
1533      rh1->Draw();
1534      sh1->Draw("sames");
1535      myPV->PVCompute(rh1, sh1, te, option );
1536      
1537      graphPad->cd(2);
1538      rh2->SetLineColor(2);
1539      sh2->SetLineColor(4);
1540      sh2->SetLineStyle(2);
1541      setStats(rh2,sh2, startingY, startingX, fit);
1542      rh2->Draw();
1543      sh2->Draw("sames");
1544      myPV->PVCompute(rh2, sh2, te, option );  
1545 
1546      graphPad->cd(3);
1547      rh3->SetLineColor(2);
1548      sh3->SetLineColor(4);
1549      sh3->SetLineStyle(2);
1550      setStats(rh3,sh3, startingY, startingX, fit);
1551      rh3->Draw();
1552      sh3->Draw("sames");
1553      myPV->PVCompute(rh3, sh3, te, option );
1554           
1555    }
1556 
1557    canvas->Print("rs_hitseta_chi2mean.eps");
1558    canvas->Print("rs_hitseta_chi2mean.gif");
1559    
1560    //pull Pt, Qoverp, Phi
1561    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullPt",rh1);
1562    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullPt",sh1);
1563    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullPt",rc1);
1564    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullPt",sc1);
1565    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullQoverp",rh2);
1566    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullQoverp",sh2);
1567    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullQoverp",rc2);
1568    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullQoverp",sc2);
1569    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullPhi",rh3);
1570    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullPhi",sh3);
1571    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullPhi",rc3);
1572    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullPhi",sc3);
1573 
1574    canvas = new TCanvas("Tracks11","Tracks: pull of Pt, Qoverp and Phi",1000,1000);
1575    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1576    title->Draw();
1577    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1578    graphPad->Draw();
1579    graphPad->cd();
1580 
1581    if (hit) { 
1582      NormalizeHistograms(rh1,sh1);
1583      NormalizeHistograms(rh2,sh2);
1584      NormalizeHistograms(rh3,sh3);
1585    }
1586    if (chi2) { 
1587      NormalizeHistograms(rc1,sc1);
1588      NormalizeHistograms(rc2,sc2);
1589      NormalizeHistograms(rc3,sc3);
1590    }
1591 
1592    if (hit&&chi2){   
1593      char * option = "UUNORM";
1594      double  startingY = 0.4;
1595      double  startingX = 0.1;
1596      bool fit = true;
1597 
1598      graphPad->Divide(2,3);
1599      
1600      graphPad->cd(1);
1601      rh1->SetLineColor(2);
1602      sh1->SetLineColor(4);
1603      sh1->SetLineStyle(2);
1604      setStats(rh1,sh1, startingY, startingX, fit);
1605      rh1->Draw();
1606      sh1->Draw("sames");
1607      myPV->PVCompute(rh1, sh1, te, option );
1608      
1609      graphPad->cd(2);
1610      rc1->SetLineColor(2);
1611      sc1->SetLineColor(4);
1612      sc1->SetLineStyle(2);
1613      setStats(rc1,sc1, startingY, startingX, fit);
1614      rc1->Draw();
1615      sc1->Draw("sames");
1616      myPV->PVCompute(rc1, sc1, te, option );
1617      
1618      graphPad->cd(3);
1619      rh2->SetLineColor(2);
1620      sh2->SetLineColor(4);
1621      sh2->SetLineStyle(2);
1622      setStats(rh2,sh2, startingY, startingX, fit);
1623      rh2->Draw();
1624      sh2->Draw("sames");
1625      myPV->PVCompute(rh2, sh2, te, option );
1626      
1627      graphPad->cd(4);
1628      rc2->SetLineColor(2);
1629      sc2->SetLineColor(4);
1630      sc2->SetLineStyle(2);
1631      setStats(rc2,sc2, startingY, startingX, fit);
1632      rc2->Draw();
1633      sc2->Draw("sames");
1634      myPV->PVCompute(rc2, sc2, te, option );
1635      
1636      graphPad->cd(5);
1637      rh3->SetLineColor(2);
1638      sh3->SetLineColor(4);
1639      sh3->SetLineStyle(2);
1640      setStats(rh3,sh3, startingY, startingX, fit);
1641      rh3->Draw();
1642      sh3->Draw("sames");
1643      myPV->PVCompute(rh3, sh3, te, option );
1644      
1645      graphPad->cd(6);
1646      rc3->SetLineColor(2);
1647      sc3->SetLineColor(4);
1648      sc3->SetLineStyle(2);
1649      setStats(rc3,sc3, startingY, startingX, fit);
1650      rc3->Draw();
1651      sc3->Draw("sames");
1652      myPV->PVCompute(rc3, sc3, te, option );
1653    }else if (hit){ 
1654      char * option = "UUNORM";
1655      double  startingY = 0.4;
1656      double  startingX = 0.1;
1657      bool fit = true;
1658 
1659      graphPad->Divide(1,3);
1660      
1661      graphPad->cd(1);
1662      rh1->SetLineColor(2);
1663      sh1->SetLineColor(4);
1664      sh1->SetLineStyle(2);
1665      setStats(rh1,sh1, startingY, startingX, fit);
1666      rh1->Draw();
1667      sh1->Draw("sames");
1668      myPV->PVCompute(rh1, sh1, te, option );
1669      
1670      graphPad->cd(2);
1671      rh2->SetLineColor(2);
1672      sh2->SetLineColor(4);
1673      sh2->SetLineStyle(2);
1674      setStats(rh2,sh2, startingY, startingX, fit);
1675      rh2->Draw();
1676      sh2->Draw("sames");
1677      myPV->PVCompute(rh2, sh2, te, option );
1678      
1679      graphPad->cd(3);
1680      rh3->SetLineColor(2);
1681      sh3->SetLineColor(4);
1682      sh3->SetLineStyle(2);
1683      setStats(rh3,sh3, startingY, startingX, fit);
1684      rh3->Draw();
1685      sh3->Draw("sames");
1686      myPV->PVCompute(rh3, sh3, te, option );
1687    }else if (chi2){
1688      char * option = "UUNORM";
1689      double  startingY = 0.4;
1690      double  startingX = 0.1;
1691      bool fit = true;
1692      
1693      graphPad->Divide(1,3);
1694      
1695      graphPad->cd(1);
1696      rh1->SetLineColor(2);
1697      sh1->SetLineColor(4);
1698      sh1->SetLineStyle(2);
1699      setStats(rh1,sh1, startingY, startingX, fit);
1700      rh1->Draw();
1701      sh1->Draw("sames");
1702      myPV->PVCompute(rh1, sh1, te, option );
1703      
1704      graphPad->cd(2);
1705      rh2->SetLineColor(2);
1706      sh2->SetLineColor(4);
1707      sh2->SetLineStyle(2);
1708      setStats(rh2,sh2, startingY, startingX, fit);
1709      rh2->Draw();
1710      sh2->Draw("sames");
1711      myPV->PVCompute(rh2, sh2, te, option );
1712      
1713      graphPad->cd(3);
1714      rh3->SetLineColor(2);
1715      sh3->SetLineColor(4);
1716      sh3->SetLineStyle(2);
1717      setStats(rh3,sh3, startingY, startingX, fit);
1718      rh3->Draw();
1719      sh3->Draw("sames");
1720      myPV->PVCompute(rh3, sh3, te, option );
1721    }
1722    
1723    canvas->Print("rs_pullPt_Qoverp_Phi.eps");
1724    canvas->Print("rs_pullPt_Qoverp_Phi.gif");
1725 
1726    //pull Dxy, Dz, Theta
1727    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullDxy",rh1);
1728    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullDxy",sh1);
1729    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullDxy",rc1);
1730    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullDxy",sc1);
1731    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullDz",rh2);
1732    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullDz",sh2);
1733    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullDz",rc2);
1734    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullDz",sc2);
1735    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/pullTheta",rh3);
1736    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/pullTheta",sh3);
1737    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/pullTheta",rc3);
1738    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/pullTheta",sc3);
1739 
1740    canvas = new TCanvas("Tracks12","Tracks: pull of Dxy, Dz, Theta",1000,1000);
1741    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1742    title->Draw();
1743    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1744    graphPad->Draw();
1745    graphPad->cd();
1746 
1747    if (hit) { 
1748      NormalizeHistograms(rh1,sh1);
1749      NormalizeHistograms(rh2,sh2);
1750      NormalizeHistograms(rh3,sh3);
1751    }
1752    if (chi2) { 
1753      NormalizeHistograms(rc1,sc1);
1754      NormalizeHistograms(rc2,sc2);
1755      NormalizeHistograms(rc3,sc3);
1756    }
1757 
1758    if (hit&&chi2){   
1759      char * option = "UUNORM";
1760      double  startingY = 0.4;
1761      double  startingX = 0.1;
1762      bool fit = true;
1763 
1764      graphPad->Divide(2,3);
1765      
1766      graphPad->cd(1);
1767      rh1->SetLineColor(2);
1768      sh1->SetLineColor(4);
1769      sh1->SetLineStyle(2);
1770      setStats(rh1,sh1, startingY, startingX, fit);
1771      rh1->Draw();
1772      sh1->Draw("sames");
1773      myPV->PVCompute(rh1, sh1, te, option );
1774      
1775      graphPad->cd(2);
1776      rc1->SetLineColor(2);
1777      sc1->SetLineColor(4);
1778      sc1->SetLineStyle(2);
1779      setStats(rc1,sc1, startingY, startingX, fit);
1780      rc1->Draw();
1781      sc1->Draw("sames");
1782      myPV->PVCompute(rc1, sc1, te, option );
1783      
1784      graphPad->cd(3);
1785      rh2->SetLineColor(2);
1786      sh2->SetLineColor(4);
1787      sh2->SetLineStyle(2);
1788      setStats(rh2,sh2, startingY, startingX, fit);
1789      rh2->Draw();
1790      sh2->Draw("sames");
1791      myPV->PVCompute(rh2, sh2, te, option );
1792      
1793      graphPad->cd(4);
1794      rc2->SetLineColor(2);
1795      sc2->SetLineColor(4);
1796      sc2->SetLineStyle(2);
1797      setStats(rc2,sc2, startingY, startingX, fit);
1798      rc2->Draw();
1799      sc2->Draw("sames");
1800      myPV->PVCompute(rc2, sc2, te, option );
1801      
1802      graphPad->cd(5);
1803      rh3->SetLineColor(2);
1804      sh3->SetLineColor(4);
1805      sh3->SetLineStyle(2);
1806      setStats(rh3,sh3, startingY, startingX, fit);
1807      rh3->Draw();
1808      sh3->Draw("sames");
1809      myPV->PVCompute(rh3, sh3, te, option );
1810      
1811      graphPad->cd(6);
1812      rc3->SetLineColor(2);
1813      sc3->SetLineColor(4);
1814      sc3->SetLineStyle(2);
1815      setStats(rc3,sc3, startingY, startingX, fit);
1816      rc3->Draw();
1817      sc3->Draw("sames");
1818      myPV->PVCompute(rc3, sc3, te, option );
1819    }else if (hit){ 
1820      char * option = "UUNORM";
1821      double  startingY = 0.4;
1822      double  startingX = 0.1;
1823      bool fit = true;
1824 
1825      graphPad->Divide(1,3);
1826      
1827      graphPad->cd(1);
1828      rh1->SetLineColor(2);
1829      sh1->SetLineColor(4);
1830      sh1->SetLineStyle(2);
1831      setStats(rh1,sh1, startingY, startingX, fit);
1832      rh1->Draw();
1833      sh1->Draw("sames");
1834      myPV->PVCompute(rh1, sh1, te, option );
1835      
1836      graphPad->cd(2);
1837      rh2->SetLineColor(2);
1838      sh2->SetLineColor(4);
1839      sh2->SetLineStyle(2);
1840      setStats(rh2,sh2, startingY, startingX, fit);
1841      rh2->Draw();
1842      sh2->Draw("sames");
1843      myPV->PVCompute(rh2, sh2, te, option );
1844      
1845      graphPad->cd(3);
1846      rh3->SetLineColor(2);
1847      sh3->SetLineColor(4);
1848      sh3->SetLineStyle(2);
1849      setStats(rh3,sh3, startingY, startingX, fit);
1850      rh3->Draw();
1851      sh3->Draw("sames");
1852      myPV->PVCompute(rh3, sh3, te, option );
1853    }else if (chi2){
1854      char * option = "UUNORM";
1855      double  startingY = 0.4;
1856      double  startingX = 0.1;
1857      bool fit = true;
1858      
1859      graphPad->Divide(1,3);
1860      
1861      graphPad->cd(1);
1862      rh1->SetLineColor(2);
1863      sh1->SetLineColor(4);
1864      sh1->SetLineStyle(2);
1865      setStats(rh1,sh1, startingY, startingX, fit);
1866      rh1->Draw();
1867      sh1->Draw("sames");
1868      myPV->PVCompute(rh1, sh1, te, option );
1869      
1870      graphPad->cd(2);
1871      rh2->SetLineColor(2);
1872      sh2->SetLineColor(4);
1873      sh2->SetLineStyle(2);
1874      setStats(rh2,sh2, startingY, startingX, fit);
1875      rh2->Draw();
1876      sh2->Draw("sames");
1877      myPV->PVCompute(rh2, sh2, te, option );
1878      
1879      graphPad->cd(3);
1880      rh3->SetLineColor(2);
1881      sh3->SetLineColor(4);
1882      sh3->SetLineStyle(2);
1883      setStats(rh3,sh3, startingY, startingX, fit);
1884      rh3->Draw();
1885      sh3->Draw("sames");
1886      myPV->PVCompute(rh3, sh3, te, option );
1887    }
1888    
1889    canvas->Print("rs_pullDxy_Dz_Theta.eps");
1890    canvas->Print("rs_pullDxy_Dz_Theta.gif");
1891 
1892    //resolution Pt, Phi
1893    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/sigmapt",rh1);
1894    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/sigmapt",sh1);
1895    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/sigmapt",rc1);
1896    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/sigmapt",sc1);
1897    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/sigmaphi",rh2);
1898    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/sigmaphi",sh2);
1899    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/sigmaphi",rc2);
1900    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/sigmaphi",sc2);
1901 
1902    canvas = new TCanvas("Tracks13","Tracks: Pt and Phi resolution",1000,1000);
1903    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
1904    title->Draw();
1905    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
1906    graphPad->Draw();
1907    graphPad->cd();
1908 
1909    if (hit&&chi2){
1910      char * option = "UU";
1911      double  startingY = -1;
1912      double  startingX = .1;
1913      bool fit = false;
1914 
1915      graphPad->Divide(2,2);
1916 
1917      graphPad->cd(1);
1918      rh1->SetLineColor(2);
1919      sh1->SetLineColor(4);
1920      sh1->SetLineStyle(1);
1921      setStats(rh1,sh1, startingY, startingX, fit);
1922      rh1->Draw();
1923      sh1->Draw("sames");
1924      myPV->PVCompute(rh1, sh1, te, option );
1925      
1926      graphPad->cd(2);
1927      rc1->SetLineColor(2);
1928      sc1->SetLineColor(4);
1929      sc1->SetLineStyle(2);
1930      setStats(rc1,sc1, startingY, startingX, fit);
1931      rc1->Draw();
1932      sc1->Draw("sames");
1933      myPV->PVCompute(rc1, sc1, te, option );
1934      
1935      graphPad->cd(3);
1936      rh2->SetLineColor(2);
1937      sh2->SetLineColor(4);
1938      sh2->SetLineStyle(2);
1939      setStats(rh2,sh2, startingY, startingX, fit);
1940      rh2->Draw();
1941      sh2->Draw("sames");
1942      myPV->PVCompute(rh2, sh2, te, option );
1943      
1944      graphPad->cd(4);
1945      rc2->SetLineColor(2);
1946      sc2->SetLineColor(4);
1947      sc2->SetLineStyle(2);
1948      setStats(rc2,sc2, startingY, startingX, fit);
1949      rc2->Draw();
1950      sc2->Draw("sames");
1951      myPV->PVCompute(rc2, sc2, te, option );
1952      
1953    }else if (hit){  
1954      char * option = "UU";
1955      double  startingY = -1;
1956      double  startingX = .1;
1957      bool fit = false;
1958 
1959      graphPad->Divide(1,2);
1960      
1961      graphPad->cd(1);
1962      rh1->SetLineColor(2);
1963      sh1->SetLineColor(4);
1964      sh1->SetLineStyle(2);
1965      setStats(rh1,sh1, startingY, startingX, fit);
1966      rh1->Draw();
1967      sh1->Draw("sames");
1968      myPV->PVCompute(rh1, sh1, te, option );
1969      
1970      graphPad->cd(2);
1971      rh2->SetLineColor(2);
1972      sh2->SetLineColor(4);
1973      sh2->SetLineStyle(2);
1974      setStats(rh2,sh2, startingY, startingX, fit);
1975      rh2->Draw();
1976      sh2->Draw("sames");
1977      myPV->PVCompute(rh2, sh2, te, option );  
1978   
1979    }else if (chi2){ 
1980      char * option = "UU";
1981      double  startingY = -1;
1982      double  startingX = .1;
1983      bool fit = false;
1984 
1985      graphPad->Divide(1,2);
1986      
1987      graphPad->cd(1);
1988      rh1->SetLineColor(2);
1989      sh1->SetLineColor(4);
1990      sh1->SetLineStyle(2);
1991      setStats(rh1,sh1, startingY, startingX, fit);
1992      rh1->Draw();
1993      sh1->Draw("sames");
1994      myPV->PVCompute(rh1, sh1, te, option );
1995      
1996      graphPad->cd(2);
1997      rh2->SetLineColor(2);
1998      sh2->SetLineColor(4);
1999      sh2->SetLineStyle(2);
2000      setStats(rh2,sh2, startingY, startingX, fit);
2001      rh2->Draw();
2002      sh2->Draw("sames");
2003      myPV->PVCompute(rh2, sh2, te, option );  
2004      
2005    }
2006 
2007    canvas->Print("rs_resolPt_Phi.eps");
2008    canvas->Print("rs_resolPt_Phi.gif");
2009 
2010    //resolution Dxy, Dz, Theta
2011    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/sigmadxy",rh1);
2012    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/sigmadxy",sh1);
2013    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/sigmadxy",rc1);
2014    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/sigmadxy",sc1);
2015    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/sigmadz",rh2);
2016    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/sigmadz",sh2);
2017    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/sigmadz",rc2);
2018    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/sigmadz",sc2);
2019    rdir->GetObject(collnamerRS+"_"+assocnamerRS1+"/sigmacotTheta",rh3);
2020    sdir->GetObject(collnamesRS+"_"+assocnamesRS1+"/sigmacotTheta",sh3);
2021    rdir->GetObject(collnamerRS+"_"+assocnamerRS2+"/sigmacotTheta",rc3);
2022    sdir->GetObject(collnamesRS+"_"+assocnamesRS2+"/sigmacotTheta",sc3);
2023 
2024    canvas = new TCanvas("Tracks14","Tracks: Dxy, Dz, Theta resolution",1000,1000);
2025    TPaveLabel* title = new TPaveLabel(0.1,0.96,0.9,0.99,relinfo);
2026    title->Draw();
2027    TPad* graphPad = new TPad("Graphs","Graphs",0.01,0.05,0.95,0.95);
2028    graphPad->Draw();
2029    graphPad->cd();
2030 
2031    if (hit&&chi2){   
2032      char * option = "UU";
2033      double  startingY = -1;
2034      double  startingX = 0.1;
2035      bool fit = true;
2036 
2037      graphPad->Divide(2,3);
2038      
2039      graphPad->cd(1);
2040      rh1->SetLineColor(2);
2041      sh1->SetLineColor(4);
2042      sh1->SetLineStyle(2);
2043      setStats(rh1,sh1, startingY, startingX, fit);
2044      rh1->Draw();
2045      sh1->Draw("sames");
2046      myPV->PVCompute(rh1, sh1, te, option );
2047      
2048      graphPad->cd(2);
2049      rc1->SetLineColor(2);
2050      sc1->SetLineColor(4);
2051      sc1->SetLineStyle(2);
2052      setStats(rc1,sc1, startingY, startingX, fit);
2053      rc1->Draw();
2054      sc1->Draw("sames");
2055      myPV->PVCompute(rc1, sc1, te, option );
2056      
2057      graphPad->cd(3);
2058      rh2->SetLineColor(2);
2059      sh2->SetLineColor(4);
2060      sh2->SetLineStyle(2);
2061      setStats(rh2,sh2, startingY, startingX, fit);
2062      rh2->Draw();
2063      sh2->Draw("sames");
2064      myPV->PVCompute(rh2, sh2, te, option );
2065      
2066      graphPad->cd(4);
2067      rc2->SetLineColor(2);
2068      sc2->SetLineColor(4);
2069      sc2->SetLineStyle(2);
2070      setStats(rc2,sc2, startingY, startingX, fit);
2071      rc2->Draw();
2072      sc2->Draw("sames");
2073      myPV->PVCompute(rc2, sc2, te, option );
2074      
2075      graphPad->cd(5);
2076      rh3->SetLineColor(2);
2077      sh3->SetLineColor(4);
2078      sh3->SetLineStyle(2);
2079      setStats(rh3,sh3, startingY, startingX, fit);
2080      rh3->Draw();
2081      sh3->Draw("sames");
2082      myPV->PVCompute(rh3, sh3, te, option );
2083      
2084      graphPad->cd(6);
2085      rc3->SetLineColor(2);
2086      sc3->SetLineColor(4);
2087      sc3->SetLineStyle(2);
2088      setStats(rc3,sc3, startingY, startingX, fit);
2089      rc3->Draw();
2090      sc3->Draw("sames");
2091      myPV->PVCompute(rc3, sc3, te, option );
2092    }else if (hit){ 
2093      char * option = "UU";
2094      double  startingY = -1;
2095      double  startingX = 0.1;
2096      bool fit = true;
2097 
2098      graphPad->Divide(1,3);
2099      
2100      graphPad->cd(1);
2101      rh1->SetLineColor(2);
2102      sh1->SetLineColor(4);
2103      sh1->SetLineStyle(2);
2104      setStats(rh1,sh1, startingY, startingX, fit);
2105      rh1->Draw();
2106      sh1->Draw("sames");
2107      myPV->PVCompute(rh1, sh1, te, option );
2108      
2109      graphPad->cd(2);
2110      rh2->SetLineColor(2);
2111      sh2->SetLineColor(4);
2112      sh2->SetLineStyle(2);
2113      setStats(rh2,sh2, startingY, startingX, fit);
2114      rh2->Draw();
2115      sh2->Draw("sames");
2116      myPV->PVCompute(rh2, sh2, te, option );
2117      
2118      graphPad->cd(3);
2119      rh3->SetLineColor(2);
2120      sh3->SetLineColor(4);
2121      sh3->SetLineStyle(2);
2122      setStats(rh3,sh3, startingY, startingX, fit);
2123      rh3->Draw();
2124      sh3->Draw("sames");
2125      myPV->PVCompute(rh3, sh3, te, option );
2126    }else if (chi2){
2127      char * option = "UU";
2128      double  startingY = -1;
2129      double  startingX = 0.1;
2130      bool fit = true;
2131      
2132      graphPad->Divide(1,3);
2133      
2134      graphPad->cd(1);
2135      rh1->SetLineColor(2);
2136      sh1->SetLineColor(4);
2137      sh1->SetLineStyle(2);
2138      setStats(rh1,sh1, startingY, startingX, fit);
2139      rh1->Draw();
2140      sh1->Draw("sames");
2141      myPV->PVCompute(rh1, sh1, te, option );
2142      
2143      graphPad->cd(2);
2144      rh2->SetLineColor(2);
2145      sh2->SetLineColor(4);
2146      sh2->SetLineStyle(2);
2147      setStats(rh2,sh2, startingY, startingX, fit);
2148      rh2->Draw();
2149      sh2->Draw("sames");
2150      myPV->PVCompute(rh2, sh2, te, option );
2151      
2152      graphPad->cd(3);
2153      rh3->SetLineColor(2);
2154      sh3->SetLineColor(4);
2155      sh3->SetLineStyle(2);
2156      setStats(rh3,sh3, startingY, startingX, fit);
2157      rh3->Draw();
2158      sh3->Draw("sames");
2159      myPV->PVCompute(rh3, sh3, te, option );
2160    }
2161    
2162    canvas->Print("rs_resolDxy_Dz_Theta.eps");
2163    canvas->Print("rs_resolDxy_Dz_Theta.gif");
2164  }
2165 }
2166 
2167 void NormalizeHistograms(TH1F* h1, TH1F* h2)
2168 {
2169   if (h1==0 || h2==0) return;
2170   float scale1 = -9999.9;
2171   float scale2 = -9999.9;
2172 
2173   if ( h1->Integral() != 0 && h2->Integral() != 0 ){
2174       scale1 = 1.0/(float)h1->Integral();
2175       scale2 = 1.0/(float)h2->Integral();
2176     
2177       h1->Sumw2();
2178       h2->Sumw2();
2179       h1->Scale(scale1);
2180       h2->Scale(scale2);
2181     }
2182 }
2183 
2184 void setStats(TH1* r,TH1* s, double startingY, double startingX = .1,bool fit){
2185   if (startingY<0){
2186     r->SetStats(0);
2187     s->SetStats(0);
2188   } else {
2189     if (fit){
2190       r->Fit("gaus");
2191       TF1* f1 = (TF1*) r->GetListOfFunctions()->FindObject("gaus");
2192       f1->SetLineColor(2);
2193       f1->SetLineWidth(1);
2194     }
2195     r->Draw();
2196     gPad->Update(); 
2197     TPaveStats* st1 = (TPaveStats*) r->GetListOfFunctions()->FindObject("stats");
2198     if (fit) st1->SetOptFit();
2199     st1->SetX1NDC(startingX);
2200     st1->SetX2NDC(startingX+0.2);
2201     st1->SetY1NDC(startingY+0.15);
2202     st1->SetY2NDC(startingY+0.3);
2203     st1->SetTextColor(2);
2204     if (fit) {
2205       s->Fit("gaus");
2206       TF1* f2 = (TF1*) s->GetListOfFunctions()->FindObject("gaus");
2207       f2->SetLineColor(4);
2208       f2->SetLineWidth(1);    
2209     }
2210     s->Draw();
2211     gPad->Update(); 
2212     TPaveStats* st2 = (TPaveStats*) s->GetListOfFunctions()->FindObject("stats");
2213     if (fit) st2->SetOptFit();
2214     st2->SetX1NDC(startingX);
2215     st2->SetX2NDC(startingX+0.2);
2216     st2->SetY1NDC(startingY);
2217     st2->SetY2NDC(startingY+0.15);
2218     st2->SetTextColor(4);
2219   }
2220 }
2221 
2222 void fixRangeY(TH1* r,TH1* s){
2223   double ymin = (r->GetBinContent(r->GetMinimumBin()) < s->GetBinContent(s->GetMinimumBin())) ? 
2224     r->GetBinContent(r->GetMinimumBin()) : s->GetBinContent(s->GetMinimumBin());
2225   double ymax = (r->GetBinContent(r->GetMaximumBin()) > s->GetBinContent(s->GetMaximumBin())) ?
2226     r->GetBinContent(r->GetMaximumBin()) : s->GetBinContent(s->GetMaximumBin());
2227   r->GetYaxis()->SetRangeUser(ymin*0.9,ymax*1.1);
2228   s->GetYaxis()->SetRangeUser(ymin*0.9,ymax*1.1);
2229 }