Add SetQA method
[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),
35 fBeam(-1)
36{
37 //
38 // Default constructor
39 //
40
41}
42
43AliTPCLaserTrack::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
57AliTPCLaserTrack::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
75void 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
109Int_t AliTPCLaserTrack::IdentifyTrack(AliExternalTrackParam *track)
110{
111 //
112 // Find the laser track which is corresponding closest to 'track'
113 // return its id
114 //
115
116 LoadTracks();
117 TObjArray *arrTracks = GetTracks();
118
119 Double_t phitr=0;
120 Double_t philtr=0;
121 Double_t xltr[3];
122 Double_t xtr[3];
123 Double_t vtr[3];
124
125 track->GetXYZ(xtr);
126 track->GetDirection(vtr);
127 phitr=track->Phi();
128
129 Int_t id = -1;
130 Double_t dcaMin=3; // 3 sigma is the minimum weighted dca accepted
131 for (Int_t itrack=0; itrack<fgkNLaserTracks; itrack++){
132 AliExternalTrackParam *ltr = (AliExternalTrackParam*)arrTracks->UncheckedAt(itrack);
133 philtr=ltr->Phi();
134 Double_t phiadd=0;
135 Double_t dphi=TMath::Abs(phitr-philtr);
136 if (dphi>TMath::Pi()) phiadd=TMath::Pi();
137 dphi-=phiadd;
138 if (dphi>2*TMath::DegToRad()) continue; //only 2 degree in phi
139
140 //printf("itrack: %d; dphi: %f\n",itrack,dphi/TMath::DegToRad());
141
142 ltr->GetXYZ(xltr);
143
144 Double_t l=0;
145 Double_t d2=0;
146 Double_t d=0;
147 for (Int_t i=0; i<2; i++)
148 l+=(xltr[i]-xtr[i])*vtr[i];
149 for (Int_t i=0; i<2; i++)
150 d2+=(xltr[i]-xtr[i]-l*vtr[i])*(xltr[i]-xtr[i]-l*vtr[i]);
151 d=TMath::Sqrt(d2);
152
153 //printf("itrack: %d; d-xy: %f\n",itrack,d);
154
155
156 //only 3mm in x-y
157 if ( d>.3 ) continue;
158
159
160 Double_t dz=TMath::Abs(xltr[2] - xtr[2]);
161 //printf("itrack: %d; d-z: %f\n",itrack,dz);
162 //30 cm in z
163 if ( dz > 30. ) continue;
164
165 //if ( id!=-1 ) printf("Warnig: Track (%d) already identified before (%d)\n", itrack, id);
166 id=itrack;
167// Double_t relDistX
168// Double_t xtr=0;
169// Double_t xltr=0;
170// Double_t dca=track->GetDCA(ltr,0,xtr,xltr);
171// if ( dca<dcaMin ){
172// id=itrack;
173// dcaMin=dca;
174// }
175 }
176 return id;
177}
178