]>
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 --- | |
2731cd1e | 115 | #include "TTree.h" |
2731cd1e | 116 | #include "TBenchmark.h" |
d15a28e7 | 117 | |
21cd0c07 | 118 | // --- Standard library --- |
194f9939 | 119 | #include "Riostream.h" |
d15a28e7 | 120 | // --- AliRoot header files --- |
e957fea8 | 121 | #include "AliPHOSGeometry.h" |
d15a28e7 | 122 | #include "AliPHOSTrackSegmentMakerv1.h" |
123 | #include "AliPHOSTrackSegment.h" | |
124 | #include "AliPHOSLink.h" | |
af885e0f | 125 | #include "AliESDEvent.h" |
aa0b9641 | 126 | #include "AliESDtrack.h" |
9a2cdbdf | 127 | #include "AliPHOSEmcRecPoint.h" |
128 | #include "AliPHOSCpvRecPoint.h" | |
96351742 | 129 | #include "AliLog.h" |
d15a28e7 | 130 | |
131 | ClassImp( AliPHOSTrackSegmentMakerv1) | |
132 | ||
133 | ||
134 | //____________________________________________________________________________ | |
3663622c | 135 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : |
136 | AliPHOSTrackSegmentMaker(), | |
137 | fDefaultInit(kTRUE), | |
138 | fWrite(kFALSE), | |
139 | fNTrackSegments(0), | |
140 | fRcpv(0.f), | |
141 | fRtpc(0.f), | |
ddd1a39c | 142 | fVtx(0.f), |
3663622c | 143 | fLinkUpArray(0), |
144 | fEmcFirst(0), | |
145 | fEmcLast(0), | |
146 | fCpvFirst(0), | |
147 | fCpvLast(0), | |
148 | fModule(0), | |
9a2cdbdf | 149 | fTrackSegments(NULL) |
d15a28e7 | 150 | { |
7b7c1533 | 151 | // default ctor (to be used mainly by Streamer) |
8d0f3f77 | 152 | InitParameters() ; |
d15a28e7 | 153 | } |
7b7c1533 | 154 | |
9f616d61 | 155 | //____________________________________________________________________________ |
9a2cdbdf | 156 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(AliPHOSGeometry *geom) : |
157 | AliPHOSTrackSegmentMaker(geom), | |
3663622c | 158 | fDefaultInit(kFALSE), |
159 | fWrite(kFALSE), | |
160 | fNTrackSegments(0), | |
161 | fRcpv(0.f), | |
162 | fRtpc(0.f), | |
ddd1a39c | 163 | fVtx(0.f), |
3663622c | 164 | fLinkUpArray(0), |
165 | fEmcFirst(0), | |
166 | fEmcLast(0), | |
167 | fCpvFirst(0), | |
168 | fCpvLast(0), | |
169 | fModule(0), | |
9a2cdbdf | 170 | fTrackSegments(NULL) |
2731cd1e | 171 | { |
172 | // ctor | |
8d0f3f77 | 173 | InitParameters() ; |
7b7c1533 | 174 | Init() ; |
aa0b9641 | 175 | fESD = 0; |
2731cd1e | 176 | } |
98cbd830 | 177 | |
3663622c | 178 | |
179 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const AliPHOSTrackSegmentMakerv1 & tsm) : | |
180 | AliPHOSTrackSegmentMaker(tsm), | |
181 | fDefaultInit(kFALSE), | |
182 | fWrite(kFALSE), | |
183 | fNTrackSegments(0), | |
184 | fRcpv(0.f), | |
185 | fRtpc(0.f), | |
ddd1a39c | 186 | fVtx(0.f), |
3663622c | 187 | fLinkUpArray(0), |
188 | fEmcFirst(0), | |
189 | fEmcLast(0), | |
190 | fCpvFirst(0), | |
191 | fCpvLast(0), | |
192 | fModule(0), | |
9a2cdbdf | 193 | fTrackSegments(NULL) |
3663622c | 194 | { |
195 | // cpy ctor: no implementation yet | |
196 | // requested by the Coding Convention | |
197 | Fatal("cpy ctor", "not implemented") ; | |
198 | } | |
199 | ||
200 | ||
2731cd1e | 201 | //____________________________________________________________________________ |
202 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() | |
203 | { | |
204 | // dtor | |
92f521a9 | 205 | // fDefaultInit = kTRUE if TrackSegmentMaker created by default ctor (to get just the parameters) |
88cb7938 | 206 | if (!fDefaultInit) |
207 | delete fLinkUpArray ; | |
9a2cdbdf | 208 | if (fTrackSegments) { |
209 | fTrackSegments->Delete(); | |
210 | delete fTrackSegments; | |
211 | } | |
fc12304f | 212 | } |
213 | ||
d15a28e7 | 214 | //____________________________________________________________________________ |
2731cd1e | 215 | void AliPHOSTrackSegmentMakerv1::FillOneModule() |
9f616d61 | 216 | { |
f035f6ce | 217 | // Finds first and last indexes between which |
218 | // clusters from one PHOS module are | |
88cb7938 | 219 | |
2731cd1e | 220 | //First EMC clusters |
9a2cdbdf | 221 | Int_t totalEmc = fEMCRecPoints->GetEntriesFast() ; |
2731cd1e | 222 | for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && |
9a2cdbdf | 223 | ((dynamic_cast<AliPHOSRecPoint *>(fEMCRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule ); |
2731cd1e | 224 | fEmcLast ++) ; |
225 | ||
2731cd1e | 226 | //Now CPV clusters |
9a2cdbdf | 227 | Int_t totalCpv = fCPVRecPoints->GetEntriesFast() ; |
6ad0bfa0 | 228 | |
2731cd1e | 229 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
9a2cdbdf | 230 | ((dynamic_cast<AliPHOSRecPoint *>(fCPVRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule ); |
88cb7938 | 231 | fCpvLast ++) ; |
9688c1dd | 232 | |
d15a28e7 | 233 | } |
7b7c1533 | 234 | |
d15a28e7 | 235 | //____________________________________________________________________________ |
e84d3def | 236 | void AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu, |
237 | AliPHOSCpvRecPoint * cpvClu, | |
238 | Int_t &trackindex, | |
239 | Float_t &dx, Float_t &dz) const | |
d15a28e7 | 240 | { |
194f9939 | 241 | // Calculates the distance between the EMC RecPoint and the CPV RecPoint |
e44c41e9 | 242 | // If no CPV, calculates the distance between the EMC RecPoint and the track |
243 | // prolongation to the PHOS module plane. | |
a4e98857 | 244 | // Clusters are sorted in "rows" and "columns" of width 1 cm |
f035f6ce | 245 | |
e84d3def | 246 | // Float_t delta = 1 ; // Width of the rows in sorting of RecPoints (in cm) |
247 | // // if you change this value, change it as well in xxxRecPoint::Compare() | |
194f9939 | 248 | |
e44c41e9 | 249 | if(!cpvClu) { |
96351742 | 250 | |
251 | trackindex = -1; | |
252 | dx=999.; | |
253 | dz=999.; | |
254 | ||
255 | if(!emcClu) { | |
256 | return; | |
257 | } | |
e44c41e9 | 258 | |
259 | TVector3 emcGlobal; | |
260 | fGeom->GetGlobalPHOS((AliPHOSRecPoint*)emcClu,emcGlobal); | |
96351742 | 261 | |
e44c41e9 | 262 | // Radius from IP to current point |
96351742 | 263 | Double_t rEMC = TMath::Abs(emcGlobal.Pt()); |
264 | ||
e44c41e9 | 265 | // Extrapolate the global track direction to EMC |
266 | // and find the closest track | |
96351742 | 267 | |
e44c41e9 | 268 | Int_t nTracks = fESD->GetNumberOfTracks(); |
e44c41e9 | 269 | |
270 | AliESDtrack *track; | |
96351742 | 271 | Double_t xyz[] = {-1,-1,-1}; |
272 | Double_t pxyz[3]; | |
273 | Double_t zEMC,xEMC; | |
274 | Int_t module; | |
275 | TVector3 vecP; | |
276 | TVector3 locClu; | |
277 | ||
278 | Float_t minDistance = 1.e6; | |
279 | Float_t dr; | |
e44c41e9 | 280 | |
281 | for (Int_t iTrack=0; iTrack<nTracks; iTrack++) { | |
282 | track = fESD->GetTrack(iTrack); | |
283 | if (!track->GetXYZAt(rEMC, fESD->GetMagneticField(), xyz)) continue; | |
e44c41e9 | 284 | |
96351742 | 285 | AliDebug(1,Form("Event %d, iTrack: %d, (%.3f,%.3f,%.3f)", |
286 | fESD->GetEventNumberInFile(),iTrack,xyz[0],xyz[1],xyz[2])); | |
287 | ||
288 | if (track->GetPxPyPzAt(rEMC,fESD->GetMagneticField(),pxyz)) { | |
289 | ||
290 | vecP.SetXYZ(pxyz[0],pxyz[1],pxyz[2]); | |
291 | fGeom->ImpactOnEmc(xyz,vecP.Theta(),vecP.Phi(),module,zEMC,xEMC) ; | |
292 | ||
293 | if(!module) continue; | |
294 | AliDebug(1,Form("\t\tTrack hit PHOS! Module: %d, (x,z)=(%.3f,%.3f)",module,xEMC,zEMC)); | |
295 | ||
296 | if(emcClu->GetPHOSMod() != module) continue; | |
297 | ||
298 | // match track to EMC cluster | |
299 | emcClu->GetLocalPosition(locClu); | |
300 | ||
301 | Float_t delta_x = xEMC - locClu.X(); | |
302 | Float_t delta_z = zEMC - locClu.Z(); | |
303 | dr = TMath::Sqrt(delta_x*delta_x + delta_z*delta_z); | |
304 | AliDebug(1,Form("\tMatch iTrack=%d: (dx,dz)=(%.3f,%.3f)",iTrack,delta_x,delta_z)); | |
305 | ||
306 | if(dr<minDistance) { | |
307 | trackindex = iTrack; | |
308 | minDistance = dr; | |
309 | dx = delta_x; | |
310 | dz = delta_z; | |
311 | } | |
e44c41e9 | 312 | } |
96351742 | 313 | |
e44c41e9 | 314 | } |
96351742 | 315 | |
316 | if(trackindex>=0) | |
317 | AliDebug(1,Form("\t\tBest match for (xClu,zClu,eClu)=(%.3f,%.3f,%.3f): iTrack=%d, dR=%.3f", | |
318 | locClu.X(),locClu.Z(),emcClu->GetEnergy(), | |
319 | trackindex,TMath::Sqrt(dx*dx+dz*dz))); | |
e44c41e9 | 320 | return; |
321 | } | |
322 | ||
323 | Float_t distance2Track = fRtpc ; | |
324 | ||
194f9939 | 325 | trackindex = -1 ; // closest track within fRCpv |
326 | ||
aa0b9641 | 327 | TVector3 vecEmc ; // Local position of EMC recpoint |
e84d3def | 328 | TVector3 vecP ; // Momentum direction at CPV plain |
329 | TVector3 vecPloc ; // Momentum direction at CPV plain | |
2731cd1e | 330 | |
194f9939 | 331 | //toofar = kTRUE ; |
e84d3def | 332 | if(emcClu->GetPHOSMod() != cpvClu->GetPHOSMod()){ |
333 | dx=999. ; | |
334 | dz=999. ; | |
335 | return ; | |
336 | } | |
337 | ||
338 | emcClu->GetLocalPosition(vecEmc) ; | |
2731cd1e | 339 | |
e84d3def | 340 | Double_t xCPV,zCPV ; //EMC-projected coordinates of CPV cluster |
341 | TVector3 cpvGlobal; // Global position of the CPV recpoint | |
9a2cdbdf | 342 | fGeom->GetGlobalPHOS((AliPHOSRecPoint*)cpvClu,cpvGlobal); |
e84d3def | 343 | Double_t vtxCPV[3]={cpvGlobal.X(),cpvGlobal.Y(),cpvGlobal.Z()} ; |
78881c42 | 344 | Int_t dummyMod ; |
e84d3def | 345 | |
346 | if (fESD == 0x0) { | |
347 | //if no track information available, assume straight line from IP to emcal | |
9a2cdbdf | 348 | fGeom->ImpactOnEmc(vtxCPV,cpvGlobal.Theta(),cpvGlobal.Phi(),dummyMod,zCPV,xCPV) ; |
e84d3def | 349 | dx=xCPV - vecEmc.X() ; |
350 | dz=zCPV - vecEmc.Z() ; | |
351 | return ; | |
352 | } | |
353 | ||
354 | //if there is ESD try to correct distance using TPC information on particle direct in CPV | |
355 | if (fESD != 0x0) { | |
0d9aa319 | 356 | |
e84d3def | 357 | Double_t rCPV = cpvGlobal.Pt() ;// Radius from IP to current point |
358 | ||
359 | // Extrapolate the global track direction if any to CPV and find the closest track | |
360 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
361 | Int_t iClosestTrack = -1; | |
362 | Double_t minDistance = 1.e6; | |
363 | TVector3 inPHOS ; | |
364 | ||
365 | AliESDtrack *track; | |
366 | Double_t xyz[3] ; | |
367 | Double_t pxyz[3]; | |
368 | for (Int_t iTrack=0; iTrack<nTracks; iTrack++) { | |
369 | track = fESD->GetTrack(iTrack); | |
370 | if (!track->GetXYZAt(rCPV, fESD->GetMagneticField(), xyz)) | |
23904d16 | 371 | continue; //track coord on the cylinder of PHOS radius |
e84d3def | 372 | if ((TMath::Abs(xyz[0])+TMath::Abs(xyz[1])+TMath::Abs(xyz[2]))<=0) |
23904d16 | 373 | continue; |
e84d3def | 374 | //Check if this track hits PHOS |
375 | inPHOS.SetXYZ(xyz[0],xyz[1],xyz[2]); | |
376 | distance2Track = inPHOS.Angle(cpvGlobal) ; | |
377 | // Find the closest track to the CPV recpoint | |
378 | if (distance2Track < minDistance) { | |
379 | minDistance = distance2Track; | |
380 | iClosestTrack = iTrack; | |
aa0b9641 | 381 | } |
e84d3def | 382 | } |
aa0b9641 | 383 | |
e84d3def | 384 | if (iClosestTrack != -1) { |
385 | track = fESD->GetTrack(iClosestTrack); | |
386 | if (track->GetPxPyPzAt(rCPV, fESD->GetMagneticField(), pxyz)) { // track momentum ibid. | |
387 | vecP.SetXYZ(pxyz[0],pxyz[1],pxyz[2]); | |
9a2cdbdf | 388 | fGeom->ImpactOnEmc(vtxCPV,vecP.Theta(),vecP.Phi(),dummyMod,zCPV,xCPV) ; |
aa0b9641 | 389 | } |
e84d3def | 390 | } |
194f9939 | 391 | |
e84d3def | 392 | if(minDistance < fRtpc ){ |
393 | trackindex = iClosestTrack ; | |
aa0b9641 | 394 | } |
bfc17d18 | 395 | } |
e84d3def | 396 | if(trackindex!=-1){ |
78881c42 | 397 | // If the closest global track is found, calculate EMC-CPV distance from it |
e84d3def | 398 | dx=xCPV - vecEmc.X() ; |
399 | dz=zCPV - vecEmc.Z() ; | |
400 | } | |
401 | else{ | |
78881c42 | 402 | // If no global track was found, just take the nearest CPV point |
9a2cdbdf | 403 | fGeom->ImpactOnEmc(vtxCPV,cpvGlobal.Theta(),cpvGlobal.Phi(),dummyMod,zCPV,xCPV) ; |
78881c42 | 404 | dx=xCPV - vecEmc.X() ; |
405 | dz=zCPV - vecEmc.Z() ; | |
e84d3def | 406 | } |
407 | return ; | |
d15a28e7 | 408 | } |
7b7c1533 | 409 | //____________________________________________________________________________ |
410 | void AliPHOSTrackSegmentMakerv1::Init() | |
411 | { | |
412 | // Make all memory allocations that are not possible in default constructor | |
413 | ||
7b7c1533 | 414 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
9a2cdbdf | 415 | fTrackSegments = new TClonesArray("AliPHOSTrackSegment",100); |
416 | fTrackSegments->SetName("TRACKS"); | |
7b7c1533 | 417 | } |
418 | ||
8d0f3f77 | 419 | //____________________________________________________________________________ |
420 | void AliPHOSTrackSegmentMakerv1::InitParameters() | |
421 | { | |
e957fea8 | 422 | //Initializes parameters |
743cb288 | 423 | fRcpv = 10. ; |
424 | fRtpc = 4. ; | |
8d0f3f77 | 425 | fEmcFirst = 0 ; |
426 | fEmcLast = 0 ; | |
427 | fCpvFirst = 0 ; | |
428 | fCpvLast = 0 ; | |
429 | fLinkUpArray = 0 ; | |
adcca1e6 | 430 | fWrite = kTRUE ; |
8d0f3f77 | 431 | } |
432 | ||
433 | ||
d15a28e7 | 434 | //____________________________________________________________________________ |
baef0810 | 435 | void AliPHOSTrackSegmentMakerv1::MakeLinks()const |
d15a28e7 | 436 | { |
194f9939 | 437 | // Finds distances (links) between all EMC and CPV clusters, |
fbf811ec | 438 | // which are not further apart from each other than fRcpv |
f035f6ce | 439 | // and sort them in accordance with this distance |
9688c1dd | 440 | |
2731cd1e | 441 | fLinkUpArray->Clear() ; |
2731cd1e | 442 | |
2bb500e5 | 443 | AliPHOSCpvRecPoint * cpv ; |
92862013 | 444 | AliPHOSEmcRecPoint * emcclu ; |
28c3a259 | 445 | |
d15a28e7 | 446 | Int_t iLinkUp = 0 ; |
447 | ||
28c3a259 | 448 | Int_t iEmcRP; |
2731cd1e | 449 | for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { |
9a2cdbdf | 450 | emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(iEmcRP)) ; |
2731cd1e | 451 | |
194f9939 | 452 | //Bool_t toofar ; |
2731cd1e | 453 | Int_t iCpv = 0 ; |
454 | for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { | |
28c3a259 | 455 | |
9a2cdbdf | 456 | cpv = dynamic_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(iCpv)) ; |
194f9939 | 457 | Int_t track = -1 ; |
e84d3def | 458 | Float_t dx,dz ; |
459 | GetDistanceInPHOSPlane(emcclu, cpv, track,dx,dz) ; | |
460 | if(TMath::Sqrt(dx*dx+dz*dz) < fRcpv ){ | |
461 | new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(dx, dz, iEmcRP, iCpv, track) ; | |
28c3a259 | 462 | } |
d15a28e7 | 463 | } |
28c3a259 | 464 | } |
d15a28e7 | 465 | |
9688c1dd | 466 | fLinkUpArray->Sort() ; //first links with smallest distances |
d15a28e7 | 467 | } |
28c3a259 | 468 | |
d15a28e7 | 469 | //____________________________________________________________________________ |
2731cd1e | 470 | void AliPHOSTrackSegmentMakerv1::MakePairs() |
6ad0bfa0 | 471 | { |
f035f6ce | 472 | // Using the previously made list of "links", we found the smallest link - i.e. |
a4e98857 | 473 | // link with the least distance between EMC and CPV and pointing to still |
f035f6ce | 474 | // unassigned RecParticles. We assign these RecPoints to TrackSegment and |
475 | // remove them from the list of "unassigned". | |
88cb7938 | 476 | |
01a599c9 | 477 | //Make arrays to mark clusters already chosen |
2731cd1e | 478 | Int_t * emcExist = 0; |
479 | if(fEmcLast > fEmcFirst) | |
480 | emcExist = new Int_t[fEmcLast-fEmcFirst] ; | |
481 | ||
482 | Int_t index; | |
483 | for(index = 0; index <fEmcLast-fEmcFirst; index ++) | |
484 | emcExist[index] = 1 ; | |
485 | ||
486 | Bool_t * cpvExist = 0; | |
487 | if(fCpvLast > fCpvFirst) | |
488 | cpvExist = new Bool_t[fCpvLast-fCpvFirst] ; | |
489 | for(index = 0; index <fCpvLast-fCpvFirst; index ++) | |
490 | cpvExist[index] = kTRUE ; | |
491 | ||
2731cd1e | 492 | |
493 | // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance | |
2731cd1e | 494 | TIter nextUp(fLinkUpArray) ; |
d15a28e7 | 495 | |
d15a28e7 | 496 | AliPHOSLink * linkUp ; |
9688c1dd | 497 | |
2bb500e5 | 498 | AliPHOSCpvRecPoint * nullpointer = 0 ; |
9688c1dd | 499 | |
29b077b5 | 500 | while ( (linkUp = static_cast<AliPHOSLink *>(nextUp()) ) ){ |
9688c1dd | 501 | |
194f9939 | 502 | if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ |
d15a28e7 | 503 | |
194f9939 | 504 | if(cpvExist[linkUp->GetCpv()-fCpvFirst]){ //CPV still exist |
d7ddbb70 | 505 | Float_t dx,dz ; |
506 | linkUp->GetXZ(dx,dz) ; | |
9a2cdbdf | 507 | new ((* fTrackSegments)[fNTrackSegments]) |
508 | AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(linkUp->GetEmc())) , | |
509 | dynamic_cast<AliPHOSCpvRecPoint *>(fCPVRecPoints->At(linkUp->GetCpv())) , | |
d7ddbb70 | 510 | linkUp->GetTrack(),dx,dz) ; |
194f9939 | 511 | |
9a2cdbdf | 512 | (dynamic_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); |
88cb7938 | 513 | fNTrackSegments++ ; |
88cb7938 | 514 | emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found |
515 | //mark CPV recpoint as already used | |
194f9939 | 516 | cpvExist[linkUp->GetCpv()-fCpvFirst] = kFALSE ; |
517 | } //if CpvUp still exist | |
28c3a259 | 518 | } |
88cb7938 | 519 | } |
28c3a259 | 520 | |
194f9939 | 521 | //look through emc recPoints left without CPV |
2731cd1e | 522 | if(emcExist){ //if there is emc rec point |
523 | Int_t iEmcRP ; | |
524 | for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ | |
525 | if(emcExist[iEmcRP] > 0 ){ | |
e44c41e9 | 526 | Int_t track = -1 ; |
527 | Float_t dx,dz ; | |
528 | AliPHOSEmcRecPoint *emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(fEMCRecPoints->At(iEmcRP+fEmcFirst)); | |
529 | GetDistanceInPHOSPlane(emcclu, 0, track,dx,dz); | |
530 | if(track<0) | |
531 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,nullpointer) ; | |
532 | else | |
533 | new ((*fTrackSegments)[fNTrackSegments]) AliPHOSTrackSegment(emcclu,0,track,dx,dz); | |
534 | (dynamic_cast<AliPHOSTrackSegment *>(fTrackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); | |
535 | fNTrackSegments++; | |
2731cd1e | 536 | } |
d15a28e7 | 537 | } |
d15a28e7 | 538 | } |
780a31c1 | 539 | delete [] emcExist ; |
540 | delete [] cpvExist ; | |
d15a28e7 | 541 | } |
542 | ||
543 | //____________________________________________________________________________ | |
9a2cdbdf | 544 | void AliPHOSTrackSegmentMakerv1::Clusters2TrackSegments(Option_t *option) |
d15a28e7 | 545 | { |
9a2cdbdf | 546 | // Steering method to perform track segment construction for the current event |
547 | // Returns an array with the found track-segments. | |
88cb7938 | 548 | |
2731cd1e | 549 | if(strstr(option,"tim")) |
b3f97575 | 550 | gBenchmark->Start("PHOSTSMaker"); |
7b7c1533 | 551 | |
552 | if(strstr(option,"print")) { | |
88cb7938 | 553 | Print() ; |
7b7c1533 | 554 | return ; |
555 | } | |
88cb7938 | 556 | |
9a2cdbdf | 557 | //Make some initializations |
558 | fNTrackSegments = 0 ; | |
559 | fEmcFirst = 0 ; | |
560 | fEmcLast = 0 ; | |
561 | fCpvFirst = 0 ; | |
562 | fCpvLast = 0 ; | |
55ea5766 | 563 | |
9a2cdbdf | 564 | fTrackSegments->Clear(); |
7b7c1533 | 565 | |
9a2cdbdf | 566 | // if(!ReadRecPoints(ievent)) continue; //reads RecPoints for event ievent |
94de8339 | 567 | |
9a2cdbdf | 568 | for(fModule = 1; fModule <= fGeom->GetNModules() ; fModule++ ) { |
569 | FillOneModule() ; | |
570 | MakeLinks() ; | |
571 | MakePairs() ; | |
2731cd1e | 572 | } |
9a2cdbdf | 573 | |
574 | if(strstr(option,"deb")) | |
575 | PrintTrackSegments(option); | |
576 | ||
2731cd1e | 577 | if(strstr(option,"tim")){ |
578 | gBenchmark->Stop("PHOSTSMaker"); | |
9a2cdbdf | 579 | Info("Exec", "took %f seconds for making TS", |
580 | gBenchmark->GetCpuTime("PHOSTSMaker")); | |
581 | } | |
d15a28e7 | 582 | } |
7b7c1533 | 583 | |
d15a28e7 | 584 | //____________________________________________________________________________ |
702ab87e | 585 | void AliPHOSTrackSegmentMakerv1::Print(const Option_t *)const |
a4e98857 | 586 | { |
baef0810 | 587 | // Print TrackSegmentMaker parameters |
588 | ||
21cd0c07 | 589 | TString message("") ; |
7b7c1533 | 590 | if( strcmp(GetName(), "") != 0 ) { |
21cd0c07 | 591 | message = "\n======== AliPHOSTrackSegmentMakerv1 ========\n" ; |
592 | message += "Making Track segments\n" ; | |
593 | message += "with parameters:\n" ; | |
194f9939 | 594 | message += " Maximal EMC - CPV distance (cm) %f\n" ; |
21cd0c07 | 595 | message += "============================================\n" ; |
596 | Info("Print", message.Data(),fRcpv) ; | |
2731cd1e | 597 | } |
598 | else | |
21cd0c07 | 599 | Info("Print", "AliPHOSTrackSegmentMakerv1 not initialized ") ; |
d15a28e7 | 600 | } |
7b7c1533 | 601 | |
2731cd1e | 602 | //____________________________________________________________________________ |
a4e98857 | 603 | void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option) |
604 | { | |
f035f6ce | 605 | // option deb - prints # of found TrackSegments |
606 | // option deb all - prints as well indexed of found RecParticles assigned to the TS | |
9688c1dd | 607 | |
88cb7938 | 608 | Info("PrintTrackSegments", "Results from TrackSegmentMaker:") ; |
9a2cdbdf | 609 | printf(" Found %d TrackSegments\n", fTrackSegments->GetEntriesFast() ); |
88cb7938 | 610 | |
2731cd1e | 611 | if(strstr(option,"all")) { // printing found TS |
88cb7938 | 612 | printf("TrackSegment # EMC RP# CPV RP#\n") ; |
2731cd1e | 613 | Int_t index; |
9a2cdbdf | 614 | for (index = 0 ; index <fTrackSegments->GetEntriesFast() ; index++) { |
615 | AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )fTrackSegments->At(index) ; | |
88cb7938 | 616 | printf(" %d %d %d \n", ts->GetIndexInList(), ts->GetEmcIndex(), ts->GetCpvIndex() ) ; |
2731cd1e | 617 | } |
d15a28e7 | 618 | } |
2731cd1e | 619 | } |