]>
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 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // This class is a container class for the laser beam positions of // | |
20 | // the TPC laser system (ALICE-INT-2002-022 v.1 ). // | |
21 | // The system consits of 6 Laser Rods, each contains four mirror bundels // | |
22 | // on each side of the TPC. Each bundle has seven mirrors. // | |
23 | // // | |
24 | // The TPC side 0 corresponds to the "Shaft Side (A)", side 1 corresponds // | |
25 | // to the "Muon Side (C)". | |
26 | // The laser rods are counted counter clockwise starting with the one // | |
27 | // with the smalles phi angle. // | |
28 | // The mirror bundles in one rod for each side are counted starting from // | |
29 | // form the greatest z value to the smalles. // | |
30 | // The beams in each bundel are counted counter clockwise. Having all beams // | |
31 | // pointing downward, the first beam will be the leftmost. // | |
32 | // // | |
33 | /////////////////////////////////////////////////////////////////////////////// | |
34 | ||
35 | /* | |
36 | Create File with design positions | |
37 | ||
38 | .L AliTPCLaserTrack.cxx+ | |
39 | AliTPCLaserTracks ltracks | |
40 | ltracks.WriteTreeDesignData() | |
41 | TFile f("LaserTracksDesing.root"); | |
42 | TTree * tree =(TTree*)f.Get("LaserTracks"); | |
43 | ||
44 | */ | |
45 | ||
46 | #include <iostream.h> | |
47 | #include <TString.h> | |
48 | #include <TPolyLine3D.h> | |
49 | #include <TMath.h> | |
50 | #include <TTree.h> | |
51 | #include <TFile.h> | |
52 | #include <TEventList.h> | |
53 | #include <TVector2.h> | |
54 | #include <TVector3.h> | |
55 | #include <TROOT.h> | |
56 | ||
57 | #include <TGraph.h> | |
58 | ||
59 | ||
60 | #include "AliTPCLaserTracks.h" | |
61 | ||
62 | //////////////////////////////////////////////////////////////////////// | |
63 | // Class AliTPCLaserTracks | |
64 | //////////////////////////////////////////////////////////////////////// | |
65 | ||
66 | ClassImp(AliTPCLaserTracks) | |
67 | ||
68 | AliTPCLaserTracks::AliTPCLaserTracks(): | |
69 | fId(-1), | |
70 | fSide(-1), | |
71 | fRod(-1), | |
72 | fBundle(-1), | |
73 | fBeam(-1), | |
74 | fX(0), | |
75 | fY(0), | |
76 | fZ(0), | |
77 | fPhi(0), | |
78 | fTheta(0), | |
79 | fMaxSize(0), | |
80 | fNpoints(0), | |
81 | fXarr(0x0), | |
82 | fYarr(0x0), | |
83 | fZarr(0x0) | |
84 | ||
85 | { | |
86 | // | |
87 | // AliTPCLaserTracks default constructor | |
88 | // | |
89 | } | |
90 | ||
91 | //_______________________________________________________________________ | |
92 | AliTPCLaserTracks::AliTPCLaserTracks(Int_t npoints): | |
93 | fId(-1), | |
94 | fSide(-1), | |
95 | fRod(-1), | |
96 | fBundle(-1), | |
97 | fBeam(-1), | |
98 | fX(0), | |
99 | fY(0), | |
100 | fZ(0), | |
101 | fPhi(0), | |
102 | fTheta(0), | |
103 | fMaxSize(0), | |
104 | fNpoints(0), | |
105 | fXarr(0x0), | |
106 | fYarr(0x0), | |
107 | fZarr(0x0) | |
108 | ||
109 | { | |
110 | // | |
111 | // AliTPCLaserTracks constructor to initialise array of points | |
112 | // | |
113 | fNpoints = npoints; | |
114 | InitPoints(); | |
115 | } | |
116 | ||
117 | //_______________________________________________________________________ | |
118 | Double_t AliTPCLaserTracks::FindBeamLength(TVector3 vF, TVector3 vP) | |
119 | { | |
120 | // | |
121 | // Find distance between mirror and the intersection between | |
122 | // inner and outer field cage respectively | |
123 | // | |
124 | // use the pq formula to find the intersection point between | |
125 | // the beam and the inner and outer fieldcage cylinders | |
126 | // The formulae solved are | |
127 | // | |
128 | // line = zylinder | |
129 | // xPoint = vF.X() + n*vP.X() = r*cos(phi) | |
130 | // yPoint = vF.Y() + n*vP.Y() = r*sin(phi) | |
131 | // zPoint = vF.Y() + n*vP.Y() | |
132 | // | |
133 | // get n from the first two equations, calculate x,y,zPoint | |
134 | // | |
135 | // vF is the mirror position and vP the beam direction | |
136 | Double_t r[2]; //smalles r[0] and largest r[1] pad radius | |
137 | r[0] = 80.0; //smalles pad radius | |
138 | r[1] = 260.0; //largest pad radius | |
139 | ||
140 | Double_t fxpxfypy = vF.X()*vP.X()+vF.Y()*vP.Y(); | |
141 | Double_t px2py2 = vP.X()*vP.X()+vP.Y()*vP.Y(); | |
142 | ||
143 | for (Int_t i=0; i<2; i++){ | |
144 | Double_t rad = (fxpxfypy/px2py2)*(fxpxfypy/px2py2)- | |
145 | (vF.X()*vF.X()+vF.Y()*vF.Y()-r[i]*r[i])/px2py2; | |
146 | ||
147 | if ( rad >= 0 ){ | |
148 | Double_t n1 = -(fxpxfypy)/px2py2+TMath::Sqrt(rad); | |
149 | TVector3 vI1(vF.X()+n1*vP.X(), | |
150 | vF.Y()+n1*vP.Y(), | |
151 | vF.Z()+n1*vP.Z()); | |
152 | ||
153 | Double_t n2 = -(fxpxfypy)/px2py2-TMath::Sqrt(rad); | |
154 | TVector3 vI2(vF.X()+n2*vP.X(), | |
155 | vF.Y()+n2*vP.Y(), | |
156 | vF.Z()+n2*vP.Z()); | |
157 | ||
158 | ||
159 | //if we cross two boarders on our way return the closer boarder | |
160 | if ( n1>0 && n2>0 ) | |
161 | if ( (vF-vI1).Mag() <= (vF-vI2).Mag() ) | |
162 | return (vF-vI1).Mag(); | |
163 | else | |
164 | return (vF-vI2).Mag(); | |
165 | ||
166 | if ( n1>0 ) | |
167 | return (vF-vI1).Mag(); | |
168 | ||
169 | if ( n2>0 ) | |
170 | return (vF-vI2).Mag(); | |
171 | ||
172 | } | |
173 | } | |
174 | ||
175 | return 3.4e38; //not found!! | |
176 | } | |
177 | ||
178 | //_______________________________________________________________________ | |
179 | void AliTPCLaserTracks::WriteTreeDesignData() | |
180 | { | |
181 | // | |
182 | // Write a tree with the design data of the laser track positions | |
183 | // | |
184 | ||
185 | TFile *f = TFile::Open("LaserTracksDesing.root","recreate"); | |
186 | ||
187 | AliTPCLaserTracks *ltp = new AliTPCLaserTracks(2); | |
188 | ||
189 | TTree *t = new TTree("LaserTracks","LaserTracks"); | |
190 | t->Branch("LaserTracks","AliTPCLaserTracks",<p); | |
191 | t->AutoSave(); | |
192 | ||
193 | Double_t phiBeam[7] = {-31.8,-16.,-9.2,2.5,9.2,16.,31.8}; | |
194 | Double_t phiRod[6] = {40.,100.,160.,220.,280.,340.}; //-20. for the muon side | |
195 | // Double_t zBundleCorse[2][4] = {{10,79,163,241},{13,85,169,247}}; | |
196 | Double_t zBundleCorse[2][4] = {{241.,163.,79.,10.},{247.,169.,85.,13.}}; | |
197 | Double_t zBeamFine[7] = {1.45,1.3,1.15,1.3,1.15,1.3,1.45}; | |
198 | ||
199 | Int_t id=0; | |
200 | //loop over TPC side -- 0:A (Shaft) side -- 1:C (Muon) side | |
201 | for (Int_t side=0; side<2; side++){ | |
202 | //loop over laser rods -- counterclockwise | |
203 | for (Int_t rod=0; rod<6; rod++){ | |
204 | //center of the rod | |
205 | TVector2 vRod; | |
206 | ||
207 | Double_t phiRod2 = phiRod[rod]-side*20; | |
208 | vRod.SetMagPhi(254.25, //center of the rod at 254.25cm | |
209 | TMath::DegToRad()* | |
210 | (phiRod2) //-20 deg on C-Side | |
211 | ); | |
212 | ||
213 | //loop over bundle -- counted from large z to small z | |
214 | for (Int_t bundle=0; bundle<4; bundle++){ | |
215 | //center of the bundle; not yet rotated | |
216 | Int_t bundleS = bundle; | |
217 | // if ( side == 1 ) bundleS = 4-bundle; | |
218 | if ( side == 1 ) bundleS = 3-bundle; | |
219 | ||
220 | TVector2 vBundle; | |
221 | vBundle.SetMagPhi(.65, | |
222 | TMath::DegToRad()* | |
223 | //? TMath::Power(-1,side)* | |
224 | (phiRod2+180.-90.*bundleS) | |
225 | ); | |
226 | ||
227 | //loop over beam | |
228 | Int_t i=0; | |
229 | for (Int_t beam=0; beam<7; beam++){ | |
230 | TVector2 vBeam; | |
231 | if ( beam == 3 ) | |
232 | vBeam.Set(0.,0.); | |
233 | else{ | |
234 | vBeam.SetMagPhi(1.,TMath::DegToRad()*(phiRod2+i*60)); | |
235 | i++; | |
236 | } | |
237 | ||
238 | TVector2 xyMirror = vRod+vBundle+vBeam; | |
239 | Double_t zMirror = (zBundleCorse[rod%2][bundleS]+zBeamFine[beam])*TMath::Power(-1,side); | |
240 | TVector3 v3Mirror(xyMirror.X(),xyMirror.Y(),zMirror); | |
241 | ||
242 | Double_t phi = TMath::DegToRad()*(phiRod2+180+phiBeam[beam]*TMath::Power(-1,side)); | |
243 | Double_t theta = TMath::DegToRad()*90; | |
244 | ||
245 | TVector3 v3Beam; | |
246 | v3Beam.SetMagThetaPhi(1,theta,phi); //Direction Vector | |
247 | v3Beam.SetMagThetaPhi(FindBeamLength(v3Mirror,v3Beam), theta, phi); | |
248 | ||
249 | ||
250 | ||
251 | ltp->SetId(id); | |
252 | ltp->SetSide(side); | |
253 | ltp->SetRod(rod); | |
254 | ltp->SetBundle(bundleS); | |
255 | ltp->SetBeam(beam); | |
256 | ||
257 | ltp->SetX(xyMirror.X()); | |
258 | ltp->SetY(xyMirror.Y()); | |
259 | ltp->SetZ(zMirror); | |
260 | ||
261 | ltp->SetPhi(phi); | |
262 | ltp->SetTheta(theta); | |
263 | ||
264 | // ltp->InitPoints(2); | |
265 | ltp->SetPoint(0,xyMirror.X(),xyMirror.Y(),zMirror); | |
266 | ltp->SetPoint(1,xyMirror.X()+v3Beam.X(),xyMirror.Y()+v3Beam.Y(),zMirror+v3Beam.Z()); | |
267 | ||
268 | cout<< "Id: " << id | |
269 | << " Side: " << side | |
270 | << " Rod: " << rod | |
271 | << " Bundle: " << bundleS | |
272 | << " Beam: " << beam | |
273 | << endl; | |
274 | ||
275 | ||
276 | t->Fill(); | |
277 | //delete line; | |
278 | id++; | |
279 | // cout << "Filled!!!" << endl; | |
280 | } | |
281 | } | |
282 | } | |
283 | } | |
284 | ||
285 | t->Write(); | |
286 | delete f; | |
287 | // delete t; | |
288 | // delete ltp; | |
289 | // delete line; | |
290 | } | |
291 | ||
292 | //_______________________________________________________________________ | |
293 | TPolyLine3D* AliTPCLaserTracks::GetLine() | |
294 | { | |
295 | if ( fNpoints ) return new TPolyLine3D(fNpoints,fXarr,fYarr,fZarr); | |
296 | ||
297 | return 0x0; | |
298 | } | |
299 | ||
300 | //_______________________________________________________________________ | |
301 | TObjArray* AliTPCLaserTracks::GetLines(Char_t* file, Char_t *cuts) | |
302 | { | |
303 | ||
304 | TObjArray *array = new TObjArray; | |
305 | ||
306 | TFile *f = TFile::Open(file,"read"); | |
307 | TTree *tree = (TTree*)f->Get("LaserTracks"); | |
308 | ||
309 | AliTPCLaserTracks *ltp = new AliTPCLaserTracks(); | |
310 | // TEventList *evList = new TEventList("evList"); | |
311 | TEventList evList("evList"); | |
312 | ||
313 | tree->SetBranchAddress("LaserTracks",<p); | |
314 | ||
315 | tree->Draw(">>evList",cuts,"goff"); | |
316 | ||
317 | // cout << "N: " << evList.GetN() << endl; | |
318 | gROOT->cd(); | |
319 | for (Int_t ev = 0; ev < evList.GetN(); ev++){ | |
320 | // cout << ev << endl; | |
321 | tree->GetEntry( evList.GetEntry(ev) ); | |
322 | array->Add(ltp->GetLine()); | |
323 | } | |
324 | // cout << "delte f"<< endl; | |
325 | // delete f; | |
326 | ||
327 | // cout << "evlist" << endl; | |
328 | ||
329 | return array; | |
330 | } | |
331 | ||
332 | //_______________________________________________________________________ | |
333 | void AliTPCLaserTracks::InitPoints() | |
334 | { | |
335 | // | |
336 | // Init point arrays | |
337 | // | |
338 | ||
339 | fMaxSize = fNpoints; | |
340 | fXarr = new Double_t[fMaxSize]; | |
341 | fYarr = new Double_t[fMaxSize]; | |
342 | fZarr = new Double_t[fMaxSize]; | |
343 | } | |
344 | ||
345 | //_______________________________________________________________________ | |
346 | Int_t AliTPCLaserTracks::SetPoint(Int_t point, Double_t x, Double_t y, Double_t z) | |
347 | { | |
348 | // | |
349 | // Set point to point arrays | |
350 | // | |
351 | ||
352 | if ( !fXarr || !fYarr || !fZarr ) return 1; | |
353 | if ( point > fNpoints-1 ) return 1; | |
354 | ||
355 | fXarr[point] = x; | |
356 | fYarr[point] = y; | |
357 | fZarr[point] = z; | |
358 | return 0; | |
359 | } | |
360 | ||
361 | //_______________________________________________________________________ | |
362 | Int_t AliTPCLaserTracks::FindMirror(Char_t *file, Double_t x, Double_t y, Double_t z, Double_t phi) | |
363 | { | |
364 | // | |
365 | // return the id of the mirror in 'file' that maches best the given parameters | |
366 | // | |
367 | ||
368 | TFile *f = TFile::Open(file,"read"); | |
369 | TTree *tree = (TTree*)f->Get("LaserTracks"); | |
370 | ||
371 | AliTPCLaserTracks *ltp = new AliTPCLaserTracks(); | |
372 | TEventList evList("evList"); | |
373 | ||
374 | tree->SetBranchAddress("LaserTracks",<p); | |
375 | ||
376 | TString s; | |
377 | s = "abs(fX-"; s+= x; | |
378 | s+= ")<3&&abs(fY-"; s+=y; | |
379 | s+= ")<3&&abs(fZ-"; s+= z; | |
380 | s+= ")<1.5"; | |
381 | // s+= "&&((abs(fPhi-";s+= phi; | |
382 | // s+= ")<.06)||(abs(fPhi-";s+= (phi-TMath::DegToRad()*180); | |
383 | // s+= ")<.06))"; | |
384 | cout << s.Data() << endl; | |
385 | ||
386 | tree->Draw(">>evList",s.Data()); | |
387 | ||
388 | Double_t dphiMin=TMath::Pi(); | |
389 | Int_t id=-1; | |
390 | ||
391 | cout << "nev: " << evList.GetN() << endl; | |
392 | for (Int_t i=0; i<evList.GetN(); i++){ | |
393 | tree->GetEntry( evList.GetEntry(i) ); | |
394 | Double_t dphi = TMath::Abs(ltp->GetPhi() - phi); | |
395 | if ( dphi > TMath::DegToRad()*180 ) dphi-=TMath::DegToRad()*180; | |
396 | if ( dphi<dphiMin ) { | |
397 | dphiMin = dphi; | |
398 | id = ltp->GetId(); | |
399 | } | |
400 | } | |
401 | ||
402 | return id; | |
403 | delete f; | |
404 | } | |
405 | ||
406 | //_______________________________________________________________________ | |
407 | AliTPCLaserTracks::~AliTPCLaserTracks() | |
408 | { | |
409 | // | |
410 | // standard destructor | |
411 | // | |
412 | ||
413 | // if ( fP ) delete fP; | |
414 | if ( fXarr ) delete fXarr; | |
415 | if ( fYarr ) delete fYarr; | |
416 | if ( fZarr ) delete fZarr; | |
417 | } |