]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDComparisonV0MI.C
Add the possibiloity to save cut settings in the ROOT file
[u/mrichter/AliRoot.git] / STEER / AliESDComparisonV0MI.C
1 /*
2
3 .L $ALICE_ROOT/STEER/AliGenInfo.C+
4 .L $ALICE_ROOT/STEER/AliESDComparisonMI.C+
5 .L AliESDComparisonV0MI.C
6 .x TDR_style.C
7
8 AliKalmanTrack::SetConvConst(1);
9 AliESDComparisonDraw compv0;  
10 AliESDComparisonDraw comp;  
11
12
13 TFile fv0("cmpESDTracks.root");
14 TTree * treev0 = (TTree*)fv0.Get("ESDcmpV0");
15 TTree * tree = (TTree*)fv0.Get("ESDcmpTracks");
16 compv0.fTree = treev0;
17 comp.fTree = tree;
18 MakeV0Aliases(&compv0);
19 MakeAliases(comp);
20
21 //
22 //
23 TChain * chain1 = new TChain("ESDcmpV0","ESDcmpV0");
24 chain1->AddFile("k0merge/cmpESDTracks.root");
25 chain1->AddFile("k0merge1000/cmpESDTracks.root");
26 chain1->AddFile("strangemerge/newv1/cmpESDTracks.root");
27 compv0.fTree = chain1;
28 MakeV0Aliases(&compv0);
29 //
30 //
31 TChain * chain3 = new TChain("ESDcmpV0","ESDcmpV0");
32 //
33 chain3->AddFile("750801/cmpESDTracks.root");
34 chain3->AddFile("751760/cmpESDTracks.root");
35 chain3->AddFile("751764/cmpESDTracks.root");
36 chain3->AddFile("751765/cmpESDTracks.root");
37 chain3->AddFile("751766/cmpESDTracks.root");
38 chain3->AddFile("751767/cmpESDTracks.root");
39 chain3->AddFile("751768/cmpESDTracks.root");
40 chain3->AddFile("751769/cmpESDTracks.root");
41 chain3->AddFile("751772/cmpESDTracks.root");
42 //
43 chain3->AddFile("751774/cmpESDTracks.root");
44 chain3->AddFile("751775/cmpESDTracks.root");
45 chain3->AddFile("751776/cmpESDTracks.root");
46 chain3->AddFile("751778/cmpESDTracks.root");
47 chain3->AddFile("751779/cmpESDTracks.root");
48 chain3->AddFile("751781/cmpESDTracks.root");
49 chain3->AddFile("751782/cmpESDTracks.root");
50 chain3->AddFile("751784/cmpESDTracks.root");
51 //
52 chain3->AddFile("751788/cmpESDTracks.root");
53 chain3->AddFile("751789/cmpESDTracks.root");
54 chain3->AddFile("751790/cmpESDTracks.root");
55 chain3->AddFile("751791/cmpESDTracks.root");
56 chain3->AddFile("751792/cmpESDTracks.root");
57 chain3->AddFile("751793/cmpESDTracks.root");
58 chain3->AddFile("751794/cmpESDTracks.root");
59 chain3->AddFile("751796/cmpESDTracks.root");
60
61 compv0.fTree = chain3;
62 MakeV0Aliases(&compv0);
63
64 TChain * chain3 = new TChain("ESDcmpTracks","ESDcmpTracks");
65 chain3->AddFile("751790/cmpESDTracks.root");
66 chain3->AddFile("751791/cmpESDTracks.root");
67 chain3->AddFile("751792/cmpESDTracks.root");
68 chain3->AddFile("751793/cmpESDTracks.root");
69 chain3->AddFile("751794/cmpESDTracks.root");
70 chain3->AddFile("751796/cmpESDTracks.root");
71 comp.fTree = chain3;
72 MakeAliases(comp);
73 //
74 TChain * chain2 = new TChain("ESDcmpV0","ESDcmpV0");
75 chain2->AddFile("run50_100/newv6/cmpESDTracks.root");
76 chain2->AddFile("run20_100/newv6/cmpESDTracks.root");
77 compv0.fTree = chain2;
78 MakeV0Aliases(&compv0);
79
80 //
81 //
82 TChain * chain3 = new TChain("ESDcmpV0","ESDcmpV0");
83 chain3->AddFile("~/data/HEAD0205/cent1_0/newv7cmpESDTracks.root");
84
85 */
86
87 TH1F hrel("hrel","hrel",100,-1,1);
88 TCut cbase("cbase","RC.fV0Status>-1");
89 TCut cr("cr","RC.fV0Status==3");
90 TCut cp("cp","MC.fMotherP.fVx<0.2&&MC.fMotherP.fVy<0.2");
91 TCut clambda("clambda","MC.fMotherP.fPdgCode==3122");
92 TCut calambda("calambda","MC.fMotherP.fPdgCode==-3122");
93 TCut clam("clam","abs(MC.fMotherP.fPdgCode)==3122");
94 TCut cgamma("cgamma","abs(MC.fMotherP.fPdgCode)==22");
95 TCut ck0s("ck0s","MC.fMotherP.fPdgCode==313");
96 TCut ck0b("ck0b","MC.fMotherP.fPdgCode==-313");
97 TCut cks0("cks0","MC.fMotherP.fPdgCode==310");
98 TCut crho0("crho0","MC.fMotherP.fPdgCode==113");
99 TCut cpi("cpi","abs(MC.fMotherP.fPdgCode)==211");
100 TCut cpa("cpa","MC.fPointAngle>0.999");
101 TCut cint("cint","abs(MC.fMotherP.fPdgCode)==3122||abs(MC.fMotherP.fPdgCode)==22||MC.fMotherP.fPdgCode==310"+cpa);
102 TH1F hpull("hpull","hpull",100,-5,5); 
103 TF1 fim("fim","[2]*exp(-(x-[0])**2/(2*[1]**2))+abs([3])+[4]*(x-0.495)",0,1);
104
105
106 void MakeV0Aliases(AliESDComparisonDraw * compv0)
107 {
108   //
109   // Make base, resol and cut aliases
110   //
111   MakeAliasBase(compv0);
112   MakeResolAlias(compv0);
113   MakeCutsAliases(compv0);
114   MakeCutsAliasesPID(compv0);
115 }
116
117 void MakeAliasBase(AliESDComparisonDraw * compv0){
118   //
119   //  aliases based on MC data
120   //  and on Reconstructed data
121   //
122   //  comp->fTree->SetAlias("locphi","(100*(180+180*atan2(MC.fParticle.fPy,MC.fParticle.fPx)/pi)%1000.)*0.01");
123   compv0->fTree->SetAlias("minlab","min(abs(RC.fV0rec.fLab[0]),abs(RC.fV0rec.fLab[1]))");    
124   compv0->fTree->SetAlias("maxlab","max(abs(RC.fV0rec.fLab[0]),abs(RC.fV0rec.fLab[1]))");    
125   compv0->fTree->SetAlias("MCE","sqrt((MC.fMCm.fParticle.fPx+MC.fMCd.fParticle.fPx)**2+(MC.fMCm.fParticle.fPy+MC.fMCd.fParticle.fPy)**2+(MC.fMCm.fParticle.fPz+MC.fMCd.fParticle.fPz)**2)");  
126   compv0->fTree->SetAlias("Ptpc","sqrt((RC.fV0tpc.fPM[0]+RC.fV0tpc.fPP[0])**2+(RC.fV0tpc.fPM[1]+RC.fV0tpc.fPP[1])**2+(RC.fV0tpc.fPM[2]+RC.fV0tpc.fPP[2])**2)");  
127   compv0->fTree->SetAlias("Pits","sqrt((RC.fV0its.fPM[0]+RC.fV0its.fPP[0])**2+(RC.fV0its.fPM[1]+RC.fV0its.fPP[1])**2+(RC.fV0its.fPM[2]+RC.fV0its.fPP[2])**2)");
128   compv0->fTree->SetAlias("Prec","sqrt((RC.fV0rec.fPM[0]+RC.fV0rec.fPP[0])**2+(RC.fV0rec.fPM[1]+RC.fV0rec.fPP[1])**2+(RC.fV0rec.fPM[2]+RC.fV0rec.fPP[2])**2)");
129
130   compv0->fTree->SetAlias("PTtpc","sqrt((RC.fV0tpc.fPM[0]+RC.fV0tpc.fPP[0])**2+(RC.fV0tpc.fPM[1]+RC.fV0tpc.fPP[1])**2)");  
131   compv0->fTree->SetAlias("PTits","sqrt((RC.fV0its.fPM[0]+RC.fV0its.fPP[0])**2+(RC.fV0its.fPM[1]+RC.fV0its.fPP[1])**2)");
132   compv0->fTree->SetAlias("PTrec","sqrt((RC.fV0rec.fPM[0]+RC.fV0rec.fPP[0])**2+(RC.fV0rec.fPM[1]+RC.fV0rec.fPP[1])**2)");
133   compv0->fTree->SetAlias("PhiRec","atan2(RC.fV0rec.fPP[1]+RC.fV0rec.fPM[1],RC.fV0rec.fPP[0]+RC.fV0rec.fPM[0])");
134   compv0->fTree->SetAlias("PhiTpc","atan2(RC.fV0tpc.fPP[1]+RC.fV0tpc.fPM[1],RC.fV0tpc.fPP[0]+RC.fV0tpc.fPM[0])");
135   compv0->fTree->SetAlias("PhiIts","atan2(RC.fV0its.fPP[1]+RC.fV0its.fPM[1],RC.fV0its.fPP[0]+RC.fV0its.fPM[0])");
136   compv0->fTree->SetAlias("PhiMC","atan2(MC.fMotherP.fPy,MC.fMotherP.fPx)");
137
138   compv0->fTree->SetAlias("minpt","min(abs(MC.fMCm.fParticle.Pt()),abs(MC.fMCd.fParticle.Pt()))");
139   compv0->fTree->SetAlias("minpt2","min(abs(MC.fMCm.fTrackRef.Pt()),abs(MC.fMCd.fTrackRef.Pt()))");
140   compv0->fTree->SetAlias("minrows","min(MC.fMCm.fRowsWithDigits,MC.fMCd.fRowsWithDigits)");
141   compv0->fTree->SetAlias("maxtan","tan(max(abs(MC.fMCm.fParticle.Theta()-1.578),abs(MC.fMCd.fParticle.Theta()-1.578)))");
142   compv0->fTree->SetAlias("maxtanr","max(abs(RC.fV0rec.fParamP.fParam[3]),abs(RC.fV0rec.fParamM.fParam[3]))");
143   
144   compv0->fTree->SetAlias("findable","RC.fRecStatus>=0&&MC.fMCR>0.8&&MC.fMCR<120&&minrows>100&&minpt>0.2&&maxtan<1.0&&sqrt(MC.fMotherP.fVx**2+MC.fMotherP.fVy**2)<0.00001&&MC.fPointAngle>0.9999");
145   
146   compv0->fTree->SetAlias("findable2","RC.fRecStatus>=0&&MC.fMCR>0.6&&MC.fMCR<120&&MC.fPointAngle>0.9999&&min(MC.fMCm.fRowsWithDigits,MC.fMCd.fRowsWithDigits)>120&&max(abs(MC.fMCm.fTrackRef.fZ),abs(MC.fMCd.fTrackRef.fZ))<90&&min(abs(MC.fMCm.fParticle.Pt()),abs(MC.fMCd.fParticle.Pt()))>0.2");
147   
148   compv0->fTree->SetAlias("EMC2","(MC.fMCd.fParticle.fE+MC.fMCm.fParticle.fE)*(MC.fMCd.fParticle.fE+MC.fMCm.fParticle.fE)");
149   compv0->fTree->SetAlias("PMC2","(MC.fMCd.fParticle.fPx+MC.fMCm.fParticle.fPx)**2+(MC.fMCd.fParticle.fPy+MC.fMCm.fParticle.fPy)**2+(MC.fMCd.fParticle.fPz+MC.fMCm.fParticle.fPz)**2");
150 }  
151
152 ////////////////////////////////////////////
153 ////////////////////////////////////////////
154 ////////////////////////////////////////////
155
156 void MakeResolAlias(AliESDComparisonDraw * compv0){
157   //
158   // Resolution estimates 
159   // SigmaAP0 and SigmaD0 - uses Covariance matrix
160   // SigmaAP2 and SigmaD2 - "Restricted Sigma"  in ( 0.5  to 1.5) window from effective sigma parameterization
161   //                       
162   compv0->fTree->SetAlias("CausalityB","(1-RC.fV0rec.fCausality[0])*(1-RC.fV0rec.fCausality[1])");
163   compv0->fTree->SetAlias("CausalityA","sqrt((min(RC.fV0rec.fCausality[2],0.7))*(min(RC.fV0rec.fCausality[3],0.7)))");
164   compv0->fTree->SetAlias("p12","sqrt(RC.fV0rec.fParamP.fParam[4]**2+RC.fV0rec.fParamM.fParam[4]**2)");
165   compv0->fTree->SetAlias("ptminrec","1./max(abs(RC.fV0rec.fParamP.fParam[4]),abs(RC.fV0rec.fParamM.fParam[4]))");
166   compv0->fTree->SetAlias("P0","(exp(-RC.fV0rec.fDistNorm)+0.1)*(RC.fV0rec.fDist2<0.5)*(RC.fV0rec.fDistNorm<5)");
167   //
168   // resolution estimates in Y and Z
169   //
170   compv0->fTree->SetAlias("SigmaY","sqrt(RC.fV0rec.fParamP.fCovar[0]+RC.fV0rec.fParamM.fCovar[0]+(RC.fV0rec.fParamP.fCovar[5])*(RC.fV0rec.fParamP.fX-RC.fV0rec.fRr)**2+(RC.fV0rec.fParamM.fCovar[5])*(RC.fV0rec.fParamM.fX-RC.fV0rec.fRr)**2)");  
171   compv0->fTree->SetAlias("SigmaZ","sqrt(RC.fV0rec.fParamP.fCovar[2]+RC.fV0rec.fParamM.fCovar[2]+(RC.fV0rec.fParamP.fCovar[9])*(RC.fV0rec.fParamP.fX-RC.fV0rec.fRr)**2+(RC.fV0rec.fParamM.fCovar[9])*(RC.fV0rec.fParamM.fX-RC.fV0rec.fRr)**2)");
172   //
173   // Normalize distance sigma
174   compv0->fTree->SetAlias("SigmaD00","RC.fV0rec.fParamP.fCovar[0]+RC.fV0rec.fParamM.fCovar[0]+RC.fV0rec.fParamP.fCovar[2]+RC.fV0rec.fParamM.fCovar[2]");
175
176   compv0->fTree->SetAlias("SigmaD01","min(RC.fV0rec.fRr-RC.fV0rec.fParamP.fX,0)**2*(RC.fV0rec.fParamP.fCovar[5]+RC.fV0rec.fParamP.fCovar[9])+min(RC.fV0rec.fRr-RC.fV0rec.fParamM.fX,0)**2*(RC.fV0rec.fParamM.fCovar[5]+RC.fV0rec.fParamM.fCovar[9])");
177   compv0->fTree->SetAlias("SigmaD0","sqrt(SigmaD00+SigmaD01+0.03**2)");
178   //
179   // Point Angle sigma
180   compv0->fTree->SetAlias("Norm0","sqrt(RC.fV0rec.fPM[0]**2+RC.fV0rec.fPM[1]**2+RC.fV0rec.fPM[2]**2)/Prec");
181   compv0->fTree->SetAlias("Norm1","sqrt(RC.fV0rec.fPP[0]**2+RC.fV0rec.fPP[1]**2+RC.fV0rec.fPP[2]**2)/Prec");
182   compv0->fTree->SetAlias("SigmaA","(RC.fV0rec.fParamP.fCovar[5]+RC.fV0rec.fParamP.fCovar[9])*(Norm1**2)+(RC.fV0rec.fParamP.fCovar[5]+RC.fV0rec.fParamM.fCovar[9])*(Norm0**2)");
183   compv0->fTree->SetAlias("SigmaAP0","sqrt(0.005**2+0.5*((SigmaD0/RC.fV0rec.fRr)**2+SigmaA))");
184   //compv0->fTree->SetAlias("SigmaAP0","sqrt(0.0001**2+0.5*((SigmaD0/RC.fV0rec.fRr)**2+SigmaA))");
185   //
186   // Effective sigma definition
187   //  
188   compv0->fTree->SetAlias("SigmaAPE0","min((0.005+0.02/(0.1+RC.fV0rec.fRr))*0.4*(0.7+0.3*p12),0.06)");
189   compv0->fTree->SetAlias("SigmaAP2","max(min((SigmaAP0+SigmaAPE0)*0.5,1.5*SigmaAPE0),0.5*SigmaAPE0+0.003)");
190   compv0->fTree->SetAlias("SigmaDE0","min(sqrt( ((0.02*max(sqrt(RC.fV0rec.fRr)-2.7,0))*p12**2)**2**2+0.06**2),0.5)");
191   compv0->fTree->SetAlias("SigmaD2","max(min((SigmaD0+SigmaDE0)*0.5,1.5*SigmaDE0),0.5*SigmaDE0)");
192
193 }
194
195 void MakeCutsAliases(AliESDComparisonDraw * compv0){
196   //
197   // Defines likelihood variables
198   // LikeAP   - likelihood acoording point angle
199   // LikeD    - likelihood according DCA
200   // LCausal  - causality likelihood  
201   // and Cuts 
202   // CLow1 cut - cut on log(LikeAP*LogD)
203   // CHigh cut - Causality likehood also used  - cut on log(LikeAP*LikeD*LCausal)
204   //
205   compv0->fTree->SetAlias("APNorm0","acos(RC.fV0rec.fPointAngle)/SigmaAP0");
206   compv0->fTree->SetAlias("DNorm0", "RC.fV0rec.fDist2/SigmaD0");
207   compv0->fTree->SetAlias("APNorm2","acos(RC.fV0rec.fPointAngle)/SigmaAP2");
208   compv0->fTree->SetAlias("DNorm2", "RC.fV0rec.fDist2/SigmaD2");
209   //
210   compv0->fTree->SetAlias("LikeAP","(10^-50+exp(-APNorm2**2/2)+0.5*exp(-APNorm2**2/4)+0.25*exp(-APNorm2**2/8))/1.75");
211   compv0->fTree->SetAlias("LikeD","10^-50+(exp(-DNorm2*2)+0.5*exp(-DNorm2)+0.25*exp(-DNorm2/2))/1.75");
212   //
213   compv0->fTree->SetAlias("LikeAP0","10^-50+exp(-APNorm0**2/2)");
214   compv0->fTree->SetAlias("LikeD0","10^-50+exp(-DNorm0*2.0)");
215   //
216   compv0->fTree->SetAlias("LikeAP1","10^-50+(exp(-APNorm0**2/2)+0.5*exp(-APNorm0**2/4))/1.5");
217   compv0->fTree->SetAlias("LikeD1","10^-50+(exp(-DNorm0*2.0)+0.3*exp(-DNorm0))/1.3");
218   //
219   compv0->fTree->SetAlias("LikeAP3","10^-50+exp(-APNorm2**2/2)");
220   compv0->fTree->SetAlias("LikeD3","10^-50+exp(-DNorm2*2.0)");
221   //
222   //
223   compv0->fTree->SetAlias("MinCausal","min(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])");
224   compv0->fTree->SetAlias("MeanCausal","0.5*(RC.fV0rec.fCausality[0]+RC.fV0rec.fCausality[1])");
225   compv0->fTree->SetAlias("MaxCausal","max(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])");
226   //  compv0->fTree->SetAlias("LCausal","(1.05-(3*(0.8-exp(-MaxCausal))+(0.8-exp(-MinCausal)))/2)**4");
227   compv0->fTree->SetAlias("LCausal","(1.05-(2*(0.8-exp(-max(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])))+2*(0.8-exp(-min(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1]))))/2)**4");
228   //  compv0->fTree->SetAlias("LCausal","(1.05-(2*(0.8-exp(-max(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])))))**4");
229   //  
230   //
231   compv0->fTree->SetAlias("CLow1","RC.fV0rec.fPointAngle>0.99&&RC.fV0rec.fRr<210&&log(LikeD*LikeAP)>-5.");
232   compv0->fTree->SetAlias("CHigh","CLow1&&log(LikeD*LikeAP*LCausal)>-5.0");
233   compv0->fTree->SetAlias("CHigh4","CLow1&&log(LikeD*LikeAP*LCausal)>-4.0");
234   compv0->fTree->SetAlias("CHigh3","CLow1&&log(LikeD*LikeAP*LCausal)>-3.0");
235   compv0->fTree->SetAlias("CHigh2","CLow1&&log(LikeD*LikeAP*LCausal)>-2.0");
236   compv0->fTree->SetAlias("CHigh1","CLow1&&log(LikeD*LikeAP*LCausal)>-1.0");
237   //  
238   compv0->fTree->SetAlias("minCB","min(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])<0.5"); 
239 }
240
241
242 void MakeCutsAliasesPID(AliESDComparisonDraw * compv0){
243   //
244   // Cuts optimized for different types of particle
245   // use PID of daughter particles as additional criteria 
246   //
247   compv0->fTree->SetAlias("Spid0","RC.fT1.fESDTrack.fTPCr[0]+RC.fT1.fESDTrack.fTPCr[2]+RC.fT1.fESDTrack.fTPCr[3]+RC.fT1.fESDTrack.fTPCr[4]");
248   compv0->fTree->SetAlias("Spid1","RC.fT2.fESDTrack.fTPCr[0]+RC.fT2.fESDTrack.fTPCr[2]+RC.fT2.fESDTrack.fTPCr[3]+RC.fT2.fESDTrack.fTPCr[4]");
249   // K0S CUT
250   compv0->fTree->SetAlias("Crecks0_0","RC.fT1.fESDTrack.fTPCr[0]/Spid0<0.9&&RC.fT1.fESDTrack.fTPCr[4]/Spid0<0.8&RC.fT1.fESDTrack.fTPCr[3]/Spid0<0.9&&RC.fT2.fESDTrack.fTPCr[0]/Spid1<0.9&&RC.fT2.fESDTrack.fTPCr[4]/Spid1<0.8&&RC.fT2.fESDTrack.fTPCr[3]/Spid1<0.9");
251   compv0->fTree->SetAlias("Crecks0_1","RC.fV0rec.fNormDCAPrim[0]>4&&RC.fV0rec.fNormDCAPrim[0]>4");
252   compv0->fTree->SetAlias("Crecks0","Crecks0_0&&Crecks0_1&&RC.fV0rec.fRr<25");
253   // 
254   // LAMBDA CUTS
255   compv0->fTree->SetAlias("CrecLambda_0","RC.fT1.fESDTrack.fTPCr[4]/Spid0>0.19&&RC.fT2.fESDTrack.fTPCr[2]/Spid0>0.19");
256   compv0->fTree->SetAlias("CrecLambda_1","RC.fT1.fESDTrack.fTPCr[0]/Spid0<0.9&&RC.fT2.fESDTrack.fTPCr[0]/Spid0<0.9");
257   compv0->fTree->SetAlias("CrecLambda","CrecLambda_0&&CrecLambda_1");
258   //
259   // GAMMA CONVERSION CUTS
260   compv0->fTree->SetAlias("CrecGamma_0","RC.fT1.fESDTrack.fTPCr[0]/Spid0+RC.fT2.fESDTrack.fTPCr[0]/Spid1>0.4");
261   compv0->fTree->SetAlias("CrecGamma_1","RC.fT1.fESDTrack.fTPCr[4]/Spid0<0.8&&RC.fT2.fESDTrack.fTPCr[4]/Spid1<0.8");
262   compv0->fTree->SetAlias("CrecGamma_2","RC.fT1.fESDTrack.fTPCr[2]/Spid0<0.9&&RC.fT2.fESDTrack.fTPCr[2]/Spid1<0.9");
263   compv0->fTree->SetAlias("CrecGamma","CrecGamma_0&&CrecGamma_1&&CrecGamma_2");
264 }
265
266 //
267 //----------------------------------------------------------------------------------------------
268 TH1F * GetInvMass(AliESDComparisonDraw* compv0, TCut cut, Int_t pdg=310, Bool_t all=kFALSE){
269   //
270   //   return invariant mass histogram
271   //   pdg - specify type of particle - (mass window)
272   //   all - kTRUE  - all particles shown
273   //         kFALSE - only particle with given pdg
274   if (pdg==310){
275     TH1F * himk0 = new TH1F("himk0","himk0",100,0.46,0.54);
276     if (all) {
277       compv0->fTree->Draw("RC.fV0rec.GetEffMass(2,2)>>himk0",cut);
278     }else{
279       compv0->fTree->Draw("RC.fV0rec.GetEffMass(2,2)>>himk0",cut+cks0);
280     }
281     himk0->SetXTitle("Invariant Mass (GeV)");
282     fim.SetParameter(0,0.4975);
283     fim.SetParameter(1,0.003);
284     fim.SetParameter(2,himk0->GetMaximum());
285     fim.SetParameter(3,(himk0->GetBinContent(1)+himk0->GetBinContent(99))*0.5);
286     fim.SetParameter(4,0);
287     himk0->Fit(&fim);
288     himk0->Draw();
289     return himk0;
290   }
291   if (pdg==3122){
292     TH1F * hlam0 = new TH1F("hlam0","hlam0",100,1.1,1.13);
293     if (all){
294       compv0->fTree->Draw("RC.fV0rec.GetEffMass(4,2)>>hlam0",cut);
295     }else{
296       compv0->fTree->Draw("RC.fV0rec.GetEffMass(4,2)>>hlam0",cut+clambda);
297     }
298     hlam0->SetXTitle("Invariant Mass (GeV)");
299     fim.SetParameter(0,1.11568);
300     fim.SetParameter(1,0.0011);
301     fim.SetParameter(2,himk0->GetMaximum());
302     fim.SetParameter(3,(himk0->GetBinContent(1)+himk0->GetBinContent(99))*0.5);
303     fim.SetParameter(4,0);
304     hlam0->Fit(&fim);
305     hlam0->Draw();
306     return hlam0;
307   }
308   if (pdg==22){
309     TH1F * hgamma = new TH1F("hgamma","hgamma",100,0.0,0.2);
310     if (all){
311       compv0->fTree->Draw("RC.fV0rec.GetEffMass(0,0)>>hgamma",cut);
312     }else{
313       compv0->fTree->Draw("RC.fV0rec.GetEffMass(0,0)>>hgamma",cut+cgamma);
314     }
315     hgamma->SetXTitle("Invariant Mass (GeV)");
316     
317     hgamma->Fit("gaus");
318     hgamma->Draw();
319     return hgamma;
320   }
321 }
322
323 TH1F * GetInvMassPtMin(AliESDComparisonDraw* compv0, TCut cut="RC.fRecStatus==1&&CHigh", Int_t pdg=310)
324 {
325   //
326   // effective mass resolution vs. particle momenta
327   //
328   if (pdg==310){
329     compv0->DrawXY("minpt","1000*(RC.fV0rec.GetEffMass(2,2)-0.49767)",cut,"RC.fRecStatus==1",5,0.2,1,-10,10);
330   }
331   if (pdg==3122){
332     compv0->DrawXY("minpt","1000*(RC.fV0rec.GetEffMass(4,2)-1.11568)",cut,"RC.fRecStatus==1",5,0.2,0.5,-10,10);
333   }
334   TH1F * his = (TH1F*)compv0->fRes->Clone();
335   his->SetXTitle("Pt(GeV)");
336   his->SetYTitle("Invariant mass sigma (MeV)");
337   his->Draw();
338   return his;
339 }
340
341 TH1F * GetLogLikelihood(AliESDComparisonDraw* compv0, char * var0="LCausal*LikeAP*LikeD", 
342                         TCut cut="RC.fRecStatus==1&&CHigh", Int_t min=-10)
343 {
344   //
345   // Likelihood
346   //
347   //char *var0 = "LCausal";
348   TH1F * his = new TH1F("loglikelihood","loglikelihood",50,min,0);
349   char var[1000];
350   sprintf(var,"log(%s)>>loglikelihood",var0);
351   compv0->fTree->Draw(var,cut);
352   his->SetXTitle("Logarithm of likelihood");
353   his->Draw();
354   return his;
355 }
356
357 //
358 //----------------------------------------------------------------------------------------------
359 TH1F * GetDeltaR(AliESDComparisonDraw* compv0, TCut cut){
360   //
361   // resolution of vertex position in radial direction 
362   //
363   TH1F * hdr = new TH1F("hdr","hdr",100,-0.5,0.5);
364   compv0->fTree->Draw("RC.fV0rec.fRr-MC.fMCR>>hdr",cut);
365   hdr->SetXTitle("Delta r (cm)");
366   hdr->Fit("gaus");
367   hdr->Draw();
368   return hdr;
369 }
370
371 //
372 //----------------------------------------------------------------------------------------------
373 TH1F* GetResolP2(AliESDComparisonDraw* compv0, TCut cut, Float_t pmin=0.6, Float_t pmax=2.){
374   //
375   //
376   //
377   compv0->DrawXY("MC.fMotherP.P()","100*(MC.fMotherP.P()-Prec)/MC.fMotherP.P()",cut,"RC.fRecStatus==1",5,pmin,pmax,-6,6);
378   TH1F * hdp0 = (TH1F*)compv0->fRes->Clone();
379   compv0->DrawXY("MC.fMotherP.P()","100*(MC.fMotherP.P()-Pits)/MC.fMotherP.P()",cut,"RC.fRecStatus==1",5,pmin,pmax,-6,6);
380   TH1F * hdp1 = (TH1F*)compv0->fRes->Clone();
381   compv0->DrawXY("MC.fMotherP.P()","100*(MC.fMotherP.P()-Ptpc)/MC.fMotherP.P()",cut,"RC.fRecStatus==1",5,pmin,pmax,-6,6);
382   TH1F * hdp2 = (TH1F*)compv0->fRes->Clone();
383   hdp0->SetXTitle("P(GeV)");
384   hdp0->SetYTitle("dP/P(%)");
385   hdp0->SetMarkerStyle(26);
386   hdp1->SetMarkerStyle(27);
387   hdp2->SetMarkerStyle(28);  
388   hdp0->Draw();
389   hdp1->Draw("same");
390   hdp2->Draw("same");
391   //
392   TLegend *legend = new TLegend(0.35,0.15,0.85,0.3, "Momentum resolution");
393   legend->SetBorderSize(1);
394   legend->AddEntry(hdp0,"Combined V0 finder");
395   legend->AddEntry(hdp1,"ESD V0 finder");
396   legend->AddEntry(hdp2,"TPC V0 finder");
397   //
398   legend->Draw();
399   return hdp0;
400 }
401 //
402 //----------------------------------------------------------------------------------------------
403 TH1F* GetResolPhi(AliESDComparisonDraw* compv0, TCut cut, Float_t pmin=0.6, Float_t pmax=2.){
404   //
405   //
406   compv0->DrawXY("MC.fMotherP.P()","1000*(PhiMC-PhiRec)",cut,"RC.fRecStatus==1",5,pmin,pmax,-15,15,20);
407   TH1F * hdp0 = (TH1F*)compv0->fRes->Clone();
408   compv0->DrawXY("MC.fMotherP.P()","1000*(PhiMC-PhiIts)",cut,"RC.fRecStatus==1",5,pmin,pmax,-15,15,20);
409   TH1F * hdp1 = (TH1F*)compv0->fRes->Clone();
410   compv0->DrawXY("MC.fMotherP.P()","1000*(PhiMC-PhiTpc)",cut,"RC.fRecStatus==1",5,pmin,pmax,-15,15,20);
411   TH1F * hdp2 = (TH1F*)compv0->fRes->Clone();
412   hdp0->SetXTitle("P(GeV)");
413   hdp0->SetYTitle("d#varphi(mrad)");
414   hdp0->SetMarkerStyle(26);
415   hdp1->SetMarkerStyle(27);
416   hdp2->SetMarkerStyle(28);  
417   hdp0->Draw();
418   hdp1->Draw("same");
419   hdp2->Draw("same");
420   //
421   TLegend *legend = new TLegend(0.2,0.15,0.55,0.3, "#varphi resolution");
422   legend->SetBorderSize(1);
423   legend->AddEntry(hdp0,"Combined V0 finder");
424   legend->AddEntry(hdp1,"ESD V0 finder");
425   legend->AddEntry(hdp2,"TPC V0 finder");
426   //
427   legend->Draw();
428   return hdp0;
429 }
430
431 //
432 //-----------------------------------------------------------------------------------------------------
433 TH1F * EffR(AliESDComparisonDraw* compv0, TCut cut, Float_t minr=0.8, Float_t maxr=30, Int_t ndiv=10){  
434   //
435   // make efficiency plots
436   //  
437   compv0->Eff("MC.fMCR",cut,"RC.fV0Status==3",ndiv,minr,maxr);
438   TH1F * heff0 = (TH1F*)compv0->fRes->Clone();  
439   compv0->Eff("MC.fMCR",cut,"RC.fRecStatus==1",ndiv,minr,maxr);
440   TH1F * heff1 = (TH1F*)compv0->fRes->Clone();  
441   compv0->Eff("MC.fMCR",cut,"RC.fRecStatus==1&&CLow1",ndiv,minr,maxr);
442   TH1F * heff2 = (TH1F*)compv0->fRes->Clone();  
443   compv0->Eff("MC.fMCR",cut,"RC.fRecStatus==1&&CHigh",ndiv,minr,maxr);
444   TH1F * heff3 = (TH1F*)compv0->fRes->Clone();   
445   heff0->SetXTitle("Decay radii (cm)");
446   heff0->SetMarkerStyle(25);
447   heff1->SetMarkerStyle(26);
448   heff2->SetMarkerStyle(27);
449   heff3->SetMarkerStyle(28);
450   heff0->Draw(); heff1->Draw("same");heff2->Draw("same");heff3->Draw("same");
451   TLegend *legend = new TLegend(0.2,0.15,0.55,0.3, "Efficiency");
452   legend->SetBorderSize(1);
453   legend->AddEntry(heff0,"Efficiency to find both decay product");
454   legend->AddEntry(heff1,"After rough cuts during tracking");
455   legend->AddEntry(heff2,"After resolution cuts");
456   legend->AddEntry(heff3,"After resolution and causality cuts");
457   //
458   legend->Draw();
459   return heff3;
460 }
461
462 //
463 //-----------------------------------------------------------------------------------------------------
464 TH1F * EffPt(AliESDComparisonDraw* compv0, TCut cut, Float_t min=0.5, Float_t max=1., Int_t ndiv=10){  
465   //
466   // make efficiency plots
467   //  
468   compv0->Eff("MC.fMotherP.Pt()",cut,"RC.fV0Status==3",ndiv,min,max);
469   TH1F * heff0 = (TH1F*)compv0->fRes->Clone();  
470   compv0->Eff("MC.fMotherP.Pt()",cut,"RC.fRecStatus==1",ndiv,min,max);
471   TH1F * heff1 = (TH1F*)compv0->fRes->Clone();  
472   compv0->Eff("MC.fMotherP.Pt()",cut,"RC.fRecStatus==1&&CLow1",ndiv,min,max);
473   TH1F * heff2 = (TH1F*)compv0->fRes->Clone();  
474   compv0->Eff("MC.fMotherP.Pt()",cut,"RC.fRecStatus==1&&CHigh",ndiv,min,max);
475   TH1F * heff3 = (TH1F*)compv0->fRes->Clone();   
476   heff0->SetXTitle("Pt(GeV)");
477   heff0->SetMarkerStyle(25);
478   heff1->SetMarkerStyle(26);
479   heff2->SetMarkerStyle(27);
480   heff3->SetMarkerStyle(28);
481   heff0->Draw(); heff1->Draw("same");heff2->Draw("same");heff3->Draw("same");
482   TLegend *legend = new TLegend(0.2,0.15,0.55,0.3, "Efficiency");
483   legend->SetBorderSize(1);
484   legend->AddEntry(heff0,"Efficiency to find both decay product");
485   legend->AddEntry(heff1,"After rough cuts during tracking");
486   legend->AddEntry(heff2,"After resolution cuts");
487   legend->AddEntry(heff3,"After resolution and causality cuts");
488   //
489   legend->Draw();
490   return heff3;
491 }
492
493 //
494 //-----------------------------------------------------------------------------------------------------
495 TH1F * EffMinPt(AliESDComparisonDraw* compv0, TCut cut, Float_t min=0.5, Float_t max=1., Int_t ndiv=10){  
496   //
497   // make efficiency plots
498   //  
499   compv0->Eff("min(MC.fMCm.fParticle.Pt(),MC.fMCd.fParticle.Pt())",cut,"RC.fV0Status==3",ndiv,min,max);
500   TH1F * heff0 = (TH1F*)compv0->fRes->Clone();  
501   compv0->Eff("min(MC.fMCm.fParticle.Pt(),MC.fMCd.fParticle.Pt())",cut,"RC.fRecStatus==1",ndiv,min,max);
502   TH1F * heff1 = (TH1F*)compv0->fRes->Clone();  
503   compv0->Eff("min(MC.fMCm.fParticle.Pt(),MC.fMCd.fParticle.Pt())",cut,"RC.fRecStatus==1&&CLow1",ndiv,min,max);
504   TH1F * heff2 = (TH1F*)compv0->fRes->Clone();  
505   compv0->Eff("min(MC.fMCm.fParticle.Pt(),MC.fMCd.fParticle.Pt())",cut,"RC.fRecStatus==1&&CHigh",ndiv,min,max);
506   TH1F * heff3 = (TH1F*)compv0->fRes->Clone();   
507   heff0->SetXTitle("Pt(GeV)");
508   heff0->SetMarkerStyle(25);
509   heff1->SetMarkerStyle(26);
510   heff2->SetMarkerStyle(27);
511   heff3->SetMarkerStyle(28);
512   heff0->Draw(); heff1->Draw("same");heff2->Draw("same");heff3->Draw("same");
513   TLegend *legend = new TLegend(0.2,0.15,0.55,0.3, "Efficiency");
514   legend->SetBorderSize(1);
515   legend->AddEntry(heff0,"Efficiency to find both decay product");
516   legend->AddEntry(heff1,"After rough cuts during tracking");
517   legend->AddEntry(heff2,"After resolution cuts");
518   legend->AddEntry(heff3,"After resolution and causality cuts");
519   //
520   legend->Draw();
521   return heff3;
522 }
523
524
525 TH1F * GetCumulative(AliESDComparisonDraw* compv0, char * var0,TCut cut = "RC.fRecStatus==1", Float_t min=0, Float_t max=30, Int_t ndiv=20)
526 {
527   //
528   // Make cumulative function
529   //
530   TH1F his("his","his",ndiv,min,max);
531   char var[1000];
532   sprintf(var,"%s>>his",var0);
533   compv0->fTree->Draw(var,cut);
534   TH1F *hcumul = new TH1F("hcumul","hcumul",ndiv,min,max);
535   Float_t all = (Float_t)his.GetSum();
536   {
537     for (Int_t i=0;i<=ndiv;i++){
538       hcumul->SetBinContent(i,his.Integral(0,i)/all);
539     }
540   }
541   hcumul->SetFillColor(0);
542   hcumul->SetXTitle("Threshold (unit)");
543   hcumul->SetYTitle("Cumulative function");
544   hcumul->Draw();
545   return hcumul;
546 }
547
548 TH1F * CompareLikeCumulative(AliESDComparisonDraw* compv0,TCut cut = "RC.fRecStatus==1", Float_t min=0, Float_t max=30, Int_t ndiv=20)
549 {
550   //
551   //
552   //
553   TH1F * h0 = GetCumulative(compv0,"-log(LikeAP*LikeD*LCausal)",cut,min,max,ndiv);
554   TH1F * h1 = GetCumulative(compv0,"-log(LikeAP1*LikeD1*LCausal)",cut,min,max,ndiv);
555   TH1F * h3 = GetCumulative(compv0,"-log(LikeAP3*LikeD3*LCausal)",cut,min,max,ndiv);
556   h0->SetXTitle("Threshold (unit)");
557   h0->SetMaximum(1.1);
558   h0->SetLineColor(1); h0->SetLineStyle(1);
559   h1->SetLineColor(2); h1->SetLineStyle(2);
560   h3->SetLineColor(3); h3->SetLineStyle(3);
561   h0->Draw();
562   h1->Draw("same");
563   h3->Draw("same");
564   TLegend *legend = new TLegend(0.4,0.12,0.88,0.5, "Cumulative as function of threshold");
565   legend->SetBorderSize(1);
566   legend->AddEntry(h0,"Likelihhod (P0 parameterization) with three components");
567   legend->AddEntry(h1,"Likelihood (P1 parameterization) with one component");
568   legend->AddEntry(h3,"Likelihood (P0 parameterization) with one component");
569   //
570   legend->Draw();
571   return h0;
572 }
573
574
575 TH1F * CompareLikeCumulative2(AliESDComparisonDraw* compv0,TCut cut = "RC.fRecStatus==1", Float_t min=0, Float_t max=30, Int_t ndiv=20)
576 {
577   //
578   //
579   //
580   TH1F * h0 = GetCumulative(compv0,"-log(LikeAP*LikeD*LCausal)",cut,min,max,ndiv);
581   TH1F * h1 = GetCumulative(compv0,"-log(LikeAP1*LikeD1*LCausal)",cut,min,max,ndiv);
582   TH1F * h3 = GetCumulative(compv0,"-log(LikeAP3*LikeD3*LCausal)",cut,min,max,ndiv);
583   TH1F * h4 = GetCumulative(compv0,"-log(RC.fV0rec.GetLikelihoodC(0,0)*RC.fV0rec.GetLikelihoodAP(2,2)*RC.fV0rec.GetLikelihoodD(2,2))",cut,min,max,ndiv);
584   h0->SetXTitle("Threshold (unit)");
585   h0->SetMaximum(1.1);
586   h0->SetLineColor(1); h0->SetLineStyle(1);
587   h1->SetLineColor(2); h1->SetLineStyle(2);
588   h3->SetLineColor(3); h3->SetLineStyle(3);
589   h4->SetLineColor(4); h4->SetLineStyle(4);
590
591   h0->Draw();
592   h1->Draw("same");
593   h3->Draw("same");
594   h4->Draw("same");
595   TLegend *legend = new TLegend(0.4,0.12,0.88,0.5, "Cumulative as function of threshold");
596   legend->SetBorderSize(1);
597   legend->AddEntry(h0,"Likelihhod (P0 parameterization) with three components");
598   legend->AddEntry(h1,"Likelihood (P1 parameterization) with one component");
599   legend->AddEntry(h3,"Likelihood (P0 parameterization) with one component");
600   legend->AddEntry(h4,"Likelihood default");
601   //
602   legend->Draw();
603   return h0;
604 }
605
606
607
608 TH1F * CompareCumulativeSec(AliESDComparisonDraw* compv0, Float_t min=0, Float_t max=30, Int_t ndiv=20)
609 {
610   //
611   //
612   //
613   // Float_t min=0; Float_t max=20; Int_t ndiv=1000;
614   TH1F * hks0 = GetCumulative(&compv0,"abs(RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))","RC.fV0Status==3&&MC.fMCR>0.5"+cint+cks0,min,max,ndiv);
615   TH1F * hks1 = GetCumulative(&compv0,"sqrt((RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))**2+((RC.fT1.fITStrack.fP1-MC.fMotherP.fVz)/sqrt(RC.fT1.fITStrack.fC11))**2)","RC.fV0Status==3&&MC.fMCR>0.5"+cint+cks0,min,max,ndiv);
616
617   TH1F * hlam0 = GetCumulative(&compv0,"abs(RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))","RC.fV0Status==3&&MC.fMCR>0.5"+cint+clam,min,max,ndiv);
618   TH1F * hlam1 = GetCumulative(&compv0,"sqrt((RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))**2+((RC.fT1.fITStrack.fP1-MC.fMotherP.fVz)/sqrt(RC.fT1.fITStrack.fC11))**2)","RC.fV0Status==3&&MC.fMCR>0.5"+cint+clam,min,max,ndiv);
619   
620   TH1F * hgamma0 = GetCumulative(&compv0,"abs(RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))","RC.fV0Status==3&&MC.fMCR>0.5"+cint+cgamma,min,max,ndiv);
621   TH1F * hgamma1 = GetCumulative(&compv0,"sqrt((RC.fT1.fITStrack.fP0/sqrt(RC.fT1.fITStrack.fC00))**2+((RC.fT1.fITStrack.fP1-MC.fMotherP.fVz)/sqrt(RC.fT1.fITStrack.fC11))**2)","RC.fV0Status==3&&MC.fMCR>0.5"+cint+cgamma,min,max,ndiv);
622   
623   hks0->SetXTitle("Threshold (sigma)");
624   hks0->SetYTitle("Cumulative probability");
625   hks0->SetMaximum(0.8);
626   hks0->SetLineColor(1); hks0->SetLineStyle(1); hks0->SetLineWidth(1)
627   hks1->SetLineColor(1); hks1->SetLineStyle(2); hks1->SetLineWidth(2);
628   hlam0->SetLineColor(1); hlam0->SetLineStyle(3); hlam0->SetLineWidth(1);
629   hlam1->SetLineColor(1); hlam1->SetLineStyle(4); hlam1->SetLineWidth(2)
630   hgamma0->SetLineColor(1); hgamma0->SetLineStyle(5); hgamma0->SetLineWidth(1);
631   hgamma1->SetLineColor(1); hgamma1->SetLineStyle(6);hgamma1->SetLineWidth(2);
632
633   hks0->Draw();
634   hks1->Draw("same");
635   hlam0->Draw("same");
636   hlam1->Draw("same");
637   hgamma0->Draw("same");
638   hgamma1->Draw("same");
639
640   TLegend *legend = new TLegend(0.4,0.12,0.88,0.5, "Cumulative probability");
641   legend->SetBorderSize(1);
642   legend->AddEntry(hks0,"K^{0}_{s} decay - normalized DCA in r#varphi");
643   legend->AddEntry(hks1,"K^{0}_{s} decay - normalized DCA 3D");
644   legend->AddEntry(hlam0,"#Lambda decay - normalized DCA in r#varphi");
645   legend->AddEntry(hlam1,"#Lambda decay - normalized DCA 3D");
646   legend->AddEntry(hgamma0,"#gamma conversion - normalized DCA in r#varphi");
647   legend->AddEntry(hgamma1,"#gamma conversion - normalized DCA 3D");
648   //
649   legend->Draw();
650   return h0;
651 }
652
653
654
655