BOSS 7.0.5
BESIII Offline Software System
Loading...
Searching...
No Matches
RootFileWriter Class Reference

#include <RootFileWriter.h>

Public Types

typedef const std::string WriterArgType
 
typedef const std::string WriterArgType
 

Public Member Functions

 RootFileWriter (WriterArgType &fname)
 
virtual ~RootFileWriter ()
 
int writeEvent (void *pevt, int size)
 
int close ()
 
int stat ()
 
 RootFileWriter (WriterArgType &fname)
 
virtual ~RootFileWriter ()
 
int writeEvent (void *pevt, int size)
 
int close ()
 
int stat ()
 

Detailed Description

Member Typedef Documentation

◆ WriterArgType [1/2]

◆ WriterArgType [2/2]

typedef const std::string RootFileWriter::WriterArgType

Constructor & Destructor Documentation

◆ RootFileWriter() [1/2]

RootFileWriter::RootFileWriter ( WriterArgType fname)

Definition at line 10 of file RootFileWriter.cxx.

11 : m_fname( fname),
12 m_firstRound( true ),
13 m_stat(0)
14{
15 m_file = new TFile(fname.c_str(), "RECREATE");
16 m_tree = new TTree("Event","Event");
17 m_jtree = new TTree("JobInfoTree", "Job info");
18 m_evt = new TBossFullEvent;
19 m_jobInfo = new TJobInfo;
20}

Referenced by RootFileWriter().

◆ ~RootFileWriter() [1/2]

RootFileWriter::~RootFileWriter ( )
virtual

Definition at line 22 of file RootFileWriter.cxx.

23{
24 if ( m_file->IsOpen() ) {
25 this->close();
26 }
27
28 delete m_file;
29 //delete m_tree;
30 //delete m_jtree;
31 delete m_evt;
32 delete m_jobInfo;
33}

◆ RootFileWriter() [2/2]

RootFileWriter::RootFileWriter ( WriterArgType fname)

◆ ~RootFileWriter() [2/2]

virtual RootFileWriter::~RootFileWriter ( )
virtual

Member Function Documentation

◆ close() [1/2]

int RootFileWriter::close ( )

Definition at line 92 of file RootFileWriter.cxx.

93{
94 m_jobInfo->setBossVer( getenv("BES_RELEASE") );
95 m_jobInfo->addJobOptions( this->getJobOptions() );
96 m_jobInfo->setDecayOptions( this->getDecayOptions() );
97 m_jtree->Fill();
98
99 m_file->Write();
100 m_file->Close();
101
102 m_stat = 1;
103
104 return 0;
105}

Referenced by main(), and ~RootFileWriter().

◆ close() [2/2]

int RootFileWriter::close ( )

◆ stat() [1/2]

int RootFileWriter::stat ( )

Definition at line 107 of file RootFileWriter.cxx.

108{
109 return m_stat;
110}

◆ stat() [2/2]

int RootFileWriter::stat ( )

◆ writeEvent() [1/2]

int RootFileWriter::writeEvent ( void *  pevt,
int  size 
)

Definition at line 35 of file RootFileWriter.cxx.

36{
37 if ( size == 4 ) {
38 m_stat = *((int*)pevt);
39 if ( m_stat == DistBossCode::StatusFinalize ) {
40 throw ReachEndOfFileList();
41 }
42 else {
43 throw RawExMessage("[RootFileWriter] Get an invalid DistBossCode!");
44 }
45 }
46
47 TBufferFile buffer(TBuffer::kRead, size, ((char*)pevt+4), kFALSE);
48 TBossFullEvent * evt = (TBossFullEvent*)buffer.ReadObject(TBossFullEvent::Class());
49
50 m_evt->copy(evt);
51
52 /*
53 static int ii = 0;
54 std::cout << "Total: " << ++ii << " Run: " << m_evt->m_EvtHeader->getRunId()
55 << " Evt: " << m_evt->m_EvtHeader->getEventId() << std::endl;
56 */
57
58 if ( m_firstRound ) {
59 if (m_evt->m_EvtHeader) m_tree->Branch("TEvtHeader","TEvtHeader",&m_evt->m_EvtHeader,3200000,1);
60 if (m_evt->m_digiEvt) m_tree->Branch("TDigiEvent","TDigiEvent",&m_evt->m_digiEvt,3200000,1);
61 if (m_evt->m_dstEvt) m_tree->Branch("TDstEvent", "TDstEvent", &m_evt->m_dstEvt, 3200000, 1);
62 if (m_evt->m_mcEvt) m_tree->Branch("TMcEvent","TMcEvent",&m_evt->m_mcEvt,3200000,1);
63 if (m_evt->m_trigEvt) m_tree->Branch("TTrigEvent","TTrigEvent",&m_evt->m_trigEvt,3200000,1);
64 if (m_evt->m_hltEvt) m_tree->Branch("THltEvent","THltEvent",&m_evt->m_hltEvt,3200000,1);
65 if (m_evt->m_rectrackEvt) m_tree->Branch("TRecEvent", "TRecTrackEvent", &m_evt->m_rectrackEvt, 3200000, 1);
66 if (m_evt->m_evtRecObject) m_tree->Branch("TEvtRecObject", "TEvtRecObject", &m_evt->m_evtRecObject, 3200000, 1);
67
68 m_jtree->Branch("JobInfo",&m_jobInfo);
69
70 m_firstRound = false;
71 }
72
73 if ( m_file->IsZombie() || (!m_file->IsOpen()) ) {
74 std::cout<<"ROOT File: " << m_fname << " bad status in RootFileWriter" << std::endl;
75 exit(1);
76 }
77
78 int nb = m_tree->Fill();
79 if ( nb == -1 ) {
80 std::cerr << "RootFileWriter: error in fill tree " << m_tree->GetName() << std::endl;
81 exit(1);
82 }
83
84 delete evt;
85
86 m_evt->reset();
87 m_file = m_tree->GetCurrentFile();
88
89 return nb;
90}
void copy(TBossFullEvent *obj)

Referenced by main().

◆ writeEvent() [2/2]

int RootFileWriter::writeEvent ( void *  pevt,
int  size 
)

The documentation for this class was generated from the following files: