]>
Commit | Line | Data |
---|---|---|
23b18f4e | 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 | **************************************************************************/ | |
15 | ||
7d855b04 | 16 | /// \class AliTPCLaserTrack |
17 | /// \brief Surveyed Laser Track positions | |
18 | /// | |
19 | /// the position and direction information are stored in | |
20 | /// the AliExternalTrackParam base class | |
21 | /// This class extends this information by identification parameters | |
22 | /// | |
23 | /// Dump positions to a tree: | |
24 | /// ~~~ | |
25 | /// AliTPCLaserTrack::LoadTracks(); | |
26 | /// TObjArray *arr=AliTPCLaserTrack::GetTracks(); | |
27 | /// TTreeSRedirector *s=new TTreeSRedirector("LaserTracks.root"); | |
28 | /// TIter next(arr); | |
29 | /// TObject *o=0x0; | |
30 | /// while ( (o=next()) ) (*s) << "tracks" << "l.=" << o << "\n"; | |
31 | /// delete s; | |
32 | /// ~~~ | |
33 | /// draw something | |
34 | /// TFile f("LaserTracks.root"); | |
35 | /// TTree *tracks=(TTree*)f.Get("tracks"); | |
36 | /// tracks->Draw("fVecGY.fElements:fVecGX.fElements"); | |
37 | /// | |
38 | /// tracks->Draw("fVecGY.fElements:fVecGX.fElements>>h(500,-250,250,500,-250,250)","fId<7") | |
7442bceb | 39 | |
23b18f4e | 40 | |
41 | #include <TObjArray.h> | |
42 | #include <TFile.h> | |
43 | #include <TString.h> | |
44 | #include <TSystem.h> | |
45 | ||
46 | #include "AliLog.h" | |
7442bceb | 47 | #include "AliCDBManager.h" |
48 | #include "AliCDBEntry.h" | |
49 | #include "AliCDBPath.h" | |
23b18f4e | 50 | #include "AliTPCLaserTrack.h" |
e955044f | 51 | #include "AliTPCROC.h" |
23b18f4e | 52 | |
7d855b04 | 53 | /// \cond CLASSIMP |
23b18f4e | 54 | ClassImp(AliTPCLaserTrack) |
7d855b04 | 55 | /// \endcond |
23b18f4e | 56 | |
57 | TObjArray *AliTPCLaserTrack::fgArrLaserTracks=0x0; | |
58 | ||
59 | AliTPCLaserTrack::AliTPCLaserTrack() : | |
60 | AliExternalTrackParam(), | |
61 | fId(-1), | |
62 | fSide(-1), | |
63 | fRod(-1), | |
64 | fBundle(-1), | |
7804aba0 | 65 | fBeam(-1), |
e955044f | 66 | fRayLength(0), |
67 | fVecSec(0), // points vectors - sector | |
68 | fVecP2(0), // points vectors - snp | |
69 | fVecPhi(0), // points vectors - global phi | |
70 | fVecGX(0), // points vectors - globalX | |
71 | fVecGY(0), // points vectors - globalY | |
72 | fVecGZ(0), // points vectors - globalZ | |
73 | fVecLX(0), // points vectors - localX | |
74 | fVecLY(0), // points vectors - localY | |
75 | fVecLZ(0) // points vectors - localZ | |
23b18f4e | 76 | { |
7d855b04 | 77 | /// Default constructor |
23b18f4e | 78 | } |
79 | ||
7804aba0 | 80 | AliTPCLaserTrack::AliTPCLaserTrack(const AliTPCLaserTrack <r) : |
23b18f4e | 81 | AliExternalTrackParam(ltr), |
82 | fId(ltr.fId), | |
83 | fSide(ltr.fSide), | |
84 | fRod(ltr.fRod), | |
85 | fBundle(ltr.fBundle), | |
7804aba0 | 86 | fBeam(ltr.fBeam), |
e955044f | 87 | fRayLength(ltr.fRayLength), |
88 | fVecSec(0), // points vectors - sector | |
89 | fVecP2(0), // points vectors - snp | |
90 | fVecPhi(0), // points vectors - global phi | |
91 | fVecGX(0), // points vectors - globalX | |
92 | fVecGY(0), // points vectors - globalY | |
93 | fVecGZ(0), // points vectors - globalZ | |
94 | fVecLX(0), // points vectors - localX | |
95 | fVecLY(0), // points vectors - localY | |
96 | fVecLZ(0) // points vectors - localZ | |
23b18f4e | 97 | { |
7d855b04 | 98 | /// Default constructor |
99 | ||
e955044f | 100 | fVecSec=new TVectorD(*ltr.fVecSec); // points vectors - sector |
101 | fVecP2 =new TVectorD(*ltr.fVecP2); // points vectors - snp | |
102 | fVecPhi=new TVectorD(*ltr.fVecPhi); // points vectors - global phi | |
103 | fVecGX =new TVectorD(*ltr.fVecGX); // points vectors - globalX | |
104 | fVecGY =new TVectorD(*ltr.fVecGY); // points vectors - globalY | |
105 | fVecGZ =new TVectorD(*ltr.fVecGZ); // points vectors - globalZ | |
106 | fVecLX =new TVectorD(*ltr.fVecLX); // points vectors - localX | |
107 | fVecLY =new TVectorD(*ltr.fVecLY); // points vectors - localY | |
108 | fVecLZ =new TVectorD(*ltr.fVecLZ); // points vectors - localY | |
23b18f4e | 109 | |
110 | } | |
111 | ||
112 | AliTPCLaserTrack::AliTPCLaserTrack(const Int_t id, const Int_t side, const Int_t rod, | |
113 | const Int_t bundle, const Int_t beam, | |
114 | Double_t x, Double_t alpha, | |
115 | const Double_t param[5], | |
7804aba0 | 116 | const Double_t covar[15], const Float_t rayLength) : |
23b18f4e | 117 | AliExternalTrackParam(x,alpha,param,covar), |
118 | fId(id), | |
119 | fSide(side), | |
120 | fRod(rod), | |
121 | fBundle(bundle), | |
7804aba0 | 122 | fBeam(beam), |
e955044f | 123 | fRayLength(rayLength), |
124 | fVecSec(new TVectorD(159)), // points vectors - sector | |
125 | fVecP2(new TVectorD(159)), // points vectors - snp | |
126 | fVecPhi(new TVectorD(159)), // points vectors - global phi | |
127 | fVecGX(new TVectorD(159)), // points vectors - globalX | |
128 | fVecGY(new TVectorD(159)), // points vectors - globalY | |
129 | fVecGZ(new TVectorD(159)), // points vectors - globalZ | |
130 | fVecLX(new TVectorD(159)), // points vectors - localX | |
131 | fVecLY(new TVectorD(159)), // points vectors - localY | |
132 | fVecLZ(new TVectorD(159)) // points vectors - localZ | |
133 | ||
23b18f4e | 134 | { |
7d855b04 | 135 | /// create laser track from arguments |
136 | ||
23b18f4e | 137 | } |
7804aba0 | 138 | //_____________________________________________________________________ |
139 | AliTPCLaserTrack& AliTPCLaserTrack::operator = (const AliTPCLaserTrack &source) | |
140 | { | |
7d855b04 | 141 | /// assignment operator |
142 | ||
7804aba0 | 143 | if (&source == this) return *this; |
144 | new (this) AliTPCLaserTrack(source); | |
7d855b04 | 145 | |
7804aba0 | 146 | return *this; |
147 | } | |
23b18f4e | 148 | |
e955044f | 149 | |
150 | AliTPCLaserTrack::~AliTPCLaserTrack(){ | |
7d855b04 | 151 | /// destructor |
152 | ||
153 | delete fVecSec; // - sector numbers | |
154 | delete fVecP2; // - P2 | |
e955044f | 155 | delete fVecPhi; // points vectors - global phi |
156 | delete fVecGX; // points vectors - globalX | |
157 | delete fVecGY; // points vectors - globalY | |
158 | delete fVecGZ; // points vectors - globalZ | |
159 | delete fVecLX; // points vectors - localX | |
160 | delete fVecLY; // points vectors - localY | |
161 | delete fVecLZ; // points vectors - localZ | |
162 | } | |
163 | ||
23b18f4e | 164 | void AliTPCLaserTrack::LoadTracks() |
165 | { | |
7d855b04 | 166 | /// Load all design positions from file into the static array fgArrLaserTracks |
167 | ||
7442bceb | 168 | if ( fgArrLaserTracks ) return; |
78f17711 | 169 | TObjArray *arrLaserTracks = 0x0; |
7d855b04 | 170 | |
7442bceb | 171 | AliCDBManager *man=AliCDBManager::Instance(); |
78f17711 | 172 | if (!man->GetDefaultStorage() && gSystem->Getenv("ALICE_ROOT")) man->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
173 | if (man->GetDefaultStorage()){ | |
174 | if (man->GetRun()<0) man->SetRun(0); | |
175 | AliCDBEntry *entry=man->Get(AliCDBPath("TPC/Calib/LaserTracks")); | |
768e46f1 | 176 | if (!entry) return; |
78f17711 | 177 | arrLaserTracks = (TObjArray*)entry->GetObject(); |
178 | entry->SetOwner(kTRUE); | |
179 | } else { | |
180 | if (!gSystem->AccessPathName("LaserTracks.root")){ | |
181 | TFile f("LaserTracks.root"); | |
182 | arrLaserTracks=(TObjArray*)f.Get("arrLaserTracks"); | |
183 | f.Close(); | |
184 | } | |
185 | } | |
7442bceb | 186 | if ( !arrLaserTracks ) { |
23b18f4e | 187 | // AliWarning(Form("Could not get laser position data from file: '%s'",fgkDataFileName)); |
7442bceb | 188 | return; |
189 | } | |
7d855b04 | 190 | |
78f17711 | 191 | arrLaserTracks->SetOwner(); |
7d855b04 | 192 | |
7442bceb | 193 | fgArrLaserTracks = new TObjArray(fgkNLaserTracks); |
78f17711 | 194 | fgArrLaserTracks->SetOwner(); |
7442bceb | 195 | for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){ |
196 | AliTPCLaserTrack *ltr = (AliTPCLaserTrack*)arrLaserTracks->At(itrack); | |
197 | if ( !ltr ){ | |
23b18f4e | 198 | // AliWarning(Form("No informatino found for Track %d!",itrack)); |
7442bceb | 199 | continue; |
23b18f4e | 200 | } |
7442bceb | 201 | ltr->UpdatePoints(); |
202 | fgArrLaserTracks->AddAt(new AliTPCLaserTrack(*ltr),itrack); | |
203 | } | |
78f17711 | 204 | |
ff595463 | 205 | //do not delete - the entry is cached in the OCDB manager and is cleaned up there |
206 | //delete arrLaserTracks; | |
23b18f4e | 207 | } |
208 | ||
f1fcccb7 | 209 | |
e955044f | 210 | void AliTPCLaserTrack::UpdatePoints(){ |
7d855b04 | 211 | /// update track points |
212 | ||
7442bceb | 213 | const Double_t kMaxSnp=0.97; |
e955044f | 214 | AliTPCROC* roc = AliTPCROC::Instance(); |
215 | // | |
216 | // | |
217 | if (!fVecSec){ | |
218 | fVecSec=new TVectorD(159); | |
7d855b04 | 219 | fVecP2 =new TVectorD(159); // - P2 |
e955044f | 220 | fVecPhi=new TVectorD(159); // - Phi |
221 | fVecGX=new TVectorD(159); // points vectors - globalX | |
222 | fVecGY=new TVectorD(159); // points vectors - globalY | |
223 | fVecGZ=new TVectorD(159); // points vectors - globalZ | |
224 | fVecLX=new TVectorD(159); // points vectors - localX | |
225 | fVecLY=new TVectorD(159); // points vectors - localY | |
226 | fVecLZ=new TVectorD(159); // points vectors - localZ | |
227 | ||
228 | } | |
229 | for (Int_t irow=158; irow>=0; irow--){ | |
7442bceb | 230 | (*fVecSec)[irow]= -1; // - |
e955044f | 231 | (*fVecP2)[irow] = 0; // - P2 -snp |
232 | (*fVecPhi)[irow]= 0; // - global phi | |
233 | (*fVecGX)[irow] = 0; // points vectors - globalX | |
234 | (*fVecGY)[irow] = 0; // points vectors - globalY | |
235 | (*fVecGZ)[irow] = 0; // points vectors - globalZ | |
236 | (*fVecLX)[irow] = 0; // points vectors - localX | |
237 | (*fVecLY)[irow] = 0; // points vectors - localY | |
238 | (*fVecLZ)[irow] = 0; // points vectors - localZ | |
239 | ||
240 | } | |
241 | Double_t gxyz[3]; | |
242 | Double_t lxyz[3]; | |
243 | AliTPCLaserTrack*ltrp=new AliTPCLaserTrack(*this); //make temporary track | |
244 | ||
245 | for (Int_t irow=158; irow>=0; irow--){ | |
246 | UInt_t srow = irow; | |
247 | Int_t sector=0; | |
7d855b04 | 248 | |
e955044f | 249 | if (srow >=roc->GetNRows(0)) { |
250 | srow-=roc->GetNRows(0); | |
251 | sector=36 ; | |
252 | } | |
253 | lxyz[0]= roc->GetPadRowRadii(sector,srow); | |
254 | if (!ltrp->PropagateTo(lxyz[0],5)) break; | |
255 | ltrp->GetXYZ(gxyz); | |
256 | // | |
257 | Double_t alpha=TMath::ATan2(gxyz[1],gxyz[0]); | |
258 | if (alpha<0) alpha+=2*TMath::Pi(); | |
259 | sector +=TMath::Nint(-0.5+9*alpha/TMath::Pi()); | |
fb962ae3 | 260 | if (gxyz[2]<0) sector+=18; |
7d855b04 | 261 | Double_t salpha = TMath::Pi()*(sector+0.5)/9.; |
e955044f | 262 | if (!ltrp->Rotate(salpha)) break; |
263 | if (!ltrp->PropagateTo(lxyz[0],5)) break; | |
264 | if (TMath::Abs(ltrp->GetSnp())>kMaxSnp) break; | |
265 | ltrp->GetXYZ(gxyz); | |
266 | lxyz[1]=ltrp->GetY(); | |
267 | lxyz[2]=ltrp->GetZ(); | |
268 | (*fVecSec)[irow]= sector; | |
269 | (*fVecP2)[irow] = ltrp->GetSnp(); // - P2 -snp | |
270 | (*fVecPhi)[irow]= TMath::ATan2(gxyz[1],gxyz[0]); // - global phi | |
271 | (*fVecGX)[irow] = gxyz[0]; // points vectors - globalX | |
272 | (*fVecGY)[irow] = gxyz[1]; // points vectors - globalY | |
273 | (*fVecGZ)[irow] = gxyz[2]; // points vectors - globalZ | |
274 | (*fVecLX)[irow] = lxyz[0]; // points vectors - localX | |
275 | (*fVecLY)[irow] = lxyz[1]; // points vectors - localY | |
276 | (*fVecLZ)[irow] = lxyz[2]; // points vectors - localZ | |
277 | ||
278 | } | |
279 | delete ltrp; // delete temporary track | |
280 | } | |
281 | ||
38b1a1ca | 282 | Int_t AliTPCLaserTrack::IdentifyTrack(AliExternalTrackParam *track, Int_t side) |
23b18f4e | 283 | { |
7d855b04 | 284 | /// Find the laser track which is corresponding closest to 'track' |
285 | /// return its id | |
286 | ||
b51d4393 | 287 | const Float_t kMaxdphi=0.2; |
265e5fdb | 288 | const Float_t kMaxdphiP=0.05; |
289 | const Float_t kMaxdz=40; | |
f1fcccb7 | 290 | |
291 | if ( !fgArrLaserTracks ) LoadTracks(); | |
292 | TObjArray *arrTracks = GetTracks(); | |
f1fcccb7 | 293 | Double_t lxyz0[3]; |
294 | Double_t lxyz1[3]; | |
295 | Double_t pxyz0[3]; | |
296 | Double_t pxyz1[3]; | |
297 | track->GetXYZ(lxyz0); | |
38b1a1ca | 298 | track->GetDirection(pxyz0); |
265e5fdb | 299 | // |
38b1a1ca | 300 | Float_t mindist=10; // maxima minimal distance |
f1fcccb7 | 301 | Int_t id = -1; |
7d855b04 | 302 | for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){ |
38b1a1ca | 303 | AliTPCLaserTrack *ltr = (AliTPCLaserTrack*)arrTracks->UncheckedAt(itrack); |
304 | if (side>=0) if (ltr->GetSide()!=side) continue; | |
f1fcccb7 | 305 | Double_t * kokot = (Double_t*)ltr->GetParameter(); |
306 | kokot[4]=-0.0000000001; | |
23b18f4e | 307 | // |
f1fcccb7 | 308 | ltr->GetXYZ(lxyz1); |
b51d4393 | 309 | if (TMath::Abs(lxyz1[2]-lxyz0[2])>kMaxdz) continue; |
f1fcccb7 | 310 | // phi position |
311 | Double_t phi0 = TMath::ATan2(lxyz0[1],lxyz0[0]); | |
312 | Double_t phi1 = TMath::ATan2(lxyz1[1],lxyz1[0]); | |
b51d4393 | 313 | if (TMath::Abs(phi0-phi1)>kMaxdphi) continue; |
f1fcccb7 | 314 | // phi direction |
38b1a1ca | 315 | ltr->GetDirection(pxyz1); |
316 | Float_t direction= pxyz0[0]*pxyz1[0] + pxyz0[1]*pxyz1[1] + pxyz0[2]*pxyz1[2]; | |
317 | Float_t distdir = (1-TMath::Abs(direction))*90.; //distance at entrance | |
318 | if (1-TMath::Abs(direction)>kMaxdphiP) | |
f1fcccb7 | 319 | continue; |
23b18f4e | 320 | // |
265e5fdb | 321 | Float_t dist=0; |
322 | dist+=TMath::Abs(lxyz1[0]-lxyz0[0]); | |
323 | dist+=TMath::Abs(lxyz1[1]-lxyz0[1]); | |
38b1a1ca | 324 | // dist+=TMath::Abs(lxyz1[2]-lxyz0[2]); //z is not used for distance calculation |
265e5fdb | 325 | dist+=distdir; |
7d855b04 | 326 | // |
265e5fdb | 327 | if (id<0) { |
7d855b04 | 328 | id =itrack; |
329 | mindist=dist; | |
265e5fdb | 330 | continue; |
331 | } | |
332 | if (dist>mindist) continue; | |
333 | id = itrack; | |
334 | mindist=dist; | |
f1fcccb7 | 335 | } |
336 | return id; | |
23b18f4e | 337 | } |
338 |