]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG1/TRD/AliTRDefficiency.cxx
bug corrected
[u/mrichter/AliRoot.git] / PWG1 / TRD / AliTRDefficiency.cxx
index efc0574138748ec92985af698a3a6b435fec83bb..6ade10f4cd144eb9832b57a57b3bf5c3917d84bf 100644 (file)
@@ -28,6 +28,7 @@
 #include <TObjArray.h>
 #include <TProfile.h>
 #include <TPad.h>
+#include <TLegend.h>
 #include "TTreeStream.h"
 
 #include "AliPID.h"
@@ -81,20 +82,20 @@ void  AliTRDefficiency::UserCreateOutputObjects()
   // Create output objects
   //
 
-  OpenFile(1, "RECREATE");
   const Int_t nbins = AliTRDCalPID::kNMom;
   Float_t xbins[nbins+1] = {.5, .7, .9, 1.3, 1.7, 2.4, 3.5, 4.5, 5.5, 7., 9., 11.};
 
   TH1 *h = NULL;
-  fContainer = new TObjArray();
+  fContainer = new TObjArray(); fContainer->SetOwner();
   for(Int_t is=0; is<AliPID::kSPECIES; is++){
-    fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), "", nbins, xbins));
+    fContainer->Add(h = new TProfile(Form("h%s", AliTRDCalPID::GetPartSymb(is)), AliPID::ParticleShortName(is), nbins, xbins));
     h->SetLineColor(AliTRDCalPID::GetPartColor(is));
     h->SetMarkerColor(AliTRDCalPID::GetPartColor(is));
-    h->SetMarkerStyle(7);
+    h->SetMarkerStyle(24);
   }
   fContainer->Add(h = new TProfile("h", "", nbins, xbins));
   h->SetMarkerStyle(7);
+  PostData(1, fContainer);
 } 
 
 //____________________________________________________________________
@@ -107,6 +108,10 @@ void AliTRDefficiency::UserExec(Option_t *)
   Int_t labelsacc[10000]; 
   memset(labelsacc, 0, sizeof(Int_t) * 10000);
        
+  fTracks = dynamic_cast<TObjArray *>(GetInputData(1));
+  if(!fTracks) return;
+  if(!fTracks->GetEntriesFast()) return;
+  else AliDebug(2, Form("Tracks[%d] for %s", fTracks->GetEntriesFast(), GetName()));
   if(!fMissed){ 
     fMissed = new TClonesArray("AliTRDtrackInfo", 10);
     fMissed->SetOwner();
@@ -138,6 +143,7 @@ void AliTRDefficiency::UserExec(Option_t *)
     mom  = ref ? ref->P(): esd->P();
     pidx = AliTRDCalPID::GetPartIndex(track->GetPDG());
     pidx = TMath::Max(pidx, 0);
+    AliDebug(4, Form("PID: %d", pidx));
 
     //Int_t n = track->GetNumberOfClusters(); 
     // where are this tracklets ???
@@ -261,7 +267,6 @@ void AliTRDefficiency::UserExec(Option_t *)
        for(Int_t itk = 0; itk < nTRD - 1; itk++)
                if(labelsacc[indices[itk]] ==labelsacc[indices[itk + 1]]) printf("Double counted MC track: %d\n", labelsacc[indices[itk]]);
        }
-  PostData(1, fContainer);
 }
 
 
@@ -276,34 +281,49 @@ Bool_t AliTRDefficiency::GetRefFigure(Int_t ifig)
   }
   gPad->SetLogx();
 
-  Bool_t bFIRST = kTRUE;
-  TProfile *h = NULL;
+  TLegend *leg(NULL);
+  Bool_t bFIRST(kTRUE);
+  TProfile *h(NULL);
   switch(ifig){
   case 0:
     h = (TProfile*)fContainer->At(AliPID::kSPECIES);
     for(Int_t is=0; is<AliPID::kSPECIES; is++){
       h->Add((TProfile*)fContainer->At(is));
     }
+    h->SetMarkerStyle(24);
     h->SetMarkerColor(kBlack);
     h->SetLineColor(kBlack);
     h->SetTitle("TRD Efficiency integrated");
-    h->GetXaxis()->SetTitle("p [GeV/c]");
+    h->SetXTitle("p [GeV/c]");
     h->GetXaxis()->SetMoreLogLabels();
-    h->GetYaxis()->SetTitle("Efficiency");
+    h->SetYTitle("Efficiency");
+    h->GetYaxis()->CenterTitle();
     h->Draw("e1");
     break;
   case 1:
     bFIRST = kTRUE;
     for(Int_t is=0; is<AliPID::kSPECIES; is++){
       if(!(h = (TProfile*)fContainer->At(is))) continue;
+      h->SetMarkerStyle(24);
       if(bFIRST){
         h->Draw("e1");
-        h->GetXaxis()->SetTitle("p [GeV/c]");
+        h->SetXTitle("p [GeV/c]");
         h->GetXaxis()->SetMoreLogLabels();
-        h->GetYaxis()->SetTitle("Efficiency");
-      } else h->Draw("same e1");
+        h->SetYTitle("Efficiency");
+        h->GetYaxis()->CenterTitle();
+        h->GetYaxis()->SetRangeUser(0.8, 1.05);
+        leg=new TLegend(.7, .2, .98, .6);
+        leg->SetHeader("Species");
+        leg->SetBorderSize(0);
+        leg->SetFillStyle(0);
+        leg->AddEntry(h, h->GetTitle(), "pl");
+      } else {
+        leg->AddEntry(h, h->GetTitle(), "pl");
+        h->Draw("same e1");
+      }
       bFIRST = kFALSE;
     }
+    if(leg) leg->Draw();
     break;
   }
   return kTRUE;