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