ROOT logo
TF1* GetEtaCorrection(TString listname){
  
  TString etaMap="$ALICE_ROOT/PWGDQ/dielectron/files/EtaCorrMaps.root";
  
  if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
    Error("ConfigHFEpbpb","Eta map not found: %s",etaMap.Data());
    return 0;
  }

  TFile f(etaMap.Data());
  if (!f.IsOpen()) return 0;
  gROOT->cd();
  TList *keys=f.GetListOfKeys();

  for (Int_t i=0; i<keys->GetEntries(); ++i){
    TString kName=keys->At(i)->GetName();
    TPRegexp reg(kName);
    if (reg.MatchB(listname)){
      printf("Using Eta Correction Function: %s\n",kName.Data());
      return (TF1*)f.Get(kName.Data());
    }
  }
  return 0;
}


AliAnalysisTaskHFE* ConfigHFEpbpb(Bool_t isaod,
				  Bool_t useMC,
				  TString appendix,
				  Int_t aodfilter=-1,
				  Int_t clusterdef=AliHFEextraCuts::kFound, Int_t clusterrdef=AliHFEextraCuts::kFoundOverFindable, 
				  UChar_t TPCcl=70, UChar_t TPCclPID = 80, 
				  Double_t TPCclRatio = 0.6, Double_t TPCclshared = 1.1,
				  Bool_t rejectkinkmother = kFALSE,
				  UChar_t ITScl=3,  Double_t ITSchi2perclusters=99999999.,
				  Int_t itspixelcut=AliHFEextraCuts::kBoth,
                                  Double_t dcaxy=1.0, Double_t dcaz=2.0,
				  Bool_t usetof=kFALSE,
				  Double_t TOFs=3.,
				  Bool_t etacor=kFALSE,TString listname="",
				  Double_t* tpcdEdxcutlow=NULL,Double_t* tpcdEdxcuthigh=NULL,
				  Float_t prodlow=0., Float_t prodhigh=100., 
				  Bool_t kNoPhotonic = kFALSE,
				  Int_t nondefaultcentr=0, Float_t* arraycentr=NULL,
				  Int_t ptbin=0){
  //
  // HFE standard task configuration
  //

  for(Int_t k=0; k < 12; k++) {
    printf("TPC dEdx cut low %f, high %f for %d\n",tpcdEdxcutlow[k],tpcdEdxcuthigh[k],k);
  }


  AliHFEcuts *hfecuts = new AliHFEcuts(appendix,"HFE cuts pbpb TOF TPC");
  hfecuts->CreateStandardCuts();

  hfecuts->SetMinNClustersTPC(TPCcl);
  hfecuts->SetMinNClustersTPCPID(TPCclPID);
  hfecuts->SetMinRatioTPCclusters(TPCclRatio);
  hfecuts->SetTPCmodes(clusterdef, clusterrdef);
  hfecuts->SetFractionOfSharedTPCClusters(TPCclshared);

  hfecuts->SetMinNClustersITS(ITScl);
  hfecuts->SetMaxChi2perClusterITS(ITSchi2perclusters);
  hfecuts->SetCutITSpixel(itspixelcut);
  hfecuts->SetCheckITSLayerStatus(kFALSE);

 if(useMC) hfecuts->SetProductionVertex(prodlow,prodhigh,prodlow,prodhigh);
 
  hfecuts->SetMaxImpactParam(dcaxy,dcaz);

  // event cuts
  hfecuts->SetUseMixedVertex(kTRUE);
  hfecuts->SetVertexRange(10.);

  // others
   if(usetof) hfecuts->SetTOFPIDStep(kTRUE);
  //hfecuts->SetMaxChi2perClusterITS(36);
  //hfecuts->SetTOFMISMATCHStep(kTRUE);
  //hfecuts->SetTPCPIDCleanUpStep(kTRUE);
  hfecuts->SetQAOn();

  // Background Subtraction
  AliHFENonPhotonicElectron *backe = new AliHFENonPhotonicElectron(appendix,"Background subtraction");
  AliESDtrackCuts *hfeBackgroundCuts = new AliESDtrackCuts();
  hfeBackgroundCuts->SetName("backgroundcuts");
  //hfeBackgroundCuts->SetAcceptKinkDaughters(kFALSE);
  hfeBackgroundCuts->SetRequireTPCRefit(kTRUE);
  hfeBackgroundCuts->SetRequireITSRefit(kTRUE);
  hfeBackgroundCuts->SetMinNClustersITS(2);
  hfeBackgroundCuts->SetEtaRange(-0.8,0.8);
  hfeBackgroundCuts->SetRequireSigmaToVertex(kTRUE);
  hfeBackgroundCuts->SetMaxChi2PerClusterTPC(3.5);
  hfeBackgroundCuts->SetMinNClustersTPC(100);
  hfeBackgroundCuts->SetPtRange(0.3,1e10);
  AliHFEpid *pidbackground = backe->GetPIDBackground();
  if(useMC) pidbackground->SetHasMCData(kTRUE);
  pidbackground->AddDetector("TPC", 1);
  pidbackground->ConfigureTPCasymmetric(0.0,9999.,-3.,3.);
  backe->SetHFEBackgroundCuts(hfeBackgroundCuts);

  // task
  AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(appendix);
  task->SetHFECuts(hfecuts);
  task->SetHFEBackgroundSubtraction(backe);
  task->SetPbPbAnalysis(kTRUE);
  task->SetRemovePileUp(kFALSE);
  task->SetRejectKinkMother(rejectkinkmother);
  task->GetPIDQAManager()->SetHighResolutionHistos();
  if(useMC) task->SetHasMCData(kTRUE); // necessary for AOD
  printf("AOD filter %d On/OFF?\n",aodfilter);
  if(aodfilter > 0) {
    printf("ON AOD filter %d\n",aodfilter);
    task->SetUseFilterAOD(kTRUE);
    task->SetFilter(aodfilter);
  }
  else {
    task->SetUseFilterAOD(kFALSE);
  }
 
  
  if((nondefaultcentr!=0) && arraycentr) {
    for(Int_t i=0;i<12;i++)
      {
	task->SetPbPbUserCentralityLimit(kTRUE);
	task->SetPbPbUserCentralityArray(i,arraycentr[i]);
	
      }
  }
  
  // Define Variables

  if(ptbin==0)
  {
      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.};
  }

  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.};
  }


  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};
  AliHFEvarManager *vm = task->GetVarManager();
  Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
  Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;

  //  printf("ptbinning: %i \n",sizept);

  //vm->AddVariable("pt");
  //vm->AddVariable("eta");
  vm->AddVariable("pt", sizept, ptbinning);
  // vm->AddVariable("pt", 18, ptbinning);
  //  vm->AddVariable("eta", 16, etabinning);
  vm->AddVariable("eta", sizeeta, etabinning);
  vm->AddVariable("phi");
  vm->AddVariable("charge");
  vm->AddVariable("source");
  vm->AddVariable("centrality");
  
  if(!useMC){
    
    for(Int_t a=0;a<12;a++)
      {
	TF1 *hBackground = new TF1("hadronicBackgroundFunction","TMath::Exp([0]/x + [1])", 0., 20.);
	hBackground->SetParameter(0, -43.87);
	hBackground->SetParameter(1, 2.85);
	task->SetBackGroundFactorsFunction(hBackground,a);
      }
  }
  
  // Define PID
  AliHFEpid *pid = task->GetPID();
  if(useMC) pid->SetHasMCData(kTRUE);
  if(usetof){
    pid->AddDetector("TOF", 0);
    pid->AddDetector("TPC", 1);
    //pid->ConfigureTPCrejection();
  }
  else {
    pid->AddDetector("TPC", 0);
  }

  if(usetof) pid->ConfigureTOF(TOFs);

  if(!useMC){
    Double_t paramsTPCdEdxcutlow[12] ={0.0, 0.0, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0};
    if(tpcdEdxcutlow) memcpy(paramsTPCdEdxcutlow,tpcdEdxcutlow,sizeof(paramsTPCdEdxcutlow));
    
    Double_t paramsTPCdEdxcuthigh[12] ={3.0, 3.0, 3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0,3.0};
    if(tpcdEdxcuthigh) memcpy(paramsTPCdEdxcuthigh,tpcdEdxcuthigh,sizeof(paramsTPCdEdxcuthigh));

    char *cutmodel;
    cutmodel="pol0";
    
    for(Int_t a=0;a<11;a++)
      {
	//   cout << a << " " << paramsTPCdEdxcut[a] << endl;
	Double_t tpcparamlow[1]={paramsTPCdEdxcutlow[a]};
	Float_t tpcparamhigh=paramsTPCdEdxcuthigh[a];
	pid->ConfigureTPCcentralityCut(a,cutmodel,tpcparamlow,tpcparamhigh);
      }
    
    if(etacor)
      { 
	// Apply eta correction
	AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
	TF1 *etacorrection = GetEtaCorrection(listname);
	if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
      }
  }
  
  // QA
  task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
  //task->SetFillSignalOnly(kFALSE);    // for DE pluging for MC
  if(kNoPhotonic) task->SwitchOnPlugin(AliAnalysisTaskHFE::kNonPhotonicElectron);
  //task->SwitchOnPlugin(AliAnalysisTaskHFE::kIsElecBackGround);
  //task->SwitchOnPlugin(AliAnalysisTaskHFE::kSecVtx);
  //task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
  //if(useMC && addflag==1) task->SetDebugStreaming();

  task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);

  task->SetFillNoCuts(kTRUE);

  if(isaod) {
    task->SetAODAnalysis();
    task->SetApplyCutAOD(kTRUE);
  }
 
  printf("*************************************\n");
  printf("Configuring task PbPb \n"); 
  //if(isLHC10) printf("Configuring TPC1 Task 2010 :\n");
  //if(isLHC11) printf("Configuring TPC1 Task 2011 :\n");
  task->Print();
  pid->PrintStatus();
  printf("*************************************\n"); 
  return task;
}
 ConfigHFEpbpb.C:1
 ConfigHFEpbpb.C:2
 ConfigHFEpbpb.C:3
 ConfigHFEpbpb.C:4
 ConfigHFEpbpb.C:5
 ConfigHFEpbpb.C:6
 ConfigHFEpbpb.C:7
 ConfigHFEpbpb.C:8
 ConfigHFEpbpb.C:9
 ConfigHFEpbpb.C:10
 ConfigHFEpbpb.C:11
 ConfigHFEpbpb.C:12
 ConfigHFEpbpb.C:13
 ConfigHFEpbpb.C:14
 ConfigHFEpbpb.C:15
 ConfigHFEpbpb.C:16
 ConfigHFEpbpb.C:17
 ConfigHFEpbpb.C:18
 ConfigHFEpbpb.C:19
 ConfigHFEpbpb.C:20
 ConfigHFEpbpb.C:21
 ConfigHFEpbpb.C:22
 ConfigHFEpbpb.C:23
 ConfigHFEpbpb.C:24
 ConfigHFEpbpb.C:25
 ConfigHFEpbpb.C:26
 ConfigHFEpbpb.C:27
 ConfigHFEpbpb.C:28
 ConfigHFEpbpb.C:29
 ConfigHFEpbpb.C:30
 ConfigHFEpbpb.C:31
 ConfigHFEpbpb.C:32
 ConfigHFEpbpb.C:33
 ConfigHFEpbpb.C:34
 ConfigHFEpbpb.C:35
 ConfigHFEpbpb.C:36
 ConfigHFEpbpb.C:37
 ConfigHFEpbpb.C:38
 ConfigHFEpbpb.C:39
 ConfigHFEpbpb.C:40
 ConfigHFEpbpb.C:41
 ConfigHFEpbpb.C:42
 ConfigHFEpbpb.C:43
 ConfigHFEpbpb.C:44
 ConfigHFEpbpb.C:45
 ConfigHFEpbpb.C:46
 ConfigHFEpbpb.C:47
 ConfigHFEpbpb.C:48
 ConfigHFEpbpb.C:49
 ConfigHFEpbpb.C:50
 ConfigHFEpbpb.C:51
 ConfigHFEpbpb.C:52
 ConfigHFEpbpb.C:53
 ConfigHFEpbpb.C:54
 ConfigHFEpbpb.C:55
 ConfigHFEpbpb.C:56
 ConfigHFEpbpb.C:57
 ConfigHFEpbpb.C:58
 ConfigHFEpbpb.C:59
 ConfigHFEpbpb.C:60
 ConfigHFEpbpb.C:61
 ConfigHFEpbpb.C:62
 ConfigHFEpbpb.C:63
 ConfigHFEpbpb.C:64
 ConfigHFEpbpb.C:65
 ConfigHFEpbpb.C:66
 ConfigHFEpbpb.C:67
 ConfigHFEpbpb.C:68
 ConfigHFEpbpb.C:69
 ConfigHFEpbpb.C:70
 ConfigHFEpbpb.C:71
 ConfigHFEpbpb.C:72
 ConfigHFEpbpb.C:73
 ConfigHFEpbpb.C:74
 ConfigHFEpbpb.C:75
 ConfigHFEpbpb.C:76
 ConfigHFEpbpb.C:77
 ConfigHFEpbpb.C:78
 ConfigHFEpbpb.C:79
 ConfigHFEpbpb.C:80
 ConfigHFEpbpb.C:81
 ConfigHFEpbpb.C:82
 ConfigHFEpbpb.C:83
 ConfigHFEpbpb.C:84
 ConfigHFEpbpb.C:85
 ConfigHFEpbpb.C:86
 ConfigHFEpbpb.C:87
 ConfigHFEpbpb.C:88
 ConfigHFEpbpb.C:89
 ConfigHFEpbpb.C:90
 ConfigHFEpbpb.C:91
 ConfigHFEpbpb.C:92
 ConfigHFEpbpb.C:93
 ConfigHFEpbpb.C:94
 ConfigHFEpbpb.C:95
 ConfigHFEpbpb.C:96
 ConfigHFEpbpb.C:97
 ConfigHFEpbpb.C:98
 ConfigHFEpbpb.C:99
 ConfigHFEpbpb.C:100
 ConfigHFEpbpb.C:101
 ConfigHFEpbpb.C:102
 ConfigHFEpbpb.C:103
 ConfigHFEpbpb.C:104
 ConfigHFEpbpb.C:105
 ConfigHFEpbpb.C:106
 ConfigHFEpbpb.C:107
 ConfigHFEpbpb.C:108
 ConfigHFEpbpb.C:109
 ConfigHFEpbpb.C:110
 ConfigHFEpbpb.C:111
 ConfigHFEpbpb.C:112
 ConfigHFEpbpb.C:113
 ConfigHFEpbpb.C:114
 ConfigHFEpbpb.C:115
 ConfigHFEpbpb.C:116
 ConfigHFEpbpb.C:117
 ConfigHFEpbpb.C:118
 ConfigHFEpbpb.C:119
 ConfigHFEpbpb.C:120
 ConfigHFEpbpb.C:121
 ConfigHFEpbpb.C:122
 ConfigHFEpbpb.C:123
 ConfigHFEpbpb.C:124
 ConfigHFEpbpb.C:125
 ConfigHFEpbpb.C:126
 ConfigHFEpbpb.C:127
 ConfigHFEpbpb.C:128
 ConfigHFEpbpb.C:129
 ConfigHFEpbpb.C:130
 ConfigHFEpbpb.C:131
 ConfigHFEpbpb.C:132
 ConfigHFEpbpb.C:133
 ConfigHFEpbpb.C:134
 ConfigHFEpbpb.C:135
 ConfigHFEpbpb.C:136
 ConfigHFEpbpb.C:137
 ConfigHFEpbpb.C:138
 ConfigHFEpbpb.C:139
 ConfigHFEpbpb.C:140
 ConfigHFEpbpb.C:141
 ConfigHFEpbpb.C:142
 ConfigHFEpbpb.C:143
 ConfigHFEpbpb.C:144
 ConfigHFEpbpb.C:145
 ConfigHFEpbpb.C:146
 ConfigHFEpbpb.C:147
 ConfigHFEpbpb.C:148
 ConfigHFEpbpb.C:149
 ConfigHFEpbpb.C:150
 ConfigHFEpbpb.C:151
 ConfigHFEpbpb.C:152
 ConfigHFEpbpb.C:153
 ConfigHFEpbpb.C:154
 ConfigHFEpbpb.C:155
 ConfigHFEpbpb.C:156
 ConfigHFEpbpb.C:157
 ConfigHFEpbpb.C:158
 ConfigHFEpbpb.C:159
 ConfigHFEpbpb.C:160
 ConfigHFEpbpb.C:161
 ConfigHFEpbpb.C:162
 ConfigHFEpbpb.C:163
 ConfigHFEpbpb.C:164
 ConfigHFEpbpb.C:165
 ConfigHFEpbpb.C:166
 ConfigHFEpbpb.C:167
 ConfigHFEpbpb.C:168
 ConfigHFEpbpb.C:169
 ConfigHFEpbpb.C:170
 ConfigHFEpbpb.C:171
 ConfigHFEpbpb.C:172
 ConfigHFEpbpb.C:173
 ConfigHFEpbpb.C:174
 ConfigHFEpbpb.C:175
 ConfigHFEpbpb.C:176
 ConfigHFEpbpb.C:177
 ConfigHFEpbpb.C:178
 ConfigHFEpbpb.C:179
 ConfigHFEpbpb.C:180
 ConfigHFEpbpb.C:181
 ConfigHFEpbpb.C:182
 ConfigHFEpbpb.C:183
 ConfigHFEpbpb.C:184
 ConfigHFEpbpb.C:185
 ConfigHFEpbpb.C:186
 ConfigHFEpbpb.C:187
 ConfigHFEpbpb.C:188
 ConfigHFEpbpb.C:189
 ConfigHFEpbpb.C:190
 ConfigHFEpbpb.C:191
 ConfigHFEpbpb.C:192
 ConfigHFEpbpb.C:193
 ConfigHFEpbpb.C:194
 ConfigHFEpbpb.C:195
 ConfigHFEpbpb.C:196
 ConfigHFEpbpb.C:197
 ConfigHFEpbpb.C:198
 ConfigHFEpbpb.C:199
 ConfigHFEpbpb.C:200
 ConfigHFEpbpb.C:201
 ConfigHFEpbpb.C:202
 ConfigHFEpbpb.C:203
 ConfigHFEpbpb.C:204
 ConfigHFEpbpb.C:205
 ConfigHFEpbpb.C:206
 ConfigHFEpbpb.C:207
 ConfigHFEpbpb.C:208
 ConfigHFEpbpb.C:209
 ConfigHFEpbpb.C:210
 ConfigHFEpbpb.C:211
 ConfigHFEpbpb.C:212
 ConfigHFEpbpb.C:213
 ConfigHFEpbpb.C:214
 ConfigHFEpbpb.C:215
 ConfigHFEpbpb.C:216
 ConfigHFEpbpb.C:217
 ConfigHFEpbpb.C:218
 ConfigHFEpbpb.C:219
 ConfigHFEpbpb.C:220
 ConfigHFEpbpb.C:221
 ConfigHFEpbpb.C:222
 ConfigHFEpbpb.C:223
 ConfigHFEpbpb.C:224
 ConfigHFEpbpb.C:225
 ConfigHFEpbpb.C:226
 ConfigHFEpbpb.C:227
 ConfigHFEpbpb.C:228
 ConfigHFEpbpb.C:229
 ConfigHFEpbpb.C:230
 ConfigHFEpbpb.C:231
 ConfigHFEpbpb.C:232
 ConfigHFEpbpb.C:233
 ConfigHFEpbpb.C:234
 ConfigHFEpbpb.C:235
 ConfigHFEpbpb.C:236
 ConfigHFEpbpb.C:237
 ConfigHFEpbpb.C:238
 ConfigHFEpbpb.C:239
 ConfigHFEpbpb.C:240
 ConfigHFEpbpb.C:241
 ConfigHFEpbpb.C:242
 ConfigHFEpbpb.C:243
 ConfigHFEpbpb.C:244
 ConfigHFEpbpb.C:245