| 1 |
mocchiut |
1.1 |
/** |
| 2 |
|
|
* \file TrkLevel2.cpp |
| 3 |
|
|
* \author Elena Vannuccini |
| 4 |
|
|
*/ |
| 5 |
|
|
#include <TrkLevel2.h> |
| 6 |
|
|
#include <iostream> |
| 7 |
pam-fi |
1.14 |
#include <math.h> |
| 8 |
mocchiut |
1.1 |
using namespace std; |
| 9 |
|
|
//...................................... |
| 10 |
|
|
// F77 routines |
| 11 |
|
|
//...................................... |
| 12 |
|
|
extern "C" { |
| 13 |
|
|
void dotrack_(int*, double*, double*, double*, double*, int*); |
| 14 |
pam-fi |
1.2 |
void dotrack2_(int*, double*, double*, double*, double*,double*, double*, double*,int*); |
| 15 |
pam-fi |
1.26 |
void mini2_(int*,int*,int*); |
| 16 |
|
|
void guess_(); |
| 17 |
mocchiut |
1.1 |
} |
| 18 |
pam-fi |
1.26 |
|
| 19 |
mocchiut |
1.1 |
//-------------------------------------- |
| 20 |
|
|
// |
| 21 |
|
|
// |
| 22 |
|
|
//-------------------------------------- |
| 23 |
|
|
TrkTrack::TrkTrack(){ |
| 24 |
pam-fi |
1.21 |
// cout << "TrkTrack::TrkTrack()" << endl; |
| 25 |
pam-fi |
1.3 |
seqno = -1; |
| 26 |
|
|
image = -1; |
| 27 |
mocchiut |
1.1 |
chi2 = 0; |
| 28 |
pam-fi |
1.14 |
nstep = 0; |
| 29 |
|
|
for(int it1=0;it1<5;it1++){ |
| 30 |
|
|
al[it1] = 0; |
| 31 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 32 |
mocchiut |
1.1 |
}; |
| 33 |
|
|
for(int ip=0;ip<6;ip++){ |
| 34 |
pam-fi |
1.21 |
xgood[ip] = 0; |
| 35 |
|
|
ygood[ip] = 0; |
| 36 |
|
|
xm[ip] = 0; |
| 37 |
|
|
ym[ip] = 0; |
| 38 |
|
|
zm[ip] = 0; |
| 39 |
|
|
resx[ip] = 0; |
| 40 |
|
|
resy[ip] = 0; |
| 41 |
pam-fi |
1.32 |
tailx[ip] = 0; |
| 42 |
|
|
taily[ip] = 0; |
| 43 |
pam-fi |
1.21 |
xv[ip] = 0; |
| 44 |
|
|
yv[ip] = 0; |
| 45 |
|
|
zv[ip] = 0; |
| 46 |
|
|
axv[ip] = 0; |
| 47 |
|
|
ayv[ip] = 0; |
| 48 |
|
|
dedx_x[ip] = 0; |
| 49 |
|
|
dedx_y[ip] = 0; |
| 50 |
|
|
}; |
| 51 |
pam-fi |
1.32 |
// clx = 0; |
| 52 |
|
|
// cly = 0; |
| 53 |
pam-fi |
1.29 |
// clx = new TRefArray(6,0); //forse causa memory leak??? |
| 54 |
|
|
// cly = new TRefArray(6,0); //forse causa memory leak??? |
| 55 |
pam-fi |
1.32 |
// clx = TRefArray(6,0); |
| 56 |
|
|
// cly = TRefArray(6,0); |
| 57 |
|
|
|
| 58 |
pam-fi |
1.33 |
TrkParams::SetTrackingMode(); |
| 59 |
|
|
TrkParams::SetPrecisionFactor(); |
| 60 |
|
|
TrkParams::SetStepMin(); |
| 61 |
|
|
TrkParams::SetPFA(); |
| 62 |
|
|
|
| 63 |
mocchiut |
1.1 |
}; |
| 64 |
|
|
//-------------------------------------- |
| 65 |
|
|
// |
| 66 |
|
|
// |
| 67 |
|
|
//-------------------------------------- |
| 68 |
|
|
TrkTrack::TrkTrack(const TrkTrack& t){ |
| 69 |
pam-fi |
1.3 |
seqno = t.seqno; |
| 70 |
mocchiut |
1.1 |
image = t.image; |
| 71 |
|
|
chi2 = t.chi2; |
| 72 |
pam-fi |
1.14 |
nstep = t.nstep; |
| 73 |
|
|
for(int it1=0;it1<5;it1++){ |
| 74 |
|
|
al[it1] = t.al[it1]; |
| 75 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = t.coval[it1][it2]; |
| 76 |
mocchiut |
1.1 |
}; |
| 77 |
|
|
for(int ip=0;ip<6;ip++){ |
| 78 |
pam-fi |
1.21 |
xgood[ip] = t.xgood[ip]; |
| 79 |
|
|
ygood[ip] = t.ygood[ip]; |
| 80 |
|
|
xm[ip] = t.xm[ip]; |
| 81 |
|
|
ym[ip] = t.ym[ip]; |
| 82 |
|
|
zm[ip] = t.zm[ip]; |
| 83 |
|
|
resx[ip] = t.resx[ip]; |
| 84 |
|
|
resy[ip] = t.resy[ip]; |
| 85 |
pam-fi |
1.32 |
tailx[ip] = t.tailx[ip]; |
| 86 |
|
|
taily[ip] = t.taily[ip]; |
| 87 |
pam-fi |
1.21 |
xv[ip] = t.xv[ip]; |
| 88 |
|
|
yv[ip] = t.yv[ip]; |
| 89 |
|
|
zv[ip] = t.zv[ip]; |
| 90 |
|
|
axv[ip] = t.axv[ip]; |
| 91 |
|
|
ayv[ip] = t.ayv[ip]; |
| 92 |
|
|
dedx_x[ip] = t.dedx_x[ip]; |
| 93 |
|
|
dedx_y[ip] = t.dedx_y[ip]; |
| 94 |
|
|
}; |
| 95 |
pam-fi |
1.32 |
// clx = 0; |
| 96 |
|
|
// cly = 0; |
| 97 |
|
|
// if(t.clx)clx = new TRefArray(*(t.clx)); |
| 98 |
|
|
// if(t.cly)cly = new TRefArray(*(t.cly)); |
| 99 |
|
|
// clx = TRefArray(t.clx); |
| 100 |
|
|
// cly = TRefArray(t.cly); |
| 101 |
|
|
|
| 102 |
pam-fi |
1.33 |
TrkParams::SetTrackingMode(); |
| 103 |
|
|
TrkParams::SetPrecisionFactor(); |
| 104 |
|
|
TrkParams::SetStepMin(); |
| 105 |
|
|
TrkParams::SetPFA(); |
| 106 |
|
|
|
| 107 |
mocchiut |
1.1 |
}; |
| 108 |
|
|
//-------------------------------------- |
| 109 |
|
|
// |
| 110 |
|
|
// |
| 111 |
|
|
//-------------------------------------- |
| 112 |
pam-fi |
1.21 |
void TrkTrack::Copy(TrkTrack& t){ |
| 113 |
|
|
|
| 114 |
|
|
t.seqno = seqno; |
| 115 |
|
|
t.image = image; |
| 116 |
|
|
t.chi2 = chi2; |
| 117 |
|
|
t.nstep = nstep; |
| 118 |
|
|
for(int it1=0;it1<5;it1++){ |
| 119 |
|
|
t.al[it1] = al[it1]; |
| 120 |
|
|
for(int it2=0;it2<5;it2++)t.coval[it1][it2] = coval[it1][it2]; |
| 121 |
|
|
}; |
| 122 |
|
|
for(int ip=0;ip<6;ip++){ |
| 123 |
|
|
t.xgood[ip] = xgood[ip]; |
| 124 |
|
|
t.ygood[ip] = ygood[ip]; |
| 125 |
|
|
t.xm[ip] = xm[ip]; |
| 126 |
|
|
t.ym[ip] = ym[ip]; |
| 127 |
|
|
t.zm[ip] = zm[ip]; |
| 128 |
|
|
t.resx[ip] = resx[ip]; |
| 129 |
|
|
t.resy[ip] = resy[ip]; |
| 130 |
pam-fi |
1.32 |
t.tailx[ip] = tailx[ip]; |
| 131 |
|
|
t.taily[ip] = taily[ip]; |
| 132 |
pam-fi |
1.21 |
t.xv[ip] = xv[ip]; |
| 133 |
|
|
t.yv[ip] = yv[ip]; |
| 134 |
|
|
t.zv[ip] = zv[ip]; |
| 135 |
|
|
t.axv[ip] = axv[ip]; |
| 136 |
|
|
t.ayv[ip] = ayv[ip]; |
| 137 |
|
|
t.dedx_x[ip] = dedx_x[ip]; |
| 138 |
|
|
t.dedx_y[ip] = dedx_y[ip]; |
| 139 |
|
|
|
| 140 |
|
|
}; |
| 141 |
pam-fi |
1.32 |
|
| 142 |
|
|
// t.clx = TRefArray(clx); |
| 143 |
|
|
// t.cly = TRefArray(cly); |
| 144 |
pam-fi |
1.21 |
|
| 145 |
|
|
}; |
| 146 |
|
|
//-------------------------------------- |
| 147 |
|
|
// |
| 148 |
|
|
// |
| 149 |
|
|
//-------------------------------------- |
| 150 |
mocchiut |
1.1 |
/** |
| 151 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
| 152 |
|
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
| 153 |
|
|
* @param t pointer to an object of the class Trajectory, |
| 154 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
| 155 |
|
|
* @return error flag. |
| 156 |
|
|
*/ |
| 157 |
|
|
int TrkTrack::DoTrack(Trajectory* t){ |
| 158 |
|
|
|
| 159 |
|
|
double *dxout = new double[t->npoint]; |
| 160 |
|
|
double *dyout = new double[t->npoint]; |
| 161 |
|
|
double *dzin = new double[t->npoint]; |
| 162 |
|
|
double dal[5]; |
| 163 |
|
|
|
| 164 |
|
|
int ifail = 0; |
| 165 |
|
|
|
| 166 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 167 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
| 168 |
|
|
|
| 169 |
pam-fi |
1.26 |
TrkParams::Load(1); |
| 170 |
|
|
if( !TrkParams::IsLoaded(1) ){ |
| 171 |
|
|
cout << "int TrkTrack::DoTrack(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 172 |
|
|
return 0; |
| 173 |
|
|
} |
| 174 |
mocchiut |
1.1 |
dotrack_(&(t->npoint),dzin,dxout,dyout,dal,&ifail); |
| 175 |
|
|
|
| 176 |
|
|
for (int i=0; i<t->npoint; i++){ |
| 177 |
|
|
t->x[i] = (float)*dxout++; |
| 178 |
|
|
t->y[i] = (float)*dyout++; |
| 179 |
|
|
} |
| 180 |
|
|
|
| 181 |
|
|
// delete [] dxout; |
| 182 |
|
|
// delete [] dyout; |
| 183 |
|
|
// delete [] dzin; |
| 184 |
|
|
|
| 185 |
|
|
return ifail; |
| 186 |
|
|
}; |
| 187 |
|
|
//-------------------------------------- |
| 188 |
|
|
// |
| 189 |
|
|
// |
| 190 |
|
|
//-------------------------------------- |
| 191 |
pam-fi |
1.2 |
/** |
| 192 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
| 193 |
|
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
| 194 |
|
|
* @param t pointer to an object of the class Trajectory, |
| 195 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
| 196 |
|
|
* @return error flag. |
| 197 |
|
|
*/ |
| 198 |
|
|
int TrkTrack::DoTrack2(Trajectory* t){ |
| 199 |
|
|
|
| 200 |
|
|
double *dxout = new double[t->npoint]; |
| 201 |
|
|
double *dyout = new double[t->npoint]; |
| 202 |
|
|
double *dthxout = new double[t->npoint]; |
| 203 |
|
|
double *dthyout = new double[t->npoint]; |
| 204 |
|
|
double *dtlout = new double[t->npoint]; |
| 205 |
|
|
double *dzin = new double[t->npoint]; |
| 206 |
|
|
double dal[5]; |
| 207 |
|
|
|
| 208 |
|
|
int ifail = 0; |
| 209 |
|
|
|
| 210 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 211 |
|
|
for (int i=0; i<t->npoint; i++) dzin[i] = (double)t->z[i]; |
| 212 |
|
|
|
| 213 |
pam-fi |
1.26 |
TrkParams::Load(1); |
| 214 |
|
|
if( !TrkParams::IsLoaded(1) ){ |
| 215 |
|
|
cout << "int TrkTrack::DoTrack2(Trajectory* t) --- ERROR --- m.field not loaded"<<endl; |
| 216 |
|
|
return 0; |
| 217 |
|
|
} |
| 218 |
pam-fi |
1.2 |
dotrack2_(&(t->npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 219 |
|
|
|
| 220 |
|
|
for (int i=0; i<t->npoint; i++){ |
| 221 |
|
|
t->x[i] = (float)*dxout++; |
| 222 |
|
|
t->y[i] = (float)*dyout++; |
| 223 |
|
|
t->thx[i] = (float)*dthxout++; |
| 224 |
|
|
t->thy[i] = (float)*dthyout++; |
| 225 |
|
|
t->tl[i] = (float)*dtlout++; |
| 226 |
|
|
} |
| 227 |
|
|
|
| 228 |
|
|
// delete [] dxout; |
| 229 |
|
|
// delete [] dyout; |
| 230 |
|
|
// delete [] dzin; |
| 231 |
|
|
|
| 232 |
|
|
return ifail; |
| 233 |
|
|
}; |
| 234 |
|
|
//-------------------------------------- |
| 235 |
|
|
// |
| 236 |
|
|
// |
| 237 |
|
|
//-------------------------------------- |
| 238 |
mocchiut |
1.1 |
//float TrkTrack::BdL(){ |
| 239 |
|
|
//}; |
| 240 |
|
|
//-------------------------------------- |
| 241 |
|
|
// |
| 242 |
|
|
// |
| 243 |
|
|
//-------------------------------------- |
| 244 |
|
|
Float_t TrkTrack::GetRigidity(){ |
| 245 |
|
|
Float_t rig=0; |
| 246 |
|
|
if(chi2>0)rig=1./al[4]; |
| 247 |
|
|
if(rig<0) rig=-rig; |
| 248 |
|
|
return rig; |
| 249 |
|
|
}; |
| 250 |
|
|
// |
| 251 |
|
|
Float_t TrkTrack::GetDeflection(){ |
| 252 |
|
|
Float_t def=0; |
| 253 |
|
|
if(chi2>0)def=al[4]; |
| 254 |
|
|
return def; |
| 255 |
|
|
}; |
| 256 |
|
|
// |
| 257 |
pam-fi |
1.32 |
/** |
| 258 |
|
|
* Method to retrieve the dE/dx measured on a tracker view. |
| 259 |
|
|
* @param ip plane (0-5) |
| 260 |
|
|
* @param iv view (0=x 1=y) |
| 261 |
|
|
*/ |
| 262 |
|
|
Float_t TrkTrack::GetDEDX(int ip, int iv){ |
| 263 |
|
|
if(iv==0 && ip>=0 && ip<6)return fabs(dedx_x[ip]); |
| 264 |
|
|
else if(iv==1 && ip>=0 && ip<6)return fabs(dedx_y[ip]); |
| 265 |
|
|
else { |
| 266 |
|
|
cout << "TrkTrack::GetDEDX(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 267 |
|
|
return 0.; |
| 268 |
|
|
} |
| 269 |
|
|
} |
| 270 |
|
|
/** |
| 271 |
|
|
* Method to evaluate the dE/dx measured on a tracker plane. |
| 272 |
|
|
* The two measurements on x- and y-view are averaged. |
| 273 |
|
|
* @param ip plane (0-5) |
| 274 |
|
|
*/ |
| 275 |
|
|
Float_t TrkTrack::GetDEDX(int ip){ |
| 276 |
|
|
if( (Int_t)XGood(ip)+(Int_t)YGood(ip) == 0 ) return 0; |
| 277 |
|
|
return (GetDEDX(ip,0)+GetDEDX(ip,1))/((Int_t)XGood(ip)+(Int_t)YGood(ip)); |
| 278 |
|
|
}; |
| 279 |
|
|
|
| 280 |
|
|
/** |
| 281 |
|
|
* Method to evaluate the dE/dx averaged over all planes. |
| 282 |
|
|
*/ |
| 283 |
mocchiut |
1.1 |
Float_t TrkTrack::GetDEDX(){ |
| 284 |
pam-fi |
1.32 |
Float_t dedx=0; |
| 285 |
|
|
for(Int_t ip=0; ip<6; ip++)dedx+=GetDEDX(ip,0)*XGood(ip)+GetDEDX(ip,1)*YGood(ip); |
| 286 |
|
|
dedx = dedx/(GetNX()+GetNY()); |
| 287 |
|
|
return dedx; |
| 288 |
|
|
}; |
| 289 |
|
|
/** |
| 290 |
|
|
* Returns 1 if the cluster on a tracker view includes bad strips. |
| 291 |
|
|
* @param ip plane (0-5) |
| 292 |
|
|
* @param iv view (0=x 1=y) |
| 293 |
|
|
*/ |
| 294 |
|
|
Bool_t TrkTrack::IsBad(int ip,int iv){ |
| 295 |
|
|
if(iv==0 && ip>=0 && ip<6)return (xgood[ip]<0) ; |
| 296 |
|
|
else if(iv==1 && ip>=0 && ip<6)return (ygood[ip]<0) ; |
| 297 |
|
|
else { |
| 298 |
|
|
cout << "TrkTrack::IsBad(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 299 |
|
|
return 0.; |
| 300 |
|
|
} |
| 301 |
mocchiut |
1.1 |
}; |
| 302 |
pam-fi |
1.32 |
/** |
| 303 |
|
|
* Returns 1 if the signal on a tracker view is saturated. |
| 304 |
|
|
* @param ip plane (0-5) |
| 305 |
|
|
* @param iv view (0=x 1=y) |
| 306 |
|
|
*/ |
| 307 |
|
|
Bool_t TrkTrack::IsSaturated(int ip,int iv){ |
| 308 |
|
|
if(iv==0 && ip>=0 && ip<6)return (dedx_x[ip]<0) ; |
| 309 |
|
|
else if(iv==1 && ip>=0 && ip<6)return (dedx_y[ip]<0) ; |
| 310 |
|
|
else { |
| 311 |
|
|
cout << "TrkTrack::IsSaturated(int ip, int iv) -- wrong input parameters "<<ip<<iv<<endl; |
| 312 |
|
|
return 0.; |
| 313 |
|
|
} |
| 314 |
|
|
}; |
| 315 |
|
|
/** |
| 316 |
|
|
* Returns 1 if either the x or the y signal on a tracker plane is saturated. |
| 317 |
|
|
* @param ip plane (0-5) |
| 318 |
|
|
*/ |
| 319 |
|
|
Bool_t TrkTrack::IsSaturated(int ip){ |
| 320 |
|
|
return (IsSaturated(ip,0)||IsSaturated(ip,1)); |
| 321 |
|
|
}; |
| 322 |
|
|
/** |
| 323 |
|
|
* Returns 1 if there is at least a saturated signal along the track. |
| 324 |
|
|
*/ |
| 325 |
|
|
Bool_t TrkTrack::IsSaturated(){ |
| 326 |
|
|
for(int ip=0; ip<6; ip++)for(int iv=0; iv<2; iv++)if(IsSaturated(ip,iv))return true; |
| 327 |
|
|
return false; |
| 328 |
|
|
} |
| 329 |
|
|
/** |
| 330 |
|
|
* Returns the track "lever-arm" on the x view, defined as the distance (in planes) between |
| 331 |
|
|
* the upper and lower x measurements (the maximum value of lever-arm is 6). |
| 332 |
|
|
*/ |
| 333 |
|
|
Int_t TrkTrack::GetLeverArmX(){ |
| 334 |
|
|
int first_plane = -1; |
| 335 |
|
|
int last_plane = -1; |
| 336 |
|
|
for(Int_t ip=0; ip<6; ip++){ |
| 337 |
|
|
if( XGood(ip) && first_plane == -1 )first_plane = ip; |
| 338 |
|
|
if( XGood(ip) && first_plane != -1 )last_plane = ip; |
| 339 |
|
|
} |
| 340 |
|
|
if( first_plane == -1 || last_plane == -1){ |
| 341 |
|
|
cout<< "Int_t TrkTrack::GetLeverArmX() -- XGood(ip) always false ??? "<<endl; |
| 342 |
|
|
return 0; |
| 343 |
|
|
} |
| 344 |
|
|
return (last_plane-first_plane+1); |
| 345 |
|
|
} |
| 346 |
|
|
/** |
| 347 |
|
|
* Returns the track "lever-arm" on the y view, defined as the distance (in planes) between |
| 348 |
|
|
* the upper and lower y measurements (the maximum value of lever-arm is 6). |
| 349 |
|
|
*/ |
| 350 |
|
|
Int_t TrkTrack::GetLeverArmY(){ |
| 351 |
|
|
int first_plane = -1; |
| 352 |
|
|
int last_plane = -1; |
| 353 |
|
|
for(Int_t ip=0; ip<6; ip++){ |
| 354 |
|
|
if( YGood(ip) && first_plane == -1 )first_plane = ip; |
| 355 |
|
|
if( YGood(ip) && first_plane != -1 )last_plane = ip; |
| 356 |
|
|
} |
| 357 |
|
|
if( first_plane == -1 || last_plane == -1){ |
| 358 |
|
|
cout<< "Int_t TrkTrack::GetLeverArmY() -- YGood(ip) always false ??? "<<endl; |
| 359 |
|
|
return 0; |
| 360 |
|
|
} |
| 361 |
|
|
return (last_plane-first_plane+1); |
| 362 |
|
|
} |
| 363 |
mocchiut |
1.1 |
//-------------------------------------- |
| 364 |
|
|
// |
| 365 |
|
|
// |
| 366 |
|
|
//-------------------------------------- |
| 367 |
|
|
void TrkTrack::Dump(){ |
| 368 |
|
|
cout << endl << "========== Track " ; |
| 369 |
pam-fi |
1.13 |
cout << endl << "seq. n. : "<< seqno; |
| 370 |
|
|
cout << endl << "image n. : "<< image; |
| 371 |
|
|
cout << endl << "al : "; for(int i=0; i<5; i++)cout << al[i] << " "; |
| 372 |
mocchiut |
1.1 |
cout << endl << "chi^2 : "<< chi2; |
| 373 |
pam-fi |
1.13 |
cout << endl << "n.step : "<< nstep; |
| 374 |
pam-fi |
1.30 |
cout << endl << "xgood : "; for(int i=0; i<6; i++)cout << XGood(i) ; |
| 375 |
|
|
cout << endl << "ygood : "; for(int i=0; i<6; i++)cout << YGood(i) ; |
| 376 |
mocchiut |
1.1 |
cout << endl << "xm : "; for(int i=0; i<6; i++)cout << xm[i] << " "; |
| 377 |
|
|
cout << endl << "ym : "; for(int i=0; i<6; i++)cout << ym[i] << " "; |
| 378 |
|
|
cout << endl << "zm : "; for(int i=0; i<6; i++)cout << zm[i] << " "; |
| 379 |
pam-fi |
1.13 |
cout << endl << "xv : "; for(int i=0; i<6; i++)cout << xv[i] << " "; |
| 380 |
|
|
cout << endl << "yv : "; for(int i=0; i<6; i++)cout << yv[i] << " "; |
| 381 |
|
|
cout << endl << "zv : "; for(int i=0; i<6; i++)cout << zv[i] << " "; |
| 382 |
|
|
cout << endl << "resx : "; for(int i=0; i<6; i++)cout << resx[i] << " "; |
| 383 |
|
|
cout << endl << "resy : "; for(int i=0; i<6; i++)cout << resy[i] << " "; |
| 384 |
|
|
cout << endl << "coval : "; for(int i=0; i<5; i++)cout << coval[0][i]<<" "; |
| 385 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[1][i]<<" "; |
| 386 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[2][i]<<" "; |
| 387 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[3][i]<<" "; |
| 388 |
|
|
cout << endl << " "; for(int i=0; i<5; i++)cout << coval[4][i]<<" "; |
| 389 |
mocchiut |
1.1 |
cout << endl << "dedx_x : "; for(int i=0; i<6; i++)cout << dedx_x[i] << " "; |
| 390 |
|
|
cout << endl << "dedx_y : "; for(int i=0; i<6; i++)cout << dedx_y[i] << " "; |
| 391 |
pam-fi |
1.14 |
cout << endl; |
| 392 |
mocchiut |
1.1 |
} |
| 393 |
pam-fi |
1.13 |
/** |
| 394 |
|
|
* Set the TrkTrack position measurements |
| 395 |
|
|
*/ |
| 396 |
|
|
void TrkTrack::SetMeasure(double *xmeas, double *ymeas, double *zmeas){ |
| 397 |
|
|
for(int i=0; i<6; i++) xm[i]=*xmeas++; |
| 398 |
|
|
for(int i=0; i<6; i++) ym[i]=*ymeas++; |
| 399 |
|
|
for(int i=0; i<6; i++) zm[i]=*zmeas++; |
| 400 |
|
|
} |
| 401 |
|
|
/** |
| 402 |
|
|
* Set the TrkTrack position resolution |
| 403 |
|
|
*/ |
| 404 |
|
|
void TrkTrack::SetResolution(double *rx, double *ry){ |
| 405 |
|
|
for(int i=0; i<6; i++) resx[i]=*rx++; |
| 406 |
|
|
for(int i=0; i<6; i++) resy[i]=*ry++; |
| 407 |
|
|
} |
| 408 |
|
|
/** |
| 409 |
pam-fi |
1.33 |
* Set the TrkTrack good measurement. |
| 410 |
pam-fi |
1.13 |
*/ |
| 411 |
|
|
void TrkTrack::SetGood(int *xg, int *yg){ |
| 412 |
pam-fi |
1.33 |
|
| 413 |
pam-fi |
1.13 |
for(int i=0; i<6; i++) xgood[i]=*xg++; |
| 414 |
|
|
for(int i=0; i<6; i++) ygood[i]=*yg++; |
| 415 |
|
|
} |
| 416 |
|
|
|
| 417 |
|
|
/** |
| 418 |
|
|
* Load the magnetic field |
| 419 |
|
|
*/ |
| 420 |
pam-fi |
1.16 |
void TrkTrack::LoadField(TString path){ |
| 421 |
|
|
|
| 422 |
pam-fi |
1.26 |
// strcpy(path_.path,path.Data()); |
| 423 |
|
|
// path_.pathlen = path.Length(); |
| 424 |
|
|
// path_.error = 0; |
| 425 |
|
|
// readb_(); |
| 426 |
|
|
|
| 427 |
pam-fi |
1.33 |
TrkParams::SetTrackingMode(); |
| 428 |
|
|
TrkParams::SetPrecisionFactor(); |
| 429 |
|
|
TrkParams::SetStepMin(); |
| 430 |
|
|
|
| 431 |
pam-fi |
1.26 |
TrkParams::Set(path,1); |
| 432 |
pam-fi |
1.28 |
TrkParams::Load(1); |
| 433 |
pam-fi |
1.16 |
|
| 434 |
pam-fi |
1.13 |
}; |
| 435 |
pam-fi |
1.19 |
|
| 436 |
pam-fi |
1.25 |
|
| 437 |
pam-fi |
1.19 |
/** |
| 438 |
|
|
* Method to fill minimization-routine common |
| 439 |
|
|
*/ |
| 440 |
|
|
void TrkTrack::FillMiniStruct(cMini2track& track){ |
| 441 |
|
|
|
| 442 |
|
|
for(int i=0; i<6; i++){ |
| 443 |
|
|
|
| 444 |
pam-fi |
1.33 |
// cout << i<<" - "<<xgood[i]<<" "<<XGood(i)<<endl; |
| 445 |
|
|
// cout << i<<" - "<<ygood[i]<<" "<<YGood(i)<<endl; |
| 446 |
pam-fi |
1.30 |
track.xgood[i]=XGood(i); |
| 447 |
|
|
track.ygood[i]=YGood(i); |
| 448 |
pam-fi |
1.19 |
|
| 449 |
|
|
track.xm[i]=xm[i]; |
| 450 |
|
|
track.ym[i]=ym[i]; |
| 451 |
|
|
track.zm[i]=zm[i]; |
| 452 |
|
|
|
| 453 |
|
|
// --- temporaneo ---------------------------- |
| 454 |
|
|
// andrebbe inserita la dimensione del sensore |
| 455 |
|
|
float segment = 100.; |
| 456 |
|
|
track.xm_a[i]=xm[i]; |
| 457 |
|
|
track.xm_b[i]=xm[i]; |
| 458 |
|
|
track.ym_a[i]=ym[i]; |
| 459 |
|
|
track.ym_b[i]=ym[i]; |
| 460 |
pam-fi |
1.30 |
if( XGood(i) && !YGood(i) ){ |
| 461 |
pam-fi |
1.19 |
track.ym_a[i] = track.ym_a[i]+segment; |
| 462 |
|
|
track.ym_b[i] = track.ym_b[i]-segment; |
| 463 |
pam-fi |
1.30 |
}else if( !XGood(i) && YGood(i)){ |
| 464 |
pam-fi |
1.19 |
track.xm_a[i] = track.xm_a[i]+segment; |
| 465 |
|
|
track.xm_b[i] = track.xm_b[i]-segment; |
| 466 |
|
|
} |
| 467 |
|
|
// --- temporaneo ---------------------------- |
| 468 |
|
|
|
| 469 |
|
|
track.resx[i]=resx[i]; |
| 470 |
|
|
track.resy[i]=resy[i]; |
| 471 |
|
|
} |
| 472 |
|
|
|
| 473 |
|
|
for(int i=0; i<5; i++) track.al[i]=al[i]; |
| 474 |
|
|
track.zini = 23.5; |
| 475 |
|
|
// ZINI = 23.5 !!! it should be the same parameter in all codes |
| 476 |
|
|
|
| 477 |
|
|
} |
| 478 |
|
|
/** |
| 479 |
|
|
* Method to set values from minimization-routine common |
| 480 |
|
|
*/ |
| 481 |
|
|
void TrkTrack::SetFromMiniStruct(cMini2track *track){ |
| 482 |
|
|
|
| 483 |
|
|
for(int i=0; i<5; i++) { |
| 484 |
|
|
al[i]=track->al[i]; |
| 485 |
|
|
for(int j=0; j<5; j++) coval[i][j]=track->cov[i][j]; |
| 486 |
|
|
} |
| 487 |
|
|
chi2 = track->chi2; |
| 488 |
|
|
nstep = track->nstep; |
| 489 |
|
|
for(int i=0; i<6; i++){ |
| 490 |
|
|
xv[i] = track->xv[i]; |
| 491 |
|
|
yv[i] = track->yv[i]; |
| 492 |
|
|
zv[i] = track->zv[i]; |
| 493 |
|
|
xm[i] = track->xm[i]; |
| 494 |
|
|
ym[i] = track->ym[i]; |
| 495 |
|
|
zm[i] = track->zm[i]; |
| 496 |
|
|
axv[i] = track->axv[i]; |
| 497 |
|
|
ayv[i] = track->ayv[i]; |
| 498 |
|
|
} |
| 499 |
|
|
|
| 500 |
|
|
} |
| 501 |
pam-fi |
1.13 |
/** |
| 502 |
pam-fi |
1.33 |
* \brief Method to re-evaluate coordinates of clusters associated with a track. |
| 503 |
|
|
* |
| 504 |
|
|
* The method can be applied only after recovering level1 information |
| 505 |
|
|
* (either by reprocessing single events from level0 or from |
| 506 |
|
|
* the TrkLevel1 branch, if present); it calls F77 subroutines that |
| 507 |
|
|
* read the level1 common and fill the minimization-routine common. |
| 508 |
|
|
* Some clusters can be excluded or added by means of the methods: |
| 509 |
|
|
* |
| 510 |
|
|
* TrkTrack::ResetXGood(int ip) |
| 511 |
|
|
* TrkTrack::ResetYGood(int ip) |
| 512 |
|
|
* TrkTrack::SetXGood(int ip, int cid, int is) |
| 513 |
|
|
* TrkTrack::SetYGood(int ip, int cid, int is) |
| 514 |
|
|
* |
| 515 |
|
|
* NB! The method TrkTrack::SetGood(int *xg, int *yg) set the plane-mask (0-1) |
| 516 |
|
|
* for the minimization-routine common. It deletes the cluster information |
| 517 |
|
|
* (at least for the moment...) thus cannot be applied before |
| 518 |
|
|
* TrkTrack::EvaluateClusterPositions(). |
| 519 |
|
|
* |
| 520 |
|
|
* Different p.f.a. can be applied by calling (once) the method: |
| 521 |
|
|
* |
| 522 |
|
|
* TrkParams::SetPFA(0); //Set ETA p.f.a. |
| 523 |
|
|
* |
| 524 |
|
|
* @see TrkParams::SetPFA(int) |
| 525 |
|
|
*/ |
| 526 |
|
|
void TrkTrack::EvaluateClusterPositions(){ |
| 527 |
|
|
|
| 528 |
|
|
// cout << "void TrkTrack::GetClusterPositions() "<<endl; |
| 529 |
|
|
|
| 530 |
|
|
TrkParams::Load( ); |
| 531 |
|
|
if( !TrkParams::IsLoaded() )return; |
| 532 |
|
|
|
| 533 |
|
|
for(int ip=0; ip<6; ip++){ |
| 534 |
|
|
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
| 535 |
|
|
int icx = GetClusterX_ID(ip)+1; |
| 536 |
|
|
int icy = GetClusterY_ID(ip)+1; |
| 537 |
|
|
int sensor = GetSensor(ip)+1;//<< convenzione "Paolo" |
| 538 |
|
|
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
| 539 |
|
|
int ladder = GetLadder(ip)+1; |
| 540 |
|
|
float ax = axv[ip]; |
| 541 |
|
|
float ay = ayv[ip]; |
| 542 |
|
|
float v[3]; |
| 543 |
|
|
v[0]=xv[ip]; |
| 544 |
|
|
v[1]=yv[ip]; |
| 545 |
|
|
v[2]=zv[ip]; |
| 546 |
|
|
float bfx = 10*TrkParams::GetBX(v);//Tesla |
| 547 |
|
|
float bfy = 10*TrkParams::GetBY(v);//Tesla |
| 548 |
|
|
int ipp=ip+1; |
| 549 |
|
|
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
| 550 |
|
|
} |
| 551 |
|
|
} |
| 552 |
|
|
/** |
| 553 |
|
|
* \brief Tracking method. It calls F77 mini routine. |
| 554 |
|
|
* |
| 555 |
|
|
* @param pfixed Particle momentum. If pfixed=0 the momentum |
| 556 |
|
|
* is left as a free parameter, otherwise it is fixed to the input value. |
| 557 |
|
|
* @param fail Output flag (!=0 if the fit failed). |
| 558 |
|
|
* @param iprint Flag to set debug mode ( 0 = no output; 1 = verbose; 2 = debug). |
| 559 |
|
|
* @param froml1 Flag to re-evaluate positions (see TrkTrack::GetClusterPositions()). |
| 560 |
|
|
* |
| 561 |
|
|
* The option to re-evaluate positions can be used only after recovering |
| 562 |
|
|
* level1 information, eg. by reprocessing the single event. |
| 563 |
|
|
* |
| 564 |
|
|
* Example: |
| 565 |
|
|
* |
| 566 |
|
|
* if( !event->GetTrkLevel0() )return false; |
| 567 |
|
|
* event->GetTrkLevel0()->ProcessEvent(); // re-processing level0->level1 |
| 568 |
|
|
* int fail=0; |
| 569 |
|
|
* event->GetTrkLevel2()->GetTrack(0)->Fit(0.,fail,0,1); |
| 570 |
|
|
* |
| 571 |
|
|
* @see EvaluateClusterPositions() |
| 572 |
|
|
* |
| 573 |
|
|
* The fitting procedure can be varied by changing the tracking mode, |
| 574 |
|
|
* the fit-precision factor and the minimum number of step. |
| 575 |
|
|
* @see SetTrackingMode(int) |
| 576 |
|
|
* @see SetPrecisionFactor(double) |
| 577 |
|
|
* @see SetStepMin(int) |
| 578 |
pam-fi |
1.13 |
*/ |
| 579 |
pam-fi |
1.33 |
void TrkTrack::Fit(double pfixed, int& fail, int iprint, int froml1){ |
| 580 |
pam-fi |
1.15 |
|
| 581 |
|
|
float al_ini[] = {0.,0.,0.,0.,0.}; |
| 582 |
|
|
|
| 583 |
pam-fi |
1.33 |
TrkParams::Load( ); |
| 584 |
|
|
if( !TrkParams::IsLoaded() )return; |
| 585 |
|
|
|
| 586 |
pam-fi |
1.13 |
extern cMini2track track_; |
| 587 |
|
|
fail = 0; |
| 588 |
pam-fi |
1.19 |
FillMiniStruct(track_); |
| 589 |
pam-fi |
1.33 |
|
| 590 |
|
|
if(froml1!=0)EvaluateClusterPositions(); |
| 591 |
|
|
|
| 592 |
pam-fi |
1.19 |
// if fit variables have been reset, evaluate the initial guess |
| 593 |
pam-fi |
1.15 |
if(al[0]==-9999.&&al[1]==-9999.&&al[2]==-9999.&&al[3]==-9999.&&al[4]==-9999.)guess_(); |
| 594 |
|
|
|
| 595 |
pam-fi |
1.16 |
// --------------------- free momentum |
| 596 |
pam-fi |
1.14 |
if(pfixed==0.) { |
| 597 |
pam-fi |
1.19 |
track_.pfixed=0.; |
| 598 |
pam-fi |
1.14 |
} |
| 599 |
pam-fi |
1.16 |
// --------------------- fixed momentum |
| 600 |
pam-fi |
1.13 |
if(pfixed!=0.) { |
| 601 |
pam-fi |
1.19 |
al[4]=1./pfixed; |
| 602 |
|
|
track_.pfixed=pfixed; |
| 603 |
pam-fi |
1.13 |
} |
| 604 |
pam-fi |
1.15 |
|
| 605 |
pam-fi |
1.19 |
// store temporarily the initial guess |
| 606 |
pam-fi |
1.15 |
for(int i=0; i<5; i++) al_ini[i]=track_.al[i]; |
| 607 |
|
|
|
| 608 |
pam-fi |
1.19 |
// ------------------------------------------ |
| 609 |
|
|
// call mini routine |
| 610 |
pam-fi |
1.33 |
// TrkParams::Load(1); |
| 611 |
|
|
// if( !TrkParams::IsLoaded(1) ){ |
| 612 |
|
|
// cout << "void TrkTrack::Fit(double pfixed, int& fail, int iprint) --- ERROR --- m.field not loaded"<<endl; |
| 613 |
|
|
// return; |
| 614 |
|
|
// } |
| 615 |
pam-fi |
1.13 |
int istep=0; |
| 616 |
|
|
int ifail=0; |
| 617 |
|
|
mini2_(&istep,&ifail, &iprint); |
| 618 |
|
|
if(ifail!=0) { |
| 619 |
pam-fi |
1.19 |
if(iprint)cout << "ERROR: ifail= " << ifail << endl; |
| 620 |
pam-fi |
1.13 |
fail = 1; |
| 621 |
|
|
} |
| 622 |
pam-fi |
1.19 |
// ------------------------------------------ |
| 623 |
pam-fi |
1.15 |
|
| 624 |
pam-fi |
1.19 |
SetFromMiniStruct(&track_); |
| 625 |
pam-fi |
1.15 |
|
| 626 |
pam-fi |
1.20 |
if(fail){ |
| 627 |
pam-fi |
1.33 |
if(iprint)cout << " >>>> fit failed "<<endl; |
| 628 |
pam-fi |
1.20 |
for(int i=0; i<5; i++) al[i]=al_ini[i]; |
| 629 |
|
|
} |
| 630 |
pam-fi |
1.15 |
|
| 631 |
pam-fi |
1.13 |
}; |
| 632 |
pam-fi |
1.33 |
/** |
| 633 |
pam-fi |
1.15 |
* Reset the fit parameters |
| 634 |
pam-fi |
1.13 |
*/ |
| 635 |
|
|
void TrkTrack::FitReset(){ |
| 636 |
|
|
for(int i=0; i<5; i++) al[i]=-9999.; |
| 637 |
|
|
chi2=0.; |
| 638 |
|
|
nstep=0; |
| 639 |
pam-fi |
1.33 |
// for(int i=0; i<6; i++) xv[i]=0.; |
| 640 |
|
|
// for(int i=0; i<6; i++) yv[i]=0.; |
| 641 |
|
|
// for(int i=0; i<6; i++) zv[i]=0.; |
| 642 |
|
|
// for(int i=0; i<6; i++) axv[i]=0.; |
| 643 |
|
|
// for(int i=0; i<6; i++) ayv[i]=0.; |
| 644 |
pam-fi |
1.13 |
for(int i=0; i<5; i++) { |
| 645 |
|
|
for(int j=0; j<5; j++) coval[i][j]=0.; |
| 646 |
|
|
} |
| 647 |
|
|
} |
| 648 |
pam-fi |
1.33 |
/** |
| 649 |
pam-fi |
1.31 |
* Set the tracking mode |
| 650 |
|
|
*/ |
| 651 |
pam-fi |
1.27 |
void TrkTrack::SetTrackingMode(int trackmode){ |
| 652 |
|
|
extern cMini2track track_; |
| 653 |
|
|
track_.trackmode = trackmode; |
| 654 |
|
|
} |
| 655 |
pam-fi |
1.33 |
/** |
| 656 |
pam-fi |
1.31 |
* Set the factor scale for tracking precision |
| 657 |
|
|
*/ |
| 658 |
|
|
void TrkTrack::SetPrecisionFactor(double fact){ |
| 659 |
|
|
extern cMini2track track_; |
| 660 |
|
|
track_.fact = fact; |
| 661 |
|
|
} |
| 662 |
pam-fi |
1.33 |
/** |
| 663 |
pam-fi |
1.31 |
* Set the factor scale for tracking precision |
| 664 |
|
|
*/ |
| 665 |
|
|
void TrkTrack::SetStepMin(int istepmin){ |
| 666 |
|
|
extern cMini2track track_; |
| 667 |
|
|
track_.istepmin = istepmin; |
| 668 |
|
|
} |
| 669 |
pam-fi |
1.13 |
|
| 670 |
pam-fi |
1.29 |
|
| 671 |
pam-fi |
1.33 |
/** |
| 672 |
pam-fi |
1.32 |
* Method to retrieve ID (0,1,...) of x-cluster (if any) associated to this track. |
| 673 |
|
|
* If no cluster is associated, ID=-1. |
| 674 |
pam-fi |
1.29 |
* @param ip Tracker plane (0-5) |
| 675 |
|
|
*/ |
| 676 |
pam-fi |
1.32 |
Int_t TrkTrack::GetClusterX_ID(int ip){ |
| 677 |
|
|
return ((Int_t)fabs(xgood[ip]))%10000000-1; |
| 678 |
pam-fi |
1.29 |
}; |
| 679 |
pam-fi |
1.33 |
/** |
| 680 |
pam-fi |
1.32 |
* Method to retrieve ID (0-xxx) of y-cluster (if any) associated to this track. |
| 681 |
|
|
* If no cluster is associated, ID=-1. |
| 682 |
pam-fi |
1.29 |
* @param ip Tracker plane (0-5) |
| 683 |
|
|
*/ |
| 684 |
pam-fi |
1.32 |
Int_t TrkTrack::GetClusterY_ID(int ip){ |
| 685 |
|
|
return ((Int_t)fabs(ygood[ip]))%10000000-1; |
| 686 |
|
|
}; |
| 687 |
pam-fi |
1.33 |
/** |
| 688 |
pam-fi |
1.32 |
* Method to retrieve the ladder (0-4, increasing x) traversed by the track on this plane. |
| 689 |
|
|
* If no ladder is traversed (dead area) the metod retuns -1. |
| 690 |
|
|
* @param ip Tracker plane (0-5) |
| 691 |
|
|
*/ |
| 692 |
|
|
Int_t TrkTrack::GetLadder(int ip){ |
| 693 |
|
|
if(XGood(ip))return (Int_t)fabs(xgood[ip]/100000000)-1; |
| 694 |
|
|
if(YGood(ip))return (Int_t)fabs(ygood[ip]/100000000)-1; |
| 695 |
|
|
return -1; |
| 696 |
|
|
}; |
| 697 |
pam-fi |
1.33 |
/** |
| 698 |
pam-fi |
1.32 |
* Method to retrieve the sensor (0-1, increasing y) traversed by the track on this plane. |
| 699 |
|
|
* If no sensor is traversed (dead area) the metod retuns -1. |
| 700 |
|
|
* @param ip Tracker plane (0-5) |
| 701 |
|
|
*/ |
| 702 |
|
|
Int_t TrkTrack::GetSensor(int ip){ |
| 703 |
|
|
if(XGood(ip))return (Int_t)((Int_t)fabs(xgood[ip]/10000000)%10)-1; |
| 704 |
|
|
if(YGood(ip))return (Int_t)((Int_t)fabs(ygood[ip]/10000000)%10)-1; |
| 705 |
|
|
return -1; |
| 706 |
pam-fi |
1.29 |
}; |
| 707 |
|
|
|
| 708 |
pam-fi |
1.33 |
/** |
| 709 |
|
|
* \brief Method to include a x-cluster to the track. |
| 710 |
|
|
* @param ip Tracker plane (0-5) |
| 711 |
|
|
* @param clid Cluster ID (0,1,...) |
| 712 |
|
|
* @param is Sensor (0-1, increasing y) |
| 713 |
|
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
| 714 |
|
|
*/ |
| 715 |
|
|
void TrkTrack::SetXGood(int ip, int clid, int is){ |
| 716 |
|
|
int il=0; //ladder (temporary) |
| 717 |
|
|
bool bad=false; //ladder (temporary) |
| 718 |
|
|
xgood[ip]=il*100000000+is*10000000+clid; |
| 719 |
|
|
if(bad)xgood[ip]=-xgood[ip]; |
| 720 |
|
|
}; |
| 721 |
|
|
/** |
| 722 |
|
|
* \brief Method to include a y-cluster to the track. |
| 723 |
|
|
* @param ip Tracker plane (0-5) |
| 724 |
|
|
* @param clid Cluster ID (0,1,...) |
| 725 |
|
|
* @param is Sensor (0-1) |
| 726 |
|
|
* @see Fit(double pfixed, int& fail, int iprint, int froml1) |
| 727 |
|
|
*/ |
| 728 |
|
|
void TrkTrack::SetYGood(int ip, int clid, int is){ |
| 729 |
|
|
int il=0; //ladder (temporary) |
| 730 |
|
|
bool bad=false; //ladder (temporary) |
| 731 |
|
|
ygood[ip]=il*100000000+is*10000000+clid; |
| 732 |
|
|
if(bad)ygood[ip]=-ygood[ip]; |
| 733 |
|
|
}; |
| 734 |
pam-fi |
1.29 |
|
| 735 |
mocchiut |
1.1 |
//-------------------------------------- |
| 736 |
|
|
// |
| 737 |
|
|
// |
| 738 |
|
|
//-------------------------------------- |
| 739 |
pam-fi |
1.10 |
void TrkTrack::Clear(){ |
| 740 |
pam-fi |
1.21 |
// cout << "TrkTrack::Clear()"<<endl; |
| 741 |
|
|
seqno = -1; |
| 742 |
|
|
image = -1; |
| 743 |
|
|
chi2 = 0; |
| 744 |
|
|
nstep = 0; |
| 745 |
|
|
for(int it1=0;it1<5;it1++){ |
| 746 |
|
|
al[it1] = 0; |
| 747 |
|
|
for(int it2=0;it2<5;it2++)coval[it1][it2] = 0; |
| 748 |
|
|
}; |
| 749 |
|
|
for(int ip=0;ip<6;ip++){ |
| 750 |
|
|
xgood[ip] = 0; |
| 751 |
|
|
ygood[ip] = 0; |
| 752 |
|
|
xm[ip] = 0; |
| 753 |
|
|
ym[ip] = 0; |
| 754 |
|
|
zm[ip] = 0; |
| 755 |
|
|
resx[ip] = 0; |
| 756 |
|
|
resy[ip] = 0; |
| 757 |
pam-fi |
1.32 |
tailx[ip] = 0; |
| 758 |
|
|
taily[ip] = 0; |
| 759 |
pam-fi |
1.21 |
xv[ip] = 0; |
| 760 |
|
|
yv[ip] = 0; |
| 761 |
|
|
zv[ip] = 0; |
| 762 |
|
|
axv[ip] = 0; |
| 763 |
|
|
ayv[ip] = 0; |
| 764 |
|
|
dedx_x[ip] = 0; |
| 765 |
|
|
dedx_y[ip] = 0; |
| 766 |
|
|
|
| 767 |
|
|
}; |
| 768 |
pam-fi |
1.32 |
// if(clx)clx->Clear(); |
| 769 |
|
|
// if(cly)cly->Clear(); |
| 770 |
|
|
// clx.Clear(); |
| 771 |
|
|
// cly.Clear(); |
| 772 |
pam-fi |
1.10 |
}; |
| 773 |
|
|
//-------------------------------------- |
| 774 |
|
|
// |
| 775 |
|
|
// |
| 776 |
|
|
//-------------------------------------- |
| 777 |
pam-fi |
1.11 |
void TrkTrack::Delete(){ |
| 778 |
pam-fi |
1.21 |
// cout << "TrkTrack::Delete()"<<endl; |
| 779 |
pam-fi |
1.32 |
Clear(); |
| 780 |
|
|
// if(clx)delete clx; |
| 781 |
|
|
// if(cly)delete cly; |
| 782 |
pam-fi |
1.11 |
}; |
| 783 |
pam-fi |
1.21 |
//-------------------------------------- |
| 784 |
pam-fi |
1.11 |
// |
| 785 |
|
|
// |
| 786 |
|
|
//-------------------------------------- |
| 787 |
pam-fi |
1.10 |
|
| 788 |
|
|
//-------------------------------------- |
| 789 |
|
|
// |
| 790 |
|
|
// |
| 791 |
|
|
//-------------------------------------- |
| 792 |
mocchiut |
1.1 |
TrkSinglet::TrkSinglet(){ |
| 793 |
pam-fi |
1.21 |
// cout << "TrkSinglet::TrkSinglet() " << GetUniqueID()<<endl; |
| 794 |
mocchiut |
1.1 |
plane = 0; |
| 795 |
|
|
coord[0] = 0; |
| 796 |
|
|
coord[1] = 0; |
| 797 |
|
|
sgnl = 0; |
| 798 |
pam-fi |
1.21 |
// cls = 0; |
| 799 |
mocchiut |
1.1 |
}; |
| 800 |
|
|
//-------------------------------------- |
| 801 |
|
|
// |
| 802 |
|
|
// |
| 803 |
|
|
//-------------------------------------- |
| 804 |
|
|
TrkSinglet::TrkSinglet(const TrkSinglet& s){ |
| 805 |
pam-fi |
1.21 |
// cout << "TrkSinglet::TrkSinglet(const TrkSinglet& s) " << GetUniqueID()<<endl; |
| 806 |
mocchiut |
1.1 |
plane = s.plane; |
| 807 |
|
|
coord[0] = s.coord[0]; |
| 808 |
|
|
coord[1] = s.coord[1]; |
| 809 |
|
|
sgnl = s.sgnl; |
| 810 |
pam-fi |
1.9 |
// cls = 0;//<<<<pointer |
| 811 |
pam-fi |
1.32 |
// cls = TRef(s.cls); |
| 812 |
mocchiut |
1.1 |
}; |
| 813 |
|
|
//-------------------------------------- |
| 814 |
|
|
// |
| 815 |
|
|
// |
| 816 |
|
|
//-------------------------------------- |
| 817 |
|
|
void TrkSinglet::Dump(){ |
| 818 |
|
|
int i=0; |
| 819 |
|
|
cout << endl << "========== Singlet " ; |
| 820 |
|
|
cout << endl << "plane : " << plane; |
| 821 |
|
|
cout << endl << "coord[2] : "; while( i<2 && cout << coord[i] << " ") i++; |
| 822 |
|
|
cout << endl << "sgnl : " << sgnl; |
| 823 |
|
|
} |
| 824 |
|
|
//-------------------------------------- |
| 825 |
|
|
// |
| 826 |
|
|
// |
| 827 |
|
|
//-------------------------------------- |
| 828 |
pam-fi |
1.21 |
void TrkSinglet::Clear(){ |
| 829 |
|
|
// cout << "TrkSinglet::Clear() " << GetUniqueID()<<endl; |
| 830 |
|
|
// cls=0; |
| 831 |
|
|
plane=-1; |
| 832 |
|
|
coord[0]=-999; |
| 833 |
|
|
coord[1]=-999; |
| 834 |
|
|
sgnl=0; |
| 835 |
|
|
|
| 836 |
|
|
} |
| 837 |
|
|
//-------------------------------------- |
| 838 |
|
|
// |
| 839 |
|
|
// |
| 840 |
|
|
//-------------------------------------- |
| 841 |
mocchiut |
1.1 |
TrkLevel2::TrkLevel2(){ |
| 842 |
mocchiut |
1.24 |
// cout <<"TrkLevel2::TrkLevel2()"<<endl; |
| 843 |
mocchiut |
1.1 |
for(Int_t i=0; i<12 ; i++){ |
| 844 |
pam-fi |
1.32 |
good[i] = -1; |
| 845 |
|
|
VKmask[i] = 0; |
| 846 |
|
|
VKflag[i] = 0; |
| 847 |
|
|
}; |
| 848 |
pam-fi |
1.21 |
Track = 0; |
| 849 |
|
|
SingletX = 0; |
| 850 |
|
|
SingletY = 0; |
| 851 |
pam-fi |
1.6 |
|
| 852 |
mocchiut |
1.1 |
} |
| 853 |
|
|
//-------------------------------------- |
| 854 |
|
|
// |
| 855 |
|
|
// |
| 856 |
|
|
//-------------------------------------- |
| 857 |
pam-fi |
1.23 |
void TrkLevel2::Set(){ |
| 858 |
|
|
if(!Track)Track = new TClonesArray("TrkTrack"); |
| 859 |
|
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 860 |
|
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 861 |
|
|
} |
| 862 |
|
|
//-------------------------------------- |
| 863 |
|
|
// |
| 864 |
|
|
// |
| 865 |
|
|
//-------------------------------------- |
| 866 |
mocchiut |
1.1 |
void TrkLevel2::Dump(){ |
| 867 |
pam-fi |
1.10 |
|
| 868 |
|
|
// |
| 869 |
mocchiut |
1.1 |
cout << endl << endl << "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; |
| 870 |
pam-fi |
1.10 |
cout << endl << "good : "; for(int i=0; i<12; i++) cout << good[i]<<" "; |
| 871 |
mocchiut |
1.1 |
cout << endl << "ntrk() : " << this->ntrk() ; |
| 872 |
|
|
cout << endl << "nclsx() : " << this->nclsx(); |
| 873 |
|
|
cout << endl << "nclsy() : " << this->nclsy(); |
| 874 |
pam-fi |
1.21 |
if(Track){ |
| 875 |
|
|
TClonesArray &t = *Track; |
| 876 |
|
|
for(int i=0; i<ntrk(); i++) ((TrkTrack *)t[i])->Dump(); |
| 877 |
|
|
} |
| 878 |
|
|
if(SingletX){ |
| 879 |
|
|
TClonesArray &sx = *SingletX; |
| 880 |
|
|
for(int i=0; i<nclsx(); i++) ((TrkSinglet *)sx[i])->Dump(); |
| 881 |
|
|
} |
| 882 |
|
|
if(SingletY){ |
| 883 |
|
|
TClonesArray &sy = *SingletY; |
| 884 |
|
|
for(int i=0; i<nclsy(); i++) ((TrkSinglet *)sy[i])->Dump(); |
| 885 |
|
|
} |
| 886 |
mocchiut |
1.1 |
} |
| 887 |
|
|
//-------------------------------------- |
| 888 |
|
|
// |
| 889 |
|
|
// |
| 890 |
|
|
//-------------------------------------- |
| 891 |
|
|
/** |
| 892 |
pam-fi |
1.32 |
* The method returns false if the viking-chip was masked |
| 893 |
|
|
* either apriori ,on the basis of the mask read from the DB, |
| 894 |
|
|
* or run-by-run, on the basis of the calibration parameters) |
| 895 |
|
|
* @param iv Tracker view (0-11) |
| 896 |
|
|
* @param ivk Viking-chip number (0-23) |
| 897 |
|
|
*/ |
| 898 |
|
|
Bool_t TrkLevel2::GetVKMask(int iv, int ivk){ |
| 899 |
|
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 900 |
|
|
return (whichbit&VKmask[iv])!=0; |
| 901 |
|
|
} |
| 902 |
|
|
/** |
| 903 |
|
|
* The method returns false if the viking-chip was masked |
| 904 |
|
|
* for this event due to common-noise computation failure. |
| 905 |
|
|
* @param iv Tracker view (0-11) |
| 906 |
|
|
* @param ivk Viking-chip number (0-23) |
| 907 |
|
|
*/ |
| 908 |
|
|
Bool_t TrkLevel2::GetVKFlag(int iv, int ivk){ |
| 909 |
|
|
Int_t whichbit = (Int_t)pow(2,ivk); |
| 910 |
|
|
return (whichbit&VKflag[iv])!=0; |
| 911 |
|
|
} |
| 912 |
|
|
/** |
| 913 |
|
|
* The method returns true if the viking-chip was masked, either |
| 914 |
|
|
* forced (see TrkLevel2::GetVKMask(int,int)) or |
| 915 |
|
|
* for this event only (TrkLevel2::GetVKFlag(int,int)). |
| 916 |
|
|
* @param iv Tracker view (0-11) |
| 917 |
|
|
* @param ivk Viking-chip number (0-23) |
| 918 |
mocchiut |
1.1 |
*/ |
| 919 |
pam-fi |
1.32 |
Bool_t TrkLevel2::IsMaskedVK(int iv, int ivk){ |
| 920 |
|
|
return !(GetVKMask(iv,ivk)&&GetVKFlag(iv,ivk) ); |
| 921 |
|
|
}; |
| 922 |
pam-fi |
1.10 |
|
| 923 |
pam-fi |
1.9 |
//-------------------------------------- |
| 924 |
|
|
// |
| 925 |
|
|
// |
| 926 |
|
|
//-------------------------------------- |
| 927 |
|
|
/** |
| 928 |
|
|
* Fills a TrkLevel2 object with values from a struct cTrkLevel2 (to get data from F77 common). |
| 929 |
pam-fi |
1.29 |
* Ref to Level1 data (clusters) is also set. If l1==NULL no references are set. |
| 930 |
|
|
* (NB It make sense to set references only if events are stored in a tree that contains also the Level1 branch) |
| 931 |
pam-fi |
1.9 |
*/ |
| 932 |
|
|
void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1){ |
| 933 |
|
|
|
| 934 |
pam-fi |
1.29 |
// cout << "void TrkLevel2::SetFromLevel2Struct(cTrkLevel2 *l2, TrkLevel1 *l1)"<<endl; |
| 935 |
|
|
Clear(); |
| 936 |
pam-fi |
1.32 |
|
| 937 |
pam-fi |
1.9 |
// temporary objects: |
| 938 |
pam-fi |
1.29 |
TrkSinglet* t_singlet = new TrkSinglet(); |
| 939 |
|
|
TrkTrack* t_track = new TrkTrack(); |
| 940 |
|
|
|
| 941 |
|
|
// ----------------- |
| 942 |
|
|
// general variables |
| 943 |
|
|
// ----------------- |
| 944 |
|
|
for(Int_t i=0; i<12 ; i++){ |
| 945 |
|
|
good[i] = l2->good[i]; |
| 946 |
pam-fi |
1.32 |
VKmask[i]=0; |
| 947 |
|
|
VKflag[i]=0; |
| 948 |
|
|
for(Int_t ii=0; ii<24 ; ii++){ |
| 949 |
|
|
Int_t setbit = (Int_t)pow(2,ii); |
| 950 |
|
|
if( l2->vkflag[ii][i]!=-1 )VKmask[i]=VKmask[i]|setbit; |
| 951 |
|
|
if( l2->vkflag[ii][i]!=0 )VKflag[i]=VKflag[i]|setbit; |
| 952 |
|
|
}; |
| 953 |
pam-fi |
1.29 |
}; |
| 954 |
|
|
// -------------- |
| 955 |
|
|
// *** TRACKS *** |
| 956 |
|
|
// -------------- |
| 957 |
|
|
if(!Track) Track = new TClonesArray("TrkTrack"); |
| 958 |
|
|
TClonesArray &t = *Track; |
| 959 |
pam-fi |
1.32 |
|
| 960 |
pam-fi |
1.29 |
for(int i=0; i<l2->ntrk; i++){ |
| 961 |
|
|
t_track->seqno = i;// NBNBNBNB deve sempre essere = i |
| 962 |
|
|
t_track->image = l2->image[i]-1; |
| 963 |
|
|
t_track->chi2 = l2->chi2_nt[i]; |
| 964 |
|
|
t_track->nstep = l2->nstep_nt[i]; |
| 965 |
|
|
for(int it1=0;it1<5;it1++){ |
| 966 |
|
|
t_track->al[it1] = l2->al_nt[i][it1]; |
| 967 |
|
|
for(int it2=0;it2<5;it2++) |
| 968 |
|
|
t_track->coval[it1][it2] = l2->coval[i][it2][it1]; |
| 969 |
pam-fi |
1.9 |
}; |
| 970 |
pam-fi |
1.29 |
for(int ip=0;ip<6;ip++){ |
| 971 |
pam-fi |
1.32 |
// --------------------------------- |
| 972 |
|
|
// new implementation of xgood/ygood |
| 973 |
|
|
// --------------------------------- |
| 974 |
|
|
t_track->xgood[ip] = l2->cltrx[i][ip]; //cluster ID |
| 975 |
|
|
t_track->ygood[ip] = l2->cltry[i][ip]; //cluster ID |
| 976 |
|
|
t_track->xgood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 977 |
|
|
t_track->ygood[ip] += 10000000*l2->ls[i][ip]; // ladder+sensor |
| 978 |
|
|
if(l2->xbad[i][ip]>0)t_track->xgood[ip]=-t_track->xgood[ip]; |
| 979 |
|
|
if(l2->ybad[i][ip]>0)t_track->ygood[ip]=-t_track->ygood[ip]; |
| 980 |
|
|
// if(l2->xbad[i][ip]>0 || l2->ybad[i][ip]>0){ |
| 981 |
|
|
// if(l2->dedx_x[i][ip]<0 || l2->dedx_y[i][ip]<0){ |
| 982 |
|
|
// cout << ip << " - "<< l2->cltrx[i][ip] << " "<<l2->cltry[i][ip]<<" "<<l2->ls[i][ip]<<endl; |
| 983 |
|
|
// cout << ip << " - "<<t_track->xgood[ip]<<" "<<t_track->ygood[ip]<<endl; |
| 984 |
|
|
// cout << ip << " - "<<t_track->GetClusterX_ID(ip)<<" "<<t_track->GetClusterY_ID(ip)<<" "<<t_track->GetLadder(ip)<<" "<<t_track->GetSensor(ip)<<endl; |
| 985 |
|
|
// cout << ip << " - "<<t_track->BadClusterX(ip)<<" "<<t_track->BadClusterY(ip)<<endl; |
| 986 |
|
|
// cout << ip << " - "<<t_track->SaturatedClusterX(ip)<<" "<<t_track->SaturatedClusterY(ip)<<endl; |
| 987 |
|
|
// } |
| 988 |
pam-fi |
1.29 |
t_track->xm[ip] = l2->xm_nt[i][ip]; |
| 989 |
|
|
t_track->ym[ip] = l2->ym_nt[i][ip]; |
| 990 |
|
|
t_track->zm[ip] = l2->zm_nt[i][ip]; |
| 991 |
|
|
t_track->resx[ip] = l2->resx_nt[i][ip]; |
| 992 |
|
|
t_track->resy[ip] = l2->resy_nt[i][ip]; |
| 993 |
pam-fi |
1.32 |
t_track->tailx[ip] = l2->tailx[i][ip]; |
| 994 |
|
|
t_track->taily[ip] = l2->taily[i][ip]; |
| 995 |
pam-fi |
1.29 |
t_track->xv[ip] = l2->xv_nt[i][ip]; |
| 996 |
|
|
t_track->yv[ip] = l2->yv_nt[i][ip]; |
| 997 |
|
|
t_track->zv[ip] = l2->zv_nt[i][ip]; |
| 998 |
|
|
t_track->axv[ip] = l2->axv_nt[i][ip]; |
| 999 |
|
|
t_track->ayv[ip] = l2->ayv_nt[i][ip]; |
| 1000 |
|
|
t_track->dedx_x[ip] = l2->dedx_x[i][ip]; |
| 1001 |
|
|
t_track->dedx_y[ip] = l2->dedx_y[i][ip]; |
| 1002 |
|
|
//----------------------------------------------------- |
| 1003 |
|
|
//----------------------------------------------------- |
| 1004 |
|
|
//----------------------------------------------------- |
| 1005 |
|
|
//----------------------------------------------------- |
| 1006 |
|
|
}; |
| 1007 |
pam-fi |
1.32 |
// if(t_track->IsSaturated())t_track->Dump(); |
| 1008 |
pam-fi |
1.29 |
new(t[i]) TrkTrack(*t_track); |
| 1009 |
|
|
t_track->Clear(); |
| 1010 |
|
|
}; |
| 1011 |
pam-fi |
1.32 |
|
| 1012 |
pam-fi |
1.29 |
// ---------------- |
| 1013 |
|
|
// *** SINGLETS *** |
| 1014 |
|
|
// ---------------- |
| 1015 |
|
|
if(!SingletX)SingletX = new TClonesArray("TrkSinglet"); |
| 1016 |
|
|
TClonesArray &sx = *SingletX; |
| 1017 |
|
|
for(int i=0; i<l2->nclsx; i++){ |
| 1018 |
|
|
t_singlet->plane = l2->planex[i]; |
| 1019 |
|
|
t_singlet->coord[0] = l2->xs[i][0]; |
| 1020 |
|
|
t_singlet->coord[1] = l2->xs[i][1]; |
| 1021 |
|
|
t_singlet->sgnl = l2->signlxs[i]; |
| 1022 |
|
|
//----------------------------------------------------- |
| 1023 |
pam-fi |
1.32 |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsx[i]-1); |
| 1024 |
pam-fi |
1.29 |
//----------------------------------------------------- |
| 1025 |
|
|
new(sx[i]) TrkSinglet(*t_singlet); |
| 1026 |
|
|
t_singlet->Clear(); |
| 1027 |
|
|
} |
| 1028 |
|
|
if(!SingletY)SingletY = new TClonesArray("TrkSinglet"); |
| 1029 |
|
|
TClonesArray &sy = *SingletY; |
| 1030 |
|
|
for(int i=0; i<l2->nclsy; i++){ |
| 1031 |
|
|
t_singlet->plane = l2->planey[i]; |
| 1032 |
|
|
t_singlet->coord[0] = l2->ys[i][0]; |
| 1033 |
|
|
t_singlet->coord[1] = l2->ys[i][1]; |
| 1034 |
|
|
t_singlet->sgnl = l2->signlys[i]; |
| 1035 |
pam-fi |
1.26 |
//----------------------------------------------------- |
| 1036 |
pam-fi |
1.32 |
// if(l1) t_singlet->cls = l1->GetCluster(l2->clsy[i]-1); |
| 1037 |
pam-fi |
1.26 |
//----------------------------------------------------- |
| 1038 |
pam-fi |
1.29 |
new(sy[i]) TrkSinglet(*t_singlet); |
| 1039 |
|
|
t_singlet->Clear(); |
| 1040 |
|
|
}; |
| 1041 |
pam-fi |
1.5 |
|
| 1042 |
pam-fi |
1.29 |
delete t_track; |
| 1043 |
|
|
delete t_singlet; |
| 1044 |
mocchiut |
1.1 |
} |
| 1045 |
pam-fi |
1.7 |
/** |
| 1046 |
|
|
* Fills a struct cTrkLevel2 with values from a TrkLevel2 object (to put data into a F77 common). |
| 1047 |
|
|
*/ |
| 1048 |
|
|
|
| 1049 |
|
|
void TrkLevel2::GetLevel2Struct(cTrkLevel2 *l2) const { |
| 1050 |
|
|
|
| 1051 |
|
|
// general variables |
| 1052 |
pam-fi |
1.10 |
// l2->good2 = good2 ; |
| 1053 |
pam-fi |
1.7 |
for(Int_t i=0; i<12 ; i++){ |
| 1054 |
pam-fi |
1.10 |
// l2->crc[i] = crc[i]; |
| 1055 |
|
|
l2->good[i] = good[i]; |
| 1056 |
pam-fi |
1.7 |
}; |
| 1057 |
|
|
// *** TRACKS *** |
| 1058 |
|
|
|
| 1059 |
pam-fi |
1.21 |
if(Track){ |
| 1060 |
|
|
l2->ntrk = Track->GetEntries(); |
| 1061 |
|
|
for(Int_t i=0;i<l2->ntrk;i++){ |
| 1062 |
|
|
l2->image[i] = 1 + ((TrkTrack *)Track->At(i))->image; |
| 1063 |
|
|
l2->chi2_nt[i] = ((TrkTrack *)Track->At(i))->chi2; |
| 1064 |
|
|
l2->nstep_nt[i] = ((TrkTrack *)Track->At(i))->nstep; |
| 1065 |
|
|
for(int it1=0;it1<5;it1++){ |
| 1066 |
|
|
l2->al_nt[i][it1] = ((TrkTrack *)Track->At(i))->al[it1]; |
| 1067 |
|
|
for(int it2=0;it2<5;it2++) |
| 1068 |
|
|
l2->coval[i][it2][it1] = ((TrkTrack *)Track->At(i))->coval[it1][it2]; |
| 1069 |
|
|
}; |
| 1070 |
|
|
for(int ip=0;ip<6;ip++){ |
| 1071 |
pam-fi |
1.30 |
l2->xgood_nt[i][ip] = ((TrkTrack *)Track->At(i))->XGood(ip); |
| 1072 |
|
|
l2->ygood_nt[i][ip] = ((TrkTrack *)Track->At(i))->YGood(ip); |
| 1073 |
pam-fi |
1.21 |
l2->xm_nt[i][ip] = ((TrkTrack *)Track->At(i))->xm[ip]; |
| 1074 |
|
|
l2->ym_nt[i][ip] = ((TrkTrack *)Track->At(i))->ym[ip]; |
| 1075 |
|
|
l2->zm_nt[i][ip] = ((TrkTrack *)Track->At(i))->zm[ip]; |
| 1076 |
|
|
l2->resx_nt[i][ip] = ((TrkTrack *)Track->At(i))->resx[ip]; |
| 1077 |
|
|
l2->resy_nt[i][ip] = ((TrkTrack *)Track->At(i))->resy[ip]; |
| 1078 |
pam-fi |
1.32 |
l2->tailx[i][ip] = ((TrkTrack *)Track->At(i))->tailx[ip]; |
| 1079 |
|
|
l2->taily[i][ip] = ((TrkTrack *)Track->At(i))->taily[ip]; |
| 1080 |
pam-fi |
1.21 |
l2->xv_nt[i][ip] = ((TrkTrack *)Track->At(i))->xv[ip]; |
| 1081 |
|
|
l2->yv_nt[i][ip] = ((TrkTrack *)Track->At(i))->yv[ip]; |
| 1082 |
|
|
l2->zv_nt[i][ip] = ((TrkTrack *)Track->At(i))->zv[ip]; |
| 1083 |
|
|
l2->axv_nt[i][ip] = ((TrkTrack *)Track->At(i))->axv[ip]; |
| 1084 |
|
|
l2->ayv_nt[i][ip] = ((TrkTrack *)Track->At(i))->ayv[ip]; |
| 1085 |
|
|
l2->dedx_x[i][ip] = ((TrkTrack *)Track->At(i))->dedx_x[ip]; |
| 1086 |
|
|
l2->dedx_y[i][ip] = ((TrkTrack *)Track->At(i))->dedx_y[ip]; |
| 1087 |
|
|
}; |
| 1088 |
|
|
} |
| 1089 |
|
|
} |
| 1090 |
|
|
// *** SINGLETS *** |
| 1091 |
|
|
if(SingletX){ |
| 1092 |
|
|
l2->nclsx = SingletX->GetEntries(); |
| 1093 |
|
|
for(Int_t i=0;i<l2->nclsx;i++){ |
| 1094 |
|
|
l2->planex[i] = ((TrkSinglet *)SingletX->At(i))->plane; |
| 1095 |
|
|
l2->xs[i][0] = ((TrkSinglet *)SingletX->At(i))->coord[0]; |
| 1096 |
|
|
l2->xs[i][1] = ((TrkSinglet *)SingletX->At(i))->coord[1]; |
| 1097 |
|
|
l2->signlxs[i] = ((TrkSinglet *)SingletX->At(i))->sgnl; |
| 1098 |
|
|
} |
| 1099 |
pam-fi |
1.7 |
} |
| 1100 |
|
|
|
| 1101 |
pam-fi |
1.21 |
if(SingletY){ |
| 1102 |
|
|
l2->nclsy = SingletY->GetEntries(); |
| 1103 |
|
|
for(Int_t i=0;i<l2->nclsy;i++){ |
| 1104 |
|
|
l2->planey[i] = ((TrkSinglet *)SingletY->At(i))->plane; |
| 1105 |
|
|
l2->ys[i][0] = ((TrkSinglet *)SingletY->At(i))->coord[0]; |
| 1106 |
|
|
l2->ys[i][1] = ((TrkSinglet *)SingletY->At(i))->coord[1]; |
| 1107 |
|
|
l2->signlys[i] = ((TrkSinglet *)SingletY->At(i))->sgnl; |
| 1108 |
|
|
} |
| 1109 |
pam-fi |
1.7 |
} |
| 1110 |
|
|
} |
| 1111 |
mocchiut |
1.1 |
//-------------------------------------- |
| 1112 |
|
|
// |
| 1113 |
|
|
// |
| 1114 |
|
|
//-------------------------------------- |
| 1115 |
|
|
void TrkLevel2::Clear(){ |
| 1116 |
|
|
for(Int_t i=0; i<12 ; i++){ |
| 1117 |
pam-fi |
1.21 |
good[i] = -1; |
| 1118 |
pam-fi |
1.32 |
VKflag[i] = 0; |
| 1119 |
|
|
VKmask[i] = 0; |
| 1120 |
pam-fi |
1.21 |
}; |
| 1121 |
|
|
// if(Track)Track->Clear("C"); |
| 1122 |
|
|
// if(SingletX)SingletX->Clear("C"); |
| 1123 |
|
|
// if(SingletY)SingletY->Clear("C"); |
| 1124 |
|
|
if(Track)Track->Delete(); |
| 1125 |
|
|
if(SingletX)SingletX->Delete(); |
| 1126 |
|
|
if(SingletY)SingletY->Delete(); |
| 1127 |
|
|
} |
| 1128 |
|
|
// //-------------------------------------- |
| 1129 |
|
|
// // |
| 1130 |
|
|
// // |
| 1131 |
|
|
// //-------------------------------------- |
| 1132 |
pam-fi |
1.11 |
void TrkLevel2::Delete(){ |
| 1133 |
|
|
|
| 1134 |
pam-fi |
1.21 |
// cout << "void TrkLevel2::Delete()"<<endl; |
| 1135 |
|
|
Clear(); |
| 1136 |
|
|
if(Track)delete Track; |
| 1137 |
|
|
if(SingletX)delete SingletX; |
| 1138 |
|
|
if(SingletY)delete SingletY; |
| 1139 |
|
|
|
| 1140 |
pam-fi |
1.11 |
} |
| 1141 |
|
|
//-------------------------------------- |
| 1142 |
|
|
// |
| 1143 |
|
|
// |
| 1144 |
|
|
//-------------------------------------- |
| 1145 |
mocchiut |
1.1 |
/** |
| 1146 |
|
|
* Sort physical tracks and stores them in a TObjectArray, ordering by increasing chi**2 value (in case of track image, it selects the one with lower chi**2). The total number of physical tracks is given by GetNTracks() and the it-th physical track can be retrieved by means of the method GetTrack(int it). |
| 1147 |
|
|
* This method is overridden by PamLevel2::GetTracks(), where calorimeter and TOF information is used. |
| 1148 |
|
|
*/ |
| 1149 |
pam-fi |
1.8 |
TRefArray *TrkLevel2::GetTracks_NFitSorted(){ |
| 1150 |
pam-fi |
1.3 |
|
| 1151 |
pam-fi |
1.21 |
if(!Track)return 0; |
| 1152 |
|
|
|
| 1153 |
|
|
TRefArray *sorted = new TRefArray(); |
| 1154 |
pam-fi |
1.8 |
|
| 1155 |
pam-fi |
1.21 |
TClonesArray &t = *Track; |
| 1156 |
pam-fi |
1.8 |
// TClonesArray &ts = *PhysicalTrack; |
| 1157 |
pam-fi |
1.21 |
int N = ntrk(); |
| 1158 |
|
|
vector<int> m(N); for(int i=0; i<N; i++)m[i]=1; |
| 1159 |
pam-fi |
1.8 |
// int m[50]; for(int i=0; i<N; i++)m[i]=1; |
| 1160 |
|
|
|
| 1161 |
pam-fi |
1.21 |
int indo=0; |
| 1162 |
|
|
int indi=0; |
| 1163 |
pam-fi |
1.26 |
while(N > 0){ |
| 1164 |
|
|
// while(N != 0){ |
| 1165 |
pam-fi |
1.21 |
int nfit =0; |
| 1166 |
|
|
float chi2ref = numeric_limits<float>::max(); |
| 1167 |
pam-fi |
1.9 |
|
| 1168 |
pam-fi |
1.21 |
// first loop to search maximum num. of fit points |
| 1169 |
|
|
for(int i=0; i < ntrk(); i++){ |
| 1170 |
|
|
if( ((TrkTrack *)t[i])->GetNtot() >= nfit && m[i]==1){ |
| 1171 |
|
|
nfit = ((TrkTrack *)t[i])->GetNtot(); |
| 1172 |
|
|
} |
| 1173 |
|
|
} |
| 1174 |
|
|
//second loop to search minimum chi2 among selected |
| 1175 |
pam-fi |
1.26 |
for(int i=0; i<ntrk(); i++){ |
| 1176 |
pam-fi |
1.21 |
Float_t chi2 = ((TrkTrack *)t[i])->chi2; |
| 1177 |
pam-fi |
1.26 |
if(chi2 < 0) chi2 = -chi2*1000; |
| 1178 |
pam-fi |
1.21 |
if( chi2 < chi2ref |
| 1179 |
|
|
&& ((TrkTrack *)t[i])->GetNtot() == nfit |
| 1180 |
|
|
&& m[i]==1){ |
| 1181 |
|
|
chi2ref = ((TrkTrack *)t[i])->chi2; |
| 1182 |
|
|
indi = i; |
| 1183 |
|
|
}; |
| 1184 |
|
|
}; |
| 1185 |
|
|
if( ((TrkTrack *)t[indi])->HasImage() ){ |
| 1186 |
|
|
m[((TrkTrack *)t[indi])->image] = 0; |
| 1187 |
|
|
N--; |
| 1188 |
pam-fi |
1.8 |
|
| 1189 |
pam-fi |
1.26 |
// cout << "i** "<< ((TrkTrack *)t[indi])->image << " " << nfiti <<" "<<chi2i<<endl; |
| 1190 |
pam-fi |
1.21 |
}; |
| 1191 |
|
|
sorted->Add( (TrkTrack*)t[indi] ); |
| 1192 |
pam-fi |
1.3 |
|
| 1193 |
pam-fi |
1.21 |
m[indi] = 0; |
| 1194 |
pam-fi |
1.26 |
// cout << "SORTED "<< indo << " "<< indi << " "<< N << " "<<((TrkTrack *)t[indi])->image<<" "<<chi2ref<<endl; |
| 1195 |
pam-fi |
1.21 |
N--; |
| 1196 |
|
|
indo++; |
| 1197 |
|
|
} |
| 1198 |
|
|
m.clear(); |
| 1199 |
pam-fi |
1.26 |
// cout << "GetTracks_NFitSorted(it): Done"<< endl; |
| 1200 |
pam-fi |
1.8 |
|
| 1201 |
pam-fi |
1.21 |
return sorted; |
| 1202 |
pam-fi |
1.6 |
// return PhysicalTrack; |
| 1203 |
pam-fi |
1.3 |
} |
| 1204 |
mocchiut |
1.1 |
//-------------------------------------- |
| 1205 |
|
|
// |
| 1206 |
|
|
// |
| 1207 |
|
|
//-------------------------------------- |
| 1208 |
|
|
/** |
| 1209 |
|
|
* Retrieves the is-th stored track. |
| 1210 |
|
|
* @param it Track number, ranging from 0 to ntrk(). |
| 1211 |
|
|
* Fitted tracks ( images included ) are stored in a TObjectArray ( TrkLevel2::Track ) in the same order they are returned by the F77 fitting routine. |
| 1212 |
|
|
*/ |
| 1213 |
|
|
TrkTrack *TrkLevel2::GetStoredTrack(int is){ |
| 1214 |
|
|
|
| 1215 |
|
|
if(is >= this->ntrk()){ |
| 1216 |
|
|
cout << "** TrkLevel2 ** Track "<< is << "doen not exits! " << endl; |
| 1217 |
|
|
cout << " Stored tracks ntrk() = "<< this->ntrk() << endl; |
| 1218 |
|
|
return 0; |
| 1219 |
|
|
} |
| 1220 |
pam-fi |
1.21 |
if(!Track){ |
| 1221 |
|
|
cout << "TrkTrack *TrkLevel2::GetStoredTrack(int is) >> (TClonesArray*) Track ==0 "<<endl; |
| 1222 |
|
|
}; |
| 1223 |
mocchiut |
1.1 |
TClonesArray &t = *(Track); |
| 1224 |
|
|
TrkTrack *track = (TrkTrack*)t[is]; |
| 1225 |
|
|
return track; |
| 1226 |
|
|
} |
| 1227 |
|
|
//-------------------------------------- |
| 1228 |
|
|
// |
| 1229 |
|
|
// |
| 1230 |
|
|
//-------------------------------------- |
| 1231 |
|
|
/** |
| 1232 |
pam-fi |
1.6 |
* Retrieves the is-th stored X singlet. |
| 1233 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
| 1234 |
|
|
*/ |
| 1235 |
|
|
TrkSinglet *TrkLevel2::GetSingletX(int is){ |
| 1236 |
|
|
|
| 1237 |
|
|
if(is >= this->nclsx()){ |
| 1238 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
| 1239 |
|
|
cout << " Stored x-singlets nclsx() = "<< this->nclsx() << endl; |
| 1240 |
|
|
return 0; |
| 1241 |
|
|
} |
| 1242 |
pam-fi |
1.21 |
if(!SingletX)return 0; |
| 1243 |
pam-fi |
1.6 |
TClonesArray &t = *(SingletX); |
| 1244 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1245 |
|
|
return singlet; |
| 1246 |
|
|
} |
| 1247 |
|
|
//-------------------------------------- |
| 1248 |
|
|
// |
| 1249 |
|
|
// |
| 1250 |
|
|
//-------------------------------------- |
| 1251 |
|
|
/** |
| 1252 |
|
|
* Retrieves the is-th stored Y singlet. |
| 1253 |
|
|
* @param it Singlet number, ranging from 0 to nclsx(). |
| 1254 |
|
|
*/ |
| 1255 |
|
|
TrkSinglet *TrkLevel2::GetSingletY(int is){ |
| 1256 |
|
|
|
| 1257 |
|
|
if(is >= this->nclsy()){ |
| 1258 |
|
|
cout << "** TrkLevel2 ** Singlet "<< is << "doen not exits! " << endl; |
| 1259 |
|
|
cout << " Stored y-singlets nclsy() = "<< this->nclsx() << endl; |
| 1260 |
|
|
return 0; |
| 1261 |
|
|
} |
| 1262 |
pam-fi |
1.21 |
if(!SingletY)return 0; |
| 1263 |
pam-fi |
1.6 |
TClonesArray &t = *(SingletY); |
| 1264 |
|
|
TrkSinglet *singlet = (TrkSinglet*)t[is]; |
| 1265 |
|
|
return singlet; |
| 1266 |
|
|
} |
| 1267 |
|
|
//-------------------------------------- |
| 1268 |
|
|
// |
| 1269 |
|
|
// |
| 1270 |
|
|
//-------------------------------------- |
| 1271 |
|
|
/** |
| 1272 |
mocchiut |
1.1 |
* Retrieves the it-th "physical" track, sorted by the method GetNTracks(). |
| 1273 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
| 1274 |
|
|
*/ |
| 1275 |
pam-fi |
1.10 |
|
| 1276 |
pam-fi |
1.8 |
TrkTrack *TrkLevel2::GetTrack(int it){ |
| 1277 |
|
|
|
| 1278 |
|
|
if(it >= this->GetNTracks()){ |
| 1279 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
| 1280 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
| 1281 |
|
|
return 0; |
| 1282 |
|
|
} |
| 1283 |
|
|
|
| 1284 |
|
|
TRefArray *sorted = GetTracks(); //TEMPORANEO |
| 1285 |
pam-fi |
1.21 |
if(!sorted)return 0; |
| 1286 |
pam-fi |
1.8 |
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1287 |
pam-fi |
1.21 |
sorted->Clear(); |
| 1288 |
|
|
delete sorted; |
| 1289 |
pam-fi |
1.8 |
return track; |
| 1290 |
mocchiut |
1.1 |
} |
| 1291 |
pam-fi |
1.6 |
/** |
| 1292 |
|
|
* Give the number of "physical" tracks, sorted by the method GetTracks(). |
| 1293 |
|
|
*/ |
| 1294 |
pam-fi |
1.5 |
Int_t TrkLevel2::GetNTracks(){ |
| 1295 |
pam-fi |
1.8 |
|
| 1296 |
|
|
Float_t ntot=0; |
| 1297 |
pam-fi |
1.21 |
if(!Track)return 0; |
| 1298 |
pam-fi |
1.8 |
TClonesArray &t = *Track; |
| 1299 |
mocchiut |
1.12 |
for(int i=0; i<ntrk(); i++) { |
| 1300 |
pam-fi |
1.8 |
if( ((TrkTrack *)t[i])->GetImageSeqNo() == -1 ) ntot+=1.; |
| 1301 |
|
|
else ntot+=0.5; |
| 1302 |
|
|
} |
| 1303 |
|
|
return (Int_t)ntot; |
| 1304 |
|
|
|
| 1305 |
pam-fi |
1.5 |
}; |
| 1306 |
mocchiut |
1.1 |
//-------------------------------------- |
| 1307 |
|
|
// |
| 1308 |
|
|
// |
| 1309 |
|
|
//-------------------------------------- |
| 1310 |
|
|
/** |
| 1311 |
|
|
* Retrieves (if present) the image of the it-th "physical" track, sorted by the method GetNTracks(). |
| 1312 |
|
|
* @param it Track number, ranging from 0 to GetNTracks(). |
| 1313 |
|
|
*/ |
| 1314 |
pam-fi |
1.8 |
TrkTrack *TrkLevel2::GetTrackImage(int it){ |
| 1315 |
|
|
|
| 1316 |
pam-fi |
1.21 |
if(it >= this->GetNTracks()){ |
| 1317 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not exits! " << endl; |
| 1318 |
|
|
cout << " Physical tracks GetNTracks() = "<< this->ntrk() << endl; |
| 1319 |
|
|
return 0; |
| 1320 |
|
|
} |
| 1321 |
pam-fi |
1.8 |
|
| 1322 |
pam-fi |
1.21 |
TRefArray* sorted = GetTracks(); //TEMPORANEO |
| 1323 |
|
|
if(!sorted)return 0; |
| 1324 |
|
|
TrkTrack *track = (TrkTrack*)sorted->At(it); |
| 1325 |
pam-fi |
1.8 |
|
| 1326 |
pam-fi |
1.21 |
if(!track->HasImage()){ |
| 1327 |
|
|
cout << "** TrkLevel2 ** Track "<< it << "does not have image! " << endl; |
| 1328 |
|
|
return 0; |
| 1329 |
|
|
} |
| 1330 |
|
|
if(!Track)return 0; |
| 1331 |
|
|
TrkTrack *image = (TrkTrack*)(*Track)[track->image]; |
| 1332 |
|
|
|
| 1333 |
|
|
sorted->Delete(); |
| 1334 |
|
|
delete sorted; |
| 1335 |
pam-fi |
1.8 |
|
| 1336 |
pam-fi |
1.21 |
return image; |
| 1337 |
pam-fi |
1.8 |
|
| 1338 |
mocchiut |
1.1 |
} |
| 1339 |
|
|
//-------------------------------------- |
| 1340 |
|
|
// |
| 1341 |
|
|
// |
| 1342 |
|
|
//-------------------------------------- |
| 1343 |
|
|
/** |
| 1344 |
|
|
* Loads the magnetic field. |
| 1345 |
|
|
* @param s Path of the magnetic-field files. |
| 1346 |
|
|
*/ |
| 1347 |
pam-fi |
1.16 |
void TrkLevel2::LoadField(TString path){ |
| 1348 |
|
|
// |
| 1349 |
pam-fi |
1.26 |
// strcpy(path_.path,path.Data()); |
| 1350 |
|
|
// path_.pathlen = path.Length(); |
| 1351 |
|
|
// path_.error = 0; |
| 1352 |
|
|
// readb_(); |
| 1353 |
|
|
|
| 1354 |
pam-fi |
1.33 |
TrkParams::SetTrackingMode(); |
| 1355 |
|
|
TrkParams::SetPrecisionFactor(); |
| 1356 |
|
|
TrkParams::SetStepMin(); |
| 1357 |
|
|
|
| 1358 |
pam-fi |
1.26 |
TrkParams::Set(path,1); |
| 1359 |
pam-fi |
1.28 |
TrkParams::Load(1); |
| 1360 |
pam-fi |
1.26 |
|
| 1361 |
pam-fi |
1.16 |
// |
| 1362 |
mocchiut |
1.1 |
}; |
| 1363 |
pam-fi |
1.33 |
// /** |
| 1364 |
|
|
// * Get BY (kGauss) |
| 1365 |
|
|
// * @param v (x,y,z) coordinates in cm |
| 1366 |
|
|
// */ |
| 1367 |
|
|
// float TrkLevel2::GetBX(float* v){ |
| 1368 |
|
|
// float b[3]; |
| 1369 |
|
|
// gufld_(v,b); |
| 1370 |
|
|
// return b[0]/10.; |
| 1371 |
|
|
// } |
| 1372 |
|
|
// /** |
| 1373 |
|
|
// * Get BY (kGauss) |
| 1374 |
|
|
// * @param v (x,y,z) coordinates in cm |
| 1375 |
|
|
// */ |
| 1376 |
|
|
// float TrkLevel2::GetBY(float* v){ |
| 1377 |
|
|
// float b[3]; |
| 1378 |
|
|
// gufld_(v,b); |
| 1379 |
|
|
// return b[1]/10.; |
| 1380 |
|
|
// } |
| 1381 |
|
|
// /** |
| 1382 |
|
|
// * Get BY (kGauss) |
| 1383 |
|
|
// * @param v (x,y,z) coordinates in cm |
| 1384 |
|
|
// */ |
| 1385 |
|
|
// float TrkLevel2::GetBZ(float* v){ |
| 1386 |
|
|
// float b[3]; |
| 1387 |
|
|
// gufld_(v,b); |
| 1388 |
|
|
// return b[2]/10.; |
| 1389 |
|
|
// } |
| 1390 |
mocchiut |
1.1 |
//-------------------------------------- |
| 1391 |
|
|
// |
| 1392 |
|
|
// |
| 1393 |
|
|
//-------------------------------------- |
| 1394 |
|
|
/** |
| 1395 |
pam-fi |
1.6 |
* Get tracker-plane (mechanical) z-coordinate |
| 1396 |
|
|
* @param plane_id plane index (1=TOP,2,3,4,5,6=BOTTOM) |
| 1397 |
|
|
*/ |
| 1398 |
|
|
Float_t TrkLevel2::GetZTrk(Int_t plane_id){ |
| 1399 |
|
|
switch(plane_id){ |
| 1400 |
|
|
case 1: return ZTRK1; |
| 1401 |
|
|
case 2: return ZTRK2; |
| 1402 |
|
|
case 3: return ZTRK3; |
| 1403 |
|
|
case 4: return ZTRK4; |
| 1404 |
|
|
case 5: return ZTRK5; |
| 1405 |
|
|
case 6: return ZTRK6; |
| 1406 |
|
|
default: return 0.; |
| 1407 |
|
|
}; |
| 1408 |
|
|
}; |
| 1409 |
|
|
//-------------------------------------- |
| 1410 |
|
|
// |
| 1411 |
|
|
// |
| 1412 |
|
|
//-------------------------------------- |
| 1413 |
|
|
/** |
| 1414 |
pam-fi |
1.2 |
* Trajectory default constructor. |
| 1415 |
|
|
* (By default is created with z-coordinates inside the tracking volume) |
| 1416 |
|
|
*/ |
| 1417 |
|
|
Trajectory::Trajectory(){ |
| 1418 |
|
|
npoint = 10; |
| 1419 |
|
|
x = new float[npoint]; |
| 1420 |
|
|
y = new float[npoint]; |
| 1421 |
|
|
z = new float[npoint]; |
| 1422 |
|
|
thx = new float[npoint]; |
| 1423 |
|
|
thy = new float[npoint]; |
| 1424 |
|
|
tl = new float[npoint]; |
| 1425 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
| 1426 |
pam-fi |
1.2 |
for(int i=0; i<npoint; i++){ |
| 1427 |
|
|
x[i] = 0; |
| 1428 |
|
|
y[i] = 0; |
| 1429 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
| 1430 |
pam-fi |
1.2 |
thx[i] = 0; |
| 1431 |
|
|
thy[i] = 0; |
| 1432 |
|
|
tl[i] = 0; |
| 1433 |
|
|
} |
| 1434 |
|
|
} |
| 1435 |
|
|
//-------------------------------------- |
| 1436 |
|
|
// |
| 1437 |
|
|
// |
| 1438 |
|
|
//-------------------------------------- |
| 1439 |
|
|
/** |
| 1440 |
mocchiut |
1.1 |
* Trajectory constructor. |
| 1441 |
pam-fi |
1.2 |
* (By default is created with z-coordinates inside the tracking volume) |
| 1442 |
mocchiut |
1.1 |
* \param n Number of points |
| 1443 |
|
|
*/ |
| 1444 |
|
|
Trajectory::Trajectory(int n){ |
| 1445 |
pam-fi |
1.2 |
if(n<=0){ |
| 1446 |
|
|
cout << "NB! Trajectory must have at least 1 point >>> created with 10 points" << endl; |
| 1447 |
|
|
n=10; |
| 1448 |
|
|
} |
| 1449 |
mocchiut |
1.1 |
npoint = n; |
| 1450 |
|
|
x = new float[npoint]; |
| 1451 |
|
|
y = new float[npoint]; |
| 1452 |
|
|
z = new float[npoint]; |
| 1453 |
pam-fi |
1.2 |
thx = new float[npoint]; |
| 1454 |
|
|
thy = new float[npoint]; |
| 1455 |
|
|
tl = new float[npoint]; |
| 1456 |
pam-fi |
1.6 |
float dz = ((ZTRK1)-(ZTRK6))/(npoint-1); |
| 1457 |
mocchiut |
1.1 |
for(int i=0; i<npoint; i++){ |
| 1458 |
pam-fi |
1.2 |
x[i] = 0; |
| 1459 |
mocchiut |
1.1 |
y[i] = 0; |
| 1460 |
pam-fi |
1.6 |
z[i] = (ZTRK1) - i*dz; |
| 1461 |
pam-fi |
1.2 |
thx[i] = 0; |
| 1462 |
|
|
thy[i] = 0; |
| 1463 |
|
|
tl[i] = 0; |
| 1464 |
mocchiut |
1.1 |
} |
| 1465 |
|
|
} |
| 1466 |
|
|
//-------------------------------------- |
| 1467 |
|
|
// |
| 1468 |
|
|
// |
| 1469 |
|
|
//-------------------------------------- |
| 1470 |
|
|
/** |
| 1471 |
|
|
* Trajectory constructor. |
| 1472 |
|
|
* \param n Number of points |
| 1473 |
|
|
* \param pz Pointer to float array, defining z coordinates |
| 1474 |
|
|
*/ |
| 1475 |
|
|
Trajectory::Trajectory(int n, float* zin){ |
| 1476 |
pam-fi |
1.2 |
npoint = 10; |
| 1477 |
|
|
if(n>0)npoint = n; |
| 1478 |
mocchiut |
1.1 |
x = new float[npoint]; |
| 1479 |
|
|
y = new float[npoint]; |
| 1480 |
|
|
z = new float[npoint]; |
| 1481 |
pam-fi |
1.2 |
thx = new float[npoint]; |
| 1482 |
|
|
thy = new float[npoint]; |
| 1483 |
|
|
tl = new float[npoint]; |
| 1484 |
|
|
int i=0; |
| 1485 |
|
|
do{ |
| 1486 |
pam-fi |
1.21 |
x[i] = 0; |
| 1487 |
|
|
y[i] = 0; |
| 1488 |
|
|
z[i] = zin[i]; |
| 1489 |
|
|
thx[i] = 0; |
| 1490 |
|
|
thy[i] = 0; |
| 1491 |
|
|
tl[i] = 0; |
| 1492 |
|
|
i++; |
| 1493 |
pam-fi |
1.2 |
}while(zin[i-1] > zin[i] && i < npoint); |
| 1494 |
|
|
npoint=i; |
| 1495 |
|
|
if(npoint != n)cout << "NB! Trajectory created with "<<npoint<<" points"<<endl; |
| 1496 |
mocchiut |
1.1 |
} |
| 1497 |
pam-fi |
1.21 |
void Trajectory::Delete(){ |
| 1498 |
|
|
|
| 1499 |
|
|
if(x) delete [] x; |
| 1500 |
|
|
if(y) delete [] y; |
| 1501 |
|
|
if(z) delete [] z; |
| 1502 |
|
|
if(thx) delete [] thx; |
| 1503 |
|
|
if(thy) delete [] thy; |
| 1504 |
|
|
if(tl) delete [] tl; |
| 1505 |
|
|
|
| 1506 |
|
|
} |
| 1507 |
mocchiut |
1.1 |
//-------------------------------------- |
| 1508 |
|
|
// |
| 1509 |
|
|
// |
| 1510 |
|
|
//-------------------------------------- |
| 1511 |
|
|
/** |
| 1512 |
|
|
* Dump the trajectory coordinates. |
| 1513 |
|
|
*/ |
| 1514 |
|
|
void Trajectory::Dump(){ |
| 1515 |
|
|
cout <<endl<< "Trajectory ========== "<<endl; |
| 1516 |
|
|
for (int i=0; i<npoint; i++){ |
| 1517 |
pam-fi |
1.2 |
cout << i <<" >> " << x[i] <<" "<< y[i] <<" "<< z[i] ; |
| 1518 |
|
|
cout <<" -- " << thx[i] <<" "<< thy[i] ; |
| 1519 |
|
|
cout <<" -- " << tl[i] << endl; |
| 1520 |
mocchiut |
1.1 |
}; |
| 1521 |
|
|
} |
| 1522 |
pam-fi |
1.2 |
//-------------------------------------- |
| 1523 |
|
|
// |
| 1524 |
|
|
// |
| 1525 |
|
|
//-------------------------------------- |
| 1526 |
|
|
/** |
| 1527 |
|
|
* Get trajectory length between two points |
| 1528 |
|
|
* @param ifirst first point (default 0) |
| 1529 |
|
|
* @param ilast last point (default npoint) |
| 1530 |
|
|
*/ |
| 1531 |
|
|
float Trajectory::GetLength(int ifirst, int ilast){ |
| 1532 |
|
|
if( ifirst<0 ) ifirst = 0; |
| 1533 |
|
|
if( ilast>=npoint) ilast = npoint-1; |
| 1534 |
|
|
float l=0; |
| 1535 |
|
|
for(int i=ifirst;i<=ilast;i++){ |
| 1536 |
|
|
l=l+tl[i]; |
| 1537 |
|
|
}; |
| 1538 |
|
|
if(z[ilast] > ZINI)l=l-tl[ilast]; |
| 1539 |
|
|
if(z[ifirst] < ZINI) l=l-tl[ifirst]; |
| 1540 |
|
|
|
| 1541 |
|
|
return l; |
| 1542 |
mocchiut |
1.1 |
|
| 1543 |
pam-fi |
1.2 |
} |
| 1544 |
pam-fi |
1.6 |
|
| 1545 |
pam-fi |
1.19 |
/** |
| 1546 |
|
|
* Evaluates the trajectory in the apparatus associated to the track. |
| 1547 |
|
|
* It integrates the equations of motion in the magnetic field. The magnetic field should be previously loaded ( by calling TrkLevel2::LoadField() ), otherwise an error message is returned. |
| 1548 |
|
|
* @param t pointer to an object of the class Trajectory, |
| 1549 |
|
|
* which z coordinates should be previously initialized by calling the proper constructor ( Trajectory::Trajectory(int n, float* zin) ). |
| 1550 |
|
|
* @return error flag. |
| 1551 |
|
|
*/ |
| 1552 |
|
|
int Trajectory::DoTrack2(float* al){ |
| 1553 |
|
|
|
| 1554 |
|
|
double *dxout = new double[npoint]; |
| 1555 |
|
|
double *dyout = new double[npoint]; |
| 1556 |
|
|
double *dthxout = new double[npoint]; |
| 1557 |
|
|
double *dthyout = new double[npoint]; |
| 1558 |
|
|
double *dtlout = new double[npoint]; |
| 1559 |
|
|
double *dzin = new double[npoint]; |
| 1560 |
|
|
double dal[5]; |
| 1561 |
|
|
|
| 1562 |
|
|
int ifail = 0; |
| 1563 |
|
|
|
| 1564 |
|
|
for (int i=0; i<5; i++) dal[i] = (double)al[i]; |
| 1565 |
|
|
for (int i=0; i<npoint; i++) dzin[i] = (double)z[i]; |
| 1566 |
|
|
|
| 1567 |
pam-fi |
1.26 |
TrkParams::Load(1); |
| 1568 |
|
|
if( !TrkParams::IsLoaded(1) ){ |
| 1569 |
|
|
cout << "int Trajectory::DoTrack2(float* al) --- ERROR --- m.field not loaded"<<endl; |
| 1570 |
|
|
return 0; |
| 1571 |
|
|
} |
| 1572 |
pam-fi |
1.19 |
dotrack2_(&(npoint),dzin,dxout,dyout,dthxout,dthyout,dtlout,dal,&ifail); |
| 1573 |
|
|
|
| 1574 |
|
|
for (int i=0; i<npoint; i++){ |
| 1575 |
|
|
x[i] = (float)*dxout++; |
| 1576 |
|
|
y[i] = (float)*dyout++; |
| 1577 |
|
|
thx[i] = (float)*dthxout++; |
| 1578 |
|
|
thy[i] = (float)*dthyout++; |
| 1579 |
|
|
tl[i] = (float)*dtlout++; |
| 1580 |
|
|
} |
| 1581 |
|
|
|
| 1582 |
|
|
return ifail; |
| 1583 |
|
|
}; |
| 1584 |
pam-fi |
1.10 |
|
| 1585 |
mocchiut |
1.1 |
ClassImp(TrkLevel2); |
| 1586 |
|
|
ClassImp(TrkSinglet); |
| 1587 |
|
|
ClassImp(TrkTrack); |
| 1588 |
|
|
ClassImp(Trajectory); |