]>
Commit | Line | Data |
---|---|---|
d15a28e7 | 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 | **************************************************************************/ | |
b2a60966 | 15 | /* $Id$ */ |
702ab87e | 16 | |
17 | /* History of cvs commits: | |
18 | * | |
19 | * $Log$ | |
04236e67 | 20 | * Revision 1.93 2007/10/10 09:05:10 schutz |
21 | * Changing name QualAss to QA | |
22 | * | |
b8274834 | 23 | * Revision 1.92 2007/08/28 12:55:08 policheh |
24 | * Loaders removed from the reconstruction code (C.Cheshkov) | |
25 | * | |
9a2cdbdf | 26 | * Revision 1.91 2007/08/07 14:12:03 kharlov |
27 | * Quality assurance added (Yves Schutz) | |
28 | * | |
ddd1a39c | 29 | * Revision 1.90 2007/07/11 13:43:30 hristov |
30 | * New class AliESDEvent, backward compatibility with the old AliESD (Christian) | |
31 | * | |
af885e0f | 32 | * Revision 1.89 2007/07/03 08:13:04 kharlov |
33 | * Bug fix in CPV local coordinates | |
34 | * | |
b22f5347 | 35 | * Revision 1.88 2007/06/27 09:11:07 kharlov |
36 | * Bug fix for CPV-EMC distance | |
37 | * | |
78881c42 | 38 | * Revision 1.87 2007/05/04 14:49:29 policheh |
39 | * AliPHOSRecPoint inheritance from AliCluster | |
40 | * | |
9ee9f78d | 41 | * Revision 1.86 2007/04/02 15:00:16 cvetan |
42 | * No more calls to gAlice in the reconstruction | |
43 | * | |
999f9a8f | 44 | * Revision 1.85 2007/03/28 19:18:15 kharlov |
45 | * RecPoints recalculation in TSM removed | |
46 | * | |
8c1fb709 | 47 | * Revision 1.84 2007/03/07 07:01:21 hristov |
48 | * Fixing copy/paste erro. Additional protections | |
49 | * | |
b89c16b2 | 50 | * Revision 1.83 2007/03/06 21:07:37 kharlov |
51 | * DP: xz CPV-EMC distance filled to TS | |
52 | * | |
d7ddbb70 | 53 | * Revision 1.82 2007/03/06 06:54:48 kharlov |
54 | * DP:Calculation of cluster properties dep. on vertex added | |
55 | * | |
e84d3def | 56 | * Revision 1.81 2007/02/05 10:02:40 kharlov |
57 | * Module numbering is corrected | |
58 | * | |
a2ee5b34 | 59 | * Revision 1.80 2006/08/28 10:01:56 kharlov |
60 | * Effective C++ warnings fixed (Timur Pocheptsov) | |
61 | * | |
3663622c | 62 | * Revision 1.79 2006/04/25 12:41:15 hristov |
63 | * Moving non-persistent data to AliESDfriend (Yu.Belikov) | |
64 | * | |
15e85efa | 65 | * Revision 1.78 2005/11/18 13:04:51 hristov |
66 | * Bug fix | |
67 | * | |
a494460a | 68 | * Revision 1.77 2005/11/17 23:34:36 hristov |
69 | * Corrected logics | |
70 | * | |
f74a631d | 71 | * Revision 1.76 2005/11/17 22:29:12 hristov |
72 | * Faster version, no attempt to match tracks outside the PHOS acceptance | |
73 | * | |
0d9aa319 | 74 | * Revision 1.75 2005/11/17 12:35:27 hristov |
75 | * Use references instead of objects. Avoid to create objects when they are not really needed | |
76 | * | |
7b51037f | 77 | * Revision 1.74 2005/07/08 14:01:36 hristov |
78 | * Tracking in non-uniform nmagnetic field (Yu.Belikov) | |
79 | * | |
c84a5e9e | 80 | * Revision 1.73 2005/05/28 14:19:05 schutz |
81 | * Compilation warnings fixed by T.P. | |
82 | * | |
702ab87e | 83 | */ |
84 | ||
d15a28e7 | 85 | //_________________________________________________________________________ |
b2a60966 | 86 | // Implementation version 1 of algorithm class to construct PHOS track segments |
f035f6ce | 87 | // Track segment for PHOS is list of |
194f9939 | 88 | // EMC RecPoint + (possibly) CPV RecPoint |
a4e98857 | 89 | // To find TrackSegments we do the following: |
90 | // for each EMC RecPoints we look at | |
194f9939 | 91 | // CPV RecPoints in the radious fRcpv. |
a4e98857 | 92 | // If there is such a CPV RecPoint, |
194f9939 | 93 | // we make "Link" it is just indexes of EMC and CPV RecPoint and distance |
a4e98857 | 94 | // between them in the PHOS plane. |
95 | // Then we sort "Links" and starting from the | |
96 | // least "Link" pointing to the unassined EMC and CPV RecPoints assing them to | |
97 | // new TrackSegment. | |
194f9939 | 98 | // If there is no CPV RecPoint we make TrackSegment |
a4e98857 | 99 | // consisting from EMC alone. There is no TrackSegments without EMC RecPoint. |
f444a19f | 100 | //// In principle this class should be called from AliPHOSReconstructor, but |
a4e98857 | 101 | // one can use it as well in standalone mode. |
102 | // Use case: | |
fc12304f | 103 | // root [0] AliPHOSTrackSegmentMakerv1 * t = new AliPHOSTrackSegmentMaker("galice.root", "tracksegmentsname", "recpointsname") |
a4e98857 | 104 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
fc12304f | 105 | // // reads gAlice from header file "galice.root", uses recpoints stored in the branch names "recpointsname" (default = "Default") |
106 | // // and saves recpoints in branch named "tracksegmentsname" (default = "recpointsname") | |
a4e98857 | 107 | // root [1] t->ExecuteTask() |
a4e98857 | 108 | // root [3] t->SetTrackSegmentsBranch("max distance 5 cm") |
109 | // root [4] t->ExecuteTask("deb all time") | |
f035f6ce | 110 | // |
fc12304f | 111 | //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH) & Yves Schutz (SUBATECH) |
b2a60966 | 112 | // |
d15a28e7 | 113 | |
114 | // --- ROOT system --- | |
f96711b8 | 115 | #include "TVector3.h" |
2731cd1e | 116 | #include "TTree.h" |
2731cd1e | 117 | #include "TBenchmark.h" |
d15a28e7 | 118 | |
21cd0c07 | 119 | // --- Standard library --- |
194f9939 | 120 | #include "Riostream.h" |
d15a28e7 | 121 | // --- AliRoot header files --- |
e957fea8 | 122 | #include "AliPHOSGeometry.h" |
d15a28e7 | 123 | #include "AliPHOSTrackSegmentMakerv1.h" |
124 | #include "AliPHOSTrackSegment.h" | |
125 | #include "AliPHOSLink.h" | |
af885e0f | 126 | #include "AliESDEvent.h" |
aa0b9641 | 127 | #include "AliESDtrack.h" |
9a2cdbdf | 128 | #include "AliPHOSEmcRecPoint.h" |
129 | #include "AliPHOSCpvRecPoint.h" | |
96351742 | 130 | #include "AliLog.h" |
f96711b8 | 131 | #include "AliMagF.h" |
c5a539a3 | 132 | #include "AliMagF.h" |
133 | #include "AliTracker.h" | |
134 | #include "AliGeomManager.h" | |
135 | #include "AliCluster.h" | |
136 | #include "AliKalmanTrack.h" | |
137 | #include "AliGlobalQADataMaker.h" | |
138 | #include "AliVParticle.h" | |
139 | ||
d15a28e7 | 140 | |
141 | ClassImp( AliPHOSTrackSegmentMakerv1) | |
142 | ||
143 | ||
144 | //____________________________________________________________________________ | |
3663622c | 145 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : |
146 | AliPHOSTrackSegmentMaker(), | |
147 | fDefaultInit(kTRUE), | |
148 | fWrite(kFALSE), | |
149 | fNTrackSegments(0), | |
150 | fRcpv(0.f), | |
151 | fRtpc(0.f), | |
4c85a8d0 | 152 | fVtx(0.f,0.f,0.f), |
3663622c | 153 | fLinkUpArray(0), |
154 | fEmcFirst(0), | |
155 | fEmcLast(0), | |
156 | fCpvFirst(0), | |
157 | fCpvLast(0), | |
158 | fModule(0), | |
9a2cdbdf | 159 | fTrackSegments(NULL) |
d15a28e7 | 160 | { |
7b7c1533 | 161 | // default ctor (to be used mainly by Streamer) |
8d0f3f77 | 162 | InitParameters() ; |
d15a28e7 | 163 | } |
7b7c1533 | 164 | |
9f616d61 | 165 | //____________________________________________________________________________ |
9a2cdbdf | 166 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(AliPHOSGeometry *geom) : |
167 | AliPHOSTrackSegmentMaker(geom), | |
3663622c | 168 | fDefaultInit(kFALSE), |
169 | fWrite(kFALSE), | |
170 | fNTrackSegments(0), | |
171 | fRcpv(0.f), | |
172 | fRtpc(0.f), | |
e483564c | 173 | fVtx(0.f,0.f,0.f), |
3663622c | 174 | fLinkUpArray(0), |
175 | fEmcFirst(0), | |
176 | fEmcLast(0), | |
177 | fCpvFirst(0), | |
178 | fCpvLast(0), | |
179 | fModule(0), | |
9a2cdbdf | 180 | fTrackSegments(NULL) |
2731cd1e | 181 | { |
182 | // ctor | |
8d0f3f77 | 183 | InitParameters() ; |
7b7c1533 | 184 | Init() ; |
aa0b9641 | 185 | fESD = 0; |
2731cd1e | 186 | } |
98cbd830 | 187 | |
3663622c | 188 | |
189 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const AliPHOSTrackSegmentMakerv1 & tsm) : | |
190 | AliPHOSTrackSegmentMaker(tsm), | |
191 | fDefaultInit(kFALSE), | |
192 | fWrite(kFALSE), | |
193 | fNTrackSegments(0), | |
194 | fRcpv(0.f), | |
195 | fRtpc(0.f), | |
e483564c | 196 | fVtx(0.f,0.f,0.f), |
3663622c | 197 | fLinkUpArray(0), |
198 | fEmcFirst(0), | |
199 | fEmcLast(0), | |
200 | fCpvFirst(0), | |
201 | fCpvLast(0), | |
202 | fModule(0), | |
9a2cdbdf | 203 | fTrackSegments(NULL) |
3663622c | 204 | { |
205 | // cpy ctor: no implementation yet | |
206 | // requested by the Coding Convention | |
207 | Fatal("cpy ctor", "not implemented") ; | |
208 | } | |
209 | ||
210 | ||
2731cd1e | 211 | //____________________________________________________________________________ |
212 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() | |
213 | { | |
214 | // dtor | |
92f521a9 | 215 | // fDefaultInit = kTRUE if TrackSegmentMaker created by default ctor (to get just the parameters) |
88cb7938 | 216 | if (!fDefaultInit) |
217 | delete fLinkUpArray ; | |
9a2cdbdf | 218 | if (fTrackSegments) { |
219 | fTrackSegments->Delete(); | |
220 | delete fTrackSegments; | |
221 | } | |
fc12304f | 222 | } |
223 | ||
d15a28e7 | 224 | //____________________________________________________________________________ |
2731cd1e | 225 | void AliPHOSTrackSegmentMakerv1::FillOneModule() |
9f616d61 | 226 | { |
f035f6ce | 227 | // Finds first and last indexes between which |
228 | // clusters from one PHOS module are | |
88cb7938 | 229 | |
2731cd1e | 230 | //First EMC clusters |
9a2cdbdf | 231 | Int_t totalEmc = fEMCRecPoints->GetEntriesFast() ; |
2731cd1e | 232 | for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && |
09828f52 | 233 | ((static_cast<AliPHOSRecPoint *>(fEMCRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule ); |
2731cd1e | 234 | fEmcLast ++) ; |
235 | ||
2731cd1e | 236 | //Now CPV clusters |
9a2cdbdf | 237 | Int_t totalCpv = fCPVRecPoints->GetEntriesFast() ; |
6ad0bfa0 | 238 | |
2731cd1e | 239 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
09828f52 | 240 | ((static_cast<AliPHOSRecPoint *>(fCPVRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule ); |
88cb7938 | 241 | fCpvLast ++) ; |
9688c1dd | 242 | |
d15a28e7 | 243 | } |
7b7c1533 | 244 | |
d15a28e7 | 245 | //____________________________________________________________________________ |
e84d3def | 246 | void AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu, |
247 | AliPHOSCpvRecPoint * cpvClu, | |
248 | Int_t &trackindex, | |
249 | Float_t &dx, Float_t &dz) const | |
d15a28e7 | 250 | { |
194f9939 | 251 | // Calculates the distance between the EMC RecPoint and the CPV RecPoint |
e44c41e9 | 252 | // If no CPV, calculates the distance between the EMC RecPoint and the track |
253 | // prolongation to the PHOS module plane. | |
a4e98857 | 254 | // Clusters are sorted in "rows" and "columns" of width 1 cm |
f035f6ce | 255 | |
e84d3def | 256 | // Float_t delta = 1 ; // Width of the rows in sorting of RecPoints (in cm) |
257 | // // if you change this value, change it as well in xxxRecPoint::Compare() | |
194f9939 | 258 | |
146aa588 | 259 | trackindex = -1; |
260 | dx = 999.; | |
261 | dz = 999.; | |
262 | ||
e44c41e9 | 263 | if(!cpvClu) { |
96351742 | 264 | |
96351742 | 265 | if(!emcClu) { |
266 | return; | |
267 | } | |
e44c41e9 | 268 | |
f96711b8 | 269 | // *** Start the matching |
270 | Int_t nt=fESD->GetNumberOfTracks(); | |
271 | Int_t iPHOSMod = emcClu->GetPHOSMod() ; | |
272 | //Calculate actual distance to PHOS module | |
273 | TVector3 globaPos ; | |
274 | fGeom->Local2Global(iPHOSMod, 0.,0., globaPos) ; | |
4efbcb95 | 275 | const Double_t rPHOS = globaPos.Pt() ; //Distance to center of PHOS module |
f96711b8 | 276 | const Double_t kYmax = 72.+10. ; //Size of the module (with some reserve) in phi direction |
277 | const Double_t kZmax = 64.+10. ; //Size of the module (with some reserve) in z direction | |
72e230ec | 278 | const Double_t kAlpha0=330./180.*TMath::Pi() ; //First PHOS module angular direction |
4efbcb95 | 279 | const Double_t kAlpha= 20./180.*TMath::Pi() ; //PHOS module angular size |
f96711b8 | 280 | Double_t minDistance = 1.e6; |
281 | ||
4efbcb95 | 282 | TVector3 vecEmc ; // Local position of EMC recpoint |
283 | emcClu->GetLocalPosition(vecEmc) ; | |
f96711b8 | 284 | |
4efbcb95 | 285 | Double_t gposTrack[3] ; |
415ea4fe | 286 | Double_t bz = AliTracker::GetBz() ; //B-Field for approximate matching |
f96711b8 | 287 | Double_t b[3]; |
288 | for (Int_t i=0; i<nt; i++) { | |
289 | AliESDtrack *esdTrack=fESD->GetTrack(i); | |
290 | ||
4efbcb95 | 291 | // Skip the tracks having "wrong" status (has to be checked/tuned) |
292 | ULong_t status = esdTrack->GetStatus(); | |
293 | if ((status & AliESDtrack::kTPCout) == 0) continue; | |
f96711b8 | 294 | // if ((status & AliESDtrack::kTRDout) == 0) continue; |
295 | // if ((status & AliESDtrack::kTRDrefit) == 1) continue; | |
296 | ||
4efbcb95 | 297 | //Continue extrapolation from TPC outer surface |
298 | const AliExternalTrackParam *outerParam=esdTrack->GetOuterParam(); | |
299 | if (!outerParam) continue; | |
300 | AliExternalTrackParam t(*outerParam); | |
f96711b8 | 301 | |
4efbcb95 | 302 | t.GetBxByBz(b) ; |
303 | //Direction to the current PHOS module | |
72e230ec | 304 | Double_t phiMod=kAlpha0-kAlpha*iPHOSMod ; |
4efbcb95 | 305 | if(!t.Rotate(phiMod)) |
306 | continue ; | |
307 | ||
f96711b8 | 308 | Double_t y; // Some tracks do not reach the PHOS |
309 | if (!t.GetYAt(rPHOS,bz,y)) continue; // because of the bending | |
310 | ||
4efbcb95 | 311 | Double_t z; |
312 | if(!t.GetZAt(rPHOS,bz,z)) | |
313 | continue ; | |
314 | if (TMath::Abs(z) > kZmax) | |
315 | continue; // Some tracks miss the PHOS in Z | |
316 | if(TMath::Abs(y) < kYmax){ | |
317 | t.PropagateToBxByBz(rPHOS,b); // Propagate to the matching module | |
b2e9b669 | 318 | //t.CorrectForMaterial(...); // Correct for the TOF material, if needed |
4efbcb95 | 319 | t.GetXYZ(gposTrack) ; |
320 | TVector3 globalPositionTr(gposTrack) ; | |
321 | TVector3 localPositionTr ; | |
322 | fGeom->Global2Local(localPositionTr,globalPositionTr,iPHOSMod) ; | |
323 | Double_t ddx = vecEmc.X()-localPositionTr.X(); | |
324 | Double_t ddz = vecEmc.Z()-localPositionTr.Z(); | |
325 | Double_t d2 = ddx*ddx + ddz*ddz; | |
326 | if(d2 < minDistance) { | |
327 | dx = ddx ; | |
328 | dz = ddz ; | |
329 | trackindex=i; | |
330 | minDistance=d2 ; | |
331 | } | |
b2e9b669 | 332 | } |
4efbcb95 | 333 | } //Scanned all tracks |
b2e9b669 | 334 | return ; |
335 | } | |
f96711b8 | 336 | |
337 | ||
b2e9b669 | 338 | TVector3 emcGlobal; |
339 | fGeom->GetGlobalPHOS((AliPHOSRecPoint*)emcClu,emcGlobal); | |
96351742 | 340 | |
b2e9b669 | 341 | // Radius from IP to current point |
342 | Double_t rEMC = TMath::Abs(emcGlobal.Pt()); | |
96351742 | 343 | |
b2e9b669 | 344 | // Extrapolate the global track direction to EMC |
345 | // and find the closest track | |
96351742 | 346 | |
b2e9b669 | 347 | Int_t nTracks = fESD->GetNumberOfTracks(); |
e44c41e9 | 348 | |
b2e9b669 | 349 | AliESDtrack *track; |
350 | Double_t xyz[] = {-1,-1,-1}; | |
351 | Double_t pxyz[3]; | |
352 | Double_t zEMC,xEMC; | |
353 | Int_t module; | |
354 | TVector3 vecP; | |
355 | TVector3 locClu; | |
356 | ||
357 | Float_t minDistance = 1.e6; | |
358 | Float_t dr; | |
359 | ||
360 | for (Int_t iTrack=0; iTrack<nTracks; iTrack++) { | |
361 | track = fESD->GetTrack(iTrack); | |
362 | if (!track->GetXYZAt(rEMC, fESD->GetMagneticField(), xyz)) continue; | |
363 | ||
364 | AliDebug(1,Form("Event %d, iTrack: %d, (%.3f,%.3f,%.3f)", | |
365 | fESD->GetEventNumberInFile(),iTrack,xyz[0],xyz[1],xyz[2])); | |
96351742 | 366 | |
b2e9b669 | 367 | if (track->GetPxPyPzAt(rEMC,fESD->GetMagneticField(),pxyz)) { |
96351742 | 368 | |
b2e9b669 | 369 | vecP.SetXYZ(pxyz[0],pxyz[1],pxyz[2]); |
370 | fGeom->ImpactOnEmc(xyz,vecP.Theta(),vecP.Phi(),module,zEMC,xEMC) ; | |
96351742 | 371 | |
b2e9b669 | 372 | if(!module) continue; |
373 | AliDebug(1,Form("\t\tTrack hit PHOS! Module: %d, (x,z)=(%.3f,%.3f)",module,xEMC,zEMC)); | |
96351742 | 374 | |
b2e9b669 | 375 | if(emcClu->GetPHOSMod() != module) continue; |
96351742 | 376 | |
b2e9b669 | 377 | // match track to EMC cluster |
378 | emcClu->GetLocalPosition(locClu); | |
96351742 | 379 | |
b2e9b669 | 380 | Float_t delta_x = xEMC - locClu.X(); |
381 | Float_t delta_z = zEMC - locClu.Z(); | |
382 | dr = TMath::Sqrt(delta_x*delta_x + delta_z*delta_z); | |
383 | AliDebug(1,Form("\tMatch iTrack=%d: (dx,dz)=(%.3f,%.3f)",iTrack,delta_x,delta_z)); | |
96351742 | 384 | |
b2e9b669 | 385 | if(dr<minDistance) { |
386 | trackindex = iTrack; | |
387 | minDistance = dr; | |
388 | dx = delta_x; | |
389 | dz = delta_z; | |
e44c41e9 | 390 | } |
391 | } | |
b2e9b669 | 392 | |
e44c41e9 | 393 | } |
b2e9b669 | 394 | |
09828f52 | 395 | if(trackindex>=0) { |
b2e9b669 | 396 | AliDebug(1,Form("\t\tBest match for (xClu,zClu,eClu)=(%.3f,%.3f,%.3f): iTrack=%d, dR=%.3f", |
397 | locClu.X(),locClu.Z(),emcClu->GetEnergy(), | |
398 | trackindex,TMath::Sqrt(dx*dx+dz*dz))); | |
09828f52 | 399 | return; |
400 | } | |
e44c41e9 | 401 | |
402 | Float_t distance2Track = fRtpc ; | |
403 | ||
194f9939 | 404 | trackindex = -1 ; // closest track within fRCpv |
b2e9b669 | 405 | |
aa0b9641 | 406 | TVector3 vecEmc ; // Local position of EMC recpoint |
e84d3def | 407 | TVector3 vecPloc ; // Momentum direction at CPV plain |
2731cd1e | 408 | |
194f9939 | 409 | //toofar = kTRUE ; |
e84d3def | 410 | if(emcClu->GetPHOSMod() != cpvClu->GetPHOSMod()){ |
411 | dx=999. ; | |
412 | dz=999. ; | |
413 | return ; | |
414 | } | |
b2e9b669 | 415 | |
e84d3def | 416 | emcClu->GetLocalPosition(vecEmc) ; |
b2e9b669 | 417 | |
3da0f212 | 418 | Double_t xCPV=0,zCPV=0 ; //EMC-projected coordinates of CPV cluster |
e84d3def | 419 | TVector3 cpvGlobal; // Global position of the CPV recpoint |
9a2cdbdf | 420 | fGeom->GetGlobalPHOS((AliPHOSRecPoint*)cpvClu,cpvGlobal); |
e84d3def | 421 | Double_t vtxCPV[3]={cpvGlobal.X(),cpvGlobal.Y(),cpvGlobal.Z()} ; |
78881c42 | 422 | Int_t dummyMod ; |
e84d3def | 423 | |
424 | if (fESD == 0x0) { | |
b2e9b669 | 425 | //if no track information available, assume straight line from IP to emcal |
426 | fGeom->ImpactOnEmc(vtxCPV,cpvGlobal.Theta(),cpvGlobal.Phi(),dummyMod,zCPV,xCPV) ; | |
427 | dx=xCPV - vecEmc.X() ; | |
428 | dz=zCPV - vecEmc.Z() ; | |
429 | return ; | |
e84d3def | 430 | } |
b2e9b669 | 431 | |
e84d3def | 432 | //if there is ESD try to correct distance using TPC information on particle direct in CPV |
433 | if (fESD != 0x0) { | |
0d9aa319 | 434 | |
e84d3def | 435 | Double_t rCPV = cpvGlobal.Pt() ;// Radius from IP to current point |
436 | ||
437 | // Extrapolate the global track direction if any to CPV and find the closest track | |
e84d3def | 438 | Int_t iClosestTrack = -1; |
e84d3def | 439 | TVector3 inPHOS ; |
440 | ||
e84d3def | 441 | for (Int_t iTrack=0; iTrack<nTracks; iTrack++) { |
442 | track = fESD->GetTrack(iTrack); | |
443 | if (!track->GetXYZAt(rCPV, fESD->GetMagneticField(), xyz)) | |
b2e9b669 | 444 | continue; //track coord on the cylinder of PHOS radius |
e84d3def | 445 | if ((TMath::Abs(xyz[0])+TMath::Abs(xyz[1])+TMath::Abs(xyz[2]))<=0) |
b2e9b669 | 446 | continue; |
e84d3def | 447 | //Check if this track hits PHOS |
448 | inPHOS.SetXYZ(xyz[0],xyz[1],xyz[2]); | |
449 | distance2Track = inPHOS.Angle(cpvGlobal) ; | |
450 | // Find the closest track to the CPV recpoint | |
451 | if (distance2Track < minDistance) { | |
b2e9b669 | 452 | minDistance = distance2Track; |
453 | iClosestTrack = iTrack; | |
aa0b9641 | 454 | } |
e84d3def | 455 | } |
aa0b9641 | 456 | |
e84d3def | 457 | if (iClosestTrack != -1) { |
458 | track = fESD->GetTrack(iClosestTrack); | |
459 | if (track->GetPxPyPzAt(rCPV, fESD->GetMagneticField(), pxyz)) { // track momentum ibid. | |
460 | vecP.SetXYZ(pxyz[0],pxyz[1],pxyz[2]); | |
9a2cdbdf | 461 | fGeom->ImpactOnEmc(vtxCPV,vecP.Theta(),vecP.Phi(),dummyMod,zCPV,xCPV) ; |
aa0b9641 | 462 | } |
e84d3def | 463 | } |
194f9939 | 464 | |
e84d3def | 465 | if(minDistance < fRtpc ){ |
466 | trackindex = iClosestTrack ; | |
aa0b9641 | 467 | } |
bfc17d18 | 468 | } |
e84d3def | 469 | if(trackindex!=-1){ |
78881c42 | 470 | // If the closest global track is found, calculate EMC-CPV distance from it |
e84d3def | 471 | dx=xCPV - vecEmc.X() ; |
472 | dz=zCPV - vecEmc.Z() ; | |
473 | } | |
474 | else{ | |
78881c42 | 475 | // If no global track was found, just take the nearest CPV point |
9a2cdbdf | 476 | fGeom->ImpactOnEmc(vtxCPV,cpvGlobal.Theta(),cpvGlobal.Phi(),dummyMod,zCPV,xCPV) ; |
78881c42 | 477 | dx=xCPV - vecEmc.X() ; |
478 | dz=zCPV - vecEmc.Z() ; | |
e84d3def | 479 | } |
480 | return ; | |
d15a28e7 | 481 | } |
7b7c1533 | 482 | //____________________________________________________________________________ |
483 | void AliPHOSTrackSegmentMakerv1::Init() | |
484 | { | |
485 | // Make all memory allocations that are not possible in default constructor | |
486 | ||
7b7c1533 | 487 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
9a2cdbdf | 488 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",100); |
489 | fTrackSegments->SetName("TRACKS"); | |
7b7c1533 | 490 | } |
491 | ||
8d0f3f77 | 492 | //____________________________________________________________________________ |
493 | void AliPHOSTrackSegmentMakerv1::InitParameters() | |
494 | { | |
e957fea8 | 495 | //Initializes parameters |
743cb288 | 496 | fRcpv = 10. ; |
497 | fRtpc = 4. ; | |
8d0f3f77 | 498 | fEmcFirst = 0 ; |
499 | fEmcLast = 0 ; | |
500 | fCpvFirst = 0 ; | |
501 | fCpvLast = 0 ; | |
502 | fLinkUpArray = 0 ; | |
adcca1e6 | 503 | fWrite = kTRUE ; |
8d0f3f77 | 504 | } |
505 | ||
506 | ||
d15a28e7 | 507 | //____________________________________________________________________________ |
baef0810 | 508 | void AliPHOSTrackSegmentMakerv1::MakeLinks()const |
d15a28e7 | 509 | { |
194f9939 | 510 | // Finds distances (links) between all EMC and CPV clusters, |
fbf811ec | 511 | // which are not further apart from each other than fRcpv |
f035f6ce | 512 | // and sort them in accordance with this distance |
9688c1dd | 513 | |
2731cd1e | 514 | fLinkUpArray->Clear() ; |
2731cd1e | 515 | |
2bb500e5 | 516 | AliPHOSCpvRecPoint * cpv ; |
92862013 | 517 | AliPHOSEmcRecPoint * emcclu ; |
28c3a259 | 518 | |
d15a28e7 | 519 | Int_t iLinkUp = 0 ; |
520 | ||
28c3a259 | 521 | Int_t iEmcRP; |
2731cd1e | 522 | for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { |
9a2cdbdf | 523 | emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(iEmcRP)) ; |
2731cd1e | 524 | |
194f9939 | 525 | //Bool_t toofar ; |
2731cd1e | 526 | Int_t iCpv = 0 ; |
527 | for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { | |
28c3a259 | 528 | |
9a2cdbdf | 529 | cpv = dynamic_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(iCpv)) ; |
194f9939 | 530 | Int_t track = -1 ; |
e84d3def | 531 | Float_t dx,dz ; |
532 | GetDistanceInPHOSPlane(emcclu, cpv, track,dx,dz) ; | |
533 | if(TMath::Sqrt(dx*dx+dz*dz) < fRcpv ){ | |
534 | new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(dx, dz, iEmcRP, iCpv, track) ; | |
28c3a259 | 535 | } |
d15a28e7 | 536 | } |
28c3a259 | 537 | } |
d15a28e7 | 538 | |
9688c1dd | 539 | fLinkUpArray->Sort() ; //first links with smallest distances |
d15a28e7 | 540 | } |
28c3a259 | 541 | |
d15a28e7 | 542 | //____________________________________________________________________________ |
2731cd1e | 543 | void AliPHOSTrackSegmentMakerv1::MakePairs() |
6ad0bfa0 | 544 | { |
f035f6ce | 545 | // Using the previously made list of "links", we found the smallest link - i.e. |
a4e98857 | 546 | // link with the least distance between EMC and CPV and pointing to still |
f035f6ce | 547 | // unassigned RecParticles. We assign these RecPoints to TrackSegment and |
548 | // remove them from the list of "unassigned". | |
88cb7938 | 549 | |
01a599c9 | 550 | //Make arrays to mark clusters already chosen |
c28bf7f5 | 551 | Int_t index; |
552 | ||
2731cd1e | 553 | Int_t * emcExist = 0; |
c28bf7f5 | 554 | if(fEmcLast > fEmcFirst) { |
2731cd1e | 555 | emcExist = new Int_t[fEmcLast-fEmcFirst] ; |
c28bf7f5 | 556 | for(index = 0; index <fEmcLast-fEmcFirst; index ++) |
557 | emcExist[index] = 1 ; | |
558 | } | |
559 | else | |
560 | return; | |
561 | ||
2731cd1e | 562 | Bool_t * cpvExist = 0; |
c28bf7f5 | 563 | if(fCpvLast > fCpvFirst) { |
2731cd1e | 564 | cpvExist = new Bool_t[fCpvLast-fCpvFirst] ; |
c28bf7f5 | 565 | for(index = 0; index <fCpvLast-fCpvFirst; index ++) |
566 | cpvExist[index] = kTRUE ; | |
567 | } | |
2731cd1e | 568 | |
569 | // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance | |
2731cd1e | 570 | TIter nextUp(fLinkUpArray) ; |
d15a28e7 | 571 | |
d15a28e7 | 572 | AliPHOSLink * linkUp ; |
9688c1dd | 573 | |
2bb500e5 | 574 | AliPHOSCpvRecPoint * nullpointer = 0 ; |
9688c1dd | 575 | |
29b077b5 | 576 | while ( (linkUp = static_cast<AliPHOSLink *>(nextUp()) ) ){ |
9688c1dd | 577 | |
194f9939 | 578 | if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ |
d15a28e7 | 579 | |
988845f7 | 580 | //array cpvExist[] should be non-zero as far as linkUp exists |
1fb480e4 | 581 | //But Coverity requires to check it |
582 | if(cpvExist && cpvExist[linkUp->GetCpv()-fCpvFirst]){ //CPV still exist | |
d7ddbb70 | 583 | Float_t dx,dz ; |
584 | linkUp->GetXZ(dx,dz) ; | |
9a2cdbdf | 585 | new ((* fTrackSegments)[fNTrackSegments]) |
09828f52 | 586 | AliPHOSTrackSegment(static_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(linkUp->GetEmc())) , |
587 | static_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(linkUp->GetCpv())) , | |
d7ddbb70 | 588 | linkUp->GetTrack(),dx,dz) ; |
194f9939 | 589 | |
c28bf7f5 | 590 | (static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); |
88cb7938 | 591 | fNTrackSegments++ ; |
88cb7938 | 592 | emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found |
593 | //mark CPV recpoint as already used | |
194f9939 | 594 | cpvExist[linkUp->GetCpv()-fCpvFirst] = kFALSE ; |
595 | } //if CpvUp still exist | |
c28bf7f5 | 596 | } |
597 | } | |
28c3a259 | 598 | |
194f9939 | 599 | //look through emc recPoints left without CPV |
2731cd1e | 600 | if(emcExist){ //if there is emc rec point |
601 | Int_t iEmcRP ; | |
602 | for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ | |
603 | if(emcExist[iEmcRP] > 0 ){ | |
e44c41e9 | 604 | Int_t track = -1 ; |
605 | Float_t dx,dz ; | |
606 | AliPHOSEmcRecPoint *emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(iEmcRP+fEmcFirst)); | |
607 | GetDistanceInPHOSPlane(emcclu, 0, track,dx,dz); | |
608 | if(track<0) | |
609 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,nullpointer) ; | |
610 | else | |
611 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,0,track,dx,dz); | |
8789edd0 | 612 | (static_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); |
e44c41e9 | 613 | fNTrackSegments++; |
2731cd1e | 614 | } |
d15a28e7 | 615 | } |
d15a28e7 | 616 | } |
780a31c1 | 617 | delete [] emcExist ; |
988845f7 | 618 | if(cpvExist) |
619 | delete [] cpvExist ; | |
d15a28e7 | 620 | } |
621 | ||
622 | //____________________________________________________________________________ | |
9a2cdbdf | 623 | void AliPHOSTrackSegmentMakerv1::Clusters2TrackSegments(Option_t *option) |
d15a28e7 | 624 | { |
9a2cdbdf | 625 | // Steering method to perform track segment construction for the current event |
626 | // Returns an array with the found track-segments. | |
88cb7938 | 627 | |
2731cd1e | 628 | if(strstr(option,"tim")) |
b3f97575 | 629 | gBenchmark->Start("PHOSTSMaker"); |
7b7c1533 | 630 | |
631 | if(strstr(option,"print")) { | |
88cb7938 | 632 | Print() ; |
7b7c1533 | 633 | return ; |
634 | } | |
88cb7938 | 635 | |
9a2cdbdf | 636 | //Make some initializations |
637 | fNTrackSegments = 0 ; | |
638 | fEmcFirst = 0 ; | |
639 | fEmcLast = 0 ; | |
640 | fCpvFirst = 0 ; | |
641 | fCpvLast = 0 ; | |
55ea5766 | 642 | |
9a2cdbdf | 643 | fTrackSegments->Clear(); |
7b7c1533 | 644 | |
9a2cdbdf | 645 | // if(!ReadRecPoints(ievent)) continue; //reads RecPoints for event ievent |
f96711b8 | 646 | |
9a2cdbdf | 647 | for(fModule = 1; fModule <= fGeom->GetNModules() ; fModule++ ) { |
648 | FillOneModule() ; | |
649 | MakeLinks() ; | |
650 | MakePairs() ; | |
2731cd1e | 651 | } |
9a2cdbdf | 652 | |
653 | if(strstr(option,"deb")) | |
654 | PrintTrackSegments(option); | |
655 | ||
2731cd1e | 656 | if(strstr(option,"tim")){ |
657 | gBenchmark->Stop("PHOSTSMaker"); | |
9a2cdbdf | 658 | Info("Exec", "took %f seconds for making TS", |
659 | gBenchmark->GetCpuTime("PHOSTSMaker")); | |
660 | } | |
d15a28e7 | 661 | } |
7b7c1533 | 662 | |
d15a28e7 | 663 | //____________________________________________________________________________ |
702ab87e | 664 | void AliPHOSTrackSegmentMakerv1::Print(const Option_t *)const |
a4e98857 | 665 | { |
baef0810 | 666 | // Print TrackSegmentMaker parameters |
667 | ||
21cd0c07 | 668 | TString message("") ; |
7b7c1533 | 669 | if( strcmp(GetName(), "") != 0 ) { |
21cd0c07 | 670 | message = "\n======== AliPHOSTrackSegmentMakerv1 ========\n" ; |
671 | message += "Making Track segments\n" ; | |
672 | message += "with parameters:\n" ; | |
194f9939 | 673 | message += " Maximal EMC - CPV distance (cm) %f\n" ; |
21cd0c07 | 674 | message += "============================================\n" ; |
675 | Info("Print", message.Data(),fRcpv) ; | |
2731cd1e | 676 | } |
677 | else | |
21cd0c07 | 678 | Info("Print", "AliPHOSTrackSegmentMakerv1 not initialized ") ; |
d15a28e7 | 679 | } |
7b7c1533 | 680 | |
2731cd1e | 681 | //____________________________________________________________________________ |
a4e98857 | 682 | void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option) |
683 | { | |
f035f6ce | 684 | // option deb - prints # of found TrackSegments |
685 | // option deb all - prints as well indexed of found RecParticles assigned to the TS | |
9688c1dd | 686 | |
88cb7938 | 687 | Info("PrintTrackSegments", "Results from TrackSegmentMaker:") ; |
9a2cdbdf | 688 | printf(" Found %d TrackSegments\n", fTrackSegments->GetEntriesFast() ); |
88cb7938 | 689 | |
2731cd1e | 690 | if(strstr(option,"all")) { // printing found TS |
88cb7938 | 691 | printf("TrackSegment # EMC RP# CPV RP#\n") ; |
2731cd1e | 692 | Int_t index; |
9a2cdbdf | 693 | for (index = 0 ; index <fTrackSegments->GetEntriesFast() ; index++) { |
694 | AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )fTrackSegments->At(index) ; | |
88cb7938 | 695 | printf(" %d %d %d \n", ts->GetIndexInList(), ts->GetEmcIndex(), ts->GetCpvIndex() ) ; |
2731cd1e | 696 | } |
d15a28e7 | 697 | } |
2731cd1e | 698 | } |
f96711b8 | 699 |