/[PAMELA software]/DarthVader/TrackerLevel2/src/ExtTrack.cpp
ViewVC logotype

Annotation of /DarthVader/TrackerLevel2/src/ExtTrack.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Thu Feb 27 11:24:43 2014 UTC (10 years, 9 months ago) by pam-fi
Branch: MAIN
Added new tracking algorythm

1 pam-fi 1.1 /**
2     * \file ExtTrack.cpp
3     * \author Elena Vannuccini
4     */
5     #include <ExtTrack.h>
6     #include <iostream>
7     #include <math.h>
8     using namespace std;
9     //......................................
10     // F77 routines
11     //......................................
12     extern "C" {
13     // void dotrack_(int*, double*, double*, double*, double*, int*);
14     // void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*);
15     // void dotrack3_(int*, double*, double*, double*, double*,double*, double*, double*,double*,int*);
16     // void mini2_(int*,int*,int*);
17     // void guess_();
18     // void gufld_(float*, float*);
19     // float risxeta2_(float *);
20     // float risxeta3_(float *);
21     // float risxeta4_(float *);
22     // float risyeta2_(float *);
23     }
24    
25     //--------------------------------------
26     //
27     //
28     //--------------------------------------
29     ExtTrack::ExtTrack(){
30     chi2 = 0;
31     nstep = 0;
32     for(int it1=0;it1<5;it1++){
33     al[it1] = 0;
34     for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
35     };
36     nplanes=0;
37    
38     xgood = 0;
39     ygood = 0;
40     xm = 0;
41     ym = 0;
42     zm = 0;
43     resx = 0;
44     resy = 0;
45     xv = 0;
46     yv = 0;
47     zv = 0;
48     axv = 0;
49     ayv = 0;
50     dedx_x = 0;
51     dedx_y = 0;
52    
53     TrkParams::SetMiniDefault();
54    
55     };
56     //--------------------------------------
57     //
58     //
59     //--------------------------------------
60     ExtTrack::ExtTrack(Int_t dim){
61     chi2 = 0;
62     nstep = 0;
63     for(int it1=0;it1<5;it1++){
64     al[it1] = 0;
65     for(int it2=0;it2<5;it2++)coval[it1][it2] = 0;
66     };
67    
68     SetDimension(dim);
69    
70     TrkParams::SetMiniDefault();
71     };
72     //--------------------------------------
73     //
74     //
75     //--------------------------------------
76     ExtTrack::ExtTrack(const ExtTrack& t){
77     chi2 = t.chi2;
78     nstep = t.nstep;
79     for(int it1=0;it1<5;it1++){
80     al[it1] = t.al[it1];
81     for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2];
82     };
83     SetDimension(t.nplanes);
84     for(int ip=0;ip<nplanes;ip++){
85     xgood[ip] = t.xgood[ip];
86     ygood[ip] = t.ygood[ip];
87     xm[ip] = t.xm[ip];
88     ym[ip] = t.ym[ip];
89     zm[ip] = t.zm[ip];
90     resx[ip] = t.resx[ip];
91     resy[ip] = t.resy[ip];
92     xv[ip] = t.xv[ip];
93     yv[ip] = t.yv[ip];
94     zv[ip] = t.zv[ip];
95     axv[ip] = t.axv[ip];
96     ayv[ip] = t.ayv[ip];
97     dedx_x[ip] = t.dedx_x[ip];
98     dedx_y[ip] = t.dedx_y[ip];
99     };
100    
101     TrkParams::SetMiniDefault();
102     };
103     //--------------------------------------
104     //
105     //
106     //--------------------------------------
107     void ExtTrack::SetDimension(Int_t dim){
108    
109     nplanes = dim;
110    
111     xgood = new Int_t[nplanes];
112     ygood = new Int_t[nplanes];
113     xm = new Float_t[nplanes];
114     ym = new Float_t[nplanes];
115     zm = new Float_t[nplanes];
116     resx = new Float_t[nplanes];
117     resy = new Float_t[nplanes];
118     xv = new Float_t[nplanes];
119     yv = new Float_t[nplanes];
120     zv = new Float_t[nplanes];
121     axv = new Float_t[nplanes];
122     ayv = new Float_t[nplanes];
123     dedx_x = new Float_t[nplanes];
124     dedx_y = new Float_t[nplanes];
125    
126     SetMeasure(0,0,0);
127     SetResolution(0,0);
128     SetGood(0,0);
129     FitReset();
130     }
131     //--------------------------------------
132     //
133     //
134     //--------------------------------------
135     void ExtTrack::Clear(Option_t* option){
136    
137     FitReset();
138     if(nplanes){
139     delete [] xgood;
140     delete [] ygood;
141     delete [] xm;
142     delete [] ym;
143     delete [] zm;
144     delete [] resx;
145     delete [] resy;
146     delete [] xv;
147     delete [] yv;
148     delete [] zv;
149     delete [] axv;
150     delete [] ayv;
151     delete [] dedx_x;
152     delete [] dedx_y;
153     }
154    
155     nplanes = 0;
156     xgood = 0;
157     ygood = 0;
158     xm = 0;
159     ym = 0;
160     zm = 0;
161     resx = 0;
162     resy = 0;
163     xv = 0;
164     yv = 0;
165     zv = 0;
166     axv = 0;
167     ayv = 0;
168     dedx_x = 0;
169     dedx_y = 0;
170    
171     };
172     //--------------------------------------
173     //
174     //
175     //--------------------------------------
176     void ExtTrack::Delete(){
177     Clear();
178     };
179    
180     /**
181     * Set the position measurements
182     */
183     void ExtTrack::SetMeasure(Double_t *xmeas, Double_t *ymeas, Double_t *zmeas){
184     for(Int_t i=0; i<nplanes; i++) xm[i]= (xmeas? *xmeas++ : 0.);
185     for(Int_t i=0; i<nplanes; i++) ym[i]= (ymeas? *ymeas++ : 0.);
186     for(Int_t i=0; i<nplanes; i++) zm[i]= (ymeas? *zmeas++ : 0.);
187     }
188     /**
189     * Set the TrkTrack position resolution
190     */
191     void ExtTrack::SetResolution(Double_t *rx, Double_t *ry){
192     for(Int_t i=0; i<nplanes; i++) resx[i]= (rx? *rx++ : 0.);
193     for(Int_t i=0; i<nplanes; i++) resy[i]= (ry? *ry++ : 0.);
194     }
195     /**
196     * Set the TrkTrack good measurement
197     */
198     void ExtTrack::SetGood(Int_t *xg, Int_t *yg){
199    
200     for(Int_t i=0; i<nplanes; i++) xgood[i]=(xg? *xg++ : 0 );
201     for(Int_t i=0; i<nplanes; i++) ygood[i]=(yg? *yg++ : 0 );
202     }
203    
204     //--------------------------------------
205     //
206     //
207     //--------------------------------------
208     void ExtTrack::Dump(){
209     cout << endl << "========== Track " ;
210     cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " ";
211     cout << endl << "chi^2 : "<< chi2;
212     cout << endl << "n.step : "<< nstep;
213     cout << endl << "xgood : "; for(int i=0; i<nplanes; i++)cout << XGood(i) ;
214     cout << endl << "ygood : "; for(int i=0; i<nplanes; i++)cout << YGood(i) ;
215     cout << endl << "xm : "; for(int i=0; i<nplanes; i++)cout << xm[i] << " ";
216     cout << endl << "ym : "; for(int i=0; i<nplanes; i++)cout << ym[i] << " ";
217     cout << endl << "zm : "; for(int i=0; i<nplanes; i++)cout << zm[i] << " ";
218     cout << endl << "xv : "; for(int i=0; i<nplanes; i++)cout << xv[i] << " ";
219     cout << endl << "yv : "; for(int i=0; i<nplanes; i++)cout << yv[i] << " ";
220     cout << endl << "zv : "; for(int i=0; i<nplanes; i++)cout << zv[i] << " ";
221     cout << endl << "resx : "; for(int i=0; i<nplanes; i++)cout << resx[i] << " ";
222     cout << endl << "resy : "; for(int i=0; i<nplanes; i++)cout << resy[i] << " ";
223     cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" ";
224     cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" ";
225     cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" ";
226     cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" ";
227     cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" ";
228     cout << endl << "dedx_x : "; for(int i=0; i<nplanes; i++)cout << dedx_x[i] << " ";
229     cout << endl << "dedx_y : "; for(int i=0; i<nplanes; i++)cout << dedx_y[i] << " ";
230    
231     cout << endl;
232     }
233     /**
234     * Reset the fit parameters
235     */
236     void ExtTrack::FitReset(){
237     for(int i=0; i<5; i++) al[i]=-9999.;
238     chi2=0.;
239     nstep=0;
240     for(int i=0; i<nplanes; i++) xv[i]=0.;
241     for(int i=0; i<nplanes; i++) yv[i]=0.;
242     for(int i=0; i<nplanes; i++) zv[i]=0.;
243     for(int i=0; i<nplanes; i++) axv[i]=0.;
244     for(int i=0; i<nplanes; i++) ayv[i]=0.;
245     for(int i=0; i<5; i++) {
246     for(int j=0; j<5; j++) coval[i][j]=0.;
247     }
248     }
249     /**
250     * Method to fill minimization-routine common
251     * NB (zini=23.5 is implicitelly set)
252     */
253     void ExtTrack::FillMiniStruct(cMini2track& track){
254    
255     for(int i=0; i<nplanes; i++){
256    
257     track.xgood[i]=XGood(i);
258     track.ygood[i]=YGood(i);
259    
260     track.xm[i]=xm[i];
261     track.ym[i]=ym[i];
262     track.zm[i]=zm[i];
263    
264     float segment = 100.; //temporaneo
265     track.xm_a[i]=xm[i];
266     track.xm_b[i]=xm[i];
267     track.ym_a[i]=ym[i];
268     track.ym_b[i]=ym[i];
269     if( XGood(i) && !YGood(i) ){
270     track.ym_a[i] = track.ym_a[i]+segment;
271     track.ym_b[i] = track.ym_b[i]-segment;
272     }else if( !XGood(i) && YGood(i)){
273     track.xm_a[i] = track.xm_a[i]+segment;
274     track.xm_b[i] = track.xm_b[i]-segment;
275     }
276    
277    
278     track.resx[i]=resx[i];
279     track.resy[i]=resy[i];
280     }
281    
282     for(int i=0; i<5; i++) track.al[i]=al[i];
283    
284     track.zini = 55.;
285    
286     // track.zini = 23.5;
287     // ZINI = 23.5 !!! it should be the same parameter in all codes
288    
289     }
290     /**
291     * Method to set values from minimization-routine common
292     */
293     void ExtTrack::SetFromMiniStruct(cMini2track *track){
294    
295     for(int i=0; i<5; i++) {
296     al[i]=track->al[i];
297     for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j];
298     }
299     chi2 = track->chi2;
300     nstep = track->nstep;
301     for(int i=0; i<6; i++){
302     xv[i] = track->xv[i];
303     yv[i] = track->yv[i];
304     zv[i] = track->zv[i];
305     xm[i] = track->xm[i];
306     ym[i] = track->ym[i];
307     zm[i] = track->zm[i];
308     axv[i] = track->axv[i];
309     ayv[i] = track->ayv[i];
310     }
311    
312     }
313    
314     ClassImp(ExtTrack);

  ViewVC Help
Powered by ViewVC 1.1.23