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