11 #include "AliITSgeom.h"
12 #include "AliITSRecPoint.h"
13 #include "AliGenerator.h"
19 #include <AliITSVertex.h>
20 #include <TObjArray.h>
24 ClassImp(AliITSVertex)
26 ////////////////////////////////////////////////////////////////////////
27 // AliITSVertex is a class for primary vertex finding.
30 // Written by Giuseppe Lo Re and Francesco Riggi
31 // Giuseppe.Lore@ct.infn.it
32 // Franco.Riggi@ct.infn.it
36 ///////////////////////////////////////////////////////////////////////
39 //______________________________________________________________________________
41 AliITSVertex::AliITSVertex() {
43 fPosition = new Double_t[3];
44 fResolution = new Double_t[3];
45 fSNR = new Double_t[3];
47 AliITS* aliits =(AliITS *)gAlice->GetDetector("ITS");
48 AliITSgeom *g2 = ((AliITS*)aliits)->GetITSgeom();
50 TClonesArray *recpoints = aliits->RecPoints();
59 //------------Rough Vertex------------------------------------------------------
61 Int_t i,npoints,ipoint,j,k;
65 TH1F *hITSx1pos = new TH1F("hITSx1pos","",100,0.,4.2);
66 TH1F *hITSx1neg = new TH1F("hITSx1neg","",100,-4.2,0.);
67 TH1F *hITSy1pos = new TH1F("hITSy1pos","",100,0.,4.2);
68 TH1F *hITSy1neg = new TH1F("hITSy1neg","",100,-4.2,0.);
69 TH1F *hITSz1 = new TH1F("hITSz1","",100,-14.35,14.35);
71 for(i=g2->GetStartSPD();i<=g2->GetLastSPD();i++)
73 aliits->ResetRecPoints();
74 gAlice->TreeR()->GetEvent(i);
76 npoints = recpoints->GetEntries();
77 for (ipoint=0;ipoint<npoints;ipoint++) {
78 pnt = (AliITSRecPoint*)recpoints->UncheckedAt(ipoint);
83 if(i<80 && TMath::Abs(p[2])<14.35) {
84 if(p[0]>0) hITSx1pos->Fill(p[0]);
85 if(p[0]<0) hITSx1neg->Fill(p[0]);
86 if(p[1]>0) hITSy1pos->Fill(p[1]);
87 if(p[1]<0) hITSy1neg->Fill(p[1]);
90 if(i>=80 && TMath::Abs(p[2])<14.35) (NoPoints2)++;
94 NoPoints1 = (Int_t)(hITSz1->GetEntries());
96 Double_t mxpiu = hITSx1pos->GetEntries();
97 Double_t mxmeno = hITSx1neg->GetEntries();
98 Double_t mypiu = hITSy1pos->GetEntries();
99 Double_t mymeno = hITSy1neg->GetEntries();
101 AsPar[0] = (mxpiu-mxmeno)/(mxpiu+mxmeno);
102 AsPar[1] = (mypiu-mymeno)/(mypiu+mymeno);
104 Vzero[0] = 5.24434*AsPar[0];
105 Vzero[1] = 5.24434*AsPar[1];
107 ZCentroid= TMath::Abs(hITSz1->GetMean());
108 Vzero[2] = -5.31040e-02+1.42198*ZCentroid+7.44718e-01*TMath::Power(ZCentroid,2)
109 -5.73426e-01*TMath::Power(ZCentroid,3)+2.01500e-01*TMath::Power(ZCentroid,4)
110 -3.34118e-02*TMath::Power(ZCentroid,5)+2.20816e-03*TMath::Power(ZCentroid,6);
112 if(hITSz1->GetMean()<0) Vzero[2] = -Vzero[2];
114 //cout << "\nCentroid and RMS of hIITSz1: \n";
115 //cout << hITSz1->GetMean() << " " << hITSz1->GetRMS() <<endl;
116 //cout << "\nAsPar[0]: " << AsPar[0];
117 //cout << "\nAsPar[1]: " << AsPar[1];
118 //cout << "\nAsPar[2]: " << AsPar[2];
119 cout << "\nXvzero: " << Vzero[0] << " cm" << "";
120 cout << "\nYvzero: " << Vzero[1] << " cm" << "";
121 cout << "\nZvzero: " << Vzero[2] << " cm" << "\n";
129 //-----------------------Get points---------------------------------------------
131 Double_t dphi,DeltaPhi,DeltaZ,r;
135 Double_t *Z1, *Z2, *Y1, *Y2, *X1, *X2, *phi1, *phi2, *r1, *r2;
136 Z1=new Double_t[NoPoints1];
137 Z2=new Double_t[NoPoints2];
138 Y1=new Double_t[NoPoints1];
139 Y2=new Double_t[NoPoints2];
140 X1=new Double_t[NoPoints1];
141 X2=new Double_t[NoPoints2];
142 phi1=new Double_t[NoPoints1];
143 phi2=new Double_t[NoPoints2];
144 r1=new Double_t[NoPoints1];
145 r2=new Double_t[NoPoints2];
147 for(i=g2->GetStartSPD();i<=g2->GetLastSPD();i++)
149 aliits->ResetRecPoints();
150 gAlice->TreeR()->GetEvent(i);
151 npoints = recpoints->GetEntries();
152 for (ipoint=0;ipoint<npoints;ipoint++) {
154 //if(rnd.Integer(10)>2) continue;
155 pnt = (AliITSRecPoint*)recpoints->UncheckedAt(ipoint);
162 r=TMath::Sqrt(TMath::Power(p[0],2)+TMath::Power(p[1],2));
164 if(i<80 && TMath::Abs(p[2])<14.35) {
169 phi1[np1]=PhiFunc(p);
173 if(i>=80 && TMath::Abs(p[2])<14.35) {
178 phi2[np2]=PhiFunc(p);
185 //-------------------Correlations-----------------------------------------------
187 //cout << "\nPoints number on the first and second layer: "<<np1<<" "<<np2<<endl;
189 DeltaPhi = 0.085-0.1*TMath::Sqrt(Vzero[0]*Vzero[0]+Vzero[1]*Vzero[1]);
191 cout << "\nThe algorith can't find the vertex. " << endl;
197 for(Int_t okm=0;okm<3;okm++) origin[okm]=0;
198 gAlice->Field()->Field(origin,B);
200 DeltaPhi = DeltaPhi*B[2]/2;
202 cout << "\nDeltaPhi: " << DeltaPhi << " deg" << "\n";
205 0.2+2.91617e-01+2.67567e-02*Vzero[2]+1.49626e-02*TMath::Power(Vzero[2],2);
207 cout << "DeltaZeta: " << DeltaZ << " cm" << "\n";
209 TH1F *hITSZv = new TH1F("hITSZv","",DeltaZ/0.005,Vzero[2]-DeltaZ,Vzero[2]+DeltaZ);
211 for(j=0; j<(np2)-1; j++) {
212 for(k=0; k<(np1)-1; k++) {
213 if(TMath::Abs(Z1[k]-Z2[j])>13.) continue;
214 dphi=TMath::Abs(phi1[k]-phi2[j]);
215 if(dphi>180) dphi = 360-dphi;
217 if(TMath::Abs((Z1[k]-(Z2[j]-Z1[k])/((r2[j]/r1[k])-1))-Vzero[2])<DeltaZ)
218 hITSZv->Fill(Z1[k]-(Z2[j]-Z1[k])/((r2[j]/r1[k])-1));
225 cout << "\nNumber of used pairs: \n";
226 cout << hITSZv->GetEntries() << '\n' << '\n';
227 cout << "\nCentroid and RMS of hIITSZv: \n";
228 cout << hITSZv->GetMean() << " " << hITSZv->GetRMS() << "\n"<< "\n";
241 Double_t a = Vzero[2]-DeltaZ;
242 Double_t b = Vzero[2]+DeltaZ;
244 TF1 *f4 = new TF1 ("f4","([0]*exp(-0.5*((x-[1])/[2])*((x-[1])/[2])))+[3]",a,b);
245 f4->SetParameter(0,700.);
246 f4->SetParameter(1,Vzero[2]);
247 f4->SetParameter(2,0.05); // !!
248 f4->SetParameter(3,50.);
250 hITSZv->Fit("f4","RME0");
254 fSNR[2] = f4->GetParameter(0)/f4->GetParameter(3);
256 cout << "\nSignal to noise ratio too small!!!" << endl;
257 cout << "The algorithm can't find the z vertex position." << endl;
262 fPosition[2] = (f4->GetParameter(1));
265 fPosition[2]=fPosition[2]-TMath::Abs(fPosition[2])*1.11/10000;
269 fPosition[2]=fPosition[2]+TMath::Abs(fPosition[2])*1.11/10000;
272 fResolution[2] = f4->GetParError(1);
274 AliGenerator *gener = gAlice->Generator();
276 gener->GetOrigin(Vx,Vy,Vz);
278 fPosition[0]=(Double_t)Vx;
279 fPosition[1]=(Double_t)Vy;
290 //______________________________________________________________________________
292 AliITSVertex::~AliITSVertex() {
294 delete [] fResolution;
298 //______________________________________________________________________________
301 Double_t AliITSVertex::PhiFunc(Float_t p[]) {
303 if(p[1]>0 && p[0]>0) phi=(TMath::ATan((Double_t)(p[1]/p[0]))*57.29578);
304 if(p[1]>0 && p[0]<0) phi=(TMath::ATan((Double_t)(p[1]/p[0]))*57.29578)+180;
305 if(p[1]<0 && p[0]<0) phi=(TMath::ATan((Double_t)(p[1]/p[0]))*57.29578)+180;
306 if(p[1]<0 && p[0]>0) phi=(TMath::ATan((Double_t)(p[1]/p[0]))*57.29578)+360;
310 //______________________________________________________________________________