1 /**************************************************************************
2 * Author: Panos Christakoglou. *
3 * Contributors are mentioned in the code where appropriate. *
5 * Permission to use, copy, modify and distribute this software and its *
6 * documentation strictly for non-commercial purposes is hereby granted *
7 * without fee, provided that the above copyright notice appears in all *
8 * copies and that both the copyright notice and this permission notice *
9 * appear in the supporting documentation. The authors make no claims *
10 * about the suitability of this software for any purpose. It is *
11 * provided "as is" without express or implied warranty. *
12 **************************************************************************/
16 //-----------------------------------------------------------------
17 // Balance Function class
18 // This is the class to deal with the Balance Function analysis
19 // Origin: Panos Christakoglou, UOA-CERN, Panos.Christakoglou@cern.ch
20 //-----------------------------------------------------------------
26 #include <Riostream.h>
32 #include <TLorentzVector.h>
34 #include "AliBalance.h"
38 //----------------------------------------//
39 AliBalance::AliBalance()
41 for(Int_t i = 0; i < MAXIMUM_NUMBER_OF_STEPS; i++)
60 //----------------------------------------//
61 AliBalance::AliBalance(Double_t P2_Start, Double_t P2_Stop, Int_t P2_bins)
63 this->fP2_Start = P2_Start;
64 this->fP2_Stop = P2_Stop;
65 this->fNumberOfBins = P2_bins;
66 this->fP2_Step = fabs(fP2_Start - fP2_Stop) / (Double_t)fNumberOfBins;
69 //----------------------------------------//
70 AliBalance::~AliBalance()
74 //----------------------------------------//
75 void AliBalance::SetNumberOfBins(Int_t ibins)
77 this->fNumberOfBins = ibins ;
80 //----------------------------------------//
81 void AliBalance::SetInterval(Double_t P2_Start, Double_t P2_Stop)
83 this->fP2_Start = P2_Start;
84 this->fP2_Stop = P2_Stop;
85 this->fP2_Step = fabs(P2_Start - P2_Stop) / (Double_t)fNumberOfBins;
88 //----------------------------------------//
89 void AliBalance::SetAnalysisType(Int_t iType)
91 //0:y - 1:eta - 2:Qlong - 3:Qout - 4:Qside - 5:Qinv - 6:phi
92 this->fAnalysisType = iType;
95 cout<<" ====================== "<<endl;
96 cout<<"||Analysis selected: y||"<<endl;
97 cout<<" ====================== "<<endl;
99 else if(fAnalysisType==1)
101 cout<<" ======================== "<<endl;
102 cout<<"||Analysis selected: eta||"<<endl;
103 cout<<" ======================== "<<endl;
105 else if(fAnalysisType==2)
107 cout<<" ========================== "<<endl;
108 cout<<"||Analysis selected: Qlong||"<<endl;
109 cout<<" ========================== "<<endl;
111 else if(fAnalysisType==3)
113 cout<<" ========================= "<<endl;
114 cout<<"||Analysis selected: Qout||"<<endl;
115 cout<<" ========================= "<<endl;
117 else if(fAnalysisType==4)
119 cout<<" ========================== "<<endl;
120 cout<<"||Analysis selected: Qside||"<<endl;
121 cout<<" ========================== "<<endl;
123 else if(fAnalysisType==5)
125 cout<<" ========================= "<<endl;
126 cout<<"||Analysis selected: Qinv||"<<endl;
127 cout<<" ========================= "<<endl;
129 else if(fAnalysisType==6)
131 cout<<" ======================== "<<endl;
132 cout<<"||Analysis selected: phi||"<<endl;
133 cout<<" ======================== "<<endl;
137 cout<<"Selection of analysis mode failed!!!"<<endl;
138 cout<<"Choices are: 0:y - 1:eta - 2:Qlong - 3:Qout - 4:Qside - 5:Qinv - 6:phi"<<endl;
143 //----------------------------------------//
144 void AliBalance::SetParticles(TLorentzVector *P, Double_t *charge, Int_t dim)
147 this->fCharge = charge;
152 //----------------------------------------//
153 void AliBalance::CalculateBalance()
159 for(i = 0; i < fNtrack; i++)
167 //0:y - 1:eta - 2:Qlong - 3:Qout - 4:Qside - 5:Qinv - 6:phi
170 for(i = 1; i < fNtrack; i++)
172 for(j = 0; j < i; j++)
174 Double_t rap1 = 0.5*log((fV[i].E() - fV[i].Pz())/(fV[i].E() + fV[i].Pz()));
175 Double_t rap2 = 0.5*log((fV[j].E() - fV[j].Pz())/(fV[j].E() + fV[j].Pz()));
176 Double_t dy = TMath::Abs(rap1 - rap2);
177 ibin = Int_t(dy/fP2_Step);
178 if((fCharge[i] > 0)&&(fCharge[j] > 0))
180 if((fCharge[i] < 0)&&(fCharge[j] < 0))
182 if((fCharge[i] > 0)&&(fCharge[j] < 0))
184 if((fCharge[i] < 0)&&(fCharge[j] > 0))
191 for(i = 1; i < fNtrack; i++)
193 for(j = 0; j < i; j++)
195 Double_t P1 = sqrt(pow(fV[i].Px(),2) + pow(fV[i].Py(),2) + pow(fV[i].Pz(),2));
196 Double_t P2 = sqrt(pow(fV[j].Px(),2) + pow(fV[j].Py(),2) + pow(fV[j].Pz(),2));
197 Double_t eta1 = 0.5*log((P1 - fV[i].Pz())/(P1 + fV[i].Pz()));
198 Double_t eta2 = 0.5*log((P2 - fV[j].Pz())/(P2 + fV[j].Pz()));
199 Double_t deta = TMath::Abs(eta1 - eta2);
200 ibin = Int_t(deta/fP2_Step);
201 if((fCharge[i] > 0)&&(fCharge[j] > 0))
203 if((fCharge[i] < 0)&&(fCharge[j] < 0))
205 if((fCharge[i] > 0)&&(fCharge[j] < 0))
207 if((fCharge[i] < 0)&&(fCharge[j] > 0))
214 for(i = 1; i < fNtrack; i++)
216 for(j = 0; j < i; j++)
218 Double_t ETot = fV[i].E() + fV[j].E();
219 Double_t PxTot = fV[i].Px() + fV[j].Px();
220 Double_t PyTot = fV[i].Py() + fV[j].Py();
221 Double_t PzTot = fV[i].Pz() + fV[j].Pz();
222 Double_t Q0Tot = fV[i].E() - fV[j].E();
223 Double_t QzTot = fV[i].Pz() - fV[j].Pz();
224 Double_t Snn = pow(ETot,2) - pow(PxTot,2) - pow(PyTot,2) - pow(PzTot,2);
225 Double_t PtTot = sqrt( pow(PxTot,2) + pow(PyTot,2));
226 Double_t Qlong = TMath::Abs(ETot*QzTot - PzTot*Q0Tot)/sqrt(Snn + pow(PtTot,2));
227 ibin = Int_t(Qlong/fP2_Step);
229 if((fCharge[i] > 0)&&(fCharge[j] > 0))
231 if((fCharge[i] < 0)&&(fCharge[j] < 0))
233 if((fCharge[i] > 0)&&(fCharge[j] < 0))
235 if((fCharge[i] < 0)&&(fCharge[j] > 0))
242 for(i = 1; i < fNtrack; i++)
244 for(j = 0; j < i; j++)
246 Double_t ETot = fV[i].E() + fV[j].E();
247 Double_t PxTot = fV[i].Px() + fV[j].Px();
248 Double_t PyTot = fV[i].Py() + fV[j].Py();
249 Double_t PzTot = fV[i].Pz() + fV[j].Pz();
250 Double_t QxTot = fV[i].Px() - fV[j].Px();
251 Double_t QyTot = fV[i].Py() - fV[j].Py();
252 Double_t Snn = pow(ETot,2) - pow(PxTot,2) - pow(PyTot,2) - pow(PzTot,2);
253 Double_t PtTot = sqrt( pow(PxTot,2) + pow(PyTot,2));
254 Double_t Qout = sqrt(Snn/(Snn + pow(PtTot,2))) * TMath::Abs(PxTot*QxTot + PyTot*QyTot)/PtTot;
255 ibin = Int_t(Qout/fP2_Step);
257 if((fCharge[i] > 0)&&(fCharge[j] > 0))
259 if((fCharge[i] < 0)&&(fCharge[j] < 0))
261 if((fCharge[i] > 0)&&(fCharge[j] < 0))
263 if((fCharge[i] < 0)&&(fCharge[j] > 0))
270 for(i = 1; i < fNtrack; i++)
272 for(j = 0; j < i; j++)
274 Double_t PxTot = fV[i].Px() + fV[j].Px();
275 Double_t PyTot = fV[i].Py() + fV[j].Py();
276 Double_t QxTot = fV[i].Px() - fV[j].Px();
277 Double_t QyTot = fV[i].Py() - fV[j].Py();
278 Double_t PtTot = sqrt( pow(PxTot,2) + pow(PyTot,2));
279 Double_t Qside = TMath::Abs(PxTot*QyTot - PyTot*QxTot)/PtTot;
280 ibin = Int_t(Qside/fP2_Step);
282 if((fCharge[i] > 0)&&(fCharge[j] > 0))
284 if((fCharge[i] < 0)&&(fCharge[j] < 0))
286 if((fCharge[i] > 0)&&(fCharge[j] < 0))
288 if((fCharge[i] < 0)&&(fCharge[j] > 0))
295 for(i = 1; i < fNtrack; i++)
297 for(j = 0; j < i; j++)
299 Double_t Q0Tot = fV[i].E() - fV[j].E();
300 Double_t QxTot = fV[i].Px() - fV[j].Px();
301 Double_t QyTot = fV[i].Py() - fV[j].Py();
302 Double_t QzTot = fV[i].Pz() - fV[j].Pz();
303 Double_t Qinv = sqrt(TMath::Abs(-pow(Q0Tot,2) +pow(QxTot,2) +pow(QyTot,2) +pow(QzTot,2)));
304 ibin = Int_t(Qinv/fP2_Step);
306 if((fCharge[i] > 0)&&(fCharge[j] > 0))
308 if((fCharge[i] < 0)&&(fCharge[j] < 0))
310 if((fCharge[i] > 0)&&(fCharge[j] < 0))
312 if((fCharge[i] < 0)&&(fCharge[j] > 0))
319 for(i = 1; i < fNtrack; i++)
321 for(j = 0; j < i; j++)
323 Double_t phi1 = TMath::ATan(fV[i].Py()/fV[i].Px())*180.0/TMath::Pi();
324 Double_t phi2 = TMath::ATan(fV[j].Py()/fV[j].Px())*180.0/TMath::Pi();
325 Double_t dphi = TMath::Abs(phi1 - phi2);
326 ibin = Int_t(dphi/fP2_Step);
327 if((fCharge[i] > 0)&&(fCharge[j] > 0))
329 if((fCharge[i] < 0)&&(fCharge[j] < 0))
331 if((fCharge[i] > 0)&&(fCharge[j] < 0))
333 if((fCharge[i] < 0)&&(fCharge[j] > 0))
340 //----------------------------------------//
341 Double_t AliBalance::GetBalance(Int_t p2)
343 fB[p2] = 0.5*(((fNpn[p2] - 2.0*fNnn[p2])/fNn) + ((fNpn[p2] - 2.0*fNpp[p2])/fNp))/fP2_Step;
348 //----------------------------------------//
349 Double_t AliBalance::GetError(Int_t p2)
351 ferror[p2] = sqrt( Double_t(fNpp[p2])/(Double_t(fNp)*Double_t(fNp)) + Double_t(fNnn[p2])/(Double_t(fNn)*Double_t(fNn)) + Double_t(fNpn[p2])*pow((0.5/Double_t(fNp) + 0.5/Double_t(fNn)),2))/fP2_Step;
356 //----------------------------------------//
357 void AliBalance::PrintResults()
359 Double_t x[MAXIMUM_NUMBER_OF_STEPS];
360 Double_t fSumXi = 0.0, fSumBi = 0.0, fSumBiXi = 0.0;
361 Double_t fSumBiXi2 = 0.0, fSumBi2Xi2 = 0.0;
362 Double_t fSumDeltaBi2 = 0.0, fSumXi2DeltaBi2 = 0.0;
363 Double_t delta_bal_P2 = 0.0, Integral = 0.0;
364 Double_t DeltaErrorNew = 0.0;
366 cout<<"=================================================="<<endl;
367 for(Int_t i = 0; i < fNumberOfBins; i++)
369 x[i] = fP2_Start + fP2_Step*i + fP2_Step/2 ;
370 cout<<"B: "<<fB[i]<<"\t Error: "<<ferror[i]<<"\t bin: "<<x[i]<<endl;
372 cout<<"=================================================="<<endl;
373 for(Int_t i = 1; i < fNumberOfBins; i++)
377 fSumBiXi += fB[i]*x[i];
378 fSumBiXi2 += fB[i]*pow(x[i],2);
379 fSumBi2Xi2 += pow(fB[i],2)*pow(x[i],2);
380 fSumDeltaBi2 += pow(ferror[i],2) ;
381 fSumXi2DeltaBi2 += pow(x[i],2) * pow(ferror[i],2) ;
383 delta_bal_P2 += fP2_Step*pow(ferror[i],2) ;
384 Integral += fP2_Step*fB[i] ;
386 for(Int_t i = 1; i < fNumberOfBins; i++)
388 DeltaErrorNew += ferror[i]*(x[i]*fSumBi - fSumBiXi)/pow(fSumBi,2);
390 Double_t IntegralError = sqrt(delta_bal_P2) ;
392 Double_t Delta = fSumBiXi / fSumBi ;
393 Double_t DeltaError = (fSumBiXi / fSumBi) * sqrt(pow((sqrt(fSumXi2DeltaBi2)/fSumBiXi),2) + pow((fSumDeltaBi2/fSumBi),2) ) ;
395 cout<<"Analyzed events: "<<fAnalyzedEvents<<endl;
396 cout<<"Width: "<<Delta<<"\t Error: "<<DeltaError<<endl;
397 cout<<"New error: "<<DeltaErrorNew<<endl;
398 cout<<"Interval: "<<Integral<<"\t Error: "<<IntegralError<<endl;
399 cout<<"=================================================="<<endl;