BOSS 7.0.1
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)
 

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 ()
 

Detailed Description

Constructor & Destructor Documentation

◆ EvtIdxHandler() [1/2]

EvtIdxHandler::EvtIdxHandler ( )

Definition at line 42 of file EvtIdxHandler.cxx.

43 : m_totEvt(0),
44 m_idxPos(-1),
45 m_blockSize(DefaultIdxBlockSize)
46{
47 m_EIdBlock = new uint32_t[m_blockSize];
48 m_PosBlock = new uint32_t[m_blockSize];
49}
#define DefaultIdxBlockSize

Referenced by instance().

◆ ~EvtIdxHandler() [1/2]

EvtIdxHandler::~EvtIdxHandler ( )
virtual

Definition at line 51 of file EvtIdxHandler.cxx.

52{
53 delete[] m_EIdBlock;
54 delete[] m_PosBlock;
55}

◆ EvtIdxHandler() [2/2]

EvtIdxHandler::EvtIdxHandler ( )

◆ ~EvtIdxHandler() [2/2]

virtual EvtIdxHandler::~EvtIdxHandler ( )
virtual

Member Function Documentation

◆ addPos() [1/2]

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

Definition at line 82 of file EvtIdxHandler.cxx.

83{
84 ++m_totEvt;
85
86 if ( m_totEvt > m_blockSize ) enlarge_block( m_totEvt );
87
88 m_EIdBlock[m_totEvt-1] = evtId;
89 m_PosBlock[m_totEvt-1] = pos;
90}

Referenced by main().

◆ addPos() [2/2]

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

◆ findPosById() [1/2]

uint32_t EvtIdxHandler::findPosById ( uint32_t  evtId)

Definition at line 71 of file EvtIdxHandler.cxx.

72{
73 while ( m_totEvt > m_idxPos ) {
74 if ( m_EIdBlock[m_idxPos] == evtId ) {
75 return m_PosBlock[m_idxPos++];
76 }
77 ++m_idxPos;
78 }
79 return 0;
80}

Referenced by RawFileReader::findEventById().

◆ findPosById() [2/2]

uint32_t EvtIdxHandler::findPosById ( uint32_t  evtId)

◆ IdxFileStartMarker() [1/2]

static uint32_t EvtIdxHandler::IdxFileStartMarker ( )
inlinestatic

Definition at line 13 of file Event/RawFile/RawFile-00-00-10/RawFile/EvtIdxHandler.h.

13{ return 0xFFFFAAAA; }

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

◆ IdxFileStartMarker() [2/2]

static uint32_t EvtIdxHandler::IdxFileStartMarker ( )
inlinestatic

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

13{ return 0xFFFFAAAA; }

◆ IdxIdBlockMarker() [1/2]

static uint32_t EvtIdxHandler::IdxIdBlockMarker ( )
inlinestatic

Definition at line 14 of file Event/RawFile/RawFile-00-00-10/RawFile/EvtIdxHandler.h.

14{ return 0xFFFFBBBB; }

Referenced by write().

◆ IdxIdBlockMarker() [2/2]

static uint32_t EvtIdxHandler::IdxIdBlockMarker ( )
inlinestatic

Definition at line 14 of file InstallArea/include/RawFile/RawFile/EvtIdxHandler.h.

14{ return 0xFFFFBBBB; }

◆ IdxPosBlockMarker() [1/2]

static uint32_t EvtIdxHandler::IdxPosBlockMarker ( )
inlinestatic

Definition at line 15 of file Event/RawFile/RawFile-00-00-10/RawFile/EvtIdxHandler.h.

15{ return 0xFFFFCCCC; }

Referenced by write().

◆ IdxPosBlockMarker() [2/2]

static uint32_t EvtIdxHandler::IdxPosBlockMarker ( )
inlinestatic

Definition at line 15 of file InstallArea/include/RawFile/RawFile/EvtIdxHandler.h.

15{ return 0xFFFFCCCC; }

◆ instance() [1/2]

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

Definition at line 11 of file EvtIdxHandler.cxx.

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

Referenced by RawFileReader::RawFileReader().

◆ instance() [2/2]

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

◆ nEvtLeft() [1/2]

int EvtIdxHandler::nEvtLeft ( int  nIgnore) const
inline

Definition at line 29 of file Event/RawFile/RawFile-00-00-10/RawFile/EvtIdxHandler.h.

29 {
30 return ( m_totEvt - (m_idxPos+nIgnore) );
31 }

Referenced by RawFileReader::nextEvent().

◆ nEvtLeft() [2/2]

int EvtIdxHandler::nEvtLeft ( int  nIgnore) const
inline

Definition at line 29 of file InstallArea/include/RawFile/RawFile/EvtIdxHandler.h.

29 {
30 return ( m_totEvt - (m_idxPos+nIgnore) );
31 }

◆ next_file() [1/2]

void EvtIdxHandler::next_file ( )

Definition at line 57 of file EvtIdxHandler.cxx.

58{
59 ++m_curFile;
60
61 m_idxPos = 0;
62 init_idx();
63}

◆ next_file() [2/2]

void EvtIdxHandler::next_file ( )

◆ nextPos() [1/2]

uint32_t EvtIdxHandler::nextPos ( int  nIgnore)

Definition at line 65 of file EvtIdxHandler.cxx.

66{
67 m_idxPos += nIgnore;
68 return m_PosBlock[m_idxPos++];
69}

Referenced by RawFileReader::nextEvent().

◆ nextPos() [2/2]

uint32_t EvtIdxHandler::nextPos ( int  nIgnore)

◆ release() [1/2]

void EvtIdxHandler::release ( )
static

Definition at line 22 of file EvtIdxHandler.cxx.

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

Referenced by RawFileReader::~RawFileReader().

◆ release() [2/2]

static void EvtIdxHandler::release ( )
static

◆ write() [1/2]

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

Definition at line 92 of file EvtIdxHandler.cxx.

93{
94 if ( m_idxPos >= 0 ) {
95 std::cerr << "[RawFile] Writing an EvtIdxHandler for reading !!!" << std::endl;
96 exit(1);
97 }
98
99 m_fs.open( fname.c_str(), std::ios::out | std::ios::binary );
100
101 uint32_t marker = EvtIdxHandler::IdxFileStartMarker();
102 m_fs.write( (char*)&marker, sizeof(marker) );
103 m_fs.write( (char*)&m_totEvt, sizeof(m_totEvt) );
104
106 m_fs.write( (char*)&marker, sizeof(marker) );
107 m_fs.write( (char*)m_EIdBlock, m_totEvt*sizeof(uint32_t) );
108
110 m_fs.write( (char*)&marker, sizeof(marker) );
111 m_fs.write( (char*)m_PosBlock, m_totEvt*sizeof(uint32_t) );
112
113 if ( ! m_fs.good() ) {
114 std::cerr << "[RawFile] Error writing IDX file: " << fname << std::endl;
115 exit(1);
116 }
117
118 m_fs.close();
119
120 std::cout << "[RawFile] Written IDX file: " << fname << std::endl;
121
122 m_totEvt = 0;
123}

Referenced by main().

◆ write() [2/2]

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

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