| 5 |
#include <TrkLevel1.h> |
#include <TrkLevel1.h> |
| 6 |
#include <iostream> |
#include <iostream> |
| 7 |
using namespace std; |
using namespace std; |
| 8 |
|
//...................................... |
| 9 |
|
// F77 routines |
| 10 |
|
//...................................... |
| 11 |
|
extern "C" { |
| 12 |
|
|
| 13 |
|
// int readetaparam_(); |
| 14 |
|
float cog_(int*,int*); |
| 15 |
|
float pfaeta_(int*,float*); |
| 16 |
|
float pfaeta2_(int*,float*); |
| 17 |
|
float pfaeta3_(int*,float*); |
| 18 |
|
float pfaeta4_(int*,float*); |
| 19 |
|
|
| 20 |
|
} |
| 21 |
//-------------------------------------- |
//-------------------------------------- |
| 22 |
// |
// |
| 23 |
// |
// |
| 74 |
// |
// |
| 75 |
//-------------------------------------- |
//-------------------------------------- |
| 76 |
/** |
/** |
| 77 |
* Evaluate the cluster signal. |
* Evaluate the cluster signal including all adjacent strip with a significant signal ( s > cut*sigma ). |
| 78 |
* @param cut Inclusion cut. |
* @param cut Inclusion cut. |
| 79 |
*/ |
*/ |
| 80 |
Float_t TrkCluster::GetSignal(Float_t cut){ |
Float_t TrkCluster::GetSignal(Float_t cut){ |
| 86 |
return s; |
return s; |
| 87 |
}; |
}; |
| 88 |
/** |
/** |
| 89 |
* Evaluate the cluster signal-to-noise, as defined by Turchetta. |
* Evaluate the cluster signal including a ( maximum ) fixed number of adjacent strips (with s>0) around the maxs. |
| 90 |
|
* @param nstrip Number of strips. |
| 91 |
|
*/ |
| 92 |
|
Float_t TrkCluster::GetSignal(Int_t nstrip){ |
| 93 |
|
|
| 94 |
|
Float_t s = 0; |
| 95 |
|
Int_t il = indmax; |
| 96 |
|
Int_t ir = indmax; |
| 97 |
|
Int_t inc = 0; |
| 98 |
|
|
| 99 |
|
while ( inc<nstrip ){ |
| 100 |
|
Float_t sl = 0; |
| 101 |
|
Float_t sr = 0; |
| 102 |
|
if( il >= 0 ) sl = clsignal[il]; |
| 103 |
|
if( ir < CLlength ) sr = clsignal[ir]; |
| 104 |
|
if( sl == sr && inc == 0 ){ |
| 105 |
|
s += clsignal[il]; |
| 106 |
|
il--; |
| 107 |
|
ir++; |
| 108 |
|
}else if ( sl >= sr && sl>0 && inc !=0){ |
| 109 |
|
s += sl; |
| 110 |
|
il--; |
| 111 |
|
}else if ( sl < sr && sr>0 ){ |
| 112 |
|
s += sr; |
| 113 |
|
ir++; |
| 114 |
|
}else break; |
| 115 |
|
|
| 116 |
|
inc++; |
| 117 |
|
} |
| 118 |
|
return s; |
| 119 |
|
}; |
| 120 |
|
/** |
| 121 |
|
* Evaluate the cluster signal-to-noise, as defined by Turchetta, including all adjacent strip with a significant signal ( s > cut*sigma ). |
| 122 |
* @param cut Inclusion cut. |
* @param cut Inclusion cut. |
| 123 |
*/ |
*/ |
| 124 |
Float_t TrkCluster::GetSignalToNoise(Float_t cut){ |
Float_t TrkCluster::GetSignalToNoise(Float_t cut){ |
| 130 |
return sn; |
return sn; |
| 131 |
}; |
}; |
| 132 |
/** |
/** |
| 133 |
|
* Evaluate the cluster signal-to-noise, as defined by Turchetta, including a ( maximum ) fixed number of adjacent strips (with s>0) around the maxs. |
| 134 |
|
* @param nstrip Number of strips. |
| 135 |
|
*/ |
| 136 |
|
Float_t TrkCluster::GetSignalToNoise(Int_t nstrip){ |
| 137 |
|
|
| 138 |
|
Float_t sn = 0; |
| 139 |
|
Int_t il = indmax; |
| 140 |
|
Int_t ir = indmax; |
| 141 |
|
Int_t inc = 0; |
| 142 |
|
|
| 143 |
|
while ( inc<nstrip ){ |
| 144 |
|
Float_t sl = 0; |
| 145 |
|
Float_t sr = 0; |
| 146 |
|
if( il >= 0 ) sl = clsignal[il]; |
| 147 |
|
if( ir < CLlength ) sr = clsignal[ir]; |
| 148 |
|
if( sl == sr && inc == 0 ){ |
| 149 |
|
sn += clsignal[il]/clsigma[is]; |
| 150 |
|
il--; |
| 151 |
|
ir++; |
| 152 |
|
}else if ( sl >= sr && sl>0 && inc !=0){ |
| 153 |
|
sn += sl/clsigma[il]; |
| 154 |
|
il--; |
| 155 |
|
}else if ( sl < sr && sr>0 ){ |
| 156 |
|
sn += sr/clsigma[ir]; |
| 157 |
|
ir++; |
| 158 |
|
}else break; |
| 159 |
|
|
| 160 |
|
inc++; |
| 161 |
|
} |
| 162 |
|
return sn; |
| 163 |
|
}; |
| 164 |
|
/** |
| 165 |
* Evaluate the cluster multiplicity. |
* Evaluate the cluster multiplicity. |
| 166 |
* @param cut Inclusion cut. |
* @param cut Inclusion cut. |
| 167 |
*/ |
*/ |
| 239 |
// |
// |
| 240 |
// |
// |
| 241 |
//-------------------------------------- |
//-------------------------------------- |
| 242 |
|
/** |
| 243 |
|
* Method to fill a level1 struct with only one cluster (done to use F77 p.f.a. routines on a cluster basis). |
| 244 |
|
*/ |
| 245 |
|
cTrkLevel1* TrkCluster::GetLevel1Struct(){ |
| 246 |
|
|
| 247 |
|
cTrkLevel1* l1 = new cTrkLevel1; |
| 248 |
|
|
| 249 |
|
l1->nclstr1 = 1; |
| 250 |
|
l1->view[0] = view; |
| 251 |
|
l1->ladder[0] = GetLadder(); |
| 252 |
|
l1->maxs[0] = maxs; |
| 253 |
|
l1->mult[0] = GetMultiplicity(); |
| 254 |
|
l1->dedx[0] = GetSignal(); |
| 255 |
|
l1->indstart[0] = 1; |
| 256 |
|
l1->indmax[0] = indmax+1; |
| 257 |
|
l1->totCLlength = CLlength; |
| 258 |
|
for(Int_t i=0; i<CLlength; i++){ |
| 259 |
|
l1->clsignal[i] = clsignal[i]; |
| 260 |
|
l1->clsigma[i] = clsigma[i]; |
| 261 |
|
l1->cladc[i] = cladc[i]; |
| 262 |
|
l1->clbad[i] = clbad[i]; |
| 263 |
|
}; |
| 264 |
|
|
| 265 |
|
return l1; |
| 266 |
|
}; |
| 267 |
|
//-------------------------------------- |
| 268 |
|
// |
| 269 |
|
// |
| 270 |
|
//-------------------------------------- |
| 271 |
|
/** |
| 272 |
|
* Evaluates the Center-Of-Gravity (COG) of the cluster, in strips, relative to the strip with the maximum signal (TrkCluster::maxs). |
| 273 |
|
* @param ncog Number of strips to evaluate COG. |
| 274 |
|
* If ncog=0, the COG of the cluster is evaluated according to the cluster multiplicity (defined by the inclusion cut). |
| 275 |
|
* If ncog>0, the COG is evaluated using ncog strips, even if they have a negative signal (according to G.Landi) |
| 276 |
|
*/ |
| 277 |
|
Float_t TrkCluster::GetCOG(Int_t ncog){ |
| 278 |
|
|
| 279 |
|
int ic = 1; |
| 280 |
|
level1event_ = *GetLevel1Struct(); |
| 281 |
|
return cog_(&ncog,&ic); |
| 282 |
|
|
| 283 |
|
}; |
| 284 |
|
//-------------------------------------- |
| 285 |
|
// |
| 286 |
|
// |
| 287 |
|
//-------------------------------------- |
| 288 |
|
/** |
| 289 |
|
* Evaluates the cluster position, in strips, relative to the strip with the maximum signal (TrkCluster::maxs), by applying the non-linear ETA-algorythm. |
| 290 |
|
* @param neta Number of strips to evaluate ETA. |
| 291 |
|
* @param angle Projected angle between particle track and detector plane. |
| 292 |
|
* Implemented values of neta are 2,3,4. If neta=0, ETA2, ETA3 and ETA4 are applied according to the angle. |
| 293 |
|
*/ |
| 294 |
|
Float_t TrkCluster::GetETA(Int_t neta, float angle){ |
| 295 |
|
|
| 296 |
|
// LoadPfaParam(); |
| 297 |
|
int ic = 1; |
| 298 |
|
level1event_ = *GetLevel1Struct(); |
| 299 |
|
if(neta == 0) return pfaeta_(&ic,&angle); |
| 300 |
|
else if(neta == 2) return pfaeta2_(&ic,&angle); |
| 301 |
|
else if(neta == 3) return pfaeta3_(&ic,&angle); |
| 302 |
|
else if(neta == 4) return pfaeta4_(&ic,&angle); |
| 303 |
|
else cout << "ETA"<<neta<<" not implemented\n"; |
| 304 |
|
return 0; |
| 305 |
|
|
| 306 |
|
}; |
| 307 |
|
|
| 308 |
|
//-------------------------------------- |
| 309 |
|
// |
| 310 |
|
// |
| 311 |
|
//-------------------------------------- |
| 312 |
TrkLevel1::TrkLevel1(){ |
TrkLevel1::TrkLevel1(){ |
| 313 |
|
|
| 314 |
// good1 = -1; |
// good1 = -1; |
| 395 |
* Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common). |
* Fills a struct cTrkLevel1 with values from a TrkLevel1 object (to put data into a F77 common). |
| 396 |
*/ |
*/ |
| 397 |
|
|
| 398 |
void TrkLevel1::GetLevel1Struct(cTrkLevel1 *l1) const { |
cTrkLevel1* TrkLevel1::GetLevel1Struct() { |
| 399 |
|
|
| 400 |
// ********* completare ********* // |
cTrkLevel1 *l1=0; |
| 401 |
// ********* completare ********* // |
// |
|
// ********* completare ********* // |
|
|
// ********* completare ********* // |
|
|
// ********* completare ********* // |
|
|
// ********* completare ********* // |
|
|
// general variables |
|
|
// l1->good1 = good1; |
|
| 402 |
for(Int_t i=0; i<12 ; i++){ |
for(Int_t i=0; i<12 ; i++){ |
| 403 |
// l1->crc[i] = crc[i]; |
l1->good[i] = good[i]; |
| 404 |
for(Int_t j=0; j<24 ; j++){ |
for(Int_t j=0; j<24 ; j++){ |
| 405 |
l1->cnev[j][i] = cnev[j][i]; |
l1->cnev[j][i] = cnev[j][i]; |
| 406 |
l1->cnnev[j][i] = cnnev[j][i]; |
l1->cnnev[j][i] = cnnev[j][i]; |
| 407 |
}; |
}; |
|
// l1->fshower[i] = fshower[i]; |
|
| 408 |
}; |
}; |
| 409 |
|
|
| 410 |
// *** CLUSTERS *** |
// *** CLUSTERS *** |
| 412 |
for(Int_t i=0;i<l1->nclstr1;i++){ |
for(Int_t i=0;i<l1->nclstr1;i++){ |
| 413 |
|
|
| 414 |
l1->view[i] = ((TrkCluster *)Cluster->At(i))->view; |
l1->view[i] = ((TrkCluster *)Cluster->At(i))->view; |
|
// l1->ladder[i] = ((TrkCluster *)Cluster->At(i))->ladder; |
|
| 415 |
l1->maxs[i] = ((TrkCluster *)Cluster->At(i))->maxs; |
l1->maxs[i] = ((TrkCluster *)Cluster->At(i))->maxs; |
| 416 |
// l1->mult[i] = ((TrkCluster *)Cluster->At(i))->mult; |
// COMPLETARE // |
| 417 |
// l1->dedx[i] = ((TrkCluster *)Cluster->At(i))->sgnl; |
// COMPLETARE // |
| 418 |
|
// COMPLETARE // |
| 419 |
|
// COMPLETARE // |
| 420 |
|
// COMPLETARE // |
| 421 |
|
// COMPLETARE // |
| 422 |
|
|
| 423 |
} |
} |
| 424 |
|
// COMPLETARE // |
| 425 |
// ********* completare ********* // |
// COMPLETARE // |
| 426 |
|
// COMPLETARE // |
| 427 |
|
// COMPLETARE // |
| 428 |
|
// COMPLETARE // |
| 429 |
|
// COMPLETARE // |
| 430 |
|
return l1; |
| 431 |
} |
} |
| 432 |
//-------------------------------------- |
//-------------------------------------- |
| 433 |
// |
// |
| 450 |
// |
// |
| 451 |
// |
// |
| 452 |
//-------------------------------------- |
//-------------------------------------- |
| 453 |
|
void TrkLevel1::Delete(){ |
| 454 |
|
|
| 455 |
|
for(Int_t i=0; i<12 ; i++){ |
| 456 |
|
good[i] = -1; |
| 457 |
|
for(Int_t j=0; j<24 ; j++){ |
| 458 |
|
cnev[j][i] = 0; |
| 459 |
|
cnnev[j][i] = 0; |
| 460 |
|
}; |
| 461 |
|
}; |
| 462 |
|
// |
| 463 |
|
Cluster->Delete(); |
| 464 |
|
|
| 465 |
|
} |
| 466 |
|
|
| 467 |
|
//-------------------------------------- |
| 468 |
|
// |
| 469 |
|
// |
| 470 |
|
//-------------------------------------- |
| 471 |
TrkCluster *TrkLevel1::GetCluster(int is){ |
TrkCluster *TrkLevel1::GetCluster(int is){ |
| 472 |
|
|
| 473 |
if(is >= this->nclstr()){ |
if(is >= this->nclstr()){ |
| 479 |
TrkCluster *cluster = (TrkCluster*)t[is]; |
TrkCluster *cluster = (TrkCluster*)t[is]; |
| 480 |
return cluster; |
return cluster; |
| 481 |
} |
} |
| 482 |
|
//-------------------------------------- |
| 483 |
|
// |
| 484 |
|
// |
| 485 |
|
//-------------------------------------- |
| 486 |
|
/** |
| 487 |
|
* Load Position-Finding-Algorythm parameters (call the F77 routine). |
| 488 |
|
* |
| 489 |
|
*/ |
| 490 |
|
int TrkLevel1::LoadPfaParam(TString path){ |
| 491 |
|
|
| 492 |
|
if( strcmp(path_.path,path.Data()) ){ |
| 493 |
|
cout <<"Loading p.f.a. parameters\n"; |
| 494 |
|
strcpy(path_.path,path.Data()); |
| 495 |
|
path_.pathlen = path.Length(); |
| 496 |
|
path_.error = 0; |
| 497 |
|
return readetaparam_(); |
| 498 |
|
} |
| 499 |
|
return 0; |
| 500 |
|
} |
| 501 |
|
|
| 502 |
|
|
| 503 |
ClassImp(TrkLevel1); |
ClassImp(TrkLevel1); |