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