147 log << MSG::INFO <<
"TofRawDataProvider::tofDataMapFull()" << endreq;
149 if( !m_tofDataMap.empty() ) {
151 log << MSG::WARNING <<
"TofRawDataProvider::tofDataMapFull: m_tofDataMap is NOT empty!" << endreq;
154 for( ;
iter != m_tofDataMap.end();
iter++ ) {
155 delete (*iter).second;
157 m_tofDataMap.clear();
160 std::string evtDataSvc_name(
"EventDataSvc");
161 if(isGaudiThreaded(
m_name)){
162 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
166 IDataProviderSvc* eventSvc;
167 StatusCode sc =
m_svcLocator->service( evtDataSvc_name.c_str(),eventSvc,
true );
168 if( !sc.isSuccess() ) {
169 log << MSG::FATAL <<
"TofRawDataProvider::tofDataMapFull: ERROR Could not load EventDataSvc" << endreq;
174 SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,
"/Event/EventHeader");
176 log << MSG::FATAL <<
"TofRawDataProvider could not find Event Header!" << endreq;
179 m_run = eventHeader->runNumber();
180 m_event = eventHeader->eventNumber();
183 bool mc = ( m_run < 0 ) ?
true:
false;
185 qCorr = qCorr && (!mc);
188 misLable = ( !mc && misLable );
192 for(
unsigned int i=0; i<5; i++ ) {
194 if( identmp != 0x2fffffff ) {
195 deadId.push_back( identmp );
198 if( identmp != 0x2fffffff ) {
199 deadId.push_back( identmp );
202 for(
unsigned int i=0; i<500; i++ ) {
204 if( identmp == 0x2fffffff )
break;
205 else { deadId.push_back( identmp ); }
209 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,
"/Event/Digi/TofDigiCol");
211 log << MSG::WARNING <<
"TofRawDataProvider::tofDataMapFull: Could not find Tof Digi Data!" << endreq;
218 std::vector<Adc*> chargeVec;
219 std::vector<Tdc*> timeVec;
221 TofDigiCol::iterator
iter = tofDigiCol->begin();
222 for( ;
iter != tofDigiCol->end();
iter++ ) {
224 unsigned int iden_value = iden.
get_value();
227 vector<int>::iterator iter_dead = deadId.begin();
228 for( ; iter_dead != deadId.end(); iter_dead++ ) {
229 if( iden_value == (*iter_dead) ) {
235 if( mc ) {
continue; }
241 bore = string(
"Barrel");
246 bore=string(
"East Endcap");
250 bore=string(
"West Endcap");
254 bore=string(
"ETF(MRPC)");
255 tofidtmp = TofID::module(iden);
264 unsigned int overflow = (*iter)->getOverflow();
265 if(
TofID::is_scin(iden) && ( ( overflow & 0xfe000000 ) == 0xfe000000 ) )
continue;
275 if( ( iden_value & 0x2fffffe0 ) == 0x2000c800 ) {
276 iden_value = 0x2000c900 + ( iden_value & 0x1f );
280 if( ( iden_value & 0x2fffffe0 ) == 0x2000c820 ) {
281 iden_value = 0x2000c8e0 + ( iden_value & 0x1f );
290 bool multiQ = ( ( overflow & 0x8 ) != 0 );
291 bool multiT = ( ( overflow & 0x4 ) != 0 );
293 unsigned int tdcChannel = (*iter)->getTimeChannel();
294 unsigned int adcChannel = (*iter)->getChargeChannel();
296 adcChannel = ( adcChannel | 0x80000 );
299 if( (adcChannel&0x7fffffff) != 0x7fffffff ) {
307 adcChannel += 0x18000;
314 chargeVec.push_back( adc );
317 if( tdcChannel != 0x7fffffff ) {
323 tdcChannel += 0x18000;
330 timeVec.push_back( tdc );
333 if( multiT || multiQ ) {
334 TofDigiCol::iterator iter_next =
iter + 1;
335 if( iter_next != tofDigiCol->end() ) {
336 unsigned int idenNext_value = ((*iter_next)->identify()).get_value();
337 if( iden_value == idenNext_value )
continue;
344 std::vector<PmtData*> pmtDataVec;
346 std::vector<Tdc*>::iterator iter_t = timeVec.begin();
347 for( ; iter_t != timeVec.end(); iter_t++ ) {
348 int tclock = (*iter_t)->clock();
352 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
353 for( ; iter_q != chargeVec.end(); iter_q++ ) {
354 if( (*iter_q)->times() != -1 ) {
continue; }
355 int qclock = (*iter_q)->clock();
356 if(
abs(tclock-qclock)<2 ) {
357 if( ( pmt->
quality() & 0x2 ) != 0 ) {
358 if( (*iter_q)->value() > pmt->
adc() ) {
368 pmtDataVec.push_back( pmt );
371 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
372 for( ; iter_q != chargeVec.end(); iter_q++ ) {
373 if( (*iter_q)->times() != -1 ) {
continue; }
377 pmtDataVec.push_back( pmt );
383 std::vector<Tdc*>::iterator iter_t = timeVec.begin();
384 for( ; iter_t != timeVec.end(); iter_t++ ) {
385 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
386 for( ; iter_q != chargeVec.end(); iter_q++ ) {
387 if( ( (*iter_q)->qtc() - (*iter_t)->value() ) >
totForward && ( (*iter_q)->qtc() - (*iter_t)->value() ) <
totBackward ) {
392 pmtDataVec.push_back( pmt );
395 if( (*iter_t)->times() == -1 ) {
398 pmtDataVec.push_back( pmt );
402 std::vector<Adc*>::iterator iter_q = chargeVec.begin();
403 for( ; iter_q != chargeVec.end(); iter_q++ ) {
404 if( (*iter_q)->times() != -1 ) {
continue; }
408 pmtDataVec.push_back( pmt );
416 unsigned int iden_value_key = (iden_value & 0xfffffffe );
422 if( ( barrel_ec == 0 ) || ( barrel_ec == 2 ) ) {
423 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
424 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
428 if( barrel_ec==2 && tofid==42 ) {
430 iden_value_key = iden91;
433 if( barrel_ec==2 && tofid==43 ) {
435 iden_value_key = iden90;
442 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
445 else if( barrel_ec == 1 ) {
446 unsigned int count = m_tofDataMap.count( iden_value_key );
448 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
449 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
459 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
463 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
464 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
465 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
468 for(
unsigned int tofDataNumber = 0; tofDataNumber <
count; tofDataNumber++,
iter++ ) {
470 bool matched =
false;
472 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
473 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
474 double time1 = (*iter_pmt)->tdc();
475 double time2 = ((*iter).second)->tdc2();
479 if( ( ((*iter).second)->quality() & 0x2 ) != 0 ) {
480 double time1 = (*iter_pmt)->tclock();
481 double time2 = (*iter_pmt)->qclock();
482 double time3 = ((*iter).second)->qclock2();
488 if( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) {
489 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
490 if( ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
491 double time1 = (*iter_pmt)->qclock();
492 double time2 = ((*iter).second)->tclock2();
493 double time3 = ((*iter).second)->qclock2();
498 if( ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) {
499 double time1 = (*iter_pmt)->qclock();
500 double time2 = ((*iter).second)->qclock2();
509 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
510 ((*iter).second)->setForward( (*iter_pmt) );
518 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
524 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
525 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
526 double time1 = (*iter_pmt)->tdc();
527 double time2 = ((*iter).second)->tdc1();
531 if( ( ((*iter).second)->quality() & 0x8 ) != 0 ) {
532 double time1 = (*iter_pmt)->tclock();
533 double time2 = (*iter_pmt)->qclock();
534 double time3 = ((*iter).second)->qclock1();
540 if( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) {
541 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
542 if( ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
543 double time1 = (*iter_pmt)->qclock();
544 double time2 = ((*iter).second)->tclock1();
545 double time3 = ((*iter).second)->qclock1();
552 if( ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) {
553 double time1 = (*iter_pmt)->qclock();
554 double time2 = ((*iter).second)->qclock1();
563 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
564 ((*iter).second)->setBackward( (*iter_pmt) );
569 tof->
setForward( ((*iter).second)->forward() );
572 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
588 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
598 int tofid = TofID::module( iden );
602 unsigned int count = m_tofDataMap.count( iden_value_key );
604 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
605 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
615 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
619 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
620 std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
621 for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
624 for(
unsigned int tofDataNumber = 0; tofDataNumber <
count; tofDataNumber++,
iter++ ) {
625 bool matched =
false;
627 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
628 if( ( ((*iter).second)->quality() & 0x1 ) != 0 ) {
629 double time1 = (*iter_pmt)->tdc();
630 double time2 = ((*iter).second)->tdc2();
632 if( endcap==0 && tofid==13 && strip==5 ) { matched = (
abs(time1-time2)<(100+
timeDiffMRPC) ); }
669 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
670 ((*iter).second)->setForward( (*iter_pmt) );
678 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
683 if( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) {
684 if( ( ((*iter).second)->quality() & 0x4 ) != 0 ) {
685 double time1 = (*iter_pmt)->tdc();
686 double time2 = ((*iter).second)->tdc1();
688 if( endcap==0 && tofid==13 && strip==5 ) { matched = (
abs(time1-time2)<(100+
timeDiffMRPC) ); }
725 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
726 ((*iter).second)->setBackward( (*iter_pmt) );
731 tof->
setForward( ((*iter).second)->forward() );
734 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
750 m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
769 log << MSG::INFO <<
"TofRawDataProvider::tofDataMapOnlineMode()" << endreq;
771 if( ! m_tofDataMapOnline.empty() ) {
774 for( ;
iter != m_tofDataMapOnline.end();
iter++ ) {
775 delete (*iter).second;
777 m_tofDataMapOnline.clear();
779 else return m_tofDataMapOnline;
782 std::string evtDataSvc_name(
"EventDataSvc");
783 if(isGaudiThreaded(
m_name)){
784 evtDataSvc_name += getGaudiThreadIDfromName(
m_name);
788 IDataProviderSvc* eventSvc;
789 StatusCode sc =
m_svcLocator->service( evtDataSvc_name.c_str(), eventSvc,
true );
790 if( !sc.isSuccess() ) {
791 log << MSG::FATAL <<
"TofRawDataProvider::tofDataMapOnlineMode(): ERROR Could not load EventDataSvc" << endreq;
792 return m_tofDataMapOnline;
796 SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,
"/Event/Digi/TofDigiCol");
798 log << MSG::WARNING <<
"TofRawDataProvider::tofDataMapOnlineMode(): Could not find Tof Digi Data!" << endreq;
799 return m_tofDataMapOnline;
802 TofDigiCol::iterator
iter = tofDigiCol->begin();
803 for( ;
iter != tofDigiCol->end();
iter++ ) {
804 unsigned int overflow = (*iter)->getOverflow();
805 if( ( overflow & 0xfe000000 ) == 0xfe000000 )
continue;
809 bool noT = ( ( overflow & 0x10 ) != 0 );
815 unsigned int iden_value = iden.
get_value();
820 unsigned int tdcChannel = (*iter)->getTimeChannel();
821 if( tdcChannel == 0x7fffffff )
continue;
828 unsigned int iden_value_key = ( iden_value & 0xfffffffe );
829 if( barrel_ec == 0 || barrel_ec == 2 ) {
833 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
835 else if( barrel_ec == 1 || barrel_ec == 3 ) {
836 unsigned int count = m_tofDataMapOnline.count( iden_value_key );
847 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
851 pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMapOnline.equal_range( iden_value_key );
853 for(
unsigned int i=0; i<
count; i++,
iter++ ) {
854 if( ( end == 0 ) && ( ( ( (*iter).second)->quality() & 0x1 ) != 0 ) ) {
855 double time1 = pmt->
tdc();
856 double time2 = ((*iter).second)->tdc2();
859 if( ( ( (*iter).second)->quality() & 0x4 ) == 0 ) {
860 ((*iter).second)->setForward( pmt );
867 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
871 else if( ( end == 1 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) {
872 double time1 = ((*iter).second)->tdc1();
873 double time2 = pmt->
tdc();
877 if( ( ( (*iter).second)->quality() & 0x1 ) == 0 ) {
878 ((*iter).second)->setBackward( pmt );
883 tof->
setForward( ((*iter).second)->forward() );
885 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
899 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
905 return m_tofDataMapOnline;