3#include "GaudiKernel/MsgStream.h"
4#include "GaudiKernel/AlgFactory.h"
5#include "GaudiKernel/Bootstrap.h"
6#include "GaudiKernel/ISvcLocator.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "GaudiKernel/IDataProviderSvc.h"
9#include "GaudiKernel/PropertyMgr.h"
10#include "GaudiKernel/DataObject.h"
11#include "GaudiKernel/GenericAddress.h"
12#include "GaudiKernel/ClassID.h"
38 Algorithm(name, pSvcLocator)
41 declareProperty(
"MdcDigi",m_mdcDigi=1);
42 declareProperty(
"TofDigi",m_tofDigi=1);
43 declareProperty(
"EmcDigi",m_emcDigi=1);
44 declareProperty(
"MucDigi",m_mucDigi=1);
45 declareProperty(
"InputFiles",m_inputFiles);
61 MsgStream log(
msgSvc(), name());
62 log << MSG::INFO <<
"in initialize()" << endreq;
64 ISvcLocator* svcLocator = Gaudi::svcLocator();
65 StatusCode sc=svcLocator->service(
"EventDataSvc", m_evtSvc);
67 std::cout<<
"Could not accesss EventDataSvc!"<<std::endl;
69 return StatusCode::SUCCESS;
75 MsgStream log(
msgSvc(), name());
76 log << MSG::INFO <<
"in execute()" << endreq;
79 StatusCode sc = m_evtSvc->registerObject(
"/Event/Digi",aDigiEvent);
80 if(sc!=StatusCode::SUCCESS) {
81 std::cout<<
"Could not register DigiEvent" <<std::endl;
85 if(m_tempNumber != m_fileNumber)
88 TFile* m_input = TFile::Open(m_inputFiles[m_fileNumber].c_str(),
"READ");
89 std::cout<<
"input file: "<<m_inputFiles[m_fileNumber].c_str()<<std::endl;
90 m_tree= (TTree *)m_input->Get(
"Event");
91 m_tree->SetMakeClass(1);
92 m_currentEntries=(Int_t)m_tree->GetEntries();
93 std::cout<<
"m_currentEntries: "<<m_currentEntries<<std::endl;
95 m_tempNumber = m_fileNumber;
110 log << MSG::INFO <<
"current Entry: "<< m_currentEntry << endreq;
114 if(m_currentEntry==m_currentEntries)
120 log << MSG::INFO <<
"total events: "<< m_totalEvents << endreq;
123 return StatusCode::SUCCESS;
130 TBranch *branch = m_tree->GetBranch(
"m_mdcDigiCol");
132 TObjArray* mdcDigiCol;
133 branch->SetAddress(&mdcDigiCol);
136 branch->GetEntry(entry);
140 TIter mdcDigiIter(mdcDigiCol);
144 while ((mdcDigiRoot = (
TMdcDigi*)mdcDigiIter.Next())) {
145 unsigned int id = mdcDigiRoot->
getIntId();
148 unsigned int overflow = mdcDigiRoot->
getOverflow();
157 mdcDigiTdsCol->push_back(mdcDigiTds);
164 StatusCode scMdc = m_evtSvc->registerObject(
"/Event/Digi/MdcDigiCol", mdcDigiTdsCol);
165 if(scMdc!=StatusCode::SUCCESS)
166 std::cout<<
"Could not register MDC digi collection" <<std::endl;
169 return StatusCode::SUCCESS;
174 TBranch *branch = m_tree->GetBranch(
"m_tofDigiCol");
176 TObjArray* tofDigiCol;
177 branch->SetAddress(&tofDigiCol);
180 branch->GetEntry(entry);
184 TIter tofDigiIter(tofDigiCol);
188 while ((tofDigiRoot = (
TTofDigi*)tofDigiIter.Next())) {
189 unsigned int id = tofDigiRoot->
getIntId();
192 unsigned int overflow = tofDigiRoot->
getOverflow();
201 tofDigiTdsCol->push_back(tofDigiTds);
205 StatusCode scTof = m_evtSvc->registerObject(
"/Event/Digi/TofDigiCol", tofDigiTdsCol);
206 if(scTof!=StatusCode::SUCCESS)
207 std::cout<<
"Could not register TOF digi collection" <<std::endl;
210 return StatusCode::SUCCESS;
215 TBranch *branch = m_tree->GetBranch(
"m_emcDigiCol");
217 TObjArray* emcDigiCol;
218 branch->SetAddress(&emcDigiCol);
221 branch->GetEntry(entry);
225 TIter emcDigiIter(emcDigiCol);
229 while ((emcDigiRoot = (
TEmcDigi*)emcDigiIter.Next())) {
230 unsigned int id = emcDigiRoot->
getIntId();
233 unsigned int measure = emcDigiRoot->
getMeasure();
242 emcDigiTdsCol->push_back(emcDigiTds);
246 StatusCode scEmc = m_evtSvc->registerObject(
"/Event/Digi/EmcDigiCol", emcDigiTdsCol);
247 if(scEmc!=StatusCode::SUCCESS)
248 std::cout<<
"Could not register EMC digi collection" <<std::endl;
251 return StatusCode::SUCCESS;
256 TBranch *branch = m_tree->GetBranch(
"m_mucDigiCol");
258 TObjArray* mucDigiCol;
259 branch->SetAddress(&mucDigiCol);
262 branch->GetEntry(entry);
266 TIter mucDigiIter(mucDigiCol);
270 while ((mucDigiRoot = (
TMucDigi*)mucDigiIter.Next())) {
271 unsigned int id = mucDigiRoot->
getIntId();
281 mucDigiTdsCol->push_back(mucDigiTds);
285 StatusCode scMuc = m_evtSvc->registerObject(
"/Event/Digi/MucDigiCol", mucDigiTdsCol);
286 if(scMuc!=StatusCode::SUCCESS)
287 std::cout<<
"Could not register MUC digi collection" <<std::endl;
290 return StatusCode::SUCCESS;
297 MsgStream log(
msgSvc(), name());
298 log << MSG::INFO <<
"in finalize()" << endreq;
300 return StatusCode::SUCCESS;
ObjectVector< EmcDigi > EmcDigiCol
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
void setMeasure(const unsigned int measure)
void setOverflow(const unsigned int overflow)
void setTrackIndex(const int trackIndex)
void setChargeChannel(const unsigned int chargeChannel)
void setTimeChannel(const unsigned int timeChannel)
StatusCode readTof(int entry)
StatusCode readMuc(int entry)
virtual ~RootRawEvtReader()
StatusCode readEmc(int entry)
RootRawEvtReader(const std::string &name, ISvcLocator *pSvcLocator)
StatusCode readMdc(int entry)
UInt_t getMeasure() const
UInt_t getOverflow() const
int getTrackIndex() const
UInt_t getChargeChannel() const
UInt_t getTimeChannel() const
UInt_t getOverflow() const
void setOverflow(const unsigned int overflow)