]>
Commit | Line | Data |
---|---|---|
3acc14d5 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, 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 | **************************************************************************/ | |
15 | ||
16 | #include <TClonesArray.h> | |
308c2f7c | 17 | #include <TTree.h> |
3acc14d5 | 18 | #include "AliLog.h" |
19 | #include "AliESDVertex.h" | |
0333e459 | 20 | #include "AliITSgeomTGeo.h" |
3acc14d5 | 21 | #include "AliITSRecPoint.h" |
81ba01de | 22 | #include "AliITSReconstructor.h" |
3acc14d5 | 23 | #include "AliITSVertexerCosmics.h" |
24 | #include "AliStrLine.h" | |
25 | ||
26 | //------------------------------------------------------------------------ | |
27 | // This class implements a method to construct a "fake" primary | |
b8ed1a92 | 28 | // vertex for cosmic events in which the muon crosses one of 5 inner |
29 | // ITS layers. A fake primary vertex is needed for the reconstruction, | |
3acc14d5 | 30 | // with e.g. AliITStrackerSA, of the two tracks produced by the muon |
31 | // in the ITS. | |
b8ed1a92 | 32 | // We build pairs of clusters on a given layer and define the fake vertex as |
3acc14d5 | 33 | // the mid-point of the straight line joining the two clusters. |
b8ed1a92 | 34 | // We use the innermost layer that has at least two clusters. |
35 | // We reject the background by requiring at least one cluster on the outer | |
36 | // layer, closer than fMaxDistOnOuterLayer to the tracklet prolongation. | |
3acc14d5 | 37 | // We can reject (potentially pathological) events with the muon track |
b8ed1a92 | 38 | // tangential to the layer by the requiring the radial position of |
3acc14d5 | 39 | // the vertex to be smaller than fMaxVtxRadius. |
40 | // Due to background clusters, more than one vertex per event can | |
41 | // be found. We consider the first found. | |
b8ed1a92 | 42 | // The errors on x,y,z of the vertex are calculated as errors on the mean |
43 | // of clusters coordinates. Non-diag elements of vertex cov. mat. are set to 0. | |
3acc14d5 | 44 | // The number of contributors set in the AliESDVertex object is the |
b8ed1a92 | 45 | // number of the layer on which the tracklet was built; if this number is -1, |
3acc14d5 | 46 | // the procedure could not find a vertex position and by default |
47 | // the vertex coordinates are set to (0,0,0) with large errors (100,100,100) | |
3acc14d5 | 48 | // |
49 | // Origin: A.Dainese, andrea.dainese@lnl.infn.it | |
50 | //------------------------------------------------------------------------- | |
51 | ||
52 | ClassImp(AliITSVertexerCosmics) | |
53 | ||
54 | //------------------------------------------------------------------------- | |
55 | AliITSVertexerCosmics::AliITSVertexerCosmics():AliITSVertexer(), | |
b8ed1a92 | 56 | fMaxDistOnOuterLayer(0), |
3acc14d5 | 57 | fMinDist2Vtxs(0) |
58 | { | |
59 | // Default constructor | |
b8ed1a92 | 60 | SetFirstLastModules(0,0,79); |
61 | SetFirstLastModules(1,80,239); | |
62 | SetFirstLastModules(2,240,323); | |
63 | SetFirstLastModules(3,324,499); | |
64 | SetFirstLastModules(4,500,1247); | |
65 | SetFirstLastModules(5,1248,2197); | |
7e33c4e6 | 66 | /* |
b8ed1a92 | 67 | SetMaxVtxRadius(0,3.5); |
68 | SetMaxVtxRadius(1,6.5); | |
69 | SetMaxVtxRadius(2,14.5); | |
70 | SetMaxVtxRadius(3,23.5); | |
71 | SetMaxVtxRadius(4,37.5); | |
72 | SetMaxVtxRadius(5,42.5); | |
7e33c4e6 | 73 | */ |
81ba01de | 74 | SetMaxVtxRadius(0,5.5); |
75 | SetMaxVtxRadius(1,8.5); | |
76 | SetMaxVtxRadius(2,18.5); | |
77 | SetMaxVtxRadius(3,28.5); | |
78 | SetMaxVtxRadius(4,39.5); | |
79 | SetMaxVtxRadius(5,48.5); | |
7e33c4e6 | 80 | |
b8ed1a92 | 81 | SetMaxDistOnOuterLayer(); |
3acc14d5 | 82 | SetMinDist2Vtxs(); |
83 | } | |
84 | //-------------------------------------------------------------------------- | |
308c2f7c | 85 | AliESDVertex* AliITSVertexerCosmics::FindVertexForCurrentEvent(TTree *itsClusterTree) |
3acc14d5 | 86 | { |
87 | // Defines the AliESDVertex for the current event | |
88 | ||
89 | fCurrentVertex = 0; | |
3acc14d5 | 90 | |
91 | TClonesArray *recpoints=new TClonesArray("AliITSRecPoint",10000); | |
308c2f7c | 92 | itsClusterTree->SetBranchAddress("ITSRecPoints",&recpoints); |
3acc14d5 | 93 | |
3acc14d5 | 94 | Int_t lay,lad,det; |
95 | ||
81ba01de | 96 | Double_t pos[3]={0.,0.,0.}; |
97 | Double_t err[3]={100.,100.,100.}; | |
98 | Int_t ncontributors = -1; | |
99 | ||
b8ed1a92 | 100 | // Search for innermost layer with at least two clusters |
101 | // on two different modules | |
81ba01de | 102 | Int_t ilayer=0,ilayer2=0; |
b8ed1a92 | 103 | while(ilayer<6) { |
81ba01de | 104 | if(AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer)) { |
105 | ilayer++; | |
106 | continue; | |
107 | } | |
b8ed1a92 | 108 | Int_t nHitModules=0; |
109 | for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer]; imodule++) { | |
308c2f7c | 110 | itsClusterTree->GetEvent(imodule); |
b8ed1a92 | 111 | AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det); |
112 | lay -= 1; // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5 | |
113 | if(lay!=ilayer) AliFatal("Layer mismatch!"); | |
114 | if(recpoints->GetEntriesFast()>0) nHitModules++; | |
115 | } | |
116 | if(nHitModules>=2) break; | |
117 | ilayer++; | |
118 | } | |
81ba01de | 119 | |
120 | ilayer2=ilayer+1; | |
121 | while(ilayer2<6) { | |
122 | if(!AliITSReconstructor::GetRecoParam()->GetLayersToSkip(ilayer2)) break; | |
123 | ilayer2++; | |
124 | } | |
125 | ||
7e33c4e6 | 126 | // try tracklet on SPD2 and point on SPD1 |
8403ece4 | 127 | if(ilayer==1 && !AliITSReconstructor::GetRecoParam()->GetLayersToSkip(0)) {ilayer=0; ilayer2=1;} |
81ba01de | 128 | |
129 | if(ilayer>4 || ilayer2>5) { | |
130 | AliWarning("Not enough clusters"); | |
131 | delete recpoints; | |
81ba01de | 132 | fCurrentVertex = new AliESDVertex(pos,err,"cosmics"); |
133 | fCurrentVertex->SetTitle("cosmics fake vertex (failed)"); | |
134 | fCurrentVertex->SetNContributors(ncontributors); | |
135 | return fCurrentVertex; | |
136 | } | |
137 | ||
b8ed1a92 | 138 | |
a1fca0e6 | 139 | const Int_t arrSize = 1000; |
140 | Float_t xclInnLay[arrSize],yclInnLay[arrSize],zclInnLay[arrSize],modclInnLay[arrSize]; | |
141 | Float_t e2xclInnLay[arrSize],e2yclInnLay[arrSize],e2zclInnLay[arrSize]; | |
81ba01de | 142 | Float_t e2xclOutLay[arrSize],e2yclOutLay[arrSize],e2zclOutLay[arrSize]; |
b8ed1a92 | 143 | Int_t nclInnLayStored=0; |
a1fca0e6 | 144 | Float_t xclOutLay[arrSize],yclOutLay[arrSize],zclOutLay[arrSize],modclOutLay[arrSize]; |
b8ed1a92 | 145 | Int_t nclOutLayStored=0; |
146 | Int_t nRecPoints,nRecPointsInnLay=0; | |
147 | ||
148 | Float_t gc[3],gcov[5]; | |
149 | ||
81ba01de | 150 | Float_t matchOutLayValue; |
151 | Float_t distxyInnLay,distxyInnLayBest=0.; | |
b8ed1a92 | 152 | Double_t p1[3],p2[3],p3[3]; |
81ba01de | 153 | |
b8ed1a92 | 154 | Float_t xvtx,yvtx,zvtx,rvtx; |
81ba01de | 155 | Int_t i1InnLayBest=-1,i2InnLayBest=-1; |
3acc14d5 | 156 | |
b107ee21 | 157 | |
b8ed1a92 | 158 | // Collect clusters in the selected layer and the outer one |
81ba01de | 159 | for(Int_t imodule=fFirst[ilayer]; imodule<=fLast[ilayer2]; imodule++) { |
308c2f7c | 160 | itsClusterTree->GetEvent(imodule); |
0333e459 | 161 | AliITSgeomTGeo::GetModuleId(imodule,lay,lad,det); |
b8ed1a92 | 162 | lay -= 1; // AliITSgeomTGeo gives layer from 1 to 6, we want 0 to 5 |
163 | nRecPoints=recpoints->GetEntriesFast(); | |
164 | if(imodule<=fLast[ilayer]) nRecPointsInnLay += nRecPoints; | |
165 | //printf("cosmics: module %d clusters %d\n",imodule,nRecPoints); | |
166 | for(Int_t irp=0; irp<nRecPoints; irp++) { | |
3acc14d5 | 167 | AliITSRecPoint *rp=(AliITSRecPoint*)recpoints->UncheckedAt(irp); |
168 | // Local coordinates of this recpoint | |
b8ed1a92 | 169 | rp->GetGlobalXYZ(gc); |
170 | if(lay==ilayer) { // store InnLay clusters | |
171 | xclInnLay[nclInnLayStored]=gc[0]; | |
172 | yclInnLay[nclInnLayStored]=gc[1]; | |
173 | zclInnLay[nclInnLayStored]=gc[2]; | |
174 | rp->GetGlobalCov(gcov); | |
175 | e2xclInnLay[nclInnLayStored]=gcov[0]; | |
176 | e2yclInnLay[nclInnLayStored]=gcov[3]; | |
177 | e2zclInnLay[nclInnLayStored]=gcov[5]; | |
178 | modclInnLay[nclInnLayStored]=imodule; | |
179 | nclInnLayStored++; | |
3acc14d5 | 180 | } |
81ba01de | 181 | if(lay==ilayer2) { // store OutLay clusters |
b8ed1a92 | 182 | xclOutLay[nclOutLayStored]=gc[0]; |
183 | yclOutLay[nclOutLayStored]=gc[1]; | |
184 | zclOutLay[nclOutLayStored]=gc[2]; | |
81ba01de | 185 | rp->GetGlobalCov(gcov); |
186 | e2xclOutLay[nclOutLayStored]=gcov[0]; | |
187 | e2yclOutLay[nclOutLayStored]=gcov[3]; | |
188 | e2zclOutLay[nclOutLayStored]=gcov[5]; | |
b8ed1a92 | 189 | modclOutLay[nclOutLayStored]=imodule; |
190 | nclOutLayStored++; | |
3acc14d5 | 191 | } |
b107ee21 | 192 | if(nclInnLayStored>arrSize || nclOutLayStored>arrSize) { |
193 | //AliFatal("More than arrSize clusters per layer"); | |
194 | AliWarning("Too many clusters per layer"); | |
195 | delete recpoints; | |
b107ee21 | 196 | fCurrentVertex = new AliESDVertex(pos,err,"cosmics"); |
197 | fCurrentVertex->SetTitle("cosmics fake vertex (failed)"); | |
198 | fCurrentVertex->SetNContributors(ncontributors); | |
199 | return fCurrentVertex; | |
200 | } | |
3acc14d5 | 201 | }// end clusters in a module |
b8ed1a92 | 202 | }// end modules |
3acc14d5 | 203 | |
81ba01de | 204 | |
205 | Int_t i1InnLay,i2InnLay,iOutLay; | |
206 | ||
3acc14d5 | 207 | // build fake vertices |
81ba01de | 208 | printf("Building tracklets on layer %d\n",ilayer); |
209 | ||
b8ed1a92 | 210 | // InnLay - first cluster |
81ba01de | 211 | for(i1InnLay=0; i1InnLay<nclInnLayStored; i1InnLay++) { |
b8ed1a92 | 212 | p1[0]=xclInnLay[i1InnLay]; |
213 | p1[1]=yclInnLay[i1InnLay]; | |
214 | p1[2]=zclInnLay[i1InnLay]; | |
215 | // InnLay - second cluster | |
81ba01de | 216 | for(i2InnLay=i1InnLay+1; i2InnLay<nclInnLayStored; i2InnLay++) { |
b8ed1a92 | 217 | if(modclInnLay[i1InnLay]==modclInnLay[i2InnLay]) continue; |
218 | p2[0]=xclInnLay[i2InnLay]; | |
219 | p2[1]=yclInnLay[i2InnLay]; | |
220 | p2[2]=zclInnLay[i2InnLay]; | |
221 | // look for point on OutLay | |
81ba01de | 222 | AliStrLine innLayline(p1,p2,kTRUE); |
223 | for(iOutLay=0; iOutLay<nclOutLayStored; iOutLay++) { | |
b8ed1a92 | 224 | p3[0]=xclOutLay[iOutLay]; |
225 | p3[1]=yclOutLay[iOutLay]; | |
226 | p3[2]=zclOutLay[iOutLay]; | |
7e33c4e6 | 227 | //printf("(%f,%f) (%f,%f) (%f,%f) %f\n",p1[0],p1[1],p2[0],p2[1],p3[0],p3[1],innLayline.GetDistFromPoint(p3)); |
81ba01de | 228 | matchOutLayValue=innLayline.GetDistFromPoint(p3); |
229 | distxyInnLay = (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]); | |
230 | if(matchOutLayValue<fMaxDistOnOuterLayer && | |
231 | distxyInnLay>distxyInnLayBest) { | |
7e33c4e6 | 232 | //printf("found\n"); |
81ba01de | 233 | distxyInnLayBest=distxyInnLay; |
234 | i1InnLayBest=i1InnLay; | |
235 | i2InnLayBest=i2InnLay; | |
236 | } | |
3acc14d5 | 237 | } |
b8ed1a92 | 238 | } // InnLay - second cluster |
239 | } // InnLay - first cluster | |
3acc14d5 | 240 | |
81ba01de | 241 | if(i1InnLayBest>-1 && i2InnLayBest>-1) { |
242 | xvtx = 0.5*(xclInnLay[i1InnLayBest]+xclInnLay[i2InnLayBest]); | |
243 | yvtx = 0.5*(yclInnLay[i1InnLayBest]+yclInnLay[i2InnLayBest]); | |
244 | zvtx = 0.5*(zclInnLay[i1InnLayBest]+zclInnLay[i2InnLayBest]); | |
245 | rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx); | |
246 | if(rvtx<fMaxVtxRadius[ilayer]) { | |
247 | ncontributors = ilayer; | |
248 | pos[0] = xvtx; | |
249 | pos[1] = yvtx; | |
250 | pos[2] = zvtx; | |
251 | err[0]=TMath::Sqrt(0.25*(e2xclInnLay[i1InnLayBest]+e2xclInnLay[i2InnLayBest])); | |
252 | err[1]=TMath::Sqrt(0.25*(e2yclInnLay[i1InnLayBest]+e2yclInnLay[i2InnLayBest])); | |
253 | err[2]=TMath::Sqrt(0.25*(e2zclInnLay[i1InnLayBest]+e2zclInnLay[i2InnLayBest])); | |
254 | } | |
81ba01de | 255 | |
7e33c4e6 | 256 | } else { // give it a try exchanging InnLay and OutLay |
257 | ||
81ba01de | 258 | // OutLay - first cluster |
259 | for(i1InnLay=0; i1InnLay<nclOutLayStored; i1InnLay++) { | |
260 | p1[0]=xclOutLay[i1InnLay]; | |
261 | p1[1]=yclOutLay[i1InnLay]; | |
262 | p1[2]=zclOutLay[i1InnLay]; | |
263 | // OutLay - second cluster | |
264 | for(i2InnLay=i1InnLay+1; i2InnLay<nclOutLayStored; i2InnLay++) { | |
265 | if(modclOutLay[i1InnLay]==modclOutLay[i2InnLay]) continue; | |
266 | p2[0]=xclOutLay[i2InnLay]; | |
267 | p2[1]=yclOutLay[i2InnLay]; | |
268 | p2[2]=zclOutLay[i2InnLay]; | |
269 | // look for point on InnLay | |
270 | AliStrLine outLayline(p1,p2,kTRUE); | |
271 | for(iOutLay=0; iOutLay<nclInnLayStored; iOutLay++) { | |
272 | p3[0]=xclInnLay[iOutLay]; | |
273 | p3[1]=yclInnLay[iOutLay]; | |
274 | p3[2]=zclInnLay[iOutLay]; | |
275 | //printf(" %f\n",InnLayline.GetDistFromPoint(p3)); | |
276 | matchOutLayValue=outLayline.GetDistFromPoint(p3); | |
277 | distxyInnLay = (p1[0]-p2[0])*(p1[0]-p2[0])+(p1[1]-p2[1])*(p1[1]-p2[1]); | |
278 | if(matchOutLayValue<fMaxDistOnOuterLayer && | |
279 | distxyInnLay>distxyInnLayBest) { | |
280 | distxyInnLayBest=distxyInnLay; | |
281 | i1InnLayBest=i1InnLay; | |
282 | i2InnLayBest=i2InnLay; | |
283 | } | |
284 | } | |
285 | } // OutLay - second cluster | |
286 | } // OutLay - first cluster | |
81ba01de | 287 | |
7e33c4e6 | 288 | if(i1InnLayBest>-1 && i2InnLayBest>-1) { |
289 | xvtx = 0.5*(xclOutLay[i1InnLayBest]+xclOutLay[i2InnLayBest]); | |
290 | yvtx = 0.5*(yclOutLay[i1InnLayBest]+yclOutLay[i2InnLayBest]); | |
291 | zvtx = 0.5*(zclOutLay[i1InnLayBest]+zclOutLay[i2InnLayBest]); | |
292 | rvtx = TMath::Sqrt(xvtx*xvtx+yvtx*yvtx); | |
293 | if(rvtx<fMaxVtxRadius[ilayer]) { | |
294 | ncontributors = ilayer2; | |
295 | pos[0] = xvtx; | |
296 | pos[1] = yvtx; | |
297 | pos[2] = zvtx; | |
298 | err[0]=TMath::Sqrt(0.25*(e2xclOutLay[i1InnLayBest]+e2xclOutLay[i2InnLayBest])); | |
299 | err[1]=TMath::Sqrt(0.25*(e2yclOutLay[i1InnLayBest]+e2yclOutLay[i2InnLayBest])); | |
300 | err[2]=TMath::Sqrt(0.25*(e2zclOutLay[i1InnLayBest]+e2zclOutLay[i2InnLayBest])); | |
301 | } | |
81ba01de | 302 | } |
7e33c4e6 | 303 | } // give it a try exchanging InnLay and OutLay |
b107ee21 | 304 | |
3acc14d5 | 305 | fCurrentVertex = new AliESDVertex(pos,err,"cosmics"); |
3acc14d5 | 306 | fCurrentVertex->SetTitle("cosmics fake vertex"); |
b107ee21 | 307 | fCurrentVertex->SetNContributors(ncontributors); |
308 | //fCurrentVertex->Print(); | |
3acc14d5 | 309 | |
310 | delete recpoints; | |
3acc14d5 | 311 | |
312 | return fCurrentVertex; | |
313 | } | |
308c2f7c | 314 | |
3acc14d5 | 315 | //------------------------------------------------------------------------- |
316 | void AliITSVertexerCosmics::PrintStatus() const | |
317 | { | |
318 | // Print current status | |
319 | printf("=======================================================\n"); | |
b8ed1a92 | 320 | printf(" fMaxDistOnOuterLayer: %f\n",fMaxDistOnOuterLayer); |
321 | printf(" fMaxVtxRadius[0]: %f\n",fMaxVtxRadius[0]); | |
3acc14d5 | 322 | printf(" fMinDist2Vtxs: %f\n",fMinDist2Vtxs); |
3acc14d5 | 323 | printf("=======================================================\n"); |
324 | } | |
325 | //------------------------------------------------------------------------- |