1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
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. //
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. //
33 ///////////////////////////////////////////////////////////////////////////////
36 Create File with design positions
38 .L AliTPCLaserTrack.cxx+
39 AliTPCLaserTracks ltracks
40 ltracks.WriteTreeDesignData()
41 TFile f("LaserTracksDesing.root");
42 TTree * tree =(TTree*)f.Get("LaserTracks");
46 #include <Riostream.h>
48 #include <TPolyLine3D.h>
52 #include <TEventList.h>
60 #include "AliTPCLaserTracks.h"
62 ////////////////////////////////////////////////////////////////////////
63 // Class AliTPCLaserTracks
64 ////////////////////////////////////////////////////////////////////////
66 ClassImp(AliTPCLaserTracks)
68 AliTPCLaserTracks::AliTPCLaserTracks():TObject(),
88 // AliTPCLaserTracks default constructor
92 //_______________________________________________________________________
93 AliTPCLaserTracks::AliTPCLaserTracks(Int_t npoints):TObject(),
113 // AliTPCLaserTracks constructor to initialise array of points
118 //______________________________________________________________________
119 AliTPCLaserTracks::AliTPCLaserTracks(const AliTPCLaserTracks ¶m):TObject(),
142 //______________________________________________________________________
143 AliTPCLaserTracks & AliTPCLaserTracks::operator=(const AliTPCLaserTracks & param)
146 // assignment operator - dummy
148 if (this == ¶m) return (*this);
154 //_______________________________________________________________________
155 Double_t AliTPCLaserTracks::FindBeamLength(TVector3 vF, TVector3 vP)
158 // Find distance between mirror and the intersection between
159 // inner and outer field cage respectively
161 // use the pq formula to find the intersection point between
162 // the beam and the inner and outer fieldcage cylinders
163 // The formulae solved are
166 // xPoint = vF.X() + n*vP.X() = r*cos(phi)
167 // yPoint = vF.Y() + n*vP.Y() = r*sin(phi)
168 // zPoint = vF.Y() + n*vP.Y()
170 // get n from the first two equations, calculate x,y,zPoint
172 // vF is the mirror position and vP the beam direction
173 Double_t r[2]; //smalles r[0] and largest r[1] pad radius
174 r[0] = 80.0; //smalles pad radius
175 r[1] = 260.0; //largest pad radius
177 Double_t fxpxfypy = vF.X()*vP.X()+vF.Y()*vP.Y();
178 Double_t px2py2 = vP.X()*vP.X()+vP.Y()*vP.Y();
180 for (Int_t i=0; i<2; i++){
181 Double_t rad = (fxpxfypy/px2py2)*(fxpxfypy/px2py2)-
182 (vF.X()*vF.X()+vF.Y()*vF.Y()-r[i]*r[i])/px2py2;
185 Double_t n1 = -(fxpxfypy)/px2py2+TMath::Sqrt(rad);
186 TVector3 vI1(vF.X()+n1*vP.X(),
190 Double_t n2 = -(fxpxfypy)/px2py2-TMath::Sqrt(rad);
191 TVector3 vI2(vF.X()+n2*vP.X(),
196 //if we cross two boarders on our way return the closer boarder
197 if ( (n1>0) && (n2>0) ) {
198 if ( (vF-vI1).Mag() <= (vF-vI2).Mag() )
199 return (vF-vI1).Mag();
201 return (vF-vI2).Mag();
205 return (vF-vI1).Mag();
208 return (vF-vI2).Mag();
213 return 3.4e38; //not found!!
216 //_______________________________________________________________________
217 void AliTPCLaserTracks::WriteTreeDesignData()
220 // Write a tree with the design data of the laser track positions
223 TFile *f = TFile::Open("LaserTracksDesing.root","recreate");
225 AliTPCLaserTracks *ltp = new AliTPCLaserTracks(2);
227 TTree *t = new TTree("LaserTracks","LaserTracks");
228 t->Branch("LaserTracks","AliTPCLaserTracks",<p);
231 Double_t phiBeam[7] = {-31.8,-16.,-9.2,2.5,9.2,16.,31.8};
232 Double_t phiRod[6] = {40.,100.,160.,220.,280.,340.}; //-20. for the muon side
233 // Double_t zBundleCorse[2][4] = {{10,79,163,241},{13,85,169,247}};
234 Double_t zBundleCorse[2][4] = {{241.,163.,79.,10.},{247.,169.,85.,13.}};
235 Double_t zBeamFine[7] = {1.45,1.3,1.15,1.3,1.15,1.3,1.45};
238 //loop over TPC side -- 0:A (Shaft) side -- 1:C (Muon) side
239 for (Int_t side=0; side<2; side++){
240 //loop over laser rods -- counterclockwise
241 for (Int_t rod=0; rod<6; rod++){
245 Double_t phiRod2 = phiRod[rod]-side*20;
246 vRod.SetMagPhi(254.25, //center of the rod at 254.25cm
248 (phiRod2) //-20 deg on C-Side
251 //loop over bundle -- counted from large z to small z
252 for (Int_t bundle=0; bundle<4; bundle++){
253 //center of the bundle; not yet rotated
254 Int_t bundleS = bundle;
255 // if ( side == 1 ) bundleS = 4-bundle;
256 if ( side == 1 ) bundleS = 3-bundle;
259 vBundle.SetMagPhi(.65,
261 //? TMath::Power(-1,side)*
262 (phiRod2+180.-90.*bundleS)
267 for (Int_t beam=0; beam<7; beam++){
272 vBeam.SetMagPhi(1.,TMath::DegToRad()*(phiRod2+i*60));
276 TVector2 xyMirror = vRod+vBundle+vBeam;
277 Double_t zMirror = (zBundleCorse[rod%2][bundleS]+zBeamFine[beam])*TMath::Power(-1,side);
278 TVector3 v3Mirror(xyMirror.X(),xyMirror.Y(),zMirror);
280 Double_t phi = TMath::DegToRad()*(phiRod2+180+phiBeam[beam]*TMath::Power(-1,side));
281 Double_t theta = TMath::DegToRad()*90;
284 v3Beam.SetMagThetaPhi(1,theta,phi); //Direction Vector
285 v3Beam.SetMagThetaPhi(FindBeamLength(v3Mirror,v3Beam), theta, phi);
292 ltp->SetBundle(bundleS);
295 ltp->SetX(xyMirror.X());
296 ltp->SetY(xyMirror.Y());
300 ltp->SetTheta(theta);
302 // ltp->InitPoints(2);
303 ltp->SetPoint(0,xyMirror.X(),xyMirror.Y(),zMirror);
304 ltp->SetPoint(1,xyMirror.X()+v3Beam.X(),xyMirror.Y()+v3Beam.Y(),zMirror+v3Beam.Z());
309 << " Bundle: " << bundleS
317 // cout << "Filled!!!" << endl;
330 //_______________________________________________________________________
331 TPolyLine3D* AliTPCLaserTracks::GetLine()
334 // Make a polilyne object oout of the points
336 if ( fNpoints ) return new TPolyLine3D(fNpoints,fXarr,fYarr,fZarr);
341 //_______________________________________________________________________
342 TObjArray* AliTPCLaserTracks::GetLines(const Char_t* file, const Char_t *cuts)
345 // Read the input files with the laser track
346 // Make a array of polylines for visualization
348 TObjArray *array = new TObjArray;
350 TFile *f = TFile::Open(file,"read");
351 TTree *tree = (TTree*)f->Get("LaserTracks");
353 AliTPCLaserTracks *ltp = new AliTPCLaserTracks();
354 // TEventList *evList = new TEventList("evList");
355 TEventList evList("evList");
357 tree->SetBranchAddress("LaserTracks",<p);
359 tree->Draw(">>evList",cuts,"goff");
361 // cout << "N: " << evList.GetN() << endl;
363 for (Int_t ev = 0; ev < evList.GetN(); ev++){
364 // cout << ev << endl;
365 tree->GetEntry( evList.GetEntry(ev) );
366 array->Add(ltp->GetLine());
368 // cout << "delte f"<< endl;
371 // cout << "evlist" << endl;
376 //_______________________________________________________________________
377 void AliTPCLaserTracks::InitPoints()
384 fXarr = new Double_t[fMaxSize];
385 fYarr = new Double_t[fMaxSize];
386 fZarr = new Double_t[fMaxSize];
389 //_______________________________________________________________________
390 Int_t AliTPCLaserTracks::SetPoint(Int_t point, Double_t x, Double_t y, Double_t z)
393 // Set point to point arrays
396 if ( !fXarr || !fYarr || !fZarr ) return 1;
397 if ( point > fNpoints-1 ) return 1;
405 //_______________________________________________________________________
406 Int_t AliTPCLaserTracks::FindMirror(Char_t *file, Double_t x, Double_t y, Double_t z, Double_t phi)
409 // return the id of the mirror in 'file' that maches best the given parameters
412 TFile *f = TFile::Open(file,"read");
413 TTree *tree = (TTree*)f->Get("LaserTracks");
415 AliTPCLaserTracks *ltp = new AliTPCLaserTracks();
416 TEventList evList("evList");
418 tree->SetBranchAddress("LaserTracks",<p);
421 s = "abs(fX-"; s+= x;
422 s+= ")<3&&abs(fY-"; s+=y;
423 s+= ")<3&&abs(fZ-"; s+= z;
425 // s+= "&&((abs(fPhi-";s+= phi;
426 // s+= ")<.06)||(abs(fPhi-";s+= (phi-TMath::DegToRad()*180);
428 cout << s.Data() << endl;
430 tree->Draw(">>evList",s.Data());
432 Double_t dphiMin=TMath::Pi();
435 cout << "nev: " << evList.GetN() << endl;
436 for (Int_t i=0; i<evList.GetN(); i++){
437 tree->GetEntry( evList.GetEntry(i) );
438 Double_t dphi = TMath::Abs(ltp->GetPhi() - phi);
439 if ( dphi > TMath::DegToRad()*180 ) dphi-=TMath::DegToRad()*180;
440 if ( dphi<dphiMin ) {
449 //_______________________________________________________________________
450 AliTPCLaserTracks::~AliTPCLaserTracks()
453 // standard destructor
456 // if ( fP ) delete fP;
457 if ( fXarr ) delete [] fXarr;
458 if ( fYarr ) delete [] fYarr;
459 if ( fZarr ) delete [] fZarr;