#include <RootFileWriter.h>
Public Types | |
typedef const std::string | WriterArgType |
typedef const std::string | WriterArgType |
Public Member Functions | |
int | close () |
int | close () |
RootFileWriter (WriterArgType &fname) | |
RootFileWriter (WriterArgType &fname) | |
int | stat () |
int | stat () |
int | writeEvent (void *pevt, int size) |
int | writeEvent (void *pevt, int size) |
virtual | ~RootFileWriter () |
virtual | ~RootFileWriter () |
Private Member Functions | |
std::string | getDecayOptions () |
std::string | getDecayOptions () |
std::string | getJobOptions () |
std::string | getJobOptions () |
RootFileWriter () | |
RootFileWriter () | |
Private Attributes | |
TBossFullEvent * | m_evt |
TBossFullEvent * | m_evt |
TFile * | m_file |
TFile * | m_file |
bool | m_firstRound |
std::string | m_fname |
TJobInfo * | m_jobInfo |
TJobInfo * | m_jobInfo |
TTree * | m_jtree |
TTree * | m_jtree |
int | m_stat |
TTree * | m_tree |
TTree * | m_tree |
|
|
|
|
|
00010 : m_fname( fname), 00011 m_firstRound( true ), 00012 m_stat(0) 00013 { 00014 m_file = new TFile(fname.c_str(), "RECREATE"); 00015 m_tree = new TTree("Event","Event"); 00016 m_jtree = new TTree("JobInfoTree", "Job info"); 00017 m_evt = new TBossFullEvent; 00018 m_jobInfo = new TJobInfo; 00019 }
|
|
00022 { 00023 if ( m_file->IsOpen() ) { 00024 this->close(); 00025 } 00026 00027 delete m_file; 00028 //delete m_tree; 00029 //delete m_jtree; 00030 delete m_evt; 00031 delete m_jobInfo; 00032 }
|
|
|
|
|
|
|
|
|
|
|
|
00092 { 00093 m_jobInfo->setBossVer( getenv("BES_RELEASE") ); 00094 m_jobInfo->addJobOptions( this->getJobOptions() ); 00095 m_jobInfo->setDecayOptions( this->getDecayOptions() ); 00096 m_jtree->Fill(); 00097 00098 m_file->Write(); 00099 m_file->Close(); 00100 00101 m_stat = 1; 00102 00103 return 0; 00104 }
|
|
|
|
00118 { 00119 string opts("DecayOptions Place Holder\n"); 00120 return opts; 00121 }
|
|
|
|
00112 { 00113 string opts("JobOptions Place Holder\n"); 00114 return opts; 00115 }
|
|
|
|
00107 {
00108 return m_stat;
00109 }
|
|
|
|
00035 { 00036 if ( size == 4 ) { 00037 m_stat = *((int*)pevt); 00038 if ( m_stat == DistBossCode::StatusFinalize ) { 00039 throw ReachEndOfFileList(); 00040 } 00041 else { 00042 throw RawExMessage("[RootFileWriter] Get an invalid DistBossCode!"); 00043 } 00044 } 00045 00046 TBuffer buffer(TBuffer::kRead, size, ((char*)pevt+4), kFALSE); 00047 TBossFullEvent * evt = (TBossFullEvent*)buffer.ReadObject(TBossFullEvent::Class()); 00048 00049 m_evt->copy(evt); 00050 00051 /* 00052 static int ii = 0; 00053 std::cout << "Total: " << ++ii << " Run: " << m_evt->m_EvtHeader->getRunId() 00054 << " Evt: " << m_evt->m_EvtHeader->getEventId() << std::endl; 00055 */ 00056 00057 if ( m_firstRound ) { 00058 if (m_evt->m_EvtHeader) m_tree->Branch("TEvtHeader","TEvtHeader",&m_evt->m_EvtHeader,3200000,1); 00059 if (m_evt->m_digiEvt) m_tree->Branch("TDigiEvent","TDigiEvent",&m_evt->m_digiEvt,3200000,1); 00060 if (m_evt->m_dstEvt) m_tree->Branch("TDstEvent", "TDstEvent", &m_evt->m_dstEvt, 3200000, 1); 00061 if (m_evt->m_mcEvt) m_tree->Branch("TMcEvent","TMcEvent",&m_evt->m_mcEvt,3200000,1); 00062 if (m_evt->m_trigEvt) m_tree->Branch("TTrigEvent","TTrigEvent",&m_evt->m_trigEvt,3200000,1); 00063 if (m_evt->m_hltEvt) m_tree->Branch("THltEvent","THltEvent",&m_evt->m_hltEvt,3200000,1); 00064 if (m_evt->m_rectrackEvt) m_tree->Branch("TRecEvent", "TRecTrackEvent", &m_evt->m_rectrackEvt, 3200000, 1); 00065 if (m_evt->m_evtRecObject) m_tree->Branch("TEvtRecObject", "TEvtRecObject", &m_evt->m_evtRecObject, 3200000, 1); 00066 00067 m_jtree->Branch("JobInfo",&m_jobInfo); 00068 00069 m_firstRound = false; 00070 } 00071 00072 if ( m_file->IsZombie() || (!m_file->IsOpen()) ) { 00073 std::cout<<"ROOT File: " << m_fname << " bad status in RootFileWriter" << std::endl; 00074 exit(1); 00075 } 00076 00077 int nb = m_tree->Fill(); 00078 if ( nb == -1 ) { 00079 std::cerr << "RootFileWriter: error in fill tree " << m_tree->GetName() << std::endl; 00080 exit(1); 00081 } 00082 00083 delete evt; 00084 00085 m_evt->reset(); 00086 m_file = m_tree->GetCurrentFile(); 00087 00088 return nb; 00089 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|