]>
Commit | Line | Data |
---|---|---|
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 | ||
17 | #include <TObjArray.h> | |
18 | #include <TFile.h> | |
19 | #include <TString.h> | |
20 | #include <TSystem.h> | |
21 | ||
22 | #include "AliLog.h" | |
23 | #include "AliTPCLaserTrack.h" | |
24 | ||
25 | ClassImp(AliTPCLaserTrack) | |
26 | ||
27 | TObjArray *AliTPCLaserTrack::fgArrLaserTracks=0x0; | |
28 | ||
29 | AliTPCLaserTrack::AliTPCLaserTrack() : | |
30 | AliExternalTrackParam(), | |
31 | fId(-1), | |
32 | fSide(-1), | |
33 | fRod(-1), | |
34 | fBundle(-1), | |
35 | fBeam(-1), | |
36 | fRayLength(0) | |
37 | { | |
38 | // | |
39 | // Default constructor | |
40 | // | |
41 | ||
42 | } | |
43 | ||
44 | AliTPCLaserTrack::AliTPCLaserTrack(const AliTPCLaserTrack <r) : | |
45 | AliExternalTrackParam(ltr), | |
46 | fId(ltr.fId), | |
47 | fSide(ltr.fSide), | |
48 | fRod(ltr.fRod), | |
49 | fBundle(ltr.fBundle), | |
50 | fBeam(ltr.fBeam), | |
51 | fRayLength(ltr.fRayLength) | |
52 | { | |
53 | // | |
54 | // Default constructor | |
55 | // | |
56 | ||
57 | } | |
58 | ||
59 | AliTPCLaserTrack::AliTPCLaserTrack(const Int_t id, const Int_t side, const Int_t rod, | |
60 | const Int_t bundle, const Int_t beam, | |
61 | Double_t x, Double_t alpha, | |
62 | const Double_t param[5], | |
63 | const Double_t covar[15], const Float_t rayLength) : | |
64 | AliExternalTrackParam(x,alpha,param,covar), | |
65 | fId(id), | |
66 | fSide(side), | |
67 | fRod(rod), | |
68 | fBundle(bundle), | |
69 | fBeam(beam), | |
70 | fRayLength(rayLength) | |
71 | { | |
72 | // | |
73 | // create laser track from arguments | |
74 | // | |
75 | ||
76 | } | |
77 | //_____________________________________________________________________ | |
78 | AliTPCLaserTrack& AliTPCLaserTrack::operator = (const AliTPCLaserTrack &source) | |
79 | { | |
80 | // | |
81 | // assignment operator | |
82 | // | |
83 | if (&source == this) return *this; | |
84 | new (this) AliTPCLaserTrack(source); | |
85 | ||
86 | return *this; | |
87 | } | |
88 | ||
89 | void AliTPCLaserTrack::LoadTracks() | |
90 | { | |
91 | // | |
92 | // Load all design positions from file into the static array fgArrLaserTracks | |
93 | // | |
94 | ||
95 | if ( fgArrLaserTracks ) return; | |
96 | ||
97 | TString dataFileName("$ALICE_ROOT/TPC/Calib/LaserTracks.root"); //Path to the Data File | |
98 | ||
99 | TFile *f=TFile::Open(gSystem->ExpandPathName(dataFileName.Data())); | |
100 | if ( !f || !f->IsOpen() ){ | |
101 | // AliWarning(Form("Could not open laser data file: '%s'",dataFileName.Data())); | |
102 | // AliWarning("Could not open laser data file"); | |
103 | return; | |
104 | } | |
105 | TObjArray *arrLaserTracks = (TObjArray*)f->Get("arrLaserTracks"); | |
106 | if ( !arrLaserTracks ) { | |
107 | // AliWarning(Form("Could not get laser position data from file: '%s'",fgkDataFileName)); | |
108 | return; | |
109 | } | |
110 | ||
111 | fgArrLaserTracks = new TObjArray(fgkNLaserTracks); | |
112 | for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){ | |
113 | AliTPCLaserTrack *ltr = (AliTPCLaserTrack*)arrLaserTracks->At(itrack); | |
114 | if ( !ltr ){ | |
115 | // AliWarning(Form("No informatino found for Track %d!",itrack)); | |
116 | continue; | |
117 | } | |
118 | fgArrLaserTracks->AddAt(new AliTPCLaserTrack(*ltr),itrack); | |
119 | } | |
120 | delete f; | |
121 | } | |
122 | ||
123 | ||
124 | Int_t AliTPCLaserTrack::IdentifyTrack(AliExternalTrackParam *track, Int_t side) | |
125 | { | |
126 | // | |
127 | // Find the laser track which is corresponding closest to 'track' | |
128 | // return its id | |
129 | // | |
130 | // | |
131 | const Float_t kMaxdphi=0.2; | |
132 | const Float_t kMaxdphiP=0.05; | |
133 | const Float_t kMaxdz=40; | |
134 | ||
135 | if ( !fgArrLaserTracks ) LoadTracks(); | |
136 | TObjArray *arrTracks = GetTracks(); | |
137 | Double_t lxyz0[3]; | |
138 | Double_t lxyz1[3]; | |
139 | Double_t pxyz0[3]; | |
140 | Double_t pxyz1[3]; | |
141 | track->GetXYZ(lxyz0); | |
142 | track->GetDirection(pxyz0); | |
143 | // | |
144 | Float_t mindist=10; // maxima minimal distance | |
145 | Int_t id = -1; | |
146 | AliExternalTrackParam* ltr0= (AliExternalTrackParam*)arrTracks->UncheckedAt(0); | |
147 | for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){ | |
148 | AliTPCLaserTrack *ltr = (AliTPCLaserTrack*)arrTracks->UncheckedAt(itrack); | |
149 | if (side>=0) if (ltr->GetSide()!=side) continue; | |
150 | Double_t * kokot = (Double_t*)ltr->GetParameter(); | |
151 | kokot[4]=-0.0000000001; | |
152 | // | |
153 | ltr->GetXYZ(lxyz1); | |
154 | if (TMath::Abs(lxyz1[2]-lxyz0[2])>kMaxdz) continue; | |
155 | // phi position | |
156 | Double_t phi0 = TMath::ATan2(lxyz0[1],lxyz0[0]); | |
157 | Double_t phi1 = TMath::ATan2(lxyz1[1],lxyz1[0]); | |
158 | if (TMath::Abs(phi0-phi1)>kMaxdphi) continue; | |
159 | // phi direction | |
160 | ltr->GetDirection(pxyz1); | |
161 | Float_t direction= pxyz0[0]*pxyz1[0] + pxyz0[1]*pxyz1[1] + pxyz0[2]*pxyz1[2]; | |
162 | Float_t distdir = (1-TMath::Abs(direction))*90.; //distance at entrance | |
163 | if (1-TMath::Abs(direction)>kMaxdphiP) | |
164 | continue; | |
165 | // | |
166 | Float_t dist=0; | |
167 | dist+=TMath::Abs(lxyz1[0]-lxyz0[0]); | |
168 | dist+=TMath::Abs(lxyz1[1]-lxyz0[1]); | |
169 | // dist+=TMath::Abs(lxyz1[2]-lxyz0[2]); //z is not used for distance calculation | |
170 | dist+=distdir; | |
171 | // | |
172 | if (id<0) { | |
173 | id =itrack; | |
174 | mindist=dist; | |
175 | ltr0=ltr; | |
176 | continue; | |
177 | } | |
178 | if (dist>mindist) continue; | |
179 | id = itrack; | |
180 | mindist=dist; | |
181 | ltr0=ltr; | |
182 | } | |
183 | return id; | |
184 | } | |
185 |