]>
Commit | Line | Data |
---|---|---|
0c6af5c9 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, 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 | **************************************************************************/ | |
d531b7a1 | 15 | #include "AliITSVertexerZ.h" |
0c6af5c9 | 16 | #include<TBranch.h> |
0c6af5c9 | 17 | #include<TH1.h> |
d531b7a1 | 18 | #include <TString.h> |
0c6af5c9 | 19 | #include<TTree.h> |
d531b7a1 | 20 | #include "AliITSLoader.h" |
21 | #include "AliITSgeom.h" | |
7d62fb64 | 22 | #include "AliITSDetTypeRec.h" |
d531b7a1 | 23 | #include "AliITSRecPoint.h" |
0c6af5c9 | 24 | |
25 | ///////////////////////////////////////////////////////////////// | |
26 | // this class implements a fast method to determine | |
27 | // the Z coordinate of the primary vertex | |
28 | // for p-p collisions it seems to give comparable or better results | |
29 | // with respect to what obtained with AliITSVertexerPPZ | |
30 | // It can be used successfully with Pb-Pb collisions | |
31 | //////////////////////////////////////////////////////////////// | |
32 | ||
33 | ClassImp(AliITSVertexerZ) | |
34 | ||
35 | ||
36 | ||
37 | //______________________________________________________________________ | |
38 | AliITSVertexerZ::AliITSVertexerZ():AliITSVertexer() { | |
39 | // Default constructor | |
40 | SetDiffPhiMax(0); | |
41 | fX0 = 0.; | |
42 | fY0 = 0.; | |
43 | SetFirstLayerModules(0); | |
44 | SetSecondLayerModules(0); | |
45 | fZFound = 0; | |
46 | fZsig = 0.; | |
0c6af5c9 | 47 | fZCombc = 0; |
48 | fZCombf = 0; | |
ecc64c3f | 49 | fZCombv = 0; |
0c6af5c9 | 50 | SetLowLimit(0.); |
51 | SetHighLimit(0.); | |
52 | SetBinWidthCoarse(0.); | |
53 | SetBinWidthFine(0.); | |
54 | SetTolerance(0.); | |
ecc64c3f | 55 | SetPPsetting(0.,0.); |
6fd990e3 | 56 | ConfigIterations(); |
0c6af5c9 | 57 | } |
58 | ||
59 | //______________________________________________________________________ | |
60 | AliITSVertexerZ::AliITSVertexerZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn) { | |
61 | // Standard Constructor | |
62 | SetDiffPhiMax(); | |
63 | fX0 = x0; | |
64 | fY0 = y0; | |
65 | SetFirstLayerModules(); | |
66 | SetSecondLayerModules(); | |
67 | fZFound = 0; | |
68 | fZsig = 0.; | |
0c6af5c9 | 69 | fZCombc = 0; |
70 | fZCombf = 0; | |
ecc64c3f | 71 | fZCombv = 0; |
0c6af5c9 | 72 | SetLowLimit(); |
73 | SetHighLimit(); | |
74 | SetBinWidthCoarse(); | |
75 | SetBinWidthFine(); | |
76 | SetTolerance(); | |
ecc64c3f | 77 | SetPPsetting(); |
6fd990e3 | 78 | ConfigIterations(); |
0c6af5c9 | 79 | |
80 | } | |
81 | ||
82 | //______________________________________________________________________ | |
83 | AliITSVertexerZ::AliITSVertexerZ(const AliITSVertexerZ &vtxr) : AliITSVertexer(vtxr) { | |
84 | // Copy constructor | |
85 | // Copies are not allowed. The method is protected to avoid misuse. | |
86 | Error("AliITSVertexerZ","Copy constructor not allowed\n"); | |
87 | } | |
88 | ||
89 | //______________________________________________________________________ | |
90 | AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& /* vtxr */){ | |
91 | // Assignment operator | |
92 | // Assignment is not allowed. The method is protected to avoid misuse. | |
93 | Error("= operator","Assignment operator not allowed\n"); | |
94 | return *this; | |
95 | } | |
96 | ||
0c6af5c9 | 97 | //______________________________________________________________________ |
98 | AliITSVertexerZ::~AliITSVertexerZ() { | |
ecc64c3f | 99 | // Destructor |
100 | delete fZCombc; | |
101 | delete fZCombf; | |
102 | delete fZCombv; | |
0c6af5c9 | 103 | } |
104 | ||
6fd990e3 | 105 | //______________________________________________________________________ |
106 | void AliITSVertexerZ::ConfigIterations(Int_t noiter,Float_t *ptr){ | |
107 | // configure the iterative procedure to gain efficiency for | |
108 | // pp events with very low multiplicity | |
109 | Float_t defaults[5]={0.05,0.1,0.2,0.3,0.5}; | |
110 | fMaxIter=noiter; | |
111 | if(noiter>5){ | |
112 | Error("ConfigIterations","Maximum number of iterations is 5\n"); | |
113 | fMaxIter=5; | |
114 | } | |
115 | for(Int_t j=0;j<5;j++)fPhiDiffIter[j]=defaults[j]; | |
116 | if(ptr)for(Int_t j=0;j<fMaxIter;j++)fPhiDiffIter[j]=ptr[j]; | |
117 | } | |
118 | ||
0c6af5c9 | 119 | //______________________________________________________________________ |
d681bb2d | 120 | AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ |
121 | // Defines the AliESDVertex for the current event | |
6fd990e3 | 122 | VertexZFinder(evnumber); |
123 | Int_t ntrackl=0; | |
124 | for(Int_t iteraz=0;iteraz<fMaxIter;iteraz++){ | |
125 | if(fCurrentVertex) ntrackl=fCurrentVertex->GetNContributors(); | |
126 | if(!fCurrentVertex || ntrackl==0 || ntrackl==-1){ | |
127 | Float_t diffPhiMaxOrig=fDiffPhiMax; | |
128 | fDiffPhiMax=GetPhiMaxIter(iteraz); | |
129 | VertexZFinder(evnumber); | |
130 | fDiffPhiMax=diffPhiMaxOrig; | |
131 | } | |
132 | } | |
32e449be | 133 | FindMultiplicity(evnumber); |
6fd990e3 | 134 | return fCurrentVertex; |
135 | } | |
136 | ||
32e449be | 137 | |
138 | ||
139 | ||
6fd990e3 | 140 | //______________________________________________________________________ |
141 | void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ | |
142 | // Defines the AliESDVertex for the current event | |
0c6af5c9 | 143 | fCurrentVertex = 0; |
144 | AliRunLoader *rl =AliRunLoader::GetRunLoader(); | |
7d62fb64 | 145 | AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader"); |
32e449be | 146 | AliITSgeom* geom = itsLoader->GetITSgeom(); |
2257f27e | 147 | itsLoader->LoadRecPoints(); |
0c6af5c9 | 148 | rl->GetEvent(evnumber); |
149 | ||
7d62fb64 | 150 | AliITSDetTypeRec detTypeRec; |
0c6af5c9 | 151 | |
152 | TTree *tR = itsLoader->TreeR(); | |
7d62fb64 | 153 | detTypeRec.SetTreeAddressR(tR); |
0c6af5c9 | 154 | TClonesArray *itsRec = 0; |
ecc64c3f | 155 | // lc and gc are local and global coordinates for layer 1 |
0c6af5c9 | 156 | Float_t lc[3]; for(Int_t ii=0; ii<3; ii++) lc[ii]=0.; |
157 | Float_t gc[3]; for(Int_t ii=0; ii<3; ii++) gc[ii]=0.; | |
ecc64c3f | 158 | // lc2 and gc2 are local and global coordinates for layer 2 |
0c6af5c9 | 159 | Float_t lc2[3]; for(Int_t ii=0; ii<3; ii++) lc2[ii]=0.; |
160 | Float_t gc2[3]; for(Int_t ii=0; ii<3; ii++) gc2[ii]=0.; | |
161 | ||
7d62fb64 | 162 | itsRec = detTypeRec.RecPoints(); |
2257f27e | 163 | TBranch *branch; |
00a7cc50 | 164 | branch = tR->GetBranch("ITSRecPoints"); |
0c6af5c9 | 165 | |
0c6af5c9 | 166 | Int_t nrpL1 = 0; |
167 | Int_t nrpL2 = 0; | |
ecc64c3f | 168 | // By default fFirstL1=0 and fLastL1=79 |
169 | // This loop counts the number of recpoints on layer1 (central modules) | |
0c6af5c9 | 170 | for(Int_t module= fFirstL1; module<=fLastL1;module++){ |
ecc64c3f | 171 | // Keep only central modules |
0c6af5c9 | 172 | if(module%4==0 || module%4==3)continue; |
ecc64c3f | 173 | // cout<<"Procesing module "<<module<<" "; |
0c6af5c9 | 174 | branch->GetEvent(module); |
ecc64c3f | 175 | // cout<<"Number of clusters "<<clusters->GetEntries()<<endl; |
0c6af5c9 | 176 | nrpL1+= itsRec->GetEntries(); |
7d62fb64 | 177 | detTypeRec.ResetRecPoints(); |
0c6af5c9 | 178 | } |
ecc64c3f | 179 | //By default fFirstL2=80 and fLastL2=239 |
180 | //This loop counts the number of RP on layer 2 | |
0c6af5c9 | 181 | for(Int_t module= fFirstL2; module<=fLastL2;module++){ |
182 | branch->GetEvent(module); | |
183 | nrpL2+= itsRec->GetEntries(); | |
7d62fb64 | 184 | detTypeRec.ResetRecPoints(); |
0c6af5c9 | 185 | } |
0c6af5c9 | 186 | if(nrpL1 == 0 || nrpL2 == 0){ |
0c6af5c9 | 187 | ResetHistograms(); |
6fd990e3 | 188 | itsLoader->UnloadRecPoints(); |
189 | fCurrentVertex = new AliESDVertex(0.,5.3,-2); | |
190 | return; | |
0c6af5c9 | 191 | } |
ecc64c3f | 192 | // The vertex finding is attempted only if the number of RP is !=0 on |
193 | // both layers | |
194 | Float_t *xc1 = new Float_t [nrpL1]; // coordinates of the L1 Recpoints | |
0c6af5c9 | 195 | Float_t *yc1 = new Float_t [nrpL1]; |
196 | Float_t *zc1 = new Float_t [nrpL1]; | |
197 | Float_t *phi1 = new Float_t [nrpL1]; | |
ecc64c3f | 198 | Float_t *xc2 = new Float_t [nrpL2]; // coordinates of the L1 Recpoints |
0c6af5c9 | 199 | Float_t *yc2 = new Float_t [nrpL2]; |
200 | Float_t *zc2 = new Float_t [nrpL2]; | |
201 | Float_t *phi2 = new Float_t [nrpL2]; | |
ecc64c3f | 202 | Int_t ind = 0;// running index for RP |
203 | // Force a coarse bin size of 200 microns if the number of clusters on layer 2 | |
204 | // is low | |
205 | if(nrpL2<fPPsetting[0])SetBinWidthCoarse(fPPsetting[1]); | |
206 | // By default nbinfine = (10+10)/0.0005=40000 | |
207 | Int_t nbinfine = static_cast<Int_t>((fHighLim-fLowLim)/fStepFine); | |
208 | // By default nbincoarse=(10+10)/0.01=2000 | |
209 | Int_t nbincoarse = static_cast<Int_t>((fHighLim-fLowLim)/fStepCoarse); | |
210 | // Set stepverycoarse = 3*fStepCoarse | |
211 | Int_t nbinvcoarse = static_cast<Int_t>((fHighLim-fLowLim)/(3.*fStepCoarse)); | |
212 | if(fZCombc)delete fZCombc; | |
213 | fZCombc = new TH1F("fZCombc","Z",nbincoarse,fLowLim,fLowLim+nbincoarse*fStepCoarse); | |
214 | if(fZCombv)delete fZCombv; | |
215 | fZCombv = new TH1F("fZCombv","Z",nbinvcoarse,fLowLim,fLowLim+nbinvcoarse*3.*fStepCoarse); | |
216 | if(fZCombf)delete fZCombf; | |
217 | fZCombf = new TH1F("fZCombf","Z",nbinfine,fLowLim,fLowLim+nbinfine*fStepFine); | |
218 | // Loop on modules of layer 1 (restricted to central modules) | |
0c6af5c9 | 219 | for(Int_t module= fFirstL1; module<=fLastL1;module++){ |
220 | if(module%4==0 || module%4==3)continue; | |
221 | branch->GetEvent(module); | |
222 | Int_t nrecp1 = itsRec->GetEntries(); | |
223 | for(Int_t j=0;j<nrecp1;j++){ | |
224 | AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j); | |
ecc64c3f | 225 | // Local coordinates of this recpoint |
00a7cc50 | 226 | lc[0]=recp->GetDetLocalX(); |
227 | lc[2]=recp->GetDetLocalZ(); | |
0c6af5c9 | 228 | geom->LtoG(module,lc,gc); |
ecc64c3f | 229 | // Global coordinates of this recpoints |
230 | gc[0]-=fX0; // Possible beam offset in the bending plane | |
231 | gc[1]-=fY0; // " " | |
0c6af5c9 | 232 | xc1[ind]=gc[0]; |
233 | yc1[ind]=gc[1]; | |
234 | zc1[ind]=gc[2]; | |
ecc64c3f | 235 | // azimuthal angle is computed in the interval 0 --> 2*pi |
0c6af5c9 | 236 | phi1[ind] = TMath::ATan2(gc[1],gc[0]); |
237 | if(phi1[ind]<0)phi1[ind]=2*TMath::Pi()+phi1[ind]; | |
238 | ind++; | |
239 | } | |
7d62fb64 | 240 | detTypeRec.ResetRecPoints(); |
0c6af5c9 | 241 | } |
ecc64c3f | 242 | ind = 0; // the running index is reset for Layer 2 |
0c6af5c9 | 243 | for(Int_t module= fFirstL2; module<=fLastL2;module++){ |
244 | branch->GetEvent(module); | |
245 | Int_t nrecp2 = itsRec->GetEntries(); | |
246 | for(Int_t j=0;j<nrecp2;j++){ | |
247 | AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j); | |
00a7cc50 | 248 | lc[0]=recp->GetDetLocalX(); |
249 | lc[2]=recp->GetDetLocalZ(); | |
0c6af5c9 | 250 | geom->LtoG(module,lc,gc); |
251 | gc[0]-=fX0; | |
252 | gc[1]-=fY0; | |
253 | xc2[ind]=gc[0]; | |
254 | yc2[ind]=gc[1]; | |
255 | zc2[ind]=gc[2]; | |
256 | phi2[ind] = TMath::ATan2(gc[1],gc[0]); | |
257 | if(phi2[ind]<0)phi2[ind]=2*TMath::Pi()+phi2[ind]; | |
258 | ind++; | |
259 | } | |
7d62fb64 | 260 | detTypeRec.ResetRecPoints(); |
0c6af5c9 | 261 | } |
32e449be | 262 | |
263 | Int_t nolines=0; | |
ecc64c3f | 264 | for(Int_t i=0;i<nrpL1;i++){ // loop on L1 RP |
265 | Float_t r1=TMath::Sqrt(xc1[i]*xc1[i]+yc1[i]*yc1[i]); // radius L1 RP | |
266 | for(Int_t j=0;j<nrpL2;j++){ // loop on L2 RP | |
267 | Float_t diff = TMath::Abs(phi2[j]-phi1[i]); // diff in azimuth | |
268 | if(diff>TMath::Pi())diff=2.*TMath::Pi()-diff; //diff<pi | |
269 | if(diff<fDiffPhiMax){ // cut on 10 milliradians by def. | |
270 | Float_t r2=TMath::Sqrt(xc2[j]*xc2[j]+yc2[j]*yc2[j]); // radius L2 RP | |
271 | Float_t zr0=(r2*zc1[i]-r1*zc2[j])/(r2-r1); //Z @ null radius | |
0c6af5c9 | 272 | fZCombf->Fill(zr0); |
273 | fZCombc->Fill(zr0); | |
ecc64c3f | 274 | fZCombv->Fill(zr0); |
32e449be | 275 | Double_t pA[3]; |
276 | Double_t pB[3]; | |
277 | pA[0]=xc1[i]; | |
278 | pA[1]=yc1[i]; | |
279 | pA[2]=zc1[i]; | |
280 | pB[0]=xc2[j]; | |
281 | pB[1]=yc2[j]; | |
282 | pB[2]=zc2[j]; | |
283 | MakeTracklet(pA,pB,nolines); | |
0c6af5c9 | 284 | } |
285 | } | |
286 | } | |
287 | delete [] xc1; | |
288 | delete [] yc1; | |
289 | delete [] zc1; | |
290 | delete [] phi1; | |
291 | delete [] xc2; | |
292 | delete [] yc2; | |
293 | delete [] zc2; | |
294 | delete [] phi2; | |
6fd990e3 | 295 | Double_t contents = fZCombc->GetEntries()- fZCombc->GetBinContent(0)-fZCombc->GetBinContent(nbincoarse+1); |
296 | if(contents<1.){ | |
297 | // Warning("FindVertexForCurrentEvent","Insufficient number of rec. points\n"); | |
0c6af5c9 | 298 | ResetHistograms(); |
6fd990e3 | 299 | itsLoader->UnloadRecPoints(); |
300 | fCurrentVertex = new AliESDVertex(0.,5.3,-1); | |
301 | return; | |
0c6af5c9 | 302 | } |
ecc64c3f | 303 | /* |
304 | else { | |
305 | if(fDebug>0)cout<<"Number of entries in hist. "<<fZCombc->GetEntries()<<endl; | |
306 | } | |
307 | */ | |
308 | ||
309 | TH1F *hc = fZCombc; | |
310 | Bool_t goon = kFALSE; | |
311 | Int_t cnt = 0; | |
312 | Int_t bi; | |
313 | ||
314 | do { | |
315 | goon = kFALSE; | |
316 | cnt++; | |
317 | bi = hc->GetMaximumBin(); // bin with maximal content on coarse histogram | |
318 | if(hc->GetBinContent(bi)<3){ | |
319 | if(cnt==1)goon = kTRUE; | |
320 | hc = fZCombv; | |
321 | } | |
322 | } while(goon); | |
323 | ||
324 | ||
325 | Float_t centre = hc->GetBinCenter(bi); // z value of the bin with maximal content | |
326 | ||
d531b7a1 | 327 | Int_t bifine=static_cast<Int_t>((hc->GetBinCenter(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); |
328 | Int_t nbinsfine=static_cast<Int_t>(3*hc->GetBinWidth(bi)/fStepFine); | |
ecc64c3f | 329 | // evaluation of the centroid |
d531b7a1 | 330 | Int_t ii1=TMath::Max(bifine-nbinsfine,1); |
331 | Int_t ii2=TMath::Min(bifine+nbinsfine,fZCombf->GetNbinsX()); | |
ecc64c3f | 332 | centre = 0.; |
333 | Int_t nn=0; | |
334 | for(Int_t ii=ii1;ii<ii2;ii++){ | |
d531b7a1 | 335 | centre+= fZCombf->GetBinCenter(ii)*fZCombf->GetBinContent(ii); |
336 | nn+=static_cast<Int_t>(fZCombf->GetBinContent(ii)); | |
ecc64c3f | 337 | } |
3eb8b116 | 338 | if (nn) centre/=nn; |
ecc64c3f | 339 | /* |
340 | if(fDebug>0){ | |
341 | cout<<"Value of center "<<centre<<endl; | |
342 | cout<<"Population of 3 central bins: "<<hc->GetBinContent(bi-1)<<", "; | |
343 | cout<<hc->GetBinContent(bi)<<", "; | |
344 | cout<<hc->GetBinContent(bi+1)<<endl; | |
345 | } | |
346 | */ | |
347 | // n1 is the bin number of fine histogram containing the point located 1 coarse bin less than "centre" | |
348 | Int_t n1 = static_cast<Int_t>((centre-hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
349 | // n2 is the bin number of fine histogram containing the point located 1 coarse bin more than "centre" | |
350 | Int_t n2 = static_cast<Int_t>((centre+hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
351 | if(n1<1)n1=1; | |
352 | if(n2>nbinfine)n2=nbinfine; | |
0c6af5c9 | 353 | Int_t niter = 0; |
ecc64c3f | 354 | goon = kTRUE; |
355 | Int_t num=0; | |
356 | Bool_t last = kFALSE; | |
357 | ||
358 | while(goon || last){ | |
0c6af5c9 | 359 | fZFound = 0.; |
360 | fZsig = 0.; | |
361 | num=0; | |
ecc64c3f | 362 | // at the end of the loop: |
363 | // fZFound = N*(Average Z) - where N is the number of tracklets | |
364 | // num=N | |
365 | // fZsig = N*Q - where Q is the average of Z*Z | |
0c6af5c9 | 366 | for(Int_t n=n1;n<=n2;n++){ |
367 | fZFound+=fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); | |
368 | num+=static_cast<Int_t>(fZCombf->GetBinContent(n)); | |
369 | fZsig+=fZCombf->GetBinCenter(n)*fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); | |
370 | } | |
371 | if(num<2){ | |
12e26c26 | 372 | fZsig = 5.3; // Default error from the beam sigmoid |
0c6af5c9 | 373 | } |
ecc64c3f | 374 | else{ |
979e3647 | 375 | Float_t radi = fZsig/(num-1)-fZFound*fZFound/num/(num-1); |
ecc64c3f | 376 | // radi = square root of sample variance of Z |
979e3647 | 377 | if(radi>0.)fZsig=TMath::Sqrt(radi); |
12e26c26 | 378 | else fZsig=5.3; // Default error from the beam sigmoid |
ecc64c3f | 379 | // fZfound - Average Z |
0c6af5c9 | 380 | fZFound/=num; |
381 | } | |
ecc64c3f | 382 | if(!last){ |
383 | // goon is true if the distance between the found Z and the lower bin differs from the distance between the found Z and | |
384 | // the upper bin by more than tolerance (0.002) | |
385 | goon = TMath::Abs(TMath::Abs(fZFound-fZCombf->GetBinCenter(n1))-TMath::Abs(fZFound-fZCombf->GetBinCenter(n2)))>fTolerance; | |
386 | // a window in the fine grained histogram is centered aroung the found Z. The width is 2 bins of | |
387 | // the coarse grained histogram | |
6fd990e3 | 388 | if(num>0){ |
389 | n1 = static_cast<Int_t>((fZFound-hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
390 | if(n1<1)n1=1; | |
391 | n2 = static_cast<Int_t>((fZFound+hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
392 | if(n2>nbinfine)n2=nbinfine; | |
393 | /* | |
394 | if(fDebug>0){ | |
395 | cout<<"Search restricted to n1 = "<<n1<<", n2= "<<n2<<endl; | |
396 | cout<<"z1= "<<fZCombf->GetBinCenter(n1)<<", n2 = "<<fZCombf->GetBinCenter(n2)<<endl; | |
397 | } | |
398 | */ | |
399 | } | |
400 | else { | |
401 | n1 = static_cast<Int_t>((centre-(niter+2)*hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
402 | n2 = static_cast<Int_t>((centre+(niter+2)*hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); | |
403 | if(n1<1)n1=1; | |
404 | if(n2>nbinfine)n2=nbinfine; | |
ecc64c3f | 405 | } |
ecc64c3f | 406 | niter++; |
407 | // no more than 10 adjusting iterations | |
408 | if(niter>=10){ | |
409 | goon = kFALSE; | |
6fd990e3 | 410 | // Warning("FindVertexForCurrentEvent","The procedure does not converge\n"); |
ecc64c3f | 411 | } |
412 | ||
413 | if((fZsig> 0.0001) && !goon && num>5){ | |
414 | last = kTRUE; | |
415 | n1 = static_cast<Int_t>((fZFound-fZsig-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
416 | if(n1<1)n1=1; | |
417 | n2 = static_cast<Int_t>((fZFound+fZsig-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); | |
418 | if(n2>nbinfine)n2=nbinfine; | |
419 | /* | |
420 | if(fDebug>0){ | |
421 | cout<<"FINAL Search restricted to n1 = "<<n1<<", n2= "<<n2<<endl; | |
422 | cout<<"z1= "<<fZCombf->GetBinCenter(n1)<<", n2 = "<<fZCombf->GetBinCenter(n2)<<endl; | |
423 | } | |
424 | */ | |
425 | } | |
426 | } | |
427 | else { | |
428 | last = kFALSE; | |
0c6af5c9 | 429 | } |
ecc64c3f | 430 | |
0c6af5c9 | 431 | } |
ecc64c3f | 432 | // if(fDebug>0)cout<<"Numer of Iterations "<<niter<<endl<<endl; |
9679d5db | 433 | // if(num!=0)fZsig/=TMath::Sqrt(num); |
12e26c26 | 434 | if (fZsig<=0) fZsig=5.3; // Default error from the beam sigmoid |
d681bb2d | 435 | fCurrentVertex = new AliESDVertex(fZFound,fZsig,num); |
0c6af5c9 | 436 | fCurrentVertex->SetTitle("vertexer: B"); |
437 | ResetHistograms(); | |
6fd990e3 | 438 | itsLoader->UnloadRecPoints(); |
439 | return; | |
0c6af5c9 | 440 | } |
441 | ||
442 | //_____________________________________________________________________ | |
443 | void AliITSVertexerZ::ResetHistograms(){ | |
444 | // delete TH1 data members | |
445 | if(fZCombc)delete fZCombc; | |
446 | if(fZCombf)delete fZCombf; | |
ecc64c3f | 447 | if(fZCombv)delete fZCombv; |
0c6af5c9 | 448 | fZCombc = 0; |
449 | fZCombf = 0; | |
ecc64c3f | 450 | fZCombv = 0; |
0c6af5c9 | 451 | } |
452 | ||
453 | //______________________________________________________________________ | |
454 | void AliITSVertexerZ::FindVertices(){ | |
455 | // computes the vertices of the events in the range FirstEvent - LastEvent | |
456 | AliRunLoader *rl = AliRunLoader::GetRunLoader(); | |
457 | AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader"); | |
458 | itsLoader->ReloadRecPoints(); | |
459 | for(Int_t i=fFirstEvent;i<=fLastEvent;i++){ | |
6fd990e3 | 460 | // cout<<"Processing event "<<i<<endl; |
0c6af5c9 | 461 | rl->GetEvent(i); |
462 | FindVertexForCurrentEvent(i); | |
463 | if(fCurrentVertex){ | |
464 | WriteCurrentVertex(); | |
465 | } | |
ecc64c3f | 466 | /* |
0c6af5c9 | 467 | else { |
468 | if(fDebug>0){ | |
469 | cout<<"Vertex not found for event "<<i<<endl; | |
470 | cout<<"fZFound = "<<fZFound<<", fZsig= "<<fZsig<<endl; | |
471 | } | |
472 | } | |
ecc64c3f | 473 | */ |
0c6af5c9 | 474 | } |
475 | } | |
476 | ||
477 | //________________________________________________________ | |
478 | void AliITSVertexerZ::PrintStatus() const { | |
479 | // Print current status | |
480 | cout <<"=======================================================\n"; | |
481 | cout <<" First layer first and last modules: "<<fFirstL1<<", "; | |
482 | cout <<fLastL1<<endl; | |
483 | cout <<" Second layer first and last modules: "<<fFirstL2<<", "; | |
484 | cout <<fLastL2<<endl; | |
485 | cout <<" Max Phi difference: "<<fDiffPhiMax<<endl; | |
486 | cout <<"Limits for Z histograms: "<<fLowLim<<"; "<<fHighLim<<endl; | |
487 | cout <<"Bin sizes for coarse and fine z histos "<<fStepCoarse<<"; "<<fStepFine<<endl; | |
488 | cout <<" Current Z "<<fZFound<<"; Z sig "<<fZsig<<endl; | |
489 | cout <<" Debug flag: "<<fDebug<<endl; | |
490 | cout <<"First event to be processed "<<fFirstEvent; | |
491 | cout <<"\n Last event to be processed "<<fLastEvent<<endl; | |
ecc64c3f | 492 | if(fZCombc){ |
493 | cout<<"fZCombc exists - entries="<<fZCombc->GetEntries()<<endl; | |
494 | } | |
495 | else{ | |
496 | cout<<"fZCombc does not exist\n"; | |
497 | } | |
498 | if(fZCombv){ | |
499 | cout<<"fZCombv exists - entries="<<fZCombv->GetEntries()<<endl; | |
500 | } | |
501 | else{ | |
502 | cout<<"fZCombv does not exist\n"; | |
503 | } | |
504 | if(fZCombf){ | |
505 | cout<<"fZCombf exists - entries="<<fZCombv->GetEntries()<<endl; | |
506 | } | |
507 | else{ | |
508 | cout<<"fZCombf does not exist\n"; | |
509 | } | |
0c6af5c9 | 510 | |
511 | cout <<"=======================================================\n"; | |
512 | } | |
513 |