Updates in plot macros.
authorakalweit <Alexander.Philipp.Kalweit@cern.ch>
Fri, 7 Mar 2014 13:49:16 +0000 (14:49 +0100)
committerakalweit <Alexander.Philipp.Kalweit@cern.ch>
Fri, 7 Mar 2014 13:49:16 +0000 (14:49 +0100)
PWGPP/EvTrkSelection/macros/MakeSensitivityPlots.C
PWGPP/EvTrkSelection/macros/MatchingEffPlots.C [new file with mode: 0644]

index 5fdd881..5410ac4 100644 (file)
@@ -7,36 +7,53 @@
 #include "TLegend.h"
 #include "TLatex.h"
 
-void MakeSensitivityPlots();
+//loadlibs();
+//gSystem->Load("libANALYSIS");
+//gSystem->Load("libANALYSISalice");
+//#include "AliESDtrackCuts.h"
+
+void MakeSensitivityPlots2();
 //
 TCanvas * GetSensitivityPlot(TString cutname = "Ncl",  
                             Int_t projectionAxis = 1,
                             Int_t particleType = 5,
                             Double_t lowCut = 80.,
                             Double_t highCut = 1e4, 
-                            TString inFileNameData = "output/LHC10b_data.root", 
-                            TString inFileNameMC = "output/LHC10b_MC.root");
+                            TString inFileNameData = "data_LHC10d.root",
+                            TString inFileNameMC = "mc_LHC10d.root");
 //
 TH1D   * GetAcceptedFraction(TString cutname = "Ncl",  
                             Int_t projectionAxis = 1,
                             Int_t particleType = 5,
                             Double_t lowCut = 80.,
                             Double_t highCut = 1e4, 
-                            TString inFileName = "output/LHC10b_data.root");
+                            TString inFileName = "data_LHC10d.root");
+//
+void PrintCutGallery(TString inFileNameData = "data_LHC10d.root",
+                    TString inFileNameMC   = "mc_LHC10d.root",
+                    TString outFileName    = "plots/10d.pdf");
+
+//
+TH1D *GetITSTPCMatchingEff(TString inFileNameData = "data_LHC10d.root",
+                              Int_t particleType = 5,
+                              Int_t projectionAxis = 1);
+
 //
-void PrintCutGallery(TString inFileNameData = "output/LHC10b_data.root", 
-                    TString inFileNameMC   = "output/LHC10b_MC.root", 
-                    TString outFileName    = "plots/10b.pdf");
+TH1D *GetITSTPCMatchingHisto(TString inFileNameData = "data_LHC10d.root",
+                             Int_t particleType = 5,
+                             Bool_t isMatched = kTRUE,
+                             Int_t projectionAxis = 1);
+
 
 //______________________________________________________________________________
-void MakeSensitivityPlots() {
+void MakeSensitivityPlots2() {
   //
   // make all the senstivity plots
   //
-  PrintCutGallery("output/LHC10b_data.root", "output/LHC10b_MC.root", "plots/10b.pdf");
-  PrintCutGallery("output/LHC10d_data.root", "output/LHC10d_MC.root", "plots/10d.pdf");
-  PrintCutGallery("output/LHC10e_data.root", "output/LHC10e_MC.root", "plots/10e.pdf");
-  PrintCutGallery("output/LHC10h_data.root", "output/LHC10h_MC.root", "plots/10h.pdf");
+  //PrintCutGallery("output/LHC10b_data.root", "output/LHC10b_MC.root", "plots/10b.pdf");
+  PrintCutGallery("data_LHC10d.root", "mc_LHC10d.root", "plots/10d.pdf");
+  //PrintCutGallery("output/LHC10e_data.root", "output/LHC10e_MC.root", "plots/10e.pdf");
+  //PrintCutGallery("output/LHC10h_data.root", "output/LHC10h_MC.root", "plots/10h.pdf");
 
 }
 
@@ -221,3 +238,72 @@ TH1D * GetAcceptedFraction(TString cutname,
 
   
 }
+
+//______________________________________________________________________________
+TH1D *GetITSTPCMatchingEff(TString inFileNameData,
+                              Int_t particleType,
+                              Int_t projectionAxis){
+    
+    //
+    // make a single plot
+    //
+    TH1D * hMatching = GetITSTPCMatchingHisto(inFileNameData, particleType, kTRUE, projectionAxis);
+    hMatching->SetNameTitle(Form("PID: %d\t proj: %d",particleType,projectionAxis), Form("PID: %d\t proj: %d",particleType,projectionAxis));
+    hMatching->Sumw2();
+    //
+    TH1D *hNoMatching = GetITSTPCMatchingHisto(inFileNameData, particleType, kFALSE, projectionAxis);
+    hNoMatching->SetNameTitle(Form("PID: %d\t proj: %d",particleType,projectionAxis), Form("PID: %d\t proj: %d",particleType,projectionAxis));
+    hNoMatching->Sumw2();
+    //
+    hMatching->Divide(hMatching,hNoMatching,1,1,"B");
+    
+    //TCanvas * canvEff = new TCanvas("canvEff","matching efficiency",600,600);
+    //hMatching->Draw();
+    
+    return hMatching;
+    
+    
+}
+
+
+
+//______________________________________________________________________________
+TH1D *GetITSTPCMatchingHisto(TString inFileNameData,
+                             Int_t particleType,
+                             Bool_t isMatched,
+                             Int_t projectionAxis){
+    
+  //
+  // ITS-TPC matching histograms as a funct. of pT, eta, phi, for each species
+  //    
+  TFile * inFileData = TFile::Open(inFileNameData);
+  TList * l = (TList * ) inFileData->Get("akalweit_TrackingUncert");
+  THnF * histITSTPC = (THnF *) l->FindObject("histTpcItsMatch");
+
+  //
+  // select particleType
+  //
+  histITSTPC->GetAxis(4)->SetRangeUser(particleType, particleType);
+
+  //
+  // extract isMatched = kFALSE or kTRUE
+  //
+  if(isMatched)
+    histITSTPC->GetAxis(0)->SetRangeUser(1,1);
+  else
+    histITSTPC->GetAxis(0)->SetRangeUser(0,0);
+  
+  TH1D * hProj  = histITSTPC->Projection(projectionAxis);
+  hProj->SetDirectory(0);
+  hProj->SetNameTitle(Form("h%d",projectionAxis),Form("h%d",projectionAxis));
+    
+  //
+  delete l;
+  inFileData->Close();
+  //
+    
+    
+  return hProj;
+  
+    
+}
diff --git a/PWGPP/EvTrkSelection/macros/MatchingEffPlots.C b/PWGPP/EvTrkSelection/macros/MatchingEffPlots.C
new file mode 100644 (file)
index 0000000..6d17dec
--- /dev/null
@@ -0,0 +1,282 @@
+/*
+
+
+gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/ -I$ALICE_ROOT/include");
+gSystem->Load("libANALYSIS");
+gSystem->Load("libANALYSISalice");
+.L MakeSensitivityPlots.C++g 
+ .L MatchingEffPlots.C++g
+MatchingEffPlots()
+
+
+ */
+
+#include "TH1D.h"
+#include "TCanvas.h"
+#include "TFile.h"
+#include "THn.h"
+#include "TList.h"
+#include "TStyle.h"
+#include "TLegend.h"
+#include "TLatex.h"
+#include "MakeSensitivityPlots.C"
+
+const int pid = 1;      // pid = 1 —> pions, pid = 2 —> kaons, pid = 3 —> protons, pid = 5 —> unidentified
+
+//const char
+
+void MatchingEffPlots(){
+    
+  //gROOT->LoadMacro("ll.C");
+  //    gROOT->LoadMacro("MakeSensitivityPlots2.C++");
+  
+  // ll();
+    
+    TCanvas *c[3];
+    TCanvas *c2[3];
+    const Char_t *proj[3] = {"pT","eta","phi"};
+    
+    TH1D *data[4];
+    TH1D *mc[4];
+    
+    TH1D *ratio[4];
+    
+    char dataset[5] = "bcde";
+
+    for(Int_t i=0;i<3;i++){     //loop over the projections: pT, eta, phi
+    
+        c[i] = new TCanvas(Form("%s",proj[i]),Form("%s",proj[i]),1000,1000);
+        gStyle->SetOptStat(0);
+        c[i]->Divide(2,2);
+    
+        for(Int_t k=0;k<4;k++){     //loop over the periods: LHC10b,10c,10d,10e
+            c[i]->cd(k+1);
+            
+            TString dataFile = Form("data_LHC10%c.root",dataset[k]);
+            TString mcFile = Form("mc_LHC10%c.root",dataset[k]);
+            
+            data[k] = (TH1D*)GetITSTPCMatchingEff(dataFile/*dataFile.Data()*/,pid,i+1);
+            mc[k]   = (TH1D*)GetITSTPCMatchingEff(mcFile/*mcFile.Data()*/,pid,i+1);
+            data[k]->Draw("Ep");
+            data[k]->SetTitle(Form("LHC10%c",dataset[k]));
+            if (i==0) data[k]->GetXaxis()->SetTitle("#it{p}_{T}");
+            if (i==1) data[k]->GetXaxis()->SetTitle("#eta");
+            if (i==2) data[k]->GetXaxis()->SetTitle("#varphi");
+        
+            data[k]->SetLineColor(kRed-3);
+            mc[k]->Draw("Ep,same");
+            mc[k]->SetLineColor(kBlue-3);
+            data[k]->SetMaximum(1);
+        
+            if(i==0){
+                gPad->SetLogx();
+            }
+        
+            if(i==1||i==0){
+                data[k]->SetMinimum(.8);
+            }
+        
+            TLegend *leg = new TLegend(0.15,0.15,.35,0.25);
+            leg->AddEntry(data[k],"Data","f");
+            leg->AddEntry(mc[k],"MC","f");
+            leg->SetBorderSize(0);
+            leg->SetFillColor(0);
+            leg->Draw();
+        }
+        
+        c2[i] = new TCanvas(Form("ratio%s",proj[i]),Form("ratio%s",proj[i]),1000,1000);
+        gStyle->SetOptStat(0);
+        c2[i]->Divide(2,2);
+        
+        for(Int_t k=0;k<4;k++){     //loop over the periods: LHC10b,10c,10d,10e
+            c2[i]->cd(k+1);
+            
+            TString dataFile = Form("data_LHC10%c.root",dataset[k]);
+            TString mcFile = Form("mc_LHC10%c.root",dataset[k]);
+            
+            data[k] = (TH1D*)GetITSTPCMatchingEff(dataFile.Data(),pid,i+1);
+            mc[k]   = (TH1D*)GetITSTPCMatchingEff(mcFile.Data(),pid,i+1);
+            ratio[k] = (TH1D*)data[k]->Clone();
+            ratio[k]->Reset();
+            ratio[k]->Divide(data[k],mc[k],1,1);
+            ratio[k]->Draw("");
+            ratio[k]->SetTitle(Form("LHC10%c",dataset[k]));
+            if (i==0) ratio[k]->GetXaxis()->SetTitle("#it{p}_{T}");
+            if (i==1) ratio[k]->GetXaxis()->SetTitle("#eta");
+            if (i==2) ratio[k]->GetXaxis()->SetTitle("#varphi");
+            
+            ratio[k]->SetLineColor(kBlack);
+            //ratio[k]->SetMaximum(1);
+            
+            if(i==0){
+                gPad->SetLogx();
+            }
+            
+            if(i==1||i==0){
+                //data[k]->SetMinimum(.8);
+            }
+            
+            TLegend *leg = new TLegend(0.15,0.15,.35,0.25);
+            leg->AddEntry(ratio[k],"Data/MC","f");
+            //leg->AddEntry(mc[k],"MC","f");
+            leg->SetBorderSize(0);
+            leg->SetFillColor(0);
+            leg->Draw();
+        }
+    }
+
+        
+}
+        
+    /*    c[i]->cd(2);
+        gStyle->SetOptStat(0);
+
+        TH1D * data_10c = GetITSTPCMatchingEff("data_LHC10c.root",pid,i+1);
+        TH1D * mc_10c   = GetITSTPCMatchingEff("mc_LHC10c.root",pid,i+1);
+        data_10c->Draw("");
+        data_10c->SetTitle("LHC10c");
+        if (i==0) data_10c->GetXaxis()->SetTitle("#it{p}_{T}");
+        if (i==1) data_10c->GetXaxis()->SetTitle("#eta");
+        if (i==2) data_10c->GetXaxis()->SetTitle("#varphi");
+        //data_10c->SetMarkerStyle(20);
+        data_10c->SetLineColor(kRed-3);
+        mc_10c->Draw("same");
+        //mc_10c->SetMarkerStyle(20);
+        mc_10c->SetLineColor(kBlue-3);
+        data_10c->SetMaximum(1);
+        
+        if(i==0){
+            gPad->SetLogx();
+        }
+        
+        if(i==1||i==0){
+            data_10c->SetMinimum(.8);
+            
+        }
+        
+        TLegend *leg = new TLegend(0.15,0.2,.35,0.3);
+        leg->AddEntry(data_10c,"Data","f");
+        leg->AddEntry(mc_10c,"MC","f");
+        leg->SetBorderSize(0);
+        gStyle->SetFillColor(0);
+        leg->Draw();
+        
+        c[i]->cd(3);
+        gStyle->SetOptStat(0);
+
+        TH1D * data_10d = GetITSTPCMatchingEff("data_LHC10d.root",pid,i+1);
+        TH1D * mc_10d   = GetITSTPCMatchingEff("mc_LHC10d.root",pid,i+1);
+        data_10d->Draw("");
+        data_10d->SetTitle("LHC10d");
+        if (i==0) data_10d->GetXaxis()->SetTitle("#it{p}_{T}");
+        if (i==1) data_10d->GetXaxis()->SetTitle("#eta");
+        if (i==2) data_10d->GetXaxis()->SetTitle("#varphi");
+        //data_10d->SetMarkerStyle(20);
+        data_10d->SetLineColor(kRed-3);
+        mc_10d->Draw("same");
+        //mc_10d->SetMarkerStyle(20);
+        mc_10d->SetLineColor(kBlue-3);
+        data_10d->SetMaximum(1);
+        
+        if(i==0){
+            gPad->SetLogx();
+        }
+        
+        if(i==1||i==0){
+            data_10d->SetMinimum(.8);
+            
+        }
+        
+        TLegend *leg = new TLegend(0.15,0.2,.35,0.3);
+        leg->AddEntry(data_10d,"Data","f");
+        leg->AddEntry(mc_10d,"MC","f");
+        leg->SetBorderSize(0);
+        gStyle->SetFillColor(0);
+        leg->Draw();
+        
+
+        c[i]->cd(4);
+        gStyle->SetOptStat(0);
+
+        TH1D * data_10e = GetITSTPCMatchingEff("data_LHC10e.root",pid,i+1);
+        TH1D * mc_10e   = GetITSTPCMatchingEff("mc_LHC10e.root",pid,i+1);
+        data_10e->Draw("");
+        data_10e->SetTitle("LHC10e");
+        if (i==0) data_10e->GetXaxis()->SetTitle("#it{p}_{T}");
+        if (i==1) data_10e->GetXaxis()->SetTitle("#eta");
+        if (i==2) data_10e->GetXaxis()->SetTitle("#varphi");
+        //data_10e->SetMarkerStyle(20);
+        data_10e->SetLineColor(kRed-3);
+        mc_10e->Draw("same");
+        //mc_10e->SetMarkerStyle(20);
+        mc_10e->SetLineColor(kBlue-3);
+        data_10e->SetMaximum(1);
+        
+        if(i==0){
+            gPad->SetLogx();
+        }
+        
+        if(i==1 || i==0){
+            data_10e->SetMinimum(.8);
+            
+        }
+        
+        TLegend *leg = new TLegend(0.15,0.2,.35,0.3);
+        leg->AddEntry(data_10e,"Data","f");
+        leg->AddEntry(mc_10e,"MC","f");
+        leg->SetBorderSize(0);
+        gStyle->SetFillColor(0);
+        leg->Draw(); */
+        
+
+  /*  }
+    
+    for(Int_t i=0;i<3;i++){     //loop over the projections: pT, eta, phi
+
+        c2[i] = new TCanvas(Form("ratio%s",proj[i]),Form("ratio%s",proj[i]),1000,1000);
+        gStyle->SetOptStat(0);
+        c2[i]->Divide(2,2);
+
+    
+        for(Int_t k=0;k<4;k++){     //loop over the periods: LHC10b,10c,10d,10e
+            c2[i]->cd(k+1);
+        
+            TString dataFile = Form("data_LHC10%c.root",dataset[k]);
+            TString mcFile = Form("mc_LHC10%c.root",dataset[k]);
+        
+            data[k] = (TH1D*)GetITSTPCMatchingEff(dataFile.Data(),pid,i+1);
+            mc[k]   = (TH1D*)GetITSTPCMatchingEff(mcFile.Data(),pid,i+1);
+            ratio[k] = (TH1D*)data[k]->Clone();
+            ratio[k]->Reset();
+            ratio[k]->Divide(data[k],mc[k],1,1);
+            ratio[k]->Draw("");
+            ratio[k]->SetTitle(Form("LHC10%c",dataset[k]));
+            if (i==0) ratio[k]->GetXaxis()->SetTitle("#it{p}_{T}");
+            if (i==1) ratio[k]->GetXaxis()->SetTitle("#eta");
+            if (i==2) ratio[k]->GetXaxis()->SetTitle("#varphi");
+        
+            ratio[k]->SetLineColor(kBlack);
+            //ratio[k]->SetMaximum(1);
+        
+            if(i==0){
+                gPad->SetLogx();
+            }
+        
+            if(i==1||i==0){
+                //data[k]->SetMinimum(.8);
+            }
+        
+            TLegend *leg = new TLegend(0.15,0.15,.35,0.25);
+            leg->AddEntry(ratio[k],"Data/MC","f");
+            //leg->AddEntry(mc[k],"MC","f");
+            leg->SetBorderSize(0);
+            leg->SetFillColor(0);
+            leg->Draw();
+        }
+
+    
+    //for identified: only vs pT
+    
+    }
+}*/