BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
EventWriter Class Reference

#include <EventWriter.h>

+ Inheritance diagram for EventWriter:

Public Member Functions

 EventWriter (const std::string &name, ISvcLocator *pSvcLocator)
 
 ~EventWriter ()
 
StatusCode initialize ()
 
StatusCode execute ()
 
StatusCode finalize ()
 

Detailed Description

Definition at line 32 of file EventWriter.h.

Constructor & Destructor Documentation

◆ EventWriter()

EventWriter::EventWriter ( const std::string &  name,
ISvcLocator *  pSvcLocator 
)

Definition at line 22 of file EventWriter.cxx.

22 :
23 Algorithm(name, pSvcLocator)
24{
25 m_itemNames.push_back("/Event");
26 m_itemNames.push_back("/Event/EventHeader");
27
28 m_itemNames.push_back("/Event/Digi");
29 m_itemNames.push_back("/Event/Digi/MdcDigiCol");
30 m_itemNames.push_back("/Event/Digi/TofDigiCol");
31 m_itemNames.push_back("/Event/Digi/EmcDigiCol");
32 m_itemNames.push_back("/Event/Digi/MucDigiCol");
33
34 m_itemNames.push_back("/Event/Hlt");
35 m_itemNames.push_back("/Event/Hlt/HltRawCol");
36 m_itemNames.push_back("/Event/Hlt/HltInf");
37 //m_itemNames.push_back("/Event/Hlt/DstHltInf");
38
39 m_itemNames.push_back("/Event/Recon");
40 // m_itemNames.push_back("/Event/Recon/RecMdcHitCol");
41 m_itemNames.push_back("/Event/Recon/RecMdcTrackCol");
42 // m_itemNames.push_back("/Event/Recon/MdcHOTCol");
43 m_itemNames.push_back("/Event/Recon/RecMdcDedxCol");
44 // m_itemNames.push_back("/Event/Recon/RecMdcDedxHitCol");
45 m_itemNames.push_back("/Event/Recon/RecMdcKalTrackCol");
46 // m_itemNames.push_back("/Event/Recon/RecMdcKalHelixSegCol");
47 m_itemNames.push_back("/Event/Recon/RecEsTimeCol");
48 m_itemNames.push_back("/Event/Recon/RecExtTrackCol");
49 // m_itemNames.push_back("/Event/Recon/RecBTofHitCol");
50 // m_itemNames.push_back("/Event/Recon/RecETofHitCol");
51 m_itemNames.push_back("/Event/Recon/RecTofTrackCol");
52 // m_itemNames.push_back("/Event/Recon/RecBTofCalHitCol");
53 // m_itemNames.push_back("/Event/Recon/RecETofCalHitCol");
54 m_itemNames.push_back("/Event/Recon/RecEmcHitCol");
55 m_itemNames.push_back("/Event/Recon/RecEmcClusterCol");
56 m_itemNames.push_back("/Event/Recon/RecEmcShowerCol");
57 // m_itemNames.push_back("/Event/Recon/MucRecHitCol");
58 m_itemNames.push_back("/Event/Recon/RecMucTrackCol");
59 m_itemNames.push_back("/Event/Recon/EvtRecEvent");
60 m_itemNames.push_back("/Event/Recon/EvtRecTrackCol");
61 // m_itemNames.push_back("/Event/Recon/EvtRecVertexCol");
62
63 // Part 1: Declare the properties
64 declareProperty("digiRootOutputFile",m_dofileName = "event.rec");
65 declareProperty("ItemList",m_itemNames);
66 declareProperty("RunMode", m_mode = 2);
67}

◆ ~EventWriter()

EventWriter::~EventWriter ( )

Definition at line 70 of file EventWriter.cxx.

70 {
71 // Part 1: Get the messaging service, print where you are
72 MsgStream log(msgSvc(), name());
73 log << MSG::INFO << " EventWriter ~EventWriter()" << endreq;
74
75
76
77}
IMessageSvc * msgSvc()

Member Function Documentation

◆ execute()

StatusCode EventWriter::execute ( )

Definition at line 176 of file EventWriter.cxx.

176 {
177
178 // Part 1: Get the messaging service, print where you are
179 MsgStream log(msgSvc(), name());
180 log << MSG::INFO << "EventWriter execute()" << endreq;
181 collectObjects();
182
183 if ( m_mode == 2 ) { //OfflineMode
184 if(st!=1){
185 if(m_common.m_rectrackEvt) m_single_outputTrees->Branch("TRecEvent","TRecTrackEvent",&m_common.m_rectrackEvt,3200000,1);
186 if(m_common.m_evtRecObject) m_single_outputTrees->Branch("TEvtRecObject","TEvtRecObject",&m_common.m_evtRecObject,3200000,1);
187 if(m_common.m_dstEvt) m_single_outputTrees->Branch("TDstEvent","TDstEvent",&m_common.m_dstEvt,3200000,1);
188 if(m_common.m_recEvt) m_single_outputTrees->Branch("TDigiEvent","TDigiEvent",&m_common.m_recEvt,3200000,1);
189 if(m_common.m_EvtHeader) m_single_outputTrees->Branch("TEvtHeader","TEvtHeader",&m_common.m_EvtHeader,3200000,1);
190 if(m_common.m_hltEvt) m_single_outputTrees->Branch("THltEvent","THltEvent",&m_common.m_hltEvt,3200000,1);
191 if(m_common.m_mcEvt) m_single_outputTrees->Branch("TMcEvent","TMcEvent",&m_common.m_mcEvt,3200000,1);
192 if(m_common.m_trigEvt) m_single_outputTrees->Branch("TTrigEvent","TTrigEvent",&m_common.m_trigEvt,3200000,1);
193 m_jobInfoTree->Branch("JobInfo",&jobInfo);
194 st=1;
195 }
196
197 if(m_single_outputFiles->IsZombie()||(!m_single_outputFiles->IsOpen())){
198 std::cout<<"EventWriter ERROR::The ROOT File:"<<m_dofileName.c_str()<<"status is false"<<std::endl;
199 exit(1);
200 }
201 int nb = m_single_outputTrees->Fill();
202 if(nb==-1)
203 {
204 log << MSG::FATAL << "Error in fill tree (EventWriter) "<<m_single_outputTrees->GetName() << " with "<<nb<<" bytes" <<endreq;
205 exit(1);
206 }
207
208 m_single_outputFiles = m_single_outputTrees->GetCurrentFile();
209 }
210 else if ( m_mode == 3 ) { //DistBossMode
211 m_TFullEvt->setEvtHeader(m_common.m_EvtHeader);
212 m_TFullEvt->setDigiEvent(m_common.m_recEvt); //TDigiEvent
213 m_TFullEvt->setDstEvent(m_common.m_dstEvt);
214 m_TFullEvt->setMcEvent(m_common.m_mcEvt);
215 m_TFullEvt->setTrigEvent(m_common.m_trigEvt);
216 m_TFullEvt->setHltEvent(m_common.m_hltEvt);
217 m_TFullEvt->setRecTrackEvent(m_common.m_rectrackEvt);
218 m_TFullEvt->setEvtRecObject(m_common.m_evtRecObject);
219
220 // Might it be able to optimize within higher version of ROOT?
221 TBufferFile m_TBuffer(TBufferFile::kWrite, m_bufsize-12, m_cbuf+4, false);
222 m_TBuffer.WriteObject(m_TFullEvt);
223 if ( m_TBuffer.Buffer() != (m_cbuf+4) ) {
224 m_bufsize = m_TBuffer.Length() + 12;
225 m_cbuf = new char[m_bufsize];
226 memcpy(m_cbuf+4, m_TBuffer.Buffer(), m_TBuffer.Length());
227 m_TBuffer.SetBit(TBuffer::kIsOwner);
228 }
229 *((int*)m_cbuf) = m_common.m_EvtHeader->getEventId();
230 m_writer->writeEvent( (void*)m_cbuf, m_TBuffer.Length()+4 );
231
232 m_TFullEvt->reset();
233 }
234
235 m_common.clear();
236
237 return StatusCode::SUCCESS;
238}
int writeEvent(void *pevt, int size)
void setHltEvent(THltEvent *obj)
void setTrigEvent(TTrigEvent *obj)
void setDigiEvent(TDigiEvent *obj)
void setEvtRecObject(TEvtRecObject *obj)
void setMcEvent(TMcEvent *obj)
void setRecTrackEvent(TRecTrackEvent *obj)
void setDstEvent(TDstEvent *obj)
void setEvtHeader(TEvtHeader *obj)
Int_t getEventId()
Access the TEvtHeader number.
Definition: TEvtHeader.h:23
static TEvtRecObject * m_evtRecObject
Definition: commonData.h:262
static TEvtHeader * m_EvtHeader
Definition: commonData.h:112
static TDigiEvent * m_recEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:124
static TTrigEvent * m_trigEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:184
static THltEvent * m_hltEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:190
static TMcEvent * m_mcEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:163
static TRecTrackEvent * m_rectrackEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:199
static TDstEvent * m_dstEvt
Provide access to the ROOT event pointers.
Definition: commonData.h:139
void clear()
Definition: commonData.cxx:147

◆ finalize()

StatusCode EventWriter::finalize ( )

Definition at line 319 of file EventWriter.cxx.

319 {
320
321 // Part 1: Get the messaging service, print where you are
322 MsgStream log(msgSvc(), name());
323 int st =1;
324 std::cout<<"11111111111111111111111111"<<std::endl;
325
326 if ( m_mode == 2 ) { //OfflineMode
327 m_bossVer = getenv("BES_RELEASE");
328 log << MSG::INFO << "fill boss version: "<<m_bossVer << endreq;
329
330 string tmpJobOptions = getJobOptions();
331 m_jobOptions.push_back( tmpJobOptions );
332
333 if(m_decayOptions.size()==0)
334 m_decayOptions = getDecayOptions();
335
336 jobInfo->setBossVer(m_bossVer);
337 jobInfo->setJobOptions(m_jobOptions);
338 jobInfo->setDecayOptions(m_decayOptions);
339
340 m_jobInfoTree->Fill();
341
342 st = m_single_outputFiles->Write();
343 if(st==0)
344 {
345 log << MSG::FATAL <<"can not write to the file "<<m_dofileName.c_str()<<endreq;
346 exit(1);
347 }
348 m_single_outputFiles->Close();
349
350 delete m_single_outputFiles;
351 delete jobInfo;
352 }
353
354 if ( m_mode == 3 ) { //DistBossMode
356 m_writer->writeEvent((void*)&code, 4);
357 delete m_writer;
358 delete m_TFullEvt;
359 delete [] m_cbuf;
360 }
361
362 log << MSG::INFO << "EventWriter finalize()" << endreq;
363 return StatusCode::SUCCESS;
364}
void setBossVer(string ver)
Definition: TJobInfo.h:21
void setDecayOptions(string opt)
Definition: TJobInfo.h:24
void setJobOptions(vector< string > opt)
Definition: TJobInfo.h:23

◆ initialize()

StatusCode EventWriter::initialize ( )

Definition at line 80 of file EventWriter.cxx.

80 {
81
82 // Part 1: Get the messaging service, print where you are
83 MsgStream log(msgSvc(), name());
84 log << MSG::INFO << " EventWriter initialize()" << endreq;
85
86
87 // StatusCode status = Converter::initialize();
88
89 // if ( status.isSuccess() ) {
90
91 IService* isvc = 0;
92
93 StatusCode status = serviceLocator()->service("RootCnvSvc", isvc, false);
94
95 if ( !status.isSuccess() ) status = serviceLocator()->service("EventCnvSvc", isvc, true);
96
97 if ( status.isSuccess() ) {
98
99 status = isvc->queryInterface(IID_IRootCnvSvc, (void**)&m_cnvSvc);
100
101 }
102
103
104 status = serviceLocator()->service("EventCnvSvc", m_pConversionSvc, true);
105 if ( !status.isSuccess() ) {
106 log << MSG::FATAL << "Unable to locate IConversionSvc interface"
107 << endreq;
108 return status;
109 }
110
111
112 status = serviceLocator()->service("EventDataSvc", m_pDataProvider, true);
113 if ( !status.isSuccess() ) {
114 log << MSG::FATAL << "Unable to locate IDataProviderSvc interface"
115 << endreq;
116 return status;
117 }
118
119 // }
120
121 if ( m_mode == 2 ) { //OfflineMode
122 m_single_outputFiles = new TFile(m_dofileName.c_str(), "RECREATE");
123 if(m_single_outputFiles->IsZombie()||(!m_single_outputFiles->IsWritable())){
124 std::cout<<"EventWriter ERROR::Can't not open file"<<m_dofileName.c_str()<<std::endl;
125 exit(1);
126 }
127
128 m_single_outputTrees = new TTree("Event","Event");
129 m_jobInfoTree = new TTree("JobInfoTree","Job info");
130 jobInfo = new TJobInfo;
131 }
132 else if ( m_mode == 3 ) { //DistBossMode
133 status = DistBoss::GetPropertyValue<std::string>("DistBoss", "ServerName", m_svrName);
134 m_TFullEvt = new TBossFullEvent;
135 m_writer = new NetDataWriter(m_svrName+'/'+name());
136 m_bufsize = 512*1024;
137 m_cbuf = new char[m_bufsize];
138 int code = DistBossCode::ClientReady;
139 m_writer->writeEvent((void*)&code, 4);
140 }
141 else {
142 log << MSG::FATAL << "Unvalid RunMode @ initialize(): " << m_mode << endreq;
143 exit(1);
144 }
145
146 status = getSvc();
147 if ( !status.isSuccess() ) {
148 log << MSG::FATAL << "can not getSvc" << endreq;
149 return status;
150 }
151 st=0;
152
153 return StatusCode::SUCCESS;
154}
PthrWriterBufPool< DimRpcWriter, 4 > NetDataWriter
Definition: NetDataWriter.h:7
const InterfaceID IID_IRootCnvSvc

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