Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

TofRawDataProvider Class Reference

#include <TofRawDataProvider.h>

Inheritance diagram for TofRawDataProvider:

RawDataProviderBase RawDataProviderBase List of all members.

Public Member Functions

void handle (const Incident &)
void handle (const Incident &)
StatusCode initialize (ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
StatusCode initialize (bool mode=false, ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
StatusCode initialize (bool mode=false, ISvcLocator *svcLoc=0, IMessageSvc *pMsg=0)
void setMsgName (const char *name)
void setMsgName (const char *name)
void setMsgSvc (IMessageSvc *svc)
void setMsgSvc (IMessageSvc *svc)
void setSvcLocator (ISvcLocator *svcLoc)
void setSvcLocator (ISvcLocator *svcLoc)
TofDataMaptofDataMapEmc (double estime=0.0)
TofDataMaptofDataMapEmc (double estime=0.0)
TofDataMaptofDataMapEstime ()
TofDataMaptofDataMapEstime ()
void tofDataMapFull ()
void tofDataMapFull ()
TofDataMaptofDataMapOnlineMode (uint32_t control=1)
TofDataMaptofDataMapOnlineMode (uint32_t control=1)
TofDataMaptofDataMapTof (double estime=0.0)
TofDataMaptofDataMapTof (double estime=0.0)
TofDataVectortofDataVectorEmc (double estime=0.0)
TofDataVectortofDataVectorEmc (double estime=0.0)
TofDataVectortofDataVectorEstime ()
TofDataVectortofDataVectorEstime ()
TofDataVectortofDataVectorOnlineMode (uint32_t control=1)
TofDataVectortofDataVectorOnlineMode (uint32_t control=1)
TofDataVectortofDataVectorTof (double estime=0.0)
TofDataVectortofDataVectorTof (double estime=0.0)
 TofRawDataProvider (const char *name)
 TofRawDataProvider ()
 TofRawDataProvider (const char *name)
 TofRawDataProvider ()
 ~TofRawDataProvider ()
 ~TofRawDataProvider ()

Protected Attributes

IMessageSvc * m_msgSvc
IMessageSvc * m_msgSvc
std::string m_name
ISvcLocator * m_svcLocator
ISvcLocator * m_svcLocator

Private Attributes

bool m_hasFilled
TofDataMap m_tofDataMap
TofDataMap m_tofDataMapEmc
TofDataMap m_tofDataMapEstime
TofDataMap m_tofDataMapOnline
TofDataMap m_tofDataMapTof
TofDataVector m_tofDataVectorEmc
TofDataVector m_tofDataVectorEstime
TofDataVector m_tofDataVectorOnline
TofDataVector m_tofDataVectorTof

Constructor & Destructor Documentation

TofRawDataProvider::TofRawDataProvider  ) 
 

00031                                        :
00032   RawDataProviderBase(),
00033   m_hasFilled(0)
00034 {}

TofRawDataProvider::TofRawDataProvider const char *  name  ) 
 

00037                                                          :
00038   RawDataProviderBase( name ),
00039   m_hasFilled(0)
00040 {}

TofRawDataProvider::~TofRawDataProvider  ) 
 

00043                                         {
00044   IterTofDataMap iter = m_tofDataMap.begin();
00045   for( ; iter != m_tofDataMap.end(); iter++ ) {
00046     delete (*iter).second;
00047   }
00048   m_tofDataMap.clear();
00049 
00050   m_tofDataMapOnline.clear();
00051   m_tofDataVectorOnline.clear();
00052   m_tofDataMapEstime.clear();
00053   m_tofDataVectorEstime.clear();
00054   m_tofDataMapTof.clear();
00055   m_tofDataVectorTof.clear();
00056   m_tofDataMapEmc.clear();
00057   m_tofDataVectorEmc.clear();
00058 
00059   return;
00060 }

TofRawDataProvider::TofRawDataProvider  ) 
 

TofRawDataProvider::TofRawDataProvider const char *  name  ) 
 

TofRawDataProvider::~TofRawDataProvider  ) 
 


Member Function Documentation

void TofRawDataProvider::handle const Incident &   ) 
 

void TofRawDataProvider::handle const Incident &   ) 
 

00098                                                   {
00099   MsgStream log( m_msgSvc, m_name );
00100   log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00101   if ( inc.type() == "BeginEvent" ){
00102     log << MSG::DEBUG << "Begin Event" << endreq;
00103     IterTofDataMap iter = m_tofDataMap.begin();
00104     for( ; iter != m_tofDataMap.end(); iter++ ) {
00105       delete (*iter).second;
00106     }
00107     m_tofDataMap.clear();
00108     m_tofDataMapOnline.clear();
00109     m_tofDataVectorOnline.clear();
00110     m_tofDataMapEstime.clear();
00111     m_tofDataVectorEstime.clear();
00112     m_tofDataMapTof.clear();
00113     m_tofDataVectorTof.clear();
00114     m_tofDataMapEmc.clear();
00115     m_tofDataVectorEmc.clear();
00116 
00117     m_hasFilled = false;
00118   }
00119   return;
00120 }

StatusCode RawDataProviderBase::initialize ISvcLocator *  svcLoc = 0,
IMessageSvc *  pMsg = 0
[inherited]
 

Reimplemented in MdcRawDataProvider, and MdcRawDataProvider.

00026                                                                                     {
00027   if(pSvcLoc!=0){
00028     // test service point
00029     // tianhl for mt
00030     std::string evtDataSvc_name("EventDataSvc");
00031     if(isGaudiThreaded(m_name)){
00032       evtDataSvc_name += getGaudiThreadIDfromName(m_name);
00033       std::cout << "---------------------------------- " <<  evtDataSvc_name << std::endl;
00034     }
00035     // tianhl for mt
00036     IDataProviderSvc* evtSvc;
00037     StatusCode sc = pSvcLoc->service(evtDataSvc_name.c_str(),evtSvc,true);
00038     if (!sc.isSuccess()){
00039       std::cout << "RawDataProviderBase::initialize()  ERROR Could not load EventDataSvc" << std::endl;
00040       return StatusCode::FAILURE;
00041     }
00042     m_svcLocator= pSvcLoc;
00043   }
00044   else {
00045     m_svcLocator= Gaudi::svcLocator();
00046   }
00047   try{
00048     if(pMsg!=0){
00049       MsgStream log(pMsg, m_name);
00050       log << MSG::INFO << "RawDataProviderBase::initialize()  Test..." << endreq;
00051       m_msgSvc=pMsg;
00052     }
00053     else{ 
00054       StatusCode sc = m_svcLocator->service("MessageSvc", m_msgSvc ,true);
00055       if (!sc.isSuccess()) throw SvcDisable("MessageSvc");
00056     }
00057   }
00058   catch(...){
00059     std::cout << "RawDataProviderBase::initialize()  ERROR Could not get MessageSvc" << std::endl;
00060   }
00061 
00062   return StatusCode::SUCCESS;
00063 }

StatusCode TofRawDataProvider::initialize bool  mode = false,
ISvcLocator *  svcLoc = 0,
IMessageSvc *  pMsg = 0
 

StatusCode TofRawDataProvider::initialize bool  mode = false,
ISvcLocator *  svcLoc = 0,
IMessageSvc *  pMsg = 0
 

00063                                                                                               {
00064   MsgStream log( m_msgSvc, m_name );
00065   RawDataProviderBase::initialize( pSvcLoc,pMsg );
00066 
00067   //Get TOF Calibtration Service
00068   StatusCode scc = m_svcLocator->service("TofCaliSvc", tofCaliSvc);
00069   if (scc ==  StatusCode::SUCCESS) { 
00070     log << MSG::INFO << "TofRec Get Calibration Service Sucessfully!" << endreq;
00071   } else if(!mode) {
00072     log << MSG::ERROR << "TofRec Get Calibration Service Failed !" << endreq;
00073     return StatusCode::FAILURE;
00074   }
00075 
00076   //Get TOF Q Correction Service
00077   StatusCode scq = m_svcLocator->service("TofQCorrSvc", tofQCorrSvc);
00078   if (scq ==  StatusCode::SUCCESS) { 
00079     log << MSG::INFO << "TofRec Get Q Correction Service Sucessfully!" << endreq;
00080   } else if(!mode){
00081     log << MSG::ERROR << "TofRec Get Q Correction Service Failed !" << endreq;
00082     return StatusCode::FAILURE;
00083   }
00084 
00085   //Get TOF Q Electronics Saturation Service
00086   StatusCode sce = m_svcLocator->service("TofQElecSvc", tofQElecSvc);
00087   if (sce ==  StatusCode::SUCCESS) { 
00088     log << MSG::INFO << "TofRec Get Q Electronics Calibration Service Sucessfully!" << endreq;
00089   } else if(!mode){
00090     log << MSG::ERROR << "TofRec Get Q Electronics Calibration Service Failed !" << endreq;
00091     return StatusCode::FAILURE;
00092   }
00093 
00094   return StatusCode::SUCCESS; 
00095 }

void RawDataProviderBase::setMsgName const char *  name  )  [inline, inherited]
 

00029 { m_name = std::string(name); };

void RawDataProviderBase::setMsgName const char *  name  )  [inline, inherited]
 

00029 { m_name = std::string(name); };

void RawDataProviderBase::setMsgSvc IMessageSvc *  svc  )  [inline, inherited]
 

00028 { m_msgSvc=svc; };

void RawDataProviderBase::setMsgSvc IMessageSvc *  svc  )  [inline, inherited]
 

00028 { m_msgSvc=svc; };

void RawDataProviderBase::setSvcLocator ISvcLocator *  svcLoc  )  [inline, inherited]
 

00027 { m_svcLocator=svcLoc; };

void RawDataProviderBase::setSvcLocator ISvcLocator *  svcLoc  )  [inline, inherited]
 

00027 { m_svcLocator=svcLoc; };

TofDataMap& TofRawDataProvider::tofDataMapEmc double  estime = 0.0  ) 
 

TofDataMap & TofRawDataProvider::tofDataMapEmc double  estime = 0.0  ) 
 

00722                                                              {
00723 
00724   if( !m_hasFilled ) {
00725     TofRawDataProvider::tofDataMapFull();
00726     m_hasFilled = true;
00727   }
00728 
00729   if( !m_tofDataMapEmc.empty() ) {
00730     m_tofDataMapEmc.clear();
00731   }
00732 
00733   IterTofDataMap iter = m_tofDataMap.begin();
00734   for( ; iter != m_tofDataMap.end(); iter++ ) {
00735     if( ( ((*iter).second)->quality() & 0xa ) != 0 ) {
00736 
00737       if( estime > 1.0e-6 ) {
00738         int t0clock = static_cast<int>(estime/24.0);
00739         int clock1 = ((*iter).second)->qclock1();
00740         int clock2 = ((*iter).second)->qclock2();
00741         bool  forward = ( ( ( t0clock - clock1 ) < tClockBackward ) && ( ( clock1 - t0clock ) < tClockForward ) );
00742         bool backward = ( ( ( t0clock - clock2 ) < tClockBackward ) && ( ( clock2 - t0clock ) < tClockForward ) );
00743         if( !forward && !backward ) continue;
00744       }
00745 
00746       m_tofDataMapEmc.insert( make_pair( (*iter).first, (*iter).second ) );
00747     }
00748   }
00749 
00750   iter = m_tofDataMapEmc.begin();
00751   while( iter != m_tofDataMapEmc.end() ) {
00752     unsigned int iden_value = (*iter).first;
00753     unsigned int count = m_tofDataMapEmc.count( iden_value );
00754     for( unsigned int i=0; i != count; i++, iter++ ) {
00755       ((*iter).second)->setTimes( count );
00756     }
00757   }
00758 
00759   return m_tofDataMapEmc;
00760 }

TofDataMap& TofRawDataProvider::tofDataMapEstime  ) 
 

TofDataMap & TofRawDataProvider::tofDataMapEstime  ) 
 

00623                                                  {
00624 
00625   if( !m_hasFilled ) {
00626     TofRawDataProvider::tofDataMapFull();
00627     m_hasFilled = true;
00628   }
00629 
00630   if( !m_tofDataMapEstime.empty() ) {
00631     m_tofDataMapEstime.clear();
00632   }
00633 
00634   IterTofDataMap iter = m_tofDataMap.begin();
00635   for( ; iter != m_tofDataMap.end(); iter++ ) {
00636     if( ( ( ((*iter).second)->quality() & 0x5 ) != 0 ) && ((*iter).second)->tmatched() ) {
00637       m_tofDataMapEstime.insert( make_pair( (*iter).first, (*iter).second ) );
00638     }
00639   }
00640 
00641   iter = m_tofDataMapEstime.begin();
00642   while( iter != m_tofDataMapEstime.end() ) {
00643     unsigned int iden_value = (*iter).first;
00644     unsigned int count = m_tofDataMapEstime.count( iden_value );
00645     for( unsigned int i=0; i != count; i++, iter++ ) {
00646       ((*iter).second)->setTimes( count );
00647     }
00648   }
00649 
00650   return m_tofDataMapEstime;
00651 }

void TofRawDataProvider::tofDataMapFull  ) 
 

void TofRawDataProvider::tofDataMapFull  ) 
 

00124                                         {
00125 
00126   MsgStream log(m_msgSvc, m_name);
00127   log << MSG::INFO << "TofRawDataProvider::tofDataMapFull()" << endreq;
00128 
00129   if( !m_tofDataMap.empty() ) {
00130 
00131     log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: m_tofDataMap is NOT empty!" << endreq;
00132 
00133     IterTofDataMap iter = m_tofDataMap.begin();
00134     for( ; iter != m_tofDataMap.end(); iter++ ) {
00135       delete (*iter).second;
00136     }
00137     m_tofDataMap.clear();
00138   }
00139    // tianhl for mt
00140     std::string evtDataSvc_name("EventDataSvc");
00141     if(isGaudiThreaded(m_name)){
00142       evtDataSvc_name += getGaudiThreadIDfromName(m_name);
00143     }
00144     // tianhl for mt
00145 
00146   IDataProviderSvc* eventSvc;
00147   StatusCode sc = m_svcLocator->service( evtDataSvc_name.c_str(),eventSvc, true );
00148   if( !sc.isSuccess() ) {
00149     log << MSG::FATAL << "TofRawDataProvider::tofDataMapFull: ERROR Could not load EventDataSvc" << endreq;
00150     return;
00151   }
00152 
00153   // Event Header
00154   SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00155   if( !eventHeader ) {
00156     log << MSG::FATAL << "TofRawDataProvider could not find Event Header!" << endreq;
00157     return;
00158   }
00159   int run = eventHeader->runNumber();
00160 
00161   bool mc = ( run < 0 ) ? true:false;
00162   bool qCorr = bool( tofCaliSvc->QCorr() );
00163   qCorr = qCorr && (!mc);
00164   bool qElec = bool( tofCaliSvc->QElec() );
00165   bool misLable = bool( tofCaliSvc->MisLable() );
00166   misLable = ( !mc && misLable );
00167   vector<int> deadId;
00168 
00169   int identmp = -1;
00170   for( unsigned int i=0; i<5; i++ ) {
00171     identmp = tofCaliSvc->BrEast(i);
00172     if( identmp != 0x2fffffff ) {
00173       deadId.push_back( identmp );
00174     }
00175     identmp = tofCaliSvc->BrWest(i);
00176     if( identmp != 0x2fffffff ) {
00177       deadId.push_back( identmp );
00178     }
00179     identmp = tofCaliSvc->Endcap(i);
00180     if( identmp != 0x2fffffff ) {
00181       deadId.push_back( identmp );
00182     }
00183   }
00184 
00185   // get TDS data in a common class
00186   SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,"/Event/Digi/TofDigiCol");
00187   if( !tofDigiCol ) {
00188     log << MSG::WARNING << "TofRawDataProvider::tofDataMapFull: Could not find Tof Digi Data!" << endreq;
00189     return;
00190   } 
00191 
00192   int qnumber = 0;
00193   int tnumber = 0;
00194 
00195   std::vector<Adc*> chargeVec;
00196   std::vector<Tdc*> timeVec;
00197 
00198   TofDigiCol::iterator iter = tofDigiCol->begin();
00199   for( ; iter != tofDigiCol->end(); iter++ ) {
00200     unsigned int overflow   = (*iter)->getOverflow();
00201     // electronics error message
00202     if( ( overflow & 0xfe000000 ) == 0xfe000000 ) continue;
00203     // overflow 0x   1 1         1 1            1 1
00204     //            no Q T / multi Q T / overflow Q T
00205     
00206     bool multiQ = ( ( overflow & 0x8 ) != 0 );
00207     bool multiT = ( ( overflow & 0x4 ) != 0 );
00208  
00209     Identifier iden = (*iter)->identify();
00210     unsigned int iden_value = iden.get_value();
00211 
00212     bool sameId = false;
00213     vector<int>::iterator iter_dead = deadId.begin();
00214     for( ; iter_dead != deadId.end(); iter_dead++ ) {
00215       if( iden_value == (*iter_dead) ) {
00216         sameId = true;
00217         break;
00218       }
00219     }
00220     if( sameId ) {
00221       if( mc ) { continue; }
00222       else {
00223         log << MSG::ERROR << "TofRawDataProvider::tofDataMapFull: Dead Channel Number is not Correct, please check TOF Calibration Constants!" << endreq;
00224      }
00225     }
00226 
00227     int  barrel_ec  = TofID::barrel_ec(iden);
00228     int  id         = TofID::phi_module(iden);
00229     int  end        = TofID::end(iden);
00230     if( ( barrel_ec != 1 ) && ( end == 1 ) ) continue;
00231     // TofDigiCol 48 and 96 for luminocity
00232     if( ( barrel_ec != 1 ) && ( id == 48 ) ) continue;
00233 
00234     unsigned int tdcChannel = (*iter)->getTimeChannel();
00235     unsigned int adcChannel = (*iter)->getChargeChannel();
00236     if( ( overflow & 0x2 ) != 0 ) { adcChannel = ( adcChannel | 0x80000 ); }
00237 
00238     if( (adcChannel&0x7fffffff) != 0x7fffffff ) {
00239       Adc* adc = new Adc;
00240       if( qCorr ) adc->setCorr();
00241       if( qElec ) adc->setElec();
00242       adc->setValue( adcChannel );
00243       qnumber++;
00244       adc->setNumber( qnumber );
00245       chargeVec.push_back( adc );
00246     }
00247 
00248     if( tdcChannel != 0x7fffffff ) {
00249       Tdc* tdc = new Tdc;
00250       tdc->setValue( tdcChannel );
00251       tnumber++;
00252       tdc->setNumber( tnumber );
00253       timeVec.push_back( tdc );
00254     }
00255 
00256     if( multiT || multiQ ) {
00257       TofDigiCol::iterator iter_next = iter + 1;
00258       if( iter_next != tofDigiCol->end() ) {
00259         unsigned int idenNext_value = ((*iter_next)->identify()).get_value();
00260         if( iden_value == idenNext_value ) continue;
00261       }
00262     }
00263 
00264     qnumber = 0;
00265     tnumber = 0;
00266 
00267     std::vector<PmtData*> pmtDataVec;
00268     std::vector<Tdc*>::iterator iter_t = timeVec.begin();
00269     for( ; iter_t != timeVec.end(); iter_t++ ) {
00270       int tclock = (*iter_t)->clock();
00271       PmtData* pmt = new PmtData;
00272       pmt->setTdc( (*iter_t) );
00273       std::vector<Adc*>::iterator iter_q = chargeVec.begin();
00274       for( ; iter_q != chargeVec.end(); iter_q++ ) {
00275         int qclock = (*iter_q)->clock();
00276         if( abs(tclock-qclock)<2 ) {
00277           if( ( pmt->quality() & 0x2 ) != 0 ) {         // pmt has Q
00278             if( (*iter_q)->value() > pmt->adc() ) {
00279               pmt->qtimesmm();
00280               pmt->setAdc( (*iter_q) );
00281             }
00282           }
00283           else {                                        // pmt has no Q
00284             pmt->setAdc( (*iter_q) );
00285           }
00286         }
00287       }
00288       pmtDataVec.push_back( pmt );
00289     }
00290 
00291     std::vector<Adc*>::iterator iter_q = chargeVec.begin();
00292     for( ; iter_q != chargeVec.end(); iter_q++ ) {
00293       if( (*iter_q)->times() != -1 ) continue;
00294       PmtData* pmt = new PmtData;
00295       pmt->setAdc( (*iter_q) );
00296       pmtDataVec.push_back( pmt );
00297     }
00298 
00299     chargeVec.clear();
00300     timeVec.clear();
00301 
00302     unsigned int iden_value_key = ( iden_value & 0xfffffffe );
00303 
00304     if( ( barrel_ec == 0 ) || ( barrel_ec == 2 ) ) {
00305       std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
00306       for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
00307         TofData* tof = new TofData;
00308         if( misLable ) { tof->setMisLable(); }
00309         tof->setIdentify( iden );
00310         tof->setForward( (*iter_pmt) );
00311         tof->setTMatched( true );
00312         m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
00313       }
00314     }
00315     else if( barrel_ec == 1 ) {
00316       unsigned int count = m_tofDataMap.count( iden_value_key );
00317       if( count == 0 ) {
00318         std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
00319         for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
00320           TofData* tof = new TofData;
00321           tof->setIdentify( iden );
00322           if( end == 0 ) {
00323             tof->setForward( (*iter_pmt) );
00324           }
00325           else {
00326             tof->setBackward( (*iter_pmt) );
00327           }
00328           tof->setTMatched( true );
00329           m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
00330         }
00331       }
00332       else {
00333         pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMap.equal_range( iden_value_key );
00334         std::vector<PmtData*>::iterator iter_pmt = pmtDataVec.begin();
00335         for( ; iter_pmt != pmtDataVec.end(); iter_pmt++ ) {
00336           bool used = false;
00337           IterTofDataMap iter = range.first;
00338           for( unsigned int tofDataNumber = 0; tofDataNumber < count; tofDataNumber++, iter++ ) {
00339             bool matched = false;
00340             if( end == 0 ) { // east, forward
00341               if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) != 0 ) ) { // has east and west time
00342                 double time1 = (*iter_pmt)->tdc();
00343                 double time2 = ((*iter).second)->tdc2();
00344                 matched = ( abs(time1-time2)<timeDiff );
00345               }
00346               else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) != 0 ) ) { // has east charge and west time
00347                 double time1 = (*iter_pmt)->qclock();
00348                 double time2 = ((*iter).second)->tclock2();
00349                 double time3 = ((*iter).second)->qclock2();
00350                 matched = ( ( abs(time1-time2)<=tClockDiff ) || ( abs(time1-time3)<=tClockDiff ) );
00351               }
00352               else if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) { // has east time and west charge
00353                 double time1 = (*iter_pmt)->tclock();
00354                 double time2 = (*iter_pmt)->qclock();
00355                 double time3 = ((*iter).second)->qclock2();
00356                 matched = ( ( abs(time1-time3)<=tClockDiff ) || ( abs(time2-time3)<=tClockDiff ) );
00357               }
00358               else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x1 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x2 ) != 0 ) ) { // has east and west charge
00359                 double time1 = (*iter_pmt)->qclock();
00360                 double time2 = ((*iter).second)->qclock2();
00361                 matched = ( abs(time1-time2)<=tClockDiff );
00362               }
00363               
00364               if( matched ) {
00365                 used = true;
00366                 if( ( ( (*iter).second)->quality() & 0xc ) == 0 ) {
00367                   ((*iter).second)->setForward( (*iter_pmt) );
00368                 }
00369                 else {
00370                   TofData* tof = new TofData;
00371                   tof->setIdentify( iden );
00372                   tof->setForward( (*iter_pmt) );
00373                   tof->setBackward( ((*iter).second)->backward() );
00374                   m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
00375                 }
00376               }
00377               
00378             }
00379             else { // west, backward
00380               if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) { // has west and east time
00381                 double time1 = (*iter_pmt)->tdc();
00382                 double time2 = ((*iter).second)->tdc1();
00383                 matched = ( abs(time1-time2)<timeDiff );
00384               }
00385               else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) { // has west charge and east time 
00386                 double time1 = (*iter_pmt)->qclock();
00387                 double time2 = ((*iter).second)->tclock1();
00388                 double time3 = ((*iter).second)->qclock1();
00389                 matched = ( ( abs(time1-time2)<=tClockDiff ) || ( abs(time1-time3)<=tClockDiff ) );
00390               }
00391               else if( ( ( (*iter_pmt)->quality() & 0x1 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) { // has east time and west charge
00392                 double time1 = (*iter_pmt)->tclock();
00393                 double time2 = (*iter_pmt)->qclock();
00394                 double time3 = ((*iter).second)->qclock1();
00395                 matched = ( ( abs(time1-time3)<=tClockDiff ) || ( abs(time2-time3)<=tClockDiff ) );
00396               }
00397               else if( ( ( (*iter_pmt)->quality() & 0x1 ) == 0 ) && ( ( (*iter_pmt)->quality() & 0x2 ) != 0 ) && ( ( ((*iter).second)->quality() & 0x4 ) == 0 ) && ( ( ((*iter).second)->quality() & 0x8 ) != 0 ) ) { // has east and west charge
00398                 double time1 = (*iter_pmt)->qclock();
00399                 double time2 = ((*iter).second)->qclock1();
00400                 matched = ( abs(time1-time2)<=tClockDiff );
00401               }
00402               
00403               if( matched ) {
00404                 used = true;
00405                 if( ( ( (*iter).second)->quality() & 0x3 ) == 0 ) {
00406                   ((*iter).second)->setBackward( (*iter_pmt) );
00407                   if( ( ( ((*iter).second)->quality() & 0x5 )==0x5 ) || ( ( ( ((*iter).second)->quality() & 0x5 )==0x4 ) && ( ((*iter).second)->ttimes1()==1 ) ) || ( ( ( ((*iter).second)->quality() & 0x5 )==0x1 ) && ( ((*iter).second)->ttimes2()==1 ) ) ) {
00408                     ((*iter).second)->setTMatched( true );
00409                   }
00410                   else {
00411                     ((*iter).second)->setTMatched( false );
00412                   }
00413                 }
00414                 else {
00415                   TofData* tof = new TofData;
00416                   tof->setIdentify( iden );
00417                   tof->setForward( ((*iter).second)->forward() );
00418                   tof->setBackward( (*iter_pmt) );
00419                   if( ( ( tof->quality() & 0x5 )==0x5 ) || ( ( ( tof->quality() & 0x5 )==0x4 ) && ( tof->ttimes1()==1 ) ) || ( ( ( tof->quality() & 0x5 )==0x1 ) && ( tof->ttimes2()==1 ) ) ) {
00420                     tof->setTMatched( true );
00421                   }
00422                   else {
00423                     tof->setTMatched( false );
00424                   }
00425                   m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
00426                 }
00427               }
00428             }
00429           }
00430           if( ! used ) {
00431             TofData* tof = new TofData;
00432             tof->setIdentify( iden );
00433             if( end == 0 ) {
00434               tof->setForward( (*iter_pmt) );
00435             }
00436             else {
00437               tof->setBackward( (*iter_pmt) );
00438             } 
00439             tof->setTMatched( true );
00440             m_tofDataMap.insert( make_pair( iden_value_key, tof ) );
00441           }
00442         }
00443       }
00444     }
00445 
00446     pmtDataVec.clear();
00447 
00448   }
00449 
00450   return;
00451 
00452 }

TofDataMap& TofRawDataProvider::tofDataMapOnlineMode uint32_t  control = 1  ) 
 

TofDataMap & TofRawDataProvider::tofDataMapOnlineMode uint32_t  control = 1  ) 
 

00456                                                                      {
00457 
00458   MsgStream log(m_msgSvc, m_name);
00459   log << MSG::INFO << "TofRawDataProvider::tofDataMapOnlineMode()" << endreq;
00460 
00461   if( ! m_tofDataMapOnline.empty() ) {
00462     if(control){
00463       IterTofDataMap iter = m_tofDataMapOnline.begin();
00464       for( ; iter != m_tofDataMapOnline.end(); iter++ ) {
00465         delete (*iter).second;
00466       }
00467       m_tofDataMapOnline.clear();
00468     }
00469     else return m_tofDataMapOnline;
00470   }
00471     // tianhl for mt
00472     std::string evtDataSvc_name("EventDataSvc");
00473     if(isGaudiThreaded(m_name)){
00474       evtDataSvc_name += getGaudiThreadIDfromName(m_name);
00475     }
00476     // tianhl for mt
00477 
00478   IDataProviderSvc* eventSvc;
00479   StatusCode sc = m_svcLocator->service( evtDataSvc_name.c_str(), eventSvc, true );
00480   if( !sc.isSuccess() ) {
00481     log << MSG::FATAL << "TofRawDataProvider::tofDataMapOnlineMode(): ERROR Could not load EventDataSvc" << endreq;
00482     return m_tofDataMapOnline;
00483   }
00484 
00485   // get TDS data in a common class
00486   SmartDataPtr<TofDigiCol> tofDigiCol(eventSvc,"/Event/Digi/TofDigiCol");
00487   if( !tofDigiCol ) {
00488     log << MSG::WARNING << "TofRawDataProvider::tofDataMapOnlineMode(): Could not find Tof Digi Data!" << endreq;
00489     return m_tofDataMapOnline;
00490   } 
00491 
00492   TofDigiCol::iterator iter = tofDigiCol->begin();
00493   for( ; iter != tofDigiCol->end(); iter++ ) {
00494     unsigned int overflow   = (*iter)->getOverflow();
00495     if( ( overflow & 0xfe000000 ) == 0xfe000000 ) continue;
00496     // overflow 0x   1 1         1 1            1 1
00497     //            no Q T / multi Q T / overflow Q T
00498     
00499     bool noT = ( ( overflow & 0x10 ) != 0 );
00500     //    bool multiQ = ( ( overflow & 0x8 ) != 0 );
00501     //    bool multiT = ( ( overflow & 0x4 ) != 0 );
00502     if( noT ) continue;
00503     
00504     Identifier iden = (*iter)->identify();
00505     unsigned int iden_value = iden.get_value();
00506     int  barrel_ec  = TofID::barrel_ec(iden);
00507     int  id         = TofID::phi_module(iden);
00508     int  end        = TofID::end(iden);
00509     if( ( barrel_ec != 1 ) && ( end == 1 ) ) continue;
00510     if( ( barrel_ec != 1 ) && ( id == 48 ) ) continue;
00511 
00512     unsigned int tdcChannel = (*iter)->getTimeChannel();
00513     if( tdcChannel == 0x7fffffff ) continue;
00514 
00515     Tdc* tdc = new Tdc;
00516     tdc->setValue( tdcChannel );
00517     PmtData* pmt = new PmtData;
00518     pmt->setTdc( tdc );
00519 
00520     unsigned int iden_value_key = ( iden_value & 0xfffffffe );
00521 
00522     if( barrel_ec == 0 || barrel_ec == 2 ) {
00523       TofData* tof = new TofData;
00524       tof->setIdentify( iden );
00525       tof->setForward( pmt );
00526       m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
00527     }
00528     else if( barrel_ec == 1 ) {
00529       unsigned int count = m_tofDataMapOnline.count( iden_value_key );
00530 
00531       if( count == 0 ) {
00532         TofData* tof = new TofData;
00533         tof->setIdentify( iden );
00534         if( end == 0 ) {
00535           tof->setForward( pmt );
00536         }
00537         else {
00538           tof->setBackward( pmt );
00539         } 
00540         m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
00541       }
00542       else {
00543         bool used = false;
00544         pair< IterTofDataMap, IterTofDataMap > range = m_tofDataMapOnline.equal_range( iden_value_key );
00545         IterTofDataMap iter = range.first;
00546         for( unsigned int i=0; i<count; i++, iter++ ) {
00547           if( ( end == 0 ) && ( ( ( (*iter).second)->quality() & 0x1 ) != 0 ) ) {
00548             double time1 = pmt->tdc();
00549             double time2 = ((*iter).second)->tdc2();
00550             if( abs(time1-time2)<timeDiff ) {
00551               used = true;
00552               if( ( ( (*iter).second)->quality() & 0x4 ) == 0 ) {
00553                 ((*iter).second)->setForward( pmt );
00554               }
00555               else {
00556                 TofData* tof = new TofData;
00557                 tof->setIdentify( iden );
00558                 tof->setForward( pmt );
00559                 tof->setBackward( ((*iter).second)->backward() );
00560                 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
00561               }
00562             }
00563           }
00564           else if( ( end == 1 ) && ( ( ((*iter).second)->quality() & 0x4 ) != 0 ) ) {
00565             double time1 = ((*iter).second)->tdc1();
00566             double time2 = pmt->tdc();
00567 
00568             if( abs(time1-time2)<timeDiff ) {
00569               used = true;
00570               if( ( ( (*iter).second)->quality() & 0x1 ) == 0 ) {
00571                 ((*iter).second)->setBackward( pmt );
00572               }
00573               else {
00574                 TofData* tof = new TofData;
00575                 tof->setIdentify( iden );
00576                 tof->setForward( ((*iter).second)->forward() );
00577                 tof->setBackward( pmt );
00578                 m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
00579               }
00580             }
00581           }
00582         }
00583         if( ! used ) {
00584           TofData* tof = new TofData;
00585           tof->setIdentify( iden );
00586           if( end == 0 ) {
00587             tof->setForward( pmt );
00588           }
00589           else {
00590             tof->setBackward( pmt );
00591           } 
00592           m_tofDataMapOnline.insert( make_pair( iden_value_key, tof ) );
00593         }
00594       }
00595     }
00596   }
00597 
00598   return m_tofDataMapOnline;
00599 
00600 }

TofDataMap& TofRawDataProvider::tofDataMapTof double  estime = 0.0  ) 
 

TofDataMap & TofRawDataProvider::tofDataMapTof double  estime = 0.0  ) 
 

00667                                                              {
00668 
00669   if( !m_hasFilled ) {
00670     TofRawDataProvider::tofDataMapFull();
00671     m_hasFilled = true;
00672   }
00673 
00674   if( !m_tofDataMapTof.empty() ) {
00675     m_tofDataMapTof.clear();
00676   }
00677 
00678   IterTofDataMap iter = m_tofDataMap.begin();
00679   for( ; iter != m_tofDataMap.end(); iter++ ) {
00680     if( ( ( ((*iter).second)->quality() & 0xc ) == 0xc ) || ( ( ((*iter).second)->quality() & 0x3 ) == 0x3 ) ) {
00681 
00682       if( estime > 1.0e-6 ) {
00683         double tdc1 = ((*iter).second)->tdc1();
00684         double tdc2 = ((*iter).second)->tdc2();
00685         bool  forward = ( ( ( estime - tdc1 ) < timeBackward ) && ( ( tdc1 - estime ) < timeForward ) );
00686         bool backward = ( ( ( estime - tdc2 ) < timeBackward ) && ( ( tdc2 - estime ) < timeForward ) );
00687         if( !forward && !backward ) continue;
00688       }
00689 
00690       m_tofDataMapTof.insert( make_pair( (*iter).first, (*iter).second ) );
00691     }
00692   }
00693 
00694   iter = m_tofDataMapTof.begin();
00695   while( iter != m_tofDataMapTof.end() ) {
00696     unsigned int iden_value = (*iter).first;
00697     unsigned int count = m_tofDataMapTof.count( iden_value );
00698     for( unsigned int i=0; i != count; i++, iter++ ) {
00699       ((*iter).second)->setTimes( count );
00700     }
00701   }
00702 
00703   return m_tofDataMapTof;
00704 }

TofDataVector& TofRawDataProvider::tofDataVectorEmc double  estime = 0.0  ) 
 

TofDataVector & TofRawDataProvider::tofDataVectorEmc double  estime = 0.0  ) 
 

00763                                                                    {
00764   if( m_tofDataVectorEmc.size() != 0 ) {
00765     m_tofDataVectorEmc.clear();
00766   }
00767 
00768   TofDataMap tofDataMapEmc = TofRawDataProvider::tofDataMapEmc( estime );
00769   IterTofDataMap iter = tofDataMapEmc.begin();
00770   for( ; iter != tofDataMapEmc.end(); iter++ ) {
00771     m_tofDataVectorEmc.push_back( iter->second );
00772   }
00773   return m_tofDataVectorEmc;
00774 }

TofDataVector& TofRawDataProvider::tofDataVectorEstime  ) 
 

TofDataVector & TofRawDataProvider::tofDataVectorEstime  ) 
 

00654                                                        {
00655   if( m_tofDataVectorEstime.size() != 0 ) return m_tofDataVectorEstime;
00656 
00657   TofDataMap tofDataMapEstime = TofRawDataProvider::tofDataMapEstime();
00658   IterTofDataMap iter = tofDataMapEstime.begin();
00659   for( ; iter != tofDataMapEstime.end(); iter++ ) {
00660     m_tofDataVectorEstime.push_back( iter->second );
00661   }
00662   return m_tofDataVectorEstime;
00663 }

TofDataVector& TofRawDataProvider::tofDataVectorOnlineMode uint32_t  control = 1  ) 
 

TofDataVector & TofRawDataProvider::tofDataVectorOnlineMode uint32_t  control = 1  ) 
 

00603                                                                            {
00604 
00605   MsgStream log(m_msgSvc, m_name);
00606   log << MSG::INFO << "TofRawDataProvider::tofDataVectorOnlineMode()" << endreq;
00607   
00608   if( m_tofDataVectorOnline.size() != 0 ) {
00609     if(!control) return m_tofDataVectorOnline;
00610     else         m_tofDataVectorOnline.clear();
00611   }
00612   TofDataMap tofRawDataMap = TofRawDataProvider::tofDataMapOnlineMode(control);
00613   IterTofDataMap iter = tofRawDataMap.begin();
00614   for( ; iter != tofRawDataMap.end(); iter++ ) {
00615     m_tofDataVectorOnline.push_back( iter->second );
00616   }
00617 
00618   return m_tofDataVectorOnline;
00619 }

TofDataVector& TofRawDataProvider::tofDataVectorTof double  estime = 0.0  ) 
 

TofDataVector & TofRawDataProvider::tofDataVectorTof double  estime = 0.0  ) 
 

00707                                                                    {
00708   if( m_tofDataVectorTof.size() != 0 ) {
00709     m_tofDataVectorTof.clear();
00710   }
00711 
00712   TofDataMap tofDataMapTof = TofRawDataProvider::tofDataMapTof( estime );
00713   IterTofDataMap iter = tofDataMapTof.begin();
00714   for( ; iter != tofDataMapTof.end(); iter++ ) {
00715     m_tofDataVectorTof.push_back( iter->second );
00716   }
00717   return m_tofDataVectorTof;
00718 }


Member Data Documentation

bool TofRawDataProvider::m_hasFilled [private]
 

IMessageSvc* RawDataProviderBase::m_msgSvc [protected, inherited]
 

IMessageSvc* RawDataProviderBase::m_msgSvc [protected, inherited]
 

std::string RawDataProviderBase::m_name [protected, inherited]
 

ISvcLocator* RawDataProviderBase::m_svcLocator [protected, inherited]
 

ISvcLocator* RawDataProviderBase::m_svcLocator [protected, inherited]
 

TofDataMap TofRawDataProvider::m_tofDataMap [private]
 

TofDataMap TofRawDataProvider::m_tofDataMapEmc [private]
 

TofDataMap TofRawDataProvider::m_tofDataMapEstime [private]
 

TofDataMap TofRawDataProvider::m_tofDataMapOnline [private]
 

TofDataMap TofRawDataProvider::m_tofDataMapTof [private]
 

TofDataVector TofRawDataProvider::m_tofDataVectorEmc [private]
 

TofDataVector TofRawDataProvider::m_tofDataVectorEstime [private]
 

TofDataVector TofRawDataProvider::m_tofDataVectorOnline [private]
 

TofDataVector TofRawDataProvider::m_tofDataVectorTof [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:00:00 2011 for BOSS6.5.5 by  doxygen 1.3.9.1