@@ -34,6 +34,22 @@ namespace raw
3434
3535using IR = o2::InteractionRecord;
3636
37+ struct ReaderInp {
38+ std::string inifile{};
39+ std::string rawChannelConfig{};
40+ size_t spSize = 1024L * 1024L ;
41+ size_t bufferSize = 1024L * 1024L ;
42+ int loop = 1 ;
43+ uint32_t delay_us = 0 ;
44+ uint32_t errMap = 0xffffffff ;
45+ uint32_t minTF = 0 ;
46+ uint32_t maxTF = 0xffffffff ;
47+ bool partPerSP = true ;
48+ bool cache = false ;
49+ bool autodetectTF0 = false ;
50+ bool preferCalcTF = false ;
51+ };
52+
3753class RawFileReader
3854{
3955 using LinkSpec_t = uint64_t ; // = (origin<<32) | LinkSubSpec
@@ -52,6 +68,8 @@ class RawFileReader
5268 ErrWrongNumberOfTF,
5369 ErrHBFJump,
5470 ErrNoSuperPageForTF,
71+ ErrNoSOX,
72+ ErrMismatchTF,
5573 NErrorsDefined
5674 };
5775
@@ -61,15 +79,17 @@ class RawFileReader
6179
6280 static constexpr std::string_view ErrNames[] = {
6381 // long names for error codes
64- " Wrong RDH.packetCounter increment" , // ErrWrongPacketCounterIncrement
65- " Wrong RDH.pageCnt increment" , // ErrWrongPageCounterIncrement
66- " RDH.stop set of 1st HBF page" , // ErrHBFStopOnFirstPage
67- " New HBF starts w/o closing old one" , // ErrHBFNoStop
68- " Data does not start with TF/HBF" , // ErrWrongFirstPage
69- " Number of HBFs per TF not as expected" , // ErrWrongHBFsPerTF
70- " Number of TFs is less than expected" , // ErrWrongNumberOfTF
71- " Wrong HBF orbit increment" , // ErrHBFJump
72- " TF does not start by new superpage" // ErrNoSuperPageForTF
82+ " Wrong RDH.packetCounter increment" , // ErrWrongPacketCounterIncrement
83+ " Wrong RDH.pageCnt increment" , // ErrWrongPageCounterIncrement
84+ " RDH.stop set of 1st HBF page" , // ErrHBFStopOnFirstPage
85+ " New HBF starts w/o closing old one" , // ErrHBFNoStop
86+ " Data does not start with TF/HBF" , // ErrWrongFirstPage
87+ " Number of HBFs per TF not as expected" , // ErrWrongHBFsPerTF
88+ " Number of TFs is less than expected" , // ErrWrongNumberOfTF
89+ " Wrong HBF orbit increment" , // ErrHBFJump
90+ " TF does not start by new superpage" , // ErrNoSuperPageForTF
91+ " No SOX found on 1st page" , // ErrNoSOX
92+ " Mismatch between flagged and calculated new TF start" // ErrMismatchTF
7393 };
7494 static constexpr std::string_view ErrNamesShort[] = {
7595 // short names for error codes
@@ -81,7 +101,9 @@ class RawFileReader
81101 " hbf-per-tf" , // ErrWrongHBFsPerTF
82102 " tf-per-link" , // ErrWrongNumberOfTF
83103 " hbf-jump" , // ErrHBFJump
84- " no-spage-for-tf" // ErrNoSuperPageForTF
104+ " no-spage-for-tf" , // ErrNoSuperPageForTF
105+ " no-sox" , // ErrNoSOX
106+ " tf-start-mismatch" // ErrMismatchTF
85107 };
86108 static constexpr bool ErrCheckDefaults[] = {
87109 true , // ErrWrongPacketCounterIncrement
@@ -92,7 +114,9 @@ class RawFileReader
92114 true , // ErrWrongHBFsPerTF
93115 true , // ErrWrongNumberOfTF
94116 true , // ErrHBFJump
95- false // ErrNoSuperPageForTF
117+ false , // ErrNoSuperPageForTF
118+ true , // ErrNoSOX
119+ true , // ErrMismatchTF
96120 };
97121 // ================================================================================
98122
@@ -115,12 +139,12 @@ class RawFileReader
115139 StartHB = 0x1 << 1 ,
116140 StartSP = 0x1 << 2 ,
117141 EndHB = 0x1 << 3 };
118- size_t offset = 0 ; // ! where data of the block starts
119- uint32_t size = 0 ; // ! block size
120- uint32_t tfID = 0 ; // ! tf counter (from 0)
121- IR ir = 0 ; // ! ir starting the block
122- uint16_t fileID = 0 ; // ! file id where the block is located
123- uint8_t flags = 0 ; // ! different flags
142+ size_t offset = 0 ; // ! where data of the block starts
143+ uint32_t size = 0 ; // ! block size
144+ uint32_t tfID = 0 ; // ! tf counter (from 0)
145+ IR ir = 0 ; // ! ir starting the block
146+ uint16_t fileID = 0 ; // ! file id where the block is located
147+ uint8_t flags = 0 ; // ! different flags
124148 std::unique_ptr<char []> dataCache; // ! optional cache for fast access
125149 LinkBlock () = default ;
126150 LinkBlock (int fid, size_t offs) : offset(offs), fileID(fid) {}
@@ -138,7 +162,8 @@ class RawFileReader
138162
139163 // =====================================================================================
140164 struct LinkData {
141- RDHAny rdhl; // ! RDH with the running info of the last RDH seen
165+ RDHAny rdhl; // ! RDH with the running info of the last RDH seen
166+ o2::InteractionRecord irOfSOX{};
142167 LinkSpec_t spec = 0 ; // ! Link subspec augmented by its origin
143168 LinkSubSpec_t subspec = 0 ; // ! subspec according to DataDistribution
144169 uint32_t nTimeFrames = 0 ; // !
@@ -244,8 +269,11 @@ class RawFileReader
244269
245270 void imposeFirstTF (uint32_t orbit, uint16_t bc);
246271 void setTFAutodetect (FirstTFDetection v) { mFirstTFAutodetect = v; }
272+ void setPreferCalculatedTFStart (bool v) { mPreferCalculatedTFStart = v; }
247273 FirstTFDetection getTFAutodetect () const { return mFirstTFAutodetect ; }
248274
275+ void setIROfSOX (const o2::InteractionRecord& ir);
276+
249277 static o2::header::DataOrigin getDataOrigin (const std::string& ors);
250278 static o2::header::DataDescription getDataDescription (const std::string& ors);
251279 static InputsMap parseInput (const std::string& confUri);
@@ -260,38 +288,36 @@ class RawFileReader
260288 static constexpr o2::header::DataOrigin DEFDataOrigin = o2::header::gDataOriginFLP ;
261289 static constexpr o2::header::DataDescription DEFDataDescription = o2::header::gDataDescriptionRawData ;
262290 static constexpr ReadoutCardType DEFCardType = CRU;
263-
264291 o2::header::DataOrigin mDefDataOrigin = DEFDataOrigin; // !
265292 o2::header::DataDescription mDefDataDescription = DEFDataDescription; // !
266293 ReadoutCardType mDefCardType = CRU; // !
267-
268- std::vector<std::string> mFileNames ; // ! input file names
269- std::vector<FILE*> mFiles ; // ! input file handlers
270- std::vector<std::unique_ptr<char []>> mFileBuffers ; // ! buffers for input files
271- std::vector<OrigDescCard> mDataSpecs ; // ! data origin and description for every input file + readout card type
294+ std::vector<std::string> mFileNames ; // ! input file names
295+ std::vector<FILE*> mFiles ; // ! input file handlers
296+ std::vector<std::unique_ptr<char []>> mFileBuffers ; // ! buffers for input files
297+ std::vector<OrigDescCard> mDataSpecs ; // ! data origin and description for every input file + readout card type
272298 bool mInitDone = false ;
273299 bool mEmpty = true ;
274- std::unordered_map<LinkSpec_t, int > mLinkEntries ; // ! mapping between RDH specs and link entry in the mLinksData
275- std::vector<LinkData> mLinksData ; // ! info on links data in the files
276- std::vector<int > mOrderedIDs ; // ! links entries ordered in Specs
277- uint32_t mMaxTFToRead = 0xffffffff ; // ! max TFs to process
278- uint32_t mNTimeFrames = 0 ; // ! total number of time frames
279- uint32_t mNextTF2Read = 0 ; // ! next TF to read
280- uint32_t mOrbitMin = 0xffffffff ; // ! lowest orbit seen by any link
281- uint32_t mOrbitMax = 0 ; // ! highest orbit seen by any link
282- size_t mBufferSize = 5 * 1024UL ; // ! size of the buffer for files reading
283- int mNominalSPageSize = 0x1 << 20 ; // ! expected super-page size in B
284- int mCurrentFileID = 0 ; // ! current file being processed
285- long int mPosInFile = 0 ; // ! current position in the file
286- bool mMultiLinkFile = false ; // ! was > than 1 link seen in the file?
287- bool mCacheData = false ; // ! cache data to block after 1st scan (may require excessive memory, use with care)
288- uint32_t mCheckErrors = 0 ; // ! mask for errors to check
300+ std::unordered_map<LinkSpec_t, int > mLinkEntries ; // ! mapping between RDH specs and link entry in the mLinksData
301+ std::vector<LinkData> mLinksData ; // ! info on links data in the files
302+ std::vector<int > mOrderedIDs ; // ! links entries ordered in Specs
303+ uint32_t mMaxTFToRead = 0xffffffff ; // ! max TFs to process
304+ uint32_t mNTimeFrames = 0 ; // ! total number of time frames
305+ uint32_t mNextTF2Read = 0 ; // ! next TF to read
306+ uint32_t mOrbitMin = 0xffffffff ; // ! lowest orbit seen by any link
307+ uint32_t mOrbitMax = 0 ; // ! highest orbit seen by any link
308+ size_t mBufferSize = 5 * 1024UL ; // ! size of the buffer for files reading
309+ int mNominalSPageSize = 0x1 << 20 ; // ! expected super-page size in B
310+ int mCurrentFileID = 0 ; // ! current file being processed
311+ long int mPosInFile = 0 ; // ! current position in the file
312+ bool mMultiLinkFile = false ; // ! was > than 1 link seen in the file?
313+ bool mCacheData = false ; // ! cache data to block after 1st scan (may require excessive memory, use with care)
314+ uint32_t mCheckErrors = 0 ; // ! mask for errors to check
289315 FirstTFDetection mFirstTFAutodetect = FirstTFDetection::Disabled; // !
316+ bool mPreferCalculatedTFStart = false ; // ! prefer TFstart calculated via HBFUtils
290317 int mVerbosity = 0 ; // !
291318 ClassDefNV (RawFileReader, 1 );
292319};
293320
294-
295321} // namespace raw
296322} // namespace o2
297323
0 commit comments