#include <EventWriter.h>
Definition at line 32 of file EventWriter.h.
typedef std::vector<std::string> EventWriter::ItemNames [private] |
Definition at line 60 of file EventWriter.h.
typedef std::vector<DataStoreItem*> EventWriter::Items [private] |
Definition at line 59 of file EventWriter.h.
EventWriter::EventWriter | ( | const std::string & | name, | |
ISvcLocator * | pSvcLocator | |||
) |
Definition at line 22 of file EventWriter.cxx.
References m_dofileName, m_itemNames, and m_mode.
00022 : 00023 Algorithm(name, pSvcLocator) 00024 { 00025 m_itemNames.push_back("/Event"); 00026 m_itemNames.push_back("/Event/EventHeader"); 00027 m_itemNames.push_back("/Event/Navigator"); 00028 00029 m_itemNames.push_back("/Event/Digi"); 00030 m_itemNames.push_back("/Event/Digi/MdcDigiCol"); 00031 m_itemNames.push_back("/Event/Digi/TofDigiCol"); 00032 m_itemNames.push_back("/Event/Digi/EmcDigiCol"); 00033 m_itemNames.push_back("/Event/Digi/MucDigiCol"); 00034 00035 m_itemNames.push_back("/Event/Hlt"); 00036 m_itemNames.push_back("/Event/Hlt/HltRawCol"); 00037 m_itemNames.push_back("/Event/Hlt/HltInf"); 00038 //m_itemNames.push_back("/Event/Hlt/DstHltInf"); 00039 00040 m_itemNames.push_back("/Event/Recon"); 00041 // m_itemNames.push_back("/Event/Recon/RecMdcHitCol"); 00042 m_itemNames.push_back("/Event/Recon/RecMdcTrackCol"); 00043 // m_itemNames.push_back("/Event/Recon/MdcHOTCol"); 00044 m_itemNames.push_back("/Event/Recon/RecMdcDedxCol"); 00045 // m_itemNames.push_back("/Event/Recon/RecMdcDedxHitCol"); 00046 m_itemNames.push_back("/Event/Recon/RecMdcKalTrackCol"); 00047 // m_itemNames.push_back("/Event/Recon/RecMdcKalHelixSegCol"); 00048 m_itemNames.push_back("/Event/Recon/RecEsTimeCol"); 00049 m_itemNames.push_back("/Event/Recon/RecExtTrackCol"); 00050 // m_itemNames.push_back("/Event/Recon/RecBTofHitCol"); 00051 // m_itemNames.push_back("/Event/Recon/RecETofHitCol"); 00052 m_itemNames.push_back("/Event/Recon/RecTofTrackCol"); 00053 // m_itemNames.push_back("/Event/Recon/RecBTofCalHitCol"); 00054 // m_itemNames.push_back("/Event/Recon/RecETofCalHitCol"); 00055 m_itemNames.push_back("/Event/Recon/RecEmcHitCol"); 00056 m_itemNames.push_back("/Event/Recon/RecEmcClusterCol"); 00057 m_itemNames.push_back("/Event/Recon/RecEmcShowerCol"); 00058 // m_itemNames.push_back("/Event/Recon/MucRecHitCol"); 00059 m_itemNames.push_back("/Event/Recon/RecMucTrackCol"); 00060 m_itemNames.push_back("/Event/Recon/EvtRecEvent"); 00061 m_itemNames.push_back("/Event/Recon/EvtRecTrackCol"); 00062 // m_itemNames.push_back("/Event/Recon/EvtRecVertexCol"); 00063 00064 // Part 1: Declare the properties 00065 declareProperty("digiRootOutputFile",m_dofileName = "event.rec"); 00066 declareProperty("ItemList",m_itemNames); 00067 declareProperty("RunMode", m_mode = 2); 00068 }
EventWriter::~EventWriter | ( | ) |
Definition at line 71 of file EventWriter.cxx.
References Bes_Common::INFO, and msgSvc().
00071 { 00072 // Part 1: Get the messaging service, print where you are 00073 MsgStream log(msgSvc(), name()); 00074 log << MSG::INFO << " EventWriter ~EventWriter()" << endreq; 00075 00076 00077 00078 }
void EventWriter::addItem | ( | Items & | itms, | |
const std::string & | descriptor | |||
) | [private] |
Definition at line 242 of file EventWriter.cxx.
References Bes_Common::DEBUG, findItem(), msgSvc(), RealDBUtil::npos, and deljobs::string.
Referenced by getSvc().
00242 { 00243 MsgStream log(msgSvc(), name()); 00244 int level = 0; 00245 size_t sep = descriptor.rfind("#"); 00246 std::string obj_path (descriptor,0,sep); 00247 std::string slevel (descriptor,sep+1,descriptor.length()); 00248 if ( slevel == "*" ) { 00249 level = 9999999; 00250 } 00251 else { 00252 level = atoi(slevel.c_str()); 00253 } 00254 size_t idx = obj_path.find("/",1); 00255 while (idx != std::string::npos) { 00256 std::string sub_item = obj_path.substr(0,idx); 00257 if ( 0 == findItem(sub_item) ) { 00258 addItem(itms, sub_item+"#1"); 00259 } 00260 idx = obj_path.find("/",idx+1); 00261 } 00262 DataStoreItem* item = new DataStoreItem(obj_path, level); 00263 log << MSG::DEBUG << "Adding OutputStream item " << item->path() 00264 << " with " << item->depth() 00265 << " level(s)." << endreq; 00266 itms.push_back( item ); 00267 }
void EventWriter::clearItems | ( | Items & | items | ) | [private] |
Definition at line 270 of file EventWriter.cxx.
References genRecEmupikp::i.
Referenced by getSvc().
00270 { 00271 for ( Items::iterator i = itms.begin(); i != itms.end(); i++ ) { 00272 delete (*i); 00273 } 00274 itms.erase(itms.begin(), itms.end()); 00275 }
StatusCode EventWriter::collectObjects | ( | ) | [private] |
Definition at line 287 of file EventWriter.cxx.
References calibUtil::ERROR, genRecEmupikp::i, m_currentItem, m_itemList, m_pConversionSvc, m_pDataProvider, and msgSvc().
Referenced by execute().
00287 { 00288 MsgStream log(msgSvc(), name()); 00289 StatusCode status = StatusCode::SUCCESS; 00290 Items::iterator i; 00291 00292 // Traverse the tree and collect the requested objects 00293 // status = m_pConversionSvc->connectOutput(f_rootOutputFile.c_str(), "recreate"); 00294 00295 for ( i = m_itemList.begin(); i != m_itemList.end(); i++ ) { 00296 DataObject* obj = 0; 00297 IOpaqueAddress *pAddress = 0; 00298 m_currentItem = (*i); 00299 00300 status = m_pDataProvider->retrieveObject(m_currentItem->path(), obj); 00301 if ( status.isSuccess() ) { 00302 status = m_pConversionSvc->createRep(obj, pAddress); 00303 //IRegistry *pReg = obj->registry(); 00304 //pReg->setAddress(pAddress); 00305 //status = m_pConversionSvc->fillRepRefs(pReg->address(), *i); 00306 } 00307 else { 00308 log << MSG::ERROR << "Cannot write mandatory object(s) (Not found): " 00309 << m_currentItem->path() << endreq; 00310 } 00311 } 00312 00313 00314 return status; 00315 }
StatusCode EventWriter::execute | ( | ) |
Definition at line 177 of file EventWriter.cxx.
References commonData::clear(), collectObjects(), Bes_Common::FATAL, TEvtHeader::getEventId(), Bes_Common::INFO, jobInfo, m_bufsize, m_cbuf, m_common, m_dofileName, commonData::m_dstEvt, commonData::m_EvtHeader, commonData::m_EvtNavigator, commonData::m_evtRecObject, commonData::m_hltEvt, m_jobInfoTree, commonData::m_mcEvt, m_mode, commonData::m_recEvt, commonData::m_rectrackEvt, m_single_outputFiles, m_single_outputTrees, m_TFullEvt, commonData::m_trigEvt, m_writer, msgSvc(), TBossFullEvent::reset(), TBossFullEvent::setDigiEvent(), TBossFullEvent::setDstEvent(), TBossFullEvent::setEvtHeader(), TBossFullEvent::setEvtRecObject(), TBossFullEvent::setHltEvent(), TBossFullEvent::setMcEvent(), TBossFullEvent::setRecTrackEvent(), TBossFullEvent::setTrigEvent(), st, and PthrWriterBufPool< Writer, PoolSize >::writeEvent().
00177 { 00178 00179 // Part 1: Get the messaging service, print where you are 00180 MsgStream log(msgSvc(), name()); 00181 log << MSG::INFO << "EventWriter execute()" << endreq; 00182 collectObjects(); 00183 00184 if ( m_mode == 2 ) { //OfflineMode 00185 if(st!=1){ 00186 if(m_common.m_rectrackEvt) m_single_outputTrees->Branch("TRecEvent","TRecTrackEvent",&m_common.m_rectrackEvt,3200000,1); 00187 if(m_common.m_evtRecObject) m_single_outputTrees->Branch("TEvtRecObject","TEvtRecObject",&m_common.m_evtRecObject,3200000,1); 00188 if(m_common.m_dstEvt) m_single_outputTrees->Branch("TDstEvent","TDstEvent",&m_common.m_dstEvt,3200000,1); 00189 if(m_common.m_recEvt) m_single_outputTrees->Branch("TDigiEvent","TDigiEvent",&m_common.m_recEvt,3200000,1); 00190 if(m_common.m_EvtHeader) m_single_outputTrees->Branch("TEvtHeader","TEvtHeader",&m_common.m_EvtHeader,3200000,1); 00191 if(m_common.m_EvtNavigator) m_single_outputTrees->Branch("TEvtNavigator","TEvtNavigator",&m_common.m_EvtNavigator,3200000,1); 00192 if(m_common.m_hltEvt) m_single_outputTrees->Branch("THltEvent","THltEvent",&m_common.m_hltEvt,3200000,1); 00193 if(m_common.m_mcEvt) m_single_outputTrees->Branch("TMcEvent","TMcEvent",&m_common.m_mcEvt,3200000,1); 00194 if(m_common.m_trigEvt) m_single_outputTrees->Branch("TTrigEvent","TTrigEvent",&m_common.m_trigEvt,3200000,1); 00195 m_jobInfoTree->Branch("JobInfo",&jobInfo); 00196 st=1; 00197 } 00198 00199 if(m_single_outputFiles->IsZombie()||(!m_single_outputFiles->IsOpen())){ 00200 std::cout<<"EventWriter ERROR::The ROOT File:"<<m_dofileName.c_str()<<"status is false"<<std::endl; 00201 exit(1); 00202 } 00203 int nb = m_single_outputTrees->Fill(); 00204 if(nb==-1) 00205 { 00206 log << MSG::FATAL << "Error in fill tree (EventWriter) "<<m_single_outputTrees->GetName() << " with "<<nb<<" bytes" <<endreq; 00207 exit(1); 00208 } 00209 00210 m_single_outputFiles = m_single_outputTrees->GetCurrentFile(); 00211 } 00212 else if ( m_mode == 3 ) { //DistBossMode 00213 m_TFullEvt->setEvtHeader(m_common.m_EvtHeader); 00214 m_TFullEvt->setDigiEvent(m_common.m_recEvt); //TDigiEvent 00215 m_TFullEvt->setDstEvent(m_common.m_dstEvt); 00216 m_TFullEvt->setMcEvent(m_common.m_mcEvt); 00217 m_TFullEvt->setTrigEvent(m_common.m_trigEvt); 00218 m_TFullEvt->setHltEvent(m_common.m_hltEvt); 00219 m_TFullEvt->setRecTrackEvent(m_common.m_rectrackEvt); 00220 m_TFullEvt->setEvtRecObject(m_common.m_evtRecObject); 00221 00222 // Might it be able to optimize within higher version of ROOT? 00223 TBufferFile m_TBuffer(TBufferFile::kWrite, m_bufsize-12, m_cbuf+4, false); 00224 m_TBuffer.WriteObject(m_TFullEvt); 00225 if ( m_TBuffer.Buffer() != (m_cbuf+4) ) { 00226 m_bufsize = m_TBuffer.Length() + 12; 00227 m_cbuf = new char[m_bufsize]; 00228 memcpy(m_cbuf+4, m_TBuffer.Buffer(), m_TBuffer.Length()); 00229 m_TBuffer.SetBit(TBuffer::kIsOwner); 00230 } 00231 *((int*)m_cbuf) = m_common.m_EvtHeader->getEventId(); 00232 m_writer->writeEvent( (void*)m_cbuf, m_TBuffer.Length()+4 ); 00233 00234 m_TFullEvt->reset(); 00235 } 00236 00237 m_common.clear(); 00238 00239 return StatusCode::SUCCESS; 00240 }
StatusCode EventWriter::finalize | ( | ) |
Definition at line 321 of file EventWriter.cxx.
References Bes_Common::FATAL, getDecayOptions(), getJobOptions(), Bes_Common::INFO, jobInfo, m_bossVer, m_cbuf, m_decayOptions, m_dofileName, m_jobInfoTree, m_jobOptions, m_mode, m_single_outputFiles, m_TFullEvt, m_writer, msgSvc(), TJobInfo::setBossVer(), TJobInfo::setDecayOptions(), TJobInfo::setJobOptions(), st, DistBossCode::StatusFinalize, deljobs::string, and PthrWriterBufPool< Writer, PoolSize >::writeEvent().
00321 { 00322 00323 // Part 1: Get the messaging service, print where you are 00324 MsgStream log(msgSvc(), name()); 00325 int st =1; 00326 std::cout<<"11111111111111111111111111"<<std::endl; 00327 00328 if ( m_mode == 2 ) { //OfflineMode 00329 m_bossVer = getenv("BES_RELEASE"); 00330 log << MSG::INFO << "fill boss version: "<<m_bossVer << endreq; 00331 00332 string tmpJobOptions = getJobOptions(); 00333 m_jobOptions.push_back( tmpJobOptions ); 00334 00335 if(m_decayOptions.size()==0) 00336 m_decayOptions = getDecayOptions(); 00337 00338 jobInfo->setBossVer(m_bossVer); 00339 jobInfo->setJobOptions(m_jobOptions); 00340 jobInfo->setDecayOptions(m_decayOptions); 00341 00342 m_jobInfoTree->Fill(); 00343 00344 st = m_single_outputFiles->Write(); 00345 if(st==0) 00346 { 00347 log << MSG::FATAL <<"can not write to the file "<<m_dofileName.c_str()<<endreq; 00348 exit(1); 00349 } 00350 m_single_outputFiles->Close(); 00351 00352 delete m_single_outputFiles; 00353 delete jobInfo; 00354 } 00355 00356 if ( m_mode == 3 ) { //DistBossMode 00357 int code = DistBossCode::StatusFinalize; 00358 m_writer->writeEvent((void*)&code, 4); 00359 delete m_writer; 00360 delete m_TFullEvt; 00361 delete [] m_cbuf; 00362 } 00363 00364 log << MSG::INFO << "EventWriter finalize()" << endreq; 00365 return StatusCode::SUCCESS; 00366 }
DataStoreItem * EventWriter::findItem | ( | const std::string & | path | ) | [private] |
Definition at line 278 of file EventWriter.cxx.
References genRecEmupikp::i, and m_itemList.
Referenced by addItem().
00278 { 00279 for (Items::const_iterator i=m_itemList.begin(); i != m_itemList.end(); ++i) { 00280 if ( (*i)->path() == path ) return (*i); 00281 } 00282 return 0; 00283 }
std::string EventWriter::getDecayOptions | ( | ) | [private, virtual] |
Definition at line 397 of file EventWriter.cxx.
References DataInfoSvc::getDecayOptions(), Bes_Common::INFO, msgSvc(), deljobs::string, and Bes_Common::WARNING.
Referenced by finalize().
00398 { 00399 MsgStream log(msgSvc(), name()); 00400 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00401 IDataInfoSvc *tmpInfoSvc; 00402 DataInfoSvc* jobInfoSvc; 00403 string decayOptions; 00404 StatusCode status = svcLocator->service("DataInfoSvc",tmpInfoSvc); 00405 if (status.isSuccess()) { 00406 log << MSG::INFO << "get the DataInfoSvc" << endreq; 00407 jobInfoSvc=dynamic_cast<DataInfoSvc *>(tmpInfoSvc); 00408 decayOptions = jobInfoSvc->getDecayOptions(); 00409 log << MSG::INFO << "get decay options" << endreq 00410 << decayOptions << endreq; 00411 }else { 00412 log << MSG::WARNING << "could not get the DataInfoSvc. Ignore it." << endreq; 00413 } 00414 return decayOptions; 00415 }
std::string EventWriter::getJobOptions | ( | ) | [private, virtual] |
Definition at line 372 of file EventWriter.cxx.
References Bes_Common::INFO, boss::jobOptions, msgSvc(), and deljobs::string.
Referenced by finalize().
00373 { 00374 MsgStream log(msgSvc(), name()); 00375 IInterface* iface = Gaudi::createApplicationMgr(); 00376 //SmartIF<IProperty> propMgr ( IID_IProperty, iface ); 00377 SmartIF<IProperty> propMgr ( iface ); 00378 std::string path; 00379 propMgr->getProperty( "JobOptionsPath", path); 00380 log << MSG::INFO << "JobOptions file for current job: " <<path << endreq; 00381 ifstream fin(path.c_str()); 00382 string jobOptions; 00383 string tempString; 00384 while(getline(fin,tempString)) 00385 { 00386 if( tempString.size()>0 && tempString.find("//")>tempString.size() ) 00387 { 00388 jobOptions += tempString; 00389 jobOptions += "\n"; 00390 } 00391 } 00392 log << MSG::INFO << "JobOptions: " << endreq 00393 << jobOptions << endreq; 00394 return jobOptions; 00395 }
StatusCode EventWriter::getSvc | ( | ) | [private] |
Definition at line 159 of file EventWriter.cxx.
References addItem(), clearItems(), calibUtil::ERROR, genRecEmupikp::i, Bes_Common::INFO, m_itemList, m_itemNames, and msgSvc().
Referenced by initialize().
00159 { 00160 MsgStream log(msgSvc(), name()); 00161 log << MSG::INFO << "getSvc()" << endreq; 00162 StatusCode status = StatusCode::SUCCESS; 00163 if(m_itemNames.empty()) { 00164 log << MSG::ERROR << "no ItemList from the jobOption" << endreq; 00165 return StatusCode::FAILURE; 00166 } 00167 // ItemNames m_itemNames; 00168 clearItems(m_itemList); 00169 ItemNames::iterator i; 00170 for (i = m_itemNames.begin(); i != m_itemNames.end(); i++){ 00171 addItem(m_itemList, *i); 00172 } 00173 return status; 00174 }
StatusCode EventWriter::initialize | ( | ) |
Definition at line 81 of file EventWriter.cxx.
References DistBossCode::ClientReady, Bes_Common::FATAL, getSvc(), IID_IRootCnvSvc, Bes_Common::INFO, jobInfo, m_bufsize, m_cbuf, m_cnvSvc, m_dofileName, m_jobInfoTree, m_mode, m_pConversionSvc, m_pDataProvider, m_single_outputFiles, m_single_outputTrees, m_svrName, m_TFullEvt, m_writer, msgSvc(), st, and PthrWriterBufPool< Writer, PoolSize >::writeEvent().
00081 { 00082 00083 // Part 1: Get the messaging service, print where you are 00084 MsgStream log(msgSvc(), name()); 00085 log << MSG::INFO << " EventWriter initialize()" << endreq; 00086 00087 00088 // StatusCode status = Converter::initialize(); 00089 00090 // if ( status.isSuccess() ) { 00091 00092 IService* isvc = 0; 00093 00094 StatusCode status = serviceLocator()->service("RootCnvSvc", isvc, false); 00095 00096 if ( !status.isSuccess() ) status = serviceLocator()->service("EventCnvSvc", isvc, true); 00097 00098 if ( status.isSuccess() ) { 00099 00100 status = isvc->queryInterface(IID_IRootCnvSvc, (void**)&m_cnvSvc); 00101 00102 } 00103 00104 00105 status = serviceLocator()->service("EventCnvSvc", m_pConversionSvc, true); 00106 if ( !status.isSuccess() ) { 00107 log << MSG::FATAL << "Unable to locate IConversionSvc interface" 00108 << endreq; 00109 return status; 00110 } 00111 00112 00113 status = serviceLocator()->service("EventDataSvc", m_pDataProvider, true); 00114 if ( !status.isSuccess() ) { 00115 log << MSG::FATAL << "Unable to locate IDataProviderSvc interface" 00116 << endreq; 00117 return status; 00118 } 00119 00120 // } 00121 00122 if ( m_mode == 2 ) { //OfflineMode 00123 m_single_outputFiles = new TFile(m_dofileName.c_str(), "RECREATE"); 00124 if(m_single_outputFiles->IsZombie()||(!m_single_outputFiles->IsWritable())){ 00125 std::cout<<"EventWriter ERROR::Can't not open file"<<m_dofileName.c_str()<<std::endl; 00126 exit(1); 00127 } 00128 00129 m_single_outputTrees = new TTree("Event","Event"); 00130 m_jobInfoTree = new TTree("JobInfoTree","Job info"); 00131 jobInfo = new TJobInfo; 00132 } 00133 else if ( m_mode == 3 ) { //DistBossMode 00134 status = DistBoss::GetPropertyValue<std::string>("DistBoss", "ServerName", m_svrName); 00135 m_TFullEvt = new TBossFullEvent; 00136 m_writer = new NetDataWriter(m_svrName+'/'+name()); 00137 m_bufsize = 512*1024; 00138 m_cbuf = new char[m_bufsize]; 00139 int code = DistBossCode::ClientReady; 00140 m_writer->writeEvent((void*)&code, 4); 00141 } 00142 else { 00143 log << MSG::FATAL << "Unvalid RunMode @ initialize(): " << m_mode << endreq; 00144 exit(1); 00145 } 00146 00147 status = getSvc(); 00148 if ( !status.isSuccess() ) { 00149 log << MSG::FATAL << "can not getSvc" << endreq; 00150 return status; 00151 } 00152 st=0; 00153 00154 return StatusCode::SUCCESS; 00155 }
TJobInfo* EventWriter::jobInfo [private] |
std::string EventWriter::m_bossVer [private] |
int EventWriter::m_bufsize [private] |
char* EventWriter::m_cbuf [private] |
RootCnvSvc* EventWriter::m_cnvSvc [private] |
commonData EventWriter::m_common [private] |
DataStoreItem* EventWriter::m_currentItem [private] |
std::string EventWriter::m_decayOptions [private] |
TDigiEvent* EventWriter::m_digiEvt [private] |
Definition at line 52 of file EventWriter.h.
string EventWriter::m_dofileName [private] |
Definition at line 67 of file EventWriter.h.
Referenced by EventWriter(), execute(), finalize(), and initialize().
string EventWriter::m_dofileName_1 [private] |
Definition at line 68 of file EventWriter.h.
TEvtHeader* EventWriter::m_evtHd [private] |
Definition at line 55 of file EventWriter.h.
THltEvent* EventWriter::m_hltEvt [private] |
Definition at line 54 of file EventWriter.h.
Items EventWriter::m_itemList [private] |
Definition at line 69 of file EventWriter.h.
Referenced by collectObjects(), findItem(), and getSvc().
ItemNames EventWriter::m_itemNames [private] |
TTree* EventWriter::m_jobInfoTree [private] |
std::vector<std::string> EventWriter::m_jobOptions [private] |
TMcEvent* EventWriter::m_mcEvt [private] |
Definition at line 53 of file EventWriter.h.
int EventWriter::m_mode [private] |
Definition at line 82 of file EventWriter.h.
Referenced by EventWriter(), execute(), finalize(), and initialize().
IDataStoreAgent* EventWriter::m_pAgent [private] |
Definition at line 47 of file EventWriter.h.
IConversionSvc* EventWriter::m_pConversionSvc [private] |
IDataManagerSvc* EventWriter::m_pDataManager [private] |
Definition at line 44 of file EventWriter.h.
IDataProviderSvc* EventWriter::m_pDataProvider [private] |
RootInterface* EventWriter::m_pRootInterface [private] |
Definition at line 49 of file EventWriter.h.
TFile* EventWriter::m_single_outputFiles [private] |
TTree* EventWriter::m_single_outputTrees [private] |
std::string EventWriter::m_svrName [private] |
TBossFullEvent* EventWriter::m_TFullEvt [private] |
TRecTrackEvent* EventWriter::m_trkEvt [private] |
Definition at line 51 of file EventWriter.h.
NetDataWriter* EventWriter::m_writer [private] |
int EventWriter::st [private] |