BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtIdxHandler Class Reference

#include <EvtIdxHandler.h>

Public Member Functions

 EvtIdxHandler ()
virtual ~EvtIdxHandler ()
void next_file ()
uint32_t nextPos (int nIgnore)
uint32_t findPosById (uint32_t evtId)
int nEvtLeft (int nIgnore) const
void addPos (uint32_t evtId, uint32_t pos)
void write (std::string fname)
 EvtIdxHandler ()
virtual ~EvtIdxHandler ()
void next_file ()
uint32_t nextPos (int nIgnore)
uint32_t findPosById (uint32_t evtId)
int nEvtLeft (int nIgnore) const
void addPos (uint32_t evtId, uint32_t pos)
void write (std::string fname)
 EvtIdxHandler ()
virtual ~EvtIdxHandler ()
void next_file ()
uint32_t nextPos (int nIgnore)
uint32_t findPosById (uint32_t evtId)
int nEvtLeft (int nIgnore) const
void addPos (uint32_t evtId, uint32_t pos)
void write (std::string fname)

Static Public Member Functions

static uint32_t IdxFileStartMarker ()
static uint32_t IdxIdBlockMarker ()
static uint32_t IdxPosBlockMarker ()
static EvtIdxHandlerinstance (const std::vector< std::string > &fnames)
static void release ()
static uint32_t IdxFileStartMarker ()
static uint32_t IdxIdBlockMarker ()
static uint32_t IdxPosBlockMarker ()
static EvtIdxHandlerinstance (const std::vector< std::string > &fnames)
static void release ()
static uint32_t IdxFileStartMarker ()
static uint32_t IdxIdBlockMarker ()
static uint32_t IdxPosBlockMarker ()
static EvtIdxHandlerinstance (const std::vector< std::string > &fnames)
static void release ()

Detailed Description

Definition at line 9 of file Event/RawFile/include/RawFile/EvtIdxHandler.h.

Constructor & Destructor Documentation

◆ EvtIdxHandler() [1/3]

EvtIdxHandler::EvtIdxHandler ( )

Definition at line 40 of file EvtIdxHandler.cxx.

41 : m_totEvt( 0 ), m_idxPos( -1 ), m_blockSize( DefaultIdxBlockSize ) {
42 m_EIdBlock = new uint32_t[m_blockSize];
43 m_PosBlock = new uint32_t[m_blockSize];
44}
#define DefaultIdxBlockSize

Referenced by instance(), and write().

◆ ~EvtIdxHandler() [1/3]

EvtIdxHandler::~EvtIdxHandler ( )
virtual

Definition at line 46 of file EvtIdxHandler.cxx.

46 {
47 delete[] m_EIdBlock;
48 delete[] m_PosBlock;
49}

◆ EvtIdxHandler() [2/3]

EvtIdxHandler::EvtIdxHandler ( )

◆ ~EvtIdxHandler() [2/3]

virtual EvtIdxHandler::~EvtIdxHandler ( )
virtual

◆ EvtIdxHandler() [3/3]

EvtIdxHandler::EvtIdxHandler ( )

◆ ~EvtIdxHandler() [3/3]

virtual EvtIdxHandler::~EvtIdxHandler ( )
virtual

Member Function Documentation

◆ addPos() [1/3]

void EvtIdxHandler::addPos ( uint32_t evtId,
uint32_t pos )

Definition at line 72 of file EvtIdxHandler.cxx.

72 {
73 ++m_totEvt;
74
75 if ( m_totEvt > m_blockSize ) enlarge_block( m_totEvt );
76
77 m_EIdBlock[m_totEvt - 1] = evtId;
78 m_PosBlock[m_totEvt - 1] = pos;
79}

Referenced by main().

◆ addPos() [2/3]

void EvtIdxHandler::addPos ( uint32_t evtId,
uint32_t pos )

◆ addPos() [3/3]

void EvtIdxHandler::addPos ( uint32_t evtId,
uint32_t pos )

◆ findPosById() [1/3]

uint32_t EvtIdxHandler::findPosById ( uint32_t evtId)

Definition at line 63 of file EvtIdxHandler.cxx.

63 {
64 while ( m_totEvt > m_idxPos )
65 {
66 if ( m_EIdBlock[m_idxPos] == evtId ) { return m_PosBlock[m_idxPos++]; }
67 ++m_idxPos;
68 }
69 return 0;
70}

◆ findPosById() [2/3]

uint32_t EvtIdxHandler::findPosById ( uint32_t evtId)

◆ findPosById() [3/3]

uint32_t EvtIdxHandler::findPosById ( uint32_t evtId)

◆ IdxFileStartMarker() [1/3]

uint32_t EvtIdxHandler::IdxFileStartMarker ( )
inlinestatic

Definition at line 11 of file Event/RawFile/include/RawFile/EvtIdxHandler.h.

11{ return 0xFFFFAAAA; }

Referenced by RawFileReader::getEventNumber(), and write().

◆ IdxFileStartMarker() [2/3]

uint32_t EvtIdxHandler::IdxFileStartMarker ( )
inlinestatic

Definition at line 11 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/EvtIdxHandler.h.

11{ return 0xFFFFAAAA; }

◆ IdxFileStartMarker() [3/3]

uint32_t EvtIdxHandler::IdxFileStartMarker ( )
inlinestatic

Definition at line 11 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/EvtIdxHandler.h.

11{ return 0xFFFFAAAA; }

◆ IdxIdBlockMarker() [1/3]

uint32_t EvtIdxHandler::IdxIdBlockMarker ( )
inlinestatic

Definition at line 12 of file Event/RawFile/include/RawFile/EvtIdxHandler.h.

12{ return 0xFFFFBBBB; }

Referenced by write().

◆ IdxIdBlockMarker() [2/3]

uint32_t EvtIdxHandler::IdxIdBlockMarker ( )
inlinestatic

Definition at line 12 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/EvtIdxHandler.h.

12{ return 0xFFFFBBBB; }

◆ IdxIdBlockMarker() [3/3]

uint32_t EvtIdxHandler::IdxIdBlockMarker ( )
inlinestatic

Definition at line 12 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/EvtIdxHandler.h.

12{ return 0xFFFFBBBB; }

◆ IdxPosBlockMarker() [1/3]

uint32_t EvtIdxHandler::IdxPosBlockMarker ( )
inlinestatic

Definition at line 13 of file Event/RawFile/include/RawFile/EvtIdxHandler.h.

13{ return 0xFFFFCCCC; }

Referenced by write().

◆ IdxPosBlockMarker() [2/3]

uint32_t EvtIdxHandler::IdxPosBlockMarker ( )
inlinestatic

Definition at line 13 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/EvtIdxHandler.h.

13{ return 0xFFFFCCCC; }

◆ IdxPosBlockMarker() [3/3]

uint32_t EvtIdxHandler::IdxPosBlockMarker ( )
inlinestatic

Definition at line 13 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/EvtIdxHandler.h.

13{ return 0xFFFFCCCC; }

◆ instance() [1/3]

EvtIdxHandler * EvtIdxHandler::instance ( const std::vector< std::string > & fnames)
static

Definition at line 15 of file EvtIdxHandler.cxx.

15 {
16 if ( _instance == 0 ) { _instance = new EvtIdxHandler( idxfnames ); }
17
18 ++_nHandler;
19
20 return _instance;
21}

Referenced by RawFileReader::RawFileReader(), RawFileReader::RawFileReader(), RawFileReader::RawFileReader(), and RawFileReader::RawFileReader().

◆ instance() [2/3]

EvtIdxHandler * EvtIdxHandler::instance ( const std::vector< std::string > & fnames)
static

◆ instance() [3/3]

EvtIdxHandler * EvtIdxHandler::instance ( const std::vector< std::string > & fnames)
static

◆ nEvtLeft() [1/3]

int EvtIdxHandler::nEvtLeft ( int nIgnore) const
inline

Definition at line 27 of file Event/RawFile/include/RawFile/EvtIdxHandler.h.

27{ return ( m_totEvt - ( m_idxPos + nIgnore ) ); }

◆ nEvtLeft() [2/3]

int EvtIdxHandler::nEvtLeft ( int nIgnore) const
inline

Definition at line 27 of file InstallArea/x86_64-el9-gcc13-dbg/include/RawFile/EvtIdxHandler.h.

27{ return ( m_totEvt - ( m_idxPos + nIgnore ) ); }

◆ nEvtLeft() [3/3]

int EvtIdxHandler::nEvtLeft ( int nIgnore) const
inline

Definition at line 27 of file InstallArea/x86_64-el9-gcc13-opt/include/RawFile/EvtIdxHandler.h.

27{ return ( m_totEvt - ( m_idxPos + nIgnore ) ); }

◆ next_file() [1/3]

void EvtIdxHandler::next_file ( )

Definition at line 51 of file EvtIdxHandler.cxx.

51 {
52 ++m_curFile;
53
54 m_idxPos = 0;
55 init_idx();
56}

◆ next_file() [2/3]

void EvtIdxHandler::next_file ( )

◆ next_file() [3/3]

void EvtIdxHandler::next_file ( )

◆ nextPos() [1/3]

uint32_t EvtIdxHandler::nextPos ( int nIgnore)

Definition at line 58 of file EvtIdxHandler.cxx.

58 {
59 m_idxPos += nIgnore;
60 return m_PosBlock[m_idxPos++];
61}

◆ nextPos() [2/3]

uint32_t EvtIdxHandler::nextPos ( int nIgnore)

◆ nextPos() [3/3]

uint32_t EvtIdxHandler::nextPos ( int nIgnore)

◆ release() [1/3]

void EvtIdxHandler::release ( )
static

Definition at line 23 of file EvtIdxHandler.cxx.

23 {
24 if ( _nHandler > 0 && --_nHandler == 0 )
25 {
26 delete _instance;
27 _instance = 0;
28 }
29}

Referenced by RawFileReader::~RawFileReader().

◆ release() [2/3]

void EvtIdxHandler::release ( )
static

◆ release() [3/3]

void EvtIdxHandler::release ( )
static

◆ write() [1/3]

void EvtIdxHandler::write ( std::string fname)

Definition at line 81 of file EvtIdxHandler.cxx.

81 {
82 if ( m_idxPos >= 0 )
83 {
84 std::cerr << "[RawFile] Writing an EvtIdxHandler for reading !!!" << std::endl;
85 exit( 1 );
86 }
87
88 m_fs.open( fname.c_str(), std::ios::out | std::ios::binary );
89
90 uint32_t marker = EvtIdxHandler::IdxFileStartMarker();
91 m_fs.write( (char*)&marker, sizeof( marker ) );
92 m_fs.write( (char*)&m_totEvt, sizeof( m_totEvt ) );
93
95 m_fs.write( (char*)&marker, sizeof( marker ) );
96 m_fs.write( (char*)m_EIdBlock, m_totEvt * sizeof( uint32_t ) );
97
99 m_fs.write( (char*)&marker, sizeof( marker ) );
100 m_fs.write( (char*)m_PosBlock, m_totEvt * sizeof( uint32_t ) );
101
102 if ( !m_fs.good() )
103 {
104 std::cerr << "[RawFile] Error writing IDX file: " << fname << std::endl;
105 exit( 1 );
106 }
107
108 m_fs.close();
109
110 std::cout << "[RawFile] Written IDX file: " << fname << std::endl;
111
112 m_totEvt = 0;
113}

Referenced by main().

◆ write() [2/3]

void EvtIdxHandler::write ( std::string fname)

◆ write() [3/3]

void EvtIdxHandler::write ( std::string fname)

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