]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/configs/PbPb/ConfigHFEpbpb.C
Update
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / PbPb / ConfigHFEpbpb.C
1 TF1* GetEtaCorrection(TString listname){
2   
3   TString etaMap="$ALICE_ROOT/PWGDQ/dielectron/files/EtaCorrMaps.root";
4   
5   if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
6     Error("ConfigHFEpbpb","Eta map not found: %s",etaMap.Data());
7     return 0;
8   }
9
10   TFile f(etaMap.Data());
11   if (!f.IsOpen()) return 0;
12   gROOT->cd();
13   TList *keys=f.GetListOfKeys();
14
15   for (Int_t i=0; i<keys->GetEntries(); ++i){
16     TString kName=keys->At(i)->GetName();
17     TPRegexp reg(kName);
18     if (reg.MatchB(listname)){
19       printf("Using Eta Correction Function: %s\n",kName.Data());
20       return (TF1*)f.Get(kName.Data());
21     }
22   }
23   return 0;
24 }
25
26
27 AliAnalysisTaskHFE* ConfigHFEpbpb(Bool_t useMC=kFALSE,
28                                   TString appendix,
29                                   Int_t aodfilter=-1,
30                                   UChar_t TPCcl=70, UChar_t TPCclPID = 80, 
31                                   Double_t TPCclRatio = 0.6, Double_t TPCclshared = 1.1,
32                                   UChar_t ITScl=3,  Double_t ITSchi2perclusters=99999999.,
33                                   Int_t itspixelcut=AliHFEextraCuts::kFirst,
34                                   Double_t dcaxy=1.0, Double_t dcaz=2.0,
35                                   Double_t TOFs=3.,
36                                   Double_t IpSig=3.,                              
37                                   Float_t prodlow=0., Float_t prodhigh=100., 
38                                   Bool_t beauty=kFALSE,
39                                   Bool_t kMCQA = kFALSE, 
40                                   Bool_t kDEStep = kFALSE,
41                                   Int_t addflag=0, Int_t ptbin=0, 
42                                   Int_t etacor=0, TString listname="",
43                                   Int_t nondefaultcentr=0, Float_t* arraycentr=NULL,
44                                   Double_t* tpcdEdxcut=NULL,Double_t tpcu=3.0){
45   //
46   // HFE standard task configuration
47   //
48
49   AliHFEcuts *hfecuts = new AliHFEcuts(appendix,"HFE cuts pbpb TOF TPC");
50   hfecuts->CreateStandardCuts();
51
52   hfecuts->SetMinNClustersTPC(TPCcl);
53   hfecuts->SetMinNClustersTPCPID(TPCclPID);
54   hfecuts->SetMinRatioTPCclusters(TPCclRatio);
55   hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
56   hfecuts->SetFractionOfSharedTPCClusters(TPCclshared);
57
58   hfecuts->SetMinNClustersITS(ITScl);
59   hfecuts->SetMaxChi2perClusterITS(ITSchi2perclusters);
60   hfecuts->SetCutITSpixel(itspixelcut);
61   hfecuts->SetCheckITSLayerStatus(kFALSE);
62
63   hfecuts->SetIPcutParam(0,0,0,IpSig,kTRUE,kTRUE);
64   // if(useMC && beauty) hfecuts->SetProductionVertex(prodlow,prodhigh,prodlow,prodhigh);
65   if(useMC) hfecuts->SetProductionVertex(prodlow,prodhigh,prodlow,prodhigh);
66
67   hfecuts->SetMaxImpactParam(dcaxy,dcaz);
68
69   // event cuts
70   hfecuts->SetUseMixedVertex(kTRUE);
71   hfecuts->SetVertexRange(10.);
72
73   // others
74   hfecuts->SetTOFPIDStep(kTRUE);
75   //hfecuts->SetMaxChi2perClusterITS(36);
76   //hfecuts->SetTOFMISMATCHStep(kTRUE);
77   //hfecuts->SetTPCPIDCleanUpStep(kTRUE);
78   hfecuts->SetQAOn();
79
80   AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(appendix);
81   task->SetHFECuts(hfecuts);
82   task->SetPbPbAnalysis(kTRUE);
83   task->SetRemovePileUp(kFALSE);
84   task->GetPIDQAManager()->SetHighResolutionHistos();
85   if(useMC) task->SetHasMCData(kTRUE); // necessary for AOD
86   printf("AOD filter %d On/OFF?\n",aodfilter);
87   if(aodfilter > 0) {
88     printf("ON AOD filter %d\n",aodfilter);
89     task->SetUseFilterAOD(kTRUE);
90     task->SetFilter(aodfilter);
91   }
92  
93   
94   if((nondefaultcentr!=0) && arraycentr) {
95     for(Int_t i=0;i<12;i++)
96       {
97         task->SetPbPbUserCentralityLimit(kTRUE);
98         task->SetPbPbUserCentralityArray(i,arraycentr[i]);
99         
100       }
101   }
102   
103   // Define Variables
104
105   if(ptbin==0)
106   {
107       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,
108       1.3, 1.4, 1.5, 1.75, 2., 2.25, 2.5, 2.75, 3., 3.5, 4., 4.5, 5.,
109       5.5, 6., 7., 8., 10., 12., 14., 16., 18., 20.};
110   }
111
112   if(ptbin==1)
113   {
114       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.};
115   }
116
117
118   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, 
119                              0.3, 0.4, 0.5, 0.6, 0.7, 0.8};
120   AliHFEvarManager *vm = task->GetVarManager();
121   Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
122   Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
123
124   //  printf("ptbinning: %i \n",sizept);
125
126   //vm->AddVariable("pt");
127   //vm->AddVariable("eta");
128   vm->AddVariable("pt", sizept, ptbinning);
129   // vm->AddVariable("pt", 18, ptbinning);
130   //  vm->AddVariable("eta", 16, etabinning);
131   vm->AddVariable("eta", sizeeta, etabinning);
132   vm->AddVariable("phi");
133   vm->AddVariable("charge");
134   vm->AddVariable("source");
135   vm->AddVariable("centrality");
136   
137   if(!useMC){
138     
139     for(Int_t a=0;a<12;a++)
140       {
141         TF1 *hBackground = new TF1("hadronicBackgroundFunction","TMath::Exp([0]/x + [1])", 0., 20.);
142         hBackground->SetParameter(0, -43.87);
143         hBackground->SetParameter(1, 2.85);
144         task->SetBackGroundFactorsFunction(hBackground,a);
145       }
146   }
147   
148   // Define PID
149   AliHFEpid *pid = task->GetPID();
150   if(useMC) pid->SetHasMCData(kTRUE);
151   pid->AddDetector("TOF", 0);
152   pid->AddDetector("TPC", 1);
153   //pid->ConfigureTPCrejection();
154
155  
156
157   if(!useMC){
158     
159     // 0-10% 0.16
160     // 10-20% 0.29
161     // 20-30% 0.38
162     // 30-40% 0.44
163     Double_t paramsTPCdEdxcut[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};
164     if((nondefaultcentr!=0) && tpcdEdxcut) memcpy(paramsTPCdEdxcut,tpcdEdxcut,sizeof(paramsTPCdEdxcut));
165
166     if(etacor==1&&nondefaultcentr==0)
167       {
168         Double_t tpcdEdxcutetacor[12]={-0.08, 0.016, 0.12,0.22,0.3,0.3,0.3,0.3,0.3,0.3,0.3,0.3};
169         memcpy(paramsTPCdEdxcut,tpcdEdxcutetacor,sizeof(paramsTPCdEdxcut));
170       }
171     
172     char *cutmodel;
173     cutmodel="pol0";
174     
175     for(Int_t a=0;a<11;a++)
176     {
177      //   cout << a << " " << paramsTPCdEdxcut[a] << endl;
178         Double_t tpcparam[1]={paramsTPCdEdxcut[a]};
179
180         pid->ConfigureTPCcentralityCut(a,cutmodel,tpcparam,tpcu);
181     }
182
183     if(etacor==1)
184       { 
185         // Apply eta correction
186         AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
187         TF1 *etacorrection = GetEtaCorrection(listname);
188         if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
189         
190       }
191
192   }
193   pid->ConfigureTOF(TOFs);
194
195   AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
196   if(TOFs<3.) tofpid->SetTOFnSigmaBand(-3,TOFs);
197
198   // QA
199   task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
200   //task->SetFillSignalOnly(kFALSE);    // for DE pluging for MC
201   if(kMCQA) task->SetQAOn(AliAnalysisTaskHFE::kMCqa);
202   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kIsElecBackGround);
203   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kSecVtx);
204   if(kDEStep) task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
205   if(useMC && addflag==1) task->SetDebugStreaming();
206
207   task->SelectCollisionCandidates(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral);
208
209  
210
211   printf("*************************************\n");
212   printf("Configuring task PbPb \n"); 
213   //if(isLHC10) printf("Configuring TPC1 Task 2010 :\n");
214   //if(isLHC11) printf("Configuring TPC1 Task 2011 :\n");
215   task->Print();
216   pid->PrintStatus();
217   printf("*************************************\n"); 
218   return task;
219 }