#include <RawDataInputSvc.h>
Inheritance diagram for RawDataInputSvc:
Public Member Functions | |
RawDataInputSvc (const std::string &name, ISvcLocator *svcloc) | |
virtual | ~RawDataInputSvc () |
virtual StatusCode | initialize () |
virtual StatusCode | finalize () |
virtual RAWEVENT * | nextEvent () |
virtual RAWEVENT * | currentEvent () |
virtual bool | setCurrentEvent (RAWEVENT *m_onlinere) |
std::string | currentFile () const |
int | runMode () |
uint32_t | runNo () |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
Private Attributes | |
RAWEVENT * | m_re |
IRawReader * | m_reader |
int | m_mode |
bool | m_keepRdm |
std::vector< std::string > | m_inputFiles |
std::string | m_evtServer |
const uint32_t ** | m_sds |
const uint32_t ** | m_robs |
Definition at line 23 of file RawDataInputSvc.h.
RawDataInputSvc::RawDataInputSvc | ( | const std::string & | name, | |
ISvcLocator * | svcloc | |||
) |
Definition at line 24 of file RawDataInputSvc.cxx.
References m_inputFiles, m_keepRdm, and m_mode.
00025 : 00026 Service(name,svcloc), 00027 m_re(0), 00028 m_reader(0), 00029 m_sds(0), 00030 m_robs(0) 00031 { 00032 // Get a pointer to the Job Options Service 00033 IJobOptionsSvc* jobSvc; 00034 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc); 00035 00036 PropertyMgr m_propMgr; 00037 // 0-NormalNetMode, 1-OnlineMode, 2-OfflineMode, 3-DistBossMode 00038 m_propMgr.declareProperty("RunMode", m_mode = 2); 00039 m_propMgr.declareProperty("KeepRandomTrigEvt", m_keepRdm = true); 00040 m_propMgr.declareProperty("InputFiles", m_inputFiles); 00041 00042 jobSvc->setMyProperties("RawDataInputSvc", &m_propMgr); 00043 }
RawDataInputSvc::~RawDataInputSvc | ( | ) | [virtual] |
Definition at line 46 of file RawDataInputSvc.cxx.
00047 { 00048 //MsgStream log(messageService(), name() ); 00049 //log << MSG::DEBUG << "RawDataInputSvc Destructor called " << endreq; 00050 }
RAWEVENT * RawDataInputSvc::currentEvent | ( | ) | [virtual] |
Get a pointer to the current event.
Implements IRawDataInputSvc.
Definition at line 271 of file RawDataInputSvc.cxx.
References m_re.
00272 { 00273 // Return a pointer to the raw event. 00274 //std::cout << "RawDataCnv -> Return a pointer to the raw event." << std::endl; 00275 //std::cout << "It is the first time to call the currentEvent()" << std::endl; 00276 return m_re; 00277 }
std::string RawDataInputSvc::currentFile | ( | ) | const [inline, virtual] |
Implements IRawDataInputSvc.
Definition at line 44 of file RawDataInputSvc.h.
References IRawReader::currentFile(), and m_reader.
00044 { return m_reader->currentFile(); }
StatusCode RawDataInputSvc::finalize | ( | ) | [virtual] |
Reimplemented from IRawDataInputSvc.
Definition at line 94 of file RawDataInputSvc.cxx.
References m_re, m_reader, m_robs, and m_sds.
00094 { 00095 // clean up 00096 if ( m_re ) { 00097 delete m_re; 00098 m_re = 0; 00099 } 00100 00101 if ( m_reader ) { 00102 delete m_reader; 00103 m_reader = 0; 00104 } 00105 00106 if ( m_sds ) delete m_sds; 00107 if ( m_robs ) delete m_robs; 00108 00109 return StatusCode::SUCCESS; 00110 }
StatusCode RawDataInputSvc::initialize | ( | ) | [virtual] |
Reimplemented from IRawDataInputSvc.
Definition at line 53 of file RawDataInputSvc.cxx.
References m_evtServer, m_inputFiles, m_mode, m_re, m_reader, m_robs, m_sds, and RawFileException::print().
00054 { 00055 //MsgStream log(messageService(), name() ); 00056 //log << MSG::DEBUG << " in RawDataInputSvc::initialize()" << endreq; 00057 00058 //StatusCode sc= IRawDataInputSvc::initialize(); 00059 //if(!sc.isSuccess()) { 00060 // log << MSG::ERROR << "failed to initialize IRawDataInputSvc" << endreq; 00061 // return sc; 00062 //} 00063 00064 #ifndef OnlineMode 00065 if ( m_mode > 1 ) { 00066 try { 00067 if ( m_mode == 2 ) { //OfflineMode 00068 if ( m_inputFiles.empty() ) return StatusCode::SUCCESS; 00069 m_reader = new RawFileReader(m_inputFiles); 00070 } 00071 else if ( m_mode == 3 ) { //DistBossMode 00072 DistBoss::GetPropertyValue<std::string>("DistBoss", "ServerName", m_evtServer); 00073 m_reader = new NetDataReader(m_evtServer+"/RawEvtSvc"); 00074 } 00075 else { 00076 throw RawExMessage("RawDataInputSvc: Invalid RunMode!"); 00077 } 00078 } 00079 catch (RawFileException& ex) { 00080 ex.print(); 00081 return StatusCode::FAILURE; 00082 } 00083 00084 m_re = new RAWEVENT; 00085 00086 m_sds = new const uint32_t*[64]; 00087 m_robs = new const uint32_t*[256]; 00088 } 00089 #endif 00090 00091 return StatusCode::SUCCESS; 00092 }
static const InterfaceID& RawDataInputSvc::interfaceID | ( | ) | [inline, static] |
Definition at line 28 of file RawDataInputSvc.h.
References IID_RawDataInputSvc().
00028 { return IID_RawDataInputSvc; }
RAWEVENT * RawDataInputSvc::nextEvent | ( | ) | [virtual] |
Implements IRawDataInputSvc.
Definition at line 113 of file RawDataInputSvc.cxx.
References RAWEVENT::addMcParticle(), RAWEVENT::addReEmcDigi(), RAWEVENT::addReEtfDigi(), RAWEVENT::addReHltRaw(), RAWEVENT::addReMdcDigi(), RAWEVENT::addReMucDigi(), RAWEVENT::addReTofDigi(), RAWEVENT::addReTrigGTD(), RAWEVENT::addReZddDigi(), eformat::FullEventFragment< TPointer >::assign(), eformat::FullEventFragment< TPointer >::check(), eformat::Header< TPointer >::children(), eformat::FullEventFragment< TPointer >::event_filter_info(), eformat::get_robs(), eformat::FullEventFragment< TPointer >::global_id(), m_keepRdm, m_re, m_reader, m_robs, m_sds, IRawReader::nextEvent(), RawFileException::print(), RAWEVENT::reset(), eformat::ROBFragment< TPointer >::rod_data(), eformat::ROBFragment< TPointer >::rod_source_id(), eformat::FullEventFragment< TPointer >::run_no(), RAWEVENT::setEventNo(), RAWEVENT::setFlag1(), RAWEVENT::setRunNo(), RAWEVENT::setTime(), IRawReader::stat(), eformat::FullEventFragment< TPointer >::time(), and ers::Issue::what().
00113 { 00114 00115 //MsgStream log(messageService(), name() ); 00116 #ifndef OnlineMode 00117 //OfflineMode and DistBossMode 00118 m_re->reset(); 00119 00120 try { 00121 RawEvent f; 00122 const uint32_t* ef = 0; 00123 do { 00124 f.assign( m_reader->nextEvent()); 00125 if (!f.check()) { 00126 std::cerr << "Found invalid event (traceback):" << std::endl; 00127 std::exit(1); 00128 } 00129 //1.print basic event information 00130 // log << MSG::DEBUG<< "run" << f.run_no() << " [Event No. #" << f.global_id() 00131 // << "] " << f.fragment_size_word() << " words in " 00132 // << f.nchildren() << " subdetectors " 00133 // << endreq; 00134 00135 //fucd: get event filter information 00136 f.event_filter_info(ef); 00137 if ( !ef ) { 00138 //log << MSG::ERROR << "Event Filter Data Failed!!!" << endreq; 00139 exit(1); 00140 } 00141 else { 00142 //log << MSG::DEBUG<< "Event Filter Information*********" <<std::hex<<endreq 00143 // <<*ef<< " "<<*(ef+1)<<" "<<*(ef+2)<<" "<<*(ef+3)<<std::dec<<endreq; 00144 if ( ! m_keepRdm && ((*ef)>>31) != 0 ) { 00145 continue; 00146 } 00147 } 00148 break; 00149 } while (true); 00150 00151 m_re->setRunNo(f.run_no()); 00152 m_re->setEventNo(f.global_id()); 00153 m_re->setTime(f.time()); 00154 m_re->addReHltRaw((uint32_t*)ef, 4); 00155 00156 //set HV status and get all robs 00157 uint32_t hv_status = 0; 00158 int nrobs = 0; 00159 int nsds = f.children(m_sds, 64); 00160 for ( int sdi = 0; sdi < nsds; ++sdi ) { 00161 eformat::SubDetectorFragment<const uint32_t*> sd(m_sds[sdi]); 00162 00163 if ( sd.nspecific() != 0 ) { 00164 const uint32_t* specific_header; 00165 sd.specific_header(specific_header); 00166 uint32_t source_id_number = sd.source_id(); 00167 source_id_number <<= 8; 00168 source_id_number >>= 24; 00169 switch( source_id_number ) { 00170 case 161: 00171 hv_status |= ((8 | ((*specific_header)&0x7)) << 8); 00172 break; 00173 case 162: 00174 hv_status |= ((8 | ((*specific_header)&0x7)) << 4); 00175 break; 00176 case 164: 00177 hv_status |= (8 | ((*specific_header)&0x7)); 00178 break; 00179 default: 00180 break; 00181 } 00182 } 00183 00184 nrobs += eformat::get_robs(m_sds[sdi], m_robs+nrobs, 256-nrobs); 00185 } 00186 00187 m_re->setFlag1( hv_status ); 00188 00189 //log << MSG::INFO << " nrobs: " << nrobs << endreq; 00190 for (int robi = 0; robi < nrobs; robi++) { 00191 eformat::ROBFragment<uint32_t*> rob((uint32_t*)m_robs[robi]); 00192 //uint32_t detev_type = rob.rod_detev_type(); 00193 if ((rob.rod_detev_type() & 0x2) != 0) continue; //bad data 00194 uint32_t* dataptr = NULL; 00195 rob.rod_data(dataptr); 00196 00197 //log << MSG::DEBUG<< "addReHltRaw" << endreq; 00198 uint32_t source_id_number = rob.rod_source_id(); 00199 //std::cout<<"#####source_id_number#####"<<source_id_number<<std::endl; 00200 source_id_number <<= 8; 00201 source_id_number >>= 24; 00202 //std::cout<<"#####(source_id_number<<24)>>29#####"<<source_id_number<<std::endl; 00203 //be careful here!!! 00204 switch(source_id_number) { 00205 case 161: 00206 m_re->addReMdcDigi(dataptr, rob.rod_ndata()); 00207 break; 00208 case 163: 00209 m_re->addReEmcDigi(dataptr, rob.rod_ndata()); 00210 break; 00211 case 162: 00212 m_re->addReTofDigi(dataptr, rob.rod_ndata()); 00213 break; 00214 case 167: //ETF(MRPC) 00215 m_re->addReEtfDigi(dataptr, rob.rod_ndata()); 00216 break; 00217 case 164: 00218 m_re->addReMucDigi(dataptr, rob.rod_ndata()); 00219 break; 00220 case 165: // trigger !!! 00221 //std::cout << "Get Trigger Data -" << std::endl; 00222 //for (int i = 0; i < rob.rod_ndata(); i++) { 00223 // std::cout << "\t0x" << std::hex << dataptr[i] << std::dec << std::endl; 00224 //} 00225 m_re->addReTrigGTD(dataptr, rob.rod_ndata()); 00226 break; 00227 case 166: 00228 m_re->addReZddDigi(dataptr, rob.rod_ndata()); 00229 break; 00230 case 124: // EventFilter 00231 m_re->addReHltRaw(dataptr, rob.rod_ndata()); 00232 break; 00233 case 241: // McParticle 00234 m_re->addMcParticle(dataptr, rob.rod_ndata()); 00235 break; 00236 default: 00237 //log << MSG::ERROR << "no such subdetector type: " << source_id_number << endreq; 00238 break; 00239 } 00240 } 00241 } 00242 catch (RawFileException& ex) { 00243 ex.print(); 00244 if ( m_reader->stat()&4 ) { // fstream badbit is set 00245 std::cerr << std::endl << "reading ifstream error !!!" << std::endl; 00246 exit(1); 00247 } 00248 delete m_re; 00249 m_re = NULL; 00250 } 00251 catch (eformat::Issue& ex) { 00252 std::cerr << std::endl << "Uncaught eformat issue: " << ex.what() << std::endl; 00253 } 00254 catch (ers::Issue& ex) { 00255 std::cerr << std::endl << "Uncaught ERS issue: " << ex.what() << std::endl; 00256 } 00257 catch (std::exception& ex) { 00258 std::cerr << std::endl << "Uncaught std exception: " << ex.what() << std::endl; 00259 } 00260 catch (...) { 00261 std::cerr << std::endl << "Uncaught unknown exception" << std::endl; 00262 } 00263 #endif 00264 00265 return m_re; 00266 }
int RawDataInputSvc::runMode | ( | ) | [inline, virtual] |
Implements IRawDataInputSvc.
Definition at line 47 of file RawDataInputSvc.h.
References m_mode.
00047 { return m_mode; }
uint32_t RawDataInputSvc::runNo | ( | ) | [inline, virtual] |
Implements IRawDataInputSvc.
Definition at line 49 of file RawDataInputSvc.h.
References m_reader, and IRawReader::runNo().
Implements IRawDataInputSvc.
Definition at line 279 of file RawDataInputSvc.cxx.
References m_re.
00280 { 00281 //std::cout << "setCurrentEvent(RAWEVENT* m_onlinere)" << std::endl; 00282 return (m_re = m_onlinere); 00283 }
std::string RawDataInputSvc::m_evtServer [private] |
std::vector<std::string> RawDataInputSvc::m_inputFiles [private] |
bool RawDataInputSvc::m_keepRdm [private] |
int RawDataInputSvc::m_mode [private] |
Definition at line 57 of file RawDataInputSvc.h.
Referenced by initialize(), RawDataInputSvc(), and runMode().
RAWEVENT* RawDataInputSvc::m_re [private] |
Definition at line 53 of file RawDataInputSvc.h.
Referenced by currentEvent(), finalize(), initialize(), nextEvent(), and setCurrentEvent().
IRawReader* RawDataInputSvc::m_reader [private] |
Definition at line 54 of file RawDataInputSvc.h.
Referenced by currentFile(), finalize(), initialize(), nextEvent(), and runNo().
const uint32_t** RawDataInputSvc::m_robs [private] |
Definition at line 68 of file RawDataInputSvc.h.
Referenced by finalize(), initialize(), and nextEvent().
const uint32_t** RawDataInputSvc::m_sds [private] |
Definition at line 67 of file RawDataInputSvc.h.
Referenced by finalize(), initialize(), and nextEvent().