Updated example macros for CAF reco.
[u/mrichter/AliRoot.git] / TPC / AliTPCLaserTrack.cxx
CommitLineData
23b18f4e 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
25ClassImp(AliTPCLaserTrack)
26
27TObjArray *AliTPCLaserTrack::fgArrLaserTracks=0x0;
28
29AliTPCLaserTrack::AliTPCLaserTrack() :
30 AliExternalTrackParam(),
31 fId(-1),
32 fSide(-1),
33 fRod(-1),
34 fBundle(-1),
7804aba0 35 fBeam(-1),
36 fRayLength(0)
23b18f4e 37{
38 //
39 // Default constructor
40 //
41
42}
43
7804aba0 44AliTPCLaserTrack::AliTPCLaserTrack(const AliTPCLaserTrack &ltr) :
23b18f4e 45 AliExternalTrackParam(ltr),
46 fId(ltr.fId),
47 fSide(ltr.fSide),
48 fRod(ltr.fRod),
49 fBundle(ltr.fBundle),
7804aba0 50 fBeam(ltr.fBeam),
51 fRayLength(ltr.fRayLength)
23b18f4e 52{
53 //
54 // Default constructor
55 //
56
57}
58
59AliTPCLaserTrack::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],
7804aba0 63 const Double_t covar[15], const Float_t rayLength) :
23b18f4e 64 AliExternalTrackParam(x,alpha,param,covar),
65 fId(id),
66 fSide(side),
67 fRod(rod),
68 fBundle(bundle),
7804aba0 69 fBeam(beam),
70 fRayLength(rayLength)
23b18f4e 71{
72 //
73 // create laser track from arguments
74 //
75
76}
7804aba0 77//_____________________________________________________________________
78AliTPCLaserTrack& 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}
23b18f4e 88
89void 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
f1fcccb7 123
38b1a1ca 124Int_t AliTPCLaserTrack::IdentifyTrack(AliExternalTrackParam *track, Int_t side)
23b18f4e 125{
f1fcccb7 126 //
127 // Find the laser track which is corresponding closest to 'track'
128 // return its id
129 //
130 //
b51d4393 131 const Float_t kMaxdphi=0.2;
265e5fdb 132 const Float_t kMaxdphiP=0.05;
133 const Float_t kMaxdz=40;
f1fcccb7 134
135 if ( !fgArrLaserTracks ) LoadTracks();
136 TObjArray *arrTracks = GetTracks();
f1fcccb7 137 Double_t lxyz0[3];
138 Double_t lxyz1[3];
139 Double_t pxyz0[3];
140 Double_t pxyz1[3];
141 track->GetXYZ(lxyz0);
38b1a1ca 142 track->GetDirection(pxyz0);
265e5fdb 143 //
38b1a1ca 144 Float_t mindist=10; // maxima minimal distance
f1fcccb7 145 Int_t id = -1;
265e5fdb 146 AliExternalTrackParam* ltr0= (AliExternalTrackParam*)arrTracks->UncheckedAt(0);
38b1a1ca 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;
f1fcccb7 150 Double_t * kokot = (Double_t*)ltr->GetParameter();
151 kokot[4]=-0.0000000001;
23b18f4e 152 //
f1fcccb7 153 ltr->GetXYZ(lxyz1);
b51d4393 154 if (TMath::Abs(lxyz1[2]-lxyz0[2])>kMaxdz) continue;
f1fcccb7 155 // phi position
156 Double_t phi0 = TMath::ATan2(lxyz0[1],lxyz0[0]);
157 Double_t phi1 = TMath::ATan2(lxyz1[1],lxyz1[0]);
b51d4393 158 if (TMath::Abs(phi0-phi1)>kMaxdphi) continue;
f1fcccb7 159 // phi direction
38b1a1ca 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)
f1fcccb7 164 continue;
23b18f4e 165 //
265e5fdb 166 Float_t dist=0;
167 dist+=TMath::Abs(lxyz1[0]-lxyz0[0]);
168 dist+=TMath::Abs(lxyz1[1]-lxyz0[1]);
38b1a1ca 169 // dist+=TMath::Abs(lxyz1[2]-lxyz0[2]); //z is not used for distance calculation
265e5fdb 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;
f1fcccb7 182 }
183 return id;
23b18f4e 184}
185