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