1 Bool_t ReadContaminationFunctions(TString filename, TF1 **functions, double sigma){
2 TFile *in = TFile::Open(Form("$ALICE_ROOT/PWGHF/hfe/macros/configs/pPb/%s", filename.Data()));
4 int isig = static_cast<int>(sigma * 100.);
5 printf("Getting hadron background for the sigma cut: %d\n", isig);
7 for(int icent = 0; icent < 12; icent++){
8 functions[icent] = dynamic_cast<TF1 *>(in->Get(Form("hback_%d_%d", isig, icent)));
9 if(functions[icent]) printf("Config for centrality class %d found\n", icent);
11 printf("Config for the centrality class %d not found\n", icent);
19 AliAnalysisTaskHFE* ConfigHFEnpepPb(Bool_t useMC, Bool_t isAOD, TString appendix,
20 UChar_t TPCcl=70, UChar_t TPCclPID = 80,
21 UChar_t ITScl=3, Double_t DCAxy=1000., Double_t DCAz=1000.,
22 Double_t* tpcdEdxcutlow=NULL, Double_t* tpcdEdxcuthigh=NULL,
23 Double_t TOFs=3., Int_t TOFmis=0,
24 Int_t itshitpixel = 0, Int_t icent,
25 Double_t etami=-0.8, Double_t etama=0.8,
26 Double_t assETAm=-0.8, Double_t assETAp=0.8,
28 Int_t assTPCcl=100, Int_t assTPCPIDcl=80,
29 Double_t assDCAr=1.0, Double_t assDCAz=2.0,
30 Double_t *assTPCSminus=NULL, Double_t *assTPCSplus=NULL,
31 Bool_t useCat1Tracks = kTRUE, Bool_t useCat2Tracks = kTRUE)
33 Bool_t kAnalyseTaggedTracks = kTRUE;
35 //***************************************//
36 // Setting up the HFE cuts //
37 //***************************************//
39 AliHFEcuts *hfecuts = new AliHFEcuts(appendix,"HFE cuts for pPb");
41 hfecuts->CreateStandardCuts();
42 hfecuts->SetMinNClustersTPC(TPCcl);
43 hfecuts->SetMinNClustersTPCPID(TPCclPID);
44 hfecuts->SetMinNClustersITS(ITScl);
45 hfecuts->SetMinRatioTPCclusters(0.6);
46 hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
47 hfecuts->SetCutITSpixel(itshitpixel);
48 hfecuts->SetCheckITSLayerStatus(kFALSE);
49 hfecuts->SetEtaRange(etami,etama);
50 if(isAOD) hfecuts->SetAODFilterBit(4);
52 //if((iPixelAny==AliHFEextraCuts::kAny) || (iPixelAny==AliHFEextraCuts::kSecond))
53 //hfecuts->SetProductionVertex(0,7,0,7);
55 hfecuts->SetMaxImpactParam(DCAxy,DCAz);
56 hfecuts->SetUseMixedVertex(kTRUE);
57 hfecuts->SetVertexRange(10.);
58 // New pPb cuts (February 2013)
59 hfecuts->SetUseCorrelationVertex();
60 hfecuts->SetSPDVtxResolutionCut();
61 hfecuts->SetpApileupCut();
65 Bool_t kTOFmis=kFALSE;
68 printf("CONFIGURATION FILE: TOF is used \n");
69 hfecuts->SetTOFPIDStep(kTRUE);
70 printf("CONFIGURATION FILE: TOF PID step is requested !!!! \n");
73 printf("CONFIGURATION FILE: TOF mismatch rejection is set ON \n");
77 //***************************************//
78 // Setting up the task //
79 //***************************************//
81 AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(Form("HFEtask%s",appendix.Data()));
82 printf("task %p\n", task);
83 task->SetpPbAnalysis();
84 if(!isAOD) task->SetRemoveFirstEventInChunk();
85 task->SetRemovePileUp(kFALSE);
86 task->SetHFECuts(hfecuts);
87 task->GetPIDQAManager()->SetHighResolutionHistos();
89 // Determine the centrality estimator
90 task->SetCentralityEstimator("V0A");
91 if (icent == 2) task->SetCentralityEstimator("V0M");
92 else if (icent == 3) task->SetCentralityEstimator("CL1");
93 else if (icent == 4) task->SetCentralityEstimator("ZNA");
95 //***************************************//
96 // Variable manager //
97 //***************************************//
99 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.};
100 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};
102 Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
103 Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
105 AliHFEvarManager *vm = task->GetVarManager();
106 vm->AddVariable("pt", sizept, ptbinning);
107 vm->AddVariable("eta", sizeeta, -0.8,0.8);
108 vm->AddVariable("phi",21, -0, 2*TMath::Pi());
109 vm->AddVariable("charge");
110 vm->AddVariable("source");
111 vm->AddVariable("centrality");
113 // For the moment, remove the part dedicated to the background subtraction.
114 // It will be implemented in a different way, reading it from a root file.
116 //***************************************//
117 // Configure the PID //
118 //***************************************//
121 AliHFEpid *pid = task->GetPID();
122 if(useMC) pid->SetHasMCData(kTRUE);
125 pid->AddDetector("TOF", 0);
126 pid->AddDetector("TPC", 1);
128 pid->AddDetector("TPC", 0);
132 // do the identical thing in data and MC
133 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};
134 if(tpcdEdxcutlow) memcpy(paramsTPCdEdxcutlow,tpcdEdxcutlow,sizeof(paramsTPCdEdxcutlow));
136 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};
137 if(tpcdEdxcuthigh) memcpy(paramsTPCdEdxcuthigh,tpcdEdxcuthigh,sizeof(paramsTPCdEdxcuthigh));
142 for(Int_t a=0;a<11;a++){
143 // Not necessary anymore, since the pPb case is handled similarly to the pp case
144 // cout << a << " " << paramsTPCdEdxcut[a] << endl;
145 Double_t tpcparamlow[1]={paramsTPCdEdxcutlow[a]};
146 Float_t tpcparamhigh=paramsTPCdEdxcuthigh[a];
147 pid->ConfigureTPCcentralityCut(a,cutmodel,tpcparamlow,tpcparamhigh);
149 pid->ConfigureTPCdefaultCut(cutmodel,paramsTPCdEdxcutlow,paramsTPCdEdxcuthigh[0]); // After introducing the pPb flag, pPb is merged with pp and this line defines the cut
153 pid->ConfigureTOF(TOFs);
154 AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
156 tofpid->SetRejectTOFmismatch();
160 // To make different upper TOF cut to see contamination effect
161 // The below two lines should be removed after this check
162 //AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
163 //if(TOFs<3.) tofpid->SetTOFnSigmaBand(-3,TOFs); //only to check the assymmetric tof cut
165 // Load hadron background
167 Bool_t status = kTRUE;
168 TF1 *hBackground[12];
169 status = ReadContaminationFunctions("hadroncontamination_TOFTPC_pPb_eta06_newsplines_try3.root", hBackground, tpcdEdxcutlow[0]);
170 for(Int_t a=0;a<12;a++) {
171 //printf("back %f \n",hBackground[a]);
172 if(status) task->SetBackGroundFactorsFunction(hBackground[a],a);
173 else printf("not all background functions found\n");
177 //***************************************//
178 // Configure NPE plugin //
179 //***************************************//
181 AliHFENonPhotonicElectron *backe = new AliHFENonPhotonicElectron(Form("HFEBackGroundSubtractionPID2%s",appendix.Data()),"Background subtraction"); //appendix
182 //Setting the Cuts for the Associated electron-pool
183 AliHFEcuts *hfeBackgroundCuts = new AliHFEcuts(Form("HFEBackSub%s",appendix.Data()),"Background sub Cuts");
184 // hfeBackgroundCuts->SetEtaRange(assETA);
185 hfeBackgroundCuts->SetEtaRange(assETAm,assETAp);
186 hfeBackgroundCuts->SetPtRange(0.1,1e10);
188 hfeBackgroundCuts->SetMaxChi2perClusterTPC(4);
189 hfeBackgroundCuts->SetMinNClustersITS(assITS);
190 hfeBackgroundCuts->SetMinNClustersTPC(assTPCcl);
191 hfeBackgroundCuts->SetMinNClustersTPCPID(assTPCPIDcl);
192 hfeBackgroundCuts->SetMaxImpactParam(assDCAr,assDCAz);
193 if(isAOD) hfeBackgroundCuts->SetAODFilterBit(4);
194 hfeBackgroundCuts->SetQAOn(); // QA
196 AliHFEpid *pidbackground = backe->GetPIDBackground();
197 if(useMC) pidbackground->SetHasMCData(kTRUE);
198 pidbackground->AddDetector("TPC", 0);
199 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};
200 if(assTPCSminus) memcpy(paramsTPCdEdxcutlowAssoc,assTPCSminus,sizeof(paramsTPCdEdxcutlowAssoc));
202 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};
203 if(assTPCSplus) memcpy(paramsTPCdEdxcuthighAssoc,assTPCSplus,sizeof(paramsTPCdEdxcuthighAssoc));
206 cutmodelAssoc="pol0";
207 for(Int_t a=0;a<11;a++){
208 // Not necessary anymore, since the pPb case is handled similarly to the pp case
209 // cout << a << " " << paramsTPCdEdxcut[a] << endl;
210 Double_t tpcparamlow[1]={paramsTPCdEdxcutlowAssoc[a]};
211 Float_t tpcparamhigh=paramsTPCdEdxcuthighAssoc[a];
212 pidbackground->ConfigureTPCcentralityCut(a,cutmodelAssoc,tpcparamlow,tpcparamhigh);
214 pidbackground->ConfigureTPCdefaultCut(cutmodelAssoc,paramsTPCdEdxcutlowAssoc,paramsTPCdEdxcuthighAssoc[0]); // After introducing the pPb flag, pPb is merged with pp and this line defines the cut
215 backe->GetPIDBackgroundQAManager()->SetHighResolutionHistos();
216 backe->SetHFEBackgroundCuts(hfeBackgroundCuts);
218 // Selection of associated tracks for the pool
219 if(useCat1Tracks) backe->SelectCategory1Tracks(kTRUE);
220 if(useCat2Tracks) backe->SelectCategory2Tracks(kTRUE);
222 // apply opening angle cut to reduce file size
223 backe->SetMaxInvMass(0.3);
225 task->SetHFEBackgroundSubtraction(backe);
227 //***************************************//
228 // V0 tagged tracks //
229 //***************************************//
231 if(kAnalyseTaggedTracks){
232 AliHFEcuts *v0trackCuts = new AliHFEcuts("V0trackCuts", "Track Cuts for tagged track Analysis");
233 v0trackCuts->CreateStandardCuts();
234 v0trackCuts->SetMinNClustersTPC(TPCcl);
235 v0trackCuts->SetMinNClustersTPCPID(TPCclPID);
236 v0trackCuts->SetMinRatioTPCclusters(0.6);
237 v0trackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
238 v0trackCuts->SetMinNClustersITS(1);
239 v0trackCuts->SetCutITSpixel(AliHFEextraCuts::kFirst);
240 v0trackCuts->SetCheckITSLayerStatus(kFALSE);
241 v0trackCuts->UnsetVertexRequirement();
242 //hfecuts->SetSigmaToVertex(10);
243 if(usetof) v0trackCuts->SetTOFPIDStep(kTRUE);
244 v0trackCuts->SetQAOn();
246 task->SwitchOnPlugin(AliAnalysisTaskHFE::kTaggedTrackAnalysis);
247 task->SetTaggedTrackCuts(v0trackCuts);
248 task->SetCleanTaggedTrack(kTRUE);
252 printf("task %p\n", task);
253 task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
254 task->SetQAOn(AliAnalysisTaskHFE::kMCqa);
255 task->SwitchOnPlugin(AliAnalysisTaskHFE::kNonPhotonicElectron);
256 task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
258 printf("*************************************\n");
259 printf("Configuring standard Task:\n");
262 printf("*************************************\n");