]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCLaserTrack.cxx
Wrong header file names.
[u/mrichter/AliRoot.git] / TPC / AliTPCLaserTrack.cxx
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 &ltr) :
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)
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->GetPxPyPz(pxyz0);
143   //
144   Float_t mindist=40; // 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     AliExternalTrackParam *ltr = (AliExternalTrackParam*)arrTracks->UncheckedAt(itrack);
149     Double_t * kokot = (Double_t*)ltr->GetParameter();
150     kokot[4]=-0.0000000001;
151     //
152     ltr->GetXYZ(lxyz1);
153     if (TMath::Abs(lxyz1[2]-lxyz0[2])>kMaxdz) continue;
154     // phi position
155     Double_t phi0 = TMath::ATan2(lxyz0[1],lxyz0[0]);
156     Double_t phi1 = TMath::ATan2(lxyz1[1],lxyz1[0]);
157     if (TMath::Abs(phi0-phi1)>kMaxdphi) continue;
158     // phi direction
159     ltr->GetPxPyPz(pxyz1);
160     Float_t distdir = (ltr->GetParameter()[2]-track->GetParameter()[2])*90; //distance at entrance
161     if (TMath::Abs(ltr->GetParameter()[2]-track->GetParameter()[2])>kMaxdphiP)
162       continue;
163     //
164     Float_t dist=0;
165     dist+=TMath::Abs(lxyz1[0]-lxyz0[0]);
166     dist+=TMath::Abs(lxyz1[1]-lxyz0[1]);
167     dist+=TMath::Abs(lxyz1[2]-lxyz0[2]);
168     dist+=distdir;
169     //    
170     if (id<0)  {
171       id =itrack; 
172       mindist=dist; 
173       ltr0=ltr;
174       continue;
175     }
176     if (dist>mindist) continue;
177     id = itrack;
178     mindist=dist;
179     ltr0=ltr;
180   }
181   return id;
182 }
183