from nagmeh: addtask for pid config task and updates to pid config task
authorrbertens <rbertens@cern.ch>
Thu, 30 Oct 2014 15:42:02 +0000 (16:42 +0100)
committerrbertens <rbertens@cern.ch>
Thu, 30 Oct 2014 15:42:16 +0000 (16:42 +0100)
PWG/FLOW/Tasks/AliAnalysisTaskPIDconfig.cxx
PWG/FLOW/Tasks/AliAnalysisTaskPIDconfig.h
PWGCF/FLOW/macros/AddTaskPIDconfig.C [new file with mode: 0644]

index 5918241..977600c 100644 (file)
@@ -359,7 +359,7 @@ void AliAnalysisTaskPIDconfig::UserExec(Option_t*){
         TH2F* HistDCAbefore =(TH2F*)fListQAInfo->At(5);
         HistDCAbefore->Fill(dcaZ,dcaXY);
         
-        Double_t p = -999, pTPC = -999, pT = -999, phi = -999, eta = -999, dEdx =-999;
+        Double_t p = -999, /*pTPC = -999,*/ pT = -999, phi = -999, eta = -999, dEdx =-999;
         Double_t length = -999., beta =-999, tofTime = -999., tof = -999.;
         Double_t c = TMath::C()*1.E-9;// m/ns
 
@@ -368,7 +368,7 @@ void AliAnalysisTaskPIDconfig::UserExec(Option_t*){
 
         //Float_t dcaXY = -999, dcaZ = -999;
         p=track->P();
-        pTPC=track->GetTPCmomentum();
+        /*pTPC=track->GetTPCmomentum();*/
         pT=track->Pt();
         phi=track->Phi();
         eta=track->Eta();
@@ -430,19 +430,36 @@ void AliAnalysisTaskPIDconfig::UserExec(Option_t*){
             Int_t pRange = -999;
             TCutG *cut[3][10];
             if(fPIDcuts){
+                if(fContourCutList){cout<<"The contour file has been retrieved"<<endl;}
+                
                 TGraph *ContourCut[3][10];
-                Double_t plow[10] = {0.2,0.5,1,1.5,2,2.5,3,3.5,4,4.5};
-                Double_t phigh[10] = {0.5,1,1.5,2,2.5,3,3.5,4,4.5,5};
-               // TString species[3] = {pion,kaon,proton};
+                //Double_t plow[10] = {0.2,0.5,1,1.5,2,2.5,3,3.5,4,4.5};
+                //Double_t phigh[10] = {0.5,1,1.5,2,2.5,3,3.5,4,4.5,5};
+                Double_t phigh=0 ,plow=0;
+                Double_t pBins[11] = {0.2,0.5,1,1.5,2,2.5,3,3.5,4,4.5,5};
+                TString Graph_Name = "contourlines_";
+                TString species[3] = {"pion","kaon","proton"};
                 for(int i=0;i<3;i++){
                     for(int j=0;j<10;j++){
-                        if(p>plow[j] && p<phigh[j]){
+                        
+                        if(p>pBins[j] && p<pBins[j+1]){
+
+                        //if(p>plow[j] && p<phigh[j]){
                             pWithinRange = kTRUE;
                             pRange = j;
-                            TList *Scontours = (TList*)fContourCutList->At(i);
-                            TList *Pcontours = (TList*)Scontours->At(j);
-                            if (!Pcontours || !Scontours) return;
-                            ContourCut[i][j] = (TGraph*)Pcontours->First();
+                            
+                            TList *Species_contours = (TList*)fContourCutList->Get(species[i]);
+                            phigh = pBins[j+1]*10;
+                            plow = pBins[j]*10;
+
+                            Graph_Name += species[i];
+                            Graph_Name += Form("%.f%.f-%i%icent",plow,phigh,fCentralityPercentileMin,fCentralityPercentileMax);
+
+                            //TList *Pcontours = (TList*)Scontours->At(j);
+                            //if (!Scontours) return;
+
+                           // if (!Pcontours || !Scontours) return;
+                            ContourCut[i][j] = (TGraph*)Species_contours->FindObject(Graph_Name);
                             cut[i][j] = new TCutG("cut",ContourCut[i][j]->GetN(),ContourCut[i][j]->GetX(),ContourCut[i][j]->GetY());
                             //ContourCut[i][j] = (TGraph *)fContourCutList->At(10*i+j);
                         }
index bc987bf..9460ed2 100644 (file)
@@ -41,27 +41,27 @@ class AliAnalysisTaskPIDconfig : public AliAnalysisTaskSE {
   
   
 public:
-  AliAnalysisTaskPIDconfig();
-  AliAnalysisTaskPIDconfig(const char *name);
-  virtual ~AliAnalysisTaskPIDconfig();
-
-  virtual void UserCreateOutputObjects();
-  virtual void UserExec(Option_t * /*option*/);
-
-  void SetFilterBit(Double_t b){fFilterBit = b;}
-  void SetCentralityPercentileMin(Int_t b){fCentralityPercentileMin = b;}
-  void SetCentralityPercentileMax(Int_t b){fCentralityPercentileMax = b;}
-  void SetCentralityEstimator(TString b){fCentralityEstimator = b;}
-  void SetUseCentrality(Bool_t b=kTRUE){fUseCentrality = b;}
-  void SetCentralityTrigger(Int_t b=AliVEvent::kMB){ fTriggerSelection = b;}
-  void SetDCAxyCut(Int_t b){fDCAxyCut = b;}
-  void SetDCAzCut(Int_t b){fDCAzCut = b;}
-  void SetCutTPCmultiplicityOutliersAOD(Bool_t b){fCutTPCmultiplicityOutliersAOD = b;}
-  void SetData2011(Bool_t b){fData2011 = b;}
-  void CheckCentrality(AliVEvent *event,Bool_t &centralitypass); //to use only events with the correct centrality....
-  void SetCuts(Bool_t b){fPIDcuts = b;}
+    AliAnalysisTaskPIDconfig();
+    AliAnalysisTaskPIDconfig(const char *name);
+    virtual ~AliAnalysisTaskPIDconfig();
+
+    virtual void UserCreateOutputObjects();
+    virtual void UserExec(Option_t * /*option*/);
+
+    void SetFilterBit(Double_t b){fFilterBit = b;}
+    void SetCentralityPercentileMin(Int_t b){fCentralityPercentileMin = b;}
+    void SetCentralityPercentileMax(Int_t b){fCentralityPercentileMax = b;}
+    void SetCentralityEstimator(TString b){fCentralityEstimator = b;}
+    void SetUseCentrality(Bool_t b=kTRUE){fUseCentrality = b;}
+    void SetCentralityTrigger(Int_t b=AliVEvent::kMB){ fTriggerSelection = b;}
+    void SetDCAxyCut(Int_t b){fDCAxyCut = b;}
+    void SetDCAzCut(Int_t b){fDCAzCut = b;}
+    void SetCutTPCmultiplicityOutliersAOD(Bool_t b){fCutTPCmultiplicityOutliersAOD = b;}
+    void SetData2011(Bool_t b){fData2011 = b;}
+    void CheckCentrality(AliVEvent *event,Bool_t &centralitypass); //to use only events with the correct centrality....
+    void SetCuts(Bool_t b){fPIDcuts = b;}
   //void MultiplicityOutlierCut(AliVEvent *event,Bool_t &centralitypass,Int_t ntracks);
-  void SetPIDcontoursList(TList* b){fContourCutList = b;}
+    void SetPIDcontoursList(TDirectory* b){fContourCutList = b;}
   //TGraph* GetPIDcontours(TString specie, Double_t Plow, Double_t Phigh,Int_t centMin, Int_t centMax){}
 
 protected:  
@@ -86,7 +86,7 @@ private:
     Bool_t                 fCutTPCmultiplicityOutliersAOD;
     Bool_t                 fPIDcuts;
     TString                fCentralityEstimator;   //"V0M","TRK","TKL","ZDC","FMD"
-    TList                 *fContourCutList;
+    TDirectory            *fContourCutList;
     TList                 *fListQA;           // List of all lists
     TList                 *fListQAtpctof;     //! List with combined PID from TPC + TOF
     TList                 *fListQAInfo;
diff --git a/PWGCF/FLOW/macros/AddTaskPIDconfig.C b/PWGCF/FLOW/macros/AddTaskPIDconfig.C
new file mode 100644 (file)
index 0000000..eece9a9
--- /dev/null
@@ -0,0 +1,81 @@
+
+void AddTaskPIDconfig(Int_t CentralityTriggerSelection = AliVEvent::kMB, Double_t centralityMin=0, Double_t centralityMax=5 ,Double_t FilterBit=1, Bool_t PIDcuts=kFALSE,TString useroutputfile="output.root"){
+
+    AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+    if (!mgr) {
+        ::Error("AddTaskPID", "No analysis manager to connect to.");
+        return 0x0;
+    }
+    
+    // standard with task
+    printf("========================================================================================\n");
+    printf("PID: Initialising AliAnalysisTaskPIDconfig\n");
+    printf("========================================================================================\n");
+    
+    Double_t centrMin[9] = {0,5,10,20,30,40,50,60,70};
+    Double_t centrMax[9] = {5,10,20,30,40,50,60,70,80};
+    Bool_t Pass_Min = kFALSE;
+    Bool_t Pass_Max = kFALSE;
+
+    for(int i=0;i<9;i++)
+    {
+        if(centralityMin == centrMin[i]){
+            const int iMin = i;
+            Pass_Min = kTRUE;
+        }
+        if(centralityMax == centrMax[i]){
+            const int iMax = i;
+            Pass_Max = kTRUE;
+        }
+    }
+    if(!Pass_Min || !Pass_Max){
+        ::Error("centrality Min and Max don't match the defined ranges");
+        return 0x0;
+    }
+    
+    const int ncentr = iMax - iMin +1;
+    TString outputfile[ncentr];
+    AliAnalysisDataContainer *coutput1[ncentr];
+    AliAnalysisTaskPIDconfig *pidTask[ncentr];
+    int icentr = 0;
+    
+    
+    
+    for(int i=0;i<iMax-iMin+1;i++){
+        icentr = i + iMin;
+        outputfile[i] = useroutputfile;
+        pidTask[i] = new AliAnalysisTaskPIDconfig(Form("pidTask_%.f-%.f",centrMin[icentr],centrMax[icentr]));
+        pidTask[i]->SelectCollisionCandidates(CentralityTriggerSelection);
+        pidTask[i]->SetCutTPCmultiplicityOutliersAOD(kTRUE);
+        pidTask[i]->SetData2011(kFALSE);
+        pidTask[i]->SetFilterBit(FilterBit);
+        pidTask[i]->SetUseCentrality(kTRUE);
+        pidTask[i]->SetCentralityPercentileMin(centrMin[icentr]);
+        pidTask[i]->SetCentralityPercentileMax(centrMax[icentr]);
+        pidTask[i]->SetCentralityEstimator("V0M");
+        pidTask[i]->SetDCAxyCut(10);
+        pidTask[i]->SetDCAzCut(10);
+        pidTask[i]->SetCuts(PIDcuts);
+        if(PIDcuts){
+            TFile *ContoursFile = new TFile(Form("PurityHistContours_%.f-%.f.root",centrMin[icentr],centrMax[icentr]));
+
+            Contourlist = new TDirectory;
+            Contourlist=(TDirectory*)ContoursFile->Get("Filterbit1");
+            if(!Contourlist){printf("The contour file is empty"); continue;}
+    
+            pidTask[i]->SetPIDcontoursList(Contourlist);
+            
+        }
+        
+        mgr->AddTask(pidTask[i]);
+        
+        coutput1[i] = mgr->CreateContainer(Form("PID_%.f-%.f",centrMin[icentr],centrMax[icentr]), TList::Class(),AliAnalysisManager::kOutputContainer,outputfile[i]);
+  
+        //connect containers
+        mgr->ConnectInput  (pidTask[i],  0, mgr->GetCommonInputContainer());
+        mgr->ConnectOutput (pidTask[i],  1, coutput1[i]);
+        
+        //return pidTask[icentr];
+
+    }
+}
\ No newline at end of file