CGEM BOSS 6.6.5.h
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 m_itemNames.push_back("/Event/Navigator");
28
29 m_itemNames.push_back("/Event/Digi");
30 m_itemNames.push_back("/Event/Digi/MdcDigiCol");
31 m_itemNames.push_back("/Event/Digi/TofDigiCol");
32 m_itemNames.push_back("/Event/Digi/EmcDigiCol");
33 m_itemNames.push_back("/Event/Digi/MucDigiCol");
34
35 m_itemNames.push_back("/Event/Hlt");
36 m_itemNames.push_back("/Event/Hlt/HltRawCol");
37 m_itemNames.push_back("/Event/Hlt/HltInf");
38 //m_itemNames.push_back("/Event/Hlt/DstHltInf");
39
40 m_itemNames.push_back("/Event/Recon");
41 // m_itemNames.push_back("/Event/Recon/RecMdcHitCol");
42 m_itemNames.push_back("/Event/Recon/RecMdcTrackCol");
43 // m_itemNames.push_back("/Event/Recon/MdcHOTCol");
44 m_itemNames.push_back("/Event/Recon/RecMdcDedxCol");
45 // m_itemNames.push_back("/Event/Recon/RecMdcDedxHitCol");
46 m_itemNames.push_back("/Event/Recon/RecMdcKalTrackCol");
47 // m_itemNames.push_back("/Event/Recon/RecMdcKalHelixSegCol");
48 m_itemNames.push_back("/Event/Recon/RecEsTimeCol");
49 m_itemNames.push_back("/Event/Recon/RecExtTrackCol");
50 // m_itemNames.push_back("/Event/Recon/RecBTofHitCol");
51 // m_itemNames.push_back("/Event/Recon/RecETofHitCol");
52 m_itemNames.push_back("/Event/Recon/RecTofTrackCol");
53 // m_itemNames.push_back("/Event/Recon/RecBTofCalHitCol");
54 // m_itemNames.push_back("/Event/Recon/RecETofCalHitCol");
55 m_itemNames.push_back("/Event/Recon/RecEmcHitCol");
56 m_itemNames.push_back("/Event/Recon/RecEmcClusterCol");
57 m_itemNames.push_back("/Event/Recon/RecEmcShowerCol");
58 // m_itemNames.push_back("/Event/Recon/MucRecHitCol");
59 m_itemNames.push_back("/Event/Recon/RecMucTrackCol");
60 m_itemNames.push_back("/Event/Recon/EvtRecEvent");
61 m_itemNames.push_back("/Event/Recon/EvtRecTrackCol");
62 // m_itemNames.push_back("/Event/Recon/EvtRecVertexCol");
63
64 // Part 1: Declare the properties
65 declareProperty("digiRootOutputFile",m_dofileName = "event.rec");
66 declareProperty("ItemList",m_itemNames);
67 declareProperty("RunMode", m_mode = 2);
68}

◆ ~EventWriter()

EventWriter::~EventWriter ( )

Definition at line 71 of file EventWriter.cxx.

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

Member Function Documentation

◆ execute()

StatusCode EventWriter::execute ( )

Definition at line 177 of file EventWriter.cxx.

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

◆ finalize()

StatusCode EventWriter::finalize ( )

Definition at line 321 of file EventWriter.cxx.

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

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

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