]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
updates for TRD HFE in pPb
authorssakai <ssakai@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 May 2013 12:13:03 +0000 (12:13 +0000)
committerssakai <ssakai@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 13 May 2013 12:13:03 +0000 (12:13 +0000)
PWGHF/hfe/AliHFEdebugTreeTask.cxx
PWGHF/hfe/AliHFEefficiency.cxx
PWGHF/hfe/AliHFEefficiency.h
PWGHF/hfe/AliHFEpidTRD.cxx
PWGHF/hfe/macros/AddTaskHFECal.C
PWGHF/hfe/macros/AddTaskHFEpPb.C
PWGHF/hfe/macros/configs/pPb/ConfigHFEmbpPbTRD.C [new file with mode: 0644]

index 4534b1e64f5d212754a548f0a8a11b8969786191..bc15d26c0585a64e6fd2c7db0fd82d1fc29af2ab 100644 (file)
@@ -34,6 +34,7 @@
 #include "AliMCEvent.h"
 #include "AliMCEventHandler.h"
 #include "AliMCParticle.h"
+#include "AliStack.h"
 #include "AliPIDResponse.h"
 #include "AliTrackReference.h"
 #include "AliVEvent.h"
@@ -165,6 +166,13 @@ void AliHFEdebugTreeTask::UserExec(Option_t *){
     fSignalCuts->SetMCEvent(fMCEvent);
   }
 
+  // MC get stack
+  AliStack* stack = 0x0;
+  if(mcthere){
+      stack = fMCEvent->Stack();
+      if(!stack) AliError("No Stack");
+  }
+
   // Get Primary Vertex
   const AliVVertex *vertex = fInputEvent->GetPrimaryVertex();
   Double_t vtx[3];
@@ -526,6 +534,34 @@ void AliHFEdebugTreeTask::UserExec(Option_t *){
     tofdx=track->GetTOFsignalDx();
     tofdz=track->GetTOFsignalDz();
 
+    // TOF track status
+    UInt_t status = 0;
+    status = track->GetStatus();
+    Bool_t hasTOFout  = status&AliESDtrack::kTOFout; 
+    Bool_t hasTOFtime = status&AliESDtrack::kTIME;
+    Bool_t hasTOFpid  = status&AliESDtrack::kTOFpid;
+    Bool_t hasgoodTOF     = kFALSE;
+    if (hasTOFout && hasTOFtime && hasTOFpid) hasgoodTOF = kTRUE;
+
+    // TRD track status
+    Bool_t hasTRDin = status&AliESDtrack::kTRDin;
+
+
+    // TOF mismatch (particle spectra group)
+    Int_t mismatchlevel=0; // default value; in data always 0
+    if(mcthere){
+       Int_t tofLabel[3];
+       track->GetTOFLabel(tofLabel);
+        if(TMath::Abs(track->GetLabel()) != TMath::Abs(tofLabel[0]) || tofLabel[1] > 0) mismatchlevel=1;
+       TParticle *matchedTrack = stack->Particle(TMath::Abs(tofLabel[0]));
+       if(TMath::Abs(matchedTrack->GetFirstMother()) == TMath::Abs(track->GetLabel()))
+       {
+           if(mismatchlevel==1) mismatchlevel=3;
+            else mismatchlevel=2;
+       }
+    }
+
+
     // Fill Tree
     (*fDebugTree) << "PIDdebug"
                   << "centrality="          << centrality
@@ -607,7 +643,10 @@ void AliHFEdebugTreeTask::UserExec(Option_t *){
                   << "vy="                  << vtx[1]
                   << "vz="                  << vtx[2]
                   << "tofdx="                << tofdx
-                  << "tofdz="                << tofdz
+                 << "tofdz="                << tofdz
+                  << "statusTOFtracking="   << hasgoodTOF
+                  << "TOFmismatchlevel="    << mismatchlevel
+                  << "statusTRDtracking="   << hasTRDin
                   << "ncontrib="            << ncontrib
                   << "mesonID="             << mesonID
                   << "eR="                  << eR
index 089df5fb7d3711b982be553c19bff69b96f8f90c..77af0109c1b20d992f5b14300131e2492e30c4ab 100644 (file)
@@ -340,7 +340,7 @@ void AliHFEefficiency::DrawCutEfficiency(AliCFEffGrid *eff, AliCFContainer *cont
     hEff->SetMarkerColor(kBlue - 5 + istep);
     hEff->Draw(kFirst ? "ep" : "epsame");
     kFirst = kFALSE;
-    leg->AddEntry(hEff, effTitle.Data(), "p");
+    leg->AddEntry(hEff, cont->GetStepTitle(istep), "p");
   }
   leg->SetBorderSize(0);
   leg->SetFillStyle(0);
index ff2f53a92633e1aa3da972bef43c4ab071d60010..a63417870fd06abfe4964d138eab1f51516deb92 100644 (file)
@@ -54,6 +54,8 @@ class AliHFEefficiency : public AliAnalysisTaskSE{
 
     void CalculatePTsmearing();
     void DrawPtResolution(const TList * const l);
+    void DrawSignalEfficiency(AliCFEffGrid *eff, AliCFContainer *cont, Int_t var);
+    void DrawCutEfficiency(AliCFEffGrid *eff, AliCFContainer *cont, Int_t var);
 
   private:
     enum{
@@ -65,8 +67,7 @@ class AliHFEefficiency : public AliAnalysisTaskSE{
     };
     AliHFEefficiency(const AliHFEefficiency &);
     AliHFEefficiency &operator=(const AliHFEefficiency &);
-    void DrawSignalEfficiency(AliCFEffGrid *eff, AliCFContainer *cont, Int_t var);
-    void DrawCutEfficiency(AliCFEffGrid *eff, AliCFContainer *cont, Int_t var);
+
 
     AliHFEtrackFilter *fFilter;           //! Track Filter
     AliHFEcutStep *fMCcut;                //! MC Signal
index dd1de79cd44ad3492d9fb02bb054a99aa9ea47c2..fd85fdf006f79f80a53c37ab58fe4b4b8ea882a3 100644 (file)
@@ -292,7 +292,8 @@ Int_t AliHFEpidTRD::IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanage
 
   Int_t centralitybin = track->IsPbPb() ? track->GetCentrality() + 1 : 0;
   Float_t fCentralityLimitsdefault[12]= {0.,5.,10., 20., 30., 40., 50., 60.,70.,80., 90., 100.};
-  Float_t centrality=fCentralityLimitsdefault[centralitybin]+1;
+  Float_t centrality=-1;
+  if(centralitybin>=0) centrality=fCentralityLimitsdefault[centralitybin]+1;
 
 
   if(fkPIDResponse->IdentifiedAsElectronTRD(track->GetRecTrack(),fElectronEfficiency,centrality,AliTRDPIDResponse::kLQ2D)){
@@ -300,6 +301,8 @@ Int_t AliHFEpidTRD::IsSelected2D(const AliHFEpidObject *track, AliHFEpidQAmanage
       return 11;
   } else return 211;
 
+
+
 }
 
 //___________________________________________________________________
index ce542c5d092ad374282a825e713ff9b133c13c37..7183fad15243b2d274f613af214f787f14644481 100644 (file)
@@ -78,11 +78,11 @@ AliAnalysisTask *AddTaskHFECal(Bool_t MassConst)
     mgr->AddTask(hfetaskMB);
     hfetaskMB->SelectCollisionCandidates(AliVEvent::kMB);
 
-    TString containerName3 = mgr->GetCommonFileName();
-    containerName3 += ":PWGHF_hfeCalkMB";
+    TString containerName4 = mgr->GetCommonFileName();
+    containerName4 += ":PWGHF_hfeCalkMB";
 
      AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
-     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalMB", TList::Class(),AliAnalysisManager::kOutputContainer, containerName3.Data());
+     AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("HFE_Results_EMCalMB", TList::Class(),AliAnalysisManager::kOutputContainer, containerName4.Data());
      mgr->ConnectInput(hfetaskMB, 0, cinput);
      mgr->ConnectOutput(hfetaskMB, 1, coutput1);
      //}
index a2a406e75ef7e2741419a0fa191acaf22f66d5cf..6202b13dc29d0877f35a6c47a140c77e752a6152 100644 (file)
@@ -4,7 +4,8 @@ AliAnalysisTask *AddTaskHFEpPb(Bool_t isMC = kFALSE,
                                Bool_t kTPC_Only = kFALSE,\r
                                Bool_t kTPCTOF_Cent = kFALSE,\r
                                Bool_t kTPCTOF_Sys = kFALSE,\r
-                                                Bool_t kTPCTOFTRD_Ref = kFALSE,\r
+                              Bool_t kTPCTOFTRD_Ref = kFALSE,
+                              Bool_t kTPCTOFTRD_PID = kFALSE,
                                int TRDtrigger = 0\r
   ){\r
   //get the current analysis manager\r
@@ -44,6 +45,9 @@ AliAnalysisTask *AddTaskHFEpPb(Bool_t isMC = kFALSE,
   // For TPC only\r
   const double kDefTPCs1 = 0.0;\r
   const double kDefTPCu1 = 3.0;\r
+
+  // eta cut
+  Int_t etacut=0; // eta cut off
   \r
   if(kTPC_Only){\r
     // for the moment (09.02.2013) use the same as TOF-TPC. Refine later on\r
@@ -109,7 +113,20 @@ AliAnalysisTask *AddTaskHFEpPb(Bool_t isMC = kFALSE,
    if(kTPCTOFTRD_Ref){\r
 \r
       RegisterTaskPID2(isMC,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,kDefTOFs,0,AliHFEextraCuts::kBoth,kFALSE,TRDtrigger);\r
-  }\r
+   }
+
+  if(kTPCTOFTRD_PID){
+      // without TOF
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,0,4,"TPC",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,6,4,"TRD,TPC",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,6,4,"TPC,TRD",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,6,2,"TRD,TPC",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,5,4,"TRD,TPC",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,5,4,"TPC,TRD",etacut);
+      RegisterTaskPID2TRD(MCthere,isAOD,kDefTPCcl,kDefTPCclPID,kDefITScl,kDefDCAr,kDefDCAz,kDefTPCs,kDefTPCu,0,0,AliHFEextraCuts::kBoth,kFALSE,0,5,2,"TRD,TPC",etacut);
+  }
+
+  \r
  \r
   \r
   return NULL;\r
@@ -247,3 +264,61 @@ AliAnalysisTask *RegisterTaskPID2(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=120,
 \r
 \r
 //=========================================================================\r
+
+AliAnalysisTask *RegisterTaskPID2TRD(Bool_t useMC, Bool_t isAOD, Int_t tpcCls=120, Int_t tpcClsPID = 80,
+                                 Int_t itsCls=4, Double_t dcaxy=1.0, Double_t dcaz=2.0, 
+                                 Double_t tpcs=-0.0113, Double_t tpcu=3.09, Double_t tofs=3., 
+                                 Int_t tofm=0,
+                                 Int_t itshitpixel = AliHFEextraCuts::kBoth, 
+                                 Bool_t withetacorrection = kTRUE,
+                                    Int_t TRDtrigger=0,Int_t trdl=6, Int_t trde=4,TString detector,Int_t etacut){
+
+    TString detused=detector.Copy();
+    TPRegexp(",").Substitute(detused,"","g");
+    printf("detectors in use %s %s \n",detector.Data(),detused.Data());
+
+
+  gROOT->LoadMacro("$TRAIN_ROOT/util/hfe/configs/ConfigHFEmbpPbTRD.C");
+  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
+  AliAnalysisDataContainer *cinput  = mgr->GetCommonInputContainer();
+  AliAnalysisTaskHFE *task = ConfigHFEmbpPbTRD(useMC, isAOD, tpcCls, tpcClsPID, itsCls, dcaxy, dcaz,
+                                            tpcs,tpcu,tofs,tofm,3.,kFALSE,kTRUE,kFALSE,itshitpixel,withetacorrection,0,TRDtrigger,trdl,trde,detector,etacut);
+
+  if(isAOD)
+    task->SetAODAnalysis();
+  else
+    task->SetESDAnalysis();
+
+  if (useMC)
+    task->SetHasMCData(kTRUE);
+  else{
+    task->SetHasMCData(kFALSE);
+  }
+
+  if(TRDtrigger==0) task->SelectCollisionCandidates(AliVEvent::kINT7);
+  else task->SelectCollisionCandidates(AliVEvent::kTRD);
+
+  Int_t idcaxy = (Int_t)(dcaxy*10.);
+  Int_t idcaz = (Int_t)(dcaz*10.);
+  Int_t itpcs = (Int_t)(tpcs*1000.);
+  Int_t itofs = (Int_t)(tofs*10.);
+  Int_t ipixelany = itshitpixel;
+  Int_t ietacorr = 0;
+  if(withetacorrection) ietacorr = 1;
+  
+  TString appendix(TString::Format("mbTPCc%dTPCp%dITS%dDCAr%dz%dTPCs%dTOFs%dm%ipa%dtrdtrg%dtrdl%itrde%iPID%setacut%i",tpcCls,
+                                  tpcClsPID,itsCls,idcaxy,idcaz,itpcs,itofs,tofm,ipixelany,TRDtrigger,trdl,trde,detused.Data(),etacut));
+  printf("Add macro appendix %s\n", appendix.Data());
+
+  //create data containers
+  task->ConnectOutput(1, mgr->CreateContainer(Form("HFE_Results_%s", appendix.Data()), 
+                                             TList::Class(), AliAnalysisManager::kOutputContainer, 
+                                             Form("HFEtask%s.root", appendix.Data())));
+  task->ConnectOutput(2, mgr->CreateContainer(Form("HFE_QA_%s", appendix.Data()), TList::Class(), 
+                                             AliAnalysisManager::kOutputContainer, 
+                                             Form("HFEtask%s.root", appendix.Data())));
+  mgr->ConnectInput(task,  0, cinput );
+
+  mgr->AddTask(task);
+  return NULL;
+}
\ No newline at end of file
diff --git a/PWGHF/hfe/macros/configs/pPb/ConfigHFEmbpPbTRD.C b/PWGHF/hfe/macros/configs/pPb/ConfigHFEmbpPbTRD.C
new file mode 100644 (file)
index 0000000..316d219
--- /dev/null
@@ -0,0 +1,283 @@
+AliAnalysisTaskHFE* ConfigHFEmbpPbTRD(Bool_t useMC, Bool_t isAOD, UChar_t TPCcl=70, UChar_t TPCclPID = 80, UChar_t ITScl=3,
+                                   Double_t DCAxy=1000., Double_t DCAz=1000.,
+                                   Double_t TPCs=0., Double_t TPCu=3.09, Double_t TOFs=3., Int_t TOFmis=0,
+                                   Double_t IpSig=3., Bool_t prodcut = kFALSE, 
+                                   Bool_t ipOpp = kTRUE, Bool_t mcstr  = kFALSE, Int_t itshitpixel = 0, 
+                                   Bool_t withetacorrection = kTRUE, Int_t ptbin=0, Int_t TRDtrigger = 0, Int_t TRDtl=6, Int_t TRDeff=4,
+                                   TString detector,Int_t etacut=0){
+  //
+  // HFE task configuration PID2 (TOF-TPC-TRD)
+  //
+//  AliLog::SetClassDebugLevel("AliHFEpidTRD", 10);
+  Bool_t kAnalyseTaggedTracks = isAOD ? kFALSE : kTRUE;
+
+
+  // TRD settings
+  Float_t eeff[6] = {0.7, 0.75, 0.8, 0.85, 0.9, 0.95};
+  Int_t eeffint[6] = {70, 75, 80, 85, 90, 95};
+//  if(TRDeff >= 6 || TRDtl < 4 || TRDtl > 6) return NULL;
+  if(TRDeff >= 6 || TRDtl > 6) return NULL;
+  printf("TRD settings: %i %f \n",TRDtl, eeff[TRDeff]);
+
+  Int_t iDCAxy = (Int_t)(DCAxy*10.);
+  Int_t iDCAz = (Int_t)(DCAz*10.);
+  Int_t iTPCs = (Int_t)(TPCs*1000.);
+  Int_t iTOFs = (Int_t)(TOFs*10.);
+  Int_t iIpSig= (Int_t)(IpSig*10.);
+  Int_t iIpOpp= 0;
+  Int_t iProdCut = 1;
+  Int_t iMCStr = 0;
+  Int_t iPixelAny = itshitpixel;
+  Int_t iEtaCorr = 0;
+  if(ipOpp)iIpOpp = 1;
+  if(prodcut) iProdCut = 0;
+  if(mcstr) iMCStr = 1;
+  if(withetacorrection) iEtaCorr = 1;
+
+  printf("\n hfeCutsPID2t%di%dr%dz%ds%dt%db%dp%do%dt%dpa%detacorr%dptbin%dtrdtrg%detacut%i \n",TPCcl,ITScl,iDCAxy,iDCAz,iTPCs,iTOFs,TOFmis,iIpSig,iProdCut,iIpOpp,iMCStr,iPixelAny,iEtaCorr,ptbin,TRDtrigger,etacut);
+
+  AliHFEcuts *hfecuts = new AliHFEcuts(Form("hfeCutsPID2tc%dtp%di%dr%dz%ds%dt%db%dp%do%dt%dpa%detacorr%dptbin%dtrdtrg%dtrdl%itrde%ietacut%i",TPCcl,TPCclPID,ITScl,iDCAxy,iDCAz,iTPCs,iTOFs,TOFmis,iIpSig,iProdCut,iIpOpp,iMCStr,iPixelAny,iEtaCorr,ptbin,TRDtrigger,TRDtl,TRDeff,etacut),"HFE cuts TOF TPC");
+  //hfecuts->SetQAOn();
+  hfecuts->CreateStandardCuts();
+  hfecuts->SetMinNClustersTPC(TPCcl);
+  hfecuts->SetMinNClustersTPCPID(TPCclPID);
+  hfecuts->SetMinNClustersITS(ITScl);
+  hfecuts->SetMinRatioTPCclusters(0.6);
+  hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
+  hfecuts->SetCutITSpixel(itshitpixel);
+  hfecuts->SetCheckITSLayerStatus(kFALSE);
+  if(TRDtl>0) hfecuts->SetMinNTrackletsTRD(TRDtl, kTRUE);   // number of trd tracklets
+  if(isAOD) hfecuts->SetAODFilterBit(4);
+  Bool_t ipCharge = kFALSE;
+  if(IpSig<0)ipCharge = kTRUE;
+  if(etacut==1) hfecuts->SetEtaRange(-0.6,0.6);
+
+
+  hfecuts->SetIPcutParam(0,0,0,IpSig,kTRUE,ipCharge,ipOpp);
+  if(TMath::Abs(IpSig)>100&&TMath::Abs(IpSig)<220){
+    hfecuts->SetIPcutParam(0.0064,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>220&&TMath::Abs(IpSig)<250){
+    hfecuts->SetIPcutParam(0.0064,0.072,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>250&&TMath::Abs(IpSig)<270){
+    hfecuts->SetIPcutParam(0.0064,0.083,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>270&&TMath::Abs(IpSig)<300){
+    hfecuts->SetIPcutParam(0.0064,0.088,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>300&&TMath::Abs(IpSig)<320){
+    hfecuts->SetIPcutParam(0.0064,0.098,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>320&&TMath::Abs(IpSig)<350){
+    hfecuts->SetIPcutParam(0.0064,0.108,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>350&&TMath::Abs(IpSig)<410){
+    hfecuts->SetIPcutParam(0.0064,0.058,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>410&&TMath::Abs(IpSig)<450){
+    hfecuts->SetIPcutParam(0.0064,0.053,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>450&&TMath::Abs(IpSig)<470){
+    hfecuts->SetIPcutParam(0.0064,0.068,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>470&&TMath::Abs(IpSig)<500){
+    hfecuts->SetIPcutParam(0.0064,0.048,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>500&&TMath::Abs(IpSig)<520){
+    hfecuts->SetIPcutParam(0.0044,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>520&&TMath::Abs(IpSig)<550){
+    hfecuts->SetIPcutParam(0.0054,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>550&&TMath::Abs(IpSig)<600){
+    hfecuts->SetIPcutParam(0.011,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>600&&TMath::Abs(IpSig)<700){
+    hfecuts->SetIPcutParam(0.012,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+  else if(TMath::Abs(IpSig)>700&&TMath::Abs(IpSig)<900){
+    hfecuts->SetIPcutParam(0.013,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
+  }
+
+
+  if(prodcut) hfecuts->SetProductionVertex(0,100,0,100);
+  else {
+    if((iPixelAny==AliHFEextraCuts::kAny) || (iPixelAny==AliHFEextraCuts::kSecond)) hfecuts->SetProductionVertex(0,7,0,7);
+  }
+  //if(trdsec) hfecuts->SetAdditionalStatusRequirement(AliVTrack::kTRDout);
+
+  //hfecuts->SetSigmaToVertex(DCAsi);
+  hfecuts->SetMaxImpactParam(DCAxy,DCAz);
+  //hfecuts->SetQAOn();
+  hfecuts->SetUseMixedVertex(kTRUE);
+  hfecuts->SetVertexRange(10.);
+  // New pPb cuts (February 2013)
+  hfecuts->SetUseCorrelationVertex();
+  hfecuts->SetSPDVtxResolutionCut();
+
+  // TOF settings:
+  Int_t usetof=0;
+  Bool_t kTOFmis=kFALSE;
+  if (TOFs>0.){
+    usetof = 1;
+    printf("CONFIGURATION FILE: TOF is used \n");
+    hfecuts->SetTOFPIDStep(kTRUE);
+    printf("CONFIGURATION FILE: TOF PID step is requested !!!! \n");
+    if (TOFmis>0){
+      kTOFmis = kTRUE;
+      printf("CONFIGURATION FILE: TOF mismatch rejection is set ON \n");
+    }
+  }
+
+  AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(Form("HFEanalysisPID2tc%dtp%di%dr%dz%ds%dt%db%dp%do%dt%dpa%detacorr%dptbin%dtrdtrg%d",TPCcl,TPCclPID,ITScl,iDCAxy,iDCAz,iTPCs,TOFs,iIpSig,iProdCut,iIpOpp,iMCStr,iPixelAny,iEtaCorr,ptbin,TRDtrigger));
+  printf("task %p\n", task);
+  task->SetHFECuts(hfecuts);
+  task->GetPIDQAManager()->SetHighResolutionHistos();
+
+  if(!isAOD) task->SetRemoveFirstEventInChunk(); // Remove first event in chunk in case of ESD analysis
+  task->SetRemovePileUp(kFALSE);
+  //task->SetApplypAVertexCut();
+
+  Bool_t activateTRDTrigger=kFALSE;
+  if(TRDtrigger>0) activateTRDTrigger=kTRUE;
+  task->SetTRDTrigger(activateTRDTrigger,TRDtrigger);
+
+  // Define Variables
+  if(ptbin==1){
+    Double_t ptbinning[19] = {0., 0.1, 0.3, 0.5, 0.7, 0.9, 1.1, 1.3, 1.5, 2., 2.5, 3., 4., 5., 6., 8., 12., 16., 20.};
+  }
+  else{
+    Double_t ptbinning[36] = {0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1., 1.1, 1.2, 1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5., 5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.};
+  }
+  //Double_t etabinning[33] = {-0.8, -0.75, -0.7, -0.65, -0.6, -0.55, -0.5, -0.45, -0.4, -0.35, -0.3, -0.25, -0.2, -0.15, -0.1, 0.05, 0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8};
+  //Double_t etabinning[17] = {-0.8, -0.7, -0.6, -0.5, -0.4, -0.3, -0.2, -0.1, 0., 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8};
+  Double_t etabinning[9] = {-0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8};
+
+  Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
+  Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
+
+  AliHFEvarManager *vm = task->GetVarManager();
+  vm->AddVariable("pt", sizept, ptbinning);
+  vm->AddVariable("eta", sizeeta, -0.8,0.8);
+  vm->AddVariable("phi",21, -0, 2*TMath::Pi());
+  vm->AddVariable("charge");
+  vm->AddVariable("source");
+  //vm->AddVariable("centrality");
+
+  if(!useMC){
+    // New background model (LHC10d pass2)
+    //TF1 *hBackground = new TF1("hadronicBackgroundFunction", "TMath::Exp(([0]/(x**1.5))+[1])", 0., 20.);
+    TF1 *hBackground = new TF1("hadronicBackgroundFunction", "TMath::Exp([0]+TMath::Sqrt([1]*x))", 0., 20.);
+    // These settings assume that the default is a cut on .ge.120 TPC clusters (Sep 27, 2011)
+    hBackground->SetParameter(0, -15.86);
+    hBackground->SetParameter(1, 33.63);
+    if (TPCcl == 100){
+      hBackground->SetParameter(0, -14.36);
+      hBackground->SetParameter(1, 27.16);
+    } elseif (TPCcl == 110){
+      hBackground->SetParameter(0, -14.88);
+      hBackground->SetParameter(1, 29.28);
+    } 
+
+    task->SetBackGroundFactorsFunction(hBackground);
+  }
+
+  // Define PID
+  AliHFEpid *pid = task->GetPID();
+  if(useMC) pid->SetHasMCData(kTRUE);
+  pid->SetDetectorsForAnalysis(detector);
+
+  /*
+  if (usetof){
+    pid->AddDetector("TOF", 0);
+    pid->AddDetector("TRD", 1);
+    pid->AddDetector("TPC", 2);
+  } else {
+    pid->AddDetector("TRD", 0);
+    pid->AddDetector("TPC", 1);
+  }*/
+    
+  // HERE PUT THE STRAIGHT CUT
+  Double_t params[4];
+  char *cutmodel;
+  if(useMC){
+    // Monte-Carlo needs modelling of the falling mean with momentum at low momentum
+    // for high momentum it is consistent with a flat -0.94
+    cutmodel = "expo(0)+pol1(2)";//[0]*TMath::Exp([1]*x) + [2] + [3]*x";
+    Double_t paramsMC[4] = {-1.00625e-01, -2.09446e+00, -4.71247e-01, 1.80301e-02};
+    for(int ipar = 0; ipar < 4; ipar++) params[ipar] = paramsMC[ipar];
+  } else {
+    // Data is consistent with a flat constant: (Sep 27, 2011)
+    // 100 clusters: mean = -0.076, width = 1.035
+    // 120 clusters: mean = -0.113, width = 1.03
+    // 140 clusters: mean = -0.093, width = 1.004
+    cutmodel = "pol0(0)";
+    params[0] = TPCs;
+
+    if(withetacorrection) {
+      // Apply eta correction
+      AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
+      TF1 *etacorrection = GetEtaCorrection();
+      if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
+    }
+  }
+  pid->ConfigureTPCdefaultCut(cutmodel, params, TPCu);
+
+  if (usetof){
+    pid->ConfigureTOF(TOFs);
+    AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
+    if (kTOFmis){
+      tofpid->SetRejectTOFmismatch();
+    }
+  }
+
+  if(TRDtl>0){
+      AliHFEpidTRD *trdpid = pid->GetDetPID(AliHFEpid::kTRDpid);
+      trdpid->SetTRD2DPID();
+      trdpid->SetElectronEfficiency(eeff[TRDeff]);   // efficiency
+      trdpid->SetNTracklets(TRDtl);      // ntracklets threshold
+      trdpid->SetCutNTracklets(TRDtl, kTRUE);
+  }
+
+  // To make different upper TOF cut to see contamination effect
+  // The below two lines should be removed after this check
+  //AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
+  //if(TOFs<3.) tofpid->SetTOFnSigmaBand(-3,TOFs); //only to check the assymmetric tof cut
+
+  if(kAnalyseTaggedTracks){
+    AliHFEcuts *v0trackCuts = new AliHFEcuts("V0trackCuts", "Track Cuts for tagged track Analysis");
+    v0trackCuts->CreateStandardCuts();
+    v0trackCuts->SetMinNClustersTPC(TPCcl);  
+    v0trackCuts->SetMinNClustersTPCPID(TPCclPID);
+    v0trackCuts->SetMinRatioTPCclusters(0.6);
+    v0trackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
+    v0trackCuts->SetMinNClustersITS(1);
+    v0trackCuts->SetCutITSpixel(AliHFEextraCuts::kFirst);
+    v0trackCuts->SetCheckITSLayerStatus(kFALSE);
+    v0trackCuts->UnsetVertexRequirement();
+    //hfecuts->SetSigmaToVertex(10);
+    if(usetof) v0trackCuts->SetTOFPIDStep(kTRUE);
+    if(TRDtl>0)v0trackCuts->SetMinNTrackletsTRD(TRDtl); // condition for TRD tracklets
+    v0trackCuts->SetQAOn();
+    task->SwitchOnPlugin(AliAnalysisTaskHFE::kTaggedTrackAnalysis);
+    task->SetTaggedTrackCuts(v0trackCuts);
+    task->SetCleanTaggedTrack(kTRUE);
+  }
+
+  // QA
+  printf("task %p\n", task);
+  task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
+  task->SetQAOn(AliAnalysisTaskHFE::kMCqa);    
+  //task->SwitchOnPlugin(AliAnalysisTaskHFE::kIsElecBackGround);
+  //task->SwitchOnPlugin(AliAnalysisTaskHFE::kSecVtx);
+  task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
+  if(useMC && mcstr) task->SetDebugStreaming();
+
+  printf("*************************************\n");
+  printf("Configuring standard Task:\n");
+  task->PrintStatus();
+  pid->PrintStatus();
+  printf("*************************************\n"); 
+  return task;
+}