215 {
216 setFilterPassed(false);
217
218 MsgStream log(
msgSvc(), name());
219 log << MSG::INFO << "in execute()" << endreq;
220
221
222 if(m_hist>0){
223 for (int ii=0;ii<43;ii++){
224 for (int jj=0;jj<288;jj++){
232 mcDrift[ii][jj] = -99.;
233 mcX[ii][jj] = -99.;
234 mcY[ii][jj] = -99.;
235 mcZ[ii][jj] = -99.;
236 mcLR[ii][jj] = -99.;
237 hitPoisoned[ii][jj]=-99;
238 }
239 }
240 }
241
242
244#ifdef MDCPATREC_TIMETEST
245 m_timer[1]->start();
246 ti_nHit=0;
247#endif
248
249 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),"/Event/EventHeader");
250 if (!evtHead) {
251 log << MSG::FATAL<< "Could not retrieve event header" << endreq;
252 return( StatusCode::FAILURE);
253 }
254 t_eventNo = evtHead->eventNumber();
255 if(m_debug!=0)std::cout<<t_iExexute<<" run "<<evtHead->runNumber()<<" evt "<<t_eventNo<<std::endl;
256 t_iExexute++;
257
258 if (m_selEvtNo.size() >0){
259 std::vector<int>::iterator it = m_selEvtNo.begin();
260 for (; it!=m_selEvtNo.end(); it++){
261 if((*it)== t_eventNo) setFilterPassed(true);
262 }
263 }
264
265 double t0 = 0.;
266 t_t0 = -1.;
267 t_t0Stat = -1;
268 bool iterateT0 = false;
269 const int nBunch = 3;
270 double iBunch = 0 ;
271 double BeamDeltaTime = 24. / nBunch;
272 SmartDataPtr<RecEsTimeCol> evTimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
273 if (!evTimeCol || evTimeCol->size()==0) {
274 log << MSG::WARNING <<" run "<<evtHead->runNumber() <<" evt "<<t_eventNo<< " Could not find RecEsTimeCol" << endreq;
275 if(m_fieldCosmic){
276 return StatusCode::SUCCESS;
277 }
278 }
279 RecEsTimeCol::iterator iter_evt = evTimeCol->begin();
280
281 if (iter_evt != evTimeCol->end()){
282 t_t0Stat = (*iter_evt)->getStat();
283 t_t0 = (*iter_evt)->getTest();
284
285 if (m_doLineFit){
286
287 if (
abs(t_t0)<0.00001 || (t_t0 < 0) || (t_t0 > 9999.0) ){
288 log << MSG::WARNING << "Skip with t0 = "<<t_t0 << endreq;
289 return StatusCode::SUCCESS;
290 }
291 }
292 t0 = t_t0*1.e-9;
293 }
294
295
296restart:
297 if ( !m_recForEsTime && m_tryBunch) {
298 if ( t_t0Stat < 10 ) return StatusCode::SUCCESS;
299 }
300 if ( m_tryBunch ){
301 if ( iBunch > (nBunch - 1) ) return StatusCode::SUCCESS;
302 if ( t_t0Stat < 0 ){ iterateT0 = true; }
303 if ( iterateT0 ){
304
305 if ( (t_t0Stat > -1) && (fabs( iBunch * BeamDeltaTime - t_t0) < 2.) ){
306 ++iBunch;
307 goto restart;
308 }else{ t0 = iBunch * BeamDeltaTime *1.e-9;}
309 ++iBunch;
310 }
311 }
312
313 SmartDataPtr<MdcHitMap> hitMap(eventSvc(),"/Event/Hit/MdcHitMap");
314 if (!hitMap) {
315 log << MSG::FATAL << "Could not retrieve MDC hit map" << endreq;
316 return( StatusCode::FAILURE);
317 }
318
319 SmartDataPtr<MdcHitCol> hitCol(eventSvc(),"/Event/Hit/MdcHitCol");
320 if (!hitCol) {
321 log << MSG::FATAL << "Could not retrieve MDC hit list" << endreq;
322 return( StatusCode::FAILURE);
323 }
324 StatusCode sc;
325
326
327 DataObject *aReconEvent;
328 eventSvc()->findObject("/Event/Recon",aReconEvent);
329 if(aReconEvent==NULL) {
331 StatusCode sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
332 if(sc!=StatusCode::SUCCESS) {
333 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
334 return( StatusCode::FAILURE);
335 }
336 }
337
338 DataObject *aTrackCol;
339 DataObject *aRecHitCol;
340
341 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
342 if(!m_combineTracking){
343 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
344 if(aTrackCol != NULL) {
345 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
346 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
347 }
348 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
349 if(aRecHitCol != NULL) {
350 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
351 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
352 }
353 }
354
356 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
357 if (aTrackCol) {
359 }else{
362 if(!sc.isSuccess()) {
363 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
364 return StatusCode::FAILURE;
365 }
366 }
368 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aRecHitCol);
369 if (aRecHitCol) {
371 }else{
374 if(!sc.isSuccess()) {
375 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
376 return StatusCode::FAILURE;
377 }
378 }
379
380 m_hitData->loadevent(hitCol, hitMap, t0);
381 t_nDigi = hitCol->size();
382
384 m_hitData->poisonHits(_gm,m_debug);
385 }
386
388 for(int i=0;i<m_hitData->nhits();i++){
389 const MdcHit* thisHit = m_hitData->hit(i);
392 if(m_hitData->segUsage().get(thisHit)->deadHit()){
393 hitPoisoned[l][w] = 1;
394 }else{
395 hitPoisoned[l][w] = 0;
396 }
397 }
398 }
399
400#ifdef MDCPATREC_TIMETEST
401 SmartDataPtr<Event::McParticleCol> mcParticleCol(eventSvc(),"/Event/MC/McParticleCol");
402 if(!mcParticleCol){
403 log << MSG::INFO << "Could not retrieve McParticelCol" << endreq;
404 }
405 m_mcTkNum = mcParticleCol->size();
406#endif
407
408
410
411
412
413 int nSegs = 0;
415
416 nSegs = m_segFinder->createSegs(_gm, *m_segs, m_hitData->segUsage(),
417 m_hitData->hitMap(), t0);
418 }
419 log << MSG::INFO << " Found " << nSegs << " segments" << endreq;
420 if (m_debug>1){
421 std::cout<<"------------------------------------------------"<<std::endl;
422 std::cout<<"==event "<<t_eventNo<< " Found " << nSegs << " segments" << std::endl;
423 m_segs->plot();
424 }
425
428 }
429
430
431
432
433 int nTracks = 0;
434 int nDeleted = 0;
436 if (nSegs > 2) {
437 nTracks = m_tracks->createFromSegs(m_segs.get(), m_hitData->hitMap(),
438 _gm, context, t0);
439 }
440
441 if(m_arbitrateHits) nDeleted = m_tracks->arbitrateHits();
442 int nKeep = nTracks - nDeleted;
443
444 if (m_debug>0 && (nTracks - nDeleted)>0){
445 std::cout<< "MdcTrkRecon: evt "<< setw(5)<<t_eventNo
446 <<" nDigi "<<setw(4)<<t_nDigi<< " t0 "<<setw(5)<<t_t0
447 << " keep "<< nKeep <<" track(s)";
448 if (nDeleted!=0){ std::cout <<",deleted " <<nDeleted; }
449 std::cout<< std::endl;
450 }else{
451 if (m_debug>0){
452 std::cout<< "MdcTrkRecon: evt "<< setw(5)<<t_eventNo
453 <<" nDigi "<<setw(4)<<t_nDigi<< " t0 "<<setw(5)<<t_t0
454 <<" found 0 track "<< endl;
455 }
456 }
457
458 if (m_flags.
lHist) t_nRecTk = nKeep;
459
460#ifdef MDCPATREC_RESLAYER
461 m_tracks->setResLayer(m_resLayer);
462#endif
464
465 m_tracks->store(trackList, hitList);
466
467 if(m_debug>1){
468 std::cout<<name()<<" print track list "<<std::endl;
470 }
471
472
473#ifdef MDCPATREC_TIMETEST
474 RecMdcTrackCol::iterator
iter = trackList->begin();
475 for (;
iter != trackList->end();
iter++) {
477 ti_nHit += tk->getNhits();
478 }
479#endif
480
481 }
482
483 m_segs->destroySegs();
484
485
486
487
489#ifdef MDCPATREC_TIMETEST
490 m_timer[1]->stop();
491
492
493 m_eventTime = m_timer[1]->elapsed();
494 m_t5recTkNum = m_tracks->length();
495 m_t5EvtNo = t_eventNo;
496 m_t5nHit = ti_nHit;
497 m_t5nDigi = t_nDigi;
498 sc = m_tupleTime->write();
499#endif
500
501 if ( m_tryBunch ){
502 if ( nTracks <1 ){ iterateT0 = true;
503 goto restart;
504 }
505 }
507
508 return StatusCode::SUCCESS;
509}
double abs(const EvtComplex &c)
double haveDigiDrift[43][288]
int haveDigiAmbig[43][288]
double haveDigiPhi[43][288]
double haveDigiTheta[43][288]
double haveDigiPt[43][288]
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
unsigned layernumber() const
unsigned wirenumber() const
void printRecMdcTrackCol() const
bool poisoningHits() const
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol