]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/configs/pPb/ConfigHFEmbpPbTRD.C
51b7a1b43cac96df6b91042c1a0276fa5550ff5d
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / pPb / ConfigHFEmbpPbTRD.C
1 AliAnalysisTaskHFE* ConfigHFEmbpPbTRD(Bool_t useMC, Bool_t isAOD, TString appendix, UChar_t TPCcl=70, UChar_t TPCclPID = 80, UChar_t ITScl=3,
2                                     Double_t DCAxy=1000., Double_t DCAz=1000.,
3                                     Double_t TPCs=0., Double_t TPCu=3.09, Double_t TOFs=3., Int_t TOFmis=0,
4                                     Double_t IpSig=3., Bool_t prodcut = kFALSE, 
5                                     Bool_t ipOpp = kTRUE, Bool_t mcstr  = kFALSE, Int_t itshitpixel = 0, 
6                                     Bool_t withetacorrection = kTRUE, Int_t ptbin=0, Int_t TRDtrigger = 0, Int_t TRDtl=6, Int_t TRDeff=4,
7                                     TString detector,Int_t etacut=0){
8   //
9   // HFE task configuration PID2 (TOF-TPC-TRD)
10   //
11 //  AliLog::SetClassDebugLevel("AliHFEpidTRD", 10);
12   Bool_t kAnalyseTaggedTracks = isAOD ? kFALSE : kTRUE;
13
14
15   // TRD settings
16   Float_t eeff[6] = {0.7, 0.75, 0.8, 0.85, 0.9, 0.95};
17   Int_t eeffint[6] = {70, 75, 80, 85, 90, 95};
18   if(TRDeff >= 6 || TRDtl < 4 || TRDtl > 6) return NULL;
19 //  if(TRDeff >= 6 || TRDtl > 6) return NULL;
20   printf("TRD settings: %i %f \n",TRDtl, eeff[TRDeff]);
21
22   Int_t iDCAxy = (Int_t)(DCAxy*10.);
23   Int_t iDCAz = (Int_t)(DCAz*10.);
24   Int_t iTPCs = (Int_t)(TPCs*1000.);
25   Int_t iTOFs = (Int_t)(TOFs*10.);
26   Int_t iIpSig= (Int_t)(IpSig*10.);
27   Int_t iIpOpp= 0;
28   Int_t iProdCut = 1;
29   Int_t iMCStr = 0;
30   Int_t iPixelAny = itshitpixel;
31   Int_t iEtaCorr = 0;
32   if(ipOpp)iIpOpp = 1;
33   if(prodcut) iProdCut = 0;
34   if(mcstr) iMCStr = 1;
35   if(withetacorrection) iEtaCorr = 1;
36
37
38   AliHFEcuts *hfecuts = new AliHFEcuts(appendix,"HFE cuts TOF TPC TRD");
39   //hfecuts->SetQAOn();
40   hfecuts->CreateStandardCuts();
41   hfecuts->SetMinNClustersTPC(TPCcl);
42   hfecuts->SetMinNClustersTPCPID(TPCclPID);
43   hfecuts->SetMinNClustersITS(ITScl);
44   hfecuts->SetMinRatioTPCclusters(0.6);
45   hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
46   hfecuts->SetCutITSpixel(itshitpixel);
47   hfecuts->SetCheckITSLayerStatus(kFALSE);
48   if(TRDtl>0) hfecuts->SetMinNTrackletsTRD(TRDtl, kTRUE);   // number of trd tracklets
49   if(isAOD) hfecuts->SetAODFilterBit(4);
50   Bool_t ipCharge = kFALSE;
51   if(IpSig<0)ipCharge = kTRUE;
52   if(etacut==1) hfecuts->SetEtaRange(-0.6,0.6);
53
54
55   hfecuts->SetIPcutParam(0,0,0,IpSig,kTRUE,ipCharge,ipOpp);
56   if(TMath::Abs(IpSig)>100&&TMath::Abs(IpSig)<220){
57     hfecuts->SetIPcutParam(0.0064,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
58   }
59   else if(TMath::Abs(IpSig)>220&&TMath::Abs(IpSig)<250){
60     hfecuts->SetIPcutParam(0.0064,0.072,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
61   }
62   else if(TMath::Abs(IpSig)>250&&TMath::Abs(IpSig)<270){
63     hfecuts->SetIPcutParam(0.0064,0.083,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
64   }
65   else if(TMath::Abs(IpSig)>270&&TMath::Abs(IpSig)<300){
66     hfecuts->SetIPcutParam(0.0064,0.088,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
67   }
68   else if(TMath::Abs(IpSig)>300&&TMath::Abs(IpSig)<320){
69     hfecuts->SetIPcutParam(0.0064,0.098,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
70   }
71   else if(TMath::Abs(IpSig)>320&&TMath::Abs(IpSig)<350){
72     hfecuts->SetIPcutParam(0.0064,0.108,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
73   }
74   else if(TMath::Abs(IpSig)>350&&TMath::Abs(IpSig)<410){
75     hfecuts->SetIPcutParam(0.0064,0.058,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
76   }
77   else if(TMath::Abs(IpSig)>410&&TMath::Abs(IpSig)<450){
78     hfecuts->SetIPcutParam(0.0064,0.053,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
79   }
80   else if(TMath::Abs(IpSig)>450&&TMath::Abs(IpSig)<470){
81     hfecuts->SetIPcutParam(0.0064,0.068,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
82   }
83   else if(TMath::Abs(IpSig)>470&&TMath::Abs(IpSig)<500){
84     hfecuts->SetIPcutParam(0.0064,0.048,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
85   }
86   else if(TMath::Abs(IpSig)>500&&TMath::Abs(IpSig)<520){
87     hfecuts->SetIPcutParam(0.0044,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
88   }
89   else if(TMath::Abs(IpSig)>520&&TMath::Abs(IpSig)<550){
90     hfecuts->SetIPcutParam(0.0054,0.078,-0.56,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
91   }
92   else if(TMath::Abs(IpSig)>550&&TMath::Abs(IpSig)<600){
93     hfecuts->SetIPcutParam(0.011,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
94   }
95   else if(TMath::Abs(IpSig)>600&&TMath::Abs(IpSig)<700){
96     hfecuts->SetIPcutParam(0.012,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
97   }
98   else if(TMath::Abs(IpSig)>700&&TMath::Abs(IpSig)<900){
99     hfecuts->SetIPcutParam(0.013,0.077,-0.65,0,kFALSE,ipCharge,ipOpp); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
100   }
101
102
103   if(prodcut) hfecuts->SetProductionVertex(0,100,0,100);
104   else {
105     if((iPixelAny==AliHFEextraCuts::kAny) || (iPixelAny==AliHFEextraCuts::kSecond)) hfecuts->SetProductionVertex(0,7,0,7);
106   }
107   //if(trdsec) hfecuts->SetAdditionalStatusRequirement(AliVTrack::kTRDout);
108
109   //hfecuts->SetSigmaToVertex(DCAsi);
110   hfecuts->SetMaxImpactParam(DCAxy,DCAz);
111   //hfecuts->SetQAOn();
112   hfecuts->SetUseMixedVertex(kTRUE);
113   hfecuts->SetVertexRange(10.);
114   // New pPb cuts (February 2013)
115   hfecuts->SetUseCorrelationVertex();
116   hfecuts->SetSPDVtxResolutionCut();
117   // TOF settings:
118   Int_t usetof=0;
119   Bool_t kTOFmis=kFALSE;
120   if (TOFs>0.){
121     usetof = 1;
122     printf("CONFIGURATION FILE: TOF is used \n");
123     hfecuts->SetTOFPIDStep(kTRUE);
124     printf("CONFIGURATION FILE: TOF PID step is requested !!!! \n");
125     if (TOFmis>0){
126       kTOFmis = kTRUE;
127       printf("CONFIGURATION FILE: TOF mismatch rejection is set ON \n");
128     }
129   }
130   AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(appendix);
131   printf("task %p\n", task);
132   task->SetHFECuts(hfecuts);
133   task->GetPIDQAManager()->SetHighResolutionHistos();
134   if(!isAOD) task->SetRemoveFirstEventInChunk(); // Remove first event in chunk in case of ESD analysis
135   task->SetRemovePileUp(kFALSE);
136   //task->SetApplypAVertexCut();
137   Bool_t activateTRDTrigger=kFALSE;
138   if(TRDtrigger>0) activateTRDTrigger=kTRUE;
139   task->SetTRDTrigger(activateTRDTrigger,TRDtrigger);
140
141   // Define Variables
142   if(ptbin==1){
143     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.};
144   }
145   else{
146       //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.};
147       Double_t ptbinning[41] = {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., 22., 24., 26., 28., 30.};
148   }
149   //Double_t etabinning[33] = {-0.8, -0.75, -0.7, -0.65, -0.6, -0.55, -0.5, -0.45, -0.4, -0.35, -0.3, -0.25, -0.2, -0.15, -0.1, 0.05, 0., 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8};
150   //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};
151   Double_t etabinning[9] = {-0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8};
152
153   Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
154   Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
155
156   AliHFEvarManager *vm = task->GetVarManager();
157   vm->AddVariable("pt", sizept, ptbinning);
158   vm->AddVariable("eta", sizeeta, -0.8,0.8);
159   vm->AddVariable("phi",21, -0, 2*TMath::Pi());
160   vm->AddVariable("charge");
161   vm->AddVariable("source");
162   //vm->AddVariable("centrality");
163   if(!useMC){
164     // New background model (LHC10d pass2)
165     //TF1 *hBackground = new TF1("hadronicBackgroundFunction", "TMath::Exp(([0]/(x**1.5))+[1])", 0., 20.);
166     TF1 *hBackground = new TF1("hadronicBackgroundFunction", "TMath::Exp([0]+TMath::Sqrt([1]*x))", 0., 20.);
167     // These settings assume that the default is a cut on .ge.120 TPC clusters (Sep 27, 2011)
168     hBackground->SetParameter(0, -15.86);
169     hBackground->SetParameter(1, 33.63);
170     if (TPCcl == 100){
171       hBackground->SetParameter(0, -14.36);
172       hBackground->SetParameter(1, 27.16);
173     } elseif (TPCcl == 110){
174       hBackground->SetParameter(0, -14.88);
175       hBackground->SetParameter(1, 29.28);
176     } 
177
178     task->SetBackGroundFactorsFunction(hBackground);
179   }
180
181   // Define PID
182   AliHFEpid *pid = task->GetPID();
183   if(useMC) pid->SetHasMCData(kTRUE);
184   pid->SetDetectorsForAnalysis(detector);
185
186   /*
187   if (usetof){
188     pid->AddDetector("TOF", 0);
189     pid->AddDetector("TRD", 1);
190     pid->AddDetector("TPC", 2);
191   } else {
192     pid->AddDetector("TRD", 0);
193     pid->AddDetector("TPC", 1);
194   }*/
195     
196   // HERE PUT THE STRAIGHT CUT
197   Double_t params[4];
198   char *cutmodel;
199   if(useMC){
200     // Monte-Carlo needs modelling of the falling mean with momentum at low momentum
201     // for high momentum it is consistent with a flat -0.94
202     cutmodel = "expo(0)+pol1(2)";//[0]*TMath::Exp([1]*x) + [2] + [3]*x";
203     Double_t paramsMC[4] = {-1.00625e-01, -2.09446e+00, -4.71247e-01, 1.80301e-02};
204     for(int ipar = 0; ipar < 4; ipar++) params[ipar] = paramsMC[ipar];
205   } else {
206     // Data is consistent with a flat constant: (Sep 27, 2011)
207     // 100 clusters: mean = -0.076, width = 1.035
208     // 120 clusters: mean = -0.113, width = 1.03
209     // 140 clusters: mean = -0.093, width = 1.004
210     cutmodel = "pol0(0)";
211     params[0] = TPCs;
212
213     if(withetacorrection) {
214       // Apply eta correction
215       AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
216       TF1 *etacorrection = GetEtaCorrection();
217       if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
218     }
219   }
220   pid->ConfigureTPCdefaultCut(cutmodel, params, TPCu);
221
222   if (usetof){
223     pid->ConfigureTOF(TOFs);
224     AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
225     if (kTOFmis){
226       tofpid->SetRejectTOFmismatch();
227     }
228   }
229
230   if(TRDtl>0){
231       AliHFEpidTRD *trdpid = pid->GetDetPID(AliHFEpid::kTRDpid);
232       trdpid->SetTRD2DPID();
233       trdpid->SetElectronEfficiency(eeff[TRDeff]);   // efficiency
234       trdpid->SetNTracklets(TRDtl);      // ntracklets threshold
235       trdpid->SetCutNTracklets(TRDtl, kTRUE);
236   }
237
238   // To make different upper TOF cut to see contamination effect
239   // The below two lines should be removed after this check
240   //AliHFEpidTOF *tofpid = pid->GetDetPID(AliHFEpid::kTOFpid);
241   //if(TOFs<3.) tofpid->SetTOFnSigmaBand(-3,TOFs); //only to check the assymmetric tof cut
242
243   if(kAnalyseTaggedTracks){
244     AliHFEcuts *v0trackCuts = new AliHFEcuts("V0trackCuts", "Track Cuts for tagged track Analysis");
245     v0trackCuts->CreateStandardCuts();
246     v0trackCuts->SetMinNClustersTPC(TPCcl);  
247     v0trackCuts->SetMinNClustersTPCPID(TPCclPID);
248     v0trackCuts->SetMinRatioTPCclusters(0.6);
249     v0trackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
250     v0trackCuts->SetMinNClustersITS(1);
251     v0trackCuts->SetCutITSpixel(AliHFEextraCuts::kFirst);
252     v0trackCuts->SetCheckITSLayerStatus(kFALSE);
253     v0trackCuts->UnsetVertexRequirement();
254     //hfecuts->SetSigmaToVertex(10);
255     if(usetof) v0trackCuts->SetTOFPIDStep(kTRUE);
256     if(TRDtl>0)v0trackCuts->SetMinNTrackletsTRD(TRDtl,kTRUE); // condition for TRD tracklets 
257     v0trackCuts->SetQAOn();
258     task->SwitchOnPlugin(AliAnalysisTaskHFE::kTaggedTrackAnalysis);
259     task->SetTaggedTrackCuts(v0trackCuts);
260     task->SetCleanTaggedTrack(kTRUE);
261   }
262
263   // QA
264   printf("task %p\n", task);
265   task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
266   task->SetQAOn(AliAnalysisTaskHFE::kMCqa);    
267   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kIsElecBackGround);
268   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kSecVtx);
269   task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
270   if(useMC && mcstr) task->SetDebugStreaming();
271
272   printf("*************************************\n");
273   printf("Configuring standard Task:\n");
274   task->PrintStatus();
275   pid->PrintStatus();
276   printf("*************************************\n"); 
277   return task;
278 }