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