177 {
178
179
180 MsgStream log(
msgSvc(), name());
181 log << MSG::INFO << "EventWriter execute()" << endreq;
182 collectObjects();
183
184 if ( m_mode == 2 ) {
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 ) {
213 m_TFullEvt->setEvtHeader(m_common.m_EvtHeader);
214 m_TFullEvt->setDigiEvent(m_common.m_recEvt);
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
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}