| 1 |
/** |
| 2 |
* \file ExtTrkingAlg.cpp |
| 3 |
* \author Elena Vannuccini |
| 4 |
**/ |
| 5 |
#include <ExtTrkingAlg.h> |
| 6 |
#include <iostream> |
| 7 |
#include <math.h> |
| 8 |
|
| 9 |
using namespace std; |
| 10 |
/** |
| 11 |
* Constructor |
| 12 |
* |
| 13 |
* @param id Algorythm identifier |
| 14 |
* |
| 15 |
* id = 0 The algorythm looks for tracks with >= 3x2y hits on the tracker plane. |
| 16 |
* It fills a TClonesArray of TrkTrack objects. |
| 17 |
* id = 1 The first plane (y) of the calorimeter is also used. |
| 18 |
* It fills a TClonesArray of ExtTrack objects. |
| 19 |
* id = 2 The first two planes (y+x) of the calorimeter are also used. |
| 20 |
* It fills a TClonesArray of ExtTrack objects. |
| 21 |
* |
| 22 |
*/ |
| 23 |
ExtTrkingAlg::ExtTrkingAlg(Int_t id){ |
| 24 |
|
| 25 |
_whichAlg = id; |
| 26 |
|
| 27 |
|
| 28 |
SetDebug(false); |
| 29 |
|
| 30 |
if(id == 0){ |
| 31 |
if(_debug){ |
| 32 |
cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl; |
| 33 |
// cout << "Creating array of TrkTrack objects "<<endl; |
| 34 |
cout << "WARNING!!! tracking not accurate!! bug not fixed yet... "<<endl; |
| 35 |
} |
| 36 |
_trkArray = new TClonesArray("TrkTrack"); |
| 37 |
// |
| 38 |
_sel_nClstrMAX = 20. ; // selection parameter: maximum number of cluster |
| 39 |
_sel_nPlaneXMIN = 3.; // selection parameter: minimum number of hit x-views |
| 40 |
_sel_nPlaneYMIN = 2.; // selection parameter: minimum number of hit y-views |
| 41 |
// |
| 42 |
_alg_nClFixX = 3.; // algorythm parameter: n.hits required on X view |
| 43 |
_alg_nClFixY = 2.; // algorythm parameter:n.hits required on Y view |
| 44 |
_alg_nTrackMAX = 400.; // algorythm parameter: maximum num. of track candidates |
| 45 |
_alg_nViewCal= 0; // ignored |
| 46 |
// _alg_nViewCalFix= 0; // ignored |
| 47 |
|
| 48 |
NEXTVIEWS = 12 +_alg_nViewCal; |
| 49 |
NEXTPLANES = 6 +_alg_nViewCal; |
| 50 |
_extTrack = NULL;//ignored |
| 51 |
_zMech = NULL;//ignored |
| 52 |
|
| 53 |
|
| 54 |
// }else if (id == 1 ){ |
| 55 |
}else if ( (id >= 100 && id < 144) || |
| 56 |
(id >= 200 && id < 244) || |
| 57 |
false){ //add n calo planes |
| 58 |
if(_debug){ |
| 59 |
cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl; |
| 60 |
// cout << "Creating array of ExtTrack objects "<<endl; |
| 61 |
} |
| 62 |
_trkArray = new TClonesArray("ExtTrack"); |
| 63 |
// |
| 64 |
_alg_nClFixX = 3.; // algorythm parameter: n.hits required on X view |
| 65 |
_alg_nClFixY = 2.; // algorythm parameter:n.hits required on Y view |
| 66 |
_alg_nTrackMAX = 1000.; // algorythm parameter: maximum num. of track candidates |
| 67 |
// _alg_nViewCal = 1; // algorythm parameter: n.calorimeter planes included |
| 68 |
//_alg_nViewCal = 1; // algorythm parameter: n.calorimeter planes included |
| 69 |
|
| 70 |
if((int)(id/100)==1)_alg_nViewCal = id - 100; // algorythm parameter: n.calorimeter planes included |
| 71 |
if((int)(id/200)==1)_alg_nViewCal = id - 200; // algorythm parameter: n.calorimeter planes included |
| 72 |
|
| 73 |
// |
| 74 |
_sel_nClstrMAX = 15.;//10. ; // selection parameter: maximum number of cluster |
| 75 |
_sel_nPlaneXMIN = (_alg_nViewCal ? 2 : 3); // selection parameter: minimum number of hit x-views |
| 76 |
_sel_nPlaneYMIN = 2 - (int)(_alg_nViewCal+1)/2 ; // selection parameter: minimum number of hit y-views |
| 77 |
|
| 78 |
NEXTVIEWS = 12 +_alg_nViewCal; |
| 79 |
NEXTPLANES = 6 +_alg_nViewCal; |
| 80 |
_extTrack = new ExtTrack(NEXTPLANES); |
| 81 |
_zMech = new float[NEXTPLANES]; |
| 82 |
|
| 83 |
// ----------------------------------- |
| 84 |
// set Z-coord of tracker planes |
| 85 |
// ----------------------------------- |
| 86 |
_zMech[0]=ZTRK1; |
| 87 |
_zMech[1]=ZTRK2; |
| 88 |
_zMech[2]=ZTRK3; |
| 89 |
_zMech[3]=ZTRK4; |
| 90 |
_zMech[4]=ZTRK5; |
| 91 |
_zMech[5]=ZTRK6; |
| 92 |
// _extTrack->SetZ(0,ZTRK1); |
| 93 |
// _extTrack->SetZ(1,ZTRK2); |
| 94 |
// _extTrack->SetZ(2,ZTRK3); |
| 95 |
// _extTrack->SetZ(3,ZTRK4); |
| 96 |
// _extTrack->SetZ(4,ZTRK5); |
| 97 |
// _extTrack->SetZ(5,ZTRK6); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
_caloStripRoto.clear(); |
| 102 |
for(int iv=0; iv<_alg_nViewCal; iv++){ //loop over calorimater tracking planes |
| 103 |
for(int is=0; is<9; is++){ //loop over calorimeter sensors |
| 104 |
CaloStripRoto s(1-iv%2, (int)(iv/2), is, false);//flight 0-order align |
| 105 |
s.ResetAligParams();//reset 1-order align parameters |
| 106 |
_caloStripRoto.push_back(s) ; |
| 107 |
} |
| 108 |
} |
| 109 |
//------------------------------------------ |
| 110 |
// read alignment parameters |
| 111 |
//------------------------------------------ |
| 112 |
// printf("qui debug : %i \n",_debug); |
| 113 |
if(_debug) cout << "Reading calorimeter alignment parameters"<<endl; |
| 114 |
const char *pamca = gSystem->Getenv("PAM_CALIB"); |
| 115 |
TString filep = "/trk-param/align_param_calo-0/CaloAlignParams.txt"; |
| 116 |
filep.Prepend(pamca); |
| 117 |
|
| 118 |
if(_debug)cout << " ---> "<<filep.Data()<<endl; |
| 119 |
std::fstream fs; |
| 120 |
fs.open (filep.Data(), std::fstream::in ); |
| 121 |
|
| 122 |
if(!fs.is_open()){ |
| 123 |
|
| 124 |
cout <<" WARNING!!!!!!!!!!!! error opening file "<<filep.Data()<<endl; |
| 125 |
cout <<" No alignment parameters loaded "<<endl; |
| 126 |
} |
| 127 |
// do{ |
| 128 |
while(fs.is_open() && !fs.eof()){ |
| 129 |
|
| 130 |
int view,plane,sensor; |
| 131 |
float par[5],err[5]; |
| 132 |
fs>>view >> plane>> sensor; |
| 133 |
for(int i=0; i<5; i++)fs>>par[i]>>err[i]; |
| 134 |
|
| 135 |
|
| 136 |
if(plane*2+1-view<_alg_nViewCal){ |
| 137 |
|
| 138 |
|
| 139 |
int index = (plane*2+1-view)*9 + sensor; |
| 140 |
if(_debug){ |
| 141 |
cout<<index<<" >> "; |
| 142 |
cout<<view << " "<<plane<<" "<<sensor<<" "; |
| 143 |
for(int i=0; i<5; i++)cout<<setw(10)<<par[i]<<" "<<setw(10)<<err[i]<<" "; |
| 144 |
cout<<endl; |
| 145 |
} |
| 146 |
|
| 147 |
_caloStripRoto[index].SetAligParams__fPitch(par[0]); |
| 148 |
_caloStripRoto[index].SetAligParams__shift(par+1); |
| 149 |
_caloStripRoto[index].SetAligParams__alpha(par[4]); |
| 150 |
// _caloStripRoto[index].SetSiSensor(sensor); |
| 151 |
// _caloStripRoto[index].SetView(view); |
| 152 |
// _caloStripRoto[index].SetPlane(plane); |
| 153 |
|
| 154 |
}; |
| 155 |
// }while(!fs.eof()); |
| 156 |
}; |
| 157 |
fs.close(); |
| 158 |
|
| 159 |
// ----------------------------------- |
| 160 |
// set Z-coord of calorimeter planes |
| 161 |
// ----------------------------------- |
| 162 |
for(int plane=0; plane<22; plane++){ |
| 163 |
for(int view=1; view>=0; view--){ |
| 164 |
int strip = 0; |
| 165 |
CaloStrip st = CaloStrip(false);//flight align |
| 166 |
st.Set(view,plane,strip); |
| 167 |
int index = 2*plane + !view; |
| 168 |
if(index >= _alg_nViewCal)break; |
| 169 |
// _extTrack->SetZ(6+index,st.GetZ()); |
| 170 |
_zMech[6+index]=st.GetZ(); |
| 171 |
} |
| 172 |
} |
| 173 |
|
| 174 |
for(int ip =0 ; ip<_extTrack->nplanes; ip++ )_extTrack->SetZ(ip,_zMech[ip]); |
| 175 |
|
| 176 |
if ( _debug ){ |
| 177 |
cout <<" Extended-track Z-coordinates: "<<endl; |
| 178 |
for(int ip =0 ; ip<_extTrack->nplanes; ip++ )cout << _extTrack->zm[ip]<<endl; |
| 179 |
} |
| 180 |
}else{ |
| 181 |
if ( _debug ){ |
| 182 |
cout << "ExtTrkingAlg(Int_t id) -- algorythm id="<<id<<" not valid "<<endl; |
| 183 |
cout << "--> Track array not created "<<endl; |
| 184 |
} |
| 185 |
_sel_nClstrMAX = 0.; |
| 186 |
_sel_nPlaneXMIN = 0.; |
| 187 |
_sel_nPlaneYMIN = 0.; |
| 188 |
// |
| 189 |
_alg_nClFixX = 0.; |
| 190 |
_alg_nClFixY = 0.; |
| 191 |
_alg_nTrackMAX = 0.; |
| 192 |
_alg_nViewCal = 0; |
| 193 |
// _alg_nViewCalFix= 0; |
| 194 |
|
| 195 |
NEXTVIEWS = 12 +_alg_nViewCal; |
| 196 |
NEXTPLANES = 6 +_alg_nViewCal; |
| 197 |
_extTrack = NULL;//ignored |
| 198 |
|
| 199 |
} |
| 200 |
|
| 201 |
CaloStrip st = CaloStrip(false); |
| 202 |
for(int view=0; view<2; view++){ |
| 203 |
for(int plane=0; plane<22; plane++){ |
| 204 |
for(int strip=0; strip<96; strip++){ |
| 205 |
st.Set(view,plane,strip); |
| 206 |
_caloCoord[view][plane][strip]=(view ? st.GetY() : st.GetX()); |
| 207 |
_caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
_caloTj = new Trajectory(44,_caloZ); |
| 212 |
// _caloTj->Dump(); |
| 213 |
|
| 214 |
int ngf = TrkParams::nGF; |
| 215 |
float *zgf = TrkParams::zGF; |
| 216 |
_tgf = new Trajectory(ngf,zgf); |
| 217 |
// _tgf->Dump(); |
| 218 |
|
| 219 |
Clear(); |
| 220 |
|
| 221 |
}; |
| 222 |
|
| 223 |
/** |
| 224 |
* Reset the algorythm flags and output |
| 225 |
*/ |
| 226 |
// void ExtTrkingAlg::Reset(){ |
| 227 |
|
| 228 |
// if(_trkArray)_trkArray->Clear("C"); |
| 229 |
|
| 230 |
// }; |
| 231 |
|
| 232 |
/** |
| 233 |
* Clear the event and reset the algorythm |
| 234 |
*/ |
| 235 |
void ExtTrkingAlg::Clear(Option_t* option){ |
| 236 |
|
| 237 |
SetTrkLevel1(); |
| 238 |
SetTrkLevel2(); |
| 239 |
|
| 240 |
SetToFLevel2(); |
| 241 |
|
| 242 |
SetCaloLevel1(); |
| 243 |
SetCaloLevel2(); |
| 244 |
|
| 245 |
if(_trkArray)_trkArray->Clear("C"); |
| 246 |
|
| 247 |
}; |
| 248 |
/** |
| 249 |
* DElete all |
| 250 |
*/ |
| 251 |
|
| 252 |
void ExtTrkingAlg::Delete(){ |
| 253 |
if(_trkArray) delete _trkArray; |
| 254 |
if(_caloTj) delete _caloTj; |
| 255 |
if(_tgf) delete _tgf; |
| 256 |
if(_zMech)delete [] _zMech; |
| 257 |
} |
| 258 |
|
| 259 |
|
| 260 |
/** |
| 261 |
* Set selection parameters |
| 262 |
*/ |
| 263 |
void ExtTrkingAlg::SetSelectionParams(double* par){ |
| 264 |
|
| 265 |
_sel_nClstrMAX = (Int_t)par[0]; // selection parameter: maximum number of cluster |
| 266 |
_sel_nPlaneXMIN = (Int_t)par[1]; // selection parameter: minimum number of hit x-views |
| 267 |
_sel_nPlaneYMIN = (Int_t)par[2]; // selection parameter: minimum number of hit y-views |
| 268 |
|
| 269 |
}; |
| 270 |
/** |
| 271 |
* Set algorythm parameters |
| 272 |
*/ |
| 273 |
void ExtTrkingAlg::SetAlgorythmParams(double* par){ |
| 274 |
|
| 275 |
_alg_nClFixX = (Int_t)par[0]; // algorythm parameter: n.hits required on X view |
| 276 |
_alg_nClFixY = (Int_t)par[1]; // algorythm parameter:n.hits required on X view |
| 277 |
_alg_nTrackMAX = (Int_t)par[2]; // algorythm parameter: maximum num. of track candidates |
| 278 |
_alg_nViewCal= (Int_t)par[3]; // algorythm parameter: n. calorimeter planes included |
| 279 |
// _alg_nViewCalFix= (Int_t)par[4]; // |
| 280 |
|
| 281 |
}; |
| 282 |
|
| 283 |
/** |
| 284 |
* Get the track array |
| 285 |
*/ |
| 286 |
TClonesArray* ExtTrkingAlg::GetTrackArray(Bool_t reset){ |
| 287 |
|
| 288 |
if( reset && _trkArray) _trkArray->Clear("C"); |
| 289 |
// if( !_procDone )ProcessEvent(); |
| 290 |
|
| 291 |
return _trkArray; |
| 292 |
|
| 293 |
}; |
| 294 |
/** |
| 295 |
* Pre-select the event |
| 296 |
*/ |
| 297 |
Bool_t ExtTrkingAlg::CheckEvent(){ |
| 298 |
|
| 299 |
if(!_trk_l1)return false; |
| 300 |
TrkLevel1 *trkl1 = _trk_l1;//event->GetTrkLevel1(); |
| 301 |
int nClstrMAX = _sel_nClstrMAX; //maximum number of cluster |
| 302 |
///////////////////////////////////////////////////////////////////// |
| 303 |
/// dump selection |
| 304 |
///////////////////////////////////////////////////////////////////// |
| 305 |
if(_debug){ |
| 306 |
cout << " n.clusters "<<trkl1->nclstr()<<endl; |
| 307 |
} |
| 308 |
if(trkl1->nclstr() > nClstrMAX) return false; |
| 309 |
///////////////////////////////////////////////////////////////////// |
| 310 |
/// count number of hit planes |
| 311 |
///////////////////////////////////////////////////////////////////// |
| 312 |
int nPlaneXMIN = _sel_nPlaneXMIN; |
| 313 |
int nPlaneYMIN = _sel_nPlaneYMIN; |
| 314 |
int nHitX[] = {0,0,0,0,0,0}; |
| 315 |
int nHitY[] = {0,0,0,0,0,0}; |
| 316 |
for(int ic=0; ic<trkl1->nclstr(); ic++){ |
| 317 |
if (trkl1->GetCluster(ic)->IsX() ) nHitX[trkl1->GetCluster(ic)->GetPlane()-1]++; |
| 318 |
else if (trkl1->GetCluster(ic)->IsY() ) nHitY[trkl1->GetCluster(ic)->GetPlane()-1]++; |
| 319 |
} |
| 320 |
///////////////////////////////////////////////////////////////////// |
| 321 |
/// set minimum condition 3x+2y |
| 322 |
///////////////////////////////////////////////////////////////////// |
| 323 |
int nPlaneX=0; |
| 324 |
for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++; |
| 325 |
int nPlaneY=0; |
| 326 |
for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++; |
| 327 |
|
| 328 |
///////////////////////////////////////////////////////////////////// |
| 329 |
/// dump selection |
| 330 |
///////////////////////////////////////////////////////////////////// |
| 331 |
if(_debug){ |
| 332 |
cout << " n.x-hit planes "<<nPlaneX<<endl; |
| 333 |
cout << " n.y-hit planes "<<nPlaneY<<endl; |
| 334 |
} |
| 335 |
if( nPlaneX<nPlaneXMIN ) return false; |
| 336 |
if( nPlaneY<nPlaneYMIN ) return false; |
| 337 |
|
| 338 |
|
| 339 |
// if(!_trk_l2)return true; |
| 340 |
// TrkLevel2 *trkl2 = _trk_l2;//event->GetTrkLevel2(); |
| 341 |
// ///////////////////////////////////////////////////////////////////// |
| 342 |
// /// dump selection |
| 343 |
// ///////////////////////////////////////////////////////////////////// |
| 344 |
// if(_debug){ |
| 345 |
// cout << " n.tracks "<<trkl2->GetNTracks()<<endl; |
| 346 |
// cout << " n.x-singles "<<trkl2->nclsx()<<endl; |
| 347 |
// cout << " n.y-singles "<<trkl2->nclsy()<<endl; |
| 348 |
// cout << " n.y-singles "<<trkl2->nclsy()<<endl; |
| 349 |
// } |
| 350 |
// if(trkl2->nclsy()+trkl2->nclsx() > nClstrMAX) return false; |
| 351 |
// ///////////////////////////////////////////////////////////////////// |
| 352 |
// /// count number of hit planes |
| 353 |
// ///////////////////////////////////////////////////////////////////// |
| 354 |
// int nPlaneXMIN = _sel_nPlaneXMIN; |
| 355 |
// int nPlaneYMIN = _sel_nPlaneYMIN; |
| 356 |
// int nHitX[] = {0,0,0,0,0,0}; |
| 357 |
// int nHitY[] = {0,0,0,0,0,0}; |
| 358 |
// for(int ix=0; ix<trkl2->nclsx(); ix++)nHitX[trkl2->GetSingletX(ix)->plane-1]++; |
| 359 |
// for(int iy=0; iy<trkl2->nclsy(); iy++)nHitY[trkl2->GetSingletY(iy)->plane-1]++; |
| 360 |
// ///////////////////////////////////////////////////////////////////// |
| 361 |
// /// set minimum condition 3x+2y |
| 362 |
// ///////////////////////////////////////////////////////////////////// |
| 363 |
// int nPlaneX=0; |
| 364 |
// for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++; |
| 365 |
// int nPlaneY=0; |
| 366 |
// for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++; |
| 367 |
// ///////////////////////////////////////////////////////////////////// |
| 368 |
// /// dump selection |
| 369 |
// ///////////////////////////////////////////////////////////////////// |
| 370 |
// if(_debug){ |
| 371 |
// cout << " n.x-planes with singles "<<nPlaneX<<endl; |
| 372 |
// cout << " n.y-planes with singles "<<nPlaneY<<endl; |
| 373 |
// } |
| 374 |
//////////////////////////////////////////////////////////////////////// |
| 375 |
// |
| 376 |
// check condition for retracking |
| 377 |
// |
| 378 |
//////////////////////////////////////////////////////////////////////// |
| 379 |
// if(trkl2->GetNTracks()==0 && nPlaneX<nPlaneXMIN) return false; |
| 380 |
// if(trkl2->GetNTracks()==0 && nPlaneY<nPlaneYMIN) return false; |
| 381 |
|
| 382 |
return true; |
| 383 |
|
| 384 |
}; |
| 385 |
|
| 386 |
|
| 387 |
/** |
| 388 |
* Process the event |
| 389 |
*/ |
| 390 |
void ExtTrkingAlg::ProcessEvent0(Bool_t force){ |
| 391 |
|
| 392 |
if(_debug)cout << " |---------------------------------------------------| "<<endl; |
| 393 |
if(_debug)cout << " void ExtTrkingAlg::ProcessEvent0("<<force<<") "<<endl; |
| 394 |
|
| 395 |
|
| 396 |
if(_debug && !_trk_l1)cout << " Missing TrkLevel1 object --- ciao! "<<endl; |
| 397 |
if(!_trk_l1)return; |
| 398 |
|
| 399 |
|
| 400 |
//=========================== |
| 401 |
// pre-selection |
| 402 |
//=========================== |
| 403 |
|
| 404 |
Bool_t RETRACK = CheckEvent(); |
| 405 |
|
| 406 |
if(_debug)cout <<" Pre-selection result: "<<RETRACK<<endl; |
| 407 |
if( !force && !RETRACK )return; |
| 408 |
|
| 409 |
|
| 410 |
//=========================== |
| 411 |
// tracking |
| 412 |
//=========================== |
| 413 |
|
| 414 |
// TClonesArray &tracks = *_trkArray; |
| 415 |
// tracks.Clear(); |
| 416 |
|
| 417 |
|
| 418 |
multimap<int,TrkTrack> trackCandidates[12]; // map: last filled view vs TrkTrack |
| 419 |
int mapIndex = 0; |
| 420 |
multimap<int,TrkTrack>::iterator trkBegin; |
| 421 |
multimap<int,TrkTrack>::iterator trkEnd; |
| 422 |
int iCand; |
| 423 |
|
| 424 |
// ------------------------------------------------ |
| 425 |
// fill a map VIEW(0-11)-CLUSTER |
| 426 |
// ------------------------------------------------ |
| 427 |
multimap<int,int> clusterMap; |
| 428 |
if(_debug)cout<<"-------- CLUSTERs --------"<<endl; |
| 429 |
for(int icl=0; icl<_trk_l1->nclstr(); icl++){ |
| 430 |
clusterMap.insert( pair<int,int>( _trk_l1->GetCluster(icl)->view-1, icl )); |
| 431 |
if(_debug)cout << icl << " - view "<<_trk_l1->GetCluster(icl)->view<<" ladder "<<_trk_l1->GetCluster(icl)->GetLadder()<<" strip "<<_trk_l1->GetCluster(icl)->maxs<<endl; |
| 432 |
} |
| 433 |
// ------------------------------------------------ |
| 434 |
// define iterators over clusters on the same view |
| 435 |
// ------------------------------------------------ |
| 436 |
pair <multimap<int,int>::iterator, multimap<int,int>::iterator> ret[12]; |
| 437 |
multimap<int,int>::iterator it[12]; |
| 438 |
for(int iv=0; iv<12; iv++)ret[iv] = clusterMap.equal_range(iv); |
| 439 |
|
| 440 |
//==================================================================== |
| 441 |
// PARAMETERS |
| 442 |
//==================================================================== |
| 443 |
// ------------------------------------------------ |
| 444 |
// number of points per candidate |
| 445 |
// ------------------------------------------------ |
| 446 |
int nClFixX = _alg_nClFixX; // n.hits required on X view |
| 447 |
int nClFixY = _alg_nClFixY; // n.hits required on X view |
| 448 |
int nTrackMAX = _alg_nTrackMAX; // |
| 449 |
//================================================== |
| 450 |
// ------------------------------------------------ |
| 451 |
// start: one candidate for each cluster |
| 452 |
// ------------------------------------------------ |
| 453 |
//================================================== |
| 454 |
if(_debug)cout<<"-------- MINIMAL --------"<<endl; |
| 455 |
for(int iv=0; iv<12; iv++){ //loop over all views |
| 456 |
|
| 457 |
if( !(iv%2) && (int)(0.5*iv) > 6-nClFixX)continue; |
| 458 |
if( (iv%2) && (int)(0.5*iv) > 6-nClFixY)continue; |
| 459 |
|
| 460 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 461 |
for (int is=0; is<2; is++){ //loop over sensors |
| 462 |
int icl = it[iv]->second; |
| 463 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 464 |
int ladder = cluster->GetLadder()-1; |
| 465 |
int plane = cluster->GetPlane()-1; |
| 466 |
bool isY = (cluster->view)%2; |
| 467 |
bool isX = !isY; |
| 468 |
// |
| 469 |
// if(_debug && isX )cout << " ^^^^^^^ X plane "<<plane<<" ladder "<<ladder<<" strip "<<cluster->maxs <<endl; |
| 470 |
// if(_debug && isY )cout << " ^^^^^^^ Y plane "<<plane<<" ladder "<<ladder<<" strip "<<cluster->maxs <<endl; |
| 471 |
|
| 472 |
TrkTrack t_track = TrkTrack(); |
| 473 |
|
| 474 |
if( isX )t_track.SetXGood(plane,icl+1,ladder,is); |
| 475 |
if( isY )t_track.SetYGood(plane,icl+1,ladder,is); |
| 476 |
|
| 477 |
trackCandidates[mapIndex].insert(pair<int,TrkTrack>(iv, TrkTrack(t_track))); |
| 478 |
|
| 479 |
} |
| 480 |
} |
| 481 |
}; |
| 482 |
|
| 483 |
//============================================================== |
| 484 |
// ------------------------------------------------------------- |
| 485 |
// next: add views to each candidate, up to nClFixX+nClFixY |
| 486 |
// ------------------------------------------------------------- |
| 487 |
//============================================================== |
| 488 |
for( ;mapIndex < nClFixX+nClFixY-1 ;++mapIndex){ |
| 489 |
|
| 490 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 491 |
trkEnd = trackCandidates[mapIndex].end(); |
| 492 |
if(_debug)cout<<"MAP "<<mapIndex<<" -----------"<<endl; |
| 493 |
|
| 494 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 495 |
|
| 496 |
TrkTrack trackCand = (*trkIter).second; |
| 497 |
int lastView = (*trkIter).first; //last inserted view |
| 498 |
int lastPlane = (int)(0.5*lastView); |
| 499 |
int lastLadder = trackCand.GetLadder(lastPlane); |
| 500 |
int lastSensor = trackCand.GetSensor(lastPlane); |
| 501 |
|
| 502 |
// if(_debug)cout<<"MAP "<<mapIndex<<" last v "<<lastView<<" NX "<<trackCand.GetNX()<<" NY "<<trackCand.GetNY()<<endl; |
| 503 |
|
| 504 |
for(int iv=lastView+1; iv<12; iv++){ //loop over next views |
| 505 |
|
| 506 |
if( (iv%2) && (int)(0.5*iv) > 6-nClFixX+trackCand.GetNX())continue; //not enough x-view left |
| 507 |
if( !(iv%2) && (int)(0.5*iv) > 6-nClFixY+trackCand.GetNY())continue; //not enough y-view left |
| 508 |
|
| 509 |
if( (iv%2) && trackCand.GetNX()==nClFixX )continue;//ok? |
| 510 |
if( !(iv%2) && trackCand.GetNY()==nClFixY )continue;//ok? |
| 511 |
|
| 512 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 513 |
|
| 514 |
int icl = it[iv]->second; |
| 515 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 516 |
int ladder = cluster->GetLadder()-1;//(_trk_l1->GetCluster(icl)->maxs-1)%1024 + 1; |
| 517 |
int plane = cluster->GetPlane()-1; |
| 518 |
bool isY = (cluster->view)%2; |
| 519 |
bool isX = !isY; |
| 520 |
|
| 521 |
if( plane==lastPlane && ladder!=lastLadder)continue; |
| 522 |
|
| 523 |
|
| 524 |
for (int is=0; is<2; is++){ //loop over sensors |
| 525 |
|
| 526 |
if( plane==lastPlane && is!=lastSensor)continue; |
| 527 |
|
| 528 |
// if(_debug)cout<<"MAP "<<mapIndex<<" last v "<<lastView; |
| 529 |
// if(_debug)cout<<" +cl "<<icl<<" s"<<is<<endl; |
| 530 |
|
| 531 |
TrkTrack t_track = TrkTrack(); |
| 532 |
trackCand.Copy(t_track); //copy the candidate parameters... |
| 533 |
|
| 534 |
if( isX )t_track.SetXGood(plane,icl+1,ladder,is); //...add a point... |
| 535 |
if( isY )t_track.SetYGood(plane,icl+1,ladder,is); |
| 536 |
|
| 537 |
trackCandidates[mapIndex+1].insert(pair<int,TrkTrack>(iv, TrkTrack(t_track))); //...and store a new candidate |
| 538 |
};//end loop over sensors |
| 539 |
};//end loop over clusters on the view iv |
| 540 |
};//endl loop over views |
| 541 |
}//end loop over candidates |
| 542 |
}//end iterations |
| 543 |
|
| 544 |
|
| 545 |
if( trackCandidates[mapIndex].size() > (uint)nTrackMAX ){ // EM, warning: comparison between signed and unsigned integer expressions [-Wsign-compare] |
| 546 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl; |
| 547 |
return;//to many candidates |
| 548 |
} |
| 549 |
if(_debug){ |
| 550 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 551 |
trkEnd = trackCandidates[mapIndex].end(); |
| 552 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 553 |
TrkTrack &trackCand = (*trkIter).second; |
| 554 |
cout << " >> "; |
| 555 |
cout << " X: "; |
| 556 |
for(int ip=0; ip<6; ip++) |
| 557 |
if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
| 558 |
cout << " Y: "; |
| 559 |
for(int ip=0; ip<6; ip++) |
| 560 |
if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
| 561 |
cout << endl; |
| 562 |
} |
| 563 |
} |
| 564 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 565 |
|
| 566 |
//============================================================== |
| 567 |
// ------------------------------------------------------------- |
| 568 |
// first selection of track candidates, based on chi2 |
| 569 |
// ------------------------------------------------------------- |
| 570 |
//============================================================== |
| 571 |
if(_debug)cout<<"-------- CHI2 --------"<<endl; |
| 572 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 573 |
trkEnd = trackCandidates[mapIndex].end(); |
| 574 |
mapIndex++; |
| 575 |
iCand = 0; |
| 576 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 577 |
int lastView = (*trkIter).first; |
| 578 |
TrkTrack &trackCand = (*trkIter).second; |
| 579 |
int ifail=0; |
| 580 |
trackCand.FitReset(); |
| 581 |
trackCand.Fit(0.,ifail,0,1);//re-evaluate cluster position from level1 |
| 582 |
if(ifail!=0)trackCand.FitReset(); |
| 583 |
|
| 584 |
// ----------------------------------- |
| 585 |
// first selection of track candidates |
| 586 |
// ----------------------------------- |
| 587 |
if(TMath::IsNaN(trackCand.chi2))continue; |
| 588 |
if(trackCand.chi2 <= 0. || trackCand.chi2 > 1.e7)continue; |
| 589 |
// if(trackCand.chi2 < 0. || trackCand.chi2 > 10. )continue; |
| 590 |
iCand++; |
| 591 |
|
| 592 |
if(_debug){ |
| 593 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 594 |
cout <<" | al: "; |
| 595 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 596 |
cout <<" | "; |
| 597 |
for(int ip=0; ip<6; ip++) |
| 598 |
if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
| 599 |
cout << " Y: "; |
| 600 |
for(int ip=0; ip<6; ip++) |
| 601 |
if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
| 602 |
} |
| 603 |
|
| 604 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 605 |
// evaluated coordinates (to define GF) |
| 606 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 607 |
int ngf = TrkParams::nGF; |
| 608 |
float *zgf = TrkParams::zGF; |
| 609 |
Trajectory tgf = Trajectory(ngf,zgf); |
| 610 |
tgf.DoTrack(trackCand.al);//<<<< integrate the trajectory |
| 611 |
for(int ip=0; ip<ngf; ip++){ |
| 612 |
trackCand.xGF[ip] = tgf.x[ip]; |
| 613 |
trackCand.yGF[ip] = tgf.y[ip]; |
| 614 |
} |
| 615 |
|
| 616 |
trackCandidates[mapIndex].insert(pair<int,TrkTrack>(lastView, TrkTrack(trackCand))); |
| 617 |
|
| 618 |
}; |
| 619 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 620 |
|
| 621 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 622 |
//================================================================= |
| 623 |
// ---------------------------------------------------------------- |
| 624 |
// CALORIMETER |
| 625 |
// ---------------------------------------------------------------- |
| 626 |
//================================================================= |
| 627 |
if(_cal_l1){ |
| 628 |
if(_debug)cout<<"-------- CALORIMETER --------"<<endl; |
| 629 |
// ----------------------------------- |
| 630 |
// evaluate calorimeter variables |
| 631 |
// ----------------------------------- |
| 632 |
// float caloCoord[2][22][96]; |
| 633 |
// float caloZ[44]; |
| 634 |
// for(int view=0; view<2; view++){ |
| 635 |
// for(int plane=0; plane<22; plane++){ |
| 636 |
// for(int strip=0; strip<96; strip++){ |
| 637 |
// CaloStrip st = CaloStrip(false); |
| 638 |
// st.Set(view,plane,strip); |
| 639 |
// caloCoord[view][plane][strip]=(view ? st.GetY() : st.GetX()); |
| 640 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 641 |
// } |
| 642 |
// } |
| 643 |
// } |
| 644 |
// Trajectory caloTj = Trajectory(44,caloZ); |
| 645 |
// for(int iz=0; iz<44;iz++)cout<<caloZ[iz]<<endl; |
| 646 |
//test calo |
| 647 |
// float caloEvent[2][22][96]; |
| 648 |
CaloLevel1* l1=_cal_l1;//event->GetCaloLevel1(); |
| 649 |
// if(!l1)return; |
| 650 |
vector<float> caloChi2; |
| 651 |
vector<int> caloHit; int caloHitMAX=0; |
| 652 |
vector<float> caloMip; |
| 653 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 654 |
trkEnd = trackCandidates[mapIndex].end(); |
| 655 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 656 |
TrkTrack trackCand = ((*trkIter).second); |
| 657 |
|
| 658 |
trackCand.DoTrack(_caloTj);//integrate the trajectory through the calorimeter |
| 659 |
|
| 660 |
float chi2 = 0.; |
| 661 |
int nhit = 0; |
| 662 |
float cmip = 0.; |
| 663 |
for(Int_t ih=0; ih<l1->istrip; ih++){ |
| 664 |
Int_t view = -1; |
| 665 |
Int_t plane = -1; |
| 666 |
Int_t strip = -1; |
| 667 |
Float_t mip = l1->DecodeEstrip(ih,view,plane,strip); |
| 668 |
if(view<0)continue; |
| 669 |
if(plane<0)continue; |
| 670 |
if(strip<0)continue; |
| 671 |
if(mip<=0)continue; |
| 672 |
float dxy = _caloCoord[view][plane][strip]-(view?_caloTj->y[plane*2+(view?0:1)]:_caloTj->x[plane*2+(view?0:1)]); |
| 673 |
if(plane<11) chi2+= mip * TMath::Power(dxy,2.); |
| 674 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 675 |
if( fabs(dxy) < 2. && plane<11)nhit++; |
| 676 |
if( fabs(dxy) < 2. && plane<11)cmip+=mip; |
| 677 |
}; |
| 678 |
if(l1->istrip>0)chi2 = chi2/l1->istrip; |
| 679 |
|
| 680 |
caloHit.push_back(nhit); |
| 681 |
if(nhit>caloHitMAX)caloHitMAX=nhit; |
| 682 |
|
| 683 |
if(_debug){ |
| 684 |
cout << " CALO "; |
| 685 |
// cout << " chi2 "<< chi2 <<" "; |
| 686 |
cout << " nhit (< 11th plane) "<< nhit <<" "; |
| 687 |
// cout << " mip "<< cmip <<" "; |
| 688 |
cout <<endl; |
| 689 |
}; |
| 690 |
} |
| 691 |
|
| 692 |
//================================================================= |
| 693 |
// ---------------------------------------------------------------- |
| 694 |
// selection of track candidates, based on n.calorimeter hits |
| 695 |
// ---------------------------------------------------------------- |
| 696 |
//================================================================= |
| 697 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 698 |
trkEnd = trackCandidates[mapIndex].end(); |
| 699 |
mapIndex++; |
| 700 |
iCand = 0; |
| 701 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 702 |
int lastView = (*trkIter).first; |
| 703 |
TrkTrack &trackCand = (*trkIter).second; |
| 704 |
if(caloHit[iCand]==caloHitMAX)trackCandidates[mapIndex].insert(pair<int,TrkTrack>(lastView, TrkTrack(trackCand))); |
| 705 |
iCand++; |
| 706 |
} |
| 707 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 708 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 709 |
|
| 710 |
} |
| 711 |
|
| 712 |
//================================================================= |
| 713 |
// ---------------------------------------------------------------- |
| 714 |
// TOF |
| 715 |
// ---------------------------------------------------------------- |
| 716 |
//================================================================= |
| 717 |
if(_tof_l2){ |
| 718 |
if(_debug)cout<<"-------- TOF --------"<<endl; |
| 719 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 720 |
trkEnd = trackCandidates[mapIndex].end(); |
| 721 |
ToFLevel2* tl2=_tof_l2;//event->GetToFLevel2(); |
| 722 |
// if(!tl2)return; |
| 723 |
iCand =0; |
| 724 |
vector<int> tofHit; int tofHitMAX=0; |
| 725 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 726 |
// int lastView = (*trkIter).first; |
| 727 |
TrkTrack &trackCand = (*trkIter).second; |
| 728 |
|
| 729 |
int nhit =0; |
| 730 |
for(int iToF=0; iToF<6; iToF++){ |
| 731 |
|
| 732 |
int iGF = iToF; |
| 733 |
if(iToF>3)iGF = iToF+8; |
| 734 |
int iPaddle = tl2->GetPaddleIdOfTrack( trackCand.xGF[iGF], trackCand.yGF[iGF], iToF); |
| 735 |
if( tl2->HitPaddle(iToF,iPaddle) )nhit++; |
| 736 |
|
| 737 |
} |
| 738 |
iCand++; |
| 739 |
|
| 740 |
tofHit.push_back(nhit); |
| 741 |
if(nhit>tofHitMAX)tofHitMAX=nhit; |
| 742 |
|
| 743 |
if(_debug){ |
| 744 |
cout << " TOF nhit "<< nhit <<" "; |
| 745 |
cout <<endl; |
| 746 |
} |
| 747 |
|
| 748 |
} |
| 749 |
//================================================================= |
| 750 |
// ---------------------------------------------------------------- |
| 751 |
// selection of track candidates, based on n.tof hits |
| 752 |
// ---------------------------------------------------------------- |
| 753 |
//================================================================= |
| 754 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 755 |
trkEnd = trackCandidates[mapIndex].end(); |
| 756 |
mapIndex++; |
| 757 |
iCand = 0; |
| 758 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 759 |
int lastView = (*trkIter).first; |
| 760 |
TrkTrack &trackCand = (*trkIter).second; |
| 761 |
if(tofHit[iCand]==tofHitMAX)trackCandidates[mapIndex].insert(pair<int,TrkTrack>(lastView, TrkTrack(trackCand))); |
| 762 |
iCand++; |
| 763 |
} |
| 764 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 765 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 766 |
|
| 767 |
} |
| 768 |
|
| 769 |
|
| 770 |
//================================================================= |
| 771 |
// ---------------------------------------------------------------- |
| 772 |
// TRACK MERGING |
| 773 |
// ---------------------------------------------------------------- |
| 774 |
//================================================================= |
| 775 |
if(_debug)cout<<"-------- MERGING --------"<<endl; |
| 776 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 777 |
trkEnd = trackCandidates[mapIndex].end(); |
| 778 |
mapIndex++; |
| 779 |
float chi2Min=1e10; |
| 780 |
iCand = 0; |
| 781 |
for( multimap<int,TrkTrack>::iterator trkIter1 = trkBegin; trkIter1!=trkEnd; ++trkIter1){ //loop over tracks (1) |
| 782 |
|
| 783 |
TrkTrack &trackCand1 = (*trkIter1).second;// get candidate 1... |
| 784 |
|
| 785 |
TrkTrack t_track = TrkTrack();// ...create a new TrkTrack instance... |
| 786 |
trackCand1.Copy(t_track); // ...and make a copy |
| 787 |
|
| 788 |
bool HBM = false; //has been merged |
| 789 |
|
| 790 |
for( multimap<int,TrkTrack>::iterator trkIter2 = trkBegin; trkIter2!=trkEnd; ++trkIter2){//loop over tracks (2) |
| 791 |
|
| 792 |
TrkTrack &trackCand2 = (*trkIter2).second; // get candidate 2... |
| 793 |
|
| 794 |
// if(_debug){ |
| 795 |
// cout <<" X: "; |
| 796 |
// for(int ip=0; ip<6; ip++) |
| 797 |
// if(t_track.GetClusterX_ID(ip)>=0)cout << t_track.GetClusterX_ID(ip)<<":"<<t_track.GetSensor(ip)<<"|"; |
| 798 |
// cout << " Y: "; |
| 799 |
// for(int ip=0; ip<6; ip++) |
| 800 |
// if(t_track.GetClusterY_ID(ip)>=0)cout << t_track.GetClusterY_ID(ip)<<":"<<t_track.GetSensor(ip)<<"|"; |
| 801 |
// cout << " + "; |
| 802 |
// cout <<" X: "; |
| 803 |
// for(int ip=0; ip<6; ip++) |
| 804 |
// if(trackCand2.GetClusterX_ID(ip)>=0)cout << trackCand2.GetClusterX_ID(ip)<<":"<<trackCand2.GetSensor(ip)<<"|"; |
| 805 |
// cout << " Y: "; |
| 806 |
// for(int ip=0; ip<6; ip++) |
| 807 |
// if(trackCand2.GetClusterY_ID(ip)>=0)cout << trackCand2.GetClusterY_ID(ip)<<":"<<trackCand2.GetSensor(ip)<<"|"; |
| 808 |
// cout << " -----> "; |
| 809 |
// } |
| 810 |
|
| 811 |
bool CBM = true; |
| 812 |
for(int ip=0; ip<6; ip++){ //loop over planes |
| 813 |
if( t_track.XGood(ip) && |
| 814 |
trackCand2.XGood(ip) && |
| 815 |
( t_track.GetClusterX_ID(ip)!=trackCand2.GetClusterX_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 816 |
true )CBM=false; // if both have a x-hit and it is not the same ---> they cannot be merged |
| 817 |
if(!CBM)break; |
| 818 |
if( t_track.YGood(ip) && |
| 819 |
trackCand2.YGood(ip) && |
| 820 |
( t_track.GetClusterY_ID(ip)!=trackCand2.GetClusterY_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 821 |
true )CBM=false; // if both have a y-hit and it is not the same ---> they cannot be merged |
| 822 |
if(!CBM)break; |
| 823 |
} |
| 824 |
// if(_debug)cout << " can be merged ? "<<CBM<<endl; |
| 825 |
if(!CBM)continue; //go to the next candidate |
| 826 |
/////////// |
| 827 |
//merging// |
| 828 |
/////////// |
| 829 |
for(int ip=0; ip<6; ip++){ |
| 830 |
if( !(t_track.XGood(ip)) && trackCand2.XGood(ip) ) |
| 831 |
t_track.SetXGood(ip,trackCand2.GetClusterX_ID(ip)+1,trackCand2.GetLadder(ip),trackCand2.GetSensor(ip)); |
| 832 |
if( !(t_track.YGood(ip)) && trackCand2.YGood(ip) ) |
| 833 |
t_track.SetYGood(ip,trackCand2.GetClusterY_ID(ip)+1,trackCand2.GetLadder(ip),trackCand2.GetSensor(ip)); |
| 834 |
}; |
| 835 |
HBM = true; |
| 836 |
}//end loop over tracks (2) |
| 837 |
|
| 838 |
|
| 839 |
// cout << "<< "; |
| 840 |
// for(int ip=0; ip<6; ip++) cout <<setw(4)<< t_track.GetClusterX_ID(ip); |
| 841 |
// for(int ip=0; ip<6; ip++) cout <<setw(4)<< t_track.GetClusterY_ID(ip); |
| 842 |
// cout << endl; |
| 843 |
// cout<< " TRK chi2 "<<setw(10)<<t_track.chi2; |
| 844 |
// cout <<" | al "; |
| 845 |
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 846 |
// cout << endl; |
| 847 |
|
| 848 |
///////////////////////////////////////////////////////// FIT START |
| 849 |
// int ifail=0; |
| 850 |
// // TrkParams::SetDebugMode(); |
| 851 |
// t_track.FitReset(); //angles set to zero |
| 852 |
// t_track.Fit(0.,ifail,0,1);//re-evaluate cluster position from level1 |
| 853 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 854 |
// if( ifail != 0 )continue; |
| 855 |
// t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
| 856 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 857 |
// if( ifail != 0 )continue; |
| 858 |
///////////////////////////////////////////////////////// FIT FINISH |
| 859 |
// cout << "Merged: "<<endl; |
| 860 |
// cout << "X "; for(int ip=0; ip<6; ip++)cout << t_track.XGood(ip); cout << endl; |
| 861 |
// cout << "Y "; for(int ip=0; ip<6; ip++)cout << t_track.YGood(ip); cout << endl; |
| 862 |
// |
| 863 |
//check if track has been already inserted |
| 864 |
// |
| 865 |
multimap<int,TrkTrack>::iterator trkB = trackCandidates[mapIndex].begin(); |
| 866 |
multimap<int,TrkTrack>::iterator trkE = trackCandidates[mapIndex].end(); |
| 867 |
// |
| 868 |
bool ADD = true; |
| 869 |
for( multimap<int,TrkTrack>::iterator trkI = trkB; trkI!=trkE; ++trkI){ |
| 870 |
TrkTrack &trackC = (*trkI).second; |
| 871 |
bool SAME=true; |
| 872 |
for(int ip=0; ip<6; ip++) |
| 873 |
if( t_track.GetClusterX_ID(ip) != trackC.GetClusterX_ID(ip) || |
| 874 |
t_track.GetClusterY_ID(ip) != trackC.GetClusterY_ID(ip) || |
| 875 |
t_track.GetSensor(ip) != trackC.GetSensor(ip) || |
| 876 |
false)SAME=false; |
| 877 |
if(SAME){ |
| 878 |
ADD=false; |
| 879 |
break; |
| 880 |
} |
| 881 |
} |
| 882 |
// if(_debug)cout <<" ADD ? "<<ADD<<endl; |
| 883 |
if(ADD){ |
| 884 |
|
| 885 |
// cout << "-----> INSERT "<<endl; |
| 886 |
if(_debug){ |
| 887 |
cout << " >> HBM "<<HBM; |
| 888 |
cout << " X:";for(int ip=0; ip<6; ip++)cout << t_track.XGood(ip); |
| 889 |
cout << " Y:";for(int ip=0; ip<6; ip++)cout << t_track.YGood(ip); |
| 890 |
cout << " S:";for(int ip=0; ip<6; ip++)cout << t_track.GetSensor(ip); |
| 891 |
} |
| 892 |
|
| 893 |
///////////////////////////////////////////////////////// FIT START |
| 894 |
int ifail=0; |
| 895 |
t_track.FitReset(); //angles set to zero |
| 896 |
t_track.Fit(0.,ifail,0,1);//re-evaluate cluster position from level1 |
| 897 |
if( TMath::IsNaN(t_track.chi2) )continue; |
| 898 |
if( ifail != 0 )continue; |
| 899 |
t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
| 900 |
if( TMath::IsNaN(t_track.chi2) )continue; |
| 901 |
if( ifail != 0 )continue; |
| 902 |
///////////////////////////////////////////////////////// FIT FINISH |
| 903 |
|
| 904 |
if(_debug){ |
| 905 |
cout << " >> al: ";for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 906 |
cout << " chi2: "<<setw(10)<< t_track.chi2; |
| 907 |
cout << endl; |
| 908 |
} |
| 909 |
|
| 910 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 911 |
// evaluated coordinates (to define GF) |
| 912 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 913 |
int ngf = TrkParams::nGF; |
| 914 |
float *zgf = TrkParams::zGF; |
| 915 |
Trajectory tgf = Trajectory(ngf,zgf); |
| 916 |
tgf.DoTrack(t_track.al);//<<<< integrate the trajectory |
| 917 |
for(int ip=0; ip<ngf; ip++){ |
| 918 |
t_track.xGF[ip] = tgf.x[ip]; |
| 919 |
t_track.yGF[ip] = tgf.y[ip]; |
| 920 |
} |
| 921 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 922 |
// evaluated other track info |
| 923 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 924 |
for(int ip=0; ip<6; ip++){ |
| 925 |
float factor = 0.; |
| 926 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.axv[ip]/180.),2); |
| 927 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.ayv[ip]/180.),2); |
| 928 |
factor += 1.; |
| 929 |
factor = TMath::Sqrt(factor); |
| 930 |
// factor = 1.;///TEMP |
| 931 |
if(t_track.XGood(ip)){ |
| 932 |
int iclx = t_track.GetClusterX_ID(ip); |
| 933 |
TrkCluster *clusterx = _trk_l1->GetCluster(iclx); |
| 934 |
float mip = TrkParams::GetMIP(clusterx->GetLadder()-1,clusterx->view-1); |
| 935 |
t_track.dedx_x[ip] = clusterx->GetSignal()/(factor>0.?factor:1.)/(mip>0.?mip:1.); |
| 936 |
t_track.multmaxx[ip] = clusterx->GetMultiplicity()*10000+clusterx->maxs; |
| 937 |
t_track.seedx[ip] = clusterx->clsignal[clusterx->indmax]/clusterx->clsigma[clusterx->indmax];//clusterx->GetSignalToNoise(0,7); |
| 938 |
t_track.xpu[ip] = 0.;//complicato.... |
| 939 |
} |
| 940 |
if(t_track.YGood(ip)){ |
| 941 |
int icly = t_track.GetClusterY_ID(ip); |
| 942 |
TrkCluster *clustery = _trk_l1->GetCluster(icly); |
| 943 |
float mip = TrkParams::GetMIP(clustery->GetLadder()-1,clustery->view-1); |
| 944 |
t_track.dedx_y[ip] = clustery->GetSignal()/(factor>0.?factor:1.)/(mip>0.?mip:1.); |
| 945 |
t_track.multmaxy[ip] = clustery->GetMultiplicity()*10000+clustery->maxs; |
| 946 |
t_track.seedy[ip] = clustery->clsignal[clustery->indmax]/clustery->clsigma[clustery->indmax];//clustery->GetSignalToNoise(0,7); |
| 947 |
t_track.ypu[ip] = 0.;//complicato.... |
| 948 |
} |
| 949 |
} |
| 950 |
///////////////////////////////////////////////////////// end additional info |
| 951 |
|
| 952 |
// cout << "ADD "<<endl; |
| 953 |
trackCandidates[mapIndex].insert(pair<int,TrkTrack>(t_track.GetNX()+t_track.GetNY(), TrkTrack(t_track))); |
| 954 |
if(t_track.GetNX()+t_track.GetNY()>5 && t_track.chi2<chi2Min) chi2Min=t_track.chi2; |
| 955 |
iCand++; |
| 956 |
}//end add-candidate condition |
| 957 |
|
| 958 |
}//end first loop on candidates |
| 959 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 960 |
|
| 961 |
//================================================================= |
| 962 |
// ---------------------------------------------------------------- |
| 963 |
// chi2 selection |
| 964 |
// ---------------------------------------------------------------- |
| 965 |
//================================================================= |
| 966 |
pair <multimap<int,TrkTrack>::iterator, multimap<int,TrkTrack>::iterator> nxny[12]; |
| 967 |
for(int inxny=0; inxny<12; inxny++){ |
| 968 |
nxny[inxny] = trackCandidates[mapIndex].equal_range(inxny); |
| 969 |
for ( multimap<int,TrkTrack>::iterator it = nxny[inxny].first; it!=nxny[inxny].second; ++it){ |
| 970 |
TrkTrack &trackC = (*it).second; |
| 971 |
// cout << " NX+NY "<< trackC.GetNX()+trackC.GetNY() <<" chi2 "<<trackC.chi2<< " R(GV) "<<trackC.GetRigidity()<<endl; |
| 972 |
// if( trackC.chi2==0 )continue; |
| 973 |
if( trackC.GetNX()+trackC.GetNY() > 5 && trackC.chi2>chi2Min )continue; |
| 974 |
trackCandidates[mapIndex+1].insert(pair<int,TrkTrack>(inxny, TrkTrack(trackC))); |
| 975 |
} |
| 976 |
} |
| 977 |
mapIndex++; |
| 978 |
|
| 979 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 980 |
|
| 981 |
//================================================================= |
| 982 |
// ---------------------------------------------------------------- |
| 983 |
// save tracks |
| 984 |
// ---------------------------------------------------------------- |
| 985 |
//================================================================= |
| 986 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 987 |
trkEnd = trackCandidates[mapIndex].end(); |
| 988 |
iCand = 0; |
| 989 |
TClonesArray &tracks = *_trkArray; |
| 990 |
tracks.Clear(); |
| 991 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 992 |
TrkTrack trackCand = ((*trkIter).second); |
| 993 |
trackCand.seqno = iCand; |
| 994 |
// trackCand.Dump(); |
| 995 |
new(tracks[iCand]) TrkTrack(trackCand); |
| 996 |
iCand++; |
| 997 |
}; |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
}; |
| 1002 |
/** |
| 1003 |
* Fill cluster map with tracker clusters |
| 1004 |
*/ |
| 1005 |
void ExtTrkingAlg::FillClusterMap(multimap<int,int> &map,TrkLevel1* l1,Int_t vOffset){ |
| 1006 |
|
| 1007 |
if(_debug)cout<<"-------- TRK CLUSTERs --------"<<endl; |
| 1008 |
|
| 1009 |
// _trk_cl.clear(); |
| 1010 |
|
| 1011 |
if(!l1)return; |
| 1012 |
|
| 1013 |
ExtHit *trkCl = new ExtHit(); |
| 1014 |
|
| 1015 |
for(int icl=0; icl<l1->nclstr(); icl++){ |
| 1016 |
|
| 1017 |
// trkCl->Reset(); |
| 1018 |
|
| 1019 |
// l1->GetCluster(icl)->GetLevel1Struct();// to use F77 routines //PERICOLOSO |
| 1020 |
// trkCl->coordPU = (float)(l1->GetCluster(icl)->maxs) - 1. + l1->GetCluster(icl)->GetCOG(); |
| 1021 |
// trkCl->coordCm = 1000.; //TEMPORANEO forse non serve |
| 1022 |
// trkCl->resCm = 1000.;//TEMPORANEO |
| 1023 |
// trkCl->signal = l1->GetCluster(icl)->GetSignal(); |
| 1024 |
// trkCl->mult = l1->GetCluster(icl)->GetMultiplicity(); |
| 1025 |
// trkCl->view = l1->GetCluster(icl)->view-1; |
| 1026 |
|
| 1027 |
// _trk_cl.push_back(ExtHit(*trkCl)); |
| 1028 |
|
| 1029 |
map.insert( pair<int,int>( l1->GetCluster(icl)->view-1 + vOffset, icl )); |
| 1030 |
if(_debug)cout << icl << " - view(0-11) "<<l1->GetCluster(icl)->view-1<<" ladder(012) "<<l1->GetCluster(icl)->GetLadder()-1<<" strip "<<l1->GetCluster(icl)->maxs<<endl; |
| 1031 |
} |
| 1032 |
|
| 1033 |
// l1->GetLevel1Struct(); //necessario per ritornare al contenuto originale del common |
| 1034 |
|
| 1035 |
if(trkCl)delete trkCl; |
| 1036 |
}; |
| 1037 |
|
| 1038 |
/** |
| 1039 |
* Fill cluster map with calorimeter clusters |
| 1040 |
*/ |
| 1041 |
void ExtTrkingAlg::FillClusterMap(multimap<int,int> &map,CaloLevel1* l1,Int_t vOffset){ |
| 1042 |
|
| 1043 |
if(_debug)cout<<"-------- CALO CLUSTERs -------- on VIEW < "<<_alg_nViewCal<<endl; |
| 1044 |
|
| 1045 |
if(_alg_nViewCal<=0)return; |
| 1046 |
|
| 1047 |
_cal_cl.clear(); |
| 1048 |
|
| 1049 |
if(!l1)return; |
| 1050 |
|
| 1051 |
|
| 1052 |
// ========================== |
| 1053 |
// CALORIMETER CLUSTERING |
| 1054 |
// ========================== |
| 1055 |
CaloStrip st = CaloStrip(false); |
| 1056 |
ExtHit *caloCl=NULL; |
| 1057 |
Int_t nCl = 0; |
| 1058 |
for(Int_t ih=0; ih<l1->istrip; ih++){//loop over calorimeter hits |
| 1059 |
Int_t view = -1; // 0-x 1-y |
| 1060 |
Int_t plane = -1; // 0-21 |
| 1061 |
Int_t strip = -1; // 0-95 |
| 1062 |
Float_t mip = l1->DecodeEstrip(ih,view,plane,strip); |
| 1063 |
|
| 1064 |
// if(strip == 0 || strip == 95)cout <<" strip "<<strip<<" OK "<<endl; |
| 1065 |
if((strip < 0 || strip > 95) && _debug)cout <<" strip "<<strip<<" AHI AHI "<<endl; |
| 1066 |
|
| 1067 |
if(view<0)continue; |
| 1068 |
if(plane<0)continue; |
| 1069 |
if(strip<0)continue; |
| 1070 |
if(mip<=0)continue; |
| 1071 |
|
| 1072 |
// cout << ih << " -- "<<view<<" "<<plane<<" "<<strip<<endl; |
| 1073 |
st.Set(view,plane,strip);// evaluate strip coordinates |
| 1074 |
// |
| 1075 |
int vv = plane*2+(int)(!view); //0-43 odd x even y |
| 1076 |
float cc = (view ? st.GetY() : st.GetX()); //coordinate |
| 1077 |
float ss = mip; //signal |
| 1078 |
float pp = (float)strip; //pitch units |
| 1079 |
|
| 1080 |
if( vv >= _alg_nViewCal ){//view not included |
| 1081 |
if(!caloCl)continue; |
| 1082 |
if(caloCl->mult>0){ //if there is a cluster under construction... |
| 1083 |
_cal_cl.push_back(ExtHit(*caloCl));//store it |
| 1084 |
map.insert( pair<int,int>(caloCl->view + vOffset, nCl )); |
| 1085 |
if(_debug)cout << nCl << " - view(0-43) "<< caloCl->view<<" strip "<<caloCl->start<<"-"<<caloCl->start+caloCl->mult-1<<endl; |
| 1086 |
nCl++; |
| 1087 |
caloCl->Reset(); |
| 1088 |
caloCl->Set(strip,vv); // start new one... (without adding the strip) |
| 1089 |
} |
| 1090 |
continue; //... and skip this view |
| 1091 |
} |
| 1092 |
// -------------- |
| 1093 |
// @first hit: |
| 1094 |
// -------------- |
| 1095 |
if(!caloCl){ |
| 1096 |
caloCl = new ExtHit(strip,vv);//create cluster starting |
| 1097 |
caloCl->Add(cc,pp,ss);//add strip |
| 1098 |
continue; |
| 1099 |
} |
| 1100 |
//------------------- |
| 1101 |
//check previous hit |
| 1102 |
//------------------- |
| 1103 |
if( |
| 1104 |
vv != caloCl->view || //hit on a different view |
| 1105 |
strip > caloCl->start + caloCl->mult ||//not adjacent to previous one |
| 1106 |
strip == 32 || //different ladder |
| 1107 |
strip == 64 || //different ladder |
| 1108 |
false ){ |
| 1109 |
// is a new cluster: |
| 1110 |
// store previous one, if not already stored |
| 1111 |
if(caloCl->mult > 0){ |
| 1112 |
_cal_cl.push_back(ExtHit(*caloCl)); |
| 1113 |
map.insert( pair<int,int>(caloCl->view + vOffset, nCl )); |
| 1114 |
if(_debug)cout << nCl << " - view(0-43) "<< caloCl->view<<" strip "<<caloCl->start<<"-"<<caloCl->start+caloCl->mult-1<<endl; |
| 1115 |
nCl++; |
| 1116 |
}; |
| 1117 |
// |
| 1118 |
caloCl->Reset(); // reset |
| 1119 |
caloCl->Set(strip,vv); // start new one from strip |
| 1120 |
|
| 1121 |
} |
| 1122 |
caloCl->Add(cc,pp,ss); //add strip |
| 1123 |
};//end loop over calorimeter hits |
| 1124 |
|
| 1125 |
if(caloCl)delete caloCl; |
| 1126 |
|
| 1127 |
return; |
| 1128 |
|
| 1129 |
}; |
| 1130 |
/** |
| 1131 |
* Evaluate positions |
| 1132 |
*/ |
| 1133 |
bool ExtTrkingAlg::EvaluateClusterPosition_Tracker( int iclx, int icly,int lad, int sen, float *xmABar, float *ymABar, float *zmAB){ |
| 1134 |
|
| 1135 |
TrkParams::Load(1); |
| 1136 |
if( !TrkParams::IsLoaded(1) ){ |
| 1137 |
cout << "Bool_t ExtTrkingAlg::EvaluateClusterPosition_Tracker ---ERROR--- m.field not loaded "<<endl; |
| 1138 |
return false; |
| 1139 |
} |
| 1140 |
TrkParams::Load(4); |
| 1141 |
if( !TrkParams::IsLoaded(4) ){ |
| 1142 |
cout << "Bool_t ExtTrkingAlg::EvaluateClusterPosition_Tracker ---ERROR--- p.f.a. par. not loaded "<<endl; |
| 1143 |
return false; |
| 1144 |
} |
| 1145 |
TrkParams::Load(5); |
| 1146 |
if( !TrkParams::IsLoaded(5) ){ |
| 1147 |
cout << "Bool_t ExtTrkingAlg::EvaluateClusterPosition_Tracker ---ERROR--- alignment par. not loaded "<<endl; |
| 1148 |
return false; |
| 1149 |
} |
| 1150 |
// cout << ip<<" ** "<<xm[ip]<<" / "<<ym[ip]<<endl;; |
| 1151 |
int icx = iclx+1;//0=no-cluster,1-N |
| 1152 |
int icy = icly+1;//0=no-cluster,1-N |
| 1153 |
int sensor = sen+1;//<< convenzione "Paolo" |
| 1154 |
int ip = (_trk_l1->GetCluster(TMath::Max(iclx,icly))->view-1)/2;//ip=0-5 |
| 1155 |
if(ip==5 && sensor!=0)sensor=3-sensor;//<< convenzione "Elena" |
| 1156 |
int ladder = lad+1; |
| 1157 |
float ax = (float)xmABar[3]; |
| 1158 |
float ay = (float)ymABar[3]; |
| 1159 |
float v[3]; |
| 1160 |
v[0]=xmABar[0]; |
| 1161 |
v[1]=ymABar[0]; |
| 1162 |
v[2]=zmAB[0]; |
| 1163 |
float bfx = 10*TrkParams::GetBX(v);//Tesla |
| 1164 |
float bfy = 10*TrkParams::GetBY(v);//Tesla |
| 1165 |
int ipp=ip+1; |
| 1166 |
|
| 1167 |
// cout<<"xyzpam_("<<ipp<<","<<icx<<","<<icy<<","<<ladder<<","<<sensor<<"...)"<<endl; |
| 1168 |
// e` una cosa bruttissima lo so ma che ci posso fare? mica posso fare tutto io!! |
| 1169 |
// ma lo sai a che ora me so` svegliata stamattina?? |
| 1170 |
xyzpam_(&ipp,&icx,&icy,&ladder,&sensor,&ax,&ay,&bfx,&bfy); |
| 1171 |
// cout<<" ip l s------------------- "<<ip<<ladder<<sensor<<" zm "<<track_.zm[ip]<<endl; |
| 1172 |
extern cMini2track track_; |
| 1173 |
|
| 1174 |
xmABar[0]=track_.xm[ip]; |
| 1175 |
ymABar[0]=track_.ym[ip]; |
| 1176 |
zmAB[0]=track_.zm[ip]; |
| 1177 |
|
| 1178 |
xmABar[1]=track_.xm_a[ip]; |
| 1179 |
ymABar[1]=track_.ym_a[ip]; |
| 1180 |
zmAB[1]=track_.zm_a[ip];// |
| 1181 |
|
| 1182 |
|
| 1183 |
xmABar[2]=track_.xm_b[ip]; |
| 1184 |
ymABar[2]=track_.ym_b[ip]; |
| 1185 |
zmAB[2]=track_.zm_b[ip];// |
| 1186 |
|
| 1187 |
xmABar[4]=track_.resx[ip]; |
| 1188 |
ymABar[4]=track_.resy[ip]; |
| 1189 |
|
| 1190 |
return true; |
| 1191 |
|
| 1192 |
} |
| 1193 |
// bool ExtTrkingAlg::EvaluateClusterPosition_Calorimeter( int icl, int sensor, float *xmABar, float *ymABar, float *zmAB, float def){ |
| 1194 |
|
| 1195 |
// ExtHit cluster = _cal_cl[icl]; |
| 1196 |
// // int plane = 6 + cluster.view; //0...21 |
| 1197 |
// int plane = (int)(cluster.view / 2 ); //0...21 |
| 1198 |
// int ladder = (int)(cluster.coordPU / 32);//0...2 |
| 1199 |
// bool isX = (cluster.view)%2; |
| 1200 |
// bool isY = !isX; |
| 1201 |
|
| 1202 |
|
| 1203 |
// bool ROTO = (sensor>=0);//if sensor is assigned (0,1,2) the strip can be rototraslated |
| 1204 |
|
| 1205 |
|
| 1206 |
// CaloStrip st = CaloStrip(false); |
| 1207 |
// //---------------------------- |
| 1208 |
// // Z-coordinate |
| 1209 |
// //---------------------------- |
| 1210 |
// st.Set((int)isY,plane,ladder*32);// |
| 1211 |
|
| 1212 |
// float coordCm_Z0 = st.GetZ(); |
| 1213 |
|
| 1214 |
// float size = 80.5; //(cm) larghezza del sensore + zone morte |
| 1215 |
// //---------------------------- |
| 1216 |
// // strip-segment coordinates |
| 1217 |
// //---------------------------- |
| 1218 |
// float coordCm_LA = cluster.coordCm; |
| 1219 |
// float coordCm_LB = cluster.coordCm; |
| 1220 |
// float coordCm_SA = (-1)*size*1.5; //full calorimeter size |
| 1221 |
// float coordCm_SB = (+1)*size*1.5; //full calorimeter size |
| 1222 |
// float coordCm_ZA = coordCm_Z0; |
| 1223 |
// float coordCm_ZB = coordCm_Z0; |
| 1224 |
|
| 1225 |
// //---------------------------- |
| 1226 |
// // rototraslation |
| 1227 |
// //---------------------------- |
| 1228 |
// if(ROTO){ |
| 1229 |
// //----------------------------- |
| 1230 |
// // sensor origin coordinates |
| 1231 |
// //----------------------------- |
| 1232 |
// st.Set( (int)isY, plane, ladder*32);// |
| 1233 |
// float coordCm_L0 = ( isX ? st.GetX() : st.GetY()); |
| 1234 |
// st.Set((int)(!isY), plane, sensor*32 ); |
| 1235 |
// float coordCm_S0 = (!isX ? st.GetX() : st.GetY()); |
| 1236 |
|
| 1237 |
// coordCm_SA = (-1)*size*0.5 + (sensor-1)*size; //sensor size |
| 1238 |
// coordCm_SB = (+1)*size*0.5 + (sensor-1)*size; //sensor size |
| 1239 |
|
| 1240 |
// //----------------------------- |
| 1241 |
// // alignment pamameters |
| 1242 |
// //----------------------------- |
| 1243 |
// float fPitch = 1.; |
| 1244 |
// float shift[]= {0.,0.,0.};//(L,S,Z) |
| 1245 |
// float alpha = 0.; |
| 1246 |
// //----------------------------- |
| 1247 |
|
| 1248 |
// //coordinate relative al sensore |
| 1249 |
// coordCm_LA = coordCm_LA - coordCm_L0; |
| 1250 |
// coordCm_SA = coordCm_SA - coordCm_S0; |
| 1251 |
// coordCm_ZA = coordCm_ZA - coordCm_Z0; |
| 1252 |
// coordCm_LB = coordCm_LB - coordCm_L0; |
| 1253 |
// coordCm_SB = coordCm_SB - coordCm_S0; |
| 1254 |
// coordCm_ZB = coordCm_ZB - coordCm_Z0; |
| 1255 |
|
| 1256 |
// //variazione di pitch |
| 1257 |
// coordCm_LA = coordCm_LA * fPitch; |
| 1258 |
// coordCm_LB = coordCm_LB * fPitch; |
| 1259 |
|
| 1260 |
// //rotazione |
| 1261 |
// float LA = coordCm_LA - alpha * coordCm_SA; |
| 1262 |
// float SA = coordCm_SA + alpha * coordCm_LA; |
| 1263 |
// float LB = coordCm_LB - alpha * coordCm_SB; |
| 1264 |
// float SB = coordCm_SB + alpha * coordCm_LB; |
| 1265 |
|
| 1266 |
// //traslazione |
| 1267 |
// coordCm_LA = LA + shift[0]; |
| 1268 |
// coordCm_SA = SA + shift[1]; |
| 1269 |
// coordCm_ZA = coordCm_ZA + shift[2]; |
| 1270 |
// coordCm_LB = LB + shift[0]; |
| 1271 |
// coordCm_SB = SB + shift[1]; |
| 1272 |
// coordCm_ZB = coordCm_ZB + shift[2]; |
| 1273 |
|
| 1274 |
// //sistema di riferimento generale |
| 1275 |
|
| 1276 |
// coordCm_LA = coordCm_LA + coordCm_L0; |
| 1277 |
// coordCm_SA = coordCm_SA + coordCm_S0; |
| 1278 |
// coordCm_ZA = coordCm_ZA + coordCm_Z0; |
| 1279 |
// coordCm_LB = coordCm_LB + coordCm_L0; |
| 1280 |
// coordCm_SB = coordCm_SB + coordCm_S0; |
| 1281 |
// coordCm_ZB = coordCm_ZB + coordCm_Z0; |
| 1282 |
|
| 1283 |
// } |
| 1284 |
|
| 1285 |
// xmABar[0] = -100.; |
| 1286 |
// ymABar[0] = -100.; |
| 1287 |
// zmAB[0] = 0.5*coordCm_ZA+0.5*coordCm_ZB; |
| 1288 |
|
| 1289 |
// xmABar[1] = (isX ? coordCm_LA : coordCm_SA); |
| 1290 |
// ymABar[1] = (isY ? coordCm_LA : coordCm_SA); |
| 1291 |
// zmAB[1] = coordCm_ZA; |
| 1292 |
|
| 1293 |
|
| 1294 |
// xmABar[2]= (isX ? coordCm_LB : coordCm_SB); |
| 1295 |
// ymABar[2]= (isY ? coordCm_LB : coordCm_SB); |
| 1296 |
// zmAB[2] = coordCm_ZB; |
| 1297 |
|
| 1298 |
|
| 1299 |
// //---------------------------- |
| 1300 |
// // evaluate spatial resolution |
| 1301 |
// //---------------------------- |
| 1302 |
|
| 1303 |
|
| 1304 |
// float res_dig = 0.24/sqrt(12.); |
| 1305 |
|
| 1306 |
// float res_ms = 0.; |
| 1307 |
|
| 1308 |
// if(def!=0.){ |
| 1309 |
|
| 1310 |
// float rig = 1/def; if(rig<0)rig = -rig; |
| 1311 |
// float factor = 0.; |
| 1312 |
// factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*xmABar[3]/180.),2); |
| 1313 |
// factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*ymABar[3]/180.),2); |
| 1314 |
// factor += 1.; |
| 1315 |
// factor = TMath::Sqrt(factor); |
| 1316 |
|
| 1317 |
// int view = cluster.view; //0... 43 |
| 1318 |
|
| 1319 |
// int nW = (int)((view + 1)/2); |
| 1320 |
// float dW = 0.74*factor;//X0 |
| 1321 |
// float dW_cm = 0.26*factor;//cm |
| 1322 |
// float dSi_cm = 0.; //cm |
| 1323 |
// if(isY && plane>0) dSi_cm = ( plane%2 ? 0.228 : 0.428); |
| 1324 |
// dSi_cm *= factor; |
| 1325 |
// // multiple scattering angle |
| 1326 |
// float theta = 0.;//ms |
| 1327 |
// theta = 0.0136/rig; |
| 1328 |
// theta = theta * sqrt(dW) * (1.+0.038*log(dW)); |
| 1329 |
// float Vt = theta*theta; //cov(theta,theta) |
| 1330 |
// float Vy = Vt * dW_cm * dW_cm /3.; //cov(y,y) |
| 1331 |
// float Vty = 0.87 * Vt * Vy; //cov(theta,y) |
| 1332 |
// float Vc = Vy + dSi_cm * dSi_cm * Vt + 2. * dSi_cm * Vty; |
| 1333 |
// float rms = sqrt( Vc ); |
| 1334 |
// // if(isY)t_track.resy[ip] = sqrt(rms*rms + t_track.resy[ip]*t_track.resy[ip]); |
| 1335 |
// // else t_track.resx[ip] = sqrt(rms*rms + t_track.resx[ip]*t_track.resx[ip]); |
| 1336 |
// // if(isY) VMS[nW] = rms*rms; |
| 1337 |
// // if(_debug)cout <<endl<<view<<" nW "<<nW<<" res(MS) "<<rms<<" factor "<<factor; |
| 1338 |
|
| 1339 |
// if(view>=3)cout << " --> NB error computation not accurate "; |
| 1340 |
// res_ms = rms; |
| 1341 |
|
| 1342 |
// } |
| 1343 |
|
| 1344 |
|
| 1345 |
|
| 1346 |
|
| 1347 |
// xmABar[4]= (isX ? sqrt(res_dig*res_dig+res_ms*res_ms) : 1000.); |
| 1348 |
// ymABar[4]= (isY ? sqrt(res_dig*res_dig+res_ms*res_ms) : 1000.); |
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
// } |
| 1353 |
bool ExtTrkingAlg::EvaluateClusterPosition_Calorimeter( int icl, int& sisensor, float *xmABar, float *ymABar, float *zmAB, float def){ |
| 1354 |
|
| 1355 |
ExtHit cluster = _cal_cl[icl]; |
| 1356 |
// int plane = 6 + cluster.view; //0...21 |
| 1357 |
int plane = (int)(cluster.view / 2 ); //0...21 |
| 1358 |
int ladder = (int)(cluster.coordPU / 32);//0...2 |
| 1359 |
// int view = cluster.view;//0...43 // EM, unused variable |
| 1360 |
bool isX = (cluster.view)%2; |
| 1361 |
bool isY = !isX; |
| 1362 |
|
| 1363 |
|
| 1364 |
// int sisensor = -1; |
| 1365 |
|
| 1366 |
|
| 1367 |
// CaloStripRoto temp; |
| 1368 |
|
| 1369 |
bool ROTO = ( xmABar[0]!=0. && ymABar[0]!=0.); |
| 1370 |
// ------------------------------------------------------------------------------ |
| 1371 |
// |
| 1372 |
// check if the cluster belongs to the hit sensor (xmABar[0],ymABar[0] must be provided) |
| 1373 |
// evaluate the hit sensor number |
| 1374 |
// |
| 1375 |
// ------------------------------------------------------------------------------ |
| 1376 |
if(ROTO){ |
| 1377 |
|
| 1378 |
|
| 1379 |
for(int is=0;is<3; is++){ |
| 1380 |
int sis = GetCaloSiSensor((int)isY,ladder,is); |
| 1381 |
// cout << "view, ladder, is :"<<(int)isY<<ladder<<is<<" ---> sis "<<sis<<endl; |
| 1382 |
int index = (plane*2+1-(int)isY)*9 + sis; |
| 1383 |
CaloStripRoto extst = _caloStripRoto[index]; |
| 1384 |
// cout << "index "<<index<<endl; |
| 1385 |
// cout << " -> view "<<extst.GetView()<<endl; |
| 1386 |
// cout << " -> plane "<<extst.GetPlane()<<endl; |
| 1387 |
// cout << " -> sisensor "<<extst.GetSiSensor()<<endl; |
| 1388 |
// cout << " -> ladder "<<extst.GetLadder(<<" "<<GetCaloLadder(extst.GetView(),extst.GetSiSensor())<<endl; |
| 1389 |
bool inside = extst.SensorContains(xmABar[0],ymABar[0]); |
| 1390 |
// cout << " inside "<<sis<<" ?? "<<inside<<endl; |
| 1391 |
if( inside ){ |
| 1392 |
sisensor = sis; |
| 1393 |
continue; |
| 1394 |
} |
| 1395 |
} |
| 1396 |
|
| 1397 |
if(sisensor==-1){ |
| 1398 |
// cout << "ATTENZIONE!!! sisensor "<<sisensor<<" x,y "<<xmABar[0]<<" "<<ymABar[0]<<endl; |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
// ------------------------------------------------------------------------------ |
| 1403 |
// |
| 1404 |
// if no sensor is hit, skip rototraslation |
| 1405 |
// |
| 1406 |
// ------------------------------------------------------------------------------ |
| 1407 |
if(sisensor==-1)ROTO=false; |
| 1408 |
// ------------------------------------------------------------------------------ |
| 1409 |
// |
| 1410 |
// now evaluate strip A-B coordinates |
| 1411 |
// |
| 1412 |
// ------------------------------------------------------------------------------ |
| 1413 |
if(ROTO){ |
| 1414 |
|
| 1415 |
int index = (plane*2+1-(int)isY)*9 + sisensor; |
| 1416 |
CaloStripRoto extst = _caloStripRoto[index]; |
| 1417 |
// CaloStrip st = extst.st; |
| 1418 |
|
| 1419 |
// cout << " extst.Set("<<(int)isY<<", "<<plane<<", "<<cluster.coordPU<<", "<<sensor<<") "<<endl; |
| 1420 |
// extst.Set((int)isY, plane, cluster.coordPU, sensor); |
| 1421 |
|
| 1422 |
if( sisensor != extst.GetSiSensor() && _debug )cout << " extst.GetSiSensor() "<<extst.GetSiSensor()<<" != "<<sisensor<<endl; |
| 1423 |
if( plane != extst.GetPlane() && _debug )cout << " extst.GetPlane() "<<extst.GetPlane()<<" != "<<plane<<endl; |
| 1424 |
if( (int)isY != extst.GetView() && _debug )cout << " extst.GetView() "<<extst.GetView()<<" != "<<isY<<endl; |
| 1425 |
// cout << " extst.SetStrip("<<cluster.coordPU<<") "<<endl; |
| 1426 |
extst.SetStrip(cluster.coordPU); |
| 1427 |
|
| 1428 |
|
| 1429 |
xmABar[0] = -100.; |
| 1430 |
ymABar[0] = -100.; |
| 1431 |
zmAB[0] = 0.5*extst.fZA+0.5*extst.fZB; |
| 1432 |
|
| 1433 |
xmABar[1] = extst.fXA; |
| 1434 |
ymABar[1] = extst.fYA; |
| 1435 |
zmAB[1] = extst.fZA; |
| 1436 |
|
| 1437 |
|
| 1438 |
xmABar[2]= extst.fXB; |
| 1439 |
ymABar[2]= extst.fYB; |
| 1440 |
zmAB[2] = extst.fZB; |
| 1441 |
|
| 1442 |
xmABar[4]= (isX ? extst.GetSpatialResolution(def, xmABar[3], ymABar[3], 1.) : 1000.); |
| 1443 |
ymABar[4]= (isY ? extst.GetSpatialResolution(def, xmABar[3], ymABar[3], 1.) : 1000.); |
| 1444 |
|
| 1445 |
|
| 1446 |
}else{ |
| 1447 |
|
| 1448 |
|
| 1449 |
CaloStrip st = CaloStrip(false); |
| 1450 |
//---------------------------- |
| 1451 |
// Z-coordinate |
| 1452 |
//---------------------------- |
| 1453 |
st.Set((int)isY,plane,ladder*32);// |
| 1454 |
|
| 1455 |
float coordCm_Z0 = st.GetZ(); |
| 1456 |
|
| 1457 |
float size = 80.5; //(cm) larghezza del sensore + zone morte |
| 1458 |
//---------------------------- |
| 1459 |
// strip-segment coordinates |
| 1460 |
//---------------------------- |
| 1461 |
float coordCm_LA = cluster.coordCm; |
| 1462 |
float coordCm_LB = cluster.coordCm; |
| 1463 |
float coordCm_SA = (-1)*size*1.5; //full calorimeter size |
| 1464 |
float coordCm_SB = (+1)*size*1.5; //full calorimeter size |
| 1465 |
float coordCm_ZA = coordCm_Z0; |
| 1466 |
float coordCm_ZB = coordCm_Z0; |
| 1467 |
|
| 1468 |
//---------------------------- |
| 1469 |
// rototraslation |
| 1470 |
//---------------------------- |
| 1471 |
|
| 1472 |
xmABar[0] = -100.; |
| 1473 |
ymABar[0] = -100.; |
| 1474 |
zmAB[0] = 0.5*coordCm_ZA+0.5*coordCm_ZB; |
| 1475 |
|
| 1476 |
xmABar[1] = (isX ? coordCm_LA : coordCm_SA); |
| 1477 |
ymABar[1] = (isY ? coordCm_LA : coordCm_SA); |
| 1478 |
zmAB[1] = coordCm_ZA; |
| 1479 |
|
| 1480 |
|
| 1481 |
xmABar[2]= (isX ? coordCm_LB : coordCm_SB); |
| 1482 |
ymABar[2]= (isY ? coordCm_LB : coordCm_SB); |
| 1483 |
zmAB[2] = coordCm_ZB; |
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
//---------------------------- |
| 1489 |
// evaluate spatial resolution |
| 1490 |
//---------------------------- |
| 1491 |
|
| 1492 |
|
| 1493 |
float res_dig = 0.24/sqrt(12.); |
| 1494 |
|
| 1495 |
float res_ms = 0.; |
| 1496 |
|
| 1497 |
if(def!=0.){ |
| 1498 |
|
| 1499 |
float rig = 1/def; if(rig<0)rig = -rig; |
| 1500 |
float factor = 0.; |
| 1501 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*xmABar[3]/180.),2); |
| 1502 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*ymABar[3]/180.),2); |
| 1503 |
factor += 1.; |
| 1504 |
factor = TMath::Sqrt(factor); |
| 1505 |
|
| 1506 |
int view = cluster.view; //0... 43 |
| 1507 |
|
| 1508 |
// int nW = (int)((view + 1)/2); // EM, unused variable |
| 1509 |
float dW = 0.74*factor;//X0 |
| 1510 |
float dW_cm = 0.26*factor;//cm |
| 1511 |
float dSi_cm = 0.; //cm |
| 1512 |
if(isY && plane>0) dSi_cm = ( plane%2 ? 0.228 : 0.428); |
| 1513 |
dSi_cm *= factor; |
| 1514 |
// multiple scattering angle |
| 1515 |
float theta = 0.;//ms |
| 1516 |
theta = 0.0136/rig; |
| 1517 |
theta = theta * sqrt(dW) * (1.+0.038*log(dW)); |
| 1518 |
float Vt = theta*theta; //cov(theta,theta) |
| 1519 |
float Vy = Vt * dW_cm * dW_cm /3.; //cov(y,y) |
| 1520 |
float Vty = 0.87 * Vt * Vy; //cov(theta,y) |
| 1521 |
float Vc = Vy + dSi_cm * dSi_cm * Vt + 2. * dSi_cm * Vty; |
| 1522 |
float rms = sqrt( Vc ); |
| 1523 |
// if(isY)t_track.resy[ip] = sqrt(rms*rms + t_track.resy[ip]*t_track.resy[ip]); |
| 1524 |
// else t_track.resx[ip] = sqrt(rms*rms + t_track.resx[ip]*t_track.resx[ip]); |
| 1525 |
// if(isY) VMS[nW] = rms*rms; |
| 1526 |
// if(_debug)cout <<endl<<view<<" nW "<<nW<<" res(MS) "<<rms<<" factor "<<factor; |
| 1527 |
|
| 1528 |
if(view>=3 && _debug)cout << " --> NB error computation not accurate "; |
| 1529 |
res_ms = rms; |
| 1530 |
|
| 1531 |
} |
| 1532 |
|
| 1533 |
xmABar[4]= (isX ? sqrt(res_dig*res_dig+res_ms*res_ms) : 1000.); |
| 1534 |
ymABar[4]= (isY ? sqrt(res_dig*res_dig+res_ms*res_ms) : 1000.); |
| 1535 |
|
| 1536 |
} |
| 1537 |
|
| 1538 |
return true; // EM, warning: no return statement in function returning non-void [-Wreturn-type] |
| 1539 |
} |
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
/** |
| 1544 |
* Process the event |
| 1545 |
*/ |
| 1546 |
void ExtTrkingAlg::ProcessEvent1(Bool_t force){ |
| 1547 |
|
| 1548 |
if(_debug)cout << " |---------------------------------------------------| "<<endl; |
| 1549 |
if(_debug)cout << " void ExtTrkingAlg::ProcessEvent1("<<force<<") "<<endl; |
| 1550 |
|
| 1551 |
|
| 1552 |
if(_debug && !_trk_l1)cout << " Missing TrkLevel1 object --- ciao! "<<endl; |
| 1553 |
if(!_trk_l1)return; |
| 1554 |
|
| 1555 |
|
| 1556 |
//=========================== |
| 1557 |
// pre-selection |
| 1558 |
//=========================== |
| 1559 |
|
| 1560 |
Bool_t RETRACK = CheckEvent(); |
| 1561 |
|
| 1562 |
if(_debug)cout <<" Pre-selection result: "<<RETRACK<<endl; |
| 1563 |
if( !force && !RETRACK )return; |
| 1564 |
|
| 1565 |
|
| 1566 |
//=========================== |
| 1567 |
// tracking |
| 1568 |
//=========================== |
| 1569 |
|
| 1570 |
// TClonesArray &tracks = *_trkArray; |
| 1571 |
// tracks.Clear(); |
| 1572 |
TClonesArray &tracks = *_trkArray; |
| 1573 |
tracks.Clear(); |
| 1574 |
|
| 1575 |
|
| 1576 |
multimap<int,ExtTrack> trackCandidates[NEXTVIEWS]; // map: last hit view vs TrkTrack |
| 1577 |
int mapIndex = 0; |
| 1578 |
multimap<int,ExtTrack>::iterator trkBegin; |
| 1579 |
multimap<int,ExtTrack>::iterator trkEnd; |
| 1580 |
int iCand; |
| 1581 |
|
| 1582 |
// ------------------------------------------------ |
| 1583 |
// fill a map VIEW-CLUSTER |
| 1584 |
// ------------------------------------------------ |
| 1585 |
multimap<int,int> clusterMap; |
| 1586 |
FillClusterMap(clusterMap,_trk_l1,0);// trk clusters |
| 1587 |
FillClusterMap(clusterMap,_cal_l1,12);// calorimeter clusters |
| 1588 |
|
| 1589 |
|
| 1590 |
// ------------------------------------------------ |
| 1591 |
// define iterators over clusters on the same view |
| 1592 |
// ------------------------------------------------ |
| 1593 |
pair <multimap<int,int>::iterator, multimap<int,int>::iterator> ret[NEXTVIEWS]; |
| 1594 |
multimap<int,int>::iterator it[NEXTVIEWS]; |
| 1595 |
for(int iv=0; iv<NEXTVIEWS; iv++)ret[iv] = clusterMap.equal_range(iv); |
| 1596 |
|
| 1597 |
|
| 1598 |
//==================================================================== |
| 1599 |
// PARAMETERS |
| 1600 |
//==================================================================== |
| 1601 |
// ------------------------------------------------ |
| 1602 |
// number of points per candidate |
| 1603 |
// ------------------------------------------------ |
| 1604 |
int nClFixX = _alg_nClFixX; // n.hits required on X view |
| 1605 |
int nClFixY = _alg_nClFixY; // n.hits required on X view |
| 1606 |
int nTrackMAX = _alg_nTrackMAX; // |
| 1607 |
//================================================== |
| 1608 |
// ------------------------------------------------ |
| 1609 |
// start: one candidate for each cluster |
| 1610 |
// ------------------------------------------------ |
| 1611 |
//================================================== |
| 1612 |
if(_debug)cout<<"-------- MINIMAL TRACK-CANDIDATES --------"; |
| 1613 |
if(_debug)cout<<nClFixX<<"X"<<nClFixY<<"Y"<<endl; |
| 1614 |
for(int iv=0; iv<NEXTVIEWS; iv++){ //loop over all views |
| 1615 |
|
| 1616 |
if( !(iv%2) && (int)(0.5*iv) > NEXTVIEWS/2-nClFixX)continue; |
| 1617 |
if( (iv%2) && (int)(0.5*iv) > NEXTVIEWS/2-nClFixY)continue; |
| 1618 |
|
| 1619 |
if(iv >= NEXTVIEWS - _alg_nViewCal )continue; //skip calo hits |
| 1620 |
|
| 1621 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 1622 |
|
| 1623 |
|
| 1624 |
|
| 1625 |
int icl = it[iv]->second; |
| 1626 |
|
| 1627 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 1628 |
// cluster->Dump(); |
| 1629 |
int ladder = cluster->GetLadder()-1; // |
| 1630 |
int plane = cluster->GetPlane()-1; |
| 1631 |
bool isY = (cluster->view)%2;// F77 1-12 ?? |
| 1632 |
bool isX = !isY; |
| 1633 |
|
| 1634 |
|
| 1635 |
/// TRACKER ============================================================================== |
| 1636 |
for (int is=0; is<2; is++){ //loop over sensors |
| 1637 |
|
| 1638 |
//cout <<endl<< " view "<<iv<<" plane "<<plane<<" cluster "<<icl<<" on sensor "<<is<<endl; |
| 1639 |
|
| 1640 |
ExtTrack& t_track = *_extTrack; |
| 1641 |
|
| 1642 |
t_track.ResetXY(); |
| 1643 |
for(int ip =0 ; ip<t_track.nplanes; ip++ )t_track.SetZ(ip,_zMech[ip]); |
| 1644 |
// t_track.Dump(); |
| 1645 |
|
| 1646 |
|
| 1647 |
// >>>> insert point |
| 1648 |
float xmABar[]={0.,0.,0.,0.,0.}; // inizializzare a zero l'angolo, come prima stima per il PFA |
| 1649 |
float ymABar[]={0.,0.,0.,0.,0.}; |
| 1650 |
float zmAB[]={t_track.zm[plane],0.,0.};//mechanical z-coordinate |
| 1651 |
EvaluateClusterPosition_Tracker( (isX?icl:-1), (isY?icl:-1), ladder, is, xmABar, ymABar, zmAB); |
| 1652 |
|
| 1653 |
if( isX ){ |
| 1654 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 1655 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1656 |
t_track.SetXGood(plane,icl+1,ladder,is); |
| 1657 |
// t_track.SetYGood(plane,0,ladder,is); |
| 1658 |
} |
| 1659 |
if( isY ){ |
| 1660 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 1661 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1662 |
t_track.SetYGood(plane,icl+1,ladder,is); |
| 1663 |
// t_track.SetXGood(plane,0,ladder,is); |
| 1664 |
} |
| 1665 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(iv, t_track)); |
| 1666 |
|
| 1667 |
} |
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
} |
| 1672 |
} |
| 1673 |
|
| 1674 |
//============================================================== |
| 1675 |
// ------------------------------------------------------------- |
| 1676 |
// next: add views to each candidate, up to nClFixX+nClFixY |
| 1677 |
// ------------------------------------------------------------- |
| 1678 |
//============================================================== |
| 1679 |
for( ;mapIndex < nClFixX+nClFixY-1 ;++mapIndex){ |
| 1680 |
|
| 1681 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 1682 |
trkEnd = trackCandidates[mapIndex].end(); |
| 1683 |
if(_debug)cout<<"MAP "<<mapIndex<<" ----------- n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 1684 |
|
| 1685 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 1686 |
|
| 1687 |
|
| 1688 |
ExtTrack trackCand = (*trkIter).second; |
| 1689 |
int lastView = (*trkIter).first; //last inserted view |
| 1690 |
bool lastIsTrk = (lastView < NEXTVIEWS - _alg_nViewCal); |
| 1691 |
int lastPlane = (int)(0.5*lastView); |
| 1692 |
if(!lastIsTrk)lastPlane =lastView-6; |
| 1693 |
int lastLadder = trackCand.GetLadder(lastPlane); |
| 1694 |
int lastSensor = trackCand.GetSensor(lastPlane); |
| 1695 |
|
| 1696 |
|
| 1697 |
// if(_debug)cout<<"MAP "<<mapIndex<<" last v "<<lastView<<" NX "<<trackCand.GetNX()<<" NY "<<trackCand.GetNY()<<endl; |
| 1698 |
|
| 1699 |
for(int iv=lastView+1; iv<NEXTVIEWS; iv++){ //loop over next views |
| 1700 |
|
| 1701 |
bool isTrk = (iv < NEXTVIEWS - _alg_nViewCal); |
| 1702 |
bool isX = (iv)%2; |
| 1703 |
bool isY = !isX; |
| 1704 |
|
| 1705 |
|
| 1706 |
// if( (iv%2) && (int)(0.5*iv) > 6-nClFixX+trackCand.GetNX())continue; //not enough x-view left |
| 1707 |
// if( !(iv%2) && (int)(0.5*iv) > 6-nClFixY+trackCand.GetNY())continue; //not enough y-view left |
| 1708 |
|
| 1709 |
// if( (iv%2) && trackCand.GetNX()==nClFixX )continue;//ok? |
| 1710 |
// if( !(iv%2) && trackCand.GetNY()==nClFixY )continue;//ok? |
| 1711 |
|
| 1712 |
if( isX && trackCand.GetNX()==nClFixX )continue;//ok? |
| 1713 |
if( isY && trackCand.GetNY()==nClFixY )continue;//ok? |
| 1714 |
|
| 1715 |
|
| 1716 |
if( isX && (int)(0.5*iv) > 6+_alg_nViewCal/2 - nClFixX+trackCand.GetNX())continue; //not enough x-view left |
| 1717 |
if( isY && (int)(0.5*iv) > 6+(_alg_nViewCal+1)/2 - nClFixY+trackCand.GetNY())continue; //not enough y-view left |
| 1718 |
|
| 1719 |
|
| 1720 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 1721 |
|
| 1722 |
int icl = it[iv]->second; |
| 1723 |
|
| 1724 |
if(isTrk){ |
| 1725 |
/// TRACKER ================================================== |
| 1726 |
|
| 1727 |
|
| 1728 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 1729 |
int ladder = cluster->GetLadder()-1;//(_trk_l1->GetCluster(icl)->maxs-1)%1024 + 1; |
| 1730 |
int plane = cluster->GetPlane()-1; |
| 1731 |
// bool isY = (cluster->view)%2; |
| 1732 |
// bool isX = !isY; |
| 1733 |
|
| 1734 |
if( plane==lastPlane && ladder!=lastLadder)continue; |
| 1735 |
|
| 1736 |
|
| 1737 |
for (int is=0; is<2; is++){ //loop over sensors |
| 1738 |
|
| 1739 |
if( plane==lastPlane && is!=lastSensor)continue; |
| 1740 |
|
| 1741 |
// if(_debug)cout<<"MAP "<<mapIndex<<" last v "<<lastView; |
| 1742 |
// if(_debug)cout<<" +cl "<<icl<<" s"<<is<<endl; |
| 1743 |
|
| 1744 |
ExtTrack t_track = ExtTrack(); |
| 1745 |
trackCand.Copy(t_track); //copy the candidate parameters... |
| 1746 |
|
| 1747 |
bool isXY = (isX && t_track.YGood(plane)) || (isY && t_track.XGood(plane)) ; |
| 1748 |
|
| 1749 |
|
| 1750 |
float xmABar[]={0.,0.,0.,0.,0.}; //importante inizializzare a zero, come prima stima per il PFA |
| 1751 |
float ymABar[]={0.,0.,0.,0.,0.}; |
| 1752 |
float zmAB[]={t_track.zm[plane],0.,0.}; |
| 1753 |
|
| 1754 |
if( isX ){ |
| 1755 |
int iclx = icl; |
| 1756 |
int icly = (isXY ? t_track.GetClusterY_ID(plane) : -1 ); |
| 1757 |
|
| 1758 |
EvaluateClusterPosition_Tracker( iclx, icly , ladder, is, xmABar, ymABar, zmAB); |
| 1759 |
|
| 1760 |
if(isXY){ |
| 1761 |
t_track.SetXY(plane,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 1762 |
t_track.SetZ(plane,zmAB[0]); |
| 1763 |
}else{ |
| 1764 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 1765 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1766 |
} |
| 1767 |
t_track.SetXGood(plane,iclx+1,ladder,is); //...add a point... |
| 1768 |
t_track.SetYGood(plane,icly+1,ladder,is); |
| 1769 |
} |
| 1770 |
// |
| 1771 |
if( isY ){ |
| 1772 |
int iclx = (isXY ? t_track.GetClusterX_ID(plane) : -1 ); |
| 1773 |
int icly = icl; |
| 1774 |
|
| 1775 |
EvaluateClusterPosition_Tracker( iclx, icly , ladder, is, xmABar, ymABar, zmAB); |
| 1776 |
|
| 1777 |
if(isXY){ |
| 1778 |
t_track.SetXY(plane,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 1779 |
t_track.SetZ(plane,zmAB[0]); |
| 1780 |
}else{ |
| 1781 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 1782 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1783 |
}; |
| 1784 |
t_track.SetYGood(plane,icly+1,ladder,is); |
| 1785 |
t_track.SetXGood(plane,iclx+1,ladder,is); |
| 1786 |
} |
| 1787 |
|
| 1788 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(iv, t_track)); //...and store a new candidate |
| 1789 |
};//end loop over sensors |
| 1790 |
|
| 1791 |
}else{ |
| 1792 |
/// CALORIMETER ================================================= |
| 1793 |
ExtHit cluster = _cal_cl[icl]; |
| 1794 |
int plane = 6 + cluster.view; |
| 1795 |
|
| 1796 |
if( plane==lastPlane )continue; |
| 1797 |
|
| 1798 |
int ladder = (int)(cluster.coordPU / 32); |
| 1799 |
int sensor = -1; //not yet known |
| 1800 |
bool isX = (cluster.view)%2; |
| 1801 |
bool isY = !isX; |
| 1802 |
|
| 1803 |
ExtTrack t_track = ExtTrack(); |
| 1804 |
trackCand.Copy(t_track); |
| 1805 |
|
| 1806 |
float xmABar[]={0.,0.,0.,0.,0.}; //importante inizializzare a zero, come prima stima per il PFA |
| 1807 |
float ymABar[]={0.,0.,0.,0.,0.}; // sensor is not evaluated |
| 1808 |
float zmAB[]={0.,0.,0.}; |
| 1809 |
EvaluateClusterPosition_Calorimeter( icl, sensor, xmABar, ymABar, zmAB); |
| 1810 |
|
| 1811 |
|
| 1812 |
if( isX ){ |
| 1813 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 1814 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1815 |
t_track.SetXGood(plane,icl+1, ladder, sensor); //...add a point. |
| 1816 |
t_track.SetYGood(plane, 0, ladder, sensor); //...add a point... |
| 1817 |
} |
| 1818 |
if( isY ){ |
| 1819 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 1820 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 1821 |
t_track.SetYGood(plane,icl+1, ladder, sensor); |
| 1822 |
t_track.SetXGood(plane, 0, ladder, sensor); |
| 1823 |
} |
| 1824 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(iv, t_track)); //...and store a new ca |
| 1825 |
|
| 1826 |
} |
| 1827 |
|
| 1828 |
if( trackCandidates[mapIndex].size() > (uint)nTrackMAX ){ // EM, compilation warning comparison between signed and unsigned |
| 1829 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl; |
| 1830 |
return;//to many candidates |
| 1831 |
} |
| 1832 |
|
| 1833 |
};//end loop over clusters on the view iv |
| 1834 |
};//endl loop over views |
| 1835 |
}//end loop over candidates |
| 1836 |
}//end iterations |
| 1837 |
|
| 1838 |
|
| 1839 |
// if( trackCandidates[mapIndex].size() > nTrakMAX ){ |
| 1840 |
// if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl; |
| 1841 |
// return;//to many candidates |
| 1842 |
// } |
| 1843 |
|
| 1844 |
// if(_debug){ |
| 1845 |
// trkBegin = trackCandidates[mapIndex].begin(); |
| 1846 |
// trkEnd = trackCandidates[mapIndex].end(); |
| 1847 |
// for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 1848 |
// ExtTrack &trackCand = (*trkIter).second; |
| 1849 |
// cout << " >> "; |
| 1850 |
// cout << " X: "; |
| 1851 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 1852 |
// cout << " Y: "; |
| 1853 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 1854 |
|
| 1855 |
// cout << endl; |
| 1856 |
// } |
| 1857 |
// } |
| 1858 |
|
| 1859 |
if(_debug)cout<<"MAP "<<mapIndex<<" ----------- n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 1860 |
|
| 1861 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 1862 |
|
| 1863 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 1864 |
|
| 1865 |
//=============================================================================================== |
| 1866 |
// ------------------------------------------------------------- |
| 1867 |
// first selection of track candidates, based on chi2 |
| 1868 |
// ------------------------------------------------------------- |
| 1869 |
//=============================================================================================== |
| 1870 |
if(_debug)cout<<"-------- CHI2 --------"<<endl; |
| 1871 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 1872 |
trkEnd = trackCandidates[mapIndex].end(); |
| 1873 |
mapIndex++; |
| 1874 |
iCand = 0; |
| 1875 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 1876 |
int lastView = (*trkIter).first; |
| 1877 |
ExtTrack &trackCand = (*trkIter).second; |
| 1878 |
int ifail=0; |
| 1879 |
trackCand.ResetFit(); |
| 1880 |
trackCand.Fit(0.,ifail,0); |
| 1881 |
if(ifail!=0)trackCand.ResetFit(); |
| 1882 |
|
| 1883 |
// ----------------------------------- |
| 1884 |
// first selection of track candidates |
| 1885 |
// ----------------------------------- |
| 1886 |
if(TMath::IsNaN(trackCand.chi2))continue; |
| 1887 |
if(trackCand.chi2 <= 0. || trackCand.chi2 > 1.e7)continue; |
| 1888 |
// if(trackCand.chi2 < 0. || trackCand.chi2 > 10. )continue; |
| 1889 |
iCand++; |
| 1890 |
|
| 1891 |
if(_debug){ |
| 1892 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 1893 |
cout <<" | al: "; |
| 1894 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 1895 |
cout <<" | "; |
| 1896 |
cout << " X: "; |
| 1897 |
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 1898 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 1899 |
// if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
| 1900 |
cout << " | "; |
| 1901 |
cout << " Y: "; |
| 1902 |
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 1903 |
cout << endl; |
| 1904 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 1905 |
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
| 1906 |
} |
| 1907 |
|
| 1908 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1909 |
// evaluated coordinates (to define GF) |
| 1910 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1911 |
// int ngf = TrkParams::nGF; |
| 1912 |
// float *zgf = TrkParams::zGF; |
| 1913 |
// Trajectory tgf = Trajectory(ngf,zgf); |
| 1914 |
// _tgf->DoTrack(trackCand.al);//<<<< integrate the trajectory |
| 1915 |
// for(int ip=0; ip<ngf; ip++){ |
| 1916 |
// trackCand.xGF[ip] = tgf->x[ip]; |
| 1917 |
// trackCand.yGF[ip] = tgf->y[ip]; |
| 1918 |
// } |
| 1919 |
|
| 1920 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
| 1921 |
|
| 1922 |
} |
| 1923 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 1924 |
|
| 1925 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 1926 |
//================================================================= |
| 1927 |
// ---------------------------------------------------------------- |
| 1928 |
// CALORIMETER |
| 1929 |
// ---------------------------------------------------------------- |
| 1930 |
//================================================================= |
| 1931 |
if(_cal_l1){ |
| 1932 |
if(_debug)cout<<"-------- CALORIMETER --------"<<endl; |
| 1933 |
// ----------------------------------- |
| 1934 |
// evaluate calorimeter variables |
| 1935 |
// ----------------------------------- |
| 1936 |
// float caloCoord[2][22][96]; |
| 1937 |
// float caloZ[44]; |
| 1938 |
// for(int view=0; view<2; view++){ |
| 1939 |
// for(int plane=0; plane<22; plane++){ |
| 1940 |
// for(int strip=0; strip<96; strip++){ |
| 1941 |
// CaloStrip st = CaloStrip(false); |
| 1942 |
// st.Set(view,plane,strip); |
| 1943 |
// caloCoord[view][plane][strip]=(view ? st.GetY() : st.GetX()); |
| 1944 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 1945 |
// } |
| 1946 |
// } |
| 1947 |
// } |
| 1948 |
// Trajectory caloTj = Trajectory(44,caloZ); |
| 1949 |
// for(int iz=0; iz<44;iz++)cout<<caloZ[iz]<<endl; |
| 1950 |
//test calo |
| 1951 |
// float caloEvent[2][22][96]; |
| 1952 |
CaloLevel1* l1=_cal_l1;//event->GetCaloLevel1(); |
| 1953 |
// if(!l1)return; |
| 1954 |
vector<float> caloChi2; |
| 1955 |
vector<int> caloHit; int caloHitMAX=0; |
| 1956 |
vector<float> caloMip; |
| 1957 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 1958 |
trkEnd = trackCandidates[mapIndex].end(); |
| 1959 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 1960 |
ExtTrack trackCand = ((*trkIter).second); |
| 1961 |
|
| 1962 |
// trackCand.DoTrack(&caloTj);//integrate the trajectory through the calorimeter |
| 1963 |
_caloTj->DoTrack(trackCand.al,trackCand.zini); |
| 1964 |
// _caloTj->Dump(); |
| 1965 |
|
| 1966 |
float chi2 = 0.; |
| 1967 |
int nhit = 0; |
| 1968 |
float cmip = 0.; |
| 1969 |
for(Int_t ih=0; ih<l1->istrip; ih++){ |
| 1970 |
Int_t view = -1; |
| 1971 |
Int_t plane = -1; |
| 1972 |
Int_t strip = -1; |
| 1973 |
Float_t mip = l1->DecodeEstrip(ih,view,plane,strip); |
| 1974 |
if(view<0)continue; |
| 1975 |
if(plane<0)continue; |
| 1976 |
if(strip<0)continue; |
| 1977 |
if(mip<=0)continue; |
| 1978 |
float dxy = _caloCoord[view][plane][strip]-(view?_caloTj->y[plane*2+(view?0:1)]:_caloTj->x[plane*2+(view?0:1)]); |
| 1979 |
if(plane<11) chi2+= mip * TMath::Power(dxy,2.); |
| 1980 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 1981 |
if( fabs(dxy) < 2. && plane<11)nhit++; |
| 1982 |
if( fabs(dxy) < 2. && plane<11)cmip+=mip; |
| 1983 |
}; |
| 1984 |
if(l1->istrip>0)chi2 = chi2/l1->istrip; |
| 1985 |
|
| 1986 |
caloHit.push_back(nhit); |
| 1987 |
if(nhit>caloHitMAX)caloHitMAX=nhit; |
| 1988 |
|
| 1989 |
if(_debug){ |
| 1990 |
cout << " CALO "; |
| 1991 |
// cout << " chi2 "<< chi2 <<" "; |
| 1992 |
cout << " nhit (< 11th plane) "<< nhit <<" "; |
| 1993 |
// cout << " mip "<< cmip <<" "; |
| 1994 |
cout <<endl; |
| 1995 |
}; |
| 1996 |
} |
| 1997 |
|
| 1998 |
|
| 1999 |
//================================================================= |
| 2000 |
// ---------------------------------------------------------------- |
| 2001 |
// selection of track candidates, based on n.calorimeter hits |
| 2002 |
// ---------------------------------------------------------------- |
| 2003 |
//================================================================= |
| 2004 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2005 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2006 |
mapIndex++; |
| 2007 |
iCand = 0; |
| 2008 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2009 |
int lastView = (*trkIter).first; |
| 2010 |
ExtTrack &trackCand = (*trkIter).second; |
| 2011 |
if(caloHit[iCand]==caloHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
| 2012 |
iCand++; |
| 2013 |
} |
| 2014 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 2015 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2016 |
|
| 2017 |
} |
| 2018 |
|
| 2019 |
|
| 2020 |
//================================================================= |
| 2021 |
// ---------------------------------------------------------------- |
| 2022 |
// TOF |
| 2023 |
// ---------------------------------------------------------------- |
| 2024 |
//================================================================= |
| 2025 |
if(_tof_l2){ |
| 2026 |
if(_debug)cout<<"-------- TOF --------"<<endl; |
| 2027 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2028 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2029 |
ToFLevel2* tl2=_tof_l2;//event->GetToFLevel2(); |
| 2030 |
// if(!tl2)return; |
| 2031 |
iCand =0; |
| 2032 |
vector<int> tofHit; int tofHitMAX=0; |
| 2033 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2034 |
// int lastView = (*trkIter).first; |
| 2035 |
ExtTrack &trackCand = (*trkIter).second; |
| 2036 |
|
| 2037 |
_tgf->DoTrack(trackCand.al);//<<<< integrate the trajectory |
| 2038 |
|
| 2039 |
for(int ip=0; ip<TrkParams::nGF; ip++){ |
| 2040 |
trackCand.xGF[ip] = _tgf->x[ip]; |
| 2041 |
trackCand.yGF[ip] = _tgf->y[ip]; |
| 2042 |
} |
| 2043 |
|
| 2044 |
int nhit =0; |
| 2045 |
for(int iToF=0; iToF<6; iToF++){ |
| 2046 |
|
| 2047 |
int iGF = iToF; |
| 2048 |
if(iToF>3)iGF = iToF+8; |
| 2049 |
int iPaddle = tl2->GetPaddleIdOfTrack( trackCand.xGF[iGF], trackCand.yGF[iGF], iToF); |
| 2050 |
if( tl2->HitPaddle(iToF,iPaddle) )nhit++; |
| 2051 |
|
| 2052 |
} |
| 2053 |
iCand++; |
| 2054 |
|
| 2055 |
tofHit.push_back(nhit); |
| 2056 |
if(nhit>tofHitMAX)tofHitMAX=nhit; |
| 2057 |
|
| 2058 |
if(_debug){ |
| 2059 |
cout << " TOF nhit "<< nhit <<" "; |
| 2060 |
cout <<endl; |
| 2061 |
} |
| 2062 |
|
| 2063 |
} |
| 2064 |
//================================================================= |
| 2065 |
// ---------------------------------------------------------------- |
| 2066 |
// selection of track candidates, based on n.tof hits |
| 2067 |
// ---------------------------------------------------------------- |
| 2068 |
//================================================================= |
| 2069 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2070 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2071 |
mapIndex++; |
| 2072 |
iCand = 0; |
| 2073 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2074 |
int lastView = (*trkIter).first; |
| 2075 |
ExtTrack &trackCand = (*trkIter).second; |
| 2076 |
if(tofHit[iCand]==tofHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, ExtTrack(trackCand))); |
| 2077 |
iCand++; |
| 2078 |
|
| 2079 |
} |
| 2080 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2081 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 2082 |
|
| 2083 |
} |
| 2084 |
|
| 2085 |
if(_debug){ |
| 2086 |
|
| 2087 |
cout<< " Minimal-track SUMMARY:"<<endl; |
| 2088 |
|
| 2089 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2090 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2091 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2092 |
ExtTrack &trackCand = (*trkIter).second; |
| 2093 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 2094 |
cout <<" | al: "; |
| 2095 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 2096 |
cout <<" | "; |
| 2097 |
cout << " X: "; |
| 2098 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 2099 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 2100 |
if(trackCand.GetClusterX_ID(ip)>=0) |
| 2101 |
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
| 2102 |
else |
| 2103 |
cout << "__"; |
| 2104 |
} |
| 2105 |
cout << " | "; |
| 2106 |
cout << " Y: "; |
| 2107 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 2108 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 2109 |
if(trackCand.GetClusterY_ID(ip)>=0) |
| 2110 |
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
| 2111 |
else |
| 2112 |
cout << "__"; |
| 2113 |
} |
| 2114 |
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
| 2115 |
cout << endl; |
| 2116 |
|
| 2117 |
} |
| 2118 |
} |
| 2119 |
|
| 2120 |
//================================================================= |
| 2121 |
// ---------------------------------------------------------------- |
| 2122 |
// TRACK MERGING |
| 2123 |
// ---------------------------------------------------------------- |
| 2124 |
//================================================================= |
| 2125 |
if(_debug)cout<<"-------- MERGING --------"; |
| 2126 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2127 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2128 |
mapIndex++; |
| 2129 |
float chi2Min=1e10; |
| 2130 |
iCand = 0; |
| 2131 |
for( multimap<int,ExtTrack>::iterator trkIter1 = trkBegin; trkIter1!=trkEnd; ++trkIter1){ //loop over tracks (1) |
| 2132 |
|
| 2133 |
ExtTrack &trackCand1 = (*trkIter1).second;// get candidate 1... |
| 2134 |
|
| 2135 |
ExtTrack t_track = ExtTrack();// ...create a new ExtTrack instance... |
| 2136 |
trackCand1.Copy(t_track); // ...and make a copy |
| 2137 |
|
| 2138 |
bool HBM = false; //has been merged |
| 2139 |
|
| 2140 |
for( multimap<int,ExtTrack>::iterator trkIter2 = trkBegin; trkIter2!=trkEnd; ++trkIter2){//loop over tracks (2) |
| 2141 |
|
| 2142 |
ExtTrack &trackCand2 = (*trkIter2).second; // get candidate 2... |
| 2143 |
|
| 2144 |
bool CBM = true; |
| 2145 |
for(int ip=0; ip<NEXTPLANES; ip++){ //loop over planes |
| 2146 |
if( t_track.XGood(ip) && |
| 2147 |
trackCand2.XGood(ip) && |
| 2148 |
( t_track.GetClusterX_ID(ip)!=trackCand2.GetClusterX_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 2149 |
true )CBM=false; // if both have a x-hit and it is not the same ---> they cannot be merged |
| 2150 |
if(!CBM)break; |
| 2151 |
if( t_track.YGood(ip) && |
| 2152 |
trackCand2.YGood(ip) && |
| 2153 |
( t_track.GetClusterY_ID(ip)!=trackCand2.GetClusterY_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 2154 |
true )CBM=false; // if both have a y-hit and it is not the same ---> they cannot be merged |
| 2155 |
if(!CBM)break; |
| 2156 |
} |
| 2157 |
// if(_debug)cout << " can be merged ? "<<CBM<<endl; |
| 2158 |
if(!CBM)continue; //go to the next candidate |
| 2159 |
/////////// |
| 2160 |
//merging// |
| 2161 |
/////////// |
| 2162 |
// cout <<endl<<" check merging al (1) "; |
| 2163 |
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2164 |
// cout <<endl<<" with al (2) "; |
| 2165 |
// for(int i=0; i<5; i++)cout <<setw(10)<< trackCand2.al[i]; |
| 2166 |
|
| 2167 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 2168 |
if( !(t_track.XGood(ip)) && trackCand2.XGood(ip) ){ |
| 2169 |
int ygood_temp = t_track.ygood[ip]; |
| 2170 |
|
| 2171 |
if(t_track.YGood(ip)){ |
| 2172 |
t_track.SetXY(ip,trackCand2.xm[ip],t_track.ym[ip],trackCand2.resx[ip],t_track.resy[ip]); |
| 2173 |
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
| 2174 |
}else{ |
| 2175 |
t_track.SetX(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resx[ip]); |
| 2176 |
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
| 2177 |
} |
| 2178 |
t_track.xgood[ip] = trackCand2.xgood[ip];//assign cluster + sensor |
| 2179 |
t_track.ygood[ip] = ygood_temp;//assign cluster + sensor |
| 2180 |
|
| 2181 |
HBM = true; |
| 2182 |
} |
| 2183 |
if( !(t_track.YGood(ip)) && trackCand2.YGood(ip) ) { |
| 2184 |
|
| 2185 |
int xgood_temp = t_track.xgood[ip]; |
| 2186 |
|
| 2187 |
if(t_track.XGood(ip)){ |
| 2188 |
t_track.SetXY(ip,t_track.xm[ip],trackCand2.ym[ip],t_track.resx[ip],trackCand2.resy[ip]); |
| 2189 |
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
| 2190 |
}else{ |
| 2191 |
t_track.SetY(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resy[ip]); |
| 2192 |
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
| 2193 |
} |
| 2194 |
t_track.ygood[ip] = trackCand2.ygood[ip];//assign cluster + sensor |
| 2195 |
t_track.xgood[ip] = xgood_temp;//assign cluster + sensor |
| 2196 |
HBM = true; |
| 2197 |
} |
| 2198 |
}; |
| 2199 |
|
| 2200 |
}//end loop over tracks (2) |
| 2201 |
|
| 2202 |
|
| 2203 |
// cout << "<< "; |
| 2204 |
// for(int ip=0; ip<6; ip++) cout <<setw(4)<< t_track.GetClusterX_ID(ip); |
| 2205 |
// for(int ip=0; ip<6; ip++) cout <<setw(4)<< t_track.GetClusterY_ID(ip); |
| 2206 |
// cout << endl; |
| 2207 |
// cout<< " TRK chi2 "<<setw(10)<<t_track.chi2; |
| 2208 |
// cout <<" | al "; |
| 2209 |
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2210 |
// cout << endl; |
| 2211 |
|
| 2212 |
///////////////////////////////////////////////////////// FIT START |
| 2213 |
// int ifail=0; |
| 2214 |
// // TrkParams::SetDebugMode(); |
| 2215 |
// t_track.FitReset(); //angles set to zero |
| 2216 |
// t_track.Fit(0.,ifail,0,1);//re-evaluate cluster position from level1 |
| 2217 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 2218 |
// if( ifail != 0 )continue; |
| 2219 |
// t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
| 2220 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 2221 |
// if( ifail != 0 )continue; |
| 2222 |
///////////////////////////////////////////////////////// FIT FINISH |
| 2223 |
// cout << "Merged: "<<endl; |
| 2224 |
// cout << "X "; for(int ip=0; ip<6; ip++)cout << t_track.XGood(ip); cout << endl; |
| 2225 |
// cout << "Y "; for(int ip=0; ip<6; ip++)cout << t_track.YGood(ip); cout << endl; |
| 2226 |
// |
| 2227 |
//check if track has been already inserted |
| 2228 |
// |
| 2229 |
multimap<int,ExtTrack>::iterator trkB = trackCandidates[mapIndex].begin(); |
| 2230 |
multimap<int,ExtTrack>::iterator trkE = trackCandidates[mapIndex].end(); |
| 2231 |
// |
| 2232 |
bool ADD = true; |
| 2233 |
for( multimap<int,ExtTrack>::iterator trkI = trkB; trkI!=trkE; ++trkI){ |
| 2234 |
ExtTrack &trackC = (*trkI).second; |
| 2235 |
bool SAME=true; |
| 2236 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 2237 |
bool isTrk = (ip < NEXTPLANES - _alg_nViewCal); |
| 2238 |
if( t_track.GetClusterX_ID(ip) != trackC.GetClusterX_ID(ip) )SAME=false; |
| 2239 |
if( t_track.GetClusterY_ID(ip) != trackC.GetClusterY_ID(ip) )SAME=false; |
| 2240 |
if( isTrk && t_track.GetSensor(ip) != trackC.GetSensor(ip) )SAME=false; |
| 2241 |
} |
| 2242 |
if(SAME){ |
| 2243 |
ADD=false; |
| 2244 |
break; |
| 2245 |
} |
| 2246 |
} |
| 2247 |
// if(_debug)cout <<" ADD ? "<<ADD<<endl; |
| 2248 |
|
| 2249 |
// cout << "-----> INSERT "<<endl; |
| 2250 |
if(_debug){ |
| 2251 |
|
| 2252 |
cout << endl; |
| 2253 |
cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
| 2254 |
cout <<" | al: "; |
| 2255 |
for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2256 |
cout <<" | "; |
| 2257 |
cout << " X: "; |
| 2258 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
| 2259 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 2260 |
if(t_track.GetClusterX_ID(ip)>=0) |
| 2261 |
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
| 2262 |
else |
| 2263 |
cout << "__"; |
| 2264 |
} |
| 2265 |
cout << " | "; |
| 2266 |
cout << " Y: "; |
| 2267 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
| 2268 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 2269 |
if(t_track.GetClusterY_ID(ip)>=0) |
| 2270 |
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
| 2271 |
else |
| 2272 |
cout << "__"; |
| 2273 |
} |
| 2274 |
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
| 2275 |
if(HBM)cout << " >> Merged"; |
| 2276 |
|
| 2277 |
} |
| 2278 |
|
| 2279 |
|
| 2280 |
if(ADD){ |
| 2281 |
|
| 2282 |
// cout << " >> re-evaluate..."; |
| 2283 |
// ///////////////////////////////////////////////////////// FIT START |
| 2284 |
int ifail=0; |
| 2285 |
t_track.ResetFit(); |
| 2286 |
// t_track.Dump(); |
| 2287 |
t_track.Fit(0.,ifail,0);// |
| 2288 |
if( ifail != 0 || TMath::IsNaN(t_track.chi2) ){ |
| 2289 |
// if(_debug){ |
| 2290 |
// t_track.ResetFit(); |
| 2291 |
// t_track.Fit(0.,ifail,2);// |
| 2292 |
// } |
| 2293 |
continue; |
| 2294 |
} |
| 2295 |
|
| 2296 |
// t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
| 2297 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 2298 |
// if( ifail != 0 )continue; |
| 2299 |
// ///////////////////////////////////////////////////////// FIT FINISH |
| 2300 |
|
| 2301 |
|
| 2302 |
|
| 2303 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2304 |
// re-evaluated coordinates |
| 2305 |
// and |
| 2306 |
// evaluated other track info |
| 2307 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 2308 |
// float VMS[22];VMS[0]=0.; // EM, 2245:13: warning: variable ?VMS? set but not used [-Wunused-but-set-variable] |
| 2309 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 2310 |
|
| 2311 |
if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue; |
| 2312 |
|
| 2313 |
int iclx = t_track.GetClusterX_ID(ip); |
| 2314 |
int icly = t_track.GetClusterY_ID(ip); |
| 2315 |
int ladder = t_track.GetLadder(ip);//ok |
| 2316 |
int sensor = t_track.GetSensor(ip);// not yet assigned for calo |
| 2317 |
|
| 2318 |
bool isTrk = (ip < NEXTPLANES - _alg_nViewCal); |
| 2319 |
bool isXY = t_track.XGood(ip)*t_track.YGood(ip); |
| 2320 |
bool isX = t_track.XGood(ip) && !isXY; |
| 2321 |
bool isY = t_track.YGood(ip) && !isXY; |
| 2322 |
|
| 2323 |
// cout <<endl<< ip << " xgood "<<t_track.xgood[ip]<<" ygood "<<t_track.ygood[ip]; |
| 2324 |
// cout <<endl<< ip << " iclx "<<iclx<<" icly "<<icly; |
| 2325 |
|
| 2326 |
// continue; |
| 2327 |
//========================================= |
| 2328 |
// evaluate angular factor |
| 2329 |
//========================================= |
| 2330 |
float factor = 0.; |
| 2331 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.axv[ip]/180.),2); |
| 2332 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.ayv[ip]/180.),2); |
| 2333 |
factor += 1.; |
| 2334 |
factor = TMath::Sqrt(factor); |
| 2335 |
// factor = 1.;///TEMP |
| 2336 |
|
| 2337 |
|
| 2338 |
//========================================= |
| 2339 |
// re-evaluate coordinates |
| 2340 |
//========================================= |
| 2341 |
float xmABar[]={t_track.xv[ip],0.,0.,t_track.axv[ip],0.};//importante passare gli angoli e la coordinata!! |
| 2342 |
float ymABar[]={t_track.yv[ip],0.,0.,t_track.ayv[ip],0.};//importante passare gli angoli e la coordinata!! |
| 2343 |
float zmAB[]={t_track.zv[ip],0.,0.}; |
| 2344 |
|
| 2345 |
if(isTrk){ |
| 2346 |
EvaluateClusterPosition_Tracker( iclx, icly, ladder, sensor, xmABar, ymABar, zmAB); |
| 2347 |
}else{ |
| 2348 |
EvaluateClusterPosition_Calorimeter( (int)fmax((float)iclx,(float)icly), sensor, xmABar, ymABar, zmAB, t_track.al[4]); |
| 2349 |
// now the hiyt sensor is assigned |
| 2350 |
} |
| 2351 |
if(isXY){ |
| 2352 |
t_track.SetXY(ip,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 2353 |
t_track.SetZ(ip,zmAB[0]); |
| 2354 |
} |
| 2355 |
if(isX ){ |
| 2356 |
t_track.SetX( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 2357 |
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
| 2358 |
} |
| 2359 |
if(isY ){ |
| 2360 |
t_track.SetY( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 2361 |
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
| 2362 |
} |
| 2363 |
|
| 2364 |
t_track.SetXGood(ip,(sensor == -1 ? 0 : iclx+1),ladder,sensor); |
| 2365 |
t_track.SetYGood(ip,(sensor == -1 ? 0 : icly+1),ladder,sensor); |
| 2366 |
|
| 2367 |
//========================================= |
| 2368 |
// re-evaluate resolution (calorimeter only) |
| 2369 |
// taking into account multiple scattering |
| 2370 |
//========================================= |
| 2371 |
// if(!isTrk && ip > NEXTPLANES - _alg_nViewCal){ |
| 2372 |
// int nW = (int)((ip - 6 + 1)/2); |
| 2373 |
// float dW = 0.74*factor;//X0 |
| 2374 |
// float dW_cm = 0.26*factor;//cm |
| 2375 |
// float dSi_cm = 0.; //cm |
| 2376 |
// if(isY) dSi_cm = ( ip%2 ? 0.228 : 0.428); |
| 2377 |
// dSi_cm *= factor; |
| 2378 |
// float theta = 0.; |
| 2379 |
// if(t_track.GetRigidity()!=0.)theta = 0.0136/t_track.GetRigidity(); |
| 2380 |
// theta = theta * sqrt(dW) * (1.+0.038*log(dW)); |
| 2381 |
// float Vt = theta*theta; //cov(theta,theta) |
| 2382 |
// float Vy = Vt * dW_cm * dW_cm /3.; //cov(y,y) |
| 2383 |
// float Vty = 0.87 * Vt * Vy; //cov(theta,y) |
| 2384 |
// float Vc = Vy + dSi_cm * dSi_cm * Vt + 2. * dSi_cm * Vty; |
| 2385 |
// float rms = sqrt( Vc + (nW>0 ? VMS[nW-1] : 0.) ); |
| 2386 |
// if(_debug)cout <<endl<< ip<<" nW "<<nW<<" res(MS) "<<rms; |
| 2387 |
// if(isY)t_track.resy[ip] = sqrt(rms*rms + t_track.resy[ip]*t_track.resy[ip]); |
| 2388 |
// else t_track.resx[ip] = sqrt(rms*rms + t_track.resx[ip]*t_track.resx[ip]); |
| 2389 |
// if(isY) VMS[nW] = rms*rms; |
| 2390 |
// } |
| 2391 |
|
| 2392 |
//========================================= |
| 2393 |
// evaluate other quantities |
| 2394 |
//========================================= |
| 2395 |
float smip,multmax; |
| 2396 |
if(t_track.XGood(ip)){ |
| 2397 |
if(isTrk){ |
| 2398 |
TrkCluster *cluster = _trk_l1->GetCluster(iclx); |
| 2399 |
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
| 2400 |
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
| 2401 |
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
| 2402 |
}else{ |
| 2403 |
ExtHit cluster = _cal_cl[iclx]; |
| 2404 |
smip = cluster.signal;//mip |
| 2405 |
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
| 2406 |
} |
| 2407 |
t_track.dedx_x[ip] = smip/(factor>0.?factor:1.); |
| 2408 |
t_track.multmaxx[ip] = multmax; |
| 2409 |
} |
| 2410 |
if(t_track.YGood(ip)){ |
| 2411 |
if(isTrk){ |
| 2412 |
TrkCluster *cluster = _trk_l1->GetCluster(icly); |
| 2413 |
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
| 2414 |
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
| 2415 |
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
| 2416 |
}else{ |
| 2417 |
ExtHit cluster = _cal_cl[icly]; |
| 2418 |
smip = cluster.signal;//mip |
| 2419 |
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
| 2420 |
} |
| 2421 |
t_track.dedx_y[ip] = smip/(factor>0.?factor:1.); |
| 2422 |
t_track.multmaxy[ip] = multmax; |
| 2423 |
} |
| 2424 |
} |
| 2425 |
///////////////////////////////////////////////////////// end additional info |
| 2426 |
|
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
// ///////////////////////////////////////////////////////// RE-FIT START |
| 2431 |
t_track.Fit(0.,ifail,0);//evaluate again taking into account the track angle |
| 2432 |
if( TMath::IsNaN(t_track.chi2) )continue; |
| 2433 |
if( ifail != 0 )continue; |
| 2434 |
// ///////////////////////////////////////////////////////// RE-FIT FINISH |
| 2435 |
if(_debug){ |
| 2436 |
// cout << endl; |
| 2437 |
// cout << " >> al: ";for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2438 |
// cout << " chi2: "<<setw(10)<< t_track.chi2; |
| 2439 |
// cout << endl; |
| 2440 |
cout << endl; |
| 2441 |
// cout << " >> al: ";for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2442 |
// cout << " chi2: "<<setw(10)<< t_track.chi2; |
| 2443 |
// // cout << endl; |
| 2444 |
cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
| 2445 |
cout <<" | al: "; |
| 2446 |
for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 2447 |
cout <<" | "; |
| 2448 |
cout << " X: "; |
| 2449 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
| 2450 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 2451 |
if(t_track.GetClusterX_ID(ip)>=0) |
| 2452 |
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
| 2453 |
else |
| 2454 |
cout << "__"; |
| 2455 |
} |
| 2456 |
cout << " | "; |
| 2457 |
cout << " Y: "; |
| 2458 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
| 2459 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 2460 |
if(t_track.GetClusterY_ID(ip)>=0) |
| 2461 |
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
| 2462 |
else |
| 2463 |
cout << "__"; |
| 2464 |
} |
| 2465 |
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
| 2466 |
cout << " >> ADD "; |
| 2467 |
} |
| 2468 |
|
| 2469 |
_caloTj->DoTrack(t_track.al,t_track.zini); |
| 2470 |
for(int ip=0; ip<_caloTj->npoint; ip++){ |
| 2471 |
t_track.xGF[ip] = _caloTj->x[ip]; |
| 2472 |
t_track.yGF[ip] = _caloTj->y[ip]; |
| 2473 |
} |
| 2474 |
|
| 2475 |
// cout << "ADD "<<endl; |
| 2476 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(t_track.GetNX()+t_track.GetNY(), ExtTrack(t_track))); |
| 2477 |
if(t_track.GetNX()+t_track.GetNY()>5 && t_track.chi2<chi2Min) chi2Min=t_track.chi2; |
| 2478 |
iCand++; |
| 2479 |
}//end add-candidate condition |
| 2480 |
|
| 2481 |
}//end first loop on candidates |
| 2482 |
if(_debug)cout <<endl<< "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2483 |
|
| 2484 |
// cout << "CHI2 min "<<chi2Min<<endl; |
| 2485 |
//================================================================= |
| 2486 |
// ---------------------------------------------------------------- |
| 2487 |
// chi2 selection |
| 2488 |
// ---------------------------------------------------------------- |
| 2489 |
//================================================================= |
| 2490 |
pair <multimap<int,ExtTrack>::iterator, multimap<int,ExtTrack>::iterator> nxny[NEXTVIEWS]; |
| 2491 |
// for(int inxny=0; inxny<NEXTVIEWS; inxny++){ |
| 2492 |
bool NMTI =false;//not-minimal track inserted |
| 2493 |
for(int inxny=NEXTVIEWS-1; inxny>=nClFixX+nClFixY; inxny--){ |
| 2494 |
nxny[inxny] = trackCandidates[mapIndex].equal_range(inxny); |
| 2495 |
// cout << " --- n "<<inxny<<endl; |
| 2496 |
for ( multimap<int,ExtTrack>::iterator it = nxny[inxny].first; it!=nxny[inxny].second; ++it){ |
| 2497 |
ExtTrack &trackC = (*it).second; |
| 2498 |
// cout << " NX+NY "<< trackC.GetNX()+trackC.GetNY() <<" chi2 "<<trackC.chi2<< " R(GV) "<<trackC.GetRigidity()<<endl; |
| 2499 |
// if( trackC.chi2==0 )continue; |
| 2500 |
if( (trackC.GetNX()+trackC.GetNY() > 5 && trackC.chi2>chi2Min ) || |
| 2501 |
(trackC.GetNX()+trackC.GetNY() == 5 && NMTI ) || |
| 2502 |
false)continue; |
| 2503 |
|
| 2504 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(inxny, ExtTrack(trackC))); |
| 2505 |
// cout << " insert "<<endl; |
| 2506 |
|
| 2507 |
if( trackC.GetNX()+trackC.GetNY() > 5 )NMTI=true; |
| 2508 |
} |
| 2509 |
} |
| 2510 |
mapIndex++; |
| 2511 |
|
| 2512 |
// if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2513 |
|
| 2514 |
if(trackCandidates[mapIndex].size()==0)return;//no good candidates |
| 2515 |
|
| 2516 |
if(_debug){ |
| 2517 |
|
| 2518 |
cout<< " Selected-track SUMMARY:"<<endl; |
| 2519 |
|
| 2520 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2521 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2522 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2523 |
ExtTrack &trackCand = (*trkIter).second; |
| 2524 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 2525 |
cout <<" | al: "; |
| 2526 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 2527 |
cout <<" | "; |
| 2528 |
cout << " X: "; |
| 2529 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 2530 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 2531 |
if(trackCand.GetClusterX_ID(ip)>=0) |
| 2532 |
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
| 2533 |
else |
| 2534 |
cout << "__"; |
| 2535 |
} |
| 2536 |
cout << " | "; |
| 2537 |
cout << " Y: "; |
| 2538 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 2539 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 2540 |
if(trackCand.GetClusterY_ID(ip)>=0) |
| 2541 |
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
| 2542 |
else |
| 2543 |
cout << "__"; |
| 2544 |
} |
| 2545 |
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
| 2546 |
cout <<" MDR="<<1./sqrt(trackCand.coval[4][4])<<endl; |
| 2547 |
cout << endl; |
| 2548 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 2549 |
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
| 2550 |
|
| 2551 |
} |
| 2552 |
} |
| 2553 |
//================================================================= |
| 2554 |
// ---------------------------------------------------------------- |
| 2555 |
// save tracks |
| 2556 |
// ---------------------------------------------------------------- |
| 2557 |
//================================================================= |
| 2558 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2559 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2560 |
iCand = 0; |
| 2561 |
// TClonesArray &tracks = *_trkArray; |
| 2562 |
// tracks.Clear(); |
| 2563 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2564 |
ExtTrack trackCand = ((*trkIter).second); |
| 2565 |
// trackCand.seqno = iCand; |
| 2566 |
// trackCand.Dump(); |
| 2567 |
new(tracks[iCand]) ExtTrack(trackCand); |
| 2568 |
iCand++; |
| 2569 |
}; |
| 2570 |
|
| 2571 |
|
| 2572 |
|
| 2573 |
}; |
| 2574 |
/** |
| 2575 |
* |
| 2576 |
*/ |
| 2577 |
|
| 2578 |
void ExtTrkingAlg::ProcessEvent2(Bool_t force){ |
| 2579 |
|
| 2580 |
|
| 2581 |
// _debug=true; |
| 2582 |
|
| 2583 |
if(_debug)cout << " |---------------------------------------------------| "<<endl; |
| 2584 |
if(_debug)cout << " void ExtTrkingAlg::ProcessEvent2("<<force<<") "<<endl; |
| 2585 |
|
| 2586 |
|
| 2587 |
if(_debug && !_trk_l1)cout << " Missing TrkLevel1 object --- ciao! "<<endl; |
| 2588 |
if(!_trk_l1)return; |
| 2589 |
|
| 2590 |
|
| 2591 |
//=========================== |
| 2592 |
// pre-selection |
| 2593 |
//=========================== |
| 2594 |
|
| 2595 |
Bool_t RETRACK = CheckEvent(); |
| 2596 |
|
| 2597 |
if(_debug)cout <<" Pre-selection result: "<<RETRACK<<endl; |
| 2598 |
if( !force && !RETRACK )return; |
| 2599 |
|
| 2600 |
NEXTVIEWS = 12 +_alg_nViewCal; |
| 2601 |
NEXTPLANES = 6 +_alg_nViewCal; |
| 2602 |
|
| 2603 |
//=========================== |
| 2604 |
// tracking |
| 2605 |
//=========================== |
| 2606 |
|
| 2607 |
// TClonesArray &tracks = *_trkArray; |
| 2608 |
// tracks.Clear(); |
| 2609 |
TClonesArray &tracks = *_trkArray; |
| 2610 |
tracks.Clear("C"); |
| 2611 |
|
| 2612 |
int maxSize = (5+5)*(_alg_nViewCal+1);//boh?! |
| 2613 |
multimap<int,ExtTrack> trackCandidates[maxSize]; // map: last hit view vs TrkTrack |
| 2614 |
int mapIndex = 0; |
| 2615 |
multimap<int,ExtTrack>::iterator trkBegin; |
| 2616 |
multimap<int,ExtTrack>::iterator trkEnd; |
| 2617 |
int iCand; |
| 2618 |
|
| 2619 |
// ------------------------------------------------ |
| 2620 |
// fill a map VIEW-CLUSTER |
| 2621 |
// ------------------------------------------------ |
| 2622 |
multimap<int,int> clusterMap; |
| 2623 |
FillClusterMap(clusterMap,_trk_l1,0);// trk clusters |
| 2624 |
FillClusterMap(clusterMap,_cal_l1,12);// calorimeter clusters |
| 2625 |
|
| 2626 |
|
| 2627 |
// ------------------------------------------------ |
| 2628 |
// define iterators over clusters on the same view |
| 2629 |
// ------------------------------------------------ |
| 2630 |
pair <multimap<int,int>::iterator, multimap<int,int>::iterator> ret[NEXTVIEWS]; |
| 2631 |
multimap<int,int>::iterator it[NEXTVIEWS]; |
| 2632 |
for(int iv=0; iv<NEXTVIEWS; iv++)ret[iv] = clusterMap.equal_range(iv); |
| 2633 |
|
| 2634 |
|
| 2635 |
//==================================================================== |
| 2636 |
// PARAMETERS |
| 2637 |
//==================================================================== |
| 2638 |
// ------------------------------------------------ |
| 2639 |
// number of points per candidate |
| 2640 |
// ------------------------------------------------ |
| 2641 |
int nClFixX = _alg_nClFixX; // n.hits required on X view |
| 2642 |
int nClFixY = _alg_nClFixY; // n.hits required on X view |
| 2643 |
int nTrackMAX = _alg_nTrackMAX; // |
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
///////////////////////////////////////////////////////////////////////// |
| 2648 |
// |
| 2649 |
// |
| 2650 |
// start loop over n.calo planes to be included |
| 2651 |
// |
| 2652 |
///////////////////////////////////////////////////////////////////////// |
| 2653 |
|
| 2654 |
for(int nViewCal=0; nViewCal<=_alg_nViewCal; nViewCal++){ |
| 2655 |
|
| 2656 |
NEXTVIEWS = 12 +nViewCal; |
| 2657 |
NEXTPLANES = 6 +nViewCal; |
| 2658 |
|
| 2659 |
if(_debug)cout<<">>>>>>>>>>> INCLUDE "<<nViewCal<<" CALORIMETER VIEWS "<<endl; |
| 2660 |
// cout<<">>>>>>>>>>> INCLUDE "<<nViewCal<<" CALORIMETER VIEWS "<<endl; |
| 2661 |
//================================================== |
| 2662 |
// ------------------------------------------------ |
| 2663 |
// start: one candidate for each cluster |
| 2664 |
// ------------------------------------------------ |
| 2665 |
//================================================== |
| 2666 |
if(_debug)cout<<"-------- MINIMAL TRACK-CANDIDATES --------"; |
| 2667 |
if(_debug)cout<<nClFixX<<"X"<<nClFixY<<"Y"<<endl; |
| 2668 |
|
| 2669 |
|
| 2670 |
for(int iv=0; iv<NEXTVIEWS; iv++){ //loop over all views |
| 2671 |
|
| 2672 |
if( !(iv%2) && (int)(0.5*iv) > NEXTVIEWS/2-nClFixX)continue; |
| 2673 |
if( (iv%2) && (int)(0.5*iv) > NEXTVIEWS/2-nClFixY)continue; |
| 2674 |
|
| 2675 |
if(iv >= NEXTVIEWS - nViewCal )continue; //skip calo hits |
| 2676 |
|
| 2677 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
int icl = it[iv]->second; |
| 2682 |
|
| 2683 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 2684 |
// cluster->Dump(); |
| 2685 |
int ladder = cluster->GetLadder()-1; // |
| 2686 |
int plane = cluster->GetPlane()-1; |
| 2687 |
bool isY = (cluster->view)%2;// F77 1-12 ?? |
| 2688 |
bool isX = !isY; |
| 2689 |
|
| 2690 |
|
| 2691 |
/// TRACKER ============================================================================== |
| 2692 |
for (int is=0; is<2; is++){ //loop over sensors |
| 2693 |
|
| 2694 |
//cout <<endl<< " view "<<iv<<" plane "<<plane<<" cluster "<<icl<<" on sensor "<<is<<endl; |
| 2695 |
|
| 2696 |
ExtTrack& t_track = *_extTrack; |
| 2697 |
|
| 2698 |
t_track.ResetXY(); |
| 2699 |
// for(int ip =0 ; ip<t_track.nplanes; ip++ )t_track.SetZ(ip,_zMech[ip]); |
| 2700 |
// t_track.Dump(); |
| 2701 |
|
| 2702 |
|
| 2703 |
// >>>> insert point |
| 2704 |
float xmABar[]={0.,0.,0.,0.,0.}; // inizializzare a zero l'angolo, come prima stima per il PFA |
| 2705 |
float ymABar[]={0.,0.,0.,0.,0.}; |
| 2706 |
float zmAB[]={t_track.zm[plane],0.,0.};//mechanical z-coordinate |
| 2707 |
EvaluateClusterPosition_Tracker( (isX?icl:-1), (isY?icl:-1), ladder, is, xmABar, ymABar, zmAB); |
| 2708 |
|
| 2709 |
if( isX ){ |
| 2710 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 2711 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2712 |
t_track.SetXGood(plane,icl+1,ladder,is); |
| 2713 |
// t_track.SetYGood(plane,0,ladder,is); |
| 2714 |
} |
| 2715 |
if( isY ){ |
| 2716 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 2717 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2718 |
t_track.SetYGood(plane,icl+1,ladder,is); |
| 2719 |
// t_track.SetXGood(plane,0,ladder,is); |
| 2720 |
} |
| 2721 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(iv, t_track)); |
| 2722 |
|
| 2723 |
} |
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
} |
| 2728 |
} |
| 2729 |
|
| 2730 |
|
| 2731 |
//============================================================== |
| 2732 |
// ------------------------------------------------------------- |
| 2733 |
// next: add views to each candidate, up to nClFixX+nClFixY |
| 2734 |
// ------------------------------------------------------------- |
| 2735 |
//============================================================== |
| 2736 |
// for( ;mapIndex < nClFixX+nClFixY-1 ;++mapIndex){ |
| 2737 |
for( int iii=0; iii< nClFixX+nClFixY-1; iii++){ |
| 2738 |
|
| 2739 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 2740 |
|
| 2741 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2742 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2743 |
if(_debug)cout<<"MAP "<<mapIndex<<" ----------- n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2744 |
|
| 2745 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2746 |
|
| 2747 |
|
| 2748 |
ExtTrack trackCand = (*trkIter).second; |
| 2749 |
int lastView = (*trkIter).first; //last inserted view |
| 2750 |
bool lastIsTrk = (lastView < NEXTVIEWS - nViewCal); |
| 2751 |
int lastPlane = (int)(0.5*lastView); |
| 2752 |
if(!lastIsTrk)lastPlane =lastView-6; |
| 2753 |
int lastLadder = trackCand.GetLadder(lastPlane); |
| 2754 |
int lastSensor = trackCand.GetSensor(lastPlane); |
| 2755 |
|
| 2756 |
|
| 2757 |
// cout <<" >>> lastView "<<lastView<< " NEXTVIEWS "<<NEXTVIEWS<<endl; |
| 2758 |
|
| 2759 |
for(int iv=lastView+1; iv<NEXTVIEWS; iv++){ //loop over next views |
| 2760 |
|
| 2761 |
bool isTrk = (iv < NEXTVIEWS - nViewCal); |
| 2762 |
bool isX = (iv)%2; |
| 2763 |
bool isY = !isX; |
| 2764 |
|
| 2765 |
|
| 2766 |
// if( (iv%2) && (int)(0.5*iv) > 6-nClFixX+trackCand.GetNX())continue; //not enough x-view left |
| 2767 |
// if( !(iv%2) && (int)(0.5*iv) > 6-nClFixY+trackCand.GetNY())continue; //not enough y-view left |
| 2768 |
|
| 2769 |
// if( (iv%2) && trackCand.GetNX()==nClFixX )continue;//ok? |
| 2770 |
// if( !(iv%2) && trackCand.GetNY()==nClFixY )continue;//ok? |
| 2771 |
|
| 2772 |
if( isX && trackCand.GetNX()==nClFixX )continue;//ok? |
| 2773 |
if( isY && trackCand.GetNY()==nClFixY )continue;//ok? |
| 2774 |
|
| 2775 |
|
| 2776 |
if( isX && (int)(0.5*iv) > 6+nViewCal/2 - nClFixX+trackCand.GetNX())continue; //not enough x-view left |
| 2777 |
if( isY && (int)(0.5*iv) > 6+(nViewCal+1)/2 - nClFixY+trackCand.GetNY())continue; //not enough y-view left |
| 2778 |
|
| 2779 |
for ( it[iv]=ret[iv].first; it[iv]!=ret[iv].second; ++it[iv]){ //loop over clusters on the view |
| 2780 |
|
| 2781 |
int icl = it[iv]->second; |
| 2782 |
|
| 2783 |
// cout <<" >>> icl "<<icl<<endl; |
| 2784 |
|
| 2785 |
if(isTrk){ |
| 2786 |
/// TRACKER ================================================== |
| 2787 |
|
| 2788 |
|
| 2789 |
TrkCluster *cluster = _trk_l1->GetCluster(icl); |
| 2790 |
int ladder = cluster->GetLadder()-1;//(_trk_l1->GetCluster(icl)->maxs-1)%1024 + 1; |
| 2791 |
int plane = cluster->GetPlane()-1; |
| 2792 |
// bool isY = (cluster->view)%2; |
| 2793 |
// bool isX = !isY; |
| 2794 |
|
| 2795 |
if( plane==lastPlane && ladder!=lastLadder)continue; |
| 2796 |
|
| 2797 |
|
| 2798 |
for (int is=0; is<2; is++){ //loop over sensors |
| 2799 |
|
| 2800 |
if( plane==lastPlane && is!=lastSensor)continue; |
| 2801 |
|
| 2802 |
// if(_debug)cout<<"MAP "<<mapIndex<<" last v "<<lastView; |
| 2803 |
// if(_debug)cout<<" +cl "<<icl<<" s"<<is<<endl; |
| 2804 |
|
| 2805 |
ExtTrack t_track = ExtTrack(); |
| 2806 |
trackCand.Copy(t_track); //copy the candidate parameters... |
| 2807 |
|
| 2808 |
bool isXY = (isX && t_track.YGood(plane)) || (isY && t_track.XGood(plane)) ; |
| 2809 |
|
| 2810 |
|
| 2811 |
float xmABar[]={0.,0.,0.,0.,0.}; //importante inizializzare a zero, come prima stima per il PFA |
| 2812 |
float ymABar[]={0.,0.,0.,0.,0.}; |
| 2813 |
float zmAB[]={t_track.zm[plane],0.,0.}; |
| 2814 |
|
| 2815 |
if( isX ){ |
| 2816 |
int iclx = icl; |
| 2817 |
int icly = (isXY ? t_track.GetClusterY_ID(plane) : -1 ); |
| 2818 |
|
| 2819 |
EvaluateClusterPosition_Tracker( iclx, icly , ladder, is, xmABar, ymABar, zmAB); |
| 2820 |
|
| 2821 |
if(isXY){ |
| 2822 |
t_track.SetXY(plane,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 2823 |
t_track.SetZ(plane,zmAB[0]); |
| 2824 |
}else{ |
| 2825 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 2826 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2827 |
} |
| 2828 |
t_track.SetXGood(plane,iclx+1,ladder,is); //...add a point... |
| 2829 |
t_track.SetYGood(plane,icly+1,ladder,is); |
| 2830 |
} |
| 2831 |
// |
| 2832 |
if( isY ){ |
| 2833 |
int iclx = (isXY ? t_track.GetClusterX_ID(plane) : -1 ); |
| 2834 |
int icly = icl; |
| 2835 |
|
| 2836 |
EvaluateClusterPosition_Tracker( iclx, icly , ladder, is, xmABar, ymABar, zmAB); |
| 2837 |
|
| 2838 |
if(isXY){ |
| 2839 |
t_track.SetXY(plane,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 2840 |
t_track.SetZ(plane,zmAB[0]); |
| 2841 |
}else{ |
| 2842 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 2843 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2844 |
}; |
| 2845 |
t_track.SetYGood(plane,icly+1,ladder,is); |
| 2846 |
t_track.SetXGood(plane,iclx+1,ladder,is); |
| 2847 |
} |
| 2848 |
|
| 2849 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(iv, t_track)); //...and store a new candidate |
| 2850 |
};//end loop over sensors |
| 2851 |
|
| 2852 |
}else{ |
| 2853 |
/// CALORIMETER ================================================= |
| 2854 |
ExtHit cluster = _cal_cl[icl]; |
| 2855 |
int plane = 6 + cluster.view; |
| 2856 |
|
| 2857 |
if( plane==lastPlane )continue; |
| 2858 |
|
| 2859 |
int ladder = (int)(cluster.coordPU / 32); |
| 2860 |
int sensor = -1; //not yet known |
| 2861 |
bool isX = (cluster.view)%2; |
| 2862 |
bool isY = !isX; |
| 2863 |
|
| 2864 |
ExtTrack t_track = ExtTrack(); |
| 2865 |
trackCand.Copy(t_track); |
| 2866 |
|
| 2867 |
float xmABar[]={0.,0.,0.,0.,0.}; //importante inizializzare a zero, come prima stima per il PFA |
| 2868 |
float ymABar[]={0.,0.,0.,0.,0.}; |
| 2869 |
float zmAB[]={0.,0.,0.}; |
| 2870 |
EvaluateClusterPosition_Calorimeter( icl, sensor, xmABar, ymABar, zmAB); |
| 2871 |
|
| 2872 |
|
| 2873 |
if( isX ){ |
| 2874 |
t_track.SetX(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 2875 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2876 |
t_track.SetXGood(plane,icl+1, ladder, sensor); //...add a point. |
| 2877 |
t_track.SetYGood(plane, 0, ladder, sensor); //...add a point... |
| 2878 |
} |
| 2879 |
if( isY ){ |
| 2880 |
t_track.SetY(plane,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 2881 |
t_track.SetZ(plane,0.5*(zmAB[1]+zmAB[2])); |
| 2882 |
t_track.SetYGood(plane,icl+1, ladder, sensor); |
| 2883 |
t_track.SetXGood(plane, 0, ladder, sensor); |
| 2884 |
} |
| 2885 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(iv, t_track)); //...and store a new ca |
| 2886 |
|
| 2887 |
} |
| 2888 |
|
| 2889 |
if( trackCandidates[mapIndex+1].size() > (uint)nTrackMAX ){ //EM, 2826:50: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] |
| 2890 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex+1].size()<<" > "<<nTrackMAX<<endl; |
| 2891 |
return;//to many candidates |
| 2892 |
} |
| 2893 |
|
| 2894 |
};//end loop over clusters on the view iv |
| 2895 |
};//endl loop over views |
| 2896 |
}//end loop over candidates |
| 2897 |
|
| 2898 |
mapIndex++; |
| 2899 |
|
| 2900 |
}//end iterations |
| 2901 |
|
| 2902 |
if(_debug)cout<<"end of cluster inclusion"<<endl; |
| 2903 |
if(_debug)cout<<"MAP "<<mapIndex<<" ----------- n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2904 |
// if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2905 |
|
| 2906 |
|
| 2907 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2908 |
if(trackCandidates[mapIndex].size()==0){ |
| 2909 |
// mapIndex++; |
| 2910 |
continue;//increment one calo plane |
| 2911 |
} |
| 2912 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2913 |
|
| 2914 |
|
| 2915 |
//=============================================================================================== |
| 2916 |
// ------------------------------------------------------------- |
| 2917 |
// first selection of track candidates, based on chi2 |
| 2918 |
// ------------------------------------------------------------- |
| 2919 |
//=============================================================================================== |
| 2920 |
if(_debug)cout<<"-------- CHI2 --------"<<endl; |
| 2921 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 2922 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2923 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2924 |
mapIndex++; |
| 2925 |
iCand = 0; |
| 2926 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2927 |
int lastView = (*trkIter).first; |
| 2928 |
ExtTrack &trackCand = (*trkIter).second; |
| 2929 |
int ifail=0; |
| 2930 |
|
| 2931 |
|
| 2932 |
// trackCand.Dump(); |
| 2933 |
|
| 2934 |
trackCand.ResetFit(); |
| 2935 |
trackCand.Fit(0.,ifail,0); |
| 2936 |
if(ifail!=0)trackCand.ResetFit(); |
| 2937 |
|
| 2938 |
// trackCand.Dump(); |
| 2939 |
|
| 2940 |
|
| 2941 |
// ----------------------------------- |
| 2942 |
// first selection of track candidates |
| 2943 |
// ----------------------------------- |
| 2944 |
if(TMath::IsNaN(trackCand.chi2))continue; |
| 2945 |
if(trackCand.chi2 <= 0. || trackCand.chi2 > 1.e7)continue; |
| 2946 |
// if(trackCand.chi2 < 0. || trackCand.chi2 > 10. )continue; |
| 2947 |
iCand++; |
| 2948 |
|
| 2949 |
if(_debug){ |
| 2950 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 2951 |
cout <<" | al: "; |
| 2952 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 2953 |
cout <<" | "; |
| 2954 |
cout << " X: "; |
| 2955 |
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 2956 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 2957 |
// if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
| 2958 |
cout << " | "; |
| 2959 |
cout << " Y: "; |
| 2960 |
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 2961 |
cout << endl; |
| 2962 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 2963 |
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
| 2964 |
} |
| 2965 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
| 2966 |
|
| 2967 |
} |
| 2968 |
|
| 2969 |
|
| 2970 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2971 |
if(trackCandidates[mapIndex].size()==0){ |
| 2972 |
mapIndex++; |
| 2973 |
continue;//increment one calo plane |
| 2974 |
} |
| 2975 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 2976 |
|
| 2977 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 2978 |
|
| 2979 |
|
| 2980 |
//================================================================= |
| 2981 |
// ---------------------------------------------------------------- |
| 2982 |
// CALORIMETER |
| 2983 |
// ---------------------------------------------------------------- |
| 2984 |
//================================================================= |
| 2985 |
if(_cal_l1){ |
| 2986 |
if(_debug)cout<<"-------- CALORIMETER --------"<<endl; |
| 2987 |
|
| 2988 |
CaloLevel1* l1=_cal_l1;//event->GetCaloLevel1(); |
| 2989 |
// if(!l1)return; |
| 2990 |
vector<float> caloChi2; |
| 2991 |
vector<int> caloHit; int caloHitMAX=0; |
| 2992 |
vector<float> caloMip; |
| 2993 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 2994 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 2995 |
trkEnd = trackCandidates[mapIndex].end(); |
| 2996 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 2997 |
ExtTrack trackCand = ((*trkIter).second); |
| 2998 |
|
| 2999 |
// trackCand.DoTrack(&caloTj);//integrate the trajectory through the calorimeter |
| 3000 |
_caloTj->DoTrack(trackCand.al,trackCand.zini); |
| 3001 |
// _caloTj->Dump(); |
| 3002 |
|
| 3003 |
float chi2 = 0.; |
| 3004 |
int nhit = 0; |
| 3005 |
float cmip = 0.; |
| 3006 |
for(Int_t ih=0; ih<l1->istrip; ih++){ |
| 3007 |
Int_t view = -1; |
| 3008 |
Int_t plane = -1; |
| 3009 |
Int_t strip = -1; |
| 3010 |
Float_t mip = l1->DecodeEstrip(ih,view,plane,strip); |
| 3011 |
if(view<0)continue; |
| 3012 |
if(plane<0)continue; |
| 3013 |
if(strip<0)continue; |
| 3014 |
if(mip<=0)continue; |
| 3015 |
float dxy = _caloCoord[view][plane][strip]-(view?_caloTj->y[plane*2+(view?0:1)]:_caloTj->x[plane*2+(view?0:1)]); |
| 3016 |
if(plane<11) chi2+= mip * TMath::Power(dxy,2.); |
| 3017 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
| 3018 |
if( fabs(dxy) < 2. && plane<11)nhit++; |
| 3019 |
if( fabs(dxy) < 2. && plane<11)cmip+=mip; |
| 3020 |
}; |
| 3021 |
if(l1->istrip>0)chi2 = chi2/l1->istrip; |
| 3022 |
|
| 3023 |
caloHit.push_back(nhit); |
| 3024 |
if(nhit>caloHitMAX)caloHitMAX=nhit; |
| 3025 |
|
| 3026 |
if(_debug){ |
| 3027 |
cout << " CALO "; |
| 3028 |
// cout << " chi2 "<< chi2 <<" "; |
| 3029 |
cout << " nhit (< 11th plane) "<< nhit <<" "; |
| 3030 |
// cout << " mip "<< cmip <<" "; |
| 3031 |
cout <<endl; |
| 3032 |
}; |
| 3033 |
} |
| 3034 |
|
| 3035 |
//================================================================= |
| 3036 |
// ---------------------------------------------------------------- |
| 3037 |
// selection of track candidates, based on n.calorimeter hits |
| 3038 |
// ---------------------------------------------------------------- |
| 3039 |
//================================================================= |
| 3040 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3041 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3042 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3043 |
mapIndex++; |
| 3044 |
iCand = 0; |
| 3045 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3046 |
int lastView = (*trkIter).first; |
| 3047 |
ExtTrack &trackCand = (*trkIter).second; |
| 3048 |
if(caloHit[iCand]==caloHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
| 3049 |
iCand++; |
| 3050 |
} |
| 3051 |
|
| 3052 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3053 |
if(trackCandidates[mapIndex].size()==0){ |
| 3054 |
mapIndex++; |
| 3055 |
continue;//increment one calo plane |
| 3056 |
} |
| 3057 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3058 |
|
| 3059 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 3060 |
|
| 3061 |
}// end if calo event |
| 3062 |
|
| 3063 |
|
| 3064 |
|
| 3065 |
|
| 3066 |
//================================================================= |
| 3067 |
// ---------------------------------------------------------------- |
| 3068 |
// TOF |
| 3069 |
// ---------------------------------------------------------------- |
| 3070 |
//================================================================= |
| 3071 |
if(_tof_l2){ |
| 3072 |
if(_debug)cout<<"-------- TOF --------"<<endl; |
| 3073 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3074 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3075 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3076 |
ToFLevel2* tl2=_tof_l2;//event->GetToFLevel2(); |
| 3077 |
// if(!tl2)return; |
| 3078 |
iCand =0; |
| 3079 |
vector<int> tofHit; int tofHitMAX=0; |
| 3080 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3081 |
// int lastView = (*trkIter).first; |
| 3082 |
ExtTrack &trackCand = (*trkIter).second; |
| 3083 |
|
| 3084 |
_tgf->DoTrack(trackCand.al);//<<<< integrate the trajectory |
| 3085 |
|
| 3086 |
for(int ip=0; ip<TrkParams::nGF; ip++){ |
| 3087 |
trackCand.xGF[ip] = _tgf->x[ip]; |
| 3088 |
trackCand.yGF[ip] = _tgf->y[ip]; |
| 3089 |
} |
| 3090 |
|
| 3091 |
int nhit =0; |
| 3092 |
for(int iToF=0; iToF<6; iToF++){ |
| 3093 |
|
| 3094 |
int iGF = iToF; |
| 3095 |
if(iToF>3)iGF = iToF+8; |
| 3096 |
int iPaddle = tl2->GetPaddleIdOfTrack( trackCand.xGF[iGF], trackCand.yGF[iGF], iToF); |
| 3097 |
if( tl2->HitPaddle(iToF,iPaddle) )nhit++; |
| 3098 |
|
| 3099 |
} |
| 3100 |
iCand++; |
| 3101 |
|
| 3102 |
tofHit.push_back(nhit); |
| 3103 |
if(nhit>tofHitMAX)tofHitMAX=nhit; |
| 3104 |
|
| 3105 |
if(_debug){ |
| 3106 |
cout << " TOF nhit "<< nhit <<" "; |
| 3107 |
cout <<endl; |
| 3108 |
} |
| 3109 |
|
| 3110 |
|
| 3111 |
} |
| 3112 |
//================================================================= |
| 3113 |
// ---------------------------------------------------------------- |
| 3114 |
// selection of track candidates, based on n.tof hits |
| 3115 |
// ---------------------------------------------------------------- |
| 3116 |
//================================================================= |
| 3117 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3118 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3119 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3120 |
mapIndex++; |
| 3121 |
iCand = 0; |
| 3122 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3123 |
int lastView = (*trkIter).first; |
| 3124 |
ExtTrack &trackCand = (*trkIter).second; |
| 3125 |
if(tofHit[iCand]==tofHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, ExtTrack(trackCand))); |
| 3126 |
iCand++; |
| 3127 |
|
| 3128 |
} |
| 3129 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 3130 |
|
| 3131 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3132 |
if(trackCandidates[mapIndex].size()==0){ |
| 3133 |
mapIndex++; |
| 3134 |
continue;//increment one calo plane |
| 3135 |
} |
| 3136 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3137 |
|
| 3138 |
} |
| 3139 |
|
| 3140 |
if(_debug){ |
| 3141 |
|
| 3142 |
cout<< " Minimal-track SUMMARY:"<<endl; |
| 3143 |
|
| 3144 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3145 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3146 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3147 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3148 |
ExtTrack &trackCand = (*trkIter).second; |
| 3149 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 3150 |
cout <<" | al: "; |
| 3151 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 3152 |
cout <<" | "; |
| 3153 |
cout << " X: "; |
| 3154 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 3155 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 3156 |
if(trackCand.GetClusterX_ID(ip)>=0) |
| 3157 |
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
| 3158 |
else |
| 3159 |
cout << "__"; |
| 3160 |
} |
| 3161 |
cout << " | "; |
| 3162 |
cout << " Y: "; |
| 3163 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 3164 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 3165 |
if(trackCand.GetClusterY_ID(ip)>=0) |
| 3166 |
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
| 3167 |
else |
| 3168 |
cout << "__"; |
| 3169 |
} |
| 3170 |
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
| 3171 |
cout << endl; |
| 3172 |
|
| 3173 |
} |
| 3174 |
} |
| 3175 |
//================================================================= |
| 3176 |
// ---------------------------------------------------------------- |
| 3177 |
// TRACK MERGING |
| 3178 |
// ---------------------------------------------------------------- |
| 3179 |
//================================================================= |
| 3180 |
if(_debug)cout<<"-------- MERGING --------"; |
| 3181 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3182 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3183 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3184 |
mapIndex++; |
| 3185 |
float chi2Min=1e10; |
| 3186 |
iCand = 0; |
| 3187 |
for( multimap<int,ExtTrack>::iterator trkIter1 = trkBegin; trkIter1!=trkEnd; ++trkIter1){ //loop over tracks (1) |
| 3188 |
|
| 3189 |
ExtTrack &trackCand1 = (*trkIter1).second;// get candidate 1... |
| 3190 |
|
| 3191 |
ExtTrack t_track = ExtTrack();// ...create a new ExtTrack instance... |
| 3192 |
trackCand1.Copy(t_track); // ...and make a copy |
| 3193 |
|
| 3194 |
bool HBM = false; //has been merged |
| 3195 |
|
| 3196 |
for( multimap<int,ExtTrack>::iterator trkIter2 = trkBegin; trkIter2!=trkEnd; ++trkIter2){//loop over tracks (2) |
| 3197 |
|
| 3198 |
ExtTrack &trackCand2 = (*trkIter2).second; // get candidate 2... |
| 3199 |
|
| 3200 |
bool CBM = true; |
| 3201 |
for(int ip=0; ip<NEXTPLANES; ip++){ //loop over planes |
| 3202 |
if( t_track.XGood(ip) && |
| 3203 |
trackCand2.XGood(ip) && |
| 3204 |
( t_track.GetClusterX_ID(ip)!=trackCand2.GetClusterX_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 3205 |
true )CBM=false; // if both have a x-hit and it is not the same ---> they cannot be merged |
| 3206 |
if(!CBM)break; |
| 3207 |
if( t_track.YGood(ip) && |
| 3208 |
trackCand2.YGood(ip) && |
| 3209 |
( t_track.GetClusterY_ID(ip)!=trackCand2.GetClusterY_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
| 3210 |
true )CBM=false; // if both have a y-hit and it is not the same ---> they cannot be merged |
| 3211 |
if(!CBM)break; |
| 3212 |
} |
| 3213 |
// if(_debug)cout << " can be merged ? "<<CBM<<endl; |
| 3214 |
if(!CBM)continue; //go to the next candidate |
| 3215 |
/////////// |
| 3216 |
//merging// |
| 3217 |
/////////// |
| 3218 |
// cout <<endl<<" check merging al (1) "; |
| 3219 |
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 3220 |
// cout <<endl<<" with al (2) "; |
| 3221 |
// for(int i=0; i<5; i++)cout <<setw(10)<< trackCand2.al[i]; |
| 3222 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 3223 |
if( !(t_track.XGood(ip)) && trackCand2.XGood(ip) ){ |
| 3224 |
int ygood_temp = t_track.ygood[ip]; |
| 3225 |
|
| 3226 |
if(t_track.YGood(ip)){ |
| 3227 |
t_track.SetXY(ip,trackCand2.xm[ip],t_track.ym[ip],trackCand2.resx[ip],t_track.resy[ip]); |
| 3228 |
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
| 3229 |
}else{ |
| 3230 |
t_track.SetX(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resx[ip]); |
| 3231 |
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
| 3232 |
} |
| 3233 |
t_track.xgood[ip] = trackCand2.xgood[ip];//assign cluster + sensor |
| 3234 |
t_track.ygood[ip] = ygood_temp;//assign cluster + sensor |
| 3235 |
|
| 3236 |
HBM = true; |
| 3237 |
} |
| 3238 |
if( !(t_track.YGood(ip)) && trackCand2.YGood(ip) ) { |
| 3239 |
|
| 3240 |
int xgood_temp = t_track.xgood[ip]; |
| 3241 |
|
| 3242 |
if(t_track.XGood(ip)){ |
| 3243 |
t_track.SetXY(ip,t_track.xm[ip],trackCand2.ym[ip],t_track.resx[ip],trackCand2.resy[ip]); |
| 3244 |
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
| 3245 |
}else{ |
| 3246 |
t_track.SetY(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resy[ip]); |
| 3247 |
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
| 3248 |
} |
| 3249 |
t_track.ygood[ip] = trackCand2.ygood[ip];//assign cluster + sensor |
| 3250 |
t_track.xgood[ip] = xgood_temp;//assign cluster + sensor |
| 3251 |
HBM = true; |
| 3252 |
} |
| 3253 |
}; |
| 3254 |
|
| 3255 |
}//end loop over tracks (2) |
| 3256 |
// |
| 3257 |
//check if track has been already inserted |
| 3258 |
// |
| 3259 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3260 |
multimap<int,ExtTrack>::iterator trkB = trackCandidates[mapIndex].begin(); |
| 3261 |
multimap<int,ExtTrack>::iterator trkE = trackCandidates[mapIndex].end(); |
| 3262 |
// |
| 3263 |
bool ADD = true; |
| 3264 |
for( multimap<int,ExtTrack>::iterator trkI = trkB; trkI!=trkE; ++trkI){ |
| 3265 |
ExtTrack &trackC = (*trkI).second; |
| 3266 |
bool SAME=true; |
| 3267 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 3268 |
bool isTrk = (ip < NEXTPLANES - nViewCal); |
| 3269 |
if( t_track.GetClusterX_ID(ip) != trackC.GetClusterX_ID(ip) )SAME=false; |
| 3270 |
if( t_track.GetClusterY_ID(ip) != trackC.GetClusterY_ID(ip) )SAME=false; |
| 3271 |
if( isTrk && t_track.GetSensor(ip) != trackC.GetSensor(ip) )SAME=false; |
| 3272 |
} |
| 3273 |
if(SAME){ |
| 3274 |
ADD=false; |
| 3275 |
break; |
| 3276 |
} |
| 3277 |
} |
| 3278 |
// if(_debug)cout <<" ADD ? "<<ADD<<endl; |
| 3279 |
|
| 3280 |
// cout << "-----> INSERT "<<endl; |
| 3281 |
if(_debug){ |
| 3282 |
|
| 3283 |
cout << endl; |
| 3284 |
// cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
| 3285 |
cout<< " TRK chi2 "<<"............."; |
| 3286 |
cout <<" | al: "; |
| 3287 |
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 3288 |
for(int i=0; i<5; i++)cout <<".........."; |
| 3289 |
cout <<" | "; |
| 3290 |
cout << " X: "; |
| 3291 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
| 3292 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 3293 |
if(t_track.GetClusterX_ID(ip)>=0) |
| 3294 |
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
| 3295 |
else |
| 3296 |
cout << "__"; |
| 3297 |
} |
| 3298 |
cout << " | "; |
| 3299 |
cout << " Y: "; |
| 3300 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
| 3301 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 3302 |
if(t_track.GetClusterY_ID(ip)>=0) |
| 3303 |
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
| 3304 |
else |
| 3305 |
cout << "__"; |
| 3306 |
} |
| 3307 |
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
| 3308 |
if(HBM)cout << " >> Merged"; |
| 3309 |
// cout << endl; |
| 3310 |
} |
| 3311 |
|
| 3312 |
if(ADD){ |
| 3313 |
// cout << " >> re-evaluate..."; |
| 3314 |
// cout << " >> Merged? "<<HBM; |
| 3315 |
// cout << "| X:"; |
| 3316 |
// for(int ip=0; ip<NEXTPLANES; ip++){ |
| 3317 |
// if(t_track.GetClusterX_ID(ip)>=0) |
| 3318 |
// cout << setw(2)<<t_track.GetClusterX_ID(ip); |
| 3319 |
// else |
| 3320 |
// cout << "__"; |
| 3321 |
// } |
| 3322 |
// // for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.XGood(ip); |
| 3323 |
// cout << "| Y:"; |
| 3324 |
// for(int ip=0; ip<NEXTPLANES; ip++){ |
| 3325 |
// if(t_track.GetClusterY_ID(ip)>=0) |
| 3326 |
// cout << setw(2)<<t_track.GetClusterY_ID(ip); |
| 3327 |
// else |
| 3328 |
// cout << "__"; |
| 3329 |
// } |
| 3330 |
// // for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.YGood(ip); |
| 3331 |
// cout << " S:";for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.GetSensor(ip)+1; |
| 3332 |
// cout << endl; |
| 3333 |
|
| 3334 |
// ///////////////////////////////////////////////////////// FIT START |
| 3335 |
int ifail=0; |
| 3336 |
t_track.ResetFit(); |
| 3337 |
// t_track.Dump(); |
| 3338 |
t_track.Fit(0.,ifail,0);// |
| 3339 |
if( ifail != 0 || TMath::IsNaN(t_track.chi2) ){ |
| 3340 |
// if(_debug){ |
| 3341 |
// t_track.ResetFit(); |
| 3342 |
// t_track.Fit(0.,ifail,2);// |
| 3343 |
// } |
| 3344 |
continue; |
| 3345 |
} |
| 3346 |
|
| 3347 |
// t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
| 3348 |
// if( TMath::IsNaN(t_track.chi2) )continue; |
| 3349 |
// if( ifail != 0 )continue; |
| 3350 |
// ///////////////////////////////////////////////////////// FIT FINISH |
| 3351 |
|
| 3352 |
|
| 3353 |
|
| 3354 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3355 |
// re-evaluated coordinates |
| 3356 |
// and |
| 3357 |
// evaluated other track info |
| 3358 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 3359 |
//float VMS[22];VMS[0]=0.; //EM, 3295:14: warning: variable ?VMS? set but not used [-Wunused-but-set-variable] |
| 3360 |
for(int ip=0; ip<NEXTPLANES; ip++){ |
| 3361 |
|
| 3362 |
if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue; |
| 3363 |
|
| 3364 |
int iclx = t_track.GetClusterX_ID(ip); |
| 3365 |
int icly = t_track.GetClusterY_ID(ip); |
| 3366 |
int ladder = t_track.GetLadder(ip);//ok |
| 3367 |
int sensor = t_track.GetSensor(ip);//not assigned yet for calo |
| 3368 |
|
| 3369 |
bool isTrk = (ip < NEXTPLANES - nViewCal); |
| 3370 |
bool isXY = t_track.XGood(ip)*t_track.YGood(ip); |
| 3371 |
bool isX = t_track.XGood(ip) && !isXY; |
| 3372 |
bool isY = t_track.YGood(ip) && !isXY; |
| 3373 |
|
| 3374 |
// cout <<endl<< ip << " xgood "<<t_track.xgood[ip]<<" ygood "<<t_track.ygood[ip]; |
| 3375 |
// cout <<endl<< ip << " iclx "<<iclx<<" icly "<<icly; |
| 3376 |
|
| 3377 |
// continue; |
| 3378 |
//========================================= |
| 3379 |
// evaluate angular factor |
| 3380 |
//========================================= |
| 3381 |
float factor = 0.; |
| 3382 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.axv[ip]/180.),2); |
| 3383 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.ayv[ip]/180.),2); |
| 3384 |
factor += 1.; |
| 3385 |
factor = TMath::Sqrt(factor); |
| 3386 |
// factor = 1.;///TEMP |
| 3387 |
|
| 3388 |
//========================================= |
| 3389 |
// re-evaluate coordinates |
| 3390 |
//========================================= |
| 3391 |
float xmABar[]={t_track.xv[ip],0.,0.,t_track.axv[ip],0.};//importante passare gli angoli!! |
| 3392 |
float ymABar[]={t_track.yv[ip],0.,0.,t_track.ayv[ip],0.};//importante passare gli angoli!! |
| 3393 |
float zmAB[]={t_track.zv[ip],0.,0.}; |
| 3394 |
|
| 3395 |
if(isTrk){ |
| 3396 |
EvaluateClusterPosition_Tracker( iclx, icly, ladder, sensor, xmABar, ymABar, zmAB); |
| 3397 |
}else{ |
| 3398 |
// cout <<" ------------ EvaluateClusterPosition_Calorimeter ----------------"<<endl; |
| 3399 |
// cout << "IN: "<<(int)fmax((float)iclx,(float)icly)<<endl; |
| 3400 |
// cout << "IN: "<<sensor<<endl; |
| 3401 |
// cout << "IN: "<<xmABar[0]<<endl; |
| 3402 |
// cout << "IN: "<<ymABar[0]<<endl; |
| 3403 |
// cout << "IN: "<<zmAB[0]<<endl; |
| 3404 |
// cout << "IN: "<<t_track.al[4]<<endl; |
| 3405 |
EvaluateClusterPosition_Calorimeter( (int)fmax((float)iclx,(float)icly), sensor, xmABar, ymABar, zmAB, t_track.al[4]); |
| 3406 |
// cout << ip << " SENSOR "<<sensor<<endl; |
| 3407 |
} |
| 3408 |
if(isXY){ |
| 3409 |
t_track.SetXY(ip,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
| 3410 |
t_track.SetZ(ip,zmAB[0]); |
| 3411 |
} |
| 3412 |
if(isX ){ |
| 3413 |
t_track.SetX( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
| 3414 |
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
| 3415 |
} |
| 3416 |
if(isY ){ |
| 3417 |
t_track.SetY( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
| 3418 |
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
| 3419 |
} |
| 3420 |
|
| 3421 |
t_track.SetXGood(ip,(sensor == -1 ? 0 : iclx+1),ladder,sensor); |
| 3422 |
t_track.SetYGood(ip,(sensor == -1 ? 0 : icly+1),ladder,sensor); |
| 3423 |
// t_track.SetXGood(ip,iclx+1,ladder,sensor); |
| 3424 |
// t_track.SetYGood(ip,icly+1,ladder,sensor); |
| 3425 |
|
| 3426 |
//========================================= |
| 3427 |
// evaluate other quantities |
| 3428 |
//========================================= |
| 3429 |
float smip,multmax; |
| 3430 |
if(t_track.XGood(ip)){ |
| 3431 |
if(isTrk){ |
| 3432 |
TrkCluster *cluster = _trk_l1->GetCluster(iclx); |
| 3433 |
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
| 3434 |
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
| 3435 |
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
| 3436 |
}else{ |
| 3437 |
ExtHit cluster = _cal_cl[iclx]; |
| 3438 |
smip = cluster.signal;//mip |
| 3439 |
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
| 3440 |
} |
| 3441 |
t_track.dedx_x[ip] = smip/(factor>0.?factor:1.); |
| 3442 |
t_track.multmaxx[ip] = multmax; |
| 3443 |
} |
| 3444 |
if(t_track.YGood(ip)){ |
| 3445 |
if(isTrk){ |
| 3446 |
TrkCluster *cluster = _trk_l1->GetCluster(icly); |
| 3447 |
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
| 3448 |
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
| 3449 |
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
| 3450 |
}else{ |
| 3451 |
ExtHit cluster = _cal_cl[icly]; |
| 3452 |
smip = cluster.signal;//mip |
| 3453 |
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
| 3454 |
} |
| 3455 |
t_track.dedx_y[ip] = smip/(factor>0.?factor:1.); |
| 3456 |
t_track.multmaxy[ip] = multmax; |
| 3457 |
} |
| 3458 |
} |
| 3459 |
///////////////////////////////////////////////////////// end additional info |
| 3460 |
|
| 3461 |
// ///////////////////////////////////////////////////////// RE-FIT START |
| 3462 |
t_track.Fit(0.,ifail,0);//evaluate again taking into account the track angle |
| 3463 |
if( TMath::IsNaN(t_track.chi2) )continue; |
| 3464 |
if( ifail != 0 )continue; |
| 3465 |
// ///////////////////////////////////////////////////////// RE-FIT FINISH |
| 3466 |
if(_debug){ |
| 3467 |
cout << endl; |
| 3468 |
// cout << " >> al: ";for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 3469 |
// cout << " chi2: "<<setw(10)<< t_track.chi2; |
| 3470 |
// // cout << endl; |
| 3471 |
cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
| 3472 |
cout <<" | al: "; |
| 3473 |
for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
| 3474 |
cout <<" | "; |
| 3475 |
cout << " X: "; |
| 3476 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
| 3477 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 3478 |
if(t_track.GetClusterX_ID(ip)>=0) |
| 3479 |
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
| 3480 |
else |
| 3481 |
cout << "__"; |
| 3482 |
} |
| 3483 |
cout << " | "; |
| 3484 |
cout << " Y: "; |
| 3485 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
| 3486 |
for(int ip=0; ip<t_track.nplanes; ip++){ |
| 3487 |
if(t_track.GetClusterY_ID(ip)>=0) |
| 3488 |
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
| 3489 |
else |
| 3490 |
cout << "__"; |
| 3491 |
} |
| 3492 |
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
| 3493 |
cout << " >> ADD "; |
| 3494 |
} |
| 3495 |
|
| 3496 |
_caloTj->DoTrack(t_track.al,t_track.zini); |
| 3497 |
for(int ip=0; ip<_caloTj->npoint; ip++){ |
| 3498 |
t_track.xGF[ip] = _caloTj->x[ip]; |
| 3499 |
t_track.yGF[ip] = _caloTj->y[ip]; |
| 3500 |
} |
| 3501 |
|
| 3502 |
// cout << "ADD "<<endl; |
| 3503 |
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(t_track.GetNX()+t_track.GetNY(), ExtTrack(t_track))); |
| 3504 |
if(t_track.GetNX()+t_track.GetNY()>5 && t_track.chi2<chi2Min) chi2Min=t_track.chi2; |
| 3505 |
iCand++; |
| 3506 |
}//end add-candidate condition |
| 3507 |
|
| 3508 |
}//end first loop on candidates |
| 3509 |
if(_debug)cout <<endl<< "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
| 3510 |
|
| 3511 |
|
| 3512 |
|
| 3513 |
//================================================================= |
| 3514 |
// ---------------------------------------------------------------- |
| 3515 |
// chi2 selection |
| 3516 |
// ---------------------------------------------------------------- |
| 3517 |
//================================================================= |
| 3518 |
pair <multimap<int,ExtTrack>::iterator, multimap<int,ExtTrack>::iterator> nxny[NEXTVIEWS]; |
| 3519 |
// for(int inxny=0; inxny<NEXTVIEWS; inxny++){ |
| 3520 |
bool NMTI =false;//not-minimal track inserted |
| 3521 |
for(int inxny=NEXTVIEWS-1; inxny>=nClFixX+nClFixY; inxny--){ |
| 3522 |
nxny[inxny] = trackCandidates[mapIndex].equal_range(inxny); |
| 3523 |
// cout << " --- n "<<inxny<<endl; |
| 3524 |
for ( multimap<int,ExtTrack>::iterator it = nxny[inxny].first; it!=nxny[inxny].second; ++it){ |
| 3525 |
ExtTrack &trackC = (*it).second; |
| 3526 |
// cout << " NX+NY "<< trackC.GetNX()+trackC.GetNY() <<" chi2 "<<trackC.chi2<< " R(GV) "<<trackC.GetRigidity()<<endl; |
| 3527 |
// if( trackC.chi2==0 )continue; |
| 3528 |
if( (trackC.GetNX()+trackC.GetNY() > 5 && trackC.chi2>chi2Min ) || |
| 3529 |
(trackC.GetNX()+trackC.GetNY() == 5 && NMTI ) || |
| 3530 |
(trackC.GetNX()+trackC.GetNY() == 5 && trackC.chi2>1. ) || |
| 3531 |
false)continue; |
| 3532 |
|
| 3533 |
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(inxny, ExtTrack(trackC))); |
| 3534 |
// cout << " insert "<<endl; |
| 3535 |
|
| 3536 |
if( trackC.GetNX()+trackC.GetNY() > 5 )NMTI=true; |
| 3537 |
} |
| 3538 |
} |
| 3539 |
mapIndex++; |
| 3540 |
|
| 3541 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3542 |
if( |
| 3543 |
trackCandidates[mapIndex].size()==0 || |
| 3544 |
(trackCandidates[mapIndex].size()>1 && nViewCal < _alg_nViewCal ) || |
| 3545 |
false){ |
| 3546 |
mapIndex++; |
| 3547 |
continue;//increment one calo plane |
| 3548 |
} |
| 3549 |
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
| 3550 |
|
| 3551 |
if(_debug){ |
| 3552 |
|
| 3553 |
cout<< " Selected-track SUMMARY:"<<endl; |
| 3554 |
|
| 3555 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3556 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3557 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3558 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3559 |
ExtTrack &trackCand = (*trkIter).second; |
| 3560 |
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
| 3561 |
cout <<" | al: "; |
| 3562 |
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
| 3563 |
cout <<" | "; |
| 3564 |
cout << " X: "; |
| 3565 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
| 3566 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 3567 |
if(trackCand.GetClusterX_ID(ip)>=0) |
| 3568 |
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
| 3569 |
else |
| 3570 |
cout << "__"; |
| 3571 |
} |
| 3572 |
cout << " | "; |
| 3573 |
cout << " Y: "; |
| 3574 |
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
| 3575 |
for(int ip=0; ip<trackCand.nplanes; ip++){ |
| 3576 |
if(trackCand.GetClusterY_ID(ip)>=0) |
| 3577 |
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
| 3578 |
else |
| 3579 |
cout << "__"; |
| 3580 |
} |
| 3581 |
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
| 3582 |
cout <<" MDR="<<1./sqrt(trackCand.coval[4][4])<<endl; |
| 3583 |
cout << endl; |
| 3584 |
// for(int ip=0; ip<trackCand.nplanes; ip++) |
| 3585 |
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
| 3586 |
|
| 3587 |
} |
| 3588 |
} |
| 3589 |
|
| 3590 |
|
| 3591 |
//================================================================= |
| 3592 |
// ---------------------------------------------------------------- |
| 3593 |
// save tracks |
| 3594 |
// ---------------------------------------------------------------- |
| 3595 |
//================================================================= |
| 3596 |
// cout << mapIndex << endl; |
| 3597 |
if(mapIndex>=maxSize)cout <<" ORRORE!!!! mapIndex"<<mapIndex<<" >= "<<maxSize<<endl; |
| 3598 |
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
| 3599 |
trkBegin = trackCandidates[mapIndex].begin(); |
| 3600 |
trkEnd = trackCandidates[mapIndex].end(); |
| 3601 |
iCand = 0; |
| 3602 |
// TClonesArray &tracks = *_trkArray; |
| 3603 |
// tracks.Clear(); |
| 3604 |
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
| 3605 |
ExtTrack trackCand = ((*trkIter).second); |
| 3606 |
// cout << iCand << " "<< trackCand.al[4] <<endl; |
| 3607 |
// trackCand.seqno = iCand; |
| 3608 |
// trackCand.Dump(); |
| 3609 |
new(tracks[iCand]) ExtTrack(trackCand); |
| 3610 |
iCand++; |
| 3611 |
}; |
| 3612 |
break; |
| 3613 |
|
| 3614 |
|
| 3615 |
|
| 3616 |
}// end loop over n.calo planes to be included |
| 3617 |
|
| 3618 |
|
| 3619 |
|
| 3620 |
|
| 3621 |
|
| 3622 |
} |
| 3623 |
|
| 3624 |
|
| 3625 |
/** |
| 3626 |
* |
| 3627 |
*/ |
| 3628 |
void ExtTrkingAlg::ProcessEvent(Bool_t force){ |
| 3629 |
|
| 3630 |
if(_whichAlg == 0) ProcessEvent0(force); |
| 3631 |
else if(_whichAlg >= 100 && _whichAlg < 144) ProcessEvent1(force); |
| 3632 |
else if(_whichAlg >= 200 && _whichAlg < 244) ProcessEvent2(force); |
| 3633 |
else{ |
| 3634 |
cout << " Algorythm id "<< _whichAlg <<" not implemented "<<endl; |
| 3635 |
} |
| 3636 |
|
| 3637 |
}; |
| 3638 |
/** |
| 3639 |
* |
| 3640 |
*/ |
| 3641 |
void ExtTrkingAlg::Dump(){ |
| 3642 |
|
| 3643 |
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
| 3644 |
cout << "ExtTrkingAlg::Dump() "<<endl<<endl; |
| 3645 |
cout << " algorythm "<<setw(10)<<_whichAlg <<endl; |
| 3646 |
cout << " debug "<<setw(10)<< _debug <<endl; |
| 3647 |
cout << " TrkLevel1 "<<setw(10)<<_trk_l1 <<endl; |
| 3648 |
cout << " TrkLevel2 "<<setw(10)<<_trk_l2 <<endl; |
| 3649 |
cout << " CaloLevel1"<<setw(10)<<_cal_l1 <<endl; |
| 3650 |
cout << " CaloLevel2"<<setw(10)<<_cal_l2 <<endl; |
| 3651 |
cout << " ToFLevel2 "<<setw(10)<<_tof_l2 <<endl; |
| 3652 |
cout << "Pre-selection parameters "<<endl; |
| 3653 |
cout << " nClstrMAX "<<setw(10)<<_sel_nClstrMAX <<endl; |
| 3654 |
cout << " nPlaneXMIN "<<setw(10)<<_sel_nPlaneXMIN <<endl; |
| 3655 |
cout << " nPlaneYMIN "<<setw(10)<<_sel_nPlaneYMIN <<endl; |
| 3656 |
cout << "Algorythm parameters "<<endl; |
| 3657 |
cout << " nClFixX "<<setw(10)<<_alg_nClFixX <<endl; |
| 3658 |
cout << " nClFixY "<<setw(10)<<_alg_nClFixY <<endl; |
| 3659 |
cout << " nTrackMAX "<<setw(10)<<_alg_nTrackMAX <<endl; |
| 3660 |
cout << " nViewCal "<<setw(10)<<_alg_nViewCal <<endl; |
| 3661 |
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
| 3662 |
|
| 3663 |
} |
| 3664 |
|
| 3665 |
|
| 3666 |
|
| 3667 |
//////////////////////////////////////////////////////////////////////// |
| 3668 |
// |
| 3669 |
// |
| 3670 |
// |
| 3671 |
// |
| 3672 |
//////////////////////////////////////////////////////////////////////// |
| 3673 |
// int GetSensor(int view, int sis){ |
| 3674 |
// if(sis<0||sis>8)return -1; |
| 3675 |
// if(view<0||view>1)return -1; |
| 3676 |
// if(!view)return (int)(sis/3); |
| 3677 |
// else return sis%3; |
| 3678 |
// }; |
| 3679 |
// int GetLadder(int view, int sis){ |
| 3680 |
// if(sis<0||sis>8)return -1; |
| 3681 |
// if(view<0||view>1)return -1; |
| 3682 |
// if(!view)return sis%3; |
| 3683 |
// else return (int)(sis/3); |
| 3684 |
// }; |
| 3685 |
// int GetSiSensor(int view, int l, int s){ |
| 3686 |
// if(view<0||view>1)return -1; |
| 3687 |
// if(s<0||s>2)return -1; |
| 3688 |
// if(!view) return 3*s+l; |
| 3689 |
// else return 3*l+s; |
| 3690 |
// }; |
| 3691 |
|
| 3692 |
int CaloStripRoto::GetSensor(){ |
| 3693 |
return GetCaloSensor(GetView(),GetSiSensor()); |
| 3694 |
}; |
| 3695 |
int CaloStripRoto::GetLadder(){ |
| 3696 |
return GetCaloLadder(GetView(),GetSiSensor()); |
| 3697 |
}; |
| 3698 |
|
| 3699 |
void CaloStripRoto::ResetAligParams(){ |
| 3700 |
fPitch = 1.; |
| 3701 |
shift[0]=0.; //L |
| 3702 |
shift[1]=0.; //S |
| 3703 |
shift[2]=0.; //Z |
| 3704 |
alpha = 0.; |
| 3705 |
|
| 3706 |
// siSensor = -1;; |
| 3707 |
|
| 3708 |
}; |
| 3709 |
/*1 |
| 3710 |
* |
| 3711 |
|
| 3712 |
* |
| 3713 |
*/ |
| 3714 |
bool CaloStripRoto::SensorContains(float x, float y){ |
| 3715 |
|
| 3716 |
float toll = 0.2;//cm |
| 3717 |
|
| 3718 |
// cout << "S -- SetStrip("<<GetLadder()*32+0<<")"<<endl; |
| 3719 |
|
| 3720 |
// cout << " extst.SetStrip("<<GetLadder()*32+0<<") "<<endl; |
| 3721 |
SetStrip(GetLadder()*32+0); |
| 3722 |
float xM0,yM0; |
| 3723 |
float d0 = GetDistanceTo(x,y,xM0,yM0); |
| 3724 |
|
| 3725 |
if( yM0-toll > fYB && yM0 > fYA )return false; |
| 3726 |
if( yM0+toll < fYB && yM0 < fYA )return false; |
| 3727 |
|
| 3728 |
if( xM0-toll > fXB && xM0 > fXA )return false; |
| 3729 |
if( xM0+toll < fXB && xM0 < fXA )return false; |
| 3730 |
|
| 3731 |
// cout << "D -- SetStrip("<<GetLadder()*32+31<<")"<<endl; |
| 3732 |
// cout << " extst.SetStrip("<<GetLadder()*32+31<<") "<<endl; |
| 3733 |
SetStrip(GetLadder()*32+31); |
| 3734 |
float xM31,yM31; |
| 3735 |
float d31 = GetDistanceTo(x,y,xM31,yM31); |
| 3736 |
|
| 3737 |
|
| 3738 |
if( d0+d31 > 31*fPitch*0.244+2.*toll)return false; |
| 3739 |
|
| 3740 |
return true; |
| 3741 |
|
| 3742 |
}; |
| 3743 |
|
| 3744 |
CaloStripRoto::CaloStripRoto(int view, int plane, int sisensor, Bool_t usemechanicalalignement){ |
| 3745 |
|
| 3746 |
SetView(view); |
| 3747 |
SetPlane(plane); |
| 3748 |
SetSiSensor(sisensor); |
| 3749 |
|
| 3750 |
st = CaloStrip(usemechanicalalignement); |
| 3751 |
ResetAligParams(); |
| 3752 |
if(!usemechanicalalignement){ |
| 3753 |
// cout <<" SETTA I PARAMETRI DI ALLINEAMNETO -- da implementare"<<endl; |
| 3754 |
} |
| 3755 |
|
| 3756 |
// Set(view,plane,0,GetSiSensor()); |
| 3757 |
} ///< Default Constructor. |
| 3758 |
|
| 3759 |
|
| 3760 |
|
| 3761 |
// relative to pamela reference system (convenzione emiliano): |
| 3762 |
// |
| 3763 |
// y ^ |
| 3764 |
// | |
| 3765 |
// | 6 7 8 sisensor |
| 3766 |
// | 3 4 5 |
| 3767 |
// | 0 1 2 |
| 3768 |
// ------------> x |
| 3769 |
// |
| 3770 |
// relative to silicon sensor |
| 3771 |
// |
| 3772 |
// S ^ |
| 3773 |
// | | |
| 3774 |
// 2 | | <- strip direction |
| 3775 |
// sensor 1 | | |
| 3776 |
// 0 |...|... |
| 3777 |
// ------------> L |
| 3778 |
// 0 1 2 |
| 3779 |
// ladder |
| 3780 |
// |
| 3781 |
// |
| 3782 |
void CaloStripRoto::Set(Int_t view, Int_t plane, float strip, int sisensor){ |
| 3783 |
|
| 3784 |
|
| 3785 |
SetView(view); |
| 3786 |
SetPlane(plane); |
| 3787 |
|
| 3788 |
|
| 3789 |
float size = 8.05; //(cm) larghezza del sensore + zone morte |
| 3790 |
|
| 3791 |
|
| 3792 |
//---------------------------- |
| 3793 |
// Z-coordinate |
| 3794 |
//---------------------------- |
| 3795 |
|
| 3796 |
float coordCM_strip; |
| 3797 |
if( strip >0. && strip < 95.){ |
| 3798 |
st.Set( view,plane,(int)strip);// istrip |
| 3799 |
coordCM_strip = ( view ? st.GetY() : st.GetX() ); |
| 3800 |
coordCM_strip *= (1-strip+(int)strip); |
| 3801 |
st.Set( view,plane,(int)strip+1);// istrip+1 |
| 3802 |
coordCM_strip += (strip-(int)strip)*( view ? st.GetY() : st.GetX() ); |
| 3803 |
}else{ |
| 3804 |
// cout << "CaloStripRoto::Set( "<<view<<","<<plane<<","<<strip<<","<<sisensor<<")"<<endl; |
| 3805 |
// cout << " ---> ERROR: 0 =< strip =< 95 " << endl; |
| 3806 |
if(strip>=95.)strip=95.; |
| 3807 |
if(strip<=0.)strip=0.; |
| 3808 |
st.Set( view,plane,(int)strip);// istrip |
| 3809 |
coordCM_strip = ( view ? st.GetY() : st.GetX() ); |
| 3810 |
} |
| 3811 |
float coordCm_Z0 = st.GetZ(); |
| 3812 |
//---------------------------- |
| 3813 |
// strip-segment coordinates |
| 3814 |
//---------------------------- |
| 3815 |
float coordCm_LA = coordCM_strip; |
| 3816 |
float coordCm_LB = coordCM_strip; |
| 3817 |
float coordCm_SA = (-1)*size*1.5; //full calorimeter size |
| 3818 |
float coordCm_SB = (+1)*size*1.5; //full calorimeter size |
| 3819 |
float coordCm_ZA = coordCm_Z0; |
| 3820 |
float coordCm_ZB = coordCm_Z0; |
| 3821 |
|
| 3822 |
//---------------------------- |
| 3823 |
// rototraslation |
| 3824 |
//---------------------------- |
| 3825 |
//if sisensor is assigned (0,...8) the strip can be rototraslated |
| 3826 |
bool ROTO = (sisensor>=0&&sisensor<9); |
| 3827 |
|
| 3828 |
if(ROTO){ |
| 3829 |
|
| 3830 |
|
| 3831 |
if( |
| 3832 |
GetCaloSiSensor(view,(int)(strip/32),0) != sisensor && |
| 3833 |
GetCaloSiSensor(view,(int)(strip/32),1) != sisensor && |
| 3834 |
GetCaloSiSensor(view,(int)(strip/32),2) != sisensor && |
| 3835 |
true){ |
| 3836 |
cout << " Strip "<<strip<<" does not belong to sensor "<<sisensor<<endl; |
| 3837 |
cout << " input data are inconsistent --- output might be wrong "<<endl; |
| 3838 |
} ; |
| 3839 |
|
| 3840 |
|
| 3841 |
int sensor = GetCaloSensor(view, sisensor);//0-1-2 |
| 3842 |
int ladder = GetCaloLadder(view, sisensor);//0-1-2 |
| 3843 |
if( ladder != (int)(strip / 32) ){ |
| 3844 |
cout << " void CaloStripRoto::Set(..) --- ERROR --- strip "<<strip<<" does not match Si-sensor "<<sisensor<<endl; |
| 3845 |
return; |
| 3846 |
} |
| 3847 |
|
| 3848 |
//----------------------------- |
| 3849 |
// sensor origin coordinates |
| 3850 |
//----------------------------- |
| 3851 |
|
| 3852 |
st.Set( view, plane, ladder*32); //strip = 0-32-64 |
| 3853 |
float coordCm_L0 = ( view ? st.GetY() : st.GetX()); |
| 3854 |
st.Set( (int)(!view), plane, sensor*32 );//strip = 0-32-64 |
| 3855 |
float coordCm_S0 = ( view ? st.GetX() : st.GetY()); |
| 3856 |
|
| 3857 |
//set sensor size |
| 3858 |
coordCm_SA = (-1)*size*0.5 + (sensor-1)*size; |
| 3859 |
coordCm_SB = (+1)*size*0.5 + (sensor-1)*size; |
| 3860 |
|
| 3861 |
//coordinate relative al sensore |
| 3862 |
coordCm_LA = coordCm_LA - coordCm_L0; |
| 3863 |
coordCm_SA = coordCm_SA - coordCm_S0; |
| 3864 |
coordCm_ZA = coordCm_ZA - coordCm_Z0; |
| 3865 |
coordCm_LB = coordCm_LB - coordCm_L0; |
| 3866 |
coordCm_SB = coordCm_SB - coordCm_S0; |
| 3867 |
coordCm_ZB = coordCm_ZB - coordCm_Z0; |
| 3868 |
|
| 3869 |
//variazione di pitch |
| 3870 |
coordCm_LA = coordCm_LA * fPitch; |
| 3871 |
coordCm_LB = coordCm_LB * fPitch; |
| 3872 |
|
| 3873 |
//rotazione |
| 3874 |
float LA = coordCm_LA - alpha * coordCm_SA; |
| 3875 |
float SA = coordCm_SA + alpha * coordCm_LA; |
| 3876 |
float LB = coordCm_LB - alpha * coordCm_SB; |
| 3877 |
float SB = coordCm_SB + alpha * coordCm_LB; |
| 3878 |
|
| 3879 |
//traslazione |
| 3880 |
coordCm_LA = LA + (!view ? shift[0] : shift[1]); |
| 3881 |
coordCm_SA = SA + ( view ? shift[1] : shift[0]); |
| 3882 |
coordCm_ZA = coordCm_ZA + shift[2]; |
| 3883 |
coordCm_LB = LB + shift[0]; |
| 3884 |
coordCm_SB = SB + shift[1]; |
| 3885 |
coordCm_ZB = coordCm_ZB + shift[2]; |
| 3886 |
|
| 3887 |
//back to sistema di riferimento generale |
| 3888 |
|
| 3889 |
coordCm_LA = coordCm_LA + coordCm_L0; |
| 3890 |
coordCm_SA = coordCm_SA + coordCm_S0; |
| 3891 |
coordCm_ZA = coordCm_ZA + coordCm_Z0; |
| 3892 |
coordCm_LB = coordCm_LB + coordCm_L0; |
| 3893 |
coordCm_SB = coordCm_SB + coordCm_S0; |
| 3894 |
coordCm_ZB = coordCm_ZB + coordCm_Z0; |
| 3895 |
|
| 3896 |
} |
| 3897 |
|
| 3898 |
fXA = (!view ? coordCm_LA : coordCm_SA); |
| 3899 |
fYA = ( view ? coordCm_LA : coordCm_SA); |
| 3900 |
fZA = coordCm_ZA; |
| 3901 |
|
| 3902 |
fXB = (!view ? coordCm_LB : coordCm_SB); |
| 3903 |
fYB = ( view ? coordCm_LB : coordCm_SB); |
| 3904 |
fZB = coordCm_ZB; |
| 3905 |
|
| 3906 |
|
| 3907 |
st.Set(view,plane,(int)strip);// istrip |
| 3908 |
|
| 3909 |
}; |
| 3910 |
// |
| 3911 |
// |
| 3912 |
// |
| 3913 |
// |
| 3914 |
// |
| 3915 |
// |
| 3916 |
float CaloStripRoto::GetSpatialResolution(float def, float degx, float degy, float beta){ |
| 3917 |
|
| 3918 |
float res_dig = 0.24/sqrt(12.); |
| 3919 |
|
| 3920 |
if(def==0.)return res_dig; |
| 3921 |
|
| 3922 |
float res_ms = 0.; |
| 3923 |
|
| 3924 |
// Int_t GetView(){return (fView-1);} ///< Get strip view [0-1] |
| 3925 |
// Int_t GetPlane(){return (fPlane-1);} ///< Get strip plane [0-21] |
| 3926 |
// Int_t GetStrip(){return (fStrip-1);} ///< Get strip number [0-95] |
| 3927 |
|
| 3928 |
|
| 3929 |
float rig = 1/def; if(rig<0)rig = -rig; |
| 3930 |
float factor = 0.; |
| 3931 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*degx/180.),2); |
| 3932 |
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*degy/180.),2); |
| 3933 |
factor += 1.; |
| 3934 |
factor = TMath::Sqrt(factor); |
| 3935 |
|
| 3936 |
int view = st.GetPlane()*2 + 1 - st.GetView() ;//cluster.view; //0... 43 |
| 3937 |
|
| 3938 |
// int nW = (int)((view + 1)/2); |
| 3939 |
float dW = 0.74*factor;//X0 |
| 3940 |
float dW_cm = 0.26*factor;//cm |
| 3941 |
float dSi_cm = 0.; //cm |
| 3942 |
if(view && st.GetPlane()>0) dSi_cm = ( st.GetPlane()%2 ? 0.228 : 0.428); |
| 3943 |
dSi_cm *= factor; |
| 3944 |
// multiple scattering angle |
| 3945 |
float theta = 0.;//ms |
| 3946 |
theta = 0.0136/rig; |
| 3947 |
theta = theta * sqrt(dW) * (1.+0.038*log(dW)); |
| 3948 |
float Vt = theta*theta; //cov(theta,theta) |
| 3949 |
float Vy = Vt * dW_cm * dW_cm /3.; //cov(y,y) |
| 3950 |
float Vty = 0.87 * Vt * Vy; //cov(theta,y) |
| 3951 |
float Vc = Vy + dSi_cm * dSi_cm * Vt + 2. * dSi_cm * Vty; |
| 3952 |
float rms = sqrt( Vc ); |
| 3953 |
// if(isY)t_track.resy[ip] = sqrt(rms*rms + t_track.resy[ip]*t_track.resy[ip]); |
| 3954 |
// else t_track.resx[ip] = sqrt(rms*rms + t_track.resx[ip]*t_track.resx[ip]); |
| 3955 |
// if(isY) VMS[nW] = rms*rms; |
| 3956 |
// if(_debug)cout <<endl<<view<<" nW "<<nW<<" res(MS) "<<rms<<" factor "<<factor; |
| 3957 |
|
| 3958 |
if(view>=3){ |
| 3959 |
cout << " --> NB resolution not accurate for layer "<<view<<endl;; |
| 3960 |
cout <<"st.GetPlane() "<<st.GetPlane()<<endl; |
| 3961 |
cout <<"st.GetView() "<<st.GetView()<<endl; |
| 3962 |
} |
| 3963 |
res_ms = rms; |
| 3964 |
|
| 3965 |
return sqrt(res_ms*res_ms + res_dig*res_dig); |
| 3966 |
|
| 3967 |
}; |
| 3968 |
/** |
| 3969 |
* |
| 3970 |
* |
| 3971 |
* |
| 3972 |
* |
| 3973 |
*/ |
| 3974 |
float CaloStripRoto::GetDistanceTo(float xP, float yP, float& xM, float &yM ){ |
| 3975 |
|
| 3976 |
|
| 3977 |
bool isX = fabs(fXA-fXB) < fabs(fYA-fYB); |
| 3978 |
|
| 3979 |
|
| 3980 |
if(isX){ |
| 3981 |
float beta = (fXB-fXA)/(fYB-fYA); |
| 3982 |
float alpha = fXA - beta * fYA; |
| 3983 |
yM = ( yP + beta*xP - beta*alpha )/(1+beta*beta); |
| 3984 |
xM = alpha + beta * yM; |
| 3985 |
}else{ |
| 3986 |
float beta = (fYB-fYA)/(fXB-fXA); |
| 3987 |
float alpha = fYA - beta * fXA; |
| 3988 |
xM = ( xP + beta*yP - beta*alpha )/(1+beta*beta); |
| 3989 |
yM = alpha + beta * xM; |
| 3990 |
} |
| 3991 |
|
| 3992 |
return sqrt((xM-xP)*(xM-xP) + (yM-yP)*(yM-yP)); |
| 3993 |
|
| 3994 |
}; |