]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCLaserTrack.cxx
(Jens Viechula)
[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 {
37   //
38   // Default constructor
39   //
40
41 }
42
43 AliTPCLaserTrack::AliTPCLaserTrack(AliTPCLaserTrack &ltr) :
44   AliExternalTrackParam(ltr),
45   fId(ltr.fId),
46   fSide(ltr.fSide),
47   fRod(ltr.fRod),
48   fBundle(ltr.fBundle),
49   fBeam(ltr.fBeam)
50 {
51   //
52   // Default constructor
53   //
54
55 }
56
57 AliTPCLaserTrack::AliTPCLaserTrack(const Int_t id, const Int_t side, const Int_t rod,
58                      const Int_t bundle, const Int_t beam,
59                      Double_t x, Double_t alpha,
60                      const Double_t param[5],
61                      const Double_t covar[15]) :
62   AliExternalTrackParam(x,alpha,param,covar),
63   fId(id),
64   fSide(side),
65   fRod(rod),
66   fBundle(bundle),
67   fBeam(beam)
68 {
69   //
70   // create laser track from arguments
71   //
72
73 }
74
75 void AliTPCLaserTrack::LoadTracks()
76 {
77     //
78     // Load all design positions from file into the static array fgArrLaserTracks
79     //
80
81     if ( fgArrLaserTracks ) return;
82
83     TString dataFileName("$ALICE_ROOT/TPC/Calib/LaserTracks.root");  //Path to the Data File
84
85     TFile *f=TFile::Open(gSystem->ExpandPathName(dataFileName.Data()));
86     if ( !f || !f->IsOpen() ){
87 //      AliWarning(Form("Could not open laser data file: '%s'",dataFileName.Data()));
88 //      AliWarning("Could not open laser data file");
89         return;
90     }
91     TObjArray *arrLaserTracks = (TObjArray*)f->Get("arrLaserTracks");
92     if ( !arrLaserTracks ) {
93 //      AliWarning(Form("Could not get laser position data from file: '%s'",fgkDataFileName));
94         return;
95     }
96
97     fgArrLaserTracks = new TObjArray(fgkNLaserTracks);
98     for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){
99         AliTPCLaserTrack *ltr = (AliTPCLaserTrack*)arrLaserTracks->At(itrack);
100         if ( !ltr ){
101 //          AliWarning(Form("No informatino found for Track %d!",itrack));
102             continue;
103         }
104         fgArrLaserTracks->AddAt(new AliTPCLaserTrack(*ltr),itrack);
105     }
106     delete f;
107 }
108
109
110 Int_t AliTPCLaserTrack::IdentifyTrack(AliExternalTrackParam *track)
111 {
112   //
113   // Find the laser track which is corresponding closest to 'track'
114   // return its id
115   //
116   // 
117   const  Float_t   kMaxdphi=0.1;
118   const  Float_t   kMaxdphiP=0.06;
119   const  Float_t   kMaxdz=50;
120
121   if ( !fgArrLaserTracks ) LoadTracks();
122   TObjArray *arrTracks = GetTracks();
123   
124
125   Double_t lxyz0[3];
126   Double_t lxyz1[3];
127   Double_t pxyz0[3];
128   Double_t pxyz1[3];
129   track->GetXYZ(lxyz0);
130   track->GetPxPyPz(pxyz0);
131   
132   Int_t id = -1;
133   for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){
134     AliExternalTrackParam *ltr = (AliExternalTrackParam*)arrTracks->UncheckedAt(itrack);
135     Double_t * kokot = (Double_t*)ltr->GetParameter();
136     kokot[4]=-0.0000000001;
137     //
138     ltr->GetXYZ(lxyz1);
139     if ( (lxyz1[2]>0) && lxyz0[2]<0) continue;
140     if ( (lxyz1[2]<0) && lxyz0[2]>0) continue;
141     if (TMath::Abs(lxyz1[2]-lxyz0[2])>kMaxdz) continue;
142     // phi position
143     Double_t phi0 = TMath::ATan2(lxyz0[1],lxyz0[0]);
144     Double_t phi1 = TMath::ATan2(lxyz1[1],lxyz1[0]);
145     if (TMath::Abs(phi0-phi1)>kMaxdphi) continue;
146     // phi direction
147     ltr->GetPxPyPz(pxyz1);
148     Double_t pphi0 = TMath::ATan2(pxyz0[1],pxyz0[0]);
149     Double_t pphi1 = TMath::ATan2(pxyz1[1],pxyz1[0]);
150     Bool_t phimatch = kFALSE;
151     if (TMath::Abs(ltr->GetParameter()[2]-track->GetParameter()[2])>kMaxdphiP)
152       continue;
153   //   if (TMath::Abs(pphi0-pphi1)<kMaxdphiP) phimatch=kTRUE;
154 //     if (TMath::Abs(pphi0-pphi1-TMath::Pi())<kMaxdphiP) phimatch=kTRUE;
155 //     if (TMath::Abs(pphi0-pphi1+TMath::Pi())<kMaxdphiP) phimatch=kTRUE;
156 //     if (!phimatch) continue;
157     //
158     id =itrack;
159   }
160   return id;
161 }
162