BOSS 7.0.5
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 278 of file RawDataInputSvc.cxx.

279{
280 // Return a pointer to the raw event.
281 //std::cout << "RawDataCnv -> Return a pointer to the raw event." << std::endl;
282 //std::cout << "It is the first time to call the currentEvent()" << std::endl;
283 return m_re;
284}

◆ 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-05-04/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-05-04/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 uint32_t* dataptr = NULL;
194 rob.rod_data(dataptr);
195
196 //log << MSG::DEBUG<< "addReHltRaw" << endreq;
197 uint32_t source_id_number = rob.rod_source_id();
198 //std::cout<<"#####source_id_number#####"<<source_id_number<<std::endl;
199 source_id_number <<= 8;
200 source_id_number >>= 24;
201 //std::cout<<"#####(source_id_number<<24)>>29#####"<<source_id_number<<std::endl;
202
203 if ((rob.rod_detev_type() & 0x2) != 0) {
204 if ( source_id_number == 165 ) {
205 m_re->addReEtsDigi(dataptr, rob.rod_ndata()); // ETS
206 }
207 continue; //bad data or ETS
208 }
209
210 //be careful here!!!
211 switch(source_id_number) {
212 case 161:
213 m_re->addReMdcDigi(dataptr, rob.rod_ndata());
214 break;
215 case 163:
216 m_re->addReEmcDigi(dataptr, rob.rod_ndata());
217 break;
218 case 162:
219 m_re->addReTofDigi(dataptr, rob.rod_ndata());
220 break;
221 case 167: //ETF(MRPC)
222 m_re->addReEtfDigi(dataptr, rob.rod_ndata());
223 break;
224 case 164:
225 m_re->addReMucDigi(dataptr, rob.rod_ndata());
226 break;
227 case 165: // trigger !!!
228 //std::cout << "Get Trigger Data -" << std::endl;
229 //for (int i = 0; i < rob.rod_ndata(); i++) {
230 // std::cout << "\t0x" << std::hex << dataptr[i] << std::dec << std::endl;
231 //}
232 m_re->addReTrigGTD(dataptr, rob.rod_ndata());
233 break;
234 case 166:
235 m_re->addReZddDigi(dataptr, rob.rod_ndata());
236 break;
237 case 124: // EventFilter
238 m_re->addReHltRaw(dataptr, rob.rod_ndata());
239 break;
240 case 241: // McParticle
241 m_re->addMcParticle(dataptr, rob.rod_ndata());
242 break;
243 default:
244 //log << MSG::ERROR << "no such subdetector type: " << source_id_number << endreq;
245 break;
246 }
247 }
248 }
249 catch (RawFileException& ex) {
250 ex.print();
251 if ( m_reader->stat()&4 ) { // fstream badbit is set
252 std::cerr << std::endl << "reading ifstream error !!!" << std::endl;
253 exit(1);
254 }
255 delete m_re;
256 m_re = NULL;
257 }
258 catch (eformat::Issue& ex) {
259 std::cerr << std::endl << "Uncaught eformat issue: " << ex.what() << std::endl;
260 }
261 catch (ers::Issue& ex) {
262 std::cerr << std::endl << "Uncaught ERS issue: " << ex.what() << std::endl;
263 }
264 catch (std::exception& ex) {
265 std::cerr << std::endl << "Uncaught std exception: " << ex.what() << std::endl;
266 }
267 catch (...) {
268 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
269 }
270#endif
271
272 return m_re;
273}
virtual const uint32_t * nextEvent()=0
virtual uint32_t stat()=0
void reset()
Definition: RAWEVENT.cxx:6
const char * what() const
Human description message.
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
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-05-04/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-05-04/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 286 of file RawDataInputSvc.cxx.

287{
288 //std::cout << "setCurrentEvent(RAWEVENT* m_onlinere)" << std::endl;
289 return (m_re = m_onlinere);
290}

◆ setCurrentEvent() [2/2]

virtual bool RawDataInputSvc::setCurrentEvent ( RAWEVENT m_onlinere)
virtual

Implements IRawDataInputSvc.


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