BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/RawFile/include/RawFile/CgemIndexFile.h
Go to the documentation of this file.
1#ifndef _CGEMINDEXFILE_H_
2#define _CGEMINDEXFILE_H_
3
4#include "RawFile/RawDataCache.h"
5#include <cstdint>
6#include <string>
7#include <vector>
8#include <fstream>
9
11 uint32_t lastL1id;
12 uint32_t pos;
13};
14
16 uint32_t l1id;
17 uint32_t pos;
18 uint32_t size;
19};
20
21class CgemIndexFile final {
22public:
23 const uint32_t kIndexFileMarker{ 0x6c6c7566 }; // "full" index
24 const uint32_t kSubIndexFileMarker{ 0x66627573 }; // "subf" (sub-file) index
25 const uint32_t kMaxNumFiles{ 1020 }; // total 8k (32 bytes file header + 1020*8 bytes meta)
26
29
30 // open an exist index file for reading
31 bool open4read( const std::string& file );
32
33 // create a new index file for writing
34 bool open4write( const std::string& file );
35
36 // extract the indices from a raw data file and append to this object
37 bool append_from( const std::string& file );
38
39 // clear the status and release resources
40 void close();
41
42 // dump the brief meta-info of the index file
43 void show();
44 // dump the meta-info of the currently loaded sub-file after loadSubFile()
45 void showSubFile();
46 void showSubFileRange(const uint32_t start, const uint32_t end);
47
48 // load the context of the nth sub-file
49 bool loadSubFile(const uint32_t n);
50
51 // get the CGEM data with the given L1ID
52 uint32_t* getCgemData(const uint32_t l1id);
53
54 // getters
55 uint32_t numFiles() { return m_numFiles; }
56 uint32_t numEvents() { return m_subFile->i_numEvents; }
57 CgemSubFileMeta* getMeta() { return m_meta->data<CgemSubFileMeta>(); }
58 CgemEventIndex* getIndices() { return m_subFile->i_fidx->data<CgemEventIndex>(); }
59
60
61private:
62 struct CgemSubFileContext {
63 uint32_t i_numEvents{ 0 }; // number of events in this sub-file
64 RawDataCache* i_fidx{ nullptr }; // the event indices of this sub-file
65 std::string i_datafn; // the related data file name
66 std::ifstream i_datafs; // the related data input stream
67
68 CgemSubFileContext() { i_fidx = new RawDataCache(); }
69 ~CgemSubFileContext() { delete i_fidx; }
70 };
71
72 bool m_isWrite{ false };
73 uint32_t m_numFiles{ 0 }; // in full-file context
74 RawDataCache* m_meta{ nullptr }; // in full-file context
75 RawDataCache* m_data{ nullptr }; // for the CGEM data
76 CgemSubFileContext* m_subFile{ nullptr }; // currently avtive sub-file
77 std::fstream m_fs;
78 std::vector<CgemSubFileContext*> m_subFiles; // sub-file caches for reading
79};
80
81#endif
char * file
Definition DQA_TO_DB.cxx:16
const Int_t n
bool append_from(const std::string &file)
bool open4read(const std::string &file)
bool open4write(const std::string &file)
bool loadSubFile(const uint32_t n)
void showSubFileRange(const uint32_t start, const uint32_t end)
uint32_t * getCgemData(const uint32_t l1id)