]>
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$ | |
a2ee5b34 | 20 | * Revision 1.80 2006/08/28 10:01:56 kharlov |
21 | * Effective C++ warnings fixed (Timur Pocheptsov) | |
22 | * | |
3663622c | 23 | * Revision 1.79 2006/04/25 12:41:15 hristov |
24 | * Moving non-persistent data to AliESDfriend (Yu.Belikov) | |
25 | * | |
15e85efa | 26 | * Revision 1.78 2005/11/18 13:04:51 hristov |
27 | * Bug fix | |
28 | * | |
a494460a | 29 | * Revision 1.77 2005/11/17 23:34:36 hristov |
30 | * Corrected logics | |
31 | * | |
f74a631d | 32 | * Revision 1.76 2005/11/17 22:29:12 hristov |
33 | * Faster version, no attempt to match tracks outside the PHOS acceptance | |
34 | * | |
0d9aa319 | 35 | * Revision 1.75 2005/11/17 12:35:27 hristov |
36 | * Use references instead of objects. Avoid to create objects when they are not really needed | |
37 | * | |
7b51037f | 38 | * Revision 1.74 2005/07/08 14:01:36 hristov |
39 | * Tracking in non-uniform nmagnetic field (Yu.Belikov) | |
40 | * | |
c84a5e9e | 41 | * Revision 1.73 2005/05/28 14:19:05 schutz |
42 | * Compilation warnings fixed by T.P. | |
43 | * | |
702ab87e | 44 | */ |
45 | ||
d15a28e7 | 46 | //_________________________________________________________________________ |
b2a60966 | 47 | // Implementation version 1 of algorithm class to construct PHOS track segments |
f035f6ce | 48 | // Track segment for PHOS is list of |
194f9939 | 49 | // EMC RecPoint + (possibly) CPV RecPoint |
a4e98857 | 50 | // To find TrackSegments we do the following: |
51 | // for each EMC RecPoints we look at | |
194f9939 | 52 | // CPV RecPoints in the radious fRcpv. |
a4e98857 | 53 | // If there is such a CPV RecPoint, |
194f9939 | 54 | // we make "Link" it is just indexes of EMC and CPV RecPoint and distance |
a4e98857 | 55 | // between them in the PHOS plane. |
56 | // Then we sort "Links" and starting from the | |
57 | // least "Link" pointing to the unassined EMC and CPV RecPoints assing them to | |
58 | // new TrackSegment. | |
194f9939 | 59 | // If there is no CPV RecPoint we make TrackSegment |
a4e98857 | 60 | // consisting from EMC alone. There is no TrackSegments without EMC RecPoint. |
f444a19f | 61 | //// In principle this class should be called from AliPHOSReconstructor, but |
a4e98857 | 62 | // one can use it as well in standalone mode. |
63 | // Use case: | |
fc12304f | 64 | // root [0] AliPHOSTrackSegmentMakerv1 * t = new AliPHOSTrackSegmentMaker("galice.root", "tracksegmentsname", "recpointsname") |
a4e98857 | 65 | // Warning in <TDatabasePDG::TDatabasePDG>: object already instantiated |
fc12304f | 66 | // // reads gAlice from header file "galice.root", uses recpoints stored in the branch names "recpointsname" (default = "Default") |
67 | // // and saves recpoints in branch named "tracksegmentsname" (default = "recpointsname") | |
a4e98857 | 68 | // root [1] t->ExecuteTask() |
a4e98857 | 69 | // root [3] t->SetTrackSegmentsBranch("max distance 5 cm") |
70 | // root [4] t->ExecuteTask("deb all time") | |
f035f6ce | 71 | // |
fc12304f | 72 | //*-- Author: Dmitri Peressounko (RRC Ki & SUBATECH) & Yves Schutz (SUBATECH) |
b2a60966 | 73 | // |
d15a28e7 | 74 | |
75 | // --- ROOT system --- | |
2731cd1e | 76 | #include "TTree.h" |
2731cd1e | 77 | #include "TBenchmark.h" |
d15a28e7 | 78 | |
21cd0c07 | 79 | // --- Standard library --- |
194f9939 | 80 | #include "Riostream.h" |
d15a28e7 | 81 | // --- AliRoot header files --- |
e957fea8 | 82 | #include "AliPHOSGeometry.h" |
d15a28e7 | 83 | #include "AliPHOSTrackSegmentMakerv1.h" |
84 | #include "AliPHOSTrackSegment.h" | |
85 | #include "AliPHOSLink.h" | |
7b7c1533 | 86 | #include "AliPHOSGetter.h" |
aa0b9641 | 87 | #include "AliESD.h" |
88 | #include "AliESDtrack.h" | |
d15a28e7 | 89 | |
90 | ClassImp( AliPHOSTrackSegmentMakerv1) | |
91 | ||
92 | ||
93 | //____________________________________________________________________________ | |
3663622c | 94 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1() : |
95 | AliPHOSTrackSegmentMaker(), | |
96 | fDefaultInit(kTRUE), | |
97 | fWrite(kFALSE), | |
98 | fNTrackSegments(0), | |
99 | fRcpv(0.f), | |
100 | fRtpc(0.f), | |
101 | fLinkUpArray(0), | |
102 | fEmcFirst(0), | |
103 | fEmcLast(0), | |
104 | fCpvFirst(0), | |
105 | fCpvLast(0), | |
106 | fModule(0), | |
107 | fTrackSegmentsInRun(0) | |
108 | ||
d15a28e7 | 109 | { |
7b7c1533 | 110 | // default ctor (to be used mainly by Streamer) |
8d0f3f77 | 111 | InitParameters() ; |
d15a28e7 | 112 | } |
7b7c1533 | 113 | |
9f616d61 | 114 | //____________________________________________________________________________ |
3663622c | 115 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const TString & alirunFileName, const TString & eventFolderName) : |
116 | AliPHOSTrackSegmentMaker(alirunFileName, eventFolderName), | |
117 | fDefaultInit(kFALSE), | |
118 | fWrite(kFALSE), | |
119 | fNTrackSegments(0), | |
120 | fRcpv(0.f), | |
121 | fRtpc(0.f), | |
122 | fLinkUpArray(0), | |
123 | fEmcFirst(0), | |
124 | fEmcLast(0), | |
125 | fCpvFirst(0), | |
126 | fCpvLast(0), | |
127 | fModule(0), | |
128 | fTrackSegmentsInRun(0) | |
2731cd1e | 129 | { |
130 | // ctor | |
8d0f3f77 | 131 | InitParameters() ; |
7b7c1533 | 132 | Init() ; |
aa0b9641 | 133 | fESD = 0; |
2731cd1e | 134 | } |
98cbd830 | 135 | |
3663622c | 136 | |
137 | AliPHOSTrackSegmentMakerv1::AliPHOSTrackSegmentMakerv1(const AliPHOSTrackSegmentMakerv1 & tsm) : | |
138 | AliPHOSTrackSegmentMaker(tsm), | |
139 | fDefaultInit(kFALSE), | |
140 | fWrite(kFALSE), | |
141 | fNTrackSegments(0), | |
142 | fRcpv(0.f), | |
143 | fRtpc(0.f), | |
144 | fLinkUpArray(0), | |
145 | fEmcFirst(0), | |
146 | fEmcLast(0), | |
147 | fCpvFirst(0), | |
148 | fCpvLast(0), | |
149 | fModule(0), | |
150 | fTrackSegmentsInRun(0) | |
151 | { | |
152 | // cpy ctor: no implementation yet | |
153 | // requested by the Coding Convention | |
154 | Fatal("cpy ctor", "not implemented") ; | |
155 | } | |
156 | ||
157 | ||
2731cd1e | 158 | //____________________________________________________________________________ |
159 | AliPHOSTrackSegmentMakerv1::~AliPHOSTrackSegmentMakerv1() | |
160 | { | |
161 | // dtor | |
92f521a9 | 162 | // fDefaultInit = kTRUE if TrackSegmentMaker created by default ctor (to get just the parameters) |
88cb7938 | 163 | if (!fDefaultInit) |
164 | delete fLinkUpArray ; | |
d15a28e7 | 165 | } |
9f616d61 | 166 | |
8d0f3f77 | 167 | |
fc12304f | 168 | //____________________________________________________________________________ |
169 | const TString AliPHOSTrackSegmentMakerv1::BranchName() const | |
170 | { | |
88cb7938 | 171 | |
172 | return GetName() ; | |
fc12304f | 173 | } |
174 | ||
d15a28e7 | 175 | //____________________________________________________________________________ |
2731cd1e | 176 | void AliPHOSTrackSegmentMakerv1::FillOneModule() |
9f616d61 | 177 | { |
f035f6ce | 178 | // Finds first and last indexes between which |
179 | // clusters from one PHOS module are | |
88cb7938 | 180 | |
181 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
fc12304f | 182 | |
fbf811ec | 183 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
184 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
9688c1dd | 185 | |
2731cd1e | 186 | //First EMC clusters |
7b7c1533 | 187 | Int_t totalEmc = emcRecPoints->GetEntriesFast() ; |
2731cd1e | 188 | for(fEmcFirst = fEmcLast; (fEmcLast < totalEmc) && |
29b077b5 | 189 | ((dynamic_cast<AliPHOSRecPoint *>(emcRecPoints->At(fEmcLast)))->GetPHOSMod() == fModule ); |
2731cd1e | 190 | fEmcLast ++) ; |
191 | ||
2731cd1e | 192 | //Now CPV clusters |
7b7c1533 | 193 | Int_t totalCpv = cpvRecPoints->GetEntriesFast() ; |
6ad0bfa0 | 194 | |
2731cd1e | 195 | for(fCpvFirst = fCpvLast; (fCpvLast < totalCpv) && |
88cb7938 | 196 | ((dynamic_cast<AliPHOSRecPoint *>(cpvRecPoints->At(fCpvLast)))->GetPHOSMod() == fModule ); |
197 | fCpvLast ++) ; | |
9688c1dd | 198 | |
d15a28e7 | 199 | } |
7b7c1533 | 200 | |
d15a28e7 | 201 | //____________________________________________________________________________ |
194f9939 | 202 | Float_t AliPHOSTrackSegmentMakerv1::GetDistanceInPHOSPlane(AliPHOSEmcRecPoint * emcClu,AliPHOSCpvRecPoint * cpvClu, Int_t &trackindex) const |
d15a28e7 | 203 | { |
194f9939 | 204 | // Calculates the distance between the EMC RecPoint and the CPV RecPoint |
a4e98857 | 205 | // Clusters are sorted in "rows" and "columns" of width 1 cm |
f035f6ce | 206 | |
743cb288 | 207 | //Float_t delta = 1 ; // Width of the rows in sorting of RecPoints (in cm) |
2731cd1e | 208 | // if you change this value, change it as well in xxxRecPoint::Compare() |
194f9939 | 209 | Float_t distance2Cpv = fRcpv ; |
743cb288 | 210 | Float_t distance2Track = fRtpc ; |
194f9939 | 211 | |
212 | trackindex = -1 ; // closest track within fRCpv | |
213 | ||
aa0b9641 | 214 | TVector3 vecEmc ; // Local position of EMC recpoint |
215 | TVector3 vecCpv ; // Local position of CPV recpoint propagated to EMC | |
216 | TVector3 vecDist ; // Distance between local positions of two points | |
2731cd1e | 217 | |
218 | emcClu->GetLocalPosition(vecEmc) ; | |
bfc17d18 | 219 | cpvClu->GetLocalPosition(vecCpv) ; |
2731cd1e | 220 | |
194f9939 | 221 | //toofar = kTRUE ; |
2731cd1e | 222 | if(emcClu->GetPHOSMod() == cpvClu->GetPHOSMod()){ |
2731cd1e | 223 | |
194f9939 | 224 | // Find EMC-CPV distance |
225 | distance2Cpv = (vecCpv - vecEmc).Mag() ; | |
226 | ||
aa0b9641 | 227 | if (fESD != 0x0) { |
0d9aa319 | 228 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
229 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; | |
230 | ||
231 | Double_t rPHOS = geom->GetIPtoCrystalSurface(); | |
232 | ||
233 | //PH Acceptance boundaries for each PHOS module | |
234 | Int_t nModules = geom->GetNModules(); | |
235 | Double_t * thmin = new Double_t[nModules];// theta min | |
236 | Double_t * thmax = new Double_t[nModules];// theta max | |
237 | Double_t * phmin = new Double_t[nModules];// phi min | |
238 | Double_t * phmax = new Double_t[nModules];// phi max | |
239 | ||
240 | for (Int_t imod=0; imod<nModules; imod++) { | |
a2ee5b34 | 241 | // Modules are numbered from 1 to 5 in AliPHOSGeometry |
242 | geom->EmcModuleCoverage(imod+1, | |
0d9aa319 | 243 | thmin[imod],thmax[imod], |
244 | phmin[imod],phmax[imod]); | |
245 | } | |
246 | ||
aa0b9641 | 247 | // Extrapolate the global track direction if any to CPV and find the closest track |
248 | Int_t nTracks = fESD->GetNumberOfTracks(); | |
249 | Int_t iClosestTrack = -1; | |
aa0b9641 | 250 | Double_t minDistance = 1e6; |
251 | Double_t pxyz[3], xyz[3]; | |
0d9aa319 | 252 | TVector3 inPHOS; //PH Used to calculate theta and phi |
253 | ||
254 | //PH Loop on tracks | |
aa0b9641 | 255 | AliESDtrack *track; |
256 | for (Int_t iTrack=0; iTrack<nTracks; iTrack++) { | |
257 | track = fESD->GetTrack(iTrack); | |
c84a5e9e | 258 | if (!track->GetXYZAt(rPHOS, fESD->GetMagneticField(), xyz)) |
23904d16 | 259 | continue; //track coord on the cylinder of PHOS radius |
75408399 | 260 | if ((TMath::Abs(xyz[0])+TMath::Abs(xyz[1])+TMath::Abs(xyz[2]))<=0) |
23904d16 | 261 | continue; |
0d9aa319 | 262 | //PH Here one has to cut out the tracks which are not inside the PHOS |
263 | //PH acceptance | |
264 | inPHOS.SetXYZ(xyz[0],xyz[1],xyz[2]); | |
265 | Double_t inPhi = inPHOS.Phi(); | |
266 | Double_t inTheta = inPHOS.Theta(); | |
267 | ||
f74a631d | 268 | Bool_t skip = kTRUE; |
a494460a | 269 | for (Int_t imod=0; imod<nModules; imod++) { |
0d9aa319 | 270 | //PH Loop on modules to check if the track enters in the acceptance |
f74a631d | 271 | if (thmin[imod] < inTheta && thmax[imod] > inTheta && |
272 | phmin[imod] < inPhi && phmax[imod] > inPhi) { | |
273 | skip = kFALSE; | |
0d9aa319 | 274 | break; |
275 | } | |
276 | } | |
277 | if (skip) continue; //PH Skip, if not in the PHOS acceptance | |
278 | ||
c84a5e9e | 279 | if (!track->GetPxPyPzAt(rPHOS, fESD->GetMagneticField(), pxyz)) |
23904d16 | 280 | continue; // track momentum ibid. |
7b51037f | 281 | PropagateToPlane(vecDist,xyz,pxyz,"CPV",cpvClu->GetPHOSMod()); |
e718c158 | 282 | // Info("GetDistanceInPHOSPlane","Track %d propagation to CPV = (%f,%f,%f)", |
283 | // iTrack,vecDist.X(),vecDist.Y(),vecDist.Z()); | |
aa0b9641 | 284 | vecDist -= vecCpv; |
194f9939 | 285 | distance2Track = TMath::Sqrt(vecDist.X()*vecDist.X() + vecDist.Z()*vecDist.Z()); |
aa0b9641 | 286 | // Find the closest track to the EMC recpoint |
194f9939 | 287 | if (distance2Track < minDistance) { |
288 | minDistance = distance2Track; | |
aa0b9641 | 289 | iClosestTrack = iTrack; |
290 | } | |
291 | } | |
292 | ||
0d9aa319 | 293 | delete [] thmin; |
294 | delete [] thmax; | |
295 | delete [] phmin; | |
296 | delete [] phmax; | |
297 | ||
aa0b9641 | 298 | if (iClosestTrack != -1) { |
299 | track = fESD->GetTrack(iClosestTrack); | |
c84a5e9e | 300 | if (track->GetPxPyPzAt(rPHOS, fESD->GetMagneticField(), pxyz)) { // track momentum ibid. |
aa0b9641 | 301 | TVector3 vecCpvGlobal; // Global position of the CPV recpoint |
aa0b9641 | 302 | geom->GetGlobal((AliRecPoint*)cpvClu,vecCpvGlobal); |
303 | for (Int_t ixyz=0; ixyz<3; ixyz++) | |
304 | xyz[ixyz] = vecCpvGlobal[ixyz]; | |
7b51037f | 305 | PropagateToPlane(vecDist,xyz,pxyz,"EMC",cpvClu->GetPHOSMod()); |
bfc17d18 | 306 | // Info("GetDistanceInPHOSPlane","Track %d propagation to EMC = (%f,%f,%f)", |
307 | // iClosestTrack,vecDist.X(),vecDist.Y(),vecDist.Z()); | |
aa0b9641 | 308 | vecDist -= vecEmc; |
194f9939 | 309 | distance2Track = TMath::Sqrt(vecDist.X()*vecDist.X() + vecDist.Z()*vecDist.Z()); |
23904d16 | 310 | } |
aa0b9641 | 311 | } |
194f9939 | 312 | // } else { |
313 | // // If no ESD exists, than simply find EMC-CPV distance | |
314 | // distance = (vecCpv - vecEmc).Mag() ; | |
315 | ||
743cb288 | 316 | //if(distance2Track < fRcpv + 2*delta ) |
317 | if(distance2Track < fRtpc ) | |
194f9939 | 318 | trackindex = iClosestTrack ; |
319 | // toofar = kFALSE ; | |
aa0b9641 | 320 | } |
194f9939 | 321 | // Info("GetDistanceInPHOSPlane","cpv-emc distance is %f cm", |
322 | // distance); | |
bfc17d18 | 323 | } |
d15a28e7 | 324 | |
194f9939 | 325 | return distance2Cpv ; |
aa0b9641 | 326 | } |
327 | ||
328 | //____________________________________________________________________________ | |
7b51037f | 329 | void AliPHOSTrackSegmentMakerv1::PropagateToPlane(TVector3& globalIntersection, |
330 | Double_t *x, | |
331 | Double_t *p, | |
332 | const char *det, | |
333 | Int_t moduleNumber) const | |
aa0b9641 | 334 | { |
335 | // Propagate a straight-line track from the origin point x | |
bfc17d18 | 336 | // along the direction p to the CPV or EMC module moduleNumber |
aa0b9641 | 337 | // Returns a local position of such a propagation |
338 | ||
339 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
340 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; | |
7b51037f | 341 | TVector3 moduleCenter; |
342 | geom->GetModuleCenter(moduleCenter,det,moduleNumber); | |
343 | TVector3 vertex; vertex.SetXYZ(x[0],x[1],x[2]); | |
344 | TVector3 direction; direction.SetXYZ(p[0],p[1],p[2]); | |
aa0b9641 | 345 | |
bfc17d18 | 346 | // Info("PropagateToCPV","Center of the %s module %d is (%f,%f,%f)", |
347 | // det,moduleNumber,moduleCenter[0],moduleCenter[1],moduleCenter[2]); | |
395f4eea | 348 | |
aa0b9641 | 349 | Double_t time = (moduleCenter.Mag2() - vertex.Dot(moduleCenter)) / |
350 | (direction.Dot(moduleCenter)); | |
7b51037f | 351 | vertex += direction*time; |
352 | geom->Global2Local(globalIntersection,vertex,moduleNumber); | |
d15a28e7 | 353 | } |
354 | ||
7b7c1533 | 355 | //____________________________________________________________________________ |
356 | void AliPHOSTrackSegmentMakerv1::Init() | |
357 | { | |
358 | // Make all memory allocations that are not possible in default constructor | |
359 | ||
adcca1e6 | 360 | AliPHOSGetter* gime = AliPHOSGetter::Instance(); |
361 | if(!gime) | |
362 | gime = AliPHOSGetter::Instance(GetTitle(), fEventFolderName.Data()); | |
fbf811ec | 363 | |
7b7c1533 | 364 | fLinkUpArray = new TClonesArray("AliPHOSLink", 1000); |
88cb7938 | 365 | if ( !gime->TrackSegmentMaker() ) { |
366 | gime->PostTrackSegmentMaker(this); | |
367 | } | |
7b7c1533 | 368 | } |
369 | ||
8d0f3f77 | 370 | //____________________________________________________________________________ |
371 | void AliPHOSTrackSegmentMakerv1::InitParameters() | |
372 | { | |
e957fea8 | 373 | //Initializes parameters |
743cb288 | 374 | fRcpv = 10. ; |
375 | fRtpc = 4. ; | |
8d0f3f77 | 376 | fEmcFirst = 0 ; |
377 | fEmcLast = 0 ; | |
378 | fCpvFirst = 0 ; | |
379 | fCpvLast = 0 ; | |
380 | fLinkUpArray = 0 ; | |
adcca1e6 | 381 | fWrite = kTRUE ; |
88cb7938 | 382 | fTrackSegmentsInRun = 0 ; |
eabde521 | 383 | SetEventRange(0,-1) ; |
8d0f3f77 | 384 | } |
385 | ||
386 | ||
d15a28e7 | 387 | //____________________________________________________________________________ |
baef0810 | 388 | void AliPHOSTrackSegmentMakerv1::MakeLinks()const |
d15a28e7 | 389 | { |
194f9939 | 390 | // Finds distances (links) between all EMC and CPV clusters, |
fbf811ec | 391 | // which are not further apart from each other than fRcpv |
f035f6ce | 392 | // and sort them in accordance with this distance |
9688c1dd | 393 | |
88cb7938 | 394 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
fbf811ec | 395 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
396 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
7b7c1533 | 397 | |
2731cd1e | 398 | fLinkUpArray->Clear() ; |
2731cd1e | 399 | |
2bb500e5 | 400 | AliPHOSCpvRecPoint * cpv ; |
92862013 | 401 | AliPHOSEmcRecPoint * emcclu ; |
28c3a259 | 402 | |
d15a28e7 | 403 | Int_t iLinkUp = 0 ; |
404 | ||
28c3a259 | 405 | Int_t iEmcRP; |
2731cd1e | 406 | for(iEmcRP = fEmcFirst; iEmcRP < fEmcLast; iEmcRP++ ) { |
29b077b5 | 407 | emcclu = dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(iEmcRP)) ; |
2731cd1e | 408 | |
194f9939 | 409 | //Bool_t toofar ; |
2731cd1e | 410 | Int_t iCpv = 0 ; |
411 | for(iCpv = fCpvFirst; iCpv < fCpvLast;iCpv++ ) { | |
28c3a259 | 412 | |
2bb500e5 | 413 | cpv = dynamic_cast<AliPHOSCpvRecPoint *>(cpvRecPoints->At(iCpv)) ; |
194f9939 | 414 | Int_t track = -1 ; |
415 | Float_t r = GetDistanceInPHOSPlane(emcclu, cpv, track) ; | |
416 | // if(toofar) | |
417 | // continue ; | |
fbf811ec | 418 | if(r < fRcpv) { |
194f9939 | 419 | new ((*fLinkUpArray)[iLinkUp++]) AliPHOSLink(r, iEmcRP, iCpv, track) ; |
28c3a259 | 420 | } |
d15a28e7 | 421 | } |
28c3a259 | 422 | } |
d15a28e7 | 423 | |
9688c1dd | 424 | fLinkUpArray->Sort() ; //first links with smallest distances |
d15a28e7 | 425 | } |
28c3a259 | 426 | |
d15a28e7 | 427 | //____________________________________________________________________________ |
2731cd1e | 428 | void AliPHOSTrackSegmentMakerv1::MakePairs() |
6ad0bfa0 | 429 | { |
f035f6ce | 430 | // Using the previously made list of "links", we found the smallest link - i.e. |
a4e98857 | 431 | // link with the least distance between EMC and CPV and pointing to still |
f035f6ce | 432 | // unassigned RecParticles. We assign these RecPoints to TrackSegment and |
433 | // remove them from the list of "unassigned". | |
88cb7938 | 434 | |
435 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; | |
436 | ||
fbf811ec | 437 | TObjArray * emcRecPoints = gime->EmcRecPoints() ; |
438 | TObjArray * cpvRecPoints = gime->CpvRecPoints() ; | |
88cb7938 | 439 | TClonesArray * trackSegments = gime->TrackSegments(); |
9688c1dd | 440 | |
01a599c9 | 441 | //Make arrays to mark clusters already chosen |
2731cd1e | 442 | Int_t * emcExist = 0; |
443 | if(fEmcLast > fEmcFirst) | |
444 | emcExist = new Int_t[fEmcLast-fEmcFirst] ; | |
445 | ||
446 | Int_t index; | |
447 | for(index = 0; index <fEmcLast-fEmcFirst; index ++) | |
448 | emcExist[index] = 1 ; | |
449 | ||
450 | Bool_t * cpvExist = 0; | |
451 | if(fCpvLast > fCpvFirst) | |
452 | cpvExist = new Bool_t[fCpvLast-fCpvFirst] ; | |
453 | for(index = 0; index <fCpvLast-fCpvFirst; index ++) | |
454 | cpvExist[index] = kTRUE ; | |
455 | ||
2731cd1e | 456 | |
457 | // Finds the smallest links and makes pairs of CPV and EMC clusters with smallest distance | |
2731cd1e | 458 | TIter nextUp(fLinkUpArray) ; |
d15a28e7 | 459 | |
d15a28e7 | 460 | AliPHOSLink * linkUp ; |
9688c1dd | 461 | |
2bb500e5 | 462 | AliPHOSCpvRecPoint * nullpointer = 0 ; |
9688c1dd | 463 | |
29b077b5 | 464 | while ( (linkUp = static_cast<AliPHOSLink *>(nextUp()) ) ){ |
9688c1dd | 465 | |
194f9939 | 466 | if(emcExist[linkUp->GetEmc()-fEmcFirst] != -1){ |
d15a28e7 | 467 | |
194f9939 | 468 | if(cpvExist[linkUp->GetCpv()-fCpvFirst]){ //CPV still exist |
469 | new ((* trackSegments)[fNTrackSegments]) | |
470 | AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(linkUp->GetEmc())) , | |
471 | dynamic_cast<AliPHOSCpvRecPoint *>(cpvRecPoints->At(linkUp->GetCpv())) , | |
472 | linkUp->GetTrack()) ; | |
473 | ||
88cb7938 | 474 | (dynamic_cast<AliPHOSTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); |
475 | fNTrackSegments++ ; | |
88cb7938 | 476 | emcExist[linkUp->GetEmc()-fEmcFirst] = -1 ; //Mark emc that Cpv was found |
477 | //mark CPV recpoint as already used | |
194f9939 | 478 | cpvExist[linkUp->GetCpv()-fCpvFirst] = kFALSE ; |
479 | } //if CpvUp still exist | |
28c3a259 | 480 | } |
88cb7938 | 481 | } |
28c3a259 | 482 | |
194f9939 | 483 | //look through emc recPoints left without CPV |
2731cd1e | 484 | if(emcExist){ //if there is emc rec point |
485 | Int_t iEmcRP ; | |
486 | for(iEmcRP = 0; iEmcRP < fEmcLast-fEmcFirst ; iEmcRP++ ){ | |
487 | if(emcExist[iEmcRP] > 0 ){ | |
88cb7938 | 488 | new ((*trackSegments)[fNTrackSegments]) |
489 | AliPHOSTrackSegment(dynamic_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(iEmcRP+fEmcFirst)), | |
490 | nullpointer) ; | |
491 | (dynamic_cast<AliPHOSTrackSegment *>(trackSegments->At(fNTrackSegments)))->SetIndexInList(fNTrackSegments); | |
492 | fNTrackSegments++; | |
2731cd1e | 493 | } |
d15a28e7 | 494 | } |
d15a28e7 | 495 | } |
780a31c1 | 496 | delete [] emcExist ; |
497 | delete [] cpvExist ; | |
d15a28e7 | 498 | } |
499 | ||
500 | //____________________________________________________________________________ | |
eabde521 | 501 | void AliPHOSTrackSegmentMakerv1::Exec(Option_t *option) |
d15a28e7 | 502 | { |
eabde521 | 503 | // Steering method to perform track segment construction for events |
504 | // in the range from fFirstEvent to fLastEvent. | |
505 | // This range is optionally set by SetEventRange(). | |
506 | // if fLastEvent=-1 (by default), then process events until the end. | |
88cb7938 | 507 | |
2731cd1e | 508 | if(strstr(option,"tim")) |
b3f97575 | 509 | gBenchmark->Start("PHOSTSMaker"); |
7b7c1533 | 510 | |
511 | if(strstr(option,"print")) { | |
88cb7938 | 512 | Print() ; |
7b7c1533 | 513 | return ; |
514 | } | |
88cb7938 | 515 | |
adcca1e6 | 516 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
fb43ada4 | 517 | |
55ea5766 | 518 | const AliPHOSGeometry * geom = gime->PHOSGeometry() ; |
7b7c1533 | 519 | |
0588c896 | 520 | if (fLastEvent == -1) |
521 | fLastEvent = gime->MaxEvent() - 1 ; | |
522 | else | |
523 | fLastEvent = TMath::Min(fFirstEvent,gime->MaxEvent()); | |
eabde521 | 524 | Int_t nEvents = fLastEvent - fFirstEvent + 1; |
01a599c9 | 525 | |
fb43ada4 | 526 | Int_t ievent ; |
527 | for (ievent = fFirstEvent; ievent <= fLastEvent; ievent++) { | |
aa0b9641 | 528 | gime->Event(ievent,"R") ; |
0588c896 | 529 | //Make some initializations |
55ea5766 | 530 | fNTrackSegments = 0 ; |
531 | fEmcFirst = 0 ; | |
532 | fEmcLast = 0 ; | |
533 | fCpvFirst = 0 ; | |
534 | fCpvLast = 0 ; | |
88cb7938 | 535 | |
536 | gime->TrackSegments()->Clear(); | |
55ea5766 | 537 | |
9688c1dd | 538 | // if(!ReadRecPoints(ievent)) continue; //reads RecPoints for event ievent |
539 | ||
88cb7938 | 540 | for(fModule = 1; fModule <= geom->GetNModules() ; fModule++ ) { |
2731cd1e | 541 | FillOneModule() ; |
2731cd1e | 542 | MakeLinks() ; |
2731cd1e | 543 | MakePairs() ; |
2731cd1e | 544 | } |
28c3a259 | 545 | |
90cceaf6 | 546 | WriteTrackSegments() ; |
7b7c1533 | 547 | |
2731cd1e | 548 | if(strstr(option,"deb")) |
88cb7938 | 549 | PrintTrackSegments(option); |
94de8339 | 550 | |
551 | //increment the total number of track segments per run | |
88cb7938 | 552 | fTrackSegmentsInRun += gime->TrackSegments()->GetEntriesFast() ; |
2731cd1e | 553 | } |
88cb7938 | 554 | |
2731cd1e | 555 | if(strstr(option,"tim")){ |
556 | gBenchmark->Stop("PHOSTSMaker"); | |
21cd0c07 | 557 | Info("Exec", "took %f seconds for making TS %f seconds per event", |
88cb7938 | 558 | gBenchmark->GetCpuTime("PHOSTSMaker"), |
eabde521 | 559 | gBenchmark->GetCpuTime("PHOSTSMaker")/nEvents) ; |
88cb7938 | 560 | } |
adcca1e6 | 561 | if(fWrite) //do not unload in "on flight" mode |
562 | Unload(); | |
88cb7938 | 563 | } |
564 | ||
565 | //____________________________________________________________________________ | |
566 | void AliPHOSTrackSegmentMakerv1::Unload() | |
567 | { | |
e957fea8 | 568 | // Unloads the task from the folder |
88cb7938 | 569 | AliPHOSGetter * gime = AliPHOSGetter::Instance() ; |
570 | gime->PhosLoader()->UnloadRecPoints() ; | |
571 | gime->PhosLoader()->UnloadTracks() ; | |
d15a28e7 | 572 | } |
7b7c1533 | 573 | |
d15a28e7 | 574 | //____________________________________________________________________________ |
702ab87e | 575 | void AliPHOSTrackSegmentMakerv1::Print(const Option_t *)const |
a4e98857 | 576 | { |
baef0810 | 577 | // Print TrackSegmentMaker parameters |
578 | ||
21cd0c07 | 579 | TString message("") ; |
7b7c1533 | 580 | if( strcmp(GetName(), "") != 0 ) { |
21cd0c07 | 581 | message = "\n======== AliPHOSTrackSegmentMakerv1 ========\n" ; |
582 | message += "Making Track segments\n" ; | |
583 | message += "with parameters:\n" ; | |
194f9939 | 584 | message += " Maximal EMC - CPV distance (cm) %f\n" ; |
21cd0c07 | 585 | message += "============================================\n" ; |
586 | Info("Print", message.Data(),fRcpv) ; | |
2731cd1e | 587 | } |
588 | else | |
21cd0c07 | 589 | Info("Print", "AliPHOSTrackSegmentMakerv1 not initialized ") ; |
d15a28e7 | 590 | } |
7b7c1533 | 591 | |
d15a28e7 | 592 | //____________________________________________________________________________ |
90cceaf6 | 593 | void AliPHOSTrackSegmentMakerv1::WriteTrackSegments() |
a4e98857 | 594 | { |
f035f6ce | 595 | // Writes found TrackSegments to TreeR. Creates branches |
596 | // "PHOSTS" and "AliPHOSTrackSegmentMaker" with the same title. | |
597 | // In the former branch found TrackSegments are stored, while | |
598 | // in the latter all parameters, with which TS were made. | |
599 | // ROOT does not allow overwriting existing branches, therefore | |
a4e98857 | 600 | // first we check, if branches with the same title already exist. |
f035f6ce | 601 | // If yes - exits without writing. |
88cb7938 | 602 | |
603 | AliPHOSGetter *gime = AliPHOSGetter::Instance() ; | |
55ea5766 | 604 | |
fbf811ec | 605 | TClonesArray * trackSegments = gime->TrackSegments() ; |
55ea5766 | 606 | trackSegments->Expand(trackSegments->GetEntriesFast()) ; |
8d0f3f77 | 607 | |
adcca1e6 | 608 | if(fWrite){ //We write TreeT |
609 | TTree * treeT = gime->TreeT(); | |
610 | ||
611 | //First TS | |
612 | Int_t bufferSize = 32000 ; | |
613 | TBranch * tsBranch = treeT->Branch("PHOSTS",&trackSegments,bufferSize); | |
614 | tsBranch->Fill() ; | |
615 | ||
616 | gime->WriteTracks("OVERWRITE"); | |
617 | gime->WriteTrackSegmentMaker("OVERWRITE"); | |
618 | } | |
2731cd1e | 619 | } |
98cbd830 | 620 | |
98cbd830 | 621 | |
2731cd1e | 622 | //____________________________________________________________________________ |
a4e98857 | 623 | void AliPHOSTrackSegmentMakerv1::PrintTrackSegments(Option_t * option) |
624 | { | |
f035f6ce | 625 | // option deb - prints # of found TrackSegments |
626 | // option deb all - prints as well indexed of found RecParticles assigned to the TS | |
9688c1dd | 627 | |
88cb7938 | 628 | TClonesArray * trackSegments = AliPHOSGetter::Instance()->TrackSegments() ; |
21cd0c07 | 629 | |
88cb7938 | 630 | Info("PrintTrackSegments", "Results from TrackSegmentMaker:") ; |
631 | printf("nevent: %d\n", gAlice->GetEvNumber()) ; | |
632 | printf(" Found %d TrackSegments\n", trackSegments->GetEntriesFast() ); | |
633 | ||
2731cd1e | 634 | if(strstr(option,"all")) { // printing found TS |
88cb7938 | 635 | printf("TrackSegment # EMC RP# CPV RP#\n") ; |
2731cd1e | 636 | Int_t index; |
7b7c1533 | 637 | for (index = 0 ; index <trackSegments->GetEntriesFast() ; index++) { |
638 | AliPHOSTrackSegment * ts = (AliPHOSTrackSegment * )trackSegments->At(index) ; | |
88cb7938 | 639 | printf(" %d %d %d \n", ts->GetIndexInList(), ts->GetEmcIndex(), ts->GetCpvIndex() ) ; |
2731cd1e | 640 | } |
d15a28e7 | 641 | } |
2731cd1e | 642 | } |