BOSS 7.0.8
BESIII Offline Software System
Loading...
Searching...
No Matches
RawDataInputSvc Class Reference

#include <RawDataInputSvc.h>

+ Inheritance diagram for RawDataInputSvc:

Public Member Functions

 RawDataInputSvc (const std::string &name, ISvcLocator *svcloc)
 
virtual ~RawDataInputSvc ()
 
virtual StatusCode initialize ()
 
virtual StatusCode finalize ()
 
virtual RAWEVENTnextEvent ()
 
virtual RAWEVENTcurrentEvent ()
 
virtual bool setCurrentEvent (RAWEVENT *m_onlinere)
 
std::string currentFile () const
 
int runMode ()
 
uint32_t runNo ()
 
OfflineReviseofflineRevisor ()
 
- Public Member Functions inherited from IRawDataInputSvc
StatusCode initialize ()
 
StatusCode finalize ()
 
virtual RAWEVENTnextEvent ()=0
 
virtual RAWEVENTcurrentEvent ()=0
 
virtual bool setCurrentEvent (RAWEVENT *)=0
 
virtual std::string currentFile () const =0
 
virtual int runMode ()=0
 
virtual uint32_t runNo ()=0
 

Static Public Member Functions

static const InterfaceID & interfaceID ()
 

Detailed Description

Definition at line 25 of file RawDataInputSvc.h.

Constructor & Destructor Documentation

◆ RawDataInputSvc()

RawDataInputSvc::RawDataInputSvc ( const std::string &  name,
ISvcLocator *  svcloc 
)

Definition at line 25 of file RawDataInputSvc.cxx.

26 :
27 Service(name,svcloc),
28 m_re(0),
29 m_reader(0),
30 m_sds(0),
31 m_robs(0)
32{
33 // Get a pointer to the Job Options Service
34 IJobOptionsSvc* jobSvc;
35 Gaudi::svcLocator()->service("JobOptionsSvc", jobSvc);
36
37 PropertyMgr m_propMgr;
38 // 0-NormalNetMode, 1-OnlineMode, 2-OfflineMode, 3-DistBossMode
39 m_propMgr.declareProperty("RunMode", m_mode = 2);
40 m_propMgr.declareProperty("KeepRandomTrigEvt", m_keepRdm = true);
41 m_propMgr.declareProperty("InputFiles", m_inputFiles);
42 m_propMgr.declareProperty("Config4Revise", m_conf4Revise);
43
44 jobSvc->setMyProperties("RawDataInputSvc", &m_propMgr);
45}

◆ ~RawDataInputSvc()

RawDataInputSvc::~RawDataInputSvc ( )
virtual

Definition at line 48 of file RawDataInputSvc.cxx.

49{
50 //MsgStream log(messageService(), name() );
51 //log << MSG::DEBUG << "RawDataInputSvc Destructor called " << endreq;
52}

Member Function Documentation

◆ currentEvent()

RAWEVENT * RawDataInputSvc::currentEvent ( )
virtual

Get a pointer to the current event.

Implements IRawDataInputSvc.

Definition at line 284 of file RawDataInputSvc.cxx.

285{
286 // Return a pointer to the raw event.
287 //std::cout << "RawDataCnv -> Return a pointer to the raw event." << std::endl;
288 //std::cout << "It is the first time to call the currentEvent()" << std::endl;
289 return m_re;
290}

◆ currentFile()

std::string RawDataInputSvc::currentFile ( ) const
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 46 of file RawDataInputSvc.h.

46{ return m_reader->currentFile(); }
virtual std::string currentFile()=0

◆ finalize()

StatusCode RawDataInputSvc::finalize ( )
virtual

Definition at line 98 of file RawDataInputSvc.cxx.

98 {
99 // clean up
100 if ( m_re ) {
101 delete m_re;
102 m_re = 0;
103 }
104
105 if ( m_reader ) {
106 delete m_reader;
107 m_reader = 0;
108 }
109
110 delete m_revisor;
111
112 if ( m_sds ) delete m_sds;
113 if ( m_robs ) delete m_robs;
114
115 return StatusCode::SUCCESS;
116}

◆ initialize()

StatusCode RawDataInputSvc::initialize ( )
virtual

Definition at line 55 of file RawDataInputSvc.cxx.

56{
57 //MsgStream log(messageService(), name() );
58 //log << MSG::DEBUG << " in RawDataInputSvc::initialize()" << endreq;
59
60 //StatusCode sc= IRawDataInputSvc::initialize();
61 //if(!sc.isSuccess()) {
62 // log << MSG::ERROR << "failed to initialize IRawDataInputSvc" << endreq;
63 // return sc;
64 //}
65
66#ifndef OnlineMode
67 if ( m_mode > 1 ) {
68 try {
69 if ( m_mode == 2 ) { //OfflineMode
70 if ( m_inputFiles.empty() ) return StatusCode::SUCCESS;
71 m_reader = new RawFileReader(m_inputFiles);
72 }
73 else if ( m_mode == 3 ) { //DistBossMode
74 DistBoss::GetPropertyValue<std::string>("DistBoss", "ServerName", m_evtServer);
75 m_reader = new NetDataReader(m_evtServer+"/RawEvtSvc");
76 }
77 else {
78 throw RawExMessage("RawDataInputSvc: Invalid RunMode!");
79 }
80 }
81 catch (RawFileException& ex) {
82 ex.print();
83 return StatusCode::FAILURE;
84 }
85
86 m_re = new RAWEVENT;
87
88 m_sds = new const uint32_t*[64];
89 m_robs = new const uint32_t*[256];
90 }
91#endif
92
93 m_revisor = new OfflineRevise(m_conf4Revise);
94
95 return StatusCode::SUCCESS;
96}
PthrReaderBufPool< DimRpcReader, 4 > NetDataReader
Definition: NetDataReader.h:7
virtual void print() const

◆ interfaceID()

static const InterfaceID & RawDataInputSvc::interfaceID ( )
inlinestatic

Definition at line 30 of file RawDataInputSvc.h.

30{ return IID_RawDataInputSvc; }

◆ nextEvent()

RAWEVENT * RawDataInputSvc::nextEvent ( )
virtual

Implements IRawDataInputSvc.

Definition at line 119 of file RawDataInputSvc.cxx.

119 {
120
121 //MsgStream log(messageService(), name() );
122#ifndef OnlineMode
123 //OfflineMode and DistBossMode
124 m_re->reset();
125
126 try {
127 RawEvent f;
128 const uint32_t* ef = 0;
129 do {
130 f.assign( m_reader->nextEvent());
131 if (!f.check()) {
132 std::cerr << "Found invalid event (traceback):" << std::endl;
133 std::exit(1);
134 }
135 //1.print basic event information
136 // log << MSG::DEBUG<< "run" << f.run_no() << " [Event No. #" << f.global_id()
137 // << "] " << f.fragment_size_word() << " words in "
138 // << f.nchildren() << " subdetectors "
139 // << endreq;
140
141 //fucd: get event filter information
142 f.event_filter_info(ef);
143 if ( !ef ) {
144 //log << MSG::ERROR << "Event Filter Data Failed!!!" << endreq;
145 exit(1);
146 }
147 else {
148 //log << MSG::DEBUG<< "Event Filter Information*********" <<std::hex<<endreq
149 // <<*ef<< " "<<*(ef+1)<<" "<<*(ef+2)<<" "<<*(ef+3)<<std::dec<<endreq;
150 if ( ! m_keepRdm && ((*ef)>>31) != 0 ) {
151 continue;
152 }
153 }
154 break;
155 } while (true);
156
157 m_re->setRunNo(f.run_no());
158 m_re->setEventNo(f.global_id());
159 m_re->setTime(f.time());
160 m_re->addReHltRaw((uint32_t*)ef, 4);
161
162 //set HV status and get all robs
163 uint32_t hv_status = 0;
164 int nrobs = 0;
165 int nsds = f.children(m_sds, 64);
166 for ( int sdi = 0; sdi < nsds; ++sdi ) {
168
169 if ( sd.nspecific() != 0 ) {
170 const uint32_t* specific_header;
171 sd.specific_header(specific_header);
172 uint32_t source_id_number = sd.source_id();
173 source_id_number <<= 8;
174 source_id_number >>= 24;
175 switch( source_id_number ) {
176 case 161:
177 hv_status |= ((8 | ((*specific_header)&0x7)) << 8);
178 break;
179 case 162:
180 hv_status |= ((8 | ((*specific_header)&0x7)) << 4);
181 break;
182 case 164:
183 hv_status |= (8 | ((*specific_header)&0x7));
184 break;
185 default:
186 break;
187 }
188 }
189
190 nrobs += eformat::get_robs(m_sds[sdi], m_robs+nrobs, 256-nrobs);
191 }
192
193 m_re->setFlag1( hv_status );
194
195 //log << MSG::INFO << " nrobs: " << nrobs << endreq;
196 for (int robi = 0; robi < nrobs; robi++) {
197 eformat::ROBFragment<uint32_t*> rob((uint32_t*)m_robs[robi]);
198 //uint32_t detev_type = rob.rod_detev_type();
199 uint32_t* dataptr = NULL;
200 rob.rod_data(dataptr);
201
202 //log << MSG::DEBUG<< "addReHltRaw" << endreq;
203 uint32_t source_id_number = rob.rod_source_id();
204 //std::cout<<"#####source_id_number#####"<<source_id_number<<std::endl;
205 source_id_number <<= 8;
206 source_id_number >>= 24;
207 //std::cout<<"#####(source_id_number<<24)>>29#####"<<source_id_number<<std::endl;
208
209 if ((rob.rod_detev_type() & 0x2) != 0) {
210 if ( source_id_number == 165 ) {
211 m_re->addReEtsDigi(dataptr, rob.rod_ndata()); // ETS
212 }
213 continue; //bad data or ETS
214 }
215
216 //be careful here!!!
217 switch(source_id_number) {
218 case 161:
219 m_re->addReMdcDigi(dataptr, rob.rod_ndata());
220 break;
221 case 163:
222 m_re->addReEmcDigi(dataptr, rob.rod_ndata());
223 break;
224 case 162:
225 m_re->addReTofDigi(dataptr, rob.rod_ndata());
226 break;
227 case 167: //ETF(MRPC)
228 m_re->addReEtfDigi(dataptr, rob.rod_ndata());
229 break;
230 case 164:
231 m_re->addReMucDigi(dataptr, rob.rod_ndata());
232 break;
233 case 165: // trigger !!!
234 //std::cout << "Get Trigger Data -" << std::endl;
235 //for (int i = 0; i < rob.rod_ndata(); i++) {
236 // std::cout << "\t0x" << std::hex << dataptr[i] << std::dec << std::endl;
237 //}
238 m_re->addReTrigGTD(dataptr, rob.rod_ndata());
239 break;
240 case 166:
241 m_re->addReZddDigi(dataptr, rob.rod_ndata());
242 break;
243 case 124: // EventFilter
244 m_re->addReHltRaw(dataptr, rob.rod_ndata());
245 break;
246 case 241: // McParticle
247 m_re->addMcParticle(dataptr, rob.rod_ndata());
248 break;
249 default:
250 //log << MSG::ERROR << "no such subdetector type: " << source_id_number << endreq;
251 break;
252 }
253 }
254 }
255 catch (RawFileException& ex) {
256 ex.print();
257 if ( m_reader->stat()&4 ) { // fstream badbit is set
258 std::cerr << std::endl << "reading ifstream error !!!" << std::endl;
259 exit(1);
260 }
261 delete m_re;
262 m_re = NULL;
263 }
264 catch (eformat::Issue& ex) {
265 std::cerr << std::endl << "Uncaught eformat issue: " << ex.what() << std::endl;
266 }
267 catch (ers::Issue& ex) {
268 std::cerr << std::endl << "Uncaught ERS issue: " << ex.what() << std::endl;
269 }
270 catch (std::exception& ex) {
271 std::cerr << std::endl << "Uncaught std exception: " << ex.what() << std::endl;
272 }
273 catch (...) {
274 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
275 }
276#endif
277
278 return m_re;
279}
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
#define NULL
virtual const uint32_t * nextEvent()=0
virtual uint32_t stat()=0
void addReTofDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:59
void setFlag1(uint32_t flag1)
Definition: RAWEVENT.h:49
void setRunNo(uint32_t run_no)
Definition: RAWEVENT.h:46
void addReEtsDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:77
void addReMdcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:53
void addReTrigGTD(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:65
void addReMucDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:62
void addReZddDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:68
void addMcParticle(uint32_t *buf, uint32_t size)
Definition: RAWEVENT.h:82
void setTime(uint32_t time)
Definition: RAWEVENT.h:48
void setEventNo(uint32_t event_no)
Definition: RAWEVENT.h:47
void addReEtfDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:74
void addReEmcDigi(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:56
void addReHltRaw(uint32_t *digi, uint32_t size)
Definition: RAWEVENT.h:71
void reset()
Definition: RAWEVENT.cxx:6
Root Issue class.
const char * what() const
Human description message.
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105

◆ offlineRevisor()

OfflineRevise * RawDataInputSvc::offlineRevisor ( )
inline

Definition at line 53 of file RawDataInputSvc.h.

53{ return m_revisor; }

◆ runMode()

int RawDataInputSvc::runMode ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 49 of file RawDataInputSvc.h.

49{ return m_mode; }

◆ runNo()

uint32_t RawDataInputSvc::runNo ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 51 of file RawDataInputSvc.h.

51{ return m_reader->runNo(); }
virtual uint32_t runNo()=0

Referenced by DetVerSvcPack::funcInputRaw().

◆ setCurrentEvent()

bool RawDataInputSvc::setCurrentEvent ( RAWEVENT m_onlinere)
virtual

Implements IRawDataInputSvc.

Definition at line 292 of file RawDataInputSvc.cxx.

293{
294 //std::cout << "setCurrentEvent(RAWEVENT* m_onlinere)" << std::endl;
295 return (m_re = m_onlinere);
296}

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