updated
authorssakai <ssakai@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 20 Mar 2013 16:55:26 +0000 (16:55 +0000)
committerssakai <ssakai@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 20 Mar 2013 16:55:26 +0000 (16:55 +0000)
PWGHF/hfe/AliAnalysisTaskHFE.cxx
PWGHF/hfe/AliAnalysisTaskHFE.h
PWGHF/hfe/macros/test/runGridpPb.C

index 1d7cd82..871c563 100644 (file)
@@ -99,7 +99,7 @@ AliAnalysisTaskSE("PID efficiency Analysis")
   , fCollisionSystem(3)\r
   , fFillSignalOnly(kTRUE)\r
   , fFillNoCuts(kFALSE)\r
-  , fApplyCutAOD(kTRUE)\r
+  , fApplyCutAOD(kFALSE)\r
   , fBackGroundFactorApply(kFALSE)\r
   , fRemovePileUp(kFALSE)\r
   , fIdentifiedAsPileUp(kFALSE)\r
@@ -113,6 +113,7 @@ AliAnalysisTaskSE("PID efficiency Analysis")
   , fSpecialTrigger(NULL)\r
   , fCentralityF(-1)\r
   , fCentralityPercent(-1)\r
+  , fCentralityEstimator("V0M")\r
   , fContributors(0.5)\r
   , fWeightBackGround(0.)\r
   , fVz(0.0)\r
@@ -136,6 +137,8 @@ AliAnalysisTaskSE("PID efficiency Analysis")
   , fTaggedTrackAnalysis(NULL)\r
   , fExtraCuts(NULL)\r
   , fBackgroundSubtraction(NULL)\r
+  , fTRDTrigger(kFALSE)\r
+  , fWhichTRDTrigger(0)\r
   , fQA(NULL)\r
   , fOutput(NULL)\r
   , fHistMCQA(NULL)\r
@@ -165,7 +168,7 @@ AliAnalysisTaskHFE::AliAnalysisTaskHFE(const char * name):
   , fCollisionSystem(3)\r
   , fFillSignalOnly(kTRUE)\r
   , fFillNoCuts(kFALSE)\r
-  , fApplyCutAOD(kTRUE)\r
+  , fApplyCutAOD(kFALSE)\r
   , fBackGroundFactorApply(kFALSE)\r
   , fRemovePileUp(kFALSE)\r
   , fIdentifiedAsPileUp(kFALSE)\r
@@ -179,6 +182,7 @@ AliAnalysisTaskHFE::AliAnalysisTaskHFE(const char * name):
   , fSpecialTrigger(NULL)\r
   , fCentralityF(-1)\r
   , fCentralityPercent(-1)\r
+  , fCentralityEstimator("V0M")\r
   , fContributors(0.5)\r
   , fWeightBackGround(0.)\r
   , fVz(0.0)\r
@@ -202,6 +206,8 @@ AliAnalysisTaskHFE::AliAnalysisTaskHFE(const char * name):
   , fTaggedTrackAnalysis(NULL)\r
   , fExtraCuts(NULL)\r
   , fBackgroundSubtraction(NULL)\r
+  , fTRDTrigger(kFALSE)\r
+  , fWhichTRDTrigger(0)\r
   , fQA(NULL)\r
   , fOutput(NULL)\r
   , fHistMCQA(NULL)\r
@@ -253,6 +259,7 @@ AliAnalysisTaskHFE::AliAnalysisTaskHFE(const AliAnalysisTaskHFE &ref):
   , fSpecialTrigger(ref.fSpecialTrigger)\r
   , fCentralityF(ref.fCentralityF)\r
   , fCentralityPercent(ref.fCentralityPercent)\r
+  , fCentralityEstimator(ref.fCentralityEstimator)\r
   , fContributors(ref.fContributors)\r
   , fWeightBackGround(ref.fWeightBackGround)\r
   , fVz(ref.fVz)\r
@@ -276,6 +283,8 @@ AliAnalysisTaskHFE::AliAnalysisTaskHFE(const AliAnalysisTaskHFE &ref):
   , fTaggedTrackAnalysis(NULL)\r
   , fExtraCuts(NULL)\r
   , fBackgroundSubtraction(NULL)\r
+  , fTRDTrigger(ref.fTRDTrigger)\r
+  , fWhichTRDTrigger(ref.fWhichTRDTrigger)\r
   , fQA(NULL)\r
   , fOutput(NULL)\r
   , fHistMCQA(NULL)\r
@@ -326,6 +335,7 @@ void AliAnalysisTaskHFE::Copy(TObject &o) const {
   target.fSpecialTrigger = fSpecialTrigger;\r
   target.fCentralityF = fCentralityF;\r
   target.fCentralityPercent = fCentralityPercent;\r
+  target.fCentralityEstimator = fCentralityEstimator;\r
   target.fContributors = fContributors;\r
   target.fWeightBackGround = fWeightBackGround;\r
   target.fVz = fVz;\r
@@ -349,6 +359,8 @@ void AliAnalysisTaskHFE::Copy(TObject &o) const {
   target.fTaggedTrackAnalysis = fTaggedTrackAnalysis;\r
   target.fExtraCuts = fExtraCuts;\r
   target.fBackgroundSubtraction = fBackgroundSubtraction;\r
+  target.fTRDTrigger = fTRDTrigger;\r
+  target.fWhichTRDTrigger = fWhichTRDTrigger;\r
   target.fQA = fQA;\r
   target.fOutput = fOutput;\r
   target.fHistMCQA = fHistMCQA;\r
@@ -425,11 +437,8 @@ void AliAnalysisTaskHFE::UserCreateOutputObjects(){
   fQACollection->CreateTH1F("nElectronTracksEvent", "Number of Electron Candidates", 100, 0, 100);\r
   fQACollection->CreateTH1F("nElectron", "Number of electrons", 100, 0, 100);\r
   fQACollection->CreateTH2F("radius", "Production Vertex", 100, 0.0, 5.0, 100, 0.0, 5.0);\r
-\r
-  if(IsAODanalysis()){\r
-    fQACollection->CreateTH1F("Filterorigin","AOD filter of tracks at origin", 21,-1, 20);\r
-    fQACollection->CreateTH1F("Filterend","AOD filter of tracks after all cuts", 21, -1, 20);\r
-  }\r
+  fQACollection->CreateTH2F("nTriggerBit2D", "Histo Trigger Bit 2d", 10, 0., 10., 10, 0., 10.,-1);\r
+  fQACollection->CreateTH1F("nTriggerBit", "Histo Trigger Bit", 12, 0, 12);\r
  \r
   InitHistoITScluster();\r
   InitContaminationQA();\r
@@ -602,6 +611,13 @@ void AliAnalysisTaskHFE::UserExec(Option_t *){
     if(fAnalysisUtils->IsFirstEventInChunk(fInputEvent)) return;\r
   }\r
 \r
+  AliESDEvent *ev = dynamic_cast<AliESDEvent *>(fInputEvent);\r
+  if(fTRDTrigger)\r
+  {\r
+      if(!CheckTRDTrigger(ev)) return;\r
+  }\r
+\r
+\r
   if(IsESDanalysis() && HasMCData()){\r
     // Protect against missing MC trees\r
     AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler *>(AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());\r
@@ -609,11 +625,9 @@ void AliAnalysisTaskHFE::UserExec(Option_t *){
       AliError("No MC Event Handler available");\r
       return;\r
     }\r
-    /*\r
     if(!mcH->InitOk()) return;\r
     if(!mcH->TreeK()) return;\r
     if(!mcH->TreeTR()) return;\r
-    */\r
 \r
     // Background subtraction-------------------------------------------------------------------\r
     if(GetPlugin(kNonPhotonicElectron)) fBackgroundSubtraction->SetMCEvent(fMCEvent);\r
@@ -686,7 +700,6 @@ void AliAnalysisTaskHFE::UserExec(Option_t *){
     // Check Trigger selection\r
     if(specialTrigger){\r
       AliDebug(2, Form("Special Trigger requested: %s", specialTrigger));\r
-      AliESDEvent *ev = dynamic_cast<AliESDEvent *>(fInputEvent);\r
       if(!(ev && ev->IsTriggerClassFired(specialTrigger))){\r
         AliDebug(2, "Event not selected"); \r
         return;\r
@@ -758,7 +771,7 @@ void AliAnalysisTaskHFE::ProcessMC(){
         fMCQA->SetMCEvent(fMCEvent);\r
         fMCQA->SetGenEventHeader(fMCEvent->GenEventHeader());\r
         fMCQA->SetCentrality(fCentralityF);\r
-        fMCQA->SetPercentrality(fCentralityPercent);\r
+        fMCQA->SetPercentrality(static_cast<Int_t>(fCentralityPercent));\r
         if(IsPbPb()) { fMCQA->SetPbPb();}\r
         else\r
         {\r
@@ -1477,14 +1490,6 @@ void AliAnalysisTaskHFE::ProcessAOD(){
       }\r
     }\r
 \r
-    fQACollection->Fill("Filterorigin", -1);  \r
-    for(Int_t k=0; k<20; k++) {\r
-      Int_t u = 1<<k;\r
-      if((track->TestFilterBit(u))) {\r
-             fQACollection->Fill("Filterorigin", k);\r
-      }\r
-    }\r
-\r
     if(fApplyCutAOD) {\r
       //printf("Apply cuts\n");\r
       // RecKine: ITSTPC cuts  \r
@@ -1492,14 +1497,14 @@ void AliAnalysisTaskHFE::ProcessAOD(){
 \r
       // Reject kink mother\r
       if(fRejectKinkMother) {\r
-           Bool_t kinkmotherpass = kTRUE;\r
-           for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {\r
-             if(track->GetID() == listofmotherkink[kinkmother]) {\r
-               kinkmotherpass = kFALSE;\r
-               continue;\r
-             }\r
-           }\r
-           if(!kinkmotherpass) continue;\r
+       Bool_t kinkmotherpass = kTRUE;\r
+       for(Int_t kinkmother = 0; kinkmother < numberofmotherkink; kinkmother++) {\r
+         if(track->GetID() == listofmotherkink[kinkmother]) {\r
+           kinkmotherpass = kFALSE;\r
+           continue;\r
+         }\r
+       }\r
+       if(!kinkmotherpass) continue;\r
       }\r
       \r
       // RecPrim\r
@@ -2029,7 +2034,7 @@ Bool_t AliAnalysisTaskHFE::ReadCentrality() {
   if(IsHeavyIon()) {\r
     // Centrality\r
     AliCentrality *centrality = fInputEvent->GetCentrality();\r
-    fCentralityPercent = centrality->GetCentralityPercentile("V0M");\r
+    fCentralityPercent = centrality->GetCentralityPercentile(fCentralityEstimator.Data());\r
     //printf("centrality %f\n",fCentralityPercent);\r
 \r
     for(Int_t ibin = 0; ibin < 11; ibin++){\r
@@ -2172,4 +2177,122 @@ void AliAnalysisTaskHFE::RejectionPileUpVertexRangeEventCut() {
  }\r
 \r
 }\r
+//___________________________________________________\r
+Bool_t AliAnalysisTaskHFE::CheckTRDTrigger(AliESDEvent *ev) {\r
+    // check function!\r
+    // pPb settings\r
 \r
+    Bool_t cint8=kFALSE;\r
+    Bool_t cint7=kFALSE;\r
+    Bool_t cint5=kFALSE;\r
+    Bool_t trdtrgevent=kFALSE;\r
+\r
+    if(fWhichTRDTrigger==1)\r
+    {\r
+       // if (!(AliTriggerAnalysis::TRDTrigger(ev) & 0x2)) return; // HSE\r
+       cint8= ev->IsTriggerClassFired("CINT8WUHSE-B-NOPF-CENT");\r
+       cint7= ev->IsTriggerClassFired("CINT7WUHSE-B-NOPF-CENT");\r
+       cint5= (ev->IsTriggerClassFired("CINT5WU-B-NOPF-ALL")) &&\r
+           (ev->GetHeader()->GetL1TriggerInputs() & (1 << 10));\r
+       //  printf("trdtrg condition %i \n",fWhichTRDTrigger);\r
+    }\r
+    if(fWhichTRDTrigger==2)\r
+    {\r
+       cint8= ev->IsTriggerClassFired("CINT8WUHSE-B-NOPF-CENT");\r
+       cint7= ev->IsTriggerClassFired("CINT7WUHSE-B-NOPF-CENT");\r
+       cint5= (ev->IsTriggerClassFired("CINT5WU-B-NOPF-ALL")) &&\r
+           (ev->GetHeader()->GetL1TriggerInputs() & (1 << 10));\r
+       //     printf("trdtrg condition %i \n",fWhichTRDTrigger);\r
+    }\r
+\r
+    //HQU\r
+    if(fWhichTRDTrigger==3)\r
+    {\r
+       // if (!(AliTriggerAnalysis::TRDTrigger(ev) & 0x4)) return; // HSE\r
+       cint8= ev->IsTriggerClassFired("CINT8WUHQU-B-NOPF-CENT");\r
+       cint7= ev->IsTriggerClassFired("CINT7WUHQU-B-NOPF-CENT");\r
+       cint5= (ev->IsTriggerClassFired("CINT5WU-B-NOPF-ALL")) &&\r
+           (ev->GetHeader()->GetL1TriggerInputs() & (1 << 12));\r
+       //  printf("trdtrg condition %i \n",fWhichTRDTrigger);\r
+    }\r
+    if(fWhichTRDTrigger==4)\r
+    {\r
+       cint8= ev->IsTriggerClassFired("CINT8WUHQU-B-NOPF-CENT");\r
+       cint7= ev->IsTriggerClassFired("CINT7WUHQU-B-NOPF-CENT");\r
+       cint5= (ev->IsTriggerClassFired("CINT5WU-B-NOPF-ALL")) &&\r
+           (ev->GetHeader()->GetL1TriggerInputs() & (1 << 12));\r
+       //  printf("trdtrg condition %i \n",fWhichTRDTrigger);\r
+    }\r
+\r
+    Int_t ntriggerbit=0;\r
+    fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    if(ev->IsTriggerClassFired("CINT7-B-NOPF-ALLNOTRD"))\r
+    {\r
+       ntriggerbit=2;\r
+       fQACollection->Fill("nTriggerBit2D",ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WU-B-NOPF-ALL"))\r
+    {\r
+       ntriggerbit=3;\r
+       fQACollection->Fill("nTriggerBit2D",ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHJT-B-NOPF-CENT"))\r
+    {\r
+       ntriggerbit=4;\r
+       fQACollection->Fill("nTriggerBit2D",ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHQU-B-NOPF-CENT")) {\r
+       ntriggerbit=5;\r
+       fQACollection->Fill("nTriggerBit2D",ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+       if(ev->IsTriggerClassFired("CINT7WUHSE-B-NOPF-CENT")) {\r
+           ntriggerbit=11;\r
+           fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+           fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+       }\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHSE-B-NOPF-CENT")) {\r
+       ntriggerbit=6;\r
+       fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+       if(ev->IsTriggerClassFired("CINT7WUHQU-B-NOPF-CENT")) {\r
+           ntriggerbit=12;\r
+           fQACollection->Fill("nTriggerBit2D",ntriggerbit,ntriggerbit);\r
+           fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+       }\r
+    }\r
+    if(ev->IsTriggerClassFired("CEMC7WUHEE-B-NOPF-CENT")) {\r
+       ntriggerbit=7;\r
+       fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHJT-B-NOPF-FAST")){\r
+       ntriggerbit=8;\r
+       fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHQU-B-NOPF-FAST")){\r
+       ntriggerbit=9;\r
+       fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ev->IsTriggerClassFired("CINT7WUHSE-B-NOPF-FAST")){\r
+       ntriggerbit=10;\r
+       fQACollection->Fill("nTriggerBit2D", ntriggerbit,ntriggerbit);\r
+       fQACollection->Fill("nTriggerBit",ntriggerbit);\r
+    }\r
+    if(ntriggerbit==0) fQACollection->Fill("nTriggerBit",1);\r
+\r
+//   printf("triggerbit %i \n",ntriggerbit);\r
+\r
\r
+\r
+    if((cint7==kFALSE)&&(cint8==kFALSE)&&(cint5==kFALSE)) trdtrgevent=kFALSE;\r
+    else trdtrgevent=kTRUE;\r
+\r
+    return trdtrgevent;\r
+\r
+}\r
index af133be..ba91766 100644 (file)
-/**************************************************************************
-* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
-*                                                                        *
-* Author: The ALICE Off-line Project.                                    *
-* Contributors are mentioned in the code where appropriate.              *
-*                                                                        *
-* Permission to use, copy, modify and distribute this software and its   *
-* documentation strictly for non-commercial purposes is hereby granted   *
-* without fee, provided that the above copyright notice appears in all   *
-* copies and that both the copyright notice and this permission notice   *
-* appear in the supporting documentation. The authors make no claims     *
-* about the suitability of this software for any purpose. It is          *
-* provided "as is" without express or implied warranty.                  *
-**************************************************************************/
-//
-// Task for Heavy Flavour Electron Analysis
-// Fills a single-inclusive electron pt-spectrum
-// For further information see implementation file
-//
-#ifndef ALIANALYSISTASKHFE_H
-#define ALIANALYSISTASKHFE_H
-
-#ifndef ALIANALYSISTASKSE_H
-#include "AliAnalysisTaskSE.h"
-#endif
-
-#ifndef ROOT_TString
-#include <TString.h>
-#endif
-
-#ifndef ROOT_TBits
-#include <TBits.h>
-#endif
-
-class AliAnalysisUtils;
-class AliESDtrackCuts;
-class AliHFEcontainer;
-class AliHFEcollection;
-class AliHFEcuts;
-class AliHFEextraCuts;
-class AliHFEelecbackground;
-class AliHFENonPhotonicElectron;
-class AliHFEmcQA;
-class AliHFEpid;
-class AliHFEpidQAmanager;
-class AliHFEsecVtx;
-class AliHFEsignalCuts;
-class AliHFEvarManager;
-class AliHFEtaggedTrackAnalysis;
-class AliCFManager;
-class AliMCEvent;
-class AliOADBContainer;
-class AliAODMCHeader;
-class AliVEvent;
-class AliVParticle;
-class AliTriggerAnalysis;
-class TH1I; 
-class TList;
-class TClonesArray;
-
-class AliAnalysisTaskHFE : public AliAnalysisTaskSE{
-  public:
-    enum{
-      kPIDqa = 0,
-      kMCqa =1 
-    };
-    enum{
-      kPriVtx = 0,
-      kSecVtx = 1,
-      kIsElecBackGround = 2,
-      kPostProcess = 3,
-      kDEstep = 4,
-      kTaggedTrackAnalysis = 5,
-      kNonPhotonicElectron = 6
-    };
-    enum CreationProcess_t{
-      kSignalCharm = 0,
-      kSignalBeauty = 1,
-      kGammaConv = 2,
-      kOther = 3
-    };
-    enum{
-      kBgPtBins = 44,
-      kElecBgSpecies = 6,
-      kCentBins = 11,
-      kBgLevels = 3
-    };
-    typedef enum{
-      kpp = 0,
-      kpPb = 1,
-      kPbPb = 2
-    } ECollisionSystem_t;
-
-    AliAnalysisTaskHFE();
-    AliAnalysisTaskHFE(const char * name);
-    AliAnalysisTaskHFE(const AliAnalysisTaskHFE &ref);
-    AliAnalysisTaskHFE& operator=(const AliAnalysisTaskHFE &ref);
-    virtual void Copy(TObject &o) const;
-    virtual ~AliAnalysisTaskHFE();
-
-    virtual void UserCreateOutputObjects();
-    virtual void UserExec(Option_t *);
-    virtual void Terminate(Option_t *);
-
-    virtual Bool_t IsEventInBinZero();
-
-    Bool_t IsQAOn(Int_t qaLevel) const { return TESTBIT(fQAlevel, qaLevel); };
-    Bool_t IsAODanalysis() const { return TestBit(kAODanalysis); };
-    Bool_t IsESDanalysis() const { return !TestBit(kAODanalysis); };
-    Bool_t HasMCData() const { return TestBit(kHasMCdata); }
-    Bool_t Ispp() const { return fCollisionSystem.TestBitNumber(kpp); }
-    Bool_t IsPbPb() const { return fCollisionSystem.TestBitNumber(kPbPb); }
-    Bool_t IspPb() const { return fCollisionSystem.TestBitNumber(kpPb); }
-    Bool_t IsHeavyIon() const { return IsPbPb() || IspPb(); }
-    Bool_t GetPlugin(Int_t plug) const { return TESTBIT(fPlugins, plug); };
-
-    // Get Components for configuration
-    AliHFEvarManager *GetVarManager() const { return fVarManager; }
-    AliHFEpidQAmanager *GetPIDQAManager() const { return fPIDqa; }
-    AliHFEpid *GetPID() const { return fPID; }
-    AliHFENonPhotonicElectron *GetHFEBackgroundSubtraction() const { return fBackgroundSubtraction; }
-
-    void SetHFECuts(AliHFEcuts * const cuts) { fCuts = cuts; };
-    void SetTaggedTrackCuts(AliHFEcuts * const cuts) { fTaggedTrackCuts = cuts; }
-    void SetCleanTaggedTrack(Bool_t clean) { fCleanTaggedTrack = clean; };
-    void SetVariablesTRDTaggedTrack(Bool_t variablesTRD) { fVariablesTRDTaggedTrack = variablesTRD; };
-    void SetHFECutsPreselect(AliESDtrackCuts * const cuts) { fCutspreselect = cuts; };
-    void SetHFEElecBackGround(AliHFEelecbackground * const elecBackGround) { fElecBackGround = elecBackGround; };
-    void SetHFEBackgroundSubtraction(AliHFENonPhotonicElectron * const backgroundSubtraction) { fBackgroundSubtraction = backgroundSubtraction; };
-    void SetQAOn(Int_t qaLevel) { SETBIT(fQAlevel, qaLevel); };
-    void SwitchOnPlugin(Int_t plug);
-    void SetHasMCData(Bool_t hasMC = kTRUE) { SetBit(kHasMCdata, hasMC); };
-    void SetFillSignalOnly(Bool_t signalOnly) { fFillSignalOnly = signalOnly; }
-   
-    void SetFillNoCuts(Bool_t fillNoCuts) { fFillNoCuts = fillNoCuts; }
-    void SetApplyCutAOD(Bool_t applyCutAOD)   { fApplyCutAOD = applyCutAOD; }
-    void SetRemovePileUp(Bool_t removePileUp) { fRemovePileUp = removePileUp; }
-    void SetRemoveFirstEventInChunk() {fRemoveFirstEvent = kTRUE;}
-    void SetPIDPreselect(AliHFEpid * const cuts) { fPIDpreselect = cuts; };
-    void SetAODAnalysis() { SetBit(kAODanalysis, kTRUE); };
-    void SetESDAnalysis() { SetBit(kAODanalysis, kFALSE); };
-    void SetCollisionSystem(ECollisionSystem_t system){
-      fCollisionSystem.Clear();
-      fCollisionSystem.SetBitNumber(system, kTRUE);
-    }
-    void SetppAnalysis(){
-      fCollisionSystem.SetBitNumber(kpPb, kFALSE); 
-      fCollisionSystem.SetBitNumber(kPbPb, kFALSE); 
-      fCollisionSystem.SetBitNumber(kpp, kTRUE); 
-    }
-    void SetpPbAnalysis() {
-      fCollisionSystem.SetBitNumber(kpp, kFALSE); 
-      fCollisionSystem.SetBitNumber(kPbPb, kFALSE); 
-      fCollisionSystem.SetBitNumber(kpPb, kTRUE); 
-    }
-    void SetPbPbAnalysis() { 
-      fCollisionSystem.SetBitNumber(kpp, kFALSE); 
-      fCollisionSystem.SetBitNumber(kpPb, kFALSE); 
-      fCollisionSystem.SetBitNumber(kPbPb, kTRUE); 
-    };
-    void SetPbPbUserCentralityLimit(Bool_t isPbPbUserBinning = kFALSE){fPbPbUserCentralityBinning = isPbPbUserBinning; };
-    void SetPbPbUserCentralityArray(Int_t icentr, Float_t valuecentr) {fCentralityLimits[icentr] = valuecentr;};
-    void SetPPMultiBinAnalysis(Bool_t isppMultiBin) { fisppMultiBin = isppMultiBin; };
-    void SetNonHFEsystematics(Bool_t isSystematics) {fisNonHFEsystematics = isSystematics; };
-    void SetRejectKinkMother(Bool_t rejectKinkMother = kFALSE) { fRejectKinkMother = rejectKinkMother; };
-    void SetBackGroundFactorsFunction(const TF1 * const backGroundFactorsFunction, Int_t centralitybin=0){  
-      fkBackGroundFactorArray[centralitybin]=backGroundFactorsFunction;
-      fBackGroundFactorApply=kTRUE;
-      SetBit(kBackgroundInitialized);
-    };
-    void SetElecBackGroundFactors(Int_t iPt, Int_t iType, Int_t iCent, Int_t iError, Double_t elecBackGroundFactor) {fElecBackgroundFactor[iError][iCent][iType][iPt] = elecBackGroundFactor; };
-    void SetBinLimits(Int_t iPt, Double_t momentum){fBinLimit[iPt] = momentum;};
-    void PrintStatus() const;
-    Bool_t ReadCentrality();
-    void RejectionPileUpVertexRangeEventCut();  
-    void SelectSpecialTrigger(const Char_t *trgclust, Int_t runMin = 0, Int_t runMax = 999999999); 
-    void SetDebugStreaming() {SetBit(kTreeStream);};
-    
-  private:
-    enum{
-      kHasMCdata = BIT(19),
-      kAODanalysis = BIT(20),
-      kBackgroundInitialized = BIT(21),
-      kTreeStream = BIT(22)
-    };
-
-    Bool_t FillProductionVertex(const AliVParticle * const track) const;
-    void MakeParticleContainer();
-    void MakeEventContainer();
-    void InitHistoITScluster();
-    void InitContaminationQA();
-    const Char_t *GetSpecialTrigger(Int_t run);
-    void ProcessMC();
-    void ProcessESD();
-    void ProcessAOD();
-    Int_t GetITSMultiplicity(AliVEvent *ev);
-    Bool_t PreSelectTrack(AliESDtrack *track) const;
-    Bool_t ProcessMCtrack(AliVParticle *track);
-    Bool_t ProcessCutStep(Int_t cutStep, AliVParticle *track);
-    AliAODMCHeader *fAODMCHeader;         // ! MC info AOD
-    TClonesArray *fAODArrayMCInfo;        // ! MC info particle AOD
-    ULong_t fQAlevel;                     // QA level
-    UShort_t fPlugins;                    // Enabled Plugins
-    TBits fCollisionSystem;              // Collision System;
-    Bool_t fFillSignalOnly;               // Fill container only with MC Signal Tracks
-    Bool_t fFillNoCuts;                   // Fill container before any cut
-    Bool_t fApplyCutAOD;                  // Apply the analysis cut for AOD tracks
-    Bool_t fBackGroundFactorApply;        // Apply Background Function Subtraction,   MF: To be removed when transition to OADB container is finished
-    Bool_t fRemovePileUp;                 // Remove Pile Up
-    Bool_t fIdentifiedAsPileUp;           // Identified as pile-up
-    Bool_t fIdentifiedAsOutInz;           // Out Of Range in z
-    Bool_t fPassTheEventCut;              // Pass The Event Cut
-    Bool_t fRejectKinkMother;             // Reject Kink Mother
-    Bool_t fisppMultiBin;                 // pp Multiplicity Bin analysis
-    Bool_t fPbPbUserCentralityBinning;    // PbPb user centrality binning
-    Bool_t fRemoveFirstEvent;             // Remove first event from chunk
-    Bool_t fisNonHFEsystematics;          // Non-HFE background systematics analysis
-    AliOADBContainer *fSpecialTrigger;    // Special trigger selection
-    Int_t   fCentralityF;                 // Centrality bin
-    Float_t fCentralityPercent;           // Centrality percentile
-    Float_t fContributors;                // Contributors
-    Double_t fWeightBackGround;            // weight background function
-    Double_t fVz;                         // z position of the primary vertex
-    const TF1  *fkBackGroundFactorArray[12];   // Array of BackGround factors for each centrality bin, bin0 = min bias
-    Double_t fElecBackgroundFactor[kBgLevels][kCentBins][kElecBgSpecies][kBgPtBins];     // Electron background factors
-    Double_t fBinLimit[kBgPtBins+1];      // Electron pt bin edges
-    Float_t fCentralityLimits[12];        // Limits for centrality bins
-    AliHFEcontainer *fContainer;          //! The HFE container
-    AliHFEvarManager *fVarManager;        // The var manager as the backbone of the analysis
-    AliHFEsignalCuts *fSignalCuts;        //! MC true signal (electron coming from certain source) 
-    AliCFManager *fCFM;                   //! Correction Framework Manager
-    AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation
-    AliHFEpid *fPID;                      // PID
-    AliHFEpidQAmanager *fPIDqa;           // PID QA
-    AliHFEpid *fPIDpreselect;             // PID oject for pre-selected tracks (without QA)
-    AliHFEcuts *fCuts;                    // Cut Collection
-    AliHFEcuts *fTaggedTrackCuts;         // Cut Collection for V0 tagged tracks
-    Bool_t fCleanTaggedTrack;             // Loose cleaning of the V0 tagged tracks electron
-    Bool_t fVariablesTRDTaggedTrack;      // Take the variables at the TRD for the V0 tagged tracks electron
-    AliAnalysisUtils *fAnalysisUtils;     // Utility object to remove the first event of a chunk from the analysis
-    AliESDtrackCuts *fCutspreselect;      // Cut Collection for pre-selected tracks
-    AliHFEsecVtx *fSecVtx;                //! Secondary Vertex Analysis
-    AliHFEelecbackground *fElecBackGround;//! Background analysis
-    AliHFEmcQA *fMCQA;                    //! MC QA
-    AliHFEtaggedTrackAnalysis *fTaggedTrackAnalysis;     //!Analyse V0-tagged tracks
-    AliHFEextraCuts *fExtraCuts;          //! temporary implementation for IP QA
-    AliHFENonPhotonicElectron *fBackgroundSubtraction; // Background subtraction
-
-    //-----------QA and output---------------
-    TList *fQA;                           //! QA histos for the cuts
-    TList *fOutput;                       //! Container for Task Output
-    TList *fHistMCQA;                     //! Output container for MC QA histograms 
-    TList *fHistSECVTX;                   //! Output container for sec. vertexing results
-    TList *fHistELECBACKGROUND;           //! Output container for electron background analysis
-    AliHFEcollection *fQACollection;      //! Tasks own QA collection
-    //---------------------------------------
-
-    ClassDef(AliAnalysisTaskHFE, 2)       // The electron Analysis Task
-};
-#endif
-
+/**************************************************************************\r
+* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *\r
+*                                                                        *\r
+* Author: The ALICE Off-line Project.                                    *\r
+* Contributors are mentioned in the code where appropriate.              *\r
+*                                                                        *\r
+* Permission to use, copy, modify and distribute this software and its   *\r
+* documentation strictly for non-commercial purposes is hereby granted   *\r
+* without fee, provided that the above copyright notice appears in all   *\r
+* copies and that both the copyright notice and this permission notice   *\r
+* appear in the supporting documentation. The authors make no claims     *\r
+* about the suitability of this software for any purpose. It is          *\r
+* provided "as is" without express or implied warranty.                  *\r
+**************************************************************************/\r
+//\r
+// Task for Heavy Flavour Electron Analysis\r
+// Fills a single-inclusive electron pt-spectrum\r
+// For further information see implementation file\r
+//\r
+#ifndef ALIANALYSISTASKHFE_H\r
+#define ALIANALYSISTASKHFE_H\r
+\r
+#ifndef ALIANALYSISTASKSE_H\r
+#include "AliAnalysisTaskSE.h"\r
+#endif\r
+\r
+#ifndef ROOT_TString\r
+#include <TString.h>\r
+#endif\r
+\r
+#ifndef ROOT_TBits\r
+#include <TBits.h>\r
+#endif\r
+\r
+class AliAnalysisUtils;\r
+class AliESDtrackCuts;\r
+class AliHFEcontainer;\r
+class AliHFEcollection;\r
+class AliHFEcuts;\r
+class AliHFEextraCuts;\r
+class AliHFEelecbackground;\r
+class AliHFENonPhotonicElectron;\r
+class AliHFEmcQA;\r
+class AliHFEpid;\r
+class AliHFEpidQAmanager;\r
+class AliHFEsecVtx;\r
+class AliHFEsignalCuts;\r
+class AliHFEvarManager;\r
+class AliHFEtaggedTrackAnalysis;\r
+class AliCFManager;\r
+class AliMCEvent;\r
+class AliOADBContainer;\r
+class AliAODMCHeader;\r
+class AliVEvent;\r
+class AliVParticle;\r
+class AliTriggerAnalysis;\r
+class TH1I; \r
+class TList;\r
+class TClonesArray;\r
+\r
+class AliAnalysisTaskHFE : public AliAnalysisTaskSE{\r
+  public:\r
+    enum{\r
+      kPIDqa = 0,\r
+      kMCqa =1 \r
+    };\r
+    enum{\r
+      kPriVtx = 0,\r
+      kSecVtx = 1,\r
+      kIsElecBackGround = 2,\r
+      kPostProcess = 3,\r
+      kDEstep = 4,\r
+      kTaggedTrackAnalysis = 5,\r
+      kNonPhotonicElectron = 6\r
+    };\r
+    enum CreationProcess_t{\r
+      kSignalCharm = 0,\r
+      kSignalBeauty = 1,\r
+      kGammaConv = 2,\r
+      kOther = 3\r
+    };\r
+    enum{\r
+      kBgPtBins = 44,\r
+      kElecBgSpecies = 6,\r
+      kCentBins = 11,\r
+      kBgLevels = 3\r
+    };\r
+    typedef enum{\r
+      kpp = 0,\r
+      kpPb = 1,\r
+      kPbPb = 2\r
+    } ECollisionSystem_t;\r
+\r
+    AliAnalysisTaskHFE();\r
+    AliAnalysisTaskHFE(const char * name);\r
+    AliAnalysisTaskHFE(const AliAnalysisTaskHFE &ref);\r
+    AliAnalysisTaskHFE& operator=(const AliAnalysisTaskHFE &ref);\r
+    virtual void Copy(TObject &o) const;\r
+    virtual ~AliAnalysisTaskHFE();\r
+\r
+    virtual void UserCreateOutputObjects();\r
+    virtual void UserExec(Option_t *);\r
+    virtual void Terminate(Option_t *);\r
+\r
+    virtual Bool_t IsEventInBinZero();\r
+\r
+    Bool_t IsQAOn(Int_t qaLevel) const { return TESTBIT(fQAlevel, qaLevel); };\r
+    Bool_t IsAODanalysis() const { return TestBit(kAODanalysis); };\r
+    Bool_t IsESDanalysis() const { return !TestBit(kAODanalysis); };\r
+    Bool_t HasMCData() const { return TestBit(kHasMCdata); }\r
+    Bool_t Ispp() const { return fCollisionSystem.TestBitNumber(kpp); }\r
+    Bool_t IsPbPb() const { return fCollisionSystem.TestBitNumber(kPbPb); }\r
+    Bool_t IspPb() const { return fCollisionSystem.TestBitNumber(kpPb); }\r
+    Bool_t IsHeavyIon() const { return IsPbPb() || IspPb(); }\r
+    Bool_t GetPlugin(Int_t plug) const { return TESTBIT(fPlugins, plug); };\r
+\r
+    // Get Components for configuration\r
+    AliHFEvarManager *GetVarManager() const { return fVarManager; }\r
+    AliHFEpidQAmanager *GetPIDQAManager() const { return fPIDqa; }\r
+    AliHFEpid *GetPID() const { return fPID; }\r
+    AliHFENonPhotonicElectron *GetHFEBackgroundSubtraction() const { return fBackgroundSubtraction; }\r
+\r
+    void SetHFECuts(AliHFEcuts * const cuts) { fCuts = cuts; };\r
+    void SetTaggedTrackCuts(AliHFEcuts * const cuts) { fTaggedTrackCuts = cuts; }\r
+    void SetCleanTaggedTrack(Bool_t clean) { fCleanTaggedTrack = clean; };\r
+    void SetVariablesTRDTaggedTrack(Bool_t variablesTRD) { fVariablesTRDTaggedTrack = variablesTRD; };\r
+    void SetHFECutsPreselect(AliESDtrackCuts * const cuts) { fCutspreselect = cuts; };\r
+    void SetHFEElecBackGround(AliHFEelecbackground * const elecBackGround) { fElecBackGround = elecBackGround; };\r
+    void SetHFEBackgroundSubtraction(AliHFENonPhotonicElectron * const backgroundSubtraction) { fBackgroundSubtraction = backgroundSubtraction; };\r
+    void SetQAOn(Int_t qaLevel) { SETBIT(fQAlevel, qaLevel); };\r
+    void SwitchOnPlugin(Int_t plug);\r
+    void SetHasMCData(Bool_t hasMC = kTRUE) { SetBit(kHasMCdata, hasMC); };\r
+    void SetFillSignalOnly(Bool_t signalOnly) { fFillSignalOnly = signalOnly; }\r
+   \r
+    void SetFillNoCuts(Bool_t fillNoCuts) { fFillNoCuts = fillNoCuts; }\r
+    void SetApplyCutAOD(Bool_t applyCutAOD)   { fApplyCutAOD = applyCutAOD; }\r
+    void SetRemovePileUp(Bool_t removePileUp) { fRemovePileUp = removePileUp; }\r
+    void SetRemoveFirstEventInChunk() {fRemoveFirstEvent = kTRUE;}\r
+    void SetPIDPreselect(AliHFEpid * const cuts) { fPIDpreselect = cuts; };\r
+    void SetAODAnalysis() { SetBit(kAODanalysis, kTRUE); };\r
+    void SetESDAnalysis() { SetBit(kAODanalysis, kFALSE); };\r
+    void SetTRDTrigger(Bool_t activateTRDTrigger, Int_t trdtrigger) {fTRDTrigger=activateTRDTrigger; fWhichTRDTrigger=trdtrigger;};\r
+    void SetCollisionSystem(ECollisionSystem_t system){\r
+      fCollisionSystem.Clear();\r
+      fCollisionSystem.SetBitNumber(system, kTRUE);\r
+    }\r
+    void SetppAnalysis(){\r
+      fCollisionSystem.SetBitNumber(kpPb, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kPbPb, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kpp, kTRUE); \r
+    }\r
+    void SetpPbAnalysis() {\r
+      fCollisionSystem.SetBitNumber(kpp, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kPbPb, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kpPb, kTRUE); \r
+    }\r
+    void SetPbPbAnalysis() { \r
+      fCollisionSystem.SetBitNumber(kpp, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kpPb, kFALSE); \r
+      fCollisionSystem.SetBitNumber(kPbPb, kTRUE); \r
+    };\r
+    void SetCentralityEstimator(const char *estimator) { fCentralityEstimator = estimator; }\r
+    void SetPbPbUserCentralityLimit(Bool_t isPbPbUserBinning = kFALSE){fPbPbUserCentralityBinning = isPbPbUserBinning; };\r
+    void SetPbPbUserCentralityArray(Int_t icentr, Float_t valuecentr) {fCentralityLimits[icentr] = valuecentr;};\r
+    void SetPPMultiBinAnalysis(Bool_t isppMultiBin) { fisppMultiBin = isppMultiBin; };\r
+    void SetNonHFEsystematics(Bool_t isSystematics) {fisNonHFEsystematics = isSystematics; };\r
+    void SetRejectKinkMother(Bool_t rejectKinkMother = kFALSE) { fRejectKinkMother = rejectKinkMother; };\r
+    void SetBackGroundFactorsFunction(const TF1 * const backGroundFactorsFunction, Int_t centralitybin=0){  \r
+      fkBackGroundFactorArray[centralitybin]=backGroundFactorsFunction;\r
+      fBackGroundFactorApply=kTRUE;\r
+      SetBit(kBackgroundInitialized);\r
+    };\r
+    void SetElecBackGroundFactors(Int_t iPt, Int_t iType, Int_t iCent, Int_t iError, Double_t elecBackGroundFactor) {fElecBackgroundFactor[iError][iCent][iType][iPt] = elecBackGroundFactor; };\r
+    void SetBinLimits(Int_t iPt, Double_t momentum){fBinLimit[iPt] = momentum;};\r
+    void PrintStatus() const;\r
+    Bool_t ReadCentrality();\r
+    void RejectionPileUpVertexRangeEventCut();  \r
+    void SelectSpecialTrigger(const Char_t *trgclust, Int_t runMin = 0, Int_t runMax = 999999999); \r
+    void SetDebugStreaming() {SetBit(kTreeStream);};\r
+    Bool_t CheckTRDTrigger(AliESDEvent *ev);\r
+\r
+  private:\r
+    enum{\r
+      kHasMCdata = BIT(19),\r
+      kAODanalysis = BIT(20),\r
+      kBackgroundInitialized = BIT(21),\r
+      kTreeStream = BIT(22)\r
+    };\r
+\r
+    Bool_t FillProductionVertex(const AliVParticle * const track) const;\r
+    void MakeParticleContainer();\r
+    void MakeEventContainer();\r
+    void InitHistoITScluster();\r
+    void InitContaminationQA();\r
+    const Char_t *GetSpecialTrigger(Int_t run);\r
+    void ProcessMC();\r
+    void ProcessESD();\r
+    void ProcessAOD();\r
+    Int_t GetITSMultiplicity(AliVEvent *ev);\r
+    Bool_t PreSelectTrack(AliESDtrack *track) const;\r
+    Bool_t ProcessMCtrack(AliVParticle *track);\r
+    Bool_t ProcessCutStep(Int_t cutStep, AliVParticle *track);\r
+    AliAODMCHeader *fAODMCHeader;         // ! MC info AOD\r
+    TClonesArray *fAODArrayMCInfo;        // ! MC info particle AOD\r
+    ULong_t fQAlevel;                     // QA level\r
+    UShort_t fPlugins;                    // Enabled Plugins\r
+    TBits fCollisionSystem;              // Collision System;\r
+    Bool_t fFillSignalOnly;               // Fill container only with MC Signal Tracks\r
+    Bool_t fFillNoCuts;                   // Fill container before any cut\r
+    Bool_t fApplyCutAOD;                  // Apply the analysis cut for AOD tracks\r
+    Bool_t fBackGroundFactorApply;        // Apply Background Function Subtraction,   MF: To be removed when transition to OADB container is finished\r
+    Bool_t fRemovePileUp;                 // Remove Pile Up\r
+    Bool_t fIdentifiedAsPileUp;           // Identified as pile-up\r
+    Bool_t fIdentifiedAsOutInz;           // Out Of Range in z\r
+    Bool_t fPassTheEventCut;              // Pass The Event Cut\r
+    Bool_t fRejectKinkMother;             // Reject Kink Mother\r
+    Bool_t fisppMultiBin;                 // pp Multiplicity Bin analysis\r
+    Bool_t fPbPbUserCentralityBinning;    // PbPb user centrality binning\r
+    Bool_t fRemoveFirstEvent;             // Remove first event from chunk\r
+    Bool_t fisNonHFEsystematics;          // Non-HFE background systematics analysis\r
+    AliOADBContainer *fSpecialTrigger;    // Special trigger selection\r
+    Int_t   fCentralityF;                 // Centrality bin\r
+    Float_t fCentralityPercent;           // Centrality percentile\r
+    TString fCentralityEstimator;         // Centrality Estimator\r
+    Float_t fContributors;                // Contributors\r
+    Double_t fWeightBackGround;            // weight background function\r
+    Double_t fVz;                         // z position of the primary vertex\r
+    const TF1  *fkBackGroundFactorArray[12];   // Array of BackGround factors for each centrality bin, bin0 = min bias\r
+    Double_t fElecBackgroundFactor[kBgLevels][kCentBins][kElecBgSpecies][kBgPtBins];     // Electron background factors\r
+    Double_t fBinLimit[kBgPtBins+1];      // Electron pt bin edges\r
+    Float_t fCentralityLimits[12];        // Limits for centrality bins\r
+    AliHFEcontainer *fContainer;          //! The HFE container\r
+    AliHFEvarManager *fVarManager;        // The var manager as the backbone of the analysis\r
+    AliHFEsignalCuts *fSignalCuts;        //! MC true signal (electron coming from certain source) \r
+    AliCFManager *fCFM;                   //! Correction Framework Manager\r
+    AliTriggerAnalysis *fTriggerAnalysis; //! Trigger Analysis for Normalisation\r
+    AliHFEpid *fPID;                      // PID\r
+    AliHFEpidQAmanager *fPIDqa;           // PID QA\r
+    AliHFEpid *fPIDpreselect;             // PID oject for pre-selected tracks (without QA)\r
+    AliHFEcuts *fCuts;                    // Cut Collection\r
+    AliHFEcuts *fTaggedTrackCuts;         // Cut Collection for V0 tagged tracks\r
+    Bool_t fCleanTaggedTrack;             // Loose cleaning of the V0 tagged tracks electron\r
+    Bool_t fVariablesTRDTaggedTrack;      // Take the variables at the TRD for the V0 tagged tracks electron\r
+    AliAnalysisUtils *fAnalysisUtils;     // Utility object to remove the first event of a chunk from the analysis\r
+    AliESDtrackCuts *fCutspreselect;      // Cut Collection for pre-selected tracks\r
+    AliHFEsecVtx *fSecVtx;                //! Secondary Vertex Analysis\r
+    AliHFEelecbackground *fElecBackGround;//! Background analysis\r
+    AliHFEmcQA *fMCQA;                    //! MC QA\r
+    AliHFEtaggedTrackAnalysis *fTaggedTrackAnalysis;     //!Analyse V0-tagged tracks\r
+    AliHFEextraCuts *fExtraCuts;          //! temporary implementation for IP QA\r
+    AliHFENonPhotonicElectron *fBackgroundSubtraction; // Background subtraction\r
+    Bool_t fTRDTrigger;                   // Check if event is TRD triggered event\r
+    Int_t  fWhichTRDTrigger;               // Select type of TRD trigger\r
+    //-----------QA and output---------------\r
+    TList *fQA;                           //! QA histos for the cuts\r
+    TList *fOutput;                       //! Container for Task Output\r
+    TList *fHistMCQA;                     //! Output container for MC QA histograms \r
+    TList *fHistSECVTX;                   //! Output container for sec. vertexing results\r
+    TList *fHistELECBACKGROUND;           //! Output container for electron background analysis\r
+    AliHFEcollection *fQACollection;      //! Tasks own QA collection\r
+    //---------------------------------------\r
+\r
+    ClassDef(AliAnalysisTaskHFE, 2)       // The electron Analysis Task\r
+};\r
+#endif\r
+\r
index f06b52d..4b60bd2 100644 (file)
-#include <fstream>
-#include <iostream>
-#include <string>
-
-TString g_aliroot_version;
-TString g_root_version;
-TString g_sample;
-TString g_plugin_mode;
-TString g_train_dir;
-TArrayI g_runlist;
-
-AliAnalysisAlien *CreateGridHandler(){
-        //
-        // Setup main settings of the Alien plugin
-        //
-        AliAnalysisAlien *plugin = new AliAnalysisAlien();
-        plugin->SetRunMode(g_plugin_mode.Data());
-        if(!g_plugin_mode.CompareTo("Terminate"))
-                plugin->SetMergeViaJDL(kFALSE);
-        else
-                plugin->SetMergeViaJDL(kTRUE);
-        plugin->SetOverwriteMode();
-        plugin->SetNtestFiles(1);
-
-        plugin->SetAPIVersion("V1.1x");
-        plugin->SetROOTVersion(g_root_version.Data());
-        plugin->SetAliROOTVersion(g_aliroot_version.Data());
-
-        plugin->SetOutputToRunNo();
-        plugin->AddIncludePath("-I. .I$ALIEN_ROOT/api/lib -I$ROOTSYS/lib -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/PWGHF/ -I$ALICE_ROOT/PWGHF/hfe/macros -I$ALICE_ROOT/PWGHF/hfe -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/ANALYSIS/Tender -I$ALICE_ROOT/ANALYSIS/TenderSupplies -I$ALICE_ROOT/PWG/ -I$ALICE_ROOT/PWG/FLOW -I$ALICE_ROOT/PWG/Base -I$ALICE_ROOT/PWG/Tasks");
-        plugin->SetAdditionalLibs("libGui.so  libXMLParser.so libSTEERBase.so libESD.so libAOD.so libCDB.so libANALYSIS.so libANALYSISalice.so libCORRFW.so  libPWGflowBase.so libPWGflowTasks.so libPWGHFhfe.so libTENDER.so libProof.so libRAWDatabase.so libSTEER.so libTOFbase.so");
-   
-        plugin->SetDefaultOutputs(kFALSE);
-        plugin->SetOutputFiles("AnalysisResults.root"); 
-        plugin->SetExecutableCommand("aliroot -b -q");
-        plugin->SetTTL(30000);
-        plugin->SetInputFormat("xml-single");
-        plugin->SetPrice(1);      
-        plugin->SetSplitMode("se");
-        return plugin;
-}
-
-void SplitConfigEntry(const std::string &input, TString &key, TString &value){
-        //
-        // Decode key and value of a config entry
-        //
-        std::istringstream stream(input, istringstream::in);
-        std::string tmp;
-        stream >> tmp;
-        key = tmp.c_str();
-        stream >> tmp;
-        value = tmp.c_str();
-}
-
-void DecodeRunlist(const TString &val){
-        //
-        // Tokenize run list
-        //
-        TObjArray *runstrings = val.Tokenize(",");
-        TObjString *os;
-        TString runstr;
-        TIter runIter(runstrings);
-        g_runlist.Set(runstrings->GetEntries());
-        int nruns(0);
-        while((os = dynamic_cast<TObjString *>(runIter()))){
-                runstr = os->String();
-                g_runlist[nruns++] = runstr.Atoi();
-        }
-        delete runstrings;
-}
-
-bool IsMC(const TString &val){
-        // 
-        // Determine whether sample is MC or Data
-        //
-        if(!val.CompareTo("MC")) return true;
-        return false;
-}
-
-bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){
-        //
-        // Find Data sample in the list of samples
-        //
-        TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));
-        if(!entry){
-                printf("Sample %s not found in the list of samples", g_sample.Data());
-                return false;
-        }
-        // Copy to output container
-        sampleinfis.SetOwner(kFALSE);
-        for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);
-        return true;
-}
-
-bool GetData(TObjArray &in, TString &out, int pos){
-        //
-        // Helper function reading data string
-        //
-        TObjString *entry = dynamic_cast<TObjString *>(in.At(pos));
-        if(!entry){
-                printf("Entry at pos %d not a string\n", pos);
-                return false;
-        }
-        out = entry->String();
-        return true;
-}
-
-void AddSample(TMap &lookup,
-                const char *key, const char* datadir, const char * pattern, const char *sampletype, const char *dataformat){
-        //
-        // Add sample entry to the lookup table
-        //
-        TObjArray *infos = new TObjArray(); 
-        infos->AddAt(new TObjString(datadir), 0);
-        infos->AddAt(new TObjString(pattern), 1);
-        infos->AddAt(new TObjString(sampletype), 2);
-        infos->AddAt(new TObjString(dataformat), 3);
-        lookup.Add(new TObjString(key), infos);
-}
-
-void Generate_Sample_Lookup(TMap &lookup){
-        // 
-        // Create Lookup table for each period
-        // Vector contains 
-        //   - path
-        //   - pattern
-        //   - MC/Data 
-        //   - ESD/AOD
-        //
-        AddSample(lookup, "LHC13b.pass2", "/alice/data/2013/LHC13b", "*/pass2/*/AliESDs.root", "Data", "ESD");
-        AddSample(lookup, "LHC13b.pass2.AOD", "/alice/data/2013/LHC13b", "*/pass2/AOD/*/AliAOD.root", "Data", "AOD"); 
-        AddSample(lookup, "LHC13b.pass2.AOD126", "/alice/data/2013/LHC13b", "*/pass2/AOD126/*/AliAOD.root", "Data", "AOD"); 
-        AddSample(lookup, "LHC13c.pass1", "/alice/data/2013/LHC13c/", "*/pass1/*/AliESDs.root", "Data", "ESD");
-        AddSample(lookup, "LHC13c.pass1.AOD", "/alice/data/2013/LHC13c/", "*/pass1/AOD/*/AliAOD.root", "Data", "AOD");
-        AddSample(lookup, "LHC13c.pass1.AOD126", "/alice/data/2013/LHC13c/", "*/pass1/AOD126/*/AliAOD.root", "Data", "AOD");
-        AddSample(lookup, "LHC13b2", "/alice/sim/2013/LHC13b2", "*/*/AliESDs.root", "MC", "ESD");
-        AddSample(lookup, "LHC13b2.AOD", "/alice/sim/2013/LHC13b2", "*/AliAOD.root", "MC", "AOD");
-        AddSample(lookup, "LHC13b2plus", "/alice/sim/2013/LHC13b2_plus", "*/*/AliESDs.root", "MC", "ESD");
-        AddSample(lookup, "LHC13b2plus.AOD", "/alice/sim/2013/LHC13b2_plus", "*/AliAOD.root", "MC", "AOD");
-        AddSample(lookup, "LHC13b3", "/alice/sim/2013/LHC13b3", "*/*/AliESDs.root", "MC", "ESD");
-        AddSample(lookup, "LHC13b3.AOD", "/alice/sim/2013/LHC13b3", "*/AliAOD.root", "MC", "AOD");
-        printf("Lookup table with sample information generated\n");
-}
-
-void ConfigParser(const char *configname){
-        //
-        // Parse configuration
-        //
-        std::ifstream in(configname);
-        std::string config;
-        TString key, value;
-        while(getline(in, config)){
-                SplitConfigEntry(config, key, value);
-                key.ToLower();
-                if(!key.CompareTo("aliroot")){
-                        // Aliroot version
-                        g_aliroot_version = value;
-                        continue;
-                }
-                if(!key.CompareTo("root")){
-                        // root version
-                        g_root_version = value;
-                        continue;
-                }
-                if(!key.CompareTo("sample")){
-                        // sample name
-                        g_sample = value; 
-                        continue;
-                }
-                if(!key.CompareTo("runlist")){
-                        // Runlist
-                        DecodeRunlist(value); 
-                        continue;
-                }
-                if(!key.CompareTo("mode")){
-                        g_plugin_mode = value;
-                        continue;
-                }
-                if(!key.CompareTo("traindir")){
-                        g_train_dir = value;
-                        continue;
-                }
-                printf("Unknown key: %s\n", key.Data());
-        }
-}
-
-bool MakeSample(AliAnalysisAlien *plugin, TMap &lookup){
-        //
-        // Fill Sample information (Data dir, pattern, run list) to the Alien plugin
-        //
-        TObjArray infos;
-        bool found = FindDataSample(lookup, infos);
-        if(!found){
-                printf("sample %s not found\n", g_sample.Data());
-                return false;
-        }
-        TString datadir, pattern, type;
-        GetData(infos, datadir, 0);
-        GetData(infos, pattern, 1);
-        GetData(infos, type, 2);
-        plugin->SetGridDataDir(datadir.Data());
-        plugin->SetDataPattern(pattern.Data());
-        if(!IsMC(type)) plugin->SetRunPrefix("000");
-        // Add runs to the sample
-        for(int irun = 0; irun < g_runlist.GetSize(); irun++){
-                plugin->AddRunNumber(g_runlist[irun]);
-        }
-        return true;
-}
-
-bool CreateTrainDir(AliAnalysisAlien *plugin, const TMap &lookup){
-        //
-        // Make train data dir name and JDL, C and sh file names
-        //
-        TObjArray infos;
-        bool found = FindDataSample(lookup, infos);
-        if(!found){
-                printf("sample %s not found\n", g_sample.Data());
-                return false;
-        }
-        TString type; GetData(infos, type, 2);
-
-        // check whether the train dir is already provided or needs to be specified
-        if(!g_train_dir.Length()){
-                // Query number of train runs before
-                const char *gridhome = gGrid->GetHomeDirectory();
-                const char gridoutdir[256];
-                sprintf(gridoutdir, "%sAnalysis_pPb/%s", gridhome, type.Data());
-                TGridResult *trainruns = gGrid->Ls(gridoutdir);
-                int nruns = trainruns->GetEntries();
-                // Get Date and time
-                TDatime time;
-                g_train_dir = Form("%d_%d%02d%02d_%02d%02d", nruns, time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute());
-        }
-        
-        plugin->SetGridWorkingDir(Form("Analysis_pPb/%s/%s", type.Data(), g_train_dir.Data()));
-        plugin->SetJDLName(Form("TPCTOFanalysispPb_%s_%s.jdl", type.Data(), g_train_dir.Data()));
-        plugin->SetExecutable(Form("TPCTOFanalysispPb_%s_%s.sh", type.Data(), g_train_dir.Data()));
-        plugin->SetAnalysisMacro(Form("TPCTOFanalysispPb_%s_%s.C", type.Data(), g_train_dir.Data()));
-        return true;
-}
-
-void SetupUtil(bool IsMC, bool isAOD){
-        //
-        // Setup utility packages
-        //
-        // 1. Physics Selection (ESD only)
-        // 2. Tender (ESD only)
-        // 3. PID Response (always)
-        // 4. Centrality Task (ESD only)
-        //
-
-        //==== Physics Selection ====
-        if(!isAOD){
-                gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
-                AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);
-        }
-
-        //==== Add tender ====
-        if(!isAOD){
-                gROOT->LoadMacro("AddTaskTender.C");
-                AddTaskTender();
-        }
-
-        //===== ADD PID RESPONSE: ===
-        gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
-        AddTaskPIDResponse();
-
-        //===== ADD CENTRALITY: ===
-        if(!isAOD){
-                gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
-                AddTaskCentrality();
-        }
-}
-
-void SetupHandlers(bool isMC, bool isAOD){
-        //
-        // Setup Handlers
-        //
-        TString macrobase = "$ALICE_ROOT/ANALYSIS/macros/train/";
-        TString macroname = macrobase;
-        if(isAOD)
-                macroname += "AddAODHandler.C";
-        else
-                macroname += "AddESDHandler.C";
-        gROOT->Macro(macroname.Data());
-
-        if(isMC){
-                // Add MC truth event handler
-                gROOT->LoadMacro(Form("%s/AddMCHandler.C", macrobase.Data()));
-                AddMCHandler();
-        }
-}
-
-void SetupHFEtask(bool isMC, bool isAOD){
-        gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/AddTaskHFEpPb.C");
-        AddTaskHFEpPb(isAOD);
-        if(!isAOD){
-                gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/AddTaskHFEnpepPb.C");
-                AddTaskHFEnpepPb();
-        }
-}
-
-void SetupTrain(const TMap &lookup){
-        //
-        // Setup train:
-        //   Determine whether the trains run on MC or Data 
-        //   and ESDs or AODs and Configure Handlers, utils
-        //   and HFE task according to this
-        //
-        bool isMC(false), isAOD(false);
-        TObjArray infos;
-        bool found = FindDataSample(lookup, infos);
-        if(!found) return;
-        TString type, mode;
-        GetData(infos, type, 2);
-        GetData(infos, mode, 3);
-        isMC = IsMC(type);
-        if(!mode.CompareTo("AOD")) isAOD = true;
-      
-        SetupHandlers(isMC, isAOD);
-        SetupUtil(isMC, isAOD);
-        SetupHFEtask(isMC, isAOD);
-}
-
-void GenerateMergeConfigs(){
-        //
-        // Generate configurations for merging 
-        // (MergeViaJDL and Terminate)
-        //
-
-        // Write config for MergeViaJDL
-        std::ofstream outMerge("configMerge.txt");
-        outMerge << "aliroot " << g_aliroot_version.Data() << std::endl;
-        outMerge << "root " << g_root_version.Data() << std::endl;
-        outMerge << "sample " << g_sample.Data() << std::endl;
-        outMerge << "mode MergeViaJDL\n";
-        outMerge << "traindir " << g_train_dir.Data() << std::endl; 
-        outMerge << "runlist ";
-        for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) outMerge << g_runlist[irun] << ",";
-        outMerge << g_runlist[g_runlist.GetSize()-1] << std::endl;
-        outMerge.close();
-        // Write config for Terminate
-        std::ofstream outTerminate("configTerminate.txt");
-        outMerge << "aliroot " << g_aliroot_version.Data() << std::endl;
-        outMerge << "root " << g_root_version.Data() << std::endl;
-        outMerge << "sample " << g_sample.Data() << std::endl;
-        outMerge << "mode Terminate\n";
-        outMerge << "traindir " << g_train_dir.Data() << std::endl; 
-        outMerge << "runlist ";
-        for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) outMerge << g_runlist[irun] << ",";
-        outMerge << g_runlist[g_runlist.GetSize()-1] << std::endl;
-        outMerge.close();
-
-        printf("Configurations for MergeViaJDL and terminate generated\n");
-}
-
-void runGridpPb(const char *config = "config.txt"){
-        //
-        // run analysis 
-        //
-
-        TGrid::Connect("alien://");
-
-        // Create Lookup with sample information
-        TMap sampleinfos;
-        Generate_Sample_Lookup(sampleinfos);
-
-        ConfigParser(config);
-
-        // Configure alien plugin
-        AliAnalysisAlien *plugin = CreateGridHandler();
-        if(!CreateTrainDir(plugin, sampleinfos)){
-                printf("Cannot setup output directory\n");
-                return;
-        }
-        if(!MakeSample(plugin, sampleinfos)){
-                printf("Cannot create data sample\n");
-                return;
-        }
-        if(!g_plugin_mode.CompareTo("full")){
-                // full mode, creating config files for the merging stage
-                GenerateMergeConfigs();
-        }
-
-        AliAnalysisManager *mgr = new AliAnalysisManager("tpctofanalysis");
-        mgr->SetGridHandler(plugin);
-        
-        SetupTrain(sampleinfos);
-
-        // Run train
-        if (!mgr->InitAnalysis()) return;
-        mgr->PrintStatus();
-        // Start analysis in grid.
-        mgr->StartAnalysis("grid");
-} 
-
+#include <fstream>\r
+#include <iostream>\r
+#include <string>\r
+\r
+TString g_aliroot_version;\r
+TString g_root_version;\r
+TString g_sample;\r
+TString g_plugin_mode;\r
+TString g_train_dir;\r
+TArrayI g_runlist;\r
+\r
+AliAnalysisAlien *CreateGridHandler(){\r
+        //\r
+        // Setup main settings of the Alien plugin\r
+        //\r
+        AliAnalysisAlien *plugin = new AliAnalysisAlien();\r
+        plugin->SetRunMode(g_plugin_mode.Data());\r
+        if(!g_plugin_mode.CompareTo("Terminate"))\r
+                plugin->SetMergeViaJDL(kFALSE);\r
+        else\r
+                plugin->SetMergeViaJDL(kTRUE);\r
+        plugin->SetOverwriteMode();\r
+        plugin->SetNtestFiles(1);\r
+\r
+        plugin->SetAPIVersion("V1.1x");\r
+        plugin->SetROOTVersion(g_root_version.Data());\r
+        plugin->SetAliROOTVersion(g_aliroot_version.Data());\r
+\r
+        plugin->SetOutputToRunNo();\r
+        plugin->AddIncludePath("-I. .I$ALIEN_ROOT/api/lib -I$ROOTSYS/lib -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/PWGHF/ -I$ALICE_ROOT/PWGHF/hfe/macros -I$ALICE_ROOT/PWGHF/hfe -I$ALICE_ROOT/ANALYSIS -I$ALICE_ROOT/ANALYSIS/Tender -I$ALICE_ROOT/ANALYSIS/TenderSupplies -I$ALICE_ROOT/PWG/ -I$ALICE_ROOT/PWG/FLOW -I$ALICE_ROOT/PWG/Base -I$ALICE_ROOT/PWG/Tasks");\r
+        plugin->SetAdditionalLibs("libGui.so  libXMLParser.so libSTEERBase.so libESD.so libAOD.so libCDB.so libANALYSIS.so libANALYSISalice.so libCORRFW.so  libPWGflowBase.so libPWGflowTasks.so libPWGHFhfe.so libTENDER.so libProof.so libRAWDatabase.so libSTEER.so libTOFbase.so");\r
+   \r
+        plugin->SetDefaultOutputs(kFALSE);\r
+        plugin->SetOutputFiles("AnalysisResults.root"); \r
+        plugin->SetExecutableCommand("aliroot -b -q");\r
+        plugin->SetTTL(30000);\r
+        plugin->SetInputFormat("xml-single");\r
+        plugin->SetPrice(1);      \r
+        plugin->SetSplitMode("se");\r
+        return plugin;\r
+}\r
+\r
+void SplitConfigEntry(const std::string &input, TString &key, TString &value){\r
+        //\r
+        // Decode key and value of a config entry\r
+        //\r
+        std::istringstream stream(input, istringstream::in);\r
+        std::string tmp;\r
+        stream >> tmp;\r
+        key = tmp.c_str();\r
+        stream >> tmp;\r
+        value = tmp.c_str();\r
+}\r
+\r
+void DecodeRunlist(const TString &val){\r
+        //\r
+        // Tokenize run list\r
+        //\r
+        TObjArray *runstrings = val.Tokenize(",");\r
+        TObjString *os;\r
+        TString runstr;\r
+        TIter runIter(runstrings);\r
+        g_runlist.Set(runstrings->GetEntries());\r
+        int nruns(0);\r
+        while((os = dynamic_cast<TObjString *>(runIter()))){\r
+                runstr = os->String();\r
+                g_runlist[nruns++] = runstr.Atoi();\r
+        }\r
+        delete runstrings;\r
+}\r
+\r
+bool IsMC(const TString &val){\r
+        // \r
+        // Determine whether sample is MC or Data\r
+        //\r
+        if(!val.CompareTo("MC")) return true;\r
+        return false;\r
+}\r
+\r
+bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){\r
+        //\r
+        // Find Data sample in the list of samples\r
+        //\r
+        TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));\r
+        if(!entry){\r
+                printf("Sample %s not found in the list of samples", g_sample.Data());\r
+                return false;\r
+        }\r
+        // Copy to output container\r
+        sampleinfis.SetOwner(kFALSE);\r
+        for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);\r
+        return true;\r
+}\r
+\r
+bool GetData(TObjArray &in, TString &out, int pos){\r
+        //\r
+        // Helper function reading data string\r
+        //\r
+        TObjString *entry = dynamic_cast<TObjString *>(in.At(pos));\r
+        if(!entry){\r
+                printf("Entry at pos %d not a string\n", pos);\r
+                return false;\r
+        }\r
+        out = entry->String();\r
+        return true;\r
+}\r
+\r
+void AddSample(TMap &lookup,\r
+                const char *key, const char* datadir, const char * pattern, const char *sampletype, const char *dataformat){\r
+        //\r
+        // Add sample entry to the lookup table\r
+        //\r
+        TObjArray *infos = new TObjArray(); \r
+        infos->AddAt(new TObjString(datadir), 0);\r
+        infos->AddAt(new TObjString(pattern), 1);\r
+        infos->AddAt(new TObjString(sampletype), 2);\r
+        infos->AddAt(new TObjString(dataformat), 3);\r
+        lookup.Add(new TObjString(key), infos);\r
+}\r
+\r
+void Generate_Sample_Lookup(TMap &lookup){\r
+        // \r
+        // Create Lookup table for each period\r
+        // Vector contains \r
+        //   - path\r
+        //   - pattern\r
+        //   - MC/Data \r
+        //   - ESD/AOD\r
+        //\r
+        AddSample(lookup, "LHC13b.pass2", "/alice/data/2013/LHC13b", "*/pass2/*/AliESDs.root", "Data", "ESD");\r
+        AddSample(lookup, "LHC13b.pass2.AOD", "/alice/data/2013/LHC13b", "*/pass2/AOD/*/AliAOD.root", "Data", "AOD"); \r
+        AddSample(lookup, "LHC13b.pass2.AOD126", "/alice/data/2013/LHC13b", "*/pass2/AOD126/*/AliAOD.root", "Data", "AOD"); \r
+        AddSample(lookup, "LHC13c.pass1", "/alice/data/2013/LHC13c/", "*/pass1/*/AliESDs.root", "Data", "ESD");\r
+        AddSample(lookup, "LHC13c.pass1.AOD", "/alice/data/2013/LHC13c/", "*/pass1/AOD/*/AliAOD.root", "Data", "AOD");\r
+        AddSample(lookup, "LHC13c.pass1.AOD126", "/alice/data/2013/LHC13c/", "*/pass1/AOD126/*/AliAOD.root", "Data", "AOD");\r
+        AddSample(lookup, "LHC13b2", "/alice/sim/2013/LHC13b2", "*/*/AliESDs.root", "MC", "ESD");\r
+        AddSample(lookup, "LHC13b2.AOD", "/alice/sim/2013/LHC13b2", "*/AliAOD.root", "MC", "AOD");\r
+        AddSample(lookup, "LHC13b2plus", "/alice/sim/2013/LHC13b2_plus", "*/*/AliESDs.root", "MC", "ESD");\r
+        AddSample(lookup, "LHC13b2plus.AOD", "/alice/sim/2013/LHC13b2_plus", "*/AliAOD.root", "MC", "AOD");\r
+        AddSample(lookup, "LHC13b3", "/alice/sim/2013/LHC13b3", "*/*/AliESDs.root", "MC", "ESD");\r
+        AddSample(lookup, "LHC13b3.AOD", "/alice/sim/2013/LHC13b3", "*/AliAOD.root", "MC", "AOD");\r
+        printf("Lookup table with sample information generated\n");\r
+}\r
+\r
+void ConfigParser(const char *configname){\r
+        //\r
+        // Parse configuration\r
+        //\r
+        std::ifstream in(configname);\r
+        std::string config;\r
+        TString key, value;\r
+        while(getline(in, config)){\r
+                SplitConfigEntry(config, key, value);\r
+                key.ToLower();\r
+                if(!key.CompareTo("aliroot")){\r
+                        // Aliroot version\r
+                        g_aliroot_version = value;\r
+                        continue;\r
+                }\r
+                if(!key.CompareTo("root")){\r
+                        // root version\r
+                        g_root_version = value;\r
+                        continue;\r
+                }\r
+                if(!key.CompareTo("sample")){\r
+                        // sample name\r
+                        g_sample = value; \r
+                        continue;\r
+                }\r
+                if(!key.CompareTo("runlist")){\r
+                        // Runlist\r
+                        DecodeRunlist(value); \r
+                        continue;\r
+                }\r
+                if(!key.CompareTo("mode")){\r
+                        g_plugin_mode = value;\r
+                        continue;\r
+                }\r
+                if(!key.CompareTo("traindir")){\r
+                        g_train_dir = value;\r
+                        continue;\r
+                }\r
+                printf("Unknown key: %s\n", key.Data());\r
+        }\r
+}\r
+\r
+bool MakeSample(AliAnalysisAlien *plugin, TMap &lookup){\r
+        //\r
+        // Fill Sample information (Data dir, pattern, run list) to the Alien plugin\r
+        //\r
+        TObjArray infos;\r
+        bool found = FindDataSample(lookup, infos);\r
+        if(!found){\r
+                printf("sample %s not found\n", g_sample.Data());\r
+                return false;\r
+        }\r
+        TString datadir, pattern, type;\r
+        GetData(infos, datadir, 0);\r
+        GetData(infos, pattern, 1);\r
+        GetData(infos, type, 2);\r
+        plugin->SetGridDataDir(datadir.Data());\r
+        plugin->SetDataPattern(pattern.Data());\r
+        if(!IsMC(type)) plugin->SetRunPrefix("000");\r
+        // Add runs to the sample\r
+        for(int irun = 0; irun < g_runlist.GetSize(); irun++){\r
+                plugin->AddRunNumber(g_runlist[irun]);\r
+        }\r
+        return true;\r
+}\r
+\r
+bool CreateTrainDir(AliAnalysisAlien *plugin, const TMap &lookup){\r
+        //\r
+        // Make train data dir name and JDL, C and sh file names\r
+        //\r
+        TObjArray infos;\r
+        bool found = FindDataSample(lookup, infos);\r
+        if(!found){\r
+                printf("sample %s not found\n", g_sample.Data());\r
+                return false;\r
+        }\r
+        TString type; GetData(infos, type, 2);\r
+\r
+        // check whether the train dir is already provided or needs to be specified\r
+        if(!g_train_dir.Length()){\r
+                // Query number of train runs before\r
+                const char *gridhome = gGrid->GetHomeDirectory();\r
+                const char gridoutdir[256];\r
+                sprintf(gridoutdir, "%sAnalysis_pPb/%s", gridhome, type.Data());\r
+                TGridResult *trainruns = gGrid->Ls(gridoutdir);\r
+                int nruns = trainruns->GetEntries();\r
+                // Get Date and time\r
+                TDatime time;\r
+                g_train_dir = Form("%d_%d%02d%02d_%02d%02d", nruns, time.GetYear(), time.GetMonth(), time.GetDay(), time.GetHour(), time.GetMinute());\r
+        }\r
+        \r
+        plugin->SetGridWorkingDir(Form("Analysis_pPb/%s/%s", type.Data(), g_train_dir.Data()));\r
+        plugin->SetJDLName(Form("TPCTOFanalysispPb_%s_%s.jdl", type.Data(), g_train_dir.Data()));\r
+        plugin->SetExecutable(Form("TPCTOFanalysispPb_%s_%s.sh", type.Data(), g_train_dir.Data()));\r
+        plugin->SetAnalysisMacro(Form("TPCTOFanalysispPb_%s_%s.C", type.Data(), g_train_dir.Data()));\r
+        return true;\r
+}\r
+\r
+void SetupUtil(bool IsMC, bool isAOD){\r
+        //\r
+        // Setup utility packages\r
+        //\r
+        // 1. Physics Selection (ESD only)\r
+        // 2. Tender (ESD only)\r
+        // 3. PID Response (always)\r
+        // 4. Centrality Task (ESD only)\r
+        //\r
+\r
+        //==== Physics Selection ====\r
+        if(!isAOD){\r
+                gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");\r
+                AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(isMC);\r
+        }\r
+\r
+        //==== Add tender ====\r
+        if(!isAOD){\r
+                gROOT->LoadMacro("AddTaskTender.C");\r
+                AddTaskTender();\r
+        }\r
+\r
+        //===== ADD PID RESPONSE: ===\r
+        gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");\r
+        AddTaskPIDResponse();\r
+\r
+        //===== ADD CENTRALITY: ===\r
+        if(!isAOD){\r
+                gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");\r
+                AddTaskCentrality();\r
+        }\r
+}\r
+\r
+void SetupHandlers(bool isMC, bool isAOD){\r
+        //\r
+        // Setup Handlers\r
+        //\r
+        TString macrobase = "$ALICE_ROOT/ANALYSIS/macros/train/";\r
+        TString macroname = macrobase;\r
+        if(isAOD)\r
+                macroname += "AddAODHandler.C";\r
+        else\r
+                macroname += "AddESDHandler.C";\r
+        gROOT->Macro(macroname.Data());\r
+\r
+        if(isMC){\r
+                // Add MC truth event handler\r
+                gROOT->LoadMacro(Form("%s/AddMCHandler.C", macrobase.Data()));\r
+                AddMCHandler();\r
+        }\r
+}\r
+\r
+void SetupHFEtask(bool isMC, bool isAOD){\r
+        gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/AddTaskHFEpPb.C");\r
+        AddTaskHFEpPb(isAOD);\r
+        if(!isAOD){\r
+                gROOT->LoadMacro("$ALICE_ROOT/PWGHF/hfe/macros/AddTaskHFEnpepPb.C");\r
+                AddTaskHFEnpepPb();\r
+        }\r
+}\r
+\r
+void SetupTrain(const TMap &lookup){\r
+        //\r
+        // Setup train:\r
+        //   Determine whether the trains run on MC or Data \r
+        //   and ESDs or AODs and Configure Handlers, utils\r
+        //   and HFE task according to this\r
+        //\r
+        bool isMC(false), isAOD(false);\r
+        TObjArray infos;\r
+        bool found = FindDataSample(lookup, infos);\r
+        if(!found) return;\r
+        TString type, mode;\r
+        GetData(infos, type, 2);\r
+        GetData(infos, mode, 3);\r
+        isMC = IsMC(type);\r
+        if(!mode.CompareTo("AOD")) isAOD = true;\r
+      \r
+        SetupHandlers(isMC, isAOD);\r
+        SetupUtil(isMC, isAOD);\r
+        SetupHFEtask(isMC, isAOD);\r
+}\r
+\r
+void GenerateMergeConfigs(){\r
+        //\r
+        // Generate configurations for merging \r
+        // (MergeViaJDL and Terminate)\r
+        //\r
+\r
+        // Write config for MergeViaJDL\r
+        std::ofstream outMerge("configMerge.txt");\r
+        outMerge << "aliroot " << g_aliroot_version.Data() << std::endl;\r
+        outMerge << "root " << g_root_version.Data() << std::endl;\r
+        outMerge << "sample " << g_sample.Data() << std::endl;\r
+        outMerge << "mode MergeViaJDL\n";\r
+        outMerge << "traindir " << g_train_dir.Data() << std::endl; \r
+        outMerge << "runlist ";\r
+        for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) outMerge << g_runlist[irun] << ",";\r
+        outMerge << g_runlist[g_runlist.GetSize()-1] << std::endl;\r
+        outMerge.close();\r
+        // Write config for Terminate\r
+        std::ofstream outTerminate("configTerminate.txt");\r
+        outTerminate << "aliroot " << g_aliroot_version.Data() << std::endl;\r
+        outTerminate << "root " << g_root_version.Data() << std::endl;\r
+        outTerminate << "sample " << g_sample.Data() << std::endl;\r
+        outTerminate << "mode Terminate\n";\r
+        outTerminate << "traindir " << g_train_dir.Data() << std::endl; \r
+        outTerminate << "runlist ";\r
+        for(int irun = 0; irun < g_runlist.GetSize()-1; irun++) Terminate << g_runlist[irun] << ",";\r
+        outTerminate << g_runlist[g_runlist.GetSize()-1] << std::endl;\r
+        outTerminate.close();\r
+\r
+        printf("Configurations for MergeViaJDL and terminate generated\n");\r
+}\r
+\r
+void runGridpPb(const char *config = "config.txt"){\r
+        //\r
+        // run analysis \r
+        //\r
+\r
+        TGrid::Connect("alien://");\r
+\r
+        // Create Lookup with sample information\r
+        TMap sampleinfos;\r
+        Generate_Sample_Lookup(sampleinfos);\r
+\r
+        ConfigParser(config);\r
+\r
+        // Configure alien plugin\r
+        AliAnalysisAlien *plugin = CreateGridHandler();\r
+        if(!CreateTrainDir(plugin, sampleinfos)){\r
+                printf("Cannot setup output directory\n");\r
+                return;\r
+        }\r
+        if(!MakeSample(plugin, sampleinfos)){\r
+                printf("Cannot create data sample\n");\r
+                return;\r
+        }\r
+        if(!g_plugin_mode.CompareTo("full")){\r
+                // full mode, creating config files for the merging stage\r
+                GenerateMergeConfigs();\r
+        }\r
+\r
+        AliAnalysisManager *mgr = new AliAnalysisManager("tpctofanalysis");\r
+        mgr->SetGridHandler(plugin);\r
+        \r
+        SetupTrain(sampleinfos);\r
+\r
+        // Run train\r
+        if (!mgr->InitAnalysis()) return;\r
+        mgr->PrintStatus();\r
+        // Start analysis in grid.\r
+        mgr->StartAnalysis("grid");\r
+} \r
+\r