9 |
using namespace std; |
using namespace std; |
10 |
/** |
/** |
11 |
* Constructor |
* 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){ |
ExtTrkingAlg::ExtTrkingAlg(Int_t id){ |
24 |
|
|
25 |
_whichAlg = id; |
_whichAlg = id; |
26 |
|
|
27 |
|
|
28 |
SetDebug(false); |
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 |
double pars[] = {20.,3.,2.}; |
// }else if (id == 1 ){ |
55 |
SetSelectionParams(pars); |
}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 |
double para[] = {3.,2.,400.}; |
_caloStripRoto.clear(); |
102 |
SetAlgorythmParams(para); |
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 |
if(id == 0){ |
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 |
cout << "ExtTrkingAlg::ExtTrkingAlg("<<id<<")"<<endl; |
if(!fs.is_open()){ |
123 |
cout << "Creating array of TrkTrack objects "<<endl; |
|
124 |
_trkArray = new TClonesArray("TrkTrack"); |
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{ |
}else{ |
181 |
|
if ( _debug ){ |
182 |
cout << "ExtTrkingAlg(Int_t id) -- algorythm id="<<id<<" not valid "<<endl; |
cout << "ExtTrkingAlg(Int_t id) -- algorythm id="<<id<<" not valid "<<endl; |
183 |
cout << "--> Track array not created "<<endl; |
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(); |
Clear(); |
220 |
|
|
221 |
}; |
}; |
223 |
/** |
/** |
224 |
* Reset the algorythm flags and output |
* Reset the algorythm flags and output |
225 |
*/ |
*/ |
226 |
void ExtTrkingAlg::Reset(){ |
// void ExtTrkingAlg::Reset(){ |
|
|
|
|
if(_trkArray)_trkArray->Clear("C"); |
|
227 |
|
|
228 |
|
// if(_trkArray)_trkArray->Clear("C"); |
229 |
|
|
230 |
}; |
// }; |
231 |
|
|
232 |
/** |
/** |
233 |
* Clear the event and reset the algorythm |
* Clear the event and reset the algorythm |
242 |
SetCaloLevel1(); |
SetCaloLevel1(); |
243 |
SetCaloLevel2(); |
SetCaloLevel2(); |
244 |
|
|
245 |
Reset(); |
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 |
* Set selection parameters |
262 |
*/ |
*/ |
275 |
_alg_nClFixX = (Int_t)par[0]; // algorythm parameter: n.hits required on X view |
_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 |
_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 |
_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 |
/** |
/** |
285 |
*/ |
*/ |
286 |
TClonesArray* ExtTrkingAlg::GetTrackArray(Bool_t reset){ |
TClonesArray* ExtTrkingAlg::GetTrackArray(Bool_t reset){ |
287 |
|
|
288 |
if( reset ) Reset(); |
if( reset && _trkArray) _trkArray->Clear("C"); |
289 |
// if( !_procDone )ProcessEvent(); |
// if( !_procDone )ProcessEvent(); |
290 |
|
|
291 |
return _trkArray; |
return _trkArray; |
296 |
*/ |
*/ |
297 |
Bool_t ExtTrkingAlg::CheckEvent(){ |
Bool_t ExtTrkingAlg::CheckEvent(){ |
298 |
|
|
299 |
if(!_trk_l2)return true; |
if(!_trk_l1)return false; |
300 |
|
TrkLevel1 *trkl1 = _trk_l1;//event->GetTrkLevel1(); |
|
TrkLevel2 *trkl2 = _trk_l2;//event->GetTrkLevel2(); |
|
301 |
int nClstrMAX = _sel_nClstrMAX; //maximum number of cluster |
int nClstrMAX = _sel_nClstrMAX; //maximum number of cluster |
302 |
int nPlaneXMIN = _sel_nPlaneXMIN; |
///////////////////////////////////////////////////////////////////// |
303 |
int nPlaneYMIN = _sel_nPlaneYMIN; |
/// 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 |
/// 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}; |
int nHitX[] = {0,0,0,0,0,0}; |
315 |
int nHitY[] = {0,0,0,0,0,0}; |
int nHitY[] = {0,0,0,0,0,0}; |
316 |
for(int ix=0; ix<trkl2->nclsx(); ix++)nHitX[trkl2->GetSingletX(ix)->plane-1]++; |
for(int ic=0; ic<trkl1->nclstr(); ic++){ |
317 |
for(int iy=0; iy<trkl2->nclsy(); iy++)nHitY[trkl2->GetSingletY(iy)->plane-1]++; |
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 |
/// set minimum condition 3x+2y |
322 |
///////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////// |
324 |
for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++; |
for(int ip=0; ip<6; ip++)if(nHitX[ip])nPlaneX++; |
325 |
int nPlaneY=0; |
int nPlaneY=0; |
326 |
for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++; |
for(int ip=0; ip<6; ip++)if(nHitY[ip])nPlaneY++; |
327 |
|
|
328 |
///////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////// |
329 |
/// dump selection |
/// dump selection |
330 |
///////////////////////////////////////////////////////////////////// |
///////////////////////////////////////////////////////////////////// |
331 |
if(_debug){ |
if(_debug){ |
332 |
cout << " n.tracks "<<trkl2->GetNTracks()<<endl; |
cout << " n.x-hit planes "<<nPlaneX<<endl; |
333 |
cout << " n.x-singles "<<trkl2->nclsx()<<endl; |
cout << " n.y-hit planes "<<nPlaneY<<endl; |
334 |
cout << " n.y-singles "<<trkl2->nclsy()<<endl; |
} |
335 |
cout << " n.x-planes with singles "<<nPlaneX<<endl; |
if( nPlaneX<nPlaneXMIN ) return false; |
336 |
cout << " n.y-planes with singles "<<nPlaneY<<endl; |
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 |
// check condition for retracking |
377 |
// |
// |
378 |
//////////////////////////////////////////////////////////////////////// |
//////////////////////////////////////////////////////////////////////// |
379 |
if(trkl2->GetNTracks()==0 && nPlaneX<nPlaneXMIN) return false; |
// if(trkl2->GetNTracks()==0 && nPlaneX<nPlaneXMIN) return false; |
380 |
if(trkl2->GetNTracks()==0 && nPlaneY<nPlaneYMIN) return false; |
// if(trkl2->GetNTracks()==0 && nPlaneY<nPlaneYMIN) return false; |
|
if(trkl2->nclsy()+trkl2->nclsx() > nClstrMAX) return false; |
|
381 |
|
|
382 |
return true; |
return true; |
383 |
|
|
387 |
/** |
/** |
388 |
* Process the event |
* Process the event |
389 |
*/ |
*/ |
390 |
void ExtTrkingAlg::ProcessEvent(Bool_t force){ |
void ExtTrkingAlg::ProcessEvent0(Bool_t force){ |
391 |
|
|
392 |
if(_debug)cout << " |---------------------------------------------------| "<<endl; |
if(_debug)cout << " |---------------------------------------------------| "<<endl; |
393 |
if(_debug)cout << " void ExtTrkingAlg::ProcessEvent("<<force<<") "<<endl; |
if(_debug)cout << " void ExtTrkingAlg::ProcessEvent0("<<force<<") "<<endl; |
394 |
|
|
395 |
|
|
396 |
if(_debug && !_trk_l1)cout << " Missing TrkLevel1 object --- ciao! "<<endl; |
if(_debug && !_trk_l1)cout << " Missing TrkLevel1 object --- ciao! "<<endl; |
411 |
// tracking |
// tracking |
412 |
//=========================== |
//=========================== |
413 |
|
|
414 |
TClonesArray &tracks = *_trkArray; |
// TClonesArray &tracks = *_trkArray; |
415 |
tracks.Clear(); |
// tracks.Clear(); |
416 |
|
|
417 |
|
|
418 |
multimap<int,TrkTrack> trackCandidates[12]; // map: last filled view vs TrkTrack |
multimap<int,TrkTrack> trackCandidates[12]; // map: last filled view vs TrkTrack |
419 |
int mapIndex = 0; |
int mapIndex = 0; |
420 |
multimap<int,TrkTrack>::iterator trkBegin; |
multimap<int,TrkTrack>::iterator trkBegin; |
542 |
}//end iterations |
}//end iterations |
543 |
|
|
544 |
|
|
545 |
if( trackCandidates[mapIndex].size() > nTrackMAX ){ |
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; |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<" > "<<nTrackMAX<<endl; |
547 |
return;//to many candidates |
return;//to many candidates |
548 |
} |
} |
554 |
cout << " >> "; |
cout << " >> "; |
555 |
cout << " X: "; |
cout << " X: "; |
556 |
for(int ip=0; ip<6; ip++) |
for(int ip=0; ip<6; ip++) |
557 |
if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
558 |
cout << " Y: "; |
cout << " Y: "; |
559 |
for(int ip=0; ip<6; ip++) |
for(int ip=0; ip<6; ip++) |
560 |
if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
561 |
cout << endl; |
cout << endl; |
562 |
} |
} |
563 |
} |
} |
564 |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
565 |
|
|
566 |
//============================================================== |
//============================================================== |
567 |
// ------------------------------------------------------------- |
// ------------------------------------------------------------- |
568 |
// first selection of track candidates, based on chi2 |
// first selection of track candidates, based on chi2 |
569 |
// ------------------------------------------------------------- |
// ------------------------------------------------------------- |
629 |
// ----------------------------------- |
// ----------------------------------- |
630 |
// evaluate calorimeter variables |
// evaluate calorimeter variables |
631 |
// ----------------------------------- |
// ----------------------------------- |
632 |
float caloCoord[2][22][96]; |
// float caloCoord[2][22][96]; |
633 |
float caloZ[44]; |
// float caloZ[44]; |
634 |
for(int view=0; view<2; view++){ |
// for(int view=0; view<2; view++){ |
635 |
for(int plane=0; plane<22; plane++){ |
// for(int plane=0; plane<22; plane++){ |
636 |
for(int strip=0; strip<96; strip++){ |
// for(int strip=0; strip<96; strip++){ |
637 |
CaloStrip st = CaloStrip(false); |
// CaloStrip st = CaloStrip(false); |
638 |
st.Set(view,plane,strip); |
// st.Set(view,plane,strip); |
639 |
caloCoord[view][plane][strip]=(view ? st.GetY() : st.GetX()); |
// caloCoord[view][plane][strip]=(view ? st.GetY() : st.GetX()); |
640 |
caloZ[plane*2+(view?0:1)]=st.GetZ(); |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
641 |
} |
// } |
642 |
} |
// } |
643 |
} |
// } |
644 |
Trajectory caloTj = Trajectory(44,caloZ); |
// Trajectory caloTj = Trajectory(44,caloZ); |
645 |
// for(int iz=0; iz<44;iz++)cout<<caloZ[iz]<<endl; |
// for(int iz=0; iz<44;iz++)cout<<caloZ[iz]<<endl; |
646 |
//test calo |
//test calo |
647 |
// float caloEvent[2][22][96]; |
// float caloEvent[2][22][96]; |
655 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
656 |
TrkTrack trackCand = ((*trkIter).second); |
TrkTrack trackCand = ((*trkIter).second); |
657 |
|
|
658 |
trackCand.DoTrack(&caloTj);//integrate the trajectory through the calorimeter |
trackCand.DoTrack(_caloTj);//integrate the trajectory through the calorimeter |
659 |
|
|
660 |
float chi2 = 0.; |
float chi2 = 0.; |
661 |
int nhit = 0; |
int nhit = 0; |
669 |
if(plane<0)continue; |
if(plane<0)continue; |
670 |
if(strip<0)continue; |
if(strip<0)continue; |
671 |
if(mip<=0)continue; |
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)]); |
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.); |
if(plane<11) chi2+= mip * TMath::Power(dxy,2.); |
674 |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
675 |
if( fabs(dxy) < 2. && plane<11)nhit++; |
if( fabs(dxy) < 2. && plane<11)nhit++; |
986 |
trkBegin = trackCandidates[mapIndex].begin(); |
trkBegin = trackCandidates[mapIndex].begin(); |
987 |
trkEnd = trackCandidates[mapIndex].end(); |
trkEnd = trackCandidates[mapIndex].end(); |
988 |
iCand = 0; |
iCand = 0; |
989 |
|
TClonesArray &tracks = *_trkArray; |
990 |
|
tracks.Clear(); |
991 |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
for( multimap<int,TrkTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
992 |
TrkTrack trackCand = ((*trkIter).second); |
TrkTrack trackCand = ((*trkIter).second); |
993 |
trackCand.seqno = iCand; |
trackCand.seqno = iCand; |
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::Dump(){ |
void ExtTrkingAlg::FillClusterMap(multimap<int,int> &map,CaloLevel1* l1,Int_t vOffset){ |
1042 |
|
|
1043 |
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
if(_debug)cout<<"-------- CALO CLUSTERs -------- on VIEW < "<<_alg_nViewCal<<endl; |
1044 |
cout << "ExtTrkingAlg::Dump() "<<endl<<endl; |
|
1045 |
cout << " algorythm "<<setw(10)<<_whichAlg <<endl; |
if(_alg_nViewCal<=0)return; |
1046 |
cout << " debug "<<setw(10)<< _debug <<endl; |
|
1047 |
cout << " TrkLevel1 "<<setw(10)<<_trk_l1 <<endl; |
_cal_cl.clear(); |
1048 |
cout << " TrkLevel2 "<<setw(10)<<_trk_l2 <<endl; |
|
1049 |
cout << " CaloLevel1"<<setw(10)<<_cal_l1 <<endl; |
if(!l1)return; |
1050 |
cout << " CaloLevel2"<<setw(10)<<_cal_l2 <<endl; |
|
1051 |
cout << " ToFLevel2 "<<setw(10)<<_tof_l2 <<endl; |
|
1052 |
cout << "Pre-selection parameters "<<endl; |
// ========================== |
1053 |
cout << " nClstrMAX "<<setw(10)<<_sel_nClstrMAX <<endl; |
// CALORIMETER CLUSTERING |
1054 |
cout << " nPlaneXMIN "<<setw(10)<<_sel_nPlaneXMIN <<endl; |
// ========================== |
1055 |
cout << " nPlaneYMIN "<<setw(10)<<_sel_nPlaneYMIN <<endl; |
CaloStrip st = CaloStrip(false); |
1056 |
cout << "Algorythm parameters "<<endl; |
ExtHit *caloCl=NULL; |
1057 |
cout << " nClFixX "<<setw(10)<<_alg_nClFixX <<endl; |
Int_t nCl = 0; |
1058 |
cout << " nClFixY "<<setw(10)<<_alg_nClFixY <<endl; |
for(Int_t ih=0; ih<l1->istrip; ih++){//loop over calorimeter hits |
1059 |
cout << " nTrackMAX "<<setw(10)<<_alg_nTrackMAX <<endl; |
Int_t view = -1; // 0-x 1-y |
1060 |
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
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.ResetFit(); |
2933 |
|
trackCand.Fit(0.,ifail,0); |
2934 |
|
if(ifail!=0)trackCand.ResetFit(); |
2935 |
|
|
2936 |
|
// trackCand.Dump(); |
2937 |
|
|
2938 |
|
|
2939 |
|
// ----------------------------------- |
2940 |
|
// first selection of track candidates |
2941 |
|
// ----------------------------------- |
2942 |
|
if(TMath::IsNaN(trackCand.chi2))continue; |
2943 |
|
if(trackCand.chi2 <= 0. || trackCand.chi2 > 1.e7)continue; |
2944 |
|
// if(trackCand.chi2 < 0. || trackCand.chi2 > 10. )continue; |
2945 |
|
iCand++; |
2946 |
|
|
2947 |
|
if(_debug){ |
2948 |
|
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
2949 |
|
cout <<" | al: "; |
2950 |
|
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
2951 |
|
cout <<" | "; |
2952 |
|
cout << " X: "; |
2953 |
|
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
2954 |
|
// for(int ip=0; ip<trackCand.nplanes; ip++) |
2955 |
|
// if(trackCand.GetClusterX_ID(ip)>=0)cout << trackCand.GetClusterX_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; |
2956 |
|
cout << " | "; |
2957 |
|
cout << " Y: "; |
2958 |
|
for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
2959 |
|
cout << endl; |
2960 |
|
// for(int ip=0; ip<trackCand.nplanes; ip++) |
2961 |
|
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
2962 |
|
} |
2963 |
|
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
2964 |
|
|
2965 |
|
} |
2966 |
|
|
2967 |
|
|
2968 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
2969 |
|
if(trackCandidates[mapIndex].size()==0){ |
2970 |
|
mapIndex++; |
2971 |
|
continue;//increment one calo plane |
2972 |
|
} |
2973 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
2974 |
|
|
2975 |
|
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
2976 |
|
|
2977 |
|
|
2978 |
|
|
2979 |
|
//================================================================= |
2980 |
|
// ---------------------------------------------------------------- |
2981 |
|
// CALORIMETER |
2982 |
|
// ---------------------------------------------------------------- |
2983 |
|
//================================================================= |
2984 |
|
if(_cal_l1){ |
2985 |
|
if(_debug)cout<<"-------- CALORIMETER --------"<<endl; |
2986 |
|
|
2987 |
|
CaloLevel1* l1=_cal_l1;//event->GetCaloLevel1(); |
2988 |
|
// if(!l1)return; |
2989 |
|
vector<float> caloChi2; |
2990 |
|
vector<int> caloHit; int caloHitMAX=0; |
2991 |
|
vector<float> caloMip; |
2992 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
2993 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
2994 |
|
trkEnd = trackCandidates[mapIndex].end(); |
2995 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
2996 |
|
ExtTrack trackCand = ((*trkIter).second); |
2997 |
|
|
2998 |
|
// trackCand.DoTrack(&caloTj);//integrate the trajectory through the calorimeter |
2999 |
|
_caloTj->DoTrack(trackCand.al,trackCand.zini); |
3000 |
|
// _caloTj->Dump(); |
3001 |
|
|
3002 |
|
float chi2 = 0.; |
3003 |
|
int nhit = 0; |
3004 |
|
float cmip = 0.; |
3005 |
|
for(Int_t ih=0; ih<l1->istrip; ih++){ |
3006 |
|
Int_t view = -1; |
3007 |
|
Int_t plane = -1; |
3008 |
|
Int_t strip = -1; |
3009 |
|
Float_t mip = l1->DecodeEstrip(ih,view,plane,strip); |
3010 |
|
if(view<0)continue; |
3011 |
|
if(plane<0)continue; |
3012 |
|
if(strip<0)continue; |
3013 |
|
if(mip<=0)continue; |
3014 |
|
float dxy = _caloCoord[view][plane][strip]-(view?_caloTj->y[plane*2+(view?0:1)]:_caloTj->x[plane*2+(view?0:1)]); |
3015 |
|
if(plane<11) chi2+= mip * TMath::Power(dxy,2.); |
3016 |
|
// caloZ[plane*2+(view?0:1)]=st.GetZ(); |
3017 |
|
if( fabs(dxy) < 2. && plane<11)nhit++; |
3018 |
|
if( fabs(dxy) < 2. && plane<11)cmip+=mip; |
3019 |
|
}; |
3020 |
|
if(l1->istrip>0)chi2 = chi2/l1->istrip; |
3021 |
|
|
3022 |
|
caloHit.push_back(nhit); |
3023 |
|
if(nhit>caloHitMAX)caloHitMAX=nhit; |
3024 |
|
|
3025 |
|
if(_debug){ |
3026 |
|
cout << " CALO "; |
3027 |
|
// cout << " chi2 "<< chi2 <<" "; |
3028 |
|
cout << " nhit (< 11th plane) "<< nhit <<" "; |
3029 |
|
// cout << " mip "<< cmip <<" "; |
3030 |
|
cout <<endl; |
3031 |
|
}; |
3032 |
|
} |
3033 |
|
|
3034 |
|
//================================================================= |
3035 |
|
// ---------------------------------------------------------------- |
3036 |
|
// selection of track candidates, based on n.calorimeter hits |
3037 |
|
// ---------------------------------------------------------------- |
3038 |
|
//================================================================= |
3039 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3040 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3041 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3042 |
|
mapIndex++; |
3043 |
|
iCand = 0; |
3044 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3045 |
|
int lastView = (*trkIter).first; |
3046 |
|
ExtTrack &trackCand = (*trkIter).second; |
3047 |
|
if(caloHit[iCand]==caloHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, trackCand)); |
3048 |
|
iCand++; |
3049 |
|
} |
3050 |
|
|
3051 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3052 |
|
if(trackCandidates[mapIndex].size()==0){ |
3053 |
|
mapIndex++; |
3054 |
|
continue;//increment one calo plane |
3055 |
|
} |
3056 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3057 |
|
|
3058 |
|
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
3059 |
|
|
3060 |
|
}// end if calo event |
3061 |
|
|
3062 |
|
|
3063 |
|
|
3064 |
|
|
3065 |
|
//================================================================= |
3066 |
|
// ---------------------------------------------------------------- |
3067 |
|
// TOF |
3068 |
|
// ---------------------------------------------------------------- |
3069 |
|
//================================================================= |
3070 |
|
if(_tof_l2){ |
3071 |
|
if(_debug)cout<<"-------- TOF --------"<<endl; |
3072 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3073 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3074 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3075 |
|
ToFLevel2* tl2=_tof_l2;//event->GetToFLevel2(); |
3076 |
|
// if(!tl2)return; |
3077 |
|
iCand =0; |
3078 |
|
vector<int> tofHit; int tofHitMAX=0; |
3079 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3080 |
|
// int lastView = (*trkIter).first; |
3081 |
|
ExtTrack &trackCand = (*trkIter).second; |
3082 |
|
|
3083 |
|
_tgf->DoTrack(trackCand.al);//<<<< integrate the trajectory |
3084 |
|
|
3085 |
|
for(int ip=0; ip<TrkParams::nGF; ip++){ |
3086 |
|
trackCand.xGF[ip] = _tgf->x[ip]; |
3087 |
|
trackCand.yGF[ip] = _tgf->y[ip]; |
3088 |
|
} |
3089 |
|
|
3090 |
|
int nhit =0; |
3091 |
|
for(int iToF=0; iToF<6; iToF++){ |
3092 |
|
|
3093 |
|
int iGF = iToF; |
3094 |
|
if(iToF>3)iGF = iToF+8; |
3095 |
|
int iPaddle = tl2->GetPaddleIdOfTrack( trackCand.xGF[iGF], trackCand.yGF[iGF], iToF); |
3096 |
|
if( tl2->HitPaddle(iToF,iPaddle) )nhit++; |
3097 |
|
|
3098 |
|
} |
3099 |
|
iCand++; |
3100 |
|
|
3101 |
|
tofHit.push_back(nhit); |
3102 |
|
if(nhit>tofHitMAX)tofHitMAX=nhit; |
3103 |
|
|
3104 |
|
if(_debug){ |
3105 |
|
cout << " TOF nhit "<< nhit <<" "; |
3106 |
|
cout <<endl; |
3107 |
|
} |
3108 |
|
|
3109 |
|
|
3110 |
|
} |
3111 |
|
//================================================================= |
3112 |
|
// ---------------------------------------------------------------- |
3113 |
|
// selection of track candidates, based on n.tof hits |
3114 |
|
// ---------------------------------------------------------------- |
3115 |
|
//================================================================= |
3116 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3117 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3118 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3119 |
|
mapIndex++; |
3120 |
|
iCand = 0; |
3121 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3122 |
|
int lastView = (*trkIter).first; |
3123 |
|
ExtTrack &trackCand = (*trkIter).second; |
3124 |
|
if(tofHit[iCand]==tofHitMAX)trackCandidates[mapIndex].insert(pair<int,ExtTrack>(lastView, ExtTrack(trackCand))); |
3125 |
|
iCand++; |
3126 |
|
|
3127 |
|
} |
3128 |
|
if(_debug)cout << "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
3129 |
|
|
3130 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3131 |
|
if(trackCandidates[mapIndex].size()==0){ |
3132 |
|
mapIndex++; |
3133 |
|
continue;//increment one calo plane |
3134 |
|
} |
3135 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3136 |
|
|
3137 |
|
} |
3138 |
|
|
3139 |
|
if(_debug){ |
3140 |
|
|
3141 |
|
cout<< " Minimal-track SUMMARY:"<<endl; |
3142 |
|
|
3143 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3144 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3145 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3146 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3147 |
|
ExtTrack &trackCand = (*trkIter).second; |
3148 |
|
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
3149 |
|
cout <<" | al: "; |
3150 |
|
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
3151 |
|
cout <<" | "; |
3152 |
|
cout << " X: "; |
3153 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
3154 |
|
for(int ip=0; ip<trackCand.nplanes; ip++){ |
3155 |
|
if(trackCand.GetClusterX_ID(ip)>=0) |
3156 |
|
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
3157 |
|
else |
3158 |
|
cout << "__"; |
3159 |
|
} |
3160 |
|
cout << " | "; |
3161 |
|
cout << " Y: "; |
3162 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
3163 |
|
for(int ip=0; ip<trackCand.nplanes; ip++){ |
3164 |
|
if(trackCand.GetClusterY_ID(ip)>=0) |
3165 |
|
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
3166 |
|
else |
3167 |
|
cout << "__"; |
3168 |
|
} |
3169 |
|
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
3170 |
|
cout << endl; |
3171 |
|
|
3172 |
|
} |
3173 |
|
} |
3174 |
|
//================================================================= |
3175 |
|
// ---------------------------------------------------------------- |
3176 |
|
// TRACK MERGING |
3177 |
|
// ---------------------------------------------------------------- |
3178 |
|
//================================================================= |
3179 |
|
if(_debug)cout<<"-------- MERGING --------"; |
3180 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3181 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3182 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3183 |
|
mapIndex++; |
3184 |
|
float chi2Min=1e10; |
3185 |
|
iCand = 0; |
3186 |
|
for( multimap<int,ExtTrack>::iterator trkIter1 = trkBegin; trkIter1!=trkEnd; ++trkIter1){ //loop over tracks (1) |
3187 |
|
|
3188 |
|
ExtTrack &trackCand1 = (*trkIter1).second;// get candidate 1... |
3189 |
|
|
3190 |
|
ExtTrack t_track = ExtTrack();// ...create a new ExtTrack instance... |
3191 |
|
trackCand1.Copy(t_track); // ...and make a copy |
3192 |
|
|
3193 |
|
bool HBM = false; //has been merged |
3194 |
|
|
3195 |
|
for( multimap<int,ExtTrack>::iterator trkIter2 = trkBegin; trkIter2!=trkEnd; ++trkIter2){//loop over tracks (2) |
3196 |
|
|
3197 |
|
ExtTrack &trackCand2 = (*trkIter2).second; // get candidate 2... |
3198 |
|
|
3199 |
|
bool CBM = true; |
3200 |
|
for(int ip=0; ip<NEXTPLANES; ip++){ //loop over planes |
3201 |
|
if( t_track.XGood(ip) && |
3202 |
|
trackCand2.XGood(ip) && |
3203 |
|
( t_track.GetClusterX_ID(ip)!=trackCand2.GetClusterX_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
3204 |
|
true )CBM=false; // if both have a x-hit and it is not the same ---> they cannot be merged |
3205 |
|
if(!CBM)break; |
3206 |
|
if( t_track.YGood(ip) && |
3207 |
|
trackCand2.YGood(ip) && |
3208 |
|
( t_track.GetClusterY_ID(ip)!=trackCand2.GetClusterY_ID(ip) || t_track.GetSensor(ip)!=trackCand2.GetSensor(ip) ) && |
3209 |
|
true )CBM=false; // if both have a y-hit and it is not the same ---> they cannot be merged |
3210 |
|
if(!CBM)break; |
3211 |
|
} |
3212 |
|
// if(_debug)cout << " can be merged ? "<<CBM<<endl; |
3213 |
|
if(!CBM)continue; //go to the next candidate |
3214 |
|
/////////// |
3215 |
|
//merging// |
3216 |
|
/////////// |
3217 |
|
// cout <<endl<<" check merging al (1) "; |
3218 |
|
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
3219 |
|
// cout <<endl<<" with al (2) "; |
3220 |
|
// for(int i=0; i<5; i++)cout <<setw(10)<< trackCand2.al[i]; |
3221 |
|
for(int ip=0; ip<NEXTPLANES; ip++){ |
3222 |
|
if( !(t_track.XGood(ip)) && trackCand2.XGood(ip) ){ |
3223 |
|
int ygood_temp = t_track.ygood[ip]; |
3224 |
|
|
3225 |
|
if(t_track.YGood(ip)){ |
3226 |
|
t_track.SetXY(ip,trackCand2.xm[ip],t_track.ym[ip],trackCand2.resx[ip],t_track.resy[ip]); |
3227 |
|
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
3228 |
|
}else{ |
3229 |
|
t_track.SetX(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resx[ip]); |
3230 |
|
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
3231 |
|
} |
3232 |
|
t_track.xgood[ip] = trackCand2.xgood[ip];//assign cluster + sensor |
3233 |
|
t_track.ygood[ip] = ygood_temp;//assign cluster + sensor |
3234 |
|
|
3235 |
|
HBM = true; |
3236 |
|
} |
3237 |
|
if( !(t_track.YGood(ip)) && trackCand2.YGood(ip) ) { |
3238 |
|
|
3239 |
|
int xgood_temp = t_track.xgood[ip]; |
3240 |
|
|
3241 |
|
if(t_track.XGood(ip)){ |
3242 |
|
t_track.SetXY(ip,t_track.xm[ip],trackCand2.ym[ip],t_track.resx[ip],trackCand2.resy[ip]); |
3243 |
|
// cout<<"confronta "<<trackCand2.zm[ip]<<" - "<<t_track.zm[ip]<<" = "<<trackCand2.zm[ip]-t_track.zm[ip]<<endl; |
3244 |
|
}else{ |
3245 |
|
t_track.SetY(ip,trackCand2.xma[ip],trackCand2.xmb[ip],trackCand2.yma[ip],trackCand2.ymb[ip],trackCand2.resy[ip]); |
3246 |
|
t_track.SetZ(ip,0.5*(trackCand2.zma[ip]+trackCand2.zmb[ip])); |
3247 |
|
} |
3248 |
|
t_track.ygood[ip] = trackCand2.ygood[ip];//assign cluster + sensor |
3249 |
|
t_track.xgood[ip] = xgood_temp;//assign cluster + sensor |
3250 |
|
HBM = true; |
3251 |
|
} |
3252 |
|
}; |
3253 |
|
|
3254 |
|
}//end loop over tracks (2) |
3255 |
|
// |
3256 |
|
//check if track has been already inserted |
3257 |
|
// |
3258 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3259 |
|
multimap<int,ExtTrack>::iterator trkB = trackCandidates[mapIndex].begin(); |
3260 |
|
multimap<int,ExtTrack>::iterator trkE = trackCandidates[mapIndex].end(); |
3261 |
|
// |
3262 |
|
bool ADD = true; |
3263 |
|
for( multimap<int,ExtTrack>::iterator trkI = trkB; trkI!=trkE; ++trkI){ |
3264 |
|
ExtTrack &trackC = (*trkI).second; |
3265 |
|
bool SAME=true; |
3266 |
|
for(int ip=0; ip<NEXTPLANES; ip++){ |
3267 |
|
bool isTrk = (ip < NEXTPLANES - nViewCal); |
3268 |
|
if( t_track.GetClusterX_ID(ip) != trackC.GetClusterX_ID(ip) )SAME=false; |
3269 |
|
if( t_track.GetClusterY_ID(ip) != trackC.GetClusterY_ID(ip) )SAME=false; |
3270 |
|
if( isTrk && t_track.GetSensor(ip) != trackC.GetSensor(ip) )SAME=false; |
3271 |
|
} |
3272 |
|
if(SAME){ |
3273 |
|
ADD=false; |
3274 |
|
break; |
3275 |
|
} |
3276 |
|
} |
3277 |
|
// if(_debug)cout <<" ADD ? "<<ADD<<endl; |
3278 |
|
|
3279 |
|
// cout << "-----> INSERT "<<endl; |
3280 |
|
if(_debug){ |
3281 |
|
|
3282 |
|
cout << endl; |
3283 |
|
// cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
3284 |
|
cout<< " TRK chi2 "<<"............."; |
3285 |
|
cout <<" | al: "; |
3286 |
|
// for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
3287 |
|
for(int i=0; i<5; i++)cout <<".........."; |
3288 |
|
cout <<" | "; |
3289 |
|
cout << " X: "; |
3290 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
3291 |
|
for(int ip=0; ip<t_track.nplanes; ip++){ |
3292 |
|
if(t_track.GetClusterX_ID(ip)>=0) |
3293 |
|
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
3294 |
|
else |
3295 |
|
cout << "__"; |
3296 |
|
} |
3297 |
|
cout << " | "; |
3298 |
|
cout << " Y: "; |
3299 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
3300 |
|
for(int ip=0; ip<t_track.nplanes; ip++){ |
3301 |
|
if(t_track.GetClusterY_ID(ip)>=0) |
3302 |
|
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
3303 |
|
else |
3304 |
|
cout << "__"; |
3305 |
|
} |
3306 |
|
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
3307 |
|
if(HBM)cout << " >> Merged"; |
3308 |
|
// cout << endl; |
3309 |
|
} |
3310 |
|
|
3311 |
|
if(ADD){ |
3312 |
|
// cout << " >> re-evaluate..."; |
3313 |
|
// cout << " >> Merged? "<<HBM; |
3314 |
|
// cout << "| X:"; |
3315 |
|
// for(int ip=0; ip<NEXTPLANES; ip++){ |
3316 |
|
// if(t_track.GetClusterX_ID(ip)>=0) |
3317 |
|
// cout << setw(2)<<t_track.GetClusterX_ID(ip); |
3318 |
|
// else |
3319 |
|
// cout << "__"; |
3320 |
|
// } |
3321 |
|
// // for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.XGood(ip); |
3322 |
|
// cout << "| Y:"; |
3323 |
|
// for(int ip=0; ip<NEXTPLANES; ip++){ |
3324 |
|
// if(t_track.GetClusterY_ID(ip)>=0) |
3325 |
|
// cout << setw(2)<<t_track.GetClusterY_ID(ip); |
3326 |
|
// else |
3327 |
|
// cout << "__"; |
3328 |
|
// } |
3329 |
|
// // for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.YGood(ip); |
3330 |
|
// cout << " S:";for(int ip=0; ip<NEXTPLANES; ip++)cout<< t_track.GetSensor(ip)+1; |
3331 |
|
// cout << endl; |
3332 |
|
|
3333 |
|
// ///////////////////////////////////////////////////////// FIT START |
3334 |
|
int ifail=0; |
3335 |
|
t_track.ResetFit(); |
3336 |
|
// t_track.Dump(); |
3337 |
|
t_track.Fit(0.,ifail,0);// |
3338 |
|
if( ifail != 0 || TMath::IsNaN(t_track.chi2) ){ |
3339 |
|
// if(_debug){ |
3340 |
|
// t_track.ResetFit(); |
3341 |
|
// t_track.Fit(0.,ifail,2);// |
3342 |
|
// } |
3343 |
|
continue; |
3344 |
|
} |
3345 |
|
|
3346 |
|
// t_track.Fit(0.,ifail,0,1);//evaluate again taking into account the track angle |
3347 |
|
// if( TMath::IsNaN(t_track.chi2) )continue; |
3348 |
|
// if( ifail != 0 )continue; |
3349 |
|
// ///////////////////////////////////////////////////////// FIT FINISH |
3350 |
|
|
3351 |
|
|
3352 |
|
|
3353 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
3354 |
|
// re-evaluated coordinates |
3355 |
|
// and |
3356 |
|
// evaluated other track info |
3357 |
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
3358 |
|
//float VMS[22];VMS[0]=0.; //EM, 3295:14: warning: variable ?VMS? set but not used [-Wunused-but-set-variable] |
3359 |
|
for(int ip=0; ip<NEXTPLANES; ip++){ |
3360 |
|
|
3361 |
|
if(!t_track.XGood(ip)&&!t_track.YGood(ip))continue; |
3362 |
|
|
3363 |
|
int iclx = t_track.GetClusterX_ID(ip); |
3364 |
|
int icly = t_track.GetClusterY_ID(ip); |
3365 |
|
int ladder = t_track.GetLadder(ip);//ok |
3366 |
|
int sensor = t_track.GetSensor(ip);//not assigned yet for calo |
3367 |
|
|
3368 |
|
bool isTrk = (ip < NEXTPLANES - nViewCal); |
3369 |
|
bool isXY = t_track.XGood(ip)*t_track.YGood(ip); |
3370 |
|
bool isX = t_track.XGood(ip) && !isXY; |
3371 |
|
bool isY = t_track.YGood(ip) && !isXY; |
3372 |
|
|
3373 |
|
// cout <<endl<< ip << " xgood "<<t_track.xgood[ip]<<" ygood "<<t_track.ygood[ip]; |
3374 |
|
// cout <<endl<< ip << " iclx "<<iclx<<" icly "<<icly; |
3375 |
|
|
3376 |
|
// continue; |
3377 |
|
//========================================= |
3378 |
|
// evaluate angular factor |
3379 |
|
//========================================= |
3380 |
|
float factor = 0.; |
3381 |
|
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.axv[ip]/180.),2); |
3382 |
|
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*t_track.ayv[ip]/180.),2); |
3383 |
|
factor += 1.; |
3384 |
|
factor = TMath::Sqrt(factor); |
3385 |
|
// factor = 1.;///TEMP |
3386 |
|
|
3387 |
|
//========================================= |
3388 |
|
// re-evaluate coordinates |
3389 |
|
//========================================= |
3390 |
|
float xmABar[]={t_track.xv[ip],0.,0.,t_track.axv[ip],0.};//importante passare gli angoli!! |
3391 |
|
float ymABar[]={t_track.yv[ip],0.,0.,t_track.ayv[ip],0.};//importante passare gli angoli!! |
3392 |
|
float zmAB[]={t_track.zv[ip],0.,0.}; |
3393 |
|
|
3394 |
|
if(isTrk){ |
3395 |
|
EvaluateClusterPosition_Tracker( iclx, icly, ladder, sensor, xmABar, ymABar, zmAB); |
3396 |
|
}else{ |
3397 |
|
// cout <<" ------------ EvaluateClusterPosition_Calorimeter ----------------"<<endl; |
3398 |
|
// cout << "IN: "<<(int)fmax((float)iclx,(float)icly)<<endl; |
3399 |
|
// cout << "IN: "<<sensor<<endl; |
3400 |
|
// cout << "IN: "<<xmABar[0]<<endl; |
3401 |
|
// cout << "IN: "<<ymABar[0]<<endl; |
3402 |
|
// cout << "IN: "<<zmAB[0]<<endl; |
3403 |
|
// cout << "IN: "<<t_track.al[4]<<endl; |
3404 |
|
EvaluateClusterPosition_Calorimeter( (int)fmax((float)iclx,(float)icly), sensor, xmABar, ymABar, zmAB, t_track.al[4]); |
3405 |
|
// cout << ip << " SENSOR "<<sensor<<endl; |
3406 |
|
} |
3407 |
|
if(isXY){ |
3408 |
|
t_track.SetXY(ip,xmABar[0],ymABar[0],xmABar[4],ymABar[4]); |
3409 |
|
t_track.SetZ(ip,zmAB[0]); |
3410 |
|
} |
3411 |
|
if(isX ){ |
3412 |
|
t_track.SetX( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],xmABar[4]); |
3413 |
|
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
3414 |
|
} |
3415 |
|
if(isY ){ |
3416 |
|
t_track.SetY( ip,xmABar[1],xmABar[2],ymABar[1],ymABar[2],ymABar[4]); |
3417 |
|
t_track.SetZ(ip,0.5*(zmAB[1]+zmAB[2])); |
3418 |
|
} |
3419 |
|
|
3420 |
|
t_track.SetXGood(ip,(sensor == -1 ? 0 : iclx+1),ladder,sensor); |
3421 |
|
t_track.SetYGood(ip,(sensor == -1 ? 0 : icly+1),ladder,sensor); |
3422 |
|
// t_track.SetXGood(ip,iclx+1,ladder,sensor); |
3423 |
|
// t_track.SetYGood(ip,icly+1,ladder,sensor); |
3424 |
|
|
3425 |
|
//========================================= |
3426 |
|
// evaluate other quantities |
3427 |
|
//========================================= |
3428 |
|
float smip,multmax; |
3429 |
|
if(t_track.XGood(ip)){ |
3430 |
|
if(isTrk){ |
3431 |
|
TrkCluster *cluster = _trk_l1->GetCluster(iclx); |
3432 |
|
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
3433 |
|
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
3434 |
|
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
3435 |
|
}else{ |
3436 |
|
ExtHit cluster = _cal_cl[iclx]; |
3437 |
|
smip = cluster.signal;//mip |
3438 |
|
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
3439 |
|
} |
3440 |
|
t_track.dedx_x[ip] = smip/(factor>0.?factor:1.); |
3441 |
|
t_track.multmaxx[ip] = multmax; |
3442 |
|
} |
3443 |
|
if(t_track.YGood(ip)){ |
3444 |
|
if(isTrk){ |
3445 |
|
TrkCluster *cluster = _trk_l1->GetCluster(icly); |
3446 |
|
float mip = TrkParams::GetMIP(cluster->GetLadder()-1,cluster->view-1); |
3447 |
|
smip = cluster->GetSignal()/(mip>0.?mip:1.); |
3448 |
|
multmax = cluster->GetMultiplicity()*10000+cluster->maxs; |
3449 |
|
}else{ |
3450 |
|
ExtHit cluster = _cal_cl[icly]; |
3451 |
|
smip = cluster.signal;//mip |
3452 |
|
multmax = cluster.mult*10000+lrint(cluster.coordPU); |
3453 |
|
} |
3454 |
|
t_track.dedx_y[ip] = smip/(factor>0.?factor:1.); |
3455 |
|
t_track.multmaxy[ip] = multmax; |
3456 |
|
} |
3457 |
|
} |
3458 |
|
///////////////////////////////////////////////////////// end additional info |
3459 |
|
|
3460 |
|
// ///////////////////////////////////////////////////////// RE-FIT START |
3461 |
|
t_track.Fit(0.,ifail,0);//evaluate again taking into account the track angle |
3462 |
|
if( TMath::IsNaN(t_track.chi2) )continue; |
3463 |
|
if( ifail != 0 )continue; |
3464 |
|
// ///////////////////////////////////////////////////////// RE-FIT FINISH |
3465 |
|
if(_debug){ |
3466 |
|
cout << endl; |
3467 |
|
// cout << " >> al: ";for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
3468 |
|
// cout << " chi2: "<<setw(10)<< t_track.chi2; |
3469 |
|
// // cout << endl; |
3470 |
|
cout<< " TRK chi2 "<<setw(13)<<t_track.chi2; |
3471 |
|
cout <<" | al: "; |
3472 |
|
for(int i=0; i<5; i++)cout <<setw(10)<< t_track.al[i]; |
3473 |
|
cout <<" | "; |
3474 |
|
cout << " X: "; |
3475 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.XGood(ip) ? "o" : "-"); |
3476 |
|
for(int ip=0; ip<t_track.nplanes; ip++){ |
3477 |
|
if(t_track.GetClusterX_ID(ip)>=0) |
3478 |
|
cout << setw(2)<<t_track.GetClusterX_ID(ip); |
3479 |
|
else |
3480 |
|
cout << "__"; |
3481 |
|
} |
3482 |
|
cout << " | "; |
3483 |
|
cout << " Y: "; |
3484 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (t_track.YGood(ip) ? "o" : "-"); |
3485 |
|
for(int ip=0; ip<t_track.nplanes; ip++){ |
3486 |
|
if(t_track.GetClusterY_ID(ip)>=0) |
3487 |
|
cout << setw(2)<<t_track.GetClusterY_ID(ip); |
3488 |
|
else |
3489 |
|
cout << "__"; |
3490 |
|
} |
3491 |
|
cout << " S:";for(int ip=0; ip<t_track.nplanes; ip++)cout<< t_track.GetSensor(ip)+1; |
3492 |
|
cout << " >> ADD "; |
3493 |
|
} |
3494 |
|
|
3495 |
|
_caloTj->DoTrack(t_track.al,t_track.zini); |
3496 |
|
for(int ip=0; ip<_caloTj->npoint; ip++){ |
3497 |
|
t_track.xGF[ip] = _caloTj->x[ip]; |
3498 |
|
t_track.yGF[ip] = _caloTj->y[ip]; |
3499 |
|
} |
3500 |
|
|
3501 |
|
// cout << "ADD "<<endl; |
3502 |
|
trackCandidates[mapIndex].insert(pair<int,ExtTrack>(t_track.GetNX()+t_track.GetNY(), ExtTrack(t_track))); |
3503 |
|
if(t_track.GetNX()+t_track.GetNY()>5 && t_track.chi2<chi2Min) chi2Min=t_track.chi2; |
3504 |
|
iCand++; |
3505 |
|
}//end add-candidate condition |
3506 |
|
|
3507 |
|
}//end first loop on candidates |
3508 |
|
if(_debug)cout <<endl<< "n.candidates "<<trackCandidates[mapIndex].size()<<endl; |
3509 |
|
|
3510 |
|
|
3511 |
|
|
3512 |
|
//================================================================= |
3513 |
|
// ---------------------------------------------------------------- |
3514 |
|
// chi2 selection |
3515 |
|
// ---------------------------------------------------------------- |
3516 |
|
//================================================================= |
3517 |
|
pair <multimap<int,ExtTrack>::iterator, multimap<int,ExtTrack>::iterator> nxny[NEXTVIEWS]; |
3518 |
|
// for(int inxny=0; inxny<NEXTVIEWS; inxny++){ |
3519 |
|
bool NMTI =false;//not-minimal track inserted |
3520 |
|
for(int inxny=NEXTVIEWS-1; inxny>=nClFixX+nClFixY; inxny--){ |
3521 |
|
nxny[inxny] = trackCandidates[mapIndex].equal_range(inxny); |
3522 |
|
// cout << " --- n "<<inxny<<endl; |
3523 |
|
for ( multimap<int,ExtTrack>::iterator it = nxny[inxny].first; it!=nxny[inxny].second; ++it){ |
3524 |
|
ExtTrack &trackC = (*it).second; |
3525 |
|
// cout << " NX+NY "<< trackC.GetNX()+trackC.GetNY() <<" chi2 "<<trackC.chi2<< " R(GV) "<<trackC.GetRigidity()<<endl; |
3526 |
|
// if( trackC.chi2==0 )continue; |
3527 |
|
if( (trackC.GetNX()+trackC.GetNY() > 5 && trackC.chi2>chi2Min ) || |
3528 |
|
(trackC.GetNX()+trackC.GetNY() == 5 && NMTI ) || |
3529 |
|
(trackC.GetNX()+trackC.GetNY() == 5 && trackC.chi2>1. ) || |
3530 |
|
false)continue; |
3531 |
|
|
3532 |
|
trackCandidates[mapIndex+1].insert(pair<int,ExtTrack>(inxny, ExtTrack(trackC))); |
3533 |
|
// cout << " insert "<<endl; |
3534 |
|
|
3535 |
|
if( trackC.GetNX()+trackC.GetNY() > 5 )NMTI=true; |
3536 |
|
} |
3537 |
|
} |
3538 |
|
mapIndex++; |
3539 |
|
|
3540 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3541 |
|
if( |
3542 |
|
trackCandidates[mapIndex].size()==0 || |
3543 |
|
(trackCandidates[mapIndex].size()>1 && nViewCal < _alg_nViewCal ) || |
3544 |
|
false){ |
3545 |
|
mapIndex++; |
3546 |
|
continue;//increment one calo plane |
3547 |
|
} |
3548 |
|
//-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
3549 |
|
|
3550 |
|
if(_debug){ |
3551 |
|
|
3552 |
|
cout<< " Selected-track SUMMARY:"<<endl; |
3553 |
|
|
3554 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3555 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3556 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3557 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3558 |
|
ExtTrack &trackCand = (*trkIter).second; |
3559 |
|
cout<< " TRK chi2 "<<setw(13)<<trackCand.chi2; |
3560 |
|
cout <<" | al: "; |
3561 |
|
for(int i=0; i<5; i++)cout <<setw(10)<< trackCand.al[i]; |
3562 |
|
cout <<" | "; |
3563 |
|
cout << " X: "; |
3564 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.XGood(ip) ? "o" : "-"); |
3565 |
|
for(int ip=0; ip<trackCand.nplanes; ip++){ |
3566 |
|
if(trackCand.GetClusterX_ID(ip)>=0) |
3567 |
|
cout << setw(2)<<trackCand.GetClusterX_ID(ip); |
3568 |
|
else |
3569 |
|
cout << "__"; |
3570 |
|
} |
3571 |
|
cout << " | "; |
3572 |
|
cout << " Y: "; |
3573 |
|
// for(int ip=0; ip<NEXTPLANES; ip++)cout << (trackCand.YGood(ip) ? "o" : "-"); |
3574 |
|
for(int ip=0; ip<trackCand.nplanes; ip++){ |
3575 |
|
if(trackCand.GetClusterY_ID(ip)>=0) |
3576 |
|
cout << setw(2)<<trackCand.GetClusterY_ID(ip); |
3577 |
|
else |
3578 |
|
cout << "__"; |
3579 |
|
} |
3580 |
|
cout << " S:";for(int ip=0; ip<trackCand.nplanes; ip++)cout<< trackCand.GetSensor(ip)+1; |
3581 |
|
cout <<" MDR="<<1./sqrt(trackCand.coval[4][4])<<endl; |
3582 |
|
cout << endl; |
3583 |
|
// for(int ip=0; ip<trackCand.nplanes; ip++) |
3584 |
|
// if(trackCand.GetClusterY_ID(ip)>=0)cout << trackCand.GetClusterY_ID(ip)<<":"<<trackCand.GetSensor(ip)<<"|"; cout << endl; |
3585 |
|
|
3586 |
|
} |
3587 |
|
} |
3588 |
|
|
3589 |
|
|
3590 |
|
//================================================================= |
3591 |
|
// ---------------------------------------------------------------- |
3592 |
|
// save tracks |
3593 |
|
// ---------------------------------------------------------------- |
3594 |
|
//================================================================= |
3595 |
|
// cout << mapIndex << endl; |
3596 |
|
if(mapIndex>=maxSize)cout <<" ORRORE!!!! mapIndex"<<mapIndex<<" >= "<<maxSize<<endl; |
3597 |
|
// if(mapIndex>0)trackCandidates[mapIndex-1].clear(); |
3598 |
|
trkBegin = trackCandidates[mapIndex].begin(); |
3599 |
|
trkEnd = trackCandidates[mapIndex].end(); |
3600 |
|
iCand = 0; |
3601 |
|
// TClonesArray &tracks = *_trkArray; |
3602 |
|
// tracks.Clear(); |
3603 |
|
for( multimap<int,ExtTrack>::iterator trkIter = trkBegin; trkIter!=trkEnd; ++trkIter){ |
3604 |
|
ExtTrack trackCand = ((*trkIter).second); |
3605 |
|
// cout << iCand << " "<< trackCand.al[4] <<endl; |
3606 |
|
// trackCand.seqno = iCand; |
3607 |
|
// trackCand.Dump(); |
3608 |
|
new(tracks[iCand]) ExtTrack(trackCand); |
3609 |
|
iCand++; |
3610 |
|
}; |
3611 |
|
break; |
3612 |
|
|
3613 |
|
|
3614 |
|
|
3615 |
|
}// end loop over n.calo planes to be included |
3616 |
|
|
3617 |
|
|
3618 |
|
|
3619 |
|
|
3620 |
|
|
3621 |
|
} |
3622 |
|
|
3623 |
|
|
3624 |
|
/** |
3625 |
|
* |
3626 |
|
*/ |
3627 |
|
void ExtTrkingAlg::ProcessEvent(Bool_t force){ |
3628 |
|
|
3629 |
|
if(_whichAlg == 0) ProcessEvent0(force); |
3630 |
|
else if(_whichAlg >= 100 && _whichAlg < 144) ProcessEvent1(force); |
3631 |
|
else if(_whichAlg >= 200 && _whichAlg < 244) ProcessEvent2(force); |
3632 |
|
else{ |
3633 |
|
cout << " Algorythm id "<< _whichAlg <<" not implemented "<<endl; |
3634 |
|
} |
3635 |
|
|
3636 |
|
}; |
3637 |
|
/** |
3638 |
|
* |
3639 |
|
*/ |
3640 |
|
void ExtTrkingAlg::Dump(){ |
3641 |
|
|
3642 |
|
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
3643 |
|
cout << "ExtTrkingAlg::Dump() "<<endl<<endl; |
3644 |
|
cout << " algorythm "<<setw(10)<<_whichAlg <<endl; |
3645 |
|
cout << " debug "<<setw(10)<< _debug <<endl; |
3646 |
|
cout << " TrkLevel1 "<<setw(10)<<_trk_l1 <<endl; |
3647 |
|
cout << " TrkLevel2 "<<setw(10)<<_trk_l2 <<endl; |
3648 |
|
cout << " CaloLevel1"<<setw(10)<<_cal_l1 <<endl; |
3649 |
|
cout << " CaloLevel2"<<setw(10)<<_cal_l2 <<endl; |
3650 |
|
cout << " ToFLevel2 "<<setw(10)<<_tof_l2 <<endl; |
3651 |
|
cout << "Pre-selection parameters "<<endl; |
3652 |
|
cout << " nClstrMAX "<<setw(10)<<_sel_nClstrMAX <<endl; |
3653 |
|
cout << " nPlaneXMIN "<<setw(10)<<_sel_nPlaneXMIN <<endl; |
3654 |
|
cout << " nPlaneYMIN "<<setw(10)<<_sel_nPlaneYMIN <<endl; |
3655 |
|
cout << "Algorythm parameters "<<endl; |
3656 |
|
cout << " nClFixX "<<setw(10)<<_alg_nClFixX <<endl; |
3657 |
|
cout << " nClFixY "<<setw(10)<<_alg_nClFixY <<endl; |
3658 |
|
cout << " nTrackMAX "<<setw(10)<<_alg_nTrackMAX <<endl; |
3659 |
|
cout << " nViewCal "<<setw(10)<<_alg_nViewCal <<endl; |
3660 |
|
cout << "|--|--|--|--|--|--|--|--|--|--|--|"<<endl; |
3661 |
|
|
3662 |
|
} |
3663 |
|
|
3664 |
|
|
3665 |
|
|
3666 |
|
//////////////////////////////////////////////////////////////////////// |
3667 |
|
// |
3668 |
|
// |
3669 |
|
// |
3670 |
|
// |
3671 |
|
//////////////////////////////////////////////////////////////////////// |
3672 |
|
// int GetSensor(int view, int sis){ |
3673 |
|
// if(sis<0||sis>8)return -1; |
3674 |
|
// if(view<0||view>1)return -1; |
3675 |
|
// if(!view)return (int)(sis/3); |
3676 |
|
// else return sis%3; |
3677 |
|
// }; |
3678 |
|
// int GetLadder(int view, int sis){ |
3679 |
|
// if(sis<0||sis>8)return -1; |
3680 |
|
// if(view<0||view>1)return -1; |
3681 |
|
// if(!view)return sis%3; |
3682 |
|
// else return (int)(sis/3); |
3683 |
|
// }; |
3684 |
|
// int GetSiSensor(int view, int l, int s){ |
3685 |
|
// if(view<0||view>1)return -1; |
3686 |
|
// if(s<0||s>2)return -1; |
3687 |
|
// if(!view) return 3*s+l; |
3688 |
|
// else return 3*l+s; |
3689 |
|
// }; |
3690 |
|
|
3691 |
|
int CaloStripRoto::GetSensor(){ |
3692 |
|
return GetCaloSensor(GetView(),GetSiSensor()); |
3693 |
|
}; |
3694 |
|
int CaloStripRoto::GetLadder(){ |
3695 |
|
return GetCaloLadder(GetView(),GetSiSensor()); |
3696 |
|
}; |
3697 |
|
|
3698 |
|
void CaloStripRoto::ResetAligParams(){ |
3699 |
|
fPitch = 1.; |
3700 |
|
shift[0]=0.; //L |
3701 |
|
shift[1]=0.; //S |
3702 |
|
shift[2]=0.; //Z |
3703 |
|
alpha = 0.; |
3704 |
|
|
3705 |
|
// siSensor = -1;; |
3706 |
|
|
3707 |
|
}; |
3708 |
|
/*1 |
3709 |
|
* |
3710 |
|
|
3711 |
|
* |
3712 |
|
*/ |
3713 |
|
bool CaloStripRoto::SensorContains(float x, float y){ |
3714 |
|
|
3715 |
|
float toll = 0.2;//cm |
3716 |
|
|
3717 |
|
// cout << "S -- SetStrip("<<GetLadder()*32+0<<")"<<endl; |
3718 |
|
|
3719 |
|
// cout << " extst.SetStrip("<<GetLadder()*32+0<<") "<<endl; |
3720 |
|
SetStrip(GetLadder()*32+0); |
3721 |
|
float xM0,yM0; |
3722 |
|
float d0 = GetDistanceTo(x,y,xM0,yM0); |
3723 |
|
|
3724 |
|
if( yM0-toll > fYB && yM0 > fYA )return false; |
3725 |
|
if( yM0+toll < fYB && yM0 < fYA )return false; |
3726 |
|
|
3727 |
|
if( xM0-toll > fXB && xM0 > fXA )return false; |
3728 |
|
if( xM0+toll < fXB && xM0 < fXA )return false; |
3729 |
|
|
3730 |
|
// cout << "D -- SetStrip("<<GetLadder()*32+31<<")"<<endl; |
3731 |
|
// cout << " extst.SetStrip("<<GetLadder()*32+31<<") "<<endl; |
3732 |
|
SetStrip(GetLadder()*32+31); |
3733 |
|
float xM31,yM31; |
3734 |
|
float d31 = GetDistanceTo(x,y,xM31,yM31); |
3735 |
|
|
3736 |
|
|
3737 |
|
if( d0+d31 > 31*fPitch*0.244+2.*toll)return false; |
3738 |
|
|
3739 |
|
return true; |
3740 |
|
|
3741 |
|
}; |
3742 |
|
|
3743 |
|
CaloStripRoto::CaloStripRoto(int view, int plane, int sisensor, Bool_t usemechanicalalignement){ |
3744 |
|
|
3745 |
|
SetView(view); |
3746 |
|
SetPlane(plane); |
3747 |
|
SetSiSensor(sisensor); |
3748 |
|
|
3749 |
|
st = CaloStrip(usemechanicalalignement); |
3750 |
|
ResetAligParams(); |
3751 |
|
if(!usemechanicalalignement){ |
3752 |
|
// cout <<" SETTA I PARAMETRI DI ALLINEAMNETO -- da implementare"<<endl; |
3753 |
|
} |
3754 |
|
|
3755 |
|
// Set(view,plane,0,GetSiSensor()); |
3756 |
|
} ///< Default Constructor. |
3757 |
|
|
3758 |
|
|
3759 |
|
|
3760 |
|
// relative to pamela reference system (convenzione emiliano): |
3761 |
|
// |
3762 |
|
// y ^ |
3763 |
|
// | |
3764 |
|
// | 6 7 8 sisensor |
3765 |
|
// | 3 4 5 |
3766 |
|
// | 0 1 2 |
3767 |
|
// ------------> x |
3768 |
|
// |
3769 |
|
// relative to silicon sensor |
3770 |
|
// |
3771 |
|
// S ^ |
3772 |
|
// | | |
3773 |
|
// 2 | | <- strip direction |
3774 |
|
// sensor 1 | | |
3775 |
|
// 0 |...|... |
3776 |
|
// ------------> L |
3777 |
|
// 0 1 2 |
3778 |
|
// ladder |
3779 |
|
// |
3780 |
|
// |
3781 |
|
void CaloStripRoto::Set(Int_t view, Int_t plane, float strip, int sisensor){ |
3782 |
|
|
3783 |
|
|
3784 |
|
SetView(view); |
3785 |
|
SetPlane(plane); |
3786 |
|
|
3787 |
|
|
3788 |
|
float size = 8.05; //(cm) larghezza del sensore + zone morte |
3789 |
|
|
3790 |
|
|
3791 |
|
//---------------------------- |
3792 |
|
// Z-coordinate |
3793 |
|
//---------------------------- |
3794 |
|
|
3795 |
|
float coordCM_strip; |
3796 |
|
if( strip >0. && strip < 95.){ |
3797 |
|
st.Set( view,plane,(int)strip);// istrip |
3798 |
|
coordCM_strip = ( view ? st.GetY() : st.GetX() ); |
3799 |
|
coordCM_strip *= (1-strip+(int)strip); |
3800 |
|
st.Set( view,plane,(int)strip+1);// istrip+1 |
3801 |
|
coordCM_strip += (strip-(int)strip)*( view ? st.GetY() : st.GetX() ); |
3802 |
|
}else{ |
3803 |
|
// cout << "CaloStripRoto::Set( "<<view<<","<<plane<<","<<strip<<","<<sisensor<<")"<<endl; |
3804 |
|
// cout << " ---> ERROR: 0 =< strip =< 95 " << endl; |
3805 |
|
if(strip>=95.)strip=95.; |
3806 |
|
if(strip<=0.)strip=0.; |
3807 |
|
st.Set( view,plane,(int)strip);// istrip |
3808 |
|
coordCM_strip = ( view ? st.GetY() : st.GetX() ); |
3809 |
|
} |
3810 |
|
float coordCm_Z0 = st.GetZ(); |
3811 |
|
//---------------------------- |
3812 |
|
// strip-segment coordinates |
3813 |
|
//---------------------------- |
3814 |
|
float coordCm_LA = coordCM_strip; |
3815 |
|
float coordCm_LB = coordCM_strip; |
3816 |
|
float coordCm_SA = (-1)*size*1.5; //full calorimeter size |
3817 |
|
float coordCm_SB = (+1)*size*1.5; //full calorimeter size |
3818 |
|
float coordCm_ZA = coordCm_Z0; |
3819 |
|
float coordCm_ZB = coordCm_Z0; |
3820 |
|
|
3821 |
|
//---------------------------- |
3822 |
|
// rototraslation |
3823 |
|
//---------------------------- |
3824 |
|
//if sisensor is assigned (0,...8) the strip can be rototraslated |
3825 |
|
bool ROTO = (sisensor>=0&&sisensor<9); |
3826 |
|
|
3827 |
|
if(ROTO){ |
3828 |
|
|
3829 |
|
|
3830 |
|
if( |
3831 |
|
GetCaloSiSensor(view,(int)(strip/32),0) != sisensor && |
3832 |
|
GetCaloSiSensor(view,(int)(strip/32),1) != sisensor && |
3833 |
|
GetCaloSiSensor(view,(int)(strip/32),2) != sisensor && |
3834 |
|
true){ |
3835 |
|
cout << " Strip "<<strip<<" does not belong to sensor "<<sisensor<<endl; |
3836 |
|
cout << " input data are inconsistent --- output might be wrong "<<endl; |
3837 |
|
} ; |
3838 |
|
|
3839 |
|
|
3840 |
|
int sensor = GetCaloSensor(view, sisensor);//0-1-2 |
3841 |
|
int ladder = GetCaloLadder(view, sisensor);//0-1-2 |
3842 |
|
if( ladder != (int)(strip / 32) ){ |
3843 |
|
cout << " void CaloStripRoto::Set(..) --- ERROR --- strip "<<strip<<" does not match Si-sensor "<<sisensor<<endl; |
3844 |
|
return; |
3845 |
|
} |
3846 |
|
|
3847 |
|
//----------------------------- |
3848 |
|
// sensor origin coordinates |
3849 |
|
//----------------------------- |
3850 |
|
|
3851 |
|
st.Set( view, plane, ladder*32); //strip = 0-32-64 |
3852 |
|
float coordCm_L0 = ( view ? st.GetY() : st.GetX()); |
3853 |
|
st.Set( (int)(!view), plane, sensor*32 );//strip = 0-32-64 |
3854 |
|
float coordCm_S0 = ( view ? st.GetX() : st.GetY()); |
3855 |
|
|
3856 |
|
//set sensor size |
3857 |
|
coordCm_SA = (-1)*size*0.5 + (sensor-1)*size; |
3858 |
|
coordCm_SB = (+1)*size*0.5 + (sensor-1)*size; |
3859 |
|
|
3860 |
|
//coordinate relative al sensore |
3861 |
|
coordCm_LA = coordCm_LA - coordCm_L0; |
3862 |
|
coordCm_SA = coordCm_SA - coordCm_S0; |
3863 |
|
coordCm_ZA = coordCm_ZA - coordCm_Z0; |
3864 |
|
coordCm_LB = coordCm_LB - coordCm_L0; |
3865 |
|
coordCm_SB = coordCm_SB - coordCm_S0; |
3866 |
|
coordCm_ZB = coordCm_ZB - coordCm_Z0; |
3867 |
|
|
3868 |
|
//variazione di pitch |
3869 |
|
coordCm_LA = coordCm_LA * fPitch; |
3870 |
|
coordCm_LB = coordCm_LB * fPitch; |
3871 |
|
|
3872 |
|
//rotazione |
3873 |
|
float LA = coordCm_LA - alpha * coordCm_SA; |
3874 |
|
float SA = coordCm_SA + alpha * coordCm_LA; |
3875 |
|
float LB = coordCm_LB - alpha * coordCm_SB; |
3876 |
|
float SB = coordCm_SB + alpha * coordCm_LB; |
3877 |
|
|
3878 |
|
//traslazione |
3879 |
|
coordCm_LA = LA + (!view ? shift[0] : shift[1]); |
3880 |
|
coordCm_SA = SA + ( view ? shift[1] : shift[0]); |
3881 |
|
coordCm_ZA = coordCm_ZA + shift[2]; |
3882 |
|
coordCm_LB = LB + shift[0]; |
3883 |
|
coordCm_SB = SB + shift[1]; |
3884 |
|
coordCm_ZB = coordCm_ZB + shift[2]; |
3885 |
|
|
3886 |
|
//back to sistema di riferimento generale |
3887 |
|
|
3888 |
|
coordCm_LA = coordCm_LA + coordCm_L0; |
3889 |
|
coordCm_SA = coordCm_SA + coordCm_S0; |
3890 |
|
coordCm_ZA = coordCm_ZA + coordCm_Z0; |
3891 |
|
coordCm_LB = coordCm_LB + coordCm_L0; |
3892 |
|
coordCm_SB = coordCm_SB + coordCm_S0; |
3893 |
|
coordCm_ZB = coordCm_ZB + coordCm_Z0; |
3894 |
|
|
3895 |
|
} |
3896 |
|
|
3897 |
|
fXA = (!view ? coordCm_LA : coordCm_SA); |
3898 |
|
fYA = ( view ? coordCm_LA : coordCm_SA); |
3899 |
|
fZA = coordCm_ZA; |
3900 |
|
|
3901 |
|
fXB = (!view ? coordCm_LB : coordCm_SB); |
3902 |
|
fYB = ( view ? coordCm_LB : coordCm_SB); |
3903 |
|
fZB = coordCm_ZB; |
3904 |
|
|
3905 |
|
|
3906 |
|
st.Set(view,plane,(int)strip);// istrip |
3907 |
|
|
3908 |
|
}; |
3909 |
|
// |
3910 |
|
// |
3911 |
|
// |
3912 |
|
// |
3913 |
|
// |
3914 |
|
// |
3915 |
|
float CaloStripRoto::GetSpatialResolution(float def, float degx, float degy, float beta){ |
3916 |
|
|
3917 |
|
float res_dig = 0.24/sqrt(12.); |
3918 |
|
|
3919 |
|
if(def==0.)return res_dig; |
3920 |
|
|
3921 |
|
float res_ms = 0.; |
3922 |
|
|
3923 |
|
// Int_t GetView(){return (fView-1);} ///< Get strip view [0-1] |
3924 |
|
// Int_t GetPlane(){return (fPlane-1);} ///< Get strip plane [0-21] |
3925 |
|
// Int_t GetStrip(){return (fStrip-1);} ///< Get strip number [0-95] |
3926 |
|
|
3927 |
|
|
3928 |
|
float rig = 1/def; if(rig<0)rig = -rig; |
3929 |
|
float factor = 0.; |
3930 |
|
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*degx/180.),2); |
3931 |
|
factor += TMath::Power(TMath::Tan(TMath::ACos(-1)*degy/180.),2); |
3932 |
|
factor += 1.; |
3933 |
|
factor = TMath::Sqrt(factor); |
3934 |
|
|
3935 |
|
int view = st.GetPlane()*2 + 1 - st.GetView() ;//cluster.view; //0... 43 |
3936 |
|
|
3937 |
|
// int nW = (int)((view + 1)/2); |
3938 |
|
float dW = 0.74*factor;//X0 |
3939 |
|
float dW_cm = 0.26*factor;//cm |
3940 |
|
float dSi_cm = 0.; //cm |
3941 |
|
if(view && st.GetPlane()>0) dSi_cm = ( st.GetPlane()%2 ? 0.228 : 0.428); |
3942 |
|
dSi_cm *= factor; |
3943 |
|
// multiple scattering angle |
3944 |
|
float theta = 0.;//ms |
3945 |
|
theta = 0.0136/rig; |
3946 |
|
theta = theta * sqrt(dW) * (1.+0.038*log(dW)); |
3947 |
|
float Vt = theta*theta; //cov(theta,theta) |
3948 |
|
float Vy = Vt * dW_cm * dW_cm /3.; //cov(y,y) |
3949 |
|
float Vty = 0.87 * Vt * Vy; //cov(theta,y) |
3950 |
|
float Vc = Vy + dSi_cm * dSi_cm * Vt + 2. * dSi_cm * Vty; |
3951 |
|
float rms = sqrt( Vc ); |
3952 |
|
// if(isY)t_track.resy[ip] = sqrt(rms*rms + t_track.resy[ip]*t_track.resy[ip]); |
3953 |
|
// else t_track.resx[ip] = sqrt(rms*rms + t_track.resx[ip]*t_track.resx[ip]); |
3954 |
|
// if(isY) VMS[nW] = rms*rms; |
3955 |
|
// if(_debug)cout <<endl<<view<<" nW "<<nW<<" res(MS) "<<rms<<" factor "<<factor; |
3956 |
|
|
3957 |
|
if(view>=3){ |
3958 |
|
cout << " --> NB resolution not accurate for layer "<<view<<endl;; |
3959 |
|
cout <<"st.GetPlane() "<<st.GetPlane()<<endl; |
3960 |
|
cout <<"st.GetView() "<<st.GetView()<<endl; |
3961 |
|
} |
3962 |
|
res_ms = rms; |
3963 |
|
|
3964 |
|
return sqrt(res_ms*res_ms + res_dig*res_dig); |
3965 |
|
|
3966 |
|
}; |
3967 |
|
/** |
3968 |
|
* |
3969 |
|
* |
3970 |
|
* |
3971 |
|
* |
3972 |
|
*/ |
3973 |
|
float CaloStripRoto::GetDistanceTo(float xP, float yP, float& xM, float &yM ){ |
3974 |
|
|
3975 |
|
|
3976 |
|
bool isX = fabs(fXA-fXB) < fabs(fYA-fYB); |
3977 |
|
|
3978 |
|
|
3979 |
|
if(isX){ |
3980 |
|
float beta = (fXB-fXA)/(fYB-fYA); |
3981 |
|
float alpha = fXA - beta * fYA; |
3982 |
|
yM = ( yP + beta*xP - beta*alpha )/(1+beta*beta); |
3983 |
|
xM = alpha + beta * yM; |
3984 |
|
}else{ |
3985 |
|
float beta = (fYB-fYA)/(fXB-fXA); |
3986 |
|
float alpha = fYA - beta * fXA; |
3987 |
|
xM = ( xP + beta*yP - beta*alpha )/(1+beta*beta); |
3988 |
|
yM = alpha + beta * xM; |
3989 |
|
} |
3990 |
|
|
3991 |
|
return sqrt((xM-xP)*(xM-xP) + (yM-yP)*(yM-yP)); |
3992 |
|
|
3993 |
|
}; |