248 {
249
250
251 b_saveEvent=false;
252 setFilterPassed(b_saveEvent);
253#ifdef MDCXTIMEDEBUG
254 m_timer[0]->start();
255 m_timer[1]->start();
256#endif
257 MsgStream log(
msgSvc(), name());
258 log << MSG::INFO << "in execute()" << endreq;
259 StatusCode sc;
260
261 nTk = 0; t_nTdsTk = 0; t_nDigi=0; t_nSeg=0;
262
263
264
265 SmartDataPtr<Event::EventHeader> evtHead(eventSvc(),"/Event/EventHeader");
266 if (!evtHead) {
267 log << MSG::FATAL<< "Could not retrieve event header" << endreq;
268 return StatusCode::FAILURE;
269 }
270 m_eventNo = evtHead->eventNumber();
271 if(m_debug>0)std::cout << "x evt: "<<evtHead->runNumber()<<" " << m_eventNo<< std::endl;
272 long t_evtNo = m_eventNo;
274
275 IDataManagerSvc *dataManSvc;
276 DataObject *aTrackCol;
277 DataObject *aHitCol;
278 if (!m_salvageTrk) {
279 SmartIF<IDataManagerSvc> dataManSvc(eventSvc());
280 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
281 if(aTrackCol != NULL) {
282 dataManSvc->clearSubTree("/Event/Recon/RecMdcTrackCol");
283 eventSvc()->unregisterObject("/Event/Recon/RecMdcTrackCol");
284 }
285 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aHitCol);
286 if(aHitCol != NULL) {
287 dataManSvc->clearSubTree("/Event/Recon/RecMdcHitCol");
288 eventSvc()->unregisterObject("/Event/Recon/RecMdcHitCol");
289 }
290 }
291
292
293
294
295 DataObject *aReconEvent;
296 eventSvc()->findObject("/Event/Recon",aReconEvent);
297 if (aReconEvent==NULL) {
299 sc = eventSvc()->registerObject("/Event/Recon",aReconEvent);
300 if(sc != StatusCode::SUCCESS) {
301 log << MSG::FATAL << "Could not register ReconEvent" <<endreq;
302 return StatusCode::FAILURE;
303 }
304 }
306 eventSvc()->findObject("/Event/Recon/RecMdcTrackCol",aTrackCol);
307 if (aTrackCol) {
309 }else{
312 if(!sc.isSuccess()) {
313 log << MSG::FATAL << " Could not register RecMdcTrack collection" <<endreq;
314 return StatusCode::FAILURE;
315 }
316 }
318 eventSvc()->findObject("/Event/Recon/RecMdcHitCol",aHitCol);
319 if (aHitCol) {
321 }else{
324 if(!sc.isSuccess()) {
325 log << MSG::FATAL << " Could not register RecMdcHit collection" <<endreq;
326 return StatusCode::FAILURE;
327 }
328 }
329
330
331
332
333 DataObject *pnode = 0;
334 sc = eventSvc()->retrieveObject("/Event/Hit",pnode);
335 if(!sc.isSuccess()) {
336 pnode = new DataObject;
337 sc = eventSvc()->registerObject("/Event/Hit",pnode);
338 if(!sc.isSuccess()) {
339 log << MSG::FATAL << " Could not register /Event/Hit branch " <<endreq;
340 return StatusCode::FAILURE;
341 }
342 }
343 SmartDataPtr<MdcHitCol> m_hitCol(eventSvc(), "/Event/Hit/MdcHitCol");
344 if (!m_hitCol){
346 sc = eventSvc()->registerObject("/Event/Hit/MdcHitCol",m_hitCol);
347 if(!sc.isSuccess()) {
348 log << MSG::FATAL << " Could not register hit collection" <<endreq;
349 return StatusCode::FAILURE;
350 }
351 }
352
353
354
355
356
357 m_bunchT0 = -999.;
358 SmartDataPtr<RecEsTimeCol> aevtimeCol(eventSvc(),"/Event/Recon/RecEsTimeCol");
359 if (!aevtimeCol || aevtimeCol->size()==0) {
360 log << MSG::WARNING<< "evt "<<m_eventNo<<" Could not find RecEsTimeCol"<< endreq;
361 return StatusCode::SUCCESS;
362 }
363
364 RecEsTimeCol::iterator iter_evt = aevtimeCol->begin();
365 for(; iter_evt!=aevtimeCol->end(); iter_evt++){
366 m_bunchT0 = (*iter_evt)->getTest();
367 m_t0Stat = (*iter_evt)->getStat();
368 if(m_debug>1) std::cout<<name()<<" "<<t_evtNo<<" t0 "<<m_bunchT0<<" t0Stat "<<m_t0Stat<<std::endl;
369 if ((m_t0Stat==0) || (m_bunchT0 < 0.) || (m_bunchT0 > 9999.0) ){
370 log << MSG::WARNING << "Skip evt:"<<m_eventNo<< " by t0 = "<<m_bunchT0 << endreq;
371
372 }
373 }
374 if(m_debug>1) std::cout<<name()<<" evt "<<t_evtNo<<" t0 "<<m_bunchT0<<" t0Stat "<<m_t0Stat<<std::endl;
375 int trigtiming=-10;
376 SmartDataPtr<TrigData> trigData(eventSvc(),"/Event/Trig/TrigData");
377 if(trigData){
378 log << MSG::INFO <<"Trigger conditions 0--43:"<<endreq;
379 for(int i = 0; i < 48; i++) {
380 log << MSG::INFO << trigData->getTrigCondName(i)<<" ---- "<<trigData->getTrigCondition(i)<< endreq;
381 }
382 for(int i = 0; i < 16; i++) log << MSG::INFO << "Trigger channel "<< i << ": " << trigData->getTrigChannel(i) << endreq;
383 m_timing=trigData->getTimingType();
384
385 log << MSG::INFO <<"Tigger Timing type: "<< trigtiming << endreq;
386 }
387
388
389
390
392 uint32_t getDigiFlag = 0;
393 getDigiFlag += m_maxMdcDigi;
397 mdcDigiVec = m_rawDataProviderSvc->
getMdcDigiVec(getDigiFlag);
398 t_nDigi = mdcDigiVec.size();
399
400
401
402
403
404 if (t_nDigi < m_minMdcDigi){
405 if (0 == t_nDigi ){
406 log << MSG::WARNING << " No hits in MdcDigiVec" << endreq;
407 }
408 log << MSG::WARNING << " Skip this event for MdcDigiVec.size() < "<<m_minMdcDigi << endreq;
409 return StatusCode::SUCCESS;
410 }
411 m_mdcxHits.
create(mdcDigiVec, m_bunchT0, m_cresol);
413
414 if(m_debug>2) m_mdcxHits.
print(std::cout,6796);
415
416
417
418
421 if(m_debug > 1 ){ dumpMdcxSegs(seglist);}
422 t_nSeg = seglist.length();
423
424
425#ifdef MDCXTIMEDEBUG
426 m_timer[1]->stop();
427 m_timer[2]->start();
428#endif
429
430
431
434 if(m_debug>1) dumpTrackList(firsttrkl);
435
436#ifdef MDCXTIMEDEBUG
437 m_timer[2]->stop();
438 m_timer[3]->start();
439#endif
440
441
442
443
444
445
446
447
448
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466 sc = FitMdcxTrack(trkl, dchitlist, m_hitCol, trackList, hitList);
467 if (!sc.isSuccess()) {return StatusCode::SUCCESS;}
468 t_nTdsTk = trackList->size();
469
470 t_nTkTot += trackList->size();
471 if(t_nTdsTk<20) t_nTkNum[t_nTdsTk]++;
472
473#ifdef MDCXTIMEDEBUG
474 m_timer[0]->stop();
475 m_timer[3]->stop();
476#endif
477
478 if(m_hist) fillEvent();
479 if (m_debug > 0) {
480 DataObject* pNode;
481 eventSvc()->retrieveObject("/Event/Recon/RecMdcTrackCol",pNode);
483 eventSvc()->retrieveObject("/Event/Recon/RecMdcHitCol",pNode);
484 int nTdsTk = 0;
485 if(tmpTrackCol) nTdsTk = tmpTrackCol->size();
486
487
488 std::cout<< "MdcxTrackFinder: evtNo "<< m_eventNo << " t0="<<m_bunchT0
489 <<" Found " <<trkl.length()
490 <<" keep "<< t_nTdsTk
491 <<" finialy keep "<< nTdsTk;
492
493 int ndelete =0; trkl.length() - trackList->size();
494 if( ndelete>0 ) std::cout <<" delete "<< ndelete;
495 std::cout <<" track(s)" <<endl;
496
497
498 if(m_debug>1)dumpTdsTrack(tmpTrackCol);
499 if(m_debug>1)dumpTrack(tmpTrackCol);
500
501
502 }
503 if((trackList->size()!=4) ) b_saveEvent = true;
504 setFilterPassed(b_saveEvent);
505 return StatusCode::SUCCESS;
506}
ObjectVector< MdcHit > MdcHitCol
ObjectVector< RecMdcHit > RecMdcHitCol
ObjectVector< RecMdcTrack > RecMdcTrackCol
void print(std::ostream &o, int pmax=10) const
const HepAList< MdcxHit > & GetMdcxHitList()
void create(MdcDigiVec digiVec, float c0=0.0, float cresol=0.0180)
MdcDigiVec & getMdcDigiVec(uint32_t control=0)
_EXTERN_ std::string RecMdcTrackCol
_EXTERN_ std::string RecMdcHitCol
NTuple::Item< long > g_eventNo