BOSS 7.0.2
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 ()
 
 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 ()
 
- 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
 
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 ()
 
static const InterfaceID & interfaceID ()
 

Detailed Description

Constructor & Destructor Documentation

◆ RawDataInputSvc() [1/2]

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

Definition at line 24 of file RawDataInputSvc.cxx.

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

◆ ~RawDataInputSvc() [1/2]

RawDataInputSvc::~RawDataInputSvc ( )
virtual

Definition at line 46 of file RawDataInputSvc.cxx.

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

◆ RawDataInputSvc() [2/2]

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

◆ ~RawDataInputSvc() [2/2]

virtual RawDataInputSvc::~RawDataInputSvc ( )
virtual

Member Function Documentation

◆ currentEvent() [1/2]

RAWEVENT * RawDataInputSvc::currentEvent ( )
virtual

Get a pointer to the current event.

Implements IRawDataInputSvc.

Definition at line 271 of file RawDataInputSvc.cxx.

272{
273 // Return a pointer to the raw event.
274 //std::cout << "RawDataCnv -> Return a pointer to the raw event." << std::endl;
275 //std::cout << "It is the first time to call the currentEvent()" << std::endl;
276 return m_re;
277}

◆ currentEvent() [2/2]

virtual RAWEVENT * RawDataInputSvc::currentEvent ( )
virtual

Implements IRawDataInputSvc.

◆ currentFile() [1/2]

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

Implements IRawDataInputSvc.

Definition at line 44 of file Event/RawDataCnv/RawDataCnv-00-04-35/RawDataCnv/RawDataInputSvc.h.

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

◆ currentFile() [2/2]

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

Implements IRawDataInputSvc.

Definition at line 44 of file InstallArea/include/RawDataCnv/RawDataCnv/RawDataInputSvc.h.

44{ return m_reader->currentFile(); }

◆ finalize() [1/2]

StatusCode RawDataInputSvc::finalize ( )
virtual

Definition at line 94 of file RawDataInputSvc.cxx.

94 {
95 // clean up
96 if ( m_re ) {
97 delete m_re;
98 m_re = 0;
99 }
100
101 if ( m_reader ) {
102 delete m_reader;
103 m_reader = 0;
104 }
105
106 if ( m_sds ) delete m_sds;
107 if ( m_robs ) delete m_robs;
108
109 return StatusCode::SUCCESS;
110}

◆ finalize() [2/2]

virtual StatusCode RawDataInputSvc::finalize ( )
virtual

◆ initialize() [1/2]

StatusCode RawDataInputSvc::initialize ( )
virtual

Definition at line 53 of file RawDataInputSvc.cxx.

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

◆ initialize() [2/2]

virtual StatusCode RawDataInputSvc::initialize ( )
virtual

◆ interfaceID() [1/2]

static const InterfaceID & RawDataInputSvc::interfaceID ( )
inlinestatic

Definition at line 28 of file Event/RawDataCnv/RawDataCnv-00-04-35/RawDataCnv/RawDataInputSvc.h.

28{ return IID_RawDataInputSvc; }

◆ interfaceID() [2/2]

static const InterfaceID & RawDataInputSvc::interfaceID ( )
inlinestatic

Definition at line 28 of file InstallArea/include/RawDataCnv/RawDataCnv/RawDataInputSvc.h.

28{ return IID_RawDataInputSvc; }

◆ nextEvent() [1/2]

RAWEVENT * RawDataInputSvc::nextEvent ( )
virtual

Implements IRawDataInputSvc.

Definition at line 113 of file RawDataInputSvc.cxx.

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

◆ nextEvent() [2/2]

virtual RAWEVENT * RawDataInputSvc::nextEvent ( )
virtual

Implements IRawDataInputSvc.

◆ runMode() [1/2]

int RawDataInputSvc::runMode ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 47 of file Event/RawDataCnv/RawDataCnv-00-04-35/RawDataCnv/RawDataInputSvc.h.

47{ return m_mode; }

◆ runMode() [2/2]

int RawDataInputSvc::runMode ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 47 of file InstallArea/include/RawDataCnv/RawDataCnv/RawDataInputSvc.h.

47{ return m_mode; }

◆ runNo() [1/2]

uint32_t RawDataInputSvc::runNo ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 49 of file Event/RawDataCnv/RawDataCnv-00-04-35/RawDataCnv/RawDataInputSvc.h.

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

Referenced by DetVerSvcPack::funcInputRaw().

◆ runNo() [2/2]

uint32_t RawDataInputSvc::runNo ( )
inlinevirtual

Implements IRawDataInputSvc.

Definition at line 49 of file InstallArea/include/RawDataCnv/RawDataCnv/RawDataInputSvc.h.

49{ return m_reader->runNo(); }

◆ setCurrentEvent() [1/2]

bool RawDataInputSvc::setCurrentEvent ( RAWEVENT m_onlinere)
virtual

Implements IRawDataInputSvc.

Definition at line 279 of file RawDataInputSvc.cxx.

280{
281 //std::cout << "setCurrentEvent(RAWEVENT* m_onlinere)" << std::endl;
282 return (m_re = m_onlinere);
283}

◆ setCurrentEvent() [2/2]

virtual bool RawDataInputSvc::setCurrentEvent ( RAWEVENT m_onlinere)
virtual

Implements IRawDataInputSvc.


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