BOSS 8.0.0
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)
StatusCode initialize ()
StatusCode finalize ()
RAWEVENTnextEvent ()
RAWEVENTcurrentEvent ()
bool setCurrentEvent (RAWEVENT *m_onlinere)
std::string currentFile () const
uint32_t runNo ()
const SniperJSONconfig (const std::string &key)
OfflineReviseofflineRevisor ()
int runMode ()

Detailed Description

Definition at line 10 of file RawDataInputSvc.h.

Constructor & Destructor Documentation

◆ RawDataInputSvc()

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

Definition at line 21 of file RawDataInputSvc.cxx.

22 : base_class( name, svcloc ), m_re( 0 ), m_reader( 0 ), m_sds( 0 ), m_robs( 0 ) {
23 declareProperty( "RunMode", m_mode = 2 );
24 declareProperty( "KeepRandomTrigEvt", m_keepRdm = true );
25 declareProperty( "InputFiles", m_inputFiles );
26 declareProperty( "Config4Revise", m_conf4Revise );
27}

Referenced by RawDataInputSvc().

Member Function Documentation

◆ config()

const SniperJSON & RawDataInputSvc::config ( const std::string & key)
inline

Definition at line 25 of file RawDataInputSvc.h.

25{ return m_json[key]; }
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42

◆ currentEvent()

RAWEVENT * RawDataInputSvc::currentEvent ( )

Get a pointer to the current event.

Definition at line 249 of file RawDataInputSvc.cxx.

249 {
250 // Return a pointer to the raw event.
251 // std::cout << "RawDataCnv -> Return a pointer to the raw event." << std::endl;
252 // std::cout << "It is the first time to call the currentEvent()" << std::endl;
253 return m_re;
254}

◆ currentFile()

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

Definition at line 23 of file RawDataInputSvc.h.

23{ return m_reader->currentFile(); }

◆ finalize()

StatusCode RawDataInputSvc::finalize ( )

Definition at line 71 of file RawDataInputSvc.cxx.

71 {
72 // clean up
73 if ( m_re )
74 {
75 delete m_re;
76 m_re = 0;
77 }
78
79 if ( m_reader )
80 {
81 delete m_reader;
82 m_reader = 0;
83 }
84
85 delete m_revisor;
86
87 if ( m_sds ) delete m_sds;
88 if ( m_robs ) delete m_robs;
89
90 return StatusCode::SUCCESS;
91}

◆ initialize()

StatusCode RawDataInputSvc::initialize ( )

Definition at line 30 of file RawDataInputSvc.cxx.

30 {
31
32#ifndef OnlineMode
33 if ( m_mode > 1 )
34 {
35 try
36 {
37 if ( m_mode == 2 )
38 { // OfflineMode
39 if ( m_inputFiles.empty() ) return StatusCode::SUCCESS;
40 m_reader = new RawFileReader( m_inputFiles );
41 }
42 else if ( m_mode == 3 )
43 {
44 // DistBossMode
45 // DistBoss::GetPropertyValue<std::string>( "DistBoss", "ServerName", m_evtServer );
46 // m_reader = new NetDataReader( m_evtServer + "/RawEvtSvc" );
47 throw RawExMessage( "RawDataInputSvc: DistBoss has been deprecated!" );
48 }
49 else { throw RawExMessage( "RawDataInputSvc: Invalid RunMode!" ); }
50 } catch ( RawFileException& ex )
51 {
52 ex.print();
53 return StatusCode::FAILURE;
54 }
55
56 m_re = new RAWEVENT;
57
58 m_sds = new const uint32_t*[64];
59 m_robs = new const uint32_t*[256];
60 }
61#endif
62
63 std::ifstream cf( m_conf4Revise.c_str() );
64 m_json = SniperJSON::load( cf );
65
66 m_revisor = new OfflineRevise( m_json["ETS_FIX"] );
67
68 return StatusCode::SUCCESS;
69}
virtual void print() const
static SniperJSON load(std::istream &is)

◆ nextEvent()

RAWEVENT * RawDataInputSvc::nextEvent ( )

Definition at line 94 of file RawDataInputSvc.cxx.

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

◆ offlineRevisor()

OfflineRevise * RawDataInputSvc::offlineRevisor ( )
inline

Definition at line 26 of file RawDataInputSvc.h.

26{ return m_revisor; }

◆ runMode()

int RawDataInputSvc::runMode ( )
inline

Definition at line 29 of file RawDataInputSvc.h.

29{ return m_mode; }

◆ runNo()

uint32_t RawDataInputSvc::runNo ( )
inline

Definition at line 24 of file RawDataInputSvc.h.

24{ return m_reader->runNo(); }

◆ setCurrentEvent()

bool RawDataInputSvc::setCurrentEvent ( RAWEVENT * m_onlinere)

Definition at line 256 of file RawDataInputSvc.cxx.

256 {
257 // std::cout << "setCurrentEvent(RAWEVENT* m_onlinere)" << std::endl;
258 return ( m_re = m_onlinere );
259}

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