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