]>
Commit | Line | Data |
---|---|---|
dd36288a | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
4aa41877 | 15 | #include "AliHLTITSVertexerZ.h" |
dd36288a | 16 | #include<TString.h> |
17 | #include<TH1.h> | |
18 | #include<TMath.h> | |
19 | #include <AliRun.h> | |
20 | #include <AliITS.h> | |
21 | #include "AliITSLoader.h" | |
22 | #include <AliITSgeom.h> | |
23 | #include <AliITSRecPoint.h> | |
3136129d | 24 | #include <AliITSclusterV2.h> |
dd36288a | 25 | |
26 | //------------------------------------------------------------------------- | |
27 | // Implementation of the HLT ITS vertexer class | |
28 | // | |
29 | // Origin: Cvetan Cheshkov, CERN, Cvetan.Cheshkov@cern.ch | |
30 | //------------------------------------------------------------------------- | |
31 | ||
4aa41877 | 32 | ClassImp(AliHLTITSVertexerZ) |
dd36288a | 33 | |
8b40a6b8 | 34 | AliHLTITSVertexerZ::AliHLTITSVertexerZ(): |
35 | AliITSVertexerZ(), | |
36 | fZCombf(0), | |
37 | fStepFine(0) | |
38 | { | |
3136129d | 39 | // Constructor in case that there is no runloader |
3136129d | 40 | SetBinWidthFine(); |
3136129d | 41 | } |
42 | ||
8b40a6b8 | 43 | AliHLTITSVertexerZ::AliHLTITSVertexerZ(TString filename,Float_t x0, Float_t y0): |
44 | AliITSVertexerZ(filename,x0,y0), | |
45 | fZCombf(0), | |
46 | fStepFine(0) | |
dd36288a | 47 | { |
48 | // Standard Constructor | |
8b40a6b8 | 49 | SetBinWidthFine(); |
50 | } | |
51 | ||
52 | AliHLTITSVertexerZ::~AliHLTITSVertexerZ() | |
53 | { | |
54 | // Destructor | |
55 | if (fZCombf) delete fZCombf; | |
dd36288a | 56 | } |
57 | ||
8b40a6b8 | 58 | //______________________________________________________________________ |
59 | AliHLTITSVertexerZ::AliHLTITSVertexerZ(const AliHLTITSVertexerZ &vtxr) : | |
60 | AliITSVertexerZ(vtxr), | |
61 | fZCombf(vtxr.fZCombf), | |
62 | fStepFine(vtxr.fStepFine) | |
63 | { | |
64 | // Copy constructor | |
65 | ||
66 | } | |
67 | ||
68 | //______________________________________________________________________ | |
69 | AliHLTITSVertexerZ& AliHLTITSVertexerZ::operator=(const AliHLTITSVertexerZ& vtxr ) | |
70 | { | |
71 | // Assignment operator | |
72 | this->~AliHLTITSVertexerZ(); | |
73 | new(this) AliHLTITSVertexerZ(vtxr); | |
74 | fZCombf = vtxr.fZCombf; | |
75 | fStepFine = vtxr.fStepFine; | |
76 | ||
77 | return *this; | |
78 | } | |
dd36288a | 79 | //______________________________________________________________________ |
4aa41877 | 80 | AliESDVertex* AliHLTITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ |
dd36288a | 81 | // Defines the AliESDVertex for the current event |
82 | ||
83 | fCurrentVertex = 0; | |
84 | AliRunLoader *rl =AliRunLoader::GetRunLoader(); | |
85 | AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader"); | |
86 | itsLoader->LoadRecPoints(); | |
87 | rl->GetEvent(evnumber); | |
88 | ||
7d62fb64 | 89 | /* if(!fITS) { |
dd36288a | 90 | fITS = (AliITS*)gAlice->GetModule("ITS"); |
91 | if(!fITS) { | |
92 | Error("FindVertexForCurrentEvent","AliITS object was not found"); | |
93 | return fCurrentVertex; | |
94 | } | |
95 | } | |
7d62fb64 | 96 | */ |
dd36288a | 97 | |
7d62fb64 | 98 | // fITS->SetTreeAddress(); |
99 | rl->CdGAFile(); | |
dd36288a | 100 | |
61436bc1 | 101 | AliITSgeom* geom=itsLoader->GetITSgeom(); |
dd36288a | 102 | TTree *tR = itsLoader->TreeR(); |
7d62fb64 | 103 | |
3136129d | 104 | return FindVertexForCurrentEvent(geom,tR); |
105 | } | |
106 | ||
107 | //______________________________________________________________________ | |
4aa41877 | 108 | AliESDVertex* AliHLTITSVertexerZ::FindVertexForCurrentEvent(AliITSgeom *geom,TTree *tR){ |
3136129d | 109 | // Defines the AliESDVertex for the current event |
110 | ||
111 | fCurrentVertex = 0; | |
112 | ||
dd36288a | 113 | Float_t lc[3]; for(Int_t ii=0; ii<3; ii++) lc[ii]=0.; |
114 | Float_t gc[3]; for(Int_t ii=0; ii<3; ii++) gc[ii]=0.; | |
115 | Float_t lc2[3]; for(Int_t ii=0; ii<3; ii++) lc2[ii]=0.; | |
116 | Float_t gc2[3]; for(Int_t ii=0; ii<3; ii++) gc2[ii]=0.; | |
117 | ||
dd36288a | 118 | TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy; |
119 | TBranch *branch; | |
3136129d | 120 | branch = tR->GetBranch("Clusters"); |
121 | branch->SetAddress(&clusters); | |
dd36288a | 122 | |
123 | Int_t nrpL1 = 0; | |
124 | Int_t nrpL2 = 0; | |
125 | for(Int_t module= fFirstL1; module<=fLastL1;module++){ | |
126 | if(module%4==0 || module%4==3)continue; | |
127 | // cout<<"Procesing module "<<module<<" "; | |
3136129d | 128 | tR->GetEvent(module); |
dd36288a | 129 | // cout<<"Number of clusters "<<clusters->GetEntries()<<endl; |
3136129d | 130 | nrpL1+= clusters->GetEntriesFast(); |
dd36288a | 131 | } |
132 | for(Int_t module= fFirstL2; module<=fLastL2;module++){ | |
3136129d | 133 | tR->GetEvent(module); |
134 | nrpL2+= clusters->GetEntriesFast(); | |
dd36288a | 135 | } |
136 | if(nrpL1 == 0 || nrpL2 == 0){ | |
137 | ResetHistograms(); | |
138 | return fCurrentVertex; | |
139 | } | |
140 | ||
141 | Int_t nPhiBins = (Int_t)(TMath::Pi()/fDiffPhiMax); | |
142 | Float_t phiBinSize = 2*TMath::Pi()/(Float_t)nPhiBins; | |
143 | ||
144 | Int_t maxind1 = 2*nrpL1/nPhiBins; | |
145 | Float_t **zc1 = new Float_t *[nPhiBins]; | |
146 | Float_t **phi1 = new Float_t *[nPhiBins]; | |
147 | Float_t **r1 = new Float_t *[nPhiBins]; | |
148 | Int_t *ind1 = new Int_t [nPhiBins]; | |
149 | Int_t maxind2 = 2*nrpL2/nPhiBins; | |
150 | Float_t **zc2 = new Float_t *[nPhiBins]; | |
151 | Float_t **phi2 = new Float_t *[nPhiBins]; | |
152 | Float_t **r2 = new Float_t *[nPhiBins]; | |
153 | Int_t *ind2 = new Int_t [nPhiBins]; | |
154 | for(Int_t i=0;i<nPhiBins;i++) { | |
155 | zc1[i] = new Float_t [maxind1]; | |
156 | phi1[i] = new Float_t [maxind1]; | |
157 | r1[i] = new Float_t [maxind1]; | |
158 | zc2[i] = new Float_t [maxind2]; | |
159 | phi2[i] = new Float_t [maxind2]; | |
160 | r2[i] = new Float_t [maxind2]; | |
161 | } | |
3136129d | 162 | |
163 | Float_t yshift = 0; | |
164 | Float_t zshift[4] = {-10.708000, -3.536000, 3.536000, 10.708000}; | |
dd36288a | 165 | |
3136129d | 166 | yshift = 0.248499; |
dd36288a | 167 | memset(ind1,0,nPhiBins*sizeof(Int_t)); |
168 | for(Int_t module= fFirstL1; module<=fLastL1;module++){ | |
169 | if(module%4==0 || module%4==3)continue; | |
3136129d | 170 | tR->GetEvent(module); |
171 | Int_t nrecp1 = clusters->GetEntriesFast(); | |
dd36288a | 172 | for(Int_t j=0;j<nrecp1;j++){ |
3136129d | 173 | AliITSclusterV2 *recp = (AliITSclusterV2*)clusters->UncheckedAt(j); |
174 | lc[0]=-recp->GetY()+yshift; | |
175 | lc[2]=-recp->GetZ()+zshift[module%4]; | |
dd36288a | 176 | geom->LtoG(module,lc,gc); |
177 | gc[0]-=fX0; | |
178 | gc[1]-=fY0; | |
179 | Float_t xc1,yc1; | |
180 | xc1=gc[0]; | |
181 | yc1=gc[1]; | |
182 | Float_t phi = TMath::ATan2(gc[1],gc[0]); | |
183 | if(phi<0)phi=2*TMath::Pi()+phi; | |
184 | Int_t bin = (Int_t)(phi/phiBinSize); | |
3136129d | 185 | if(bin>=nPhiBins || bin<0) bin = 0; |
dd36288a | 186 | Int_t ind = ind1[bin]; |
187 | if(ind<maxind1) { | |
188 | phi1[bin][ind] = phi; | |
189 | zc1[bin][ind]=gc[2]/fStepFine; | |
190 | r1[bin][ind]=sqrt(xc1*xc1+yc1*yc1); | |
191 | ind1[bin]++; | |
192 | } | |
193 | } | |
3136129d | 194 | clusters->Delete(); |
dd36288a | 195 | } |
3136129d | 196 | yshift = 3.096207; |
dd36288a | 197 | memset(ind2,0,nPhiBins*sizeof(Int_t)); |
198 | for(Int_t module= fFirstL2; module<=fLastL2;module++){ | |
3136129d | 199 | tR->GetEvent(module); |
200 | Int_t nrecp2 = clusters->GetEntriesFast(); | |
dd36288a | 201 | for(Int_t j=0;j<nrecp2;j++){ |
3136129d | 202 | AliITSclusterV2 *recp = (AliITSclusterV2*)clusters->UncheckedAt(j); |
203 | lc[0]=recp->GetY()+yshift; | |
204 | lc[2]=-recp->GetZ()+zshift[module%4]; | |
dd36288a | 205 | geom->LtoG(module,lc,gc); |
206 | gc[0]-=fX0; | |
207 | gc[1]-=fY0; | |
208 | Float_t xc2,yc2; | |
209 | xc2=gc[0]; | |
210 | yc2=gc[1]; | |
211 | Float_t phi = TMath::ATan2(gc[1],gc[0]); | |
212 | if(phi<0)phi=2*TMath::Pi()+phi; | |
213 | Int_t bin = (Int_t)(phi/phiBinSize+0.5); | |
3136129d | 214 | if(bin>=nPhiBins || bin<0) bin = 0; |
dd36288a | 215 | Int_t ind = ind2[bin]; |
216 | if(ind<maxind2) { | |
217 | phi2[bin][ind] = phi; | |
218 | zc2[bin][ind]=gc[2]/fStepFine; | |
219 | r2[bin][ind]=sqrt(xc2*xc2+yc2*yc2); | |
220 | ind2[bin]++; | |
221 | } | |
222 | } | |
3136129d | 223 | clusters->Delete(); |
dd36288a | 224 | } |
225 | Int_t nbinfine = static_cast<Int_t>((fHighLim-fLowLim)/fStepFine); | |
226 | Float_t lowz = fLowLim/fStepFine; | |
dd36288a | 227 | Int_t *harray = new Int_t[nbinfine]; |
228 | memset(harray,0,nbinfine*sizeof(Int_t)); | |
229 | for(Int_t ibin=0;ibin<nPhiBins;ibin++) { | |
230 | Float_t *pphi1 = phi1[ibin]; | |
231 | Float_t *pr1 = r1[ibin]; | |
232 | Float_t *pzc1 = zc1[ibin]; | |
233 | for(Int_t i=0;i<ind1[ibin];i++){ | |
234 | for(Int_t jbin=ibin;jbin<=(ibin+1);jbin++) { | |
235 | Int_t jbin2 = jbin; | |
236 | if(jbin==nPhiBins) jbin2 = 0; | |
237 | Float_t *pphi2 = phi2[jbin2]; | |
238 | Float_t *pr2 = r2[jbin2]; | |
239 | Float_t *pzc2 = zc2[jbin2]; | |
240 | for(Int_t j=0;j<ind2[jbin2];j++){ | |
241 | Float_t diff = TMath::Abs(pphi2[j]-pphi1[i]); | |
242 | if(diff>TMath::Pi())diff=2.*TMath::Pi()-diff; | |
243 | if(diff<fDiffPhiMax){ | |
244 | Float_t zr0=(pr2[j]*pzc1[i]-pr1[i]*pzc2[j])/(pr2[j]-pr1[i]); | |
3136129d | 245 | Int_t bin = (Int_t)(zr0-lowz); |
246 | if(bin>=0 && bin<nbinfine){ | |
dd36288a | 247 | harray[bin]++; |
248 | } | |
249 | } | |
250 | } | |
251 | } | |
252 | } | |
253 | } | |
254 | for(Int_t i=0;i<nPhiBins;i++) { | |
255 | delete [] zc1[i]; | |
256 | delete [] phi1[i]; | |
257 | delete [] r1[i]; | |
258 | delete [] zc2[i]; | |
259 | delete [] phi2[i]; | |
260 | delete [] r2[i]; | |
261 | } | |
262 | delete [] zc1; | |
263 | delete [] phi1; | |
264 | delete [] r1; | |
265 | delete [] ind1; | |
266 | delete [] zc2; | |
267 | delete [] phi2; | |
268 | delete [] r2; | |
269 | delete [] ind2; | |
270 | ||
271 | Int_t nbinratio = (Int_t)(fStepCoarse/fStepFine+0.5); | |
272 | Int_t nbincoarse = nbinfine/nbinratio; | |
273 | ||
274 | if(fZCombc)delete fZCombc; | |
275 | fZCombc = new TH1F("fZCombc","Z",nbincoarse,fLowLim,fLowLim+nbincoarse*fStepCoarse); | |
276 | if(fZCombf)delete fZCombf; | |
277 | fZCombf = new TH1F("fZCombf","Z",nbinfine,fLowLim,fLowLim+nbinfine*fStepFine); | |
278 | Stat_t contents=0; | |
279 | Int_t counter=0; | |
280 | for(Int_t bin=0;bin<nbinfine;bin++) { | |
281 | fZCombf->SetBinContent(bin+1,(Stat_t)harray[bin]); | |
282 | fZCombf->SetBinError(bin+1,TMath::Sqrt((Stat_t)harray[bin])); | |
283 | contents+=(Stat_t)harray[bin]; | |
284 | counter++; | |
285 | if(counter==nbinratio) { | |
286 | Int_t binc=bin/nbinratio; | |
287 | fZCombc->SetBinContent(binc+1,contents); | |
288 | fZCombc->SetBinError(binc+1,TMath::Sqrt(contents)); | |
289 | contents=0; | |
290 | counter=0; | |
291 | } | |
292 | } | |
293 | ||
294 | delete [] harray; | |
295 | ||
296 | if(fZCombc->GetEntries()==0){ | |
297 | Warning("FindVertexForCurrentEvent","Insufficient number of rec. points\n"); | |
298 | ResetHistograms(); | |
299 | return fCurrentVertex; | |
300 | } | |
301 | // else { | |
302 | // cout<<"Number of entries in hist. "<<fZCombc->GetEntries()<<endl; | |
303 | // } | |
304 | Int_t bi = fZCombc->GetMaximumBin(); | |
305 | Float_t centre = fZCombc->GetBinCenter(bi); | |
306 | Int_t n1 = static_cast<Int_t>((centre-fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
307 | Int_t n2 = static_cast<Int_t>((centre+fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
308 | Int_t niter = 0; | |
309 | Bool_t goon = kTRUE; | |
310 | Int_t num; | |
311 | while(goon){ | |
312 | fZFound = 0.; | |
313 | fZsig = 0.; | |
314 | num=0; | |
315 | for(Int_t n=n1;n<=n2;n++){ | |
316 | fZFound+=fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); | |
317 | num+=static_cast<Int_t>(fZCombf->GetBinContent(n)); | |
318 | fZsig+=fZCombf->GetBinCenter(n)*fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); | |
319 | } | |
320 | if(num<2){ | |
321 | fZsig = 0.; | |
322 | } | |
323 | else { | |
324 | Float_t radi = fZsig/(num-1)-fZFound*fZFound/num/(num-1); | |
325 | if(radi>0.)fZsig=TMath::Sqrt(radi); | |
326 | else fZsig=0.; | |
327 | fZFound/=num; | |
328 | } | |
329 | goon = TMath::Abs(TMath::Abs(fZFound-fZCombf->GetBinCenter(n1))-TMath::Abs(fZFound-fZCombf->GetBinCenter(n2)))>fTolerance; | |
330 | n1 = static_cast<Int_t>((fZFound-fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
331 | n2 = static_cast<Int_t>((fZFound+fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
332 | niter++; | |
333 | if(niter>=10){ | |
334 | goon = kFALSE; | |
335 | Warning("FindVertexForCurrentEvent","The procedure dows not converge\n"); | |
336 | } | |
337 | } | |
338 | // cout<<"Numer of Iterations "<<niter<<endl<<endl; | |
339 | fCurrentVertex = new AliESDVertex(fZFound,fZsig,num); | |
340 | fCurrentVertex->SetTitle("vertexer: HLT"); | |
341 | ResetHistograms(); | |
342 | PrintStatus(); | |
343 | return fCurrentVertex; | |
344 | } |