]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/configs/pp/ConfigHFEpid2SYS.C
Update for aod pp lego train
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / configs / pp / ConfigHFEpid2SYS.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("ConfigHFEpid2SYS","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 AliAnalysisTaskHFE* ConfigHFEpid2SYS(Bool_t useMC, 
27                                      TString appendix, 
28                                      UChar_t TPCcl=70, UChar_t TPCclPID = 80, UChar_t ITScl=3, 
29                                      Double_t DCAxy=1000., Double_t DCAz=1000.,
30                                      Double_t TPCs=0., Double_t TPCu=3.09, Double_t TOFs=3.,
31                                      Double_t IpSig=3., Bool_t prodcut = kFALSE, Bool_t IPAbs = kTRUE, Int_t itshitpixel = 0, 
32                                      Bool_t withetacorrection = kTRUE, TString listname,
33                                      Int_t ptbin=0,
34                                      Bool_t kAnalyseTaggedTracks, Bool_t kMCQA, Bool_t kDEStep){
35   //
36   // HFE task configuration PID2 (TOF-TPC only!)
37   //
38
39   // Name
40   printf("appendix %s\n", appendix.Data());
41
42   // hfecuts
43   AliHFEcuts *hfecuts = new AliHFEcuts(Form("hfeCutsPID2_%s",appendix.Data()),"HFE cuts TOF TPC");
44   hfecuts->CreateStandardCuts();
45   hfecuts->SetMinNClustersTPC(TPCcl);
46   hfecuts->SetMinNClustersTPCPID(TPCclPID);
47   hfecuts->SetMinNClustersITS(ITScl);
48   hfecuts->SetMinRatioTPCclusters(0.6);
49   hfecuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
50   hfecuts->SetCutITSpixel(itshitpixel);
51   hfecuts->SetCheckITSLayerStatus(kFALSE);
52   hfecuts->SetIPcutParam(0,0,0,IpSig,kTRUE,IPAbs);
53   if(IpSig>100&&IpSig<300){
54     hfecuts->SetIPcutParam(0.0064,0.078,-0.56,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
55   }
56   else if(IpSig>300&&IpSig<320){
57     hfecuts->SetIPcutParam(0.0044,0.078,-0.56,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
58   }
59   else if(IpSig>320&&IpSig<350){
60     hfecuts->SetIPcutParam(0.0054,0.078,-0.56,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
61   }
62   else if(IpSig>350&&IpSig<500){
63     hfecuts->SetIPcutParam(0.011,0.077,-0.65,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
64   }
65   else if(IpSig>500&&IpSig<700){
66     hfecuts->SetIPcutParam(0.012,0.077,-0.65,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
67   }
68   else if(IpSig>700&&IpSig<900){
69     hfecuts->SetIPcutParam(0.013,0.077,-0.65,0,kFALSE,IPAbs); // used Carlo's old parameter (new: 0.011+0.077*exp(-0.65*pt))
70   }
71
72   if(prodcut) hfecuts->SetProductionVertex(0,100,0,100);
73   else {
74     if((itshitpixel==AliHFEextraCuts::kAny) || (itshitpixel==AliHFEextraCuts::kSecond)) hfecuts->SetProductionVertex(0,7,0,7);
75   }
76   
77   hfecuts->SetMaxImpactParam(DCAxy,DCAz);
78   hfecuts->SetTOFPIDStep(kTRUE);
79   hfecuts->SetUseMixedVertex(kTRUE);
80   hfecuts->SetVertexRange(10.);
81
82   // analysis task
83   AliAnalysisTaskHFE *task = new AliAnalysisTaskHFE(Form("HFEanalysisPID2_%s",appendix.Data()));
84   task->SetHFECuts(hfecuts);
85   task->SetRemovePileUp(kTRUE);
86   task->GetPIDQAManager()->SetHighResolutionHistos();
87
88   // Define Variables
89   if(ptbin==1){
90     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.};
91   }
92   else{
93     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.};
94   }
95   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};
96
97   Int_t sizept=(sizeof(ptbinning)/sizeof(double))-1;
98   Int_t sizeeta=(sizeof(etabinning)/sizeof(double))-1;
99
100   AliHFEvarManager *vm = task->GetVarManager();
101   vm->AddVariable("pt", sizept, ptbinning);
102   vm->AddVariable("eta", sizeeta, -0.8,0.8);
103   vm->AddVariable("phi",21, -0, 2*TMath::Pi());
104   vm->AddVariable("charge");
105   vm->AddVariable("source");
106   
107   // Contamination
108   if(!useMC){
109     // New background model (LHC10d pass2)
110     TF1 *hBackground = new TF1("hadronicBackgroundFunction", "TMath::Exp(([0]/(x**1.5))+[1])", 0., 20.);
111     // These settings assume that the default is a cut on .ge.120 TPC clusters (Sep 27, 2011)
112     hBackground->SetParameter(0, -55.18);
113     hBackground->SetParameter(1, -0.0026);
114     if (TPCcl == 100){
115       hBackground->SetParameter(0, -39.5);
116       hBackground->SetParameter(1, -0.438);
117     } elseif (TPCcl == 140){
118       hBackground->SetParameter(0, -82.11);
119       hBackground->SetParameter(1, 1.138);
120     } 
121
122     task->SetBackGroundFactorsFunction(hBackground);
123   }
124
125   // Define PID
126   AliHFEpid *pid = task->GetPID();
127   if(useMC) pid->SetHasMCData(kTRUE);
128   pid->AddDetector("TOF", 0);
129   pid->AddDetector("TPC", 1);
130   // HERE PUT THE STRAIGHT CUT
131   Double_t params[4];
132   char *cutmodel;
133   if(useMC){
134     // Monte-Carlo needs modelling of the falling mean with momentum at low momentum
135     // for high momentum it is consistent with a flat -0.94
136     cutmodel = "expo(0)+pol1(2)";//[0]*TMath::Exp([1]*x) + [2] + [3]*x";
137     Double_t paramsMC[4] = {-1.00625e-01, -2.09446e+00, -4.71247e-01, 1.80301e-02};
138     for(int ipar = 0; ipar < 4; ipar++) params[ipar] = paramsMC[ipar];
139   } else {
140     // Data is consistent with a flat constant: (Sep 27, 2011)
141     // 100 clusters: mean = -0.076, width = 1.035
142     // 120 clusters: mean = -0.113, width = 1.03
143     // 140 clusters: mean = -0.093, width = 1.004
144     cutmodel = "pol0(0)";
145     params[0] = TPCs;
146
147     if(withetacorrection) {
148       // Apply eta correction
149       AliHFEpidTPC *tpcpid = pid->GetDetPID(AliHFEpid::kTPCpid);
150       TF1 *etacorrection = GetEtaCorrection(listname);
151       if(etacorrection) tpcpid->SetEtaCorrection(etacorrection);
152     }
153   }
154   pid->ConfigureTOF(TOFs);
155   pid->ConfigureTPCdefaultCut(cutmodel, params, TPCu);
156
157   if(kAnalyseTaggedTracks){
158     AliHFEcuts *v0trackCuts = new AliHFEcuts("V0trackCuts", "Track Cuts for tagged track Analysis");
159     v0trackCuts->CreateStandardCuts();
160     v0trackCuts->SetMinNClustersTPC(TPCcl);  
161     v0trackCuts->SetMinRatioTPCclusters(0.6);
162     v0trackCuts->SetTPCmodes(AliHFEextraCuts::kFound, AliHFEextraCuts::kFoundOverFindable);
163     v0trackCuts->SetMinNClustersITS(1);
164     v0trackCuts->SetCutITSpixel(AliHFEextraCuts::kFirst);
165     v0trackCuts->SetCheckITSLayerStatus(kFALSE);
166     v0trackCuts->UnsetVertexRequirement();
167     v0trackCuts->SetTOFPIDStep(kTRUE);
168     v0trackCuts->SetQAOn();
169
170     task->SwitchOnPlugin(AliAnalysisTaskHFE::kTaggedTrackAnalysis);
171     task->SetTaggedTrackCuts(v0trackCuts);
172     task->SetCleanTaggedTrack(kTRUE);
173   }
174
175   // QA
176   printf("task %p\n", task);
177   task->SetQAOn(AliAnalysisTaskHFE::kPIDqa);
178   if(kMCQA) task->SetQAOn(AliAnalysisTaskHFE::kMCqa);    
179   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kIsElecBackGround);
180   //task->SwitchOnPlugin(AliAnalysisTaskHFE::kSecVtx);
181   if(kDEStep) task->SwitchOnPlugin(AliAnalysisTaskHFE::kDEstep);
182   
183   printf("*************************************\n");
184   printf("Configuring standard Task:\n");
185   task->PrintStatus();
186   pid->PrintStatus();
187   printf("*************************************\n"); 
188   return task;
189 }