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

Contents of /DarthVader/TrackerLevel2/src/TrkHough.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Wed Nov 7 10:38:52 2007 UTC (17 years ago) by pam-fi
Branch: MAIN
CVS Tags: v5r00
Changes since 1.1: +185 -81 lines
fixed bug on DB connection

1 /**
2 * \file TrkHough.cpp
3 * \author David Fedele
4 */
5 #include <TrkHough.h>
6 #include <iostream>
7 using namespace std;
8
9 //--------------------------------------
10 //
11 //
12 //--------------------------------------
13 TrkHough::TrkHough(){
14
15 ndblt=0;
16 alfayz1=0;
17 alfayz2=0;
18 db_cloud=0;
19
20 ntrpt=0;
21 alfaxz1=0;
22 alfaxz2=0;
23 alfaxz3=0;
24 tr_cloud=0;
25
26 nclouds_yz=0;
27 alfayz1_av=0;
28 alfayz2_av=0;
29 ptcloud_yz=0;
30
31 nclouds_xz=0;
32 alfaxz1_av=0;
33 alfaxz2_av=0;
34 alfaxz3_av=0;
35 ptcloud_xz=0;
36
37 nclstr=0;
38 totaltime=0;
39 houghtime=0;
40 fittime=0;
41
42 // ntracks=0;
43 // al0=0;
44 // al1=0;
45 // al2=0;
46 // al3=0;
47 // al4=0;
48
49 Candidates = 0;
50
51 };
52 //--------------------------------------
53 //
54 //
55 //--------------------------------------
56 /**
57 * Fills a TrkHough object with values from a struct cTrkhough (to get data from F77 common).
58 */
59 void TrkHough::SetFromHoughStruct(cTrkHough *lh, cTrkCandidates *lc){
60
61 if(!lh) return;
62 // -------------------------
63 // fill hough transform info
64 // -------------------------
65 ndblt = lh->ndblt_nt;
66 ntrpt = lh->ntrpt_nt;
67 nclouds_yz = lh->nclouds_yz_nt;
68 nclouds_xz = lh->nclouds_xz_nt;
69 nclstr = lh->nclstr;
70 totaltime = lh->totaltime;
71 houghtime = lh->houghtime;
72 fittime = lh->fittime;
73
74 alfayz1 = new Float_t[ndblt];
75 alfayz2 = new Float_t[ndblt];
76 db_cloud = new Int_t[ndblt];
77 for(int i=0; i<ndblt; i++){
78 alfayz1[i] = (Float_t) lh->alfayz1_nt[i];
79 alfayz2[i] = (Float_t) lh->alfayz2_nt[i];
80 db_cloud[i] = (Int_t) lh->db_cloud_nt[i];
81 }
82
83 alfaxz1 = new Float_t[ntrpt];
84 alfaxz2 = new Float_t[ntrpt];
85 alfaxz3 = new Float_t[ntrpt];
86 tr_cloud = new Int_t[ntrpt];
87 for(int i=0; i<ntrpt; i++){
88 alfaxz1[i] = (Float_t) lh->alfaxz1_nt[i];
89 alfaxz2[i] = (Float_t) lh->alfaxz2_nt[i];
90 alfaxz3[i] = (Float_t) lh->alfaxz3_nt[i];
91 tr_cloud[i] = (Int_t) lh->tr_cloud_nt[i];
92 }
93
94 alfayz1_av = new Float_t[nclouds_yz];
95 alfayz2_av = new Float_t[nclouds_yz];
96 ptcloud_yz = new Int_t[nclouds_yz];
97 for(int i=0; i<nclouds_yz; i++){
98 alfayz1_av[i] = (Float_t) lh->alfayz1_av_nt[i];
99 alfayz2_av[i] = (Float_t) lh->alfayz2_av_nt[i];
100 ptcloud_yz[i] = (Int_t) lh->ptcloud_yz_nt[i];
101 }
102
103 alfaxz1_av = new Float_t[nclouds_xz];
104 alfaxz2_av = new Float_t[nclouds_xz];
105 alfaxz3_av = new Float_t[nclouds_xz];
106 ptcloud_xz = new Int_t[nclouds_xz];
107 for(int i=0; i<nclouds_xz; i++){
108 alfaxz1_av[i] = (Float_t) lh->alfaxz1_av_nt[i] ;
109 alfaxz2_av[i] = (Float_t) lh->alfaxz2_av_nt[i];
110 alfaxz3_av[i] = (Float_t) lh->alfaxz3_av_nt[i];
111 ptcloud_xz[i] = (Int_t) lh->ptcloud_xz_nt[i];
112 }
113
114 if(!lc) return;
115 // --------------------------
116 // fill track candidates info
117 // --------------------------
118 // ntracks = lc->ntracks;
119 // al0 = new Float_t[ntracks];
120 // al1 = new Float_t[ntracks];
121 // al2 = new Float_t[ntracks];
122 // al3 = new Float_t[ntracks];
123 // al4 = new Float_t[ntracks];
124 // for(int ii=0; ii<ntracks; ii++){
125 // al0[ii] = (Float_t) lc->al[ii][0];
126 // al1[ii] = (Float_t) lc->al[ii][1];
127 // al2[ii] = (Float_t) lc->al[ii][2];
128 // al3[ii] = (Float_t) lc->al[ii][3];
129 // al4[ii] = (Float_t) lc->al[ii][4];
130 // }
131 TrkTrack* t_track = new TrkTrack();
132 Candidates = new TClonesArray("TrkTrack");
133 TClonesArray &t = *Candidates;
134 for(int i=0; i<lc->ntracks; i++){
135 t_track->seqno = i;
136 t_track->image = 0;
137 t_track->chi2 = lc->chi2[i];
138 t_track->nstep = 0;
139 for(int it1=0;it1<5;it1++){
140 t_track->al[it1] = lc->al[i][it1];
141 for(int it2=0;it2<5;it2++)
142 t_track->coval[it1][it2] = 0.;
143 };
144 for(int ip=0;ip<6;ip++){
145 // ---------------------------------
146 // new implementation of xgood/ygood
147 // ---------------------------------
148 t_track->xgood[ip] = (Int_t) lc->xgood[i][ip];
149 t_track->ygood[ip] = (Int_t) lc->ygood[i][ip];
150 int ssensor = lc->sensor[i][ip];
151 int sladder = lc->ladder[i][ip];
152 if(ip==5&&ssensor!=0)ssensor = 3 - ssensor; //notazione paolo x align
153 t_track->xgood[ip] += 10000000*ssensor+10*sladder ; // ladder+sensor
154 t_track->ygood[ip] += 10000000*ssensor+10*sladder ; // ladder+sensor
155 // if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip];
156 // if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip];
157 t_track->xm[ip] = lc->xm[i][ip];
158 t_track->ym[ip] = lc->ym[i][ip];
159 t_track->zm[ip] = lc->zm[i][ip];
160 t_track->resx[ip] = lc->resx[i][ip];
161 t_track->resy[ip] = lc->resy[i][ip];
162 t_track->tailx[ip] = 0.;
163 t_track->taily[ip] = 0.;
164 t_track->xv[ip] = lc->xv[i][ip];
165 t_track->yv[ip] = lc->yv[i][ip];
166 t_track->zv[ip] = lc->zv[i][ip];
167 t_track->axv[ip] = lc->axv[i][ip];
168 t_track->ayv[ip] = lc->ayv[i][ip];
169 t_track->dedx_x[ip] = 0.;
170 t_track->dedx_y[ip] = 0.;
171 t_track->multmaxx[ip] = 0;
172 t_track->multmaxy[ip] = 0;
173 t_track->seedx[ip] = 0.;
174 t_track->seedy[ip] = 0.;
175 t_track->xpu[ip] = 0.;
176 t_track->ypu[ip] = 0.;
177 //-----------------------------------------------------
178 //-----------------------------------------------------
179 //-----------------------------------------------------
180 //-----------------------------------------------------
181 };
182 // if(t_track->IsSaturated())t_track->Dump();
183 new(t[i]) TrkTrack(*t_track);
184 t_track->Clear();
185 };
186
187 delete t_track;
188
189
190 };
191 //--------------------------------------
192 //
193 //
194 //--------------------------------------
195 TrkTrack *TrkHough::GetCandidate(int it){
196
197 if(it >= GetNCandidates()){
198 cout << "** TrkHough ** Track-candidate "<< it << "does not exits! " << endl;
199 cout << " n.candidates = "<< GetNCandidates() << endl;
200 return 0;
201 }
202 if(!Candidates){
203 cout << "TrkTrack *TrkHough::GetCandidate(int is) >> (TClonesArray*) Candidate ==0 "<<endl;
204 };
205
206 TClonesArray &t = *(Candidates);
207 TrkTrack *track = (TrkTrack*)t[it];
208 return track;
209 }
210 //--------------------------------------
211 //
212 //
213 //--------------------------------------
214 void TrkHough::Clear(){
215
216
217 ndblt = 0;
218 ntrpt = 0;
219 nclouds_yz = 0;
220 nclouds_xz = 0;
221 nclstr = 0;
222 totaltime = 0;
223 houghtime = 0;
224 fittime = 0;
225 // ntracks = 0;
226
227 if(Candidates)Candidates->Delete();
228 };
229 //--------------------------------------
230 //
231 //
232 //--------------------------------------
233 void TrkHough::Delete(){
234
235 Clear();
236
237 delete [] alfayz1;
238 delete [] alfayz2;
239 delete [] db_cloud;
240
241 delete [] alfaxz1;
242 delete [] alfaxz2;
243 delete [] alfaxz3;
244 delete [] tr_cloud;
245
246 delete [] alfayz1_av;
247 delete [] alfayz2_av;
248 delete [] ptcloud_yz;
249
250 delete [] alfaxz1_av;
251 delete [] alfaxz2_av;
252 delete [] alfaxz3_av;
253 delete [] ptcloud_xz;
254
255 // delete [] al0;
256 // delete [] al1;
257 // delete [] al2;
258 // delete [] al3;
259 // delete [] al4;
260
261 if(Candidates)delete Candidates;
262
263 };
264
265
266 ClassImp(TrkHough);

  ViewVC Help
Powered by ViewVC 1.1.23