BOSS 8.0.0
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 27 of file EventWriter.h.

Constructor & Destructor Documentation

◆ EventWriter()

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

Definition at line 15 of file EventWriter.cxx.

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

Referenced by EventWriter().

◆ ~EventWriter()

EventWriter::~EventWriter ( )

Definition at line 63 of file EventWriter.cxx.

63 {
64 // Part 1: Get the messaging service, print where you are
65 MsgStream log( msgSvc(), name() );
66 log << MSG::INFO << " EventWriter ~EventWriter()" << endmsg;
67}
IMessageSvc * msgSvc()

Member Function Documentation

◆ execute()

StatusCode EventWriter::execute ( )

Definition at line 149 of file EventWriter.cxx.

149 {
150
151 // Part 1: Get the messaging service, print where you are
152 MsgStream log( msgSvc(), name() );
153 log << MSG::INFO << "EventWriter execute()" << endmsg;
154 collectObjects().ignore();
155
156 if ( m_mode == 2 )
157 { // OfflineMode
158 if ( st != 1 )
159 {
160 if ( m_common.m_rectrackEvt )
161 m_single_outputTrees->Branch( "TRecEvent", "TRecTrackEvent", &m_common.m_rectrackEvt,
162 3200000, 1 );
163 if ( m_common.m_evtRecObject )
164 m_single_outputTrees->Branch( "TEvtRecObject", "TEvtRecObject",
165 &m_common.m_evtRecObject, 3200000, 1 );
166 if ( m_common.m_dstEvt )
167 m_single_outputTrees->Branch( "TDstEvent", "TDstEvent", &m_common.m_dstEvt, 3200000,
168 1 );
169 if ( m_common.m_recEvt )
170 m_single_outputTrees->Branch( "TDigiEvent", "TDigiEvent", &m_common.m_recEvt, 3200000,
171 1 );
172 if ( m_common.m_EvtHeader )
173 m_single_outputTrees->Branch( "TEvtHeader", "TEvtHeader", &m_common.m_EvtHeader,
174 3200000, 1 );
175 if ( m_common.m_EvtNavigator )
176 m_single_outputTrees->Branch( "TEvtNavigator", "TEvtNavigator",
177 &m_common.m_EvtNavigator, 3200000, 1 );
178 if ( m_common.m_hltEvt )
179 m_single_outputTrees->Branch( "THltEvent", "THltEvent", &m_common.m_hltEvt, 3200000,
180 1 );
181 if ( m_common.m_mcEvt )
182 m_single_outputTrees->Branch( "TMcEvent", "TMcEvent", &m_common.m_mcEvt, 3200000, 1 );
183 if ( m_common.m_trigEvt )
184 m_single_outputTrees->Branch( "TTrigEvent", "TTrigEvent", &m_common.m_trigEvt, 3200000,
185 1 );
186 m_jobInfoTree->Branch( "JobInfo", &jobInfo );
187 st = 1;
188 }
189
190 if ( m_single_outputFiles->IsZombie() || ( !m_single_outputFiles->IsOpen() ) )
191 {
192 std::cout << "EventWriter ERROR::The ROOT File:" << m_dofileName.c_str()
193 << "status is false" << std::endl;
194 exit( 1 );
195 }
196 int nb = m_single_outputTrees->Fill();
197 if ( nb == -1 )
198 {
199 log << MSG::FATAL << "Error in fill tree (EventWriter) "
200 << m_single_outputTrees->GetName() << " with " << nb << " bytes" << endmsg;
201 exit( 1 );
202 }
203
204 m_single_outputFiles = m_single_outputTrees->GetCurrentFile();
205 }
206 else if ( m_mode == 3 )
207 { // DistBossMode
208 log << MSG::FATAL << "The DistBossMode has been abandoned!" << endmsg;
209 return StatusCode::FAILURE;
210 }
211
212 m_common.clear();
213
214 return StatusCode::SUCCESS;
215}

◆ finalize()

StatusCode EventWriter::finalize ( )

Definition at line 287 of file EventWriter.cxx.

287 {
288
289 // Part 1: Get the messaging service, print where you are
290 MsgStream log( msgSvc(), name() );
291 int st = 1;
292 std::cout << "11111111111111111111111111" << std::endl;
293
294 if ( m_mode == 2 )
295 { // OfflineMode
296 m_bossVer = getenv( "BES_RELEASE" );
297 log << MSG::INFO << "fill boss version: " << m_bossVer << endmsg;
298
299 string tmpJobOptions = getJobOptions();
300 m_jobOptions.push_back( tmpJobOptions );
301
302 if ( m_decayOptions.size() == 0 ) m_decayOptions = getDecayOptions();
303
304 jobInfo->setBossVer( m_bossVer );
305 jobInfo->setJobOptions( m_jobOptions );
306 jobInfo->setDecayOptions( m_decayOptions );
307
308 m_jobInfoTree->Fill();
309
310 st = m_single_outputFiles->Write();
311 if ( st == 0 )
312 {
313 log << MSG::FATAL << "can not write to the file " << m_dofileName.c_str() << endmsg;
314 exit( 1 );
315 }
316 m_single_outputFiles->Close();
317
318 delete m_single_outputFiles;
319 delete jobInfo;
320 }
321
322 if ( m_mode == 3 )
323 { // DistBossMode
324 log << MSG::FATAL << "The DistBossMode has been abandoned!" << endmsg;
325 return StatusCode::FAILURE;
326 }
327
328 log << MSG::INFO << "EventWriter finalize()" << endmsg;
329 return StatusCode::SUCCESS;
330}

◆ initialize()

StatusCode EventWriter::initialize ( )

Definition at line 70 of file EventWriter.cxx.

70 {
71
72 // Part 1: Get the messaging service, print where you are
73 MsgStream log( msgSvc(), name() );
74 log << MSG::INFO << " EventWriter initialize()" << endmsg;
75
76 StatusCode status = serviceLocator()->service( "RootCnvSvc", m_cnvSvc, false );
77
78 if ( !status.isSuccess() )
79 status = serviceLocator()->service( "EventCnvSvc", m_cnvSvc, true );
80
81 status = serviceLocator()->service( "EventCnvSvc", m_pConversionSvc, true );
82 if ( !status.isSuccess() )
83 {
84 log << MSG::FATAL << "Unable to locate IConversionSvc interface" << endmsg;
85 return status;
86 }
87
88 status = serviceLocator()->service( "EventDataSvc", m_pDataProvider, true );
89 if ( !status.isSuccess() )
90 {
91 log << MSG::FATAL << "Unable to locate IDataProviderSvc interface" << endmsg;
92 return status;
93 }
94
95 if ( m_mode == 2 )
96 { // OfflineMode
97 m_single_outputFiles = new TFile( m_dofileName.c_str(), "RECREATE" );
98 if ( m_single_outputFiles->IsZombie() || ( !m_single_outputFiles->IsWritable() ) )
99 {
100 std::cout << "EventWriter ERROR::Can't not open file" << m_dofileName.c_str()
101 << std::endl;
102 exit( 1 );
103 }
104
105 m_single_outputTrees = new TTree( "Event", "Event" );
106 m_jobInfoTree = new TTree( "JobInfoTree", "Job info" );
107 jobInfo = new TJobInfo;
108 }
109 else if ( m_mode == 3 )
110 { // DistBossMode
111 log << MSG::FATAL << "The DistBossMode has been abandoned!" << endmsg;
112 return StatusCode::FAILURE;
113 }
114 else
115 {
116 log << MSG::FATAL << "Unvalid RunMode @ initialize(): " << m_mode << endmsg;
117 exit( 1 );
118 }
119
120 status = getSvc();
121 if ( !status.isSuccess() )
122 {
123 log << MSG::FATAL << "can not getSvc" << endmsg;
124 return status;
125 }
126 st = 0;
127
128 return StatusCode::SUCCESS;
129}

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