]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGHF/hfe/macros/configs/PbPb/ConfigHFEnpePbPb.C
Fix
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / PbPb / ConfigHFEnpePbPb.C
CommitLineData
1452614c 1TF1* GetEtaCorrection(){
2 TString list=gSystem->Getenv("LIST");
3
4 TString etaMap="$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/EtaCorrMapsTPC.root";
5 if (gSystem->AccessPathName(gSystem->ExpandPathName(etaMap.Data()))){
6 Error("ConfigPbPb2010_Cent","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(list)){
19 printf("Using Eta Correction Function: %s\n",kName.Data());
20 return (TF1*)f.Get(kName.Data());
21 }
22 }
23 return 0;
24}
25
26Bool_t ReadContaminationFunctions(TString filename, TF1 **functions, double sigma){
27 TFile *in = TFile::Open(Form("$ALICE_ROOT/PWGHF/hfe/macros/configs/PbPb/%s", filename.Data()));
28 gROOT->cd();
29 int isig = static_cast<int>(sigma * 100.);
30 printf("Getting hadron background for the sigma cut: %d\n", isig);
31 bool status = kTRUE;
32 for(int icent = 0; icent < 12; icent++){
33 functions[icent] = dynamic_cast<TF1 *>(in->Get(Form("hback_%d_%d", isig, icent)));
34 if(functions[icent]) printf("Config for centrality class %d found\n", icent);
35 else{
36 printf("Config for the centrality class %d not found\n", icent);
37 status = kFALSE;
38 }
39 }
40 delete in;
41 return status;
42}
43
44AliAnalysisTaskHFE* ConfigHFEnpePbPb(Bool_t useMC, Bool_t isAOD, TString appendix,
45 UChar_t TPCcl=70, UChar_t TPCclPID = 80,
46 UChar_t ITScl=3, Double_t DCAxy=1000., Double_t DCAz=1000.,
47 Double_t* tpcdEdxcutlow=NULL, Double_t* tpcdEdxcuthigh=NULL,
48 Double_t TOFs=3., Int_t TOFmis=0,
49 Int_t itshitpixel = 0, Double_t itsChi2PerClusters, Double_t tpcClShared,
50 Bool_t etacor = kFALSE, Bool_t multicor = kFALSE,
51 Double_t etami=-0.8, Double_t etama=0.8,
52 Double_t assETAm=-0.8, Double_t assETAp=0.8,
53 Int_t assITS=2,
54 Int_t assTPCcl=100, Int_t assTPCPIDcl=80,
55 Double_t assDCAr=1.0, Double_t assDCAz=2.0,
56 Double_t *assTPCSminus=NULL, Double_t *assTPCSplus=NULL,
57 Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE)
58{
59 Bool_t kAnalyseTaggedTracks = kFALSE;
60 Bool_t kApplyPreselection = kTRUE;
61
62 //***************************************//
63 // Setting up the HFE cuts //
64 //***************************************//
65
66 AliHFEcuts *hfecuts = new AliHFEcuts(appendix,"HFE cuts for PbPb");
67 //hfecuts->SetQAOn();
68 hfecuts->CreateStandardCuts();
69 hfecuts->SetMinNClustersTPC(TPCcl);
70 hfecuts->SetMinNClustersTPCPID(TPCclPID);
71 hfecuts->SetMinNClustersITS(ITScl);
72 hfecuts->SetMinRatioTPCclusters(0.6);
73 hfecuts->SetTPCmodes(AliHFEextraCuts::kFoundAll, AliHFEextraCuts::kFoundAllOverFindable);
74 hfecuts->SetCutITSpixel(itshitpixel);
75 hfecuts->SetCheckITSLayerStatus(kFALSE);
76 hfecuts->SetMaxChi2perClusterITS(itsChi2PerClusters);
77 hfecuts->SetEtaRange(etami,etama);
78 hfecuts->SetFractionOfSharedTPCClusters(tpcClShared);
79 hfecuts->SetAcceptKinkMothers();
80 if(isAOD) hfecuts->SetAODFilterBit(2);
81
82 if((iPixelAny==AliHFEextraCuts::kAny) || (iPixelAny==AliHFEextraCuts::kSecond))
83 hfecuts->SetProductionVertex(0,7,0,7);
84
85 hfecuts->SetMaxImpactParam(DCAxy,DCAz);
86 hfecuts->SetUseMixedVertex(kTRUE);
87 hfecuts->SetVertexRange(10.);
88
89 // TOF settings:
90 Int_t usetof=0;
91 Bool_t kTOFmis=kFALSE;
92 if (TOFs>0.){
93 usetof = 1;
94 printf("CONFIGURATION FILE: TOF is used \n");
95 hfecuts->SetTOFPIDStep(kTRUE);
96 printf("CONFIGURATION FILE: TOF PID step is requested !!!! \n");
97 if (TOFmis>0){
98 kTOFmis = kTRUE;
99 printf("CONFIGURATION FILE: TOF mismatch rejection is set ON \n");
100 }
101 }
102
103 //***************************************//
104 // Setting up the task //
105 //***************************************//
106
107 AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(Form("HFEtask%s",appendix.Data()));
108 printf("task %p\n", task);
109 task->SetPbPbAnalysis();
110 task->SetRemovePileUp(kFALSE);
111 task->SetHFECuts(hfecuts);
112 task->SetRejectKinkMother(kFALSE);
113 task->GetPIDQAManager()->SetHighResolutionHistos();
114
115 // Determine the centrality estimator
116 task->SetCentralityEstimator("V0M");
117
118 //***************************************//
119 // Prepare preselection //
120 // This mimics the ESD->AOD filter in //
121 // case of the ESD analysis and selects //
122 // only tracks which will be selected in //
123 // the AOD analysis with the given filter//
124 // bit. Not to be applied for AODS. //
125 // For pPb the cuts used are (bit 4) //
126 // esdTrackCutsHG0 from file $ALICE_ROOT///
127 // ANALYSIS/macros/AddTaskESDFilter.C //
128 //***************************************//
129 if(kApplyPreselection){
130 AliESDtrackCuts* esdTrackCutsH = AliESDtrackCuts::GetStandardTPCOnlyTrackCuts();
131 esdTrackCutsH->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
132 task->SetHFECutsPreselect(esdTrackCutsH);
133 printf("Put a preselection cut\n");
134 task->SetFillNoCuts(kTRUE);
135 }
136
137 //***************************************//
138 // Variable manager //
139 //***************************************//
140 // Define Variables
141 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.};
142 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};
143
144 Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
145 Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
146
147 AliHFEvarManager *vm = task->GetVarManager();
148 vm->AddVariable("pt", sizept, ptbinning);
149 vm->AddVariable("eta", sizeeta, -0.8,0.8);
150 vm->AddVariable("phi",21, -0, 2*TMath::Pi());
151 vm->AddVariable("charge");
152 vm->AddVariable("source");
153 vm->AddVariable("centrality");
154
155 // For the moment, remove the part dedicated to the background subtraction.
156 // It will be implemented in a different way, reading it from a root file.
157
158 //***************************************//
159 // Configure the PID //
160 //***************************************//
161
162 // Define PID
163 AliHFEpid *pid = task->GetPID();
164 if(useMC) pid->SetHasMCData(kTRUE);
165
166 if (usetof){
167 pid->AddDetector("TOF", 0);
168 pid->AddDetector("TPC", 1);
169 } else {
170 pid->AddDetector("TPC", 0);
171 }
172
173 // Configure TPC PID
174 // do the identical thing in data and MC
175 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};
176 if(tpcdEdxcutlow) memcpy(paramsTPCdEdxcutlow,tpcdEdxcutlow,sizeof(paramsTPCdEdxcutlow));
177
178 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};
179 if(tpcdEdxcuthigh) memcpy(paramsTPCdEdxcuthigh,tpcdEdxcuthigh,sizeof(paramsTPCdEdxcuthigh));
180
181 char *cutmodel;
182 cutmodel="pol0";
183
184 for(Int_t a=0;a<11;a++){
185 // Not necessary anymore, since the PbPb case is handled similarly to the pp case
186 // cout << a << " " << paramsTPCdEdxcut[a] << endl;
187 Double_t tpcparamlow[1]={paramsTPCdEdxcutlow[a]};
188 Float_t tpcparamhigh=paramsTPCdEdxcuthigh[a];
189 pid->ConfigureTPCcentralityCut(a,cutmodel,tpcparamlow,tpcparamhigh);
190 }
191
192 if(!useMC){
193 AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTOFpid);
194 if(etacor){
195 // Apply eta correction
196 TF1 *etacorrection = GetEtaCorrection();
197 if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
198 }
199 if(multicor){
200 TF1 *centralityCorrection = new TF1("centralityCorrection", "pol1", 0., 10000.);
201 centralityCorrection->SetParameter(0, 1.0);
202 centralityCorrection->SetParameter(1, -0.00002);
203 tpcpid->SetCentralityCorrection(centralityCorrection);
204 }
205 }
206
207 // Configure TOF PID
208 if (usetof){
209 pid->ConfigureTOF(TOFs);
210 AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
211 if (kTOFmis){
212 tofpid->SetRejectTOFmismatch();
213 }
214 }
215
216 // To make different upper TOF cut to see contamination effect
217 // The below two lines should be removed after this check
218 //AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
219 //if(TOFs<3.) tofpid->SetTOFnSigmaBand(-3,TOFs); //only to check the assymmetric tof cut
220
221 // Load hadron background
222 if(!useMC){
223 Bool_t status = kTRUE;
224 TF1 *hBackground[12];
225 status = ReadContaminationFunctions("hadronContamination_PbPbTPC.root", hBackground, tpcdEdxcutlow[0]);
226 for(Int_t a=0;a<12;a++) {
227 //printf("back %f \n",hBackground[a]);
228 if(status) task->SetBackGroundFactorsFunction(hBackground[a],a);
229 else printf("not all background functions found\n");
230 }
231 }
232
233 //***************************************//
234 // Configure NPE plugin //
235 //***************************************//
236
237 AliHFENonPhotonicElectron *backe = new AliHFENonPhotonicElectron(Form("HFEBackGroundSubtractionPID2%s",appendix.Data()),"Background subtraction"); //appendix
238 //Setting the Cuts for the Associated electron-pool
239 AliHFEcuts *hfeBackgroundCuts = new AliHFEcuts(Form("HFEBackSub%s",appendix.Data()),"Background sub Cuts");
240 // hfeBackgroundCuts->SetEtaRange(assETA);
241 hfeBackgroundCuts->SetEtaRange(assETAm,assETAp);
242 hfeBackgroundCuts->SetPtRange(0.1,1e10);
243
244 hfeBackgroundCuts->SetMaxChi2perClusterTPC(4);
245 hfeBackgroundCuts->SetMinNClustersITS(assITS);
246 hfeBackgroundCuts->SetMinNClustersTPC(assTPCcl);
247 hfeBackgroundCuts->SetMinNClustersTPCPID(assTPCPIDcl);
248 hfeBackgroundCuts->SetMaxImpactParam(assDCAr,assDCAz);
249 if(isAOD) hfeBackgroundCuts->SetAODFilterBit(0);
250 //hfeBackgroundCuts->SetQAOn(); // QA
251
252 AliHFEpid *pidbackground = backe->GetPIDBackground();
253 if(useMC) pidbackground->SetHasMCData(kTRUE);
254 pidbackground->AddDetector("TPC", 0);
255 Double_t paramsTPCdEdxcutlowAssoc[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};
256 if(assTPCSminus) memcpy(paramsTPCdEdxcutlowAssoc,assTPCSminus,sizeof(paramsTPCdEdxcutlowAssoc));
257
258 Double_t paramsTPCdEdxcuthighAssoc[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};
259 if(assTPCSplus) memcpy(paramsTPCdEdxcuthighAssoc,assTPCSplus,sizeof(paramsTPCdEdxcuthighAssoc));
260
261 char *cutmodelAssoc;
262 cutmodelAssoc="pol0";
263 for(Int_t a=0;a<11;a++){
264 // cout << a << " " << paramsTPCdEdxcut[a] << endl;
265 Double_t tpcparamlow[1]={paramsTPCdEdxcutlowAssoc[a]};
266 Float_t tpcparamhigh=paramsTPCdEdxcuthighAssoc[a];
267 pidbackground->ConfigureTPCcentralityCut(a,cutmodelAssoc,tpcparamlow,tpcparamhigh);
268 }
269 //backe->GetPIDBackgroundQAManager()->SetHighResolutionHistos();
270 backe->SetHFEBackgroundCuts(hfeBackgroundCuts);
271
272 // Selection of associated tracks for the pool
273 if(useCat1Tracks) backe->SelectCategory1Tracks(kTRUE);
274 if(useCat2Tracks){
275 backe->SelectCategory2Tracks(kTRUE);
276 backe->SetITSMeanShift(-0.5);
277 }
278
279 // apply opening angle cut to reduce file size
280 backe->SetMaxInvMass(0.3);
281 backe->SetPtBinning(sizept, ptbinning);
282 backe->SetEtaBinning(sizeeta, etabinning);
283
284 task->SetHFEBackgroundSubtraction(backe);
285
286 //***************************************//
287 // V0 tagged tracks //
288 //***************************************//
289
290 if(kAnalyseTaggedTracks){
291 AliHFEcuts *v0trackCuts = new AliHFEcuts("V0trackCuts", "Track Cuts for tagged track Analysis");
292 v0trackCuts->CreateStandardCuts();
293 v0trackCuts->SetMinNClustersTPC(TPCcl);
294 v0trackCuts->SetMinNClustersTPCPID(TPCclPID);
295 v0trackCuts->SetMinRatioTPCclusters(0.6);
296 v0trackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
297 v0trackCuts->SetMinNClustersITS(1);
298 v0trackCuts->SetCutITSpixel(AliHFEextraCuts::kFirst);
299 v0trackCuts->SetCheckITSLayerStatus(kFALSE);
300 v0trackCuts->UnsetVertexRequirement();
301 //hfecuts->SetSigmaToVertex(10);
302 if(usetof) v0trackCuts->SetTOFPIDStep(kTRUE);
303 v0trackCuts->SetQAOn();
304
305 task->SwitchOnPlugin(AliAnalysisTaskHFE::kTaggedTrackAnalysis);
306 task->SetTaggedTrackCuts(v0trackCuts);
307 task->SetCleanTaggedTrack(kTRUE);
308 }
309
310 // QA
311 printf("task %p\n", task);
312 task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
313 task->SetQAOn(AliAnalysisTaskHFE::kMCqa);
314 task->SwitchOnPlugin(AliAnalysisTaskHFE::kNonPhotonicElectron);
315 task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
316
317 printf("*************************************\n");
318 printf("Configuring standard Task:\n");
319 task->PrintStatus();
320 pid->PrintStatus();
321 printf("*************************************\n");
322 return task;
323}