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