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