Exemplo n.º 1
0
void RecoMuonValHistoPublisher(char* newFile="NEW_FILE",char* refFile="REF_FILE")
{
  //gROOT->ProcessLine(".x HistoCompare_Tracks.C");
 gROOT ->Reset();
 gROOT ->SetBatch();

 //=========  settings ====================

 char* dataType = "DATATYPE";

 gROOT->SetStyle("Plain");
 gStyle->SetPadGridX(kTRUE);
 gStyle->SetPadGridY(kTRUE);
 gStyle->SetPadRightMargin(0.07);
 gStyle->SetPadLeftMargin(0.13);
 //gStyle->SetTitleXSize(0.07); 
 //gStyle->SetTitleXOffset(0.6); 
 //tyle->SetTitleYSize(0.3);
 //gStyle->SetLabelSize(0.6) 
 //gStyle->SetTextSize(0.5);
 char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION");
 char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION");

 Float_t maxPT=1500.;

 char* fastSim = "IS_FSIM";

 //=============================================


 delete gROOT->GetListOfFiles()->FindObject(refFile);
 delete gROOT->GetListOfFiles()->FindObject(newFile); 

//INPUT FILE IS DEFINED HERE, passed from python wrapper
 TText* te = new TText();
 TFile * sfile = new TFile(newFile);
 TDirectory * sdir=gDirectory;
 TFile * rfile = new TFile(refFile);
 TDirectory * rdir=gDirectory;

//check datatype
 if (dataType == "RECO") {
   if(sfile->cd("DQMData/Run 1/Muons/Run summary")) {;}
   else {
     cout << " Muon Histos for " << dataType << " not found" << endl;
     return;
   }
 }
 else {
   cout << " Data type " << dataType << " not allowed: only RECO is considered" << endl;
   return;
 }
 sdir=gDirectory;
 TIter nextkey( sdir->GetListOfKeys() );
 TList *sl = new TList();
 TKey *key, *oldkey=0;
 cout << "- New DQM muon reco collections: " << endl;
 while ( key = (TKey*)nextkey() ) {
   TObject *obj = key->ReadObj();
   if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) {
     TString theName = obj->GetName();
     if (theName.Contains("RecoMuonV")) {
       cout << " -> " << theName << endl;
       sl->Add(obj);
     }
   }
 }
 if (sl->GetSize()>0) {
   TString collname2 =sl->At(0)->GetName(); 
 }
 else {
   cout << " No DQM muon reco histos found in NEW file " << endl;
   return;
 }
 
 if (dataType == "RECO") {
   if(rfile->cd("DQMData/Run 1/Muons/Run summary")) {;}
   else {
     cout << " Muon Histos for " << dataType << " not found" << endl;
     return;
   }
 }
 rdir=gDirectory;
 TIter nextkeyr( rdir->GetListOfKeys() );
 TList *rl = new TList();
 TKey *keyr, *oldkeyr=0;
 cout << "- Ref DQM muon reco collections: " << endl;
 while ( keyr = (TKey*)nextkeyr() ) {
   TObject *obj = keyr->ReadObj();
   if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) {
     TString theName = obj->GetName();
     if (theName.Contains("RecoMuonV")) {
       cout << " -> " << theName << endl;
       rl->Add(obj);
     }
   }
 }
 if (rl->GetSize()>0) {
   TString collname1=rl->At(0)->GetName();
  }
 else {
   cout << " No DQM muon reco histos found in REF file " << endl;
   return;
 }

 TCanvas *canvas;
 
 TH1F *sh1,*rh1;
 TH1F *sh2,*rh2;
 TH1F *sh3,*rh3;
 TH1F *sh4,*rh4;
 TH1F *sh5,*rh5;
 TH1F *sh6,*rh6;
 
 TIter iter_r( rl );
 TIter iter_s( sl );
 TKey * myKey1, *myKey2;
 while ( (myKey1 = (TKey*)iter_r()) ) {
   TString myName = myKey1->GetName();
   collname1 = myName;
   myKey2 = (TKey*)iter_s();
   if (!myKey2) continue;
   collname2 = myKey2->GetName();
      if ( (collname1 != collname2) && (collname1+"FS" != collname2) && (collname1 != collname2+"FS") ) {
     cout << " Different collection names, please check: " << collname1 << " : " << collname2 << endl;
     continue;
   }

   TString newDir("NEW_RELEASE/NEWSELECTION/NEW_LABEL/");
   newDir+=myName;
   gSystem->mkdir(newDir,kTRUE);
 
   //rh1 = 0;
   //sh1 = 0;
   //===== For each monitored type as defined in muonValidation_cff.py 
 
   //===== reco muon distributions: GLB
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt",sh1);
   rh1->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T}");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrP",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrP",sh2);
   rh2->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p/p");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3);
   if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3);
   if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3);
   rh3->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(#eta)");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4);
   if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4);
   if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4);
   rh4->GetYaxis()->SetTitle("GlobalMuon(GLB) #Delta p_{T}/p_{T} vs #sigma(p_{T})");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecHistosGlb","Distributions for GlobalMuons (GLB)",1000,1050);

   // Normalize to the same number of "new" events:
   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);

   plot4histos(canvas,
	       sh1,rh1,sh2,rh2,
	       sh3,rh3,sh4,rh4,
	       te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoGlb.pdf");   
   delete l;
   delete canvas;

   //==== efficiencies and fractions GLB
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffP",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffP",sh1);
   //if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("GlobalMuon(GLB) #epsilon vs. p");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffEta",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/EffEta",sh2);
   rh2->GetYaxis()->SetTitle("GlobalMuon(GLB) #epsilon vs. #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractP",rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractP",sh3);
   rh3->GetYaxis()->SetTitle("GlobalMuon(GLB) fraction vs. p");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractEta",rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Glb"+fastSim+"/FractEta",sh4);
   rh4->GetYaxis()->SetTitle("GlobalMuon(GLB) fraction vs. #eta");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecEffHistosGlb","Distributions for GlobalMuons (GLB), efficiencies and fractions",1000,1050);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoGlbEff.pdf");
   delete l;
   delete canvas;

   //===== reco muon distributions: GLBPF
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T}");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrP",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrP",sh2);
   rh2->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p/p");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3);
   if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3);
   if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3);
   rh3->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(#eta)");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4);
   if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4);
   if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4);
   rh4->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #Delta p_{T}/p_{T} vs #sigma(p_{T})");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecHistosGlbPF","Distributions for PFGlobalMuons (GLBPF)",1000,1050);

   // Normalize to the same number of "new" events:
   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoGlbPF.pdf");
   delete l;
   delete canvas;

   //==== efficiencies and fractions GLBPF
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffP",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffP",sh1);
   //if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #epsilon vs. p");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffEta",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/EffEta",sh2);
   rh2->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) #epsilon vs. #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractP",rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractP",sh3);
   rh3->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) fraction vs. p");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractEta",rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_GlbPF"+fastSim+"/FractEta",sh4);
   rh4->GetYaxis()->SetTitle("PFGlobalMuon(GLBPF) fraction vs. #eta");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecEffHistosGlbPF","Distributions for PFGlobalMuons (GLBPF), efficiencies and fractions",1000,1050);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoGlbPFEff.pdf");
   delete l;
   delete canvas;


   //===== reco muon distributions: STA
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T}");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrP",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrP",sh2);
   rh2->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p/p");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3);
   if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3);
   if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3);
   rh3->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(#eta)");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4);
   if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4);
   if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4);
   rh4->GetYaxis()->SetTitle("StandAloneMuon(STA) #Delta p_{T}/p_{T} vs #sigma(p_{T})");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecHistosSta","Distributions for StandAloneMuons (STA)",1000,1050);

   // Normalize to the same number of "new" events:
   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoSta.pdf");
   delete l;
   delete canvas;

   //==== efficiencies and fractions STA
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffP",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffP",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("StandAloneMuon(STA) #epsilon vs. p");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffEta",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/EffEta",sh2);
   rh2->GetYaxis()->SetTitle("StandAloneMuon(STA) #epsilon vs. #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractP",rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractP",sh3);
   rh3->GetYaxis()->SetTitle("StandAloneMuon(STA) fraction vs. p");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractEta",rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Sta"+fastSim+"/FractEta",sh4);
   rh4->GetYaxis()->SetTitle("StandAloneMuon(STA) fraction vs. #eta");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecEffHistosSta","Distributions for StandAloneMuons (STA), efficiencies and fractions",1000,1050);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoStaEff.pdf");
   delete l;
   delete canvas;

   //===== reco muon distributions: TRK
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T}");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrP",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrP",sh2);
   rh2->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p/p");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3);
   if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3);
   if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3);
   rh3->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(#eta)");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4);
   if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4);
   if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4);
   rh4->GetYaxis()->SetTitle("TrackerMuon(TRK) #Delta p_{T}/p_{T} vs #sigma(p_{T})");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecHistosTrk","Distributions for TrackerMuons (TRK)",1000,1050);

   // Normalize to the same number of "new" events:
   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoTrk.pdf");
   delete l;
   delete canvas;


   //==== efficiencies and fractions TRK
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffP",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffP",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("TrackerMuon(TRK) #epsilon vs. p");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffEta",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/EffEta",sh2);
   rh2->GetYaxis()->SetTitle("TrackerMuon(TRK) #epsilon vs. #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractP",rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractP",sh3);
   rh3->GetYaxis()->SetTitle("TrackerMuon(TRK) fraction vs. p");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractEta",rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Trk"+fastSim+"/FractEta",sh4);
   rh4->GetYaxis()->SetTitle("TrackerMuon(TRK) fraction vs. #eta");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecEffHistosTrk","Distributions for TrackerMuons (TRK), efficiencies and fractions",1000,1050);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoTrkEff.pdf");
   delete l;
   delete canvas;

   //
   //===== reco muon distributions: Tight Muons
   //
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("Tight Muon #Delta p_{T}/p_{T}");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrP",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrP",sh2);
   rh2->GetYaxis()->SetTitle("Tight Muon #Delta p/p");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",rh3);
   if (!rh3) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",sh3);
   if (!sh3) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Eta_Sigma",(TProfile*)sh3);
   rh3->GetYaxis()->SetTitle("Tight Muon #Delta p_{T}/p_{T} vs #sigma(#eta)");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",rh4);
   if (!rh4) rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",sh4);
   if (!sh4) sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/ErrPt_vs_Pt_Sigma",(TProfile*)sh4);
   rh4->GetYaxis()->SetTitle("Tigh Muon) #Delta p_{T}/p_{T} vs #sigma(p_{T})");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecHistosTgt","Distributions for Tight Muons",1000,1050);

   // Normalize to the same number of "new" events:
   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoTgt.pdf");
   delete l;
   delete canvas;


   //==== efficiencies and fractions Tight Muons
   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffP",rh1);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffP",sh1);
  // if(! rh1 && sh1) continue;
   rh1->GetYaxis()->SetTitle("Tight Muon #epsilon vs. p");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffEta",rh2);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/EffEta",sh2);
   rh2->GetYaxis()->SetTitle("Tight Muon #epsilon vs. #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractP",rh3);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractP",sh3);
   rh3->GetYaxis()->SetTitle("Tight Muon fraction vs. p");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractEta",rh4);
   sdir->GetObject(collname2+"/RecoMuon_MuonAssoc_Tgt"+fastSim+"/FractEta",sh4);
   rh4->GetYaxis()->SetTitle("Tight Muon fraction vs. #eta");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("RecEffHistosTgt","Distributions for Tight Muons, efficiencies and fractions",1000,1050);

   plot4histos(canvas,
               sh1,rh1,sh2,rh2,
               sh3,rh3,sh4,rh4,
               te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print(newDir+"/muonRecoTgtEff.pdf");
   delete l;
   delete canvas;


   //
   // Merge pdf histograms together into larger files, and name them based on the collection names
   //
 gSystem->Exec("gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged.pdf "
	       +newDir+"/muonRecoGlb.pdf "
	       +newDir+"/muonRecoGlbEff.pdf "
               +newDir+"/muonRecoGlbPF.pdf "
               +newDir+"/muonRecoGlbPFEff.pdf "
               +newDir+"/muonRecoSta.pdf "
               +newDir+"/muonRecoStaEff.pdf "
               +newDir+"/muonRecoTrk.pdf "
               +newDir+"/muonRecoTrkEff.pdf "
               +newDir+"/muonRecoTgt.pdf "
               +newDir+"/muonRecoTgtEff.pdf ");
 gSystem->Exec("mv merged.pdf "+newDir+"/../"+myName+".pdf");
 gSystem->Exec("rm -r "+newDir);
 
 }  // end of "while loop"
 
}
void IterTrackValHistoPublisher(char* newFile="NEW_FILE",char* refFile="REF_FILE")
{
  //gROOT->ProcessLine(".x HistoCompare_Tracks.C");
 gROOT ->Reset();
 gROOT ->SetBatch();

 //=========  settings ====================
 gROOT->SetStyle("Plain");
 gStyle->SetPadGridX(kTRUE);
 gStyle->SetPadGridY(kTRUE);
 gStyle->SetPadRightMargin(0.07);
 gStyle->SetPadLeftMargin(0.13);
 //gStyle->SetTitleXSize(0.07); 
 //gStyle->SetTitleXOffset(0.6); 
 //tyle->SetTitleYSize(0.3);
 //gStyle->SetLabelSize(0.6) 
 //gStyle->SetTextSize(0.5);
 char* refLabel("REF_LABEL, REF_RELEASE REFSELECTION");
 char* newLabel("NEW_LABEL, NEW_RELEASE NEWSELECTION");


 //=============================================


 delete gROOT->GetListOfFiles()->FindObject(refFile);
 delete gROOT->GetListOfFiles()->FindObject(newFile); 

 TText* te = new TText();
 TFile * sfile = new TFile(newFile);
 TDirectory * sdir=gDirectory;
 TFile * rfile = new TFile(refFile);
 TDirectory * rdir=gDirectory;

 if(sfile->GetDirectory("DQMData/Run 1/RecoTrackV")) sfile->cd("DQMData/Run 1/RecoTrackV/Run summary/Track");
 else if(sfile->GetDirectory("DQMData/RecoTrackV/Track"))sfile->cd("DQMData/RecoTrackV/Track");
 else if(sfile->GetDirectory("DQMData/Run 1/Tracking")) sfile->cd("DQMData/Run 1/Tracking/Run summary/Track");
 else if(sfile->GetDirectory("DQMData/Tracking/Track"))sfile->cd("DQMData/Tracking/Track");
 sdir=gDirectory;
 TList *sl= sdir->GetListOfKeys();
 TString collname2 =sl->At(0)->GetName(); 

 // select generalTracks to make the usual validation plots for
 int num_col = sl->GetSize();
 for(int i=0; i<num_col;i++){
   collname2 =sl->At(i)->GetName();
   if(collname2.Contains("general")) break;
 }
 //cout << "collname2 = " << collname2 << endl;

 if(rfile->GetDirectory("DQMData/Run 1/RecoTrackV")) rfile->cd("DQMData/Run 1/RecoTrackV/Run summary/Track");
 else if(rfile->GetDirectory("DQMData/RecoTrackV/Track"))rfile->cd("DQMData/RecoTrackV/Track");
 else if(rfile->GetDirectory("DQMData/Run 1/Tracking")) rfile->cd("DQMData/Run 1/Tracking/Run summary/Track");
 else if(rfile->GetDirectory("DQMData/Tracking/Track"))rfile->cd("DQMData/Tracking/Track");
 rdir=gDirectory;
 TList *rl= rdir->GetListOfKeys();
 TString collname1=rl->At(0)->GetName(); 

 num_col = rl->GetSize();
 for(int i=0; i<num_col;i++){
   collname1 =rl->At(i)->GetName();
   if(collname1.Contains("general")) break;
 }
 //cout << "collname1 = " << collname1 << endl;
 //int num_col = rl->GetSize();
 //for(int i=0; i<num_col;i++){
 //  cout << " >>>>>>>>>dir " << i << " name = " << rl->At(i)->GetName() << endl;
 //}

 //HistoCompare_Tracks * myPV = new HistoCompare_Tracks();

 TCanvas *canvas;

 TH1F *sh1,*rh1;
 TH1F *sh2,*rh2;
 TH1F *sh3,*rh3;
 TH1F *sh4,*rh4;
 TH1F *sh5,*rh5;
 TH1F *sh6,*rh6;

 TH1F *sc1,*rc1;
 TH1F *sc2,*rc2;
 TH1F *sc3,*rc3;

 bool hit=1;
 bool chi2=1;
 bool ctf=1;
 bool rs=0;


 //////////////////////////////////////
 /////////// CTF //////////////////////
 //////////////////////////////////////
 if (ctf){
   //===== building
   rdir->GetObject(collname1+"/effic",rh1);
   sdir->GetObject(collname2+"/effic",sh1);
   rh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rh1->GetXaxis()->SetTitle("#eta");
   rh1->GetYaxis()->SetTitle("efficiency vs #eta");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);
//   rh1->GetYaxis()->SetRangeUser(0.5,1.025);
//   sh1->GetYaxis()->SetRangeUser(0.5,1.025);
   rdir->GetObject(collname1+"/fakerate",rh2);
   sdir->GetObject(collname2+"/fakerate",sh2);
   rh2->GetYaxis()->SetRangeUser(0.,MAXFAKE);
   sh2->GetYaxis()->SetRangeUser(0.,MAXFAKE);
   rh2->GetXaxis()->SetTitle("#eta");
   rh2->GetYaxis()->SetTitle("fakerate vs #eta");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);
//   rh2->GetYaxis()->SetRangeUser(0.,.70);
//   sh2->GetYaxis()->SetRangeUser(0.,.70);


   rdir->GetObject(collname1+"/efficPt",rh3);
   sdir->GetObject(collname2+"/efficPt",sh3);
   rh3->GetXaxis()->SetRangeUser(0,300);
   sh3->GetXaxis()->SetRangeUser(0,300);
   rh3->GetXaxis()->SetTitle("p_{t}");
   rh3->GetYaxis()->SetTitle("efficiency vs p_{t}");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);
   rh3->SetTitle("");
   rdir->GetObject(collname1+"/fakeratePt",rh4);
   sdir->GetObject(collname2+"/fakeratePt",sh4);
   rh4->SetTitle("");
   rh4->GetXaxis()->SetTitle("p_{t}");
   rh4->GetYaxis()->SetTitle("fakrate vs p_{t}");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);
   rh4->GetYaxis()->SetRangeUser(0.,.80);
   sh4->GetYaxis()->SetRangeUser(0.,.80);
   rh4->GetXaxis()->SetRangeUser(0.2,300);
   sh4->GetXaxis()->SetRangeUser(0.2,300);


   rdir->GetObject(collname1+"/effic_vs_hit",rh5);
   sdir->GetObject(collname2+"/effic_vs_hit",sh5);
   rh5->GetXaxis()->SetTitle("hits");
   rh5->GetYaxis()->SetTitle("efficiency vs hits");
   rh5->GetYaxis()->SetTitleSize(0.05);
   rh5->GetYaxis()->SetTitleOffset(1.2);
   //rh3->GetXaxis()->SetRangeUser(0,30);
   //sh3->GetXaxis()->SetRangeUser(0,30);
   rdir->GetObject(collname1+"/fakerate_vs_hit",rh6);
   sdir->GetObject(collname2+"/fakerate_vs_hit",sh6);
   rh6->GetYaxis()->SetRangeUser(0.,1.0);
   rh6->GetYaxis()->SetRangeUser(0.,1.0);
   rh6->GetXaxis()->SetTitle("hits");
   rh6->GetYaxis()->SetTitle("fakerate vs hits");
   rh6->GetYaxis()->SetTitleSize(0.05);
   rh6->GetYaxis()->SetTitleOffset(1.2);

   //rdir->GetObject(collname1+"/num_reco_pT",rh6);
   //sdir->GetObject(collname2+"/num_reco_pT",sh6);



   canvas = new TCanvas("Tracks","Tracks: efficiency & fakerate",1000,1400);


   //NormalizeHistograms(rh2,sh2);
   //NormalizeHistograms(rh6,sh6);
   //rh1->GetYaxis()->SetRangeUser(8,24);
   //sh1->GetYaxis()->SetRangeUser(8,24);

   //rh6->GetXaxis()->SetRangeUser(0,10);
   //sh6->GetXaxis()->SetRangeUser(0,10);

   TH1F * r[6]={rh1,rh2,rh3,rh4,rh5,rh6};
   TH1F * s[6]={sh1,sh2,sh3,sh4,sh5,sh6};

   plotBuilding(canvas,s, r,6,
		te,"UU",-1, 1, false, 0xC);

   canvas->cd();
   //TPaveText* text = new TPaveText(0.25,0.72,0.75,0.77,"prova");
   //text->SetFillColor(0);
   //text->SetTextColor(1);
   //text->Draw();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("building.pdf");   
   delete l;


   // ====== hits and pt
   rdir->GetObject(collname1+"/nhits_vs_eta_pfx",(TProfile*)rh1);                                                                                                                                                                                
   sdir->GetObject(collname2+"/nhits_vs_eta_pfx",(TProfile*)sh1);                                                                                                                                                                                
   rdir->GetObject(collname1+"/hits",rh2);                                                                                                                                                                                    
   sdir->GetObject(collname2+"/hits",sh2);         
   
   rdir->GetObject(collname1+"/num_simul_pT",rh3);
   sdir->GetObject(collname2+"/num_simul_pT",sh3);
   rdir->GetObject(collname1+"/num_reco_pT",rh4);
   sdir->GetObject(collname2+"/num_reco_pT",sh4);
   
   canvas = new TCanvas("Tracks1","Tracks: hits and Pt",1000,1050);
   
   rh1->GetYaxis()->SetRangeUser(8,24);
   sh1->GetYaxis()->SetRangeUser(8,24);
   rh1->GetXaxis()->SetTitle("#eta");
   rh1->GetYaxis()->SetTitle("<hits> vs #eta");
   rh2->GetXaxis()->SetRangeUser(0,30);
   sh2->GetXaxis()->SetRangeUser(0,30);
   rh2->GetXaxis()->SetTitle("hits");


   rh3->GetXaxis()->SetRangeUser(0,10);
   sh3->GetXaxis()->SetRangeUser(0,10);
   rh3->GetXaxis()->SetTitle("p_{t}");
   rh4->GetXaxis()->SetRangeUser(0,10);
   sh4->GetXaxis()->SetRangeUser(0,10);
   rh4->GetXaxis()->SetTitle("p_{t}");
   NormalizeHistograms(rh3,sh3);
   NormalizeHistograms(rh4,sh4);
   
   plot4histos(canvas,
	      sh1,rh1,sh2,rh2,
	      sh3,rh3,sh4,rh4,
	      te,"UU",-1);
   
   canvas->cd();
   
   l = new TLegend(0.20,0.49,0.90,0.54);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("hitsAndPt.pdf");
   delete l;


   //===== tuning
   rdir->GetObject(collname1+"/chi2",rh1);
   sdir->GetObject(collname2+"/chi2",sh1);
   rdir->GetObject(collname1+"/chi2_prob",rh2);
   sdir->GetObject(collname2+"/chi2_prob",sh2);
   rdir->GetObject(collname1+"/chi2_vs_eta_pfx",(TProfile*)rh3);
   sdir->GetObject(collname2+"/chi2_vs_eta_pfx",(TProfile*)sh3);

   rdir->GetObject(collname1+"/ptres_vs_eta_Mean",rh4);
   sdir->GetObject(collname2+"/ptres_vs_eta_Mean",sh4);


   canvas = new TCanvas("Tracks2","Tracks: chi2 & chi2 probability",1000,1050);

   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);
   fixRangeY(rh1,sh1);
   fixRangeY(rh2,sh2);
   rh1->GetXaxis()->SetTitle("#chi^{2}");
   rh2->GetXaxis()->SetTitle("Prob(#chi^{2})");
   
   rh3->GetYaxis()->SetRangeUser(0,2.5);
   sh3->GetYaxis()->SetRangeUser(0,2.5);


   rh3->SetTitle("");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);
   rh3->GetYaxis()->SetTitle("<  #chi^{2} / ndf >");
   rh3->GetXaxis()->SetTitleSize(0.07);
   rh3->GetXaxis()->SetTitleOffset(0.6);
   rh3->GetXaxis()->SetTitle("#eta");

   rh4->Scale(100.);
   sh4->Scale(100.);
   rh4->GetYaxis()->SetRangeUser(-1.5,1.5);
   sh4->GetYaxis()->SetRangeUser(-1.5,1.5);
   rh4->SetTitle("");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);
   rh4->GetYaxis()->SetTitle("< #delta p_{t} / p_{t} > [%]");
   rh4->GetXaxis()->SetTitleSize(0.07);
   rh4->GetXaxis()->SetTitleOffset(0.6);
   rh4->GetXaxis()->SetTitle("#eta");

     
   plot4histos(canvas,
	       sh1,rh1,sh2,rh2,
	       sh3,rh3,sh4,rh4,    
	       te,"UU",-1);
   
   canvas->cd();   
   l = new TLegend(0.20,0.48,0.90,0.53);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("tuning.pdf");
   delete l;
   

   //===== pulls
   rdir->GetObject(collname1+"/pullPt",rh1);
   sdir->GetObject(collname2+"/pullPt",sh1);

   rdir->GetObject(collname1+"/pullQoverp",rh2);
   sdir->GetObject(collname2+"/pullQoverp",sh2);

   rdir->GetObject(collname1+"/pullPhi",rh3);

   sdir->GetObject(collname2+"/pullPhi",sh3);

   rdir->GetObject(collname1+"/pullTheta",rh4);
   sdir->GetObject(collname2+"/pullTheta",sh4);

   rdir->GetObject(collname1+"/pullDxy",rh5);
   sdir->GetObject(collname2+"/pullDxy",sh5);

   rdir->GetObject(collname1+"/pullDz",rh6);
   sdir->GetObject(collname2+"/pullDz",sh6);


   canvas = new TCanvas("Tracks4","Tracks: pull of Pt, Qoverp and Phi",1000,1400);

   NormalizeHistograms(rh1,sh1);
   NormalizeHistograms(rh2,sh2);
   NormalizeHistograms(rh3,sh3);
   NormalizeHistograms(rh4,sh4);
   NormalizeHistograms(rh5,sh5);
   NormalizeHistograms(rh6,sh6);

   rh1->GetXaxis()->SetRangeUser(-10,10);
   sh1->GetXaxis()->SetRangeUser(-10,10);
   rh2->GetXaxis()->SetRangeUser(-10,10);
   sh2->GetXaxis()->SetRangeUser(-10,10);
   rh3->GetXaxis()->SetRangeUser(-10,10);
   sh3->GetXaxis()->SetRangeUser(-10,10);
   rh4->GetXaxis()->SetRangeUser(-10,10);
   sh4->GetXaxis()->SetRangeUser(-10,10);
   rh5->GetXaxis()->SetRangeUser(-10,10);
   sh5->GetXaxis()->SetRangeUser(-10,10);
   rh6->GetXaxis()->SetRangeUser(-10,10);
   sh6->GetXaxis()->SetRangeUser(-10,10);


   plotPulls(canvas,
	     sh1,rh1,sh2,rh2,
	     sh3,rh3,sh4,rh4,
	     sh5,rh5,sh6,rh6,
	     te,"UU",-1);

   canvas->cd();

   l = new TLegend(0.20,0.655,0.80,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("pulls.pdf");
   delete l;




   

   //===== resolutions vs eta
   rdir->GetObject(collname1+"/phires_vs_eta_Sigma",rh1);
   sdir->GetObject(collname2+"/phires_vs_eta_Sigma",sh1);

   rdir->GetObject(collname1+"/cotThetares_vs_eta_Sigma",rh2);
   sdir->GetObject(collname2+"/cotThetares_vs_eta_Sigma",sh2);

   rdir->GetObject(collname1+"/dxyres_vs_eta_Sigma",rh3);
   sdir->GetObject(collname2+"/dxyres_vs_eta_Sigma",sh3);

   rdir->GetObject(collname1+"/dzres_vs_eta_Sigma",rh4);
   sdir->GetObject(collname2+"/dzres_vs_eta_Sigma",sh4);

   rdir->GetObject(collname1+"/ptres_vs_eta_Sigma",rh5);
   sdir->GetObject(collname2+"/ptres_vs_eta_Sigma",sh5);



   canvas = new TCanvas("Tracks7","Tracks: Dxy, Dz, Theta resolution",1000,1400);

   plotResolutions(canvas,
		   sh1,rh1,sh2,rh2,
		   sh3,rh3,sh4,rh4,
		   sh5,rh5,sh6,rh6,
		   te,"UU",-1);
   
   // new general range
   rh1->GetYaxis()->SetRangeUser(0.000009,0.01);
   sh1->GetYaxis()->SetRangeUser(0.000009,0.01);

   rh1->SetTitle(""); 
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);
   //   rh1->GetYaxis()->SetTitleColor(2);
   rh1->GetYaxis()->SetTitle("#sigma(#delta #phi) [rad]");
   rh1->GetXaxis()->SetTitleSize(0.07);
   rh1->GetXaxis()->SetTitleOffset(0.6);
   rh1->GetXaxis()->SetTitle("#eta");


   // new general range
   rh2->GetYaxis()->SetRangeUser(0.00009,0.03);
   sh2->GetYaxis()->SetRangeUser(0.00009,0.03);
   // for multi-track samples
   //rh2->GetYaxis()->SetRangeUser(0.0009,0.01);
   //sh2->GetYaxis()->SetRangeUser(0.0009,0.01);
   // for single particle pt 10
   //rh2->GetYaxis()->SetRangeUser(0.00009,0.01);
   //sh2->GetYaxis()->SetRangeUser(0.00009,0.01);
   // for single particle pt 1
   //rh2->GetYaxis()->SetRangeUser(0.0009,0.01);
   //sh2->GetYaxis()->SetRangeUser(0.0009,0.01);
   rh2->SetTitle("");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);
   rh2->GetYaxis()->SetTitle("#sigma(#delta cot(#theta)) ");
   rh2->GetXaxis()->SetTitleSize(0.07);
   rh2->GetXaxis()->SetTitleOffset(0.6);
   rh2->GetXaxis()->SetTitle("#eta");


   // new general range
   rh3->GetYaxis()->SetRangeUser(0.00009,0.05);  
   sh3->GetYaxis()->SetRangeUser(0.00009,0.05);
   // for multi-track samples
   //rh3->GetYaxis()->SetRangeUser(0.0009,0.02);  
   //sh3->GetYaxis()->SetRangeUser(0.0009,0.02);
   //rh3->GetYaxis()->SetRangeUser(0.0009,0.02);
   //sh3->GetYaxis()->SetRangeUser(0.0009,0.02);
   // for single particle pt 100    
   //rh3->GetYaxis()->SetRangeUser(0.00009,0.002);
   //sh3->GetYaxis()->SetRangeUser(0.00009,0.002);
   rh3->SetTitle("");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);
   rh3->GetYaxis()->SetTitle("#sigma(#delta d_{0}) [cm]");
   rh3->GetXaxis()->SetTitleSize(0.07);
   rh3->GetXaxis()->SetTitleOffset(0.6);
   rh3->GetXaxis()->SetTitle("#eta"); 


   // new general range
   rh4->GetYaxis()->SetRangeUser(0.0009,0.1);  
   sh4->GetYaxis()->SetRangeUser(0.0009,0.1);
   // for multi-track samples
   //rh4->GetYaxis()->SetRangeUser(0.0009,0.08);
   //sh4->GetYaxis()->SetRangeUser(0.0009,0.08);

   rh4->SetTitle("");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);
   rh4->GetYaxis()->SetTitle("#sigma(#delta z_{0}) [cm]");
   rh4->GetXaxis()->SetTitleSize(0.07);
   rh4->GetXaxis()->SetTitleOffset(0.6);
   rh4->GetXaxis()->SetTitle("#eta");

   rh5->SetTitle("");
   rh5->GetYaxis()->SetTitleSize(0.05);
   rh5->GetYaxis()->SetTitleOffset(1.2);
   rh5->GetYaxis()->SetTitle("#sigma(#delta p_{t}/p_{t}) ");
   rh5->GetXaxis()->SetTitleSize(0.07);
   rh5->GetXaxis()->SetTitleOffset(0.6);
   rh5->GetXaxis()->SetTitle("#eta");



   /* plotResolutions(canvas,
	     sh1,rh1,sh2,rh2,
	     sh3,rh3,sh4,rh4,
	     sh5,rh5,sh6,rh6,
	     te,"UU",-1);
   */
   canvas->cd();

   l = new TLegend(0.10,0.63,0.90,0.67);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("resolutionsEta.pdf");
   delete l;

   //===== resolutions vs pt
   rdir->GetObject(collname1+"/phires_vs_pt_Sigma",rh1);
   sdir->GetObject(collname2+"/phires_vs_pt_Sigma",sh1);

   rdir->GetObject(collname1+"/cotThetares_vs_pt_Sigma",rh2);
   sdir->GetObject(collname2+"/cotThetares_vs_pt_Sigma",sh2);


   rdir->GetObject(collname1+"/dxyres_vs_pt_Sigma",rh3);
   sdir->GetObject(collname2+"/dxyres_vs_pt_Sigma",sh3);

   rdir->GetObject(collname1+"/dzres_vs_pt_Sigma",rh4);
   sdir->GetObject(collname2+"/dzres_vs_pt_Sigma",sh4);

   rdir->GetObject(collname1+"/ptres_vs_pt_Sigma",rh5);
   sdir->GetObject(collname2+"/ptres_vs_pt_Sigma",sh5);


   rh1->SetTitle("");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);
   rh1->GetYaxis()->SetTitle("#sigma(#delta #phi) [rad]");
   rh1->GetXaxis()->SetTitleSize(0.055);
   rh1->GetXaxis()->SetTitleOffset(0.8);
   rh1->GetXaxis()->SetTitle("p_{t}");
   rh1->GetXaxis()->SetRangeUser(0,1000.);
   sh1->GetXaxis()->SetRangeUser(0,1000.);
 

   rh2->SetTitle("");
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);
   rh2->GetYaxis()->SetTitle("#sigma(#delta cot(#theta)) ");
   rh2->GetXaxis()->SetTitleSize(0.055);
   rh2->GetXaxis()->SetTitleOffset(0.8);
   rh2->GetXaxis()->SetTitle("p_{t}");

   rh2->GetXaxis()->SetRangeUser(0,1000.);
   sh2->GetXaxis()->SetRangeUser(0,1000.);

   rh3->SetTitle("");
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);
   rh3->GetYaxis()->SetTitle("#sigma(#delta d_{0}) [cm]");
   rh3->GetXaxis()->SetTitleSize(0.055);
   rh3->GetXaxis()->SetTitleOffset(0.8);
   rh3->GetXaxis()->SetTitle("p_{t}");


   rh3->GetXaxis()->SetRangeUser(0,1000.);
   sh3->GetXaxis()->SetRangeUser(0,1000.);


   rh4->SetTitle("");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);
   rh4->GetYaxis()->SetTitle("#sigma(#delta z_{0}) [cm]");
   rh4->GetXaxis()->SetTitleSize(0.055);
   rh4->GetXaxis()->SetTitleOffset(0.8);
   rh4->GetXaxis()->SetTitle("p_{t}");

   rh4->GetXaxis()->SetRangeUser(0,1000.);
   sh4->GetXaxis()->SetRangeUser(0,1000.);


   rh5->SetTitle("");
   rh5->GetYaxis()->SetTitleSize(0.05);
   rh5->GetYaxis()->SetTitleOffset(1.2);
   rh5->GetYaxis()->SetTitle("#sigma(#delta p_{t}/p_{t}) ");
   rh5->GetXaxis()->SetTitleSize(0.055);
   rh5->GetXaxis()->SetTitleOffset(0.8);
   rh5->GetXaxis()->SetTitle("p_{t}");


   rh5->GetXaxis()->SetRangeUser(0,1000.);
   sh5->GetXaxis()->SetRangeUser(0,1000.);


   rh6->GetXaxis()->SetRangeUser(0,1000.);
   sh6->GetXaxis()->SetRangeUser(0,1000.);


   canvas = new TCanvas("Tracks7b","Tracks: Dxy, Dz, Theta resolution",1000,1400);

   plotResolutions(canvas,
	     sh1,rh1,sh2,rh2,
	     sh3,rh3,sh4,rh4,
	     sh5,rh5,sh6,rh6,
		   te,"UU",-1, true);

   canvas->cd();

   l = new TLegend(0.10,0.63,0.90,0.67);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("resolutionsPt.pdf");
   delete l;


    //===== building 2
   rdir->GetObject(collname1+"/effic_vs_phi",rh1);
   sdir->GetObject(collname2+"/effic_vs_phi",sh1);
   rh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rh1->GetXaxis()->SetTitle("#phi");
   rh1->GetYaxis()->SetTitle("efficiency vs #phi");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);
   rdir->GetObject(collname1+"/fakerate_vs_phi",rh2);
   sdir->GetObject(collname2+"/fakerate_vs_phi",sh2);
   rh2->GetXaxis()->SetTitle("#phi");
   rh2->GetYaxis()->SetTitle("fakerate vs #phi");
   rh2->GetYaxis()->SetRangeUser(0.,MAXFAKE);
   sh2->GetYaxis()->SetRangeUser(0.,MAXFAKE);
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);



   rdir->GetObject(collname1+"/effic_vs_dxy",rh3);
   sdir->GetObject(collname2+"/effic_vs_dxy",sh3);
   rh3->GetXaxis()->SetTitle("dxy");
   rh3->GetYaxis()->SetTitle("efficiency vs dxy");
   rh3->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh3->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rh3->GetYaxis()->SetTitleSize(0.05);
   rh3->GetYaxis()->SetTitleOffset(1.2);
   rh3->SetTitle("");
   rdir->GetObject(collname1+"/fakerate_vs_dxy",rh4);
   sdir->GetObject(collname2+"/fakerate_vs_dxy",sh4);
   rh4->SetTitle("");
   rh4->GetXaxis()->SetTitle("dxy");
   rh4->GetYaxis()->SetTitle("fakerate vs dxy");
   rh4->GetYaxis()->SetTitleSize(0.05);
   rh4->GetYaxis()->SetTitleOffset(1.2);
   rh4->GetYaxis()->SetRangeUser(0.,MAXFAKE);
   sh4->GetYaxis()->SetRangeUser(0.,MAXFAKE);


   rdir->GetObject(collname1+"/effic_vs_dz",rh5);
   sdir->GetObject(collname2+"/effic_vs_dz",sh5);
   rh5->GetXaxis()->SetTitle("dz");
   rh5->GetYaxis()->SetTitle("efficiency vs dz");
   rh5->GetYaxis()->SetTitleSize(0.05);
   rh5->GetYaxis()->SetTitleOffset(1.2);
   rh5->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh5->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rdir->GetObject(collname1+"/fakerate_vs_dz",rh6);
   sdir->GetObject(collname2+"/fakerate_vs_dz",sh6);
   rh6->GetYaxis()->SetRangeUser(0.,1.0);
   rh6->GetYaxis()->SetRangeUser(0.,1.0);
   rh6->GetXaxis()->SetTitle("dz");
   rh6->GetYaxis()->SetTitle("fakerate vs dz");
   rh6->GetYaxis()->SetTitleSize(0.05);
   rh6->GetYaxis()->SetTitleOffset(1.2);

   canvas = new TCanvas("Tracks8","Tracks: efficiency & fakerate",1000,1400);

   TH1F * r[6]={rh1,rh2,rh3,rh4,rh5,rh6};
   TH1F * s[6]={sh1,sh2,sh3,sh4,sh5,sh6};

   plotBuilding(canvas,s, r,6,
		te,"UU",-1);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("building2.pdf");   
   delete l;

    //===== building 3
   rdir->GetObject(collname1+"/effic_vs_vertpos",rh1);
   sdir->GetObject(collname2+"/effic_vs_vertpos",sh1);
   rh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh1->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rh1->GetXaxis()->SetTitle("TP vert xy pos");
   rh1->GetYaxis()->SetTitle("efficiency vs vert xy pos");
   rh1->GetYaxis()->SetTitleSize(0.05);
   rh1->GetYaxis()->SetTitleOffset(1.2);

   rdir->GetObject(collname1+"/effic_vs_zpos",rh2);
   sdir->GetObject(collname2+"/effic_vs_zpos",sh2);
   rh2->GetXaxis()->SetTitle("TP vert z pos");
   rh2->GetYaxis()->SetTitle("efficiency vs  vert z pos");
   rh2->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   sh2->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
   rh2->GetYaxis()->SetTitleSize(0.05);
   rh2->GetYaxis()->SetTitleOffset(1.2);
   rh2->SetTitle("");

   canvas = new TCanvas("Tracks9","Tracks: efficiency & fakerate",1000,1400);

   TH1F * r[2]={rh1,rh2};
   TH1F * s[2]={sh1,sh2};

   plotBuilding(canvas,s, r,2,
		te,"UU",-1);

   canvas->cd();
   l = new TLegend(0.10,0.14,0.90,0.19);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(rh1,refLabel,"LPF");
   l->AddEntry(sh1,newLabel,"LPF");
   l->Draw();
   canvas->Print("building3.pdf");   
   delete l;

   //======== plots of eff, fake rates for various iterative tracking steps
   //== we assume that the ref and new have the same histogram list! (and there are 6!)
   // HERE
//   TString refcollname=rl->At(0)->GetName();
//   TString newcollname=sl->At(0)->GetName();
//   num_col = rl->GetSize();
   TH1F * r[6];
   TH1F * s[6];
//   // eff vs eta
//   for(int i=0; i<num_col;i++){
//     refcollname =rl->At(i)->GetName();
//     newcollname =sl->At(i)->GetName();
//     rdir->GetObject(refcollname+"/effic",r[i]);
//     sdir->GetObject(newcollname+"/effic",s[i]);
//     //r[i]->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
//     //s[i]->GetYaxis()->SetRangeUser(MINEFF,MAXEFF);
//     r[i]->GetYaxis()->SetRangeUser(0.,MAXEFF);
//     s[i]->GetYaxis()->SetRangeUser(0.,MAXEFF);
//     r[i]->GetXaxis()->SetTitle("#eta");
//     r[i]->GetYaxis()->SetTitle("efficiency vs #eta");
//     r[i]->GetYaxis()->SetTitleSize(0.05);
//     r[i]->GetYaxis()->SetTitleOffset(1.2);
//     r[i]->SetTitle(refcollname);
//     if(i==2 || i==3) {
//       //r[i]->SetTitleY(0.);
//       //r[i]->SetTitle("");
//       r[i]->SetTitleOffset(-1.,"HIST");
//     }
//   }
   // fill with the histos we want for eff
   fillStepHisto(rdir, sdir, rl, sl, r, s, "/effic", "#eta", "efficiency vs #eta", 0., MAXEFF);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks10","Tracks: efficiency for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_eff.pdf");   
   delete l;

   // fill with the histos we want for fake rate
   fillStepHisto(rdir, sdir, rl, sl, r, s, "/fakerate", "#eta", "fakerate vs #eta", 0., MAXFAKE);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks11","Tracks: fakerate for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_fakerate.pdf");   
   delete l;

   // fill with the histos we want for eff vs pT
   fillStepHisto(rdir, sdir, rl, sl, r, s, "/efficPt", "p_{t}", "efficiency vs p_{t}", 0., MAXEFF);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks12","Tracks: efficiency for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69, 1, false, 127);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_effpt.pdf");   
   delete l;

   fillStepHisto(rdir, sdir, rl, sl, r, s, "/fakeratePt", "p_{t}", "fakerate vs p_{t}", 0., MAXFAKE);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks13","Tracks: fakerate for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69, 1, false, 127);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_fakeratePt.pdf");   
   delete l;

   // fill with the histos we want for eff
   fillStepHisto(rdir, sdir, rl, sl, r, s, "/effic_vs_hit", "hits", "efficiency vs hits", 0., MAXEFF);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks14","Tracks: efficiency for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_effhits.pdf");   
   delete l;

   // fill with the histos we want for fake rate
   fillStepHisto(rdir, sdir, rl, sl, r, s, "/fakerate_vs_hit", "hits", "fakerate vs hits", 0., MAXFAKE);
   // rearrange to a more natural order for plotting
   TH1F * rr[6]={r[5],r[2],r[0],r[3],r[4],r[1]};
   TH1F * ss[6]={s[5],s[2],s[0],s[3],s[4],s[1]};

   canvas = new TCanvas("Tracks15","Tracks: fakerate for each step",1000,1400);

   plotBuilding(canvas,ss, rr,6,
		te,"UU",-69);

   canvas->cd();
   l = new TLegend(0.10,0.64,0.90,0.69);
   l->SetTextSize(0.016);
   l->SetLineColor(1);
   l->SetLineWidth(1);
   l->SetLineStyle(1);
   l->SetFillColor(0);
   l->SetBorderSize(3);
   l->AddEntry(r[0],refLabel,"LPF");
   l->AddEntry(s[0],newLabel,"LPF");
   l->Draw();
   canvas->Print("steps_fakeratehits.pdf");   
   delete l;

 }
}