BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
eformat::old Namespace Reference

Classes

class  FullEventFragment
class  Header
class  ROBFragment
class  RODFragment
class  ROSFragment
class  SubDetectorFragment

Functions

uint32_t convert_source (uint32_t old_id)
uint32_t convert (const uint32_t *src, uint32_t *dest, uint32_t max)

Detailed Description

Includes classes and non-member methods that allows provisional reading from event format v2.4. The main purpose of this functionality is conversion from the old to the new event format.

Function Documentation

◆ convert()

uint32_t eformat::old::convert ( const uint32_t * src,
uint32_t * dest,
uint32_t max )

Converts a full event fragment, from the old to new format, using the space of contiguous memory storage area given. If the event given is already on v3.0 format, no conversion takes place.

Parameters
srcA pointer to the first word of the event, lying in a contiguous area of memory.
destThe destination area of memory, preallocated
maxThe maximum number of words that fit in the preallocated memory area "dest".
Returns
A counter, for the number of words copied from the source to the destination. If that number is zero, something wrong happened.

Definition at line 244 of file util24.cxx.

244 {
245 using namespace eformat;
246
247 if ( src[0] != FULL_EVENT )
248 {
249 if ( src[0] != ROS ) { throw EFORMAT_WRONG_MARKER( src[0], FULL_EVENT ); }
250 return convert_ros( src, dest, max );
251 }
252
253 // check version
254 helper::Version version( src[3] );
255 if ( version.major2() == MAJOR_DEFAULT_VERSION )
256 {
257 memcpy( dest, src, sizeof( uint32_t ) * src[1] );
258 return src[1];
259 }
260 if ( version.major2() != MAJOR_OLD_VERSION )
261 throw EFORMAT_BAD_VERSION( version.major2(), MAJOR_DEFAULT_VERSION );
262
263 // this is from the old major version of eformat, proceed with conversion
264 old::FullEventFragment fe( src );
265 fe.check_tree(); // this may throw
266
267 // create the base FullEvent
268 /**********renzy edit***/
269 // write::FullEventFragment nfe(convert_source(fe.source_id()),
270 eformat::write::FullEventFragment nfe( convert_source( fe.source_id() ),
271 /**********renzy edit***/
272 fe.date(), fe.global_id(), fe.run_no(), fe.lvl1_id(),
273 fe.lvl1_trigger_type(), fe.lvl2_trigger_info(),
274 fe.event_filter_info() );
275 nfe.status( fe.nstatus(), fe.status() );
276 nfe.minor_version( version.minor2() );
277
278 /**********renzy edit***/
279 /*std::vector<write::SubDetectorFragment*> acc_sd;
280 std::vector<write::ROSFragment*> acc_ros;
281 std::vector<write::ROBFragment*> acc_rob;*/
282 std::vector<eformat::write::SubDetectorFragment*> acc_sd;
283 std::vector<eformat::write::ROSFragment*> acc_ros;
284 std::vector<eformat::write::ROBFragment*> acc_rob;
285 /**********renzy edit***/
286 for ( size_t i = 0; i < fe.noffset(); ++i )
287 {
288 old::SubDetectorFragment sd( fe.child( i ) );
289 // create the new subdetector and set _all_ relevant stuff
290 /**********renzy edit***/
291 /*write::SubDetectorFragment* nsd =
292 new write::SubDetectorFragment(convert_source(sd.source_id()));*/
293 eformat::write::SubDetectorFragment* nsd =
294 new eformat::write::SubDetectorFragment( convert_source( sd.source_id() ) );
295 /**********renzy edit***/
296 nsd->status( sd.nstatus(), sd.status() );
297 helper::Version sd_version( sd.version() );
298 nsd->minor_version( sd_version.minor2() );
299
300 for ( size_t j = 0; j < sd.noffset(); ++j )
301 {
302 old::ROSFragment ros( sd.child( j ) );
303 /**********renzy edit***/
304 /*write::ROSFragment* nros =
305 new write::ROSFragment(convert_source(ros.source_id()),
306 ros.run_no(), ros.lvl1_id(), ros.bc_id());*/
307 eformat::write::ROSFragment* nros = new eformat::write::ROSFragment(
308 convert_source( ros.source_id() ), ros.run_no(), ros.lvl1_id(), ros.bc_id() );
309 /**********renzy edit***/
310 nros->status( ros.nstatus(), ros.status() );
311 helper::Version ros_version( ros.version() );
312 nros->minor_version( ros_version.minor2() );
313
314 for ( size_t k = 0; k < ros.noffset(); ++k )
315 {
316 old::ROBFragment rob( ros.child( k ) );
317 uint32_t source_id = rob.source_id();
318
319 for ( size_t l = 0; l < rob.noffset(); ++l )
320 {
321 old::RODFragment rod( rob.rod( l ) );
322 if ( rob.noffset() != 1 ) source_id = rod.source_id();
323 /**********renzy edit***/
324 // write::ROBFragment* nrob = new write::ROBFragment
325 eformat::write::ROBFragment* nrob = new eformat::write::ROBFragment
326 /**********renzy edit***/
327 ( convert_source( source_id ), rod.run_no(), rod.lvl1_id(), rod.bc_id(),
328 rod.lvl1_trigger_type(), rod.detev_type(), rod.ndata(), rod.data(),
329 rod.status_position() );
330 nrob->status( rob.nstatus(), rob.status() );
331 nrob->rod_status( rod.nstatus(), rod.status() );
332 helper::Version rob_version( rob.version() );
333 nrob->minor_version( rob_version.minor2() );
334 helper::Version rod_version( rod.version() );
335 nrob->rod_minor_version( rod_version.minor2() );
336
337 // make this new ROB part of the new ROS
338 nros->append( nrob );
339 // make sure we don't forget to delete this guy
340 acc_rob.push_back( nrob );
341 }
342 }
343 // maks this new ROS part of the new SD
344 nsd->append( nros );
345 // make sure we don't forget to delete this guy
346 acc_ros.push_back( nros );
347 }
348 // make this new SD part of the new FE
349 nfe.append( nsd );
350 // make sure we don't forget to delete this guy
351 acc_sd.push_back( nsd );
352 }
353
354 // now the FullEvent is in `nfe', bind
355 const eformat::write::node_t* top = nfe.bind();
356 // memcpy the list of pages into contiguous memory
357 uint32_t retval = eformat::write::copy( *top, dest, max );
358
359 // delete the allocated stuff
360 for ( size_t i = 0; i < acc_rob.size(); ++i ) delete acc_rob[i];
361 for ( size_t i = 0; i < acc_ros.size(); ++i ) delete acc_ros[i];
362 for ( size_t i = 0; i < acc_sd.size(); ++i ) delete acc_sd[i];
363
364 return retval;
365}
#define max(a, b)
#define EFORMAT_BAD_VERSION(current, supported)
#define EFORMAT_WRONG_MARKER(current, expected)
void status(uint32_t n, const uint32_t *status)
void rod_status(uint32_t n, const uint32_t *status)
void status(uint32_t n, const uint32_t *status)
void append(eformat::write::ROBFragment *rob)
void status(uint32_t n, const uint32_t *status)
void append(eformat::write::ROSFragment *ros)
uint32_t convert_source(uint32_t old_id)
Definition util24.cxx:28
struct eformat::write::node_t node_t
uint32_t copy(const node_t &list, uint32_t *dest, size_t max)
Definition node.cxx:60
uint32_t convert_ros(const uint32_t *src, uint32_t *dest, uint32_t max)
Definition util24.cxx:172

Referenced by main().

◆ convert_source()

uint32_t eformat::old::convert_source ( uint32_t old_id)

Gets an old source identitifier (v2.4) and transforms it into a new one, for version 3.0 of the event format

Parameters
old_idThe old source identifier

Definition at line 28 of file util24.cxx.

28 {
29 using namespace eformat;
30
31 uint16_t id = old_id & 0x00ff;
32 uint8_t sd = ( old_id >> 8 ) & 0xff;
33 uint8_t md = ( old_id >> 16 ) & 0xff;
34 uint32_t retval = 0;
35
36 switch ( (SubDetector)sd )
37 {
38 case FULL_SD_EVENT:
39 case PIXEL_BARREL:
42 case PIXEL_B_LAYER:
58 case LAR_FCAL_A_SIDE:
59 case LAR_FCAL_C_SIDE:
76 case TDAQ_BEAM_CRATE:
79 case OTHER: retval = sd; break;
80 case TDAQ_CALO_CLUSTER_PROC_ROI: // old TDAQ_CALO_JET
81 retval = 0x74;
82 break;
83 case TDAQ_CALO_JET_PROC_DAQ: // old TDAQ_CTP
84 retval = 0x77;
85 break;
86 case TDAQ_CALO_JET_PROC_ROI: // old TDAQ_MUON_INTERFACE
87 retval = 0x76;
88 break;
89 case TDAQ_MUON_CTP_INTERFACE: // old TDAQ_DATAFLOW
90 switch ( md )
91 {
92 case 0x02: // LVL1 ROSes
93 case 0x04: // old SUPERVISOR
94 retval = 0x78; // new L2SV
95 break;
96 case 0x06: // old SFI
97 retval = 0x79; // new SFI
98 break;
99 case 0x07: // old SFO
100 retval = 0x7a; // new SFO
101 break;
102 case 0x0a: // old OTHER_MODULE
103 retval = OTHER; // new OTHER
104 break;
105 default:
106 ERS_WARN( "%s%x%s%s", "Propose an equivalent of the source identifier 0x", old_id,
107 " [v2.4], for the 3.0 format, to eformat developers.",
108 "The subdetector identifier field will be zero'd for now." );
109 }
110 break;
111 case TDAQ_CTP: // old TDAQ_LVL2
112 switch ( md )
113 {
114 case 0x01: // old L2PU->PROS
115 case 0x02: // old L2PU->PROS
116 case 0x05: // old HLT_PROCESSOR
117 retval = 0x7b; // new LVL2
118 break;
119 case 0x04: // old SUPERVISOR
120 retval = 0x78; // new L2SV
121 break;
122 case 0x06: // old SFI marker for PROS data
123 retval = 0x79; // new SFI
124 break;
125 default:
126 ERS_WARN( "%s%x%s%s", "Propose an equivalent of the source identifier 0x", old_id,
127 " [v2.4], for the 3.0 format, to eformat developers.",
128 "The subdetector identifier field will be zero'd for now." );
129 }
130 break;
131 case TDAQ_L2SV: // old TDAQ_EVENT_FILTER
132 switch ( md )
133 {
134 case 0x05: // old HLT_PROCESSOR
135 retval = 0x7b; // new LVL2
136 default:
137 ERS_WARN( "%s%x%s%s", "Propose an equivalent of the source identifier 0x", old_id,
138 " [v2.4], for the 3.0 format, to eformat developers.",
139 "The subdetector identifier field will be zero'd for now." );
140 }
141 break;
142 case TDAQ_SFI:
143 case TDAQ_SFO:
144 case TDAQ_LVL2:
146 default:
147 ERS_WARN( "%s%x%s%s", "Propose an equivalent of the source identifier 0x", old_id,
148 " [v2.4], for the 3.0 format, to eformat developers.",
149 "The subdetector identifier field will be zero'd for now." );
150 break;
151 }
152 retval <<= 16;
153 retval |= id;
154 ERS_DEBUG_3( "Source identifier 0x%x [v2.4] was converted to 0x%x [v3.0]", old_id, retval );
155 return retval;
156}
#define ERS_DEBUG_3(...)

Referenced by convert(), and convert_ros().