]>
Commit | Line | Data |
---|---|---|
32d38de2 | 1 | #include <TClonesArray.h> |
a11ef2e4 | 2 | #include "AliITSURecoLayer.h" |
a11ef2e4 | 3 | #include "AliITSsegmentation.h" |
a11ef2e4 | 4 | #include "AliITSUAux.h" |
32d38de2 | 5 | #include "AliITSUClusterPix.h" |
8b16dbae | 6 | #include "AliITSUGeomTGeo.h" |
7 | #include "AliLog.h" | |
a11ef2e4 | 8 | |
9 | using namespace AliITSUAux; | |
10 | using namespace TMath; | |
11 | ||
12 | ClassImp(AliITSURecoLayer) | |
13 | ||
14 | ||
15 | //______________________________________________________ | |
16 | AliITSURecoLayer::AliITSURecoLayer(const char* name) | |
17 | :fActiveID(-1) | |
18 | ,fNSensors(0) | |
19 | ,fNSensInLadder(0) | |
20 | ,fNLadders(0) | |
21 | ,fR(0) | |
22 | ,fRMax(0) | |
23 | ,fRMin(0) | |
24 | ,fZMax(0) | |
25 | ,fZMin(0) | |
26 | ,fPhiLadMax(0) | |
27 | ,fPhiLadMin(0) | |
28 | ,fPhiOffs(0) | |
29 | ,fSensDZInv(0) | |
30 | ,fDPhiLadInv(0) | |
32d38de2 | 31 | ,fMaxStep(0.5) |
a11ef2e4 | 32 | ,fSensors(0) |
33 | ,fITSGeom(0) | |
32d38de2 | 34 | ,fClusters(0) |
a11ef2e4 | 35 | { |
36 | // def. c-tor | |
37 | SetNameTitle(name,name); | |
a11ef2e4 | 38 | } |
39 | ||
40 | //______________________________________________________ | |
32d38de2 | 41 | AliITSURecoLayer::AliITSURecoLayer(const char* name, Int_t activeID, AliITSUGeomTGeo* gm) |
a11ef2e4 | 42 | :fActiveID(activeID) |
43 | ,fNSensors(0) | |
44 | ,fNSensInLadder(0) | |
45 | ,fNLadders(0) | |
46 | ,fR(0) | |
47 | ,fRMax(0) | |
48 | ,fRMin(0) | |
49 | ,fZMax(0) | |
50 | ,fZMin(0) | |
51 | ,fPhiLadMax(0) | |
52 | ,fPhiLadMin(0) | |
53 | ,fPhiOffs(0) | |
54 | ,fSensDZInv(0) | |
55 | ,fDPhiLadInv(0) | |
32d38de2 | 56 | ,fMaxStep(0.5) |
57 | ,fSensors(0) | |
a11ef2e4 | 58 | ,fITSGeom(gm) |
32d38de2 | 59 | ,fClusters(0) |
a11ef2e4 | 60 | { |
61 | // def. c-tor | |
62 | SetNameTitle(name,name); | |
32d38de2 | 63 | Build(); |
a11ef2e4 | 64 | } |
65 | ||
66 | //______________________________________________________ | |
67 | AliITSURecoLayer::~AliITSURecoLayer() | |
68 | { | |
69 | // def. d-tor | |
32d38de2 | 70 | delete[] fSensors; |
71 | delete[] fPhiLadMax; | |
72 | delete[] fPhiLadMin; | |
ee52e7b5 | 73 | if (GetOwnsClusterArray()) delete fClusters; |
a11ef2e4 | 74 | } |
75 | ||
76 | //______________________________________________________ | |
77 | void AliITSURecoLayer::Print(Option_t* opt) const | |
78 | { | |
79 | ||
173b3073 | 80 | printf("Lr %-15s %d (act:%+d), NSens: %4d | MaxStep:%.2f ",GetName(),GetID(),GetActiveID(),GetNSensors(),fMaxStep); |
dde91d5d | 81 | printf("%6.3f<R<%6.3f | %+8.3f<Z<%+8.3f dZ:%6.3f\n",fRMin,fRMax,fZMin,fZMax,fSensDZInv>0 ? 1/fSensDZInv : 0); |
a11ef2e4 | 82 | TString opts = opt; opts.ToLower(); |
83 | if (opts.Contains("sn")) for (int i=0;i<GetNSensors();i++) GetSensor(i)->Print(opt); | |
84 | } | |
85 | ||
86 | //______________________________________________________ | |
32d38de2 | 87 | void AliITSURecoLayer::Build() |
a11ef2e4 | 88 | { |
89 | // build internal structures | |
32d38de2 | 90 | if (fActiveID<0) return; |
a11ef2e4 | 91 | fNLadders = fITSGeom->GetNLadders(fActiveID); |
92 | fNSensInLadder = fITSGeom->GetNDetectors(fActiveID); | |
32d38de2 | 93 | fNSensors = fNLadders*fNSensInLadder; |
94 | fSensors = new AliITSURecoSens*[fNSensors]; | |
546d00d8 | 95 | const AliITSsegmentation* kSegm = fITSGeom->GetSegmentation(fActiveID); |
a11ef2e4 | 96 | // |
97 | // name layer according its active id, detector type and segmentation tyoe | |
98 | TGeoHMatrix mmod; | |
99 | const TGeoHMatrix* mt2l; | |
100 | fRMin=fZMin=1e9; | |
101 | fRMax=fZMax=-1e9; | |
102 | double phiTF,rTF, loc[3]={0,0,0},glo[3]; | |
103 | fNSensors = 0; | |
104 | fPhiLadMin = new Double_t[fNLadders]; | |
105 | fPhiLadMax = new Double_t[fNLadders]; | |
106 | fSensDZInv = 0; | |
173b3073 | 107 | fDPhiLadInv = fNLadders/TwoPi(); |
a11ef2e4 | 108 | // |
109 | for (int ild=0;ild<fNLadders;ild++) { | |
110 | fPhiLadMin[ild] = 1e9; | |
111 | fPhiLadMax[ild] = -1e9; | |
112 | // | |
113 | for (int idt=0;idt<fNSensInLadder;idt++) { | |
114 | AliITSURecoSens* sens = new AliITSURecoSens(fNSensors++); | |
dde91d5d | 115 | fSensors[ild*fNSensInLadder+idt] = sens; |
a11ef2e4 | 116 | // |
117 | double phiMin=1e9,phiMax=-1e9,zMin=1e9,zMax=-1e9; | |
118 | mmod = *fITSGeom->GetMatrix(fActiveID,ild,idt); | |
119 | for (int ix=0;ix<2;ix++) { | |
546d00d8 | 120 | loc[0] = (ix-0.5)*kSegm->Dx(); // +-DX/2 |
a11ef2e4 | 121 | for (int iy=0;iy<2;iy++) { |
546d00d8 | 122 | loc[1] = (iy-0.5)*kSegm->Dy(); // +-DY/2 |
a11ef2e4 | 123 | for (int iz=0;iz<2;iz++) { |
546d00d8 | 124 | loc[2] = (iz-0.5)*kSegm->Dz(); // +-DZ/2 |
a11ef2e4 | 125 | // |
126 | mmod.LocalToMaster(loc,glo); | |
127 | double phi = ATan2(glo[1],glo[0]); | |
128 | double r = glo[0]*glo[0] + glo[1]*glo[1]; | |
129 | if (fRMin>r) fRMin = r; | |
130 | if (fRMax<r) fRMax = r; | |
131 | BringTo02Pi(phi); | |
132 | if (phiMin>1e8) phiMin=phi; | |
133 | else if (!OKforPhiMin(phiMin,phi)) phiMin=phi; | |
134 | if (phiMax<-1e8) phiMax=phi; | |
135 | else if (!OKforPhiMax(phiMax,phi)) phiMax=phi; | |
dde91d5d | 136 | if (glo[2]>zMax) zMax=glo[2]; |
137 | if (glo[2]<zMin) zMin=glo[2]; | |
a11ef2e4 | 138 | } |
139 | } | |
140 | } | |
a11ef2e4 | 141 | sens->SetBoundaries(phiMin,phiMax,zMin,zMax); |
142 | mt2l = fITSGeom->GetMatrixT2L(fActiveID,ild,idt); | |
143 | mmod.Multiply(mt2l); | |
144 | loc[0]=loc[1]=loc[2]=0; | |
145 | mmod.LocalToMaster(loc,glo); | |
146 | rTF = Sqrt(glo[0]*glo[0] + glo[1]*glo[1]); // tracking params (misaligned) | |
147 | phiTF = ATan2(glo[1],glo[0]); | |
148 | BringTo02Pi(phiTF); | |
149 | // | |
150 | sens->SetXTF(rTF); | |
151 | sens->SetPhiTF(phiTF); | |
152 | // | |
153 | if (fPhiLadMin[ild]>1e8) fPhiLadMin[ild] = phiMin; | |
154 | else if (!OKforPhiMin(fPhiLadMin[ild],phiMin)) fPhiLadMin[ild] = phiMin; | |
155 | if (fPhiLadMax[ild]<-1e8) fPhiLadMax[ild] = phiMax; | |
156 | else if (!OKforPhiMax(fPhiLadMax[ild],phiMax)) fPhiLadMax[ild] = phiMax; | |
157 | if (fZMin>zMin) fZMin = zMin; | |
158 | if (fZMax<zMax) fZMax = zMax; | |
159 | // | |
dde91d5d | 160 | if (idt>0) fSensDZInv += zMax - GetSensor(ild,idt-1)->GetZMax(); // z interval to previous |
a11ef2e4 | 161 | } |
162 | } | |
163 | // | |
164 | fRMin = Sqrt(fRMin); | |
165 | fRMax = Sqrt(fRMax); | |
166 | fR = 0.5*(fRMin+fRMax); | |
167 | double dz = fNSensInLadder>0 ? fSensDZInv/(fNSensInLadder-1)/fNLadders : fZMax-fZMin; | |
168 | fSensDZInv = 1./dz; | |
169 | ||
170 | const int kNBId[3][3] = { | |
171 | {AliITSURecoSens::kNghbBL,AliITSURecoSens::kNghbB,AliITSURecoSens::kNghbBR}, | |
172 | {AliITSURecoSens::kNghbL, -1 ,AliITSURecoSens::kNghbR }, | |
173 | {AliITSURecoSens::kNghbTL,AliITSURecoSens::kNghbT,AliITSURecoSens::kNghbTR} | |
174 | }; | |
175 | ||
176 | // add neighbours info | |
177 | double zTol = 0.45*dz, phiTol = 0.45*TwoPi()/fNLadders; | |
178 | for (int ild=0;ild<fNLadders;ild++) { | |
179 | for (int idt=0;idt<fNSensInLadder;idt++) { | |
180 | AliITSURecoSens* sens = GetSensor(ild,idt); | |
181 | // | |
182 | for (int ils=-1;ils<=1;ils++) { | |
183 | int ildN = ild+ils; // ladders of neighbouring sensors | |
184 | if (ildN<0) ildN = fNLadders-1; else if (ildN==fNLadders) ildN = 0; | |
185 | for (int ids=-1;ids<=1;ids++) { | |
186 | int idtN = idt+ids; | |
187 | if (idtN<0 || idtN==fNSensInLadder || (ids==0&&ils==0)) continue; | |
188 | AliITSURecoSens* sensN = GetSensor(ildN,idtN); // potential neighbor | |
189 | int neighbID = ildN*fNSensInLadder+idtN; | |
190 | // | |
191 | int zType = 1; // side | |
32d38de2 | 192 | if (sens->GetZMin()-zTol > sensN->GetZMax()) continue; // too large distance |
193 | if (sensN->GetZMin()-zTol > sens->GetZMax() ) continue; // too large distance | |
a11ef2e4 | 194 | if (sens->GetZMin()-zTol>sensN->GetZMin()) zType = 0; // bottom |
195 | else if (sensN->GetZMin()-zTol>sens->GetZMin()) zType = 2; // top | |
196 | // | |
197 | int phiType = 1; | |
32d38de2 | 198 | |
a11ef2e4 | 199 | double phiTstMn = sensN->GetPhiMin()-phiTol; |
200 | BringTo02Pi(phiTstMn); | |
201 | if (!OKforPhiMax(sens->GetPhiMax(),phiTstMn)) continue; // too large angle | |
202 | double phiTstMx = sensN->GetPhiMax()+phiTol; | |
203 | BringTo02Pi(phiTstMx); | |
204 | if (!OKforPhiMin(sens->GetPhiMin(),phiTstMx)) continue; // too large angle | |
205 | // | |
206 | phiTstMn = sensN->GetPhiMin()+phiTol; | |
207 | BringTo02Pi(phiTstMn); | |
208 | phiTstMx = sensN->GetPhiMax()-phiTol; | |
209 | BringTo02Pi(phiTstMx); | |
210 | if (!OKforPhiMax(sens->GetPhiMax(),phiTstMx)) phiType = 0; // left | |
211 | else if (!OKforPhiMin(sens->GetPhiMin(),phiTstMn)) phiType = 2; // right | |
212 | // | |
213 | sens->SetNeighborID(kNBId[zType][phiType], neighbID); | |
214 | } // phi scan | |
215 | } // z scan | |
216 | } // sensors | |
217 | } // ladders | |
218 | // | |
a11ef2e4 | 219 | } |
220 | ||
221 | //______________________________________________________ | |
32d38de2 | 222 | Int_t AliITSURecoLayer::FindSensors(const double* impPar, AliITSURecoSens *sensors[AliITSURecoSens::kNNeighbors]) |
a11ef2e4 | 223 | { |
224 | // find sensors having intersection with track | |
225 | // impPar contains: lab phi of track, dphi, labZ, dz | |
226 | double z = impPar[2]; | |
0091e9f0 | 227 | if (z>fZMax+impPar[3]) return 0; // outside of Z coverage |
a11ef2e4 | 228 | z -= fZMin; |
0091e9f0 | 229 | if (z<-impPar[3]) return 0; // outside of Z coverage |
a11ef2e4 | 230 | int sensInLad = int(z*fSensDZInv); |
0091e9f0 | 231 | if (sensInLad<0) sensInLad = 0; |
232 | else if (sensInLad>=fNSensInLadder) sensInLad = fNSensInLadder-1; | |
a11ef2e4 | 233 | // |
234 | double phi = impPar[0] - fPhiOffs; | |
235 | BringTo02Pi(phi); | |
236 | int ladID = int(phi*fDPhiLadInv); // ladder id | |
237 | int nsens = 0; | |
238 | // | |
239 | AliITSURecoSens* sensN,*sens = GetSensor(ladID*fNSensInLadder+sensInLad); | |
240 | sensors[nsens++] = sens; | |
241 | // check neighbours | |
242 | double zMn=impPar[2]-impPar[3], zMx=impPar[2]+impPar[3], phiMn=impPar[0]-impPar[1], phiMx=impPar[0]+impPar[1]; | |
243 | BringTo02Pi(phiMn); | |
244 | BringTo02Pi(phiMx); | |
245 | // | |
173b3073 | 246 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbR)); // neighbor on the right (smaller phi) |
247 | if (sensN && OKforPhiMin(phiMn,sensN->GetPhiMax())) sensors[nsens++] = sensN; | |
a11ef2e4 | 248 | // |
173b3073 | 249 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbTR)); // neighbor on the top right (smaller phi, larger Z) |
250 | if (sensN && OKforPhiMin(phiMn,sensN->GetPhiMax()) && sensN->GetZMin()<zMx) sensors[nsens++] = sensN; | |
a11ef2e4 | 251 | // |
173b3073 | 252 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbT)); // neighbor on the top (larger Z) |
253 | if (sensN && sensN->GetZMin()<zMx) sensors[nsens++] = sensN; | |
a11ef2e4 | 254 | // |
173b3073 | 255 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbTL)); // neighbor on the top left (larger Z, larger phi) |
256 | if (sensN && OKforPhiMax(phiMx,sensN->GetPhiMin()) && sensN->GetZMin()<zMx) sensors[nsens++] = sensN; | |
a11ef2e4 | 257 | // |
173b3073 | 258 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbL)); // neighbor on the left (larger phi) |
259 | if (sensN && OKforPhiMax(phiMx,sensN->GetPhiMin())) sensors[nsens++] = sensN; | |
a11ef2e4 | 260 | // |
173b3073 | 261 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbBL)); // neighbor on the bottom left (smaller Z, larger phi) |
262 | if (sensN && OKforPhiMax(phiMx,sensN->GetPhiMin()) && sensN->GetZMax()>zMn) sensors[nsens++] = sensN; | |
a11ef2e4 | 263 | // |
173b3073 | 264 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbB)); // neighbor on the bottom (smaller Z) |
a11ef2e4 | 265 | if (sensN && sensN->GetZMax()>zMn) sensors[nsens++] = sensN; |
266 | // | |
173b3073 | 267 | sensN = GetSensor(sens->GetNeighborID(AliITSURecoSens::kNghbBR)); // neighbor on the bottom right (smaller Z, smaller phi) |
268 | if (sensN && OKforPhiMin(phiMn,sensN->GetPhiMax()) && sensN->GetZMax()>zMn) sensors[nsens++] = sensN; | |
a11ef2e4 | 269 | // |
270 | return nsens; | |
271 | } | |
272 | ||
32d38de2 | 273 | //______________________________________________________ |
274 | void AliITSURecoLayer::ProcessClusters(Int_t mode) | |
275 | { | |
276 | // register in each sensor of the layer its cluster. | |
277 | // the clusters of the layer must be sorted per sensor | |
278 | int ncl = fClusters->GetEntriesFast(); | |
279 | int curSensID = -1; | |
0091e9f0 | 280 | for (int i=fNSensors;i--;) GetSensor(i)->SetNClusters(0); |
32d38de2 | 281 | AliITSURecoSens* curSens = 0; |
282 | for (int icl=0;icl<ncl;icl++) { | |
283 | AliITSUClusterPix* cl = (AliITSUClusterPix*) fClusters->UncheckedAt(icl); | |
284 | cl->GoToFrameTrk(); | |
285 | int vID = cl->GetVolumeId(); | |
286 | if (vID<curSensID) {AliFatal("Clusters are not sorted in increasing sensorID");} | |
287 | if (vID>curSensID) { | |
288 | if (curSens) curSens->ProcessClusters(mode); // prepare clusters for reconstruction | |
289 | curSens = GetSensor(vID - fITSGeom->GetFirstModIndex(fActiveID)); | |
290 | curSensID = vID; | |
291 | curSens->SetFirstClusterId(icl); | |
292 | } | |
293 | curSens->IncNClusters(); | |
294 | } | |
295 | if (curSens) curSens->ProcessClusters(mode); // last sensor was not processed yet | |
296 | // | |
297 | } | |
dde91d5d | 298 | |
299 | //______________________________________________________ | |
300 | Bool_t AliITSURecoLayer::IsEqual(const TObject* obj) const | |
301 | { | |
302 | // check if layers are equal in R | |
44785f3e | 303 | const AliITSURecoLayer* lr = (const AliITSURecoLayer*)obj; |
dde91d5d | 304 | return Abs(lr->GetR()-GetR())<1e-6 ? kTRUE : kFALSE; |
305 | } | |
306 | ||
307 | //______________________________________________________ | |
308 | Int_t AliITSURecoLayer::Compare(const TObject* obj) const | |
309 | { | |
310 | // compare two layers | |
44785f3e | 311 | const AliITSURecoLayer* lr = (const AliITSURecoLayer*)obj; |
dde91d5d | 312 | double dr = GetR() - lr->GetR(); |
313 | if (Abs(dr)<1e-6) return 0; | |
314 | return dr>0 ? 1:-1; | |
315 | // | |
316 | } | |
8b16dbae | 317 | |
318 | //_________________________________________________________________ | |
319 | AliITSURecoSens* AliITSURecoLayer::GetSensorFromID(Int_t i) const | |
320 | { | |
321 | // get sensor from its global id | |
322 | i -= fITSGeom->GetFirstModIndex(fActiveID); | |
323 | if (i<0||i>=fNSensors) AliFatal(Form("Sensor with id=%d is not in layer %d",i+fITSGeom->GetFirstModIndex(fActiveID),fActiveID)); | |
324 | return (AliITSURecoSens*)fSensors[i]; | |
325 | } |