Project
Loading...
Searching...
No Matches
HmpidDecodeRawFile.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
18
19/* ------ HISTORY ---------
20*/
21#include <fairlogger/Logger.h> // for LOG
22#include "Framework/Logger.h"
23
25
26using namespace o2::hmpid;
27
31 : HmpidDecoder(numOfEquipments)
32{
33 fh = 0;
34}
35
41HmpidDecodeRawFile::HmpidDecodeRawFile(int* EqIds, int* CruIds, int* LinkIds, int numOfEquipments)
42 : HmpidDecoder(EqIds, CruIds, LinkIds, numOfEquipments)
43{
44 fh = 0;
45}
46
51
59bool HmpidDecodeRawFile::setUpStream(void* FileName, long Size)
60{
61 strcpy(mInputFile, (const char*)FileName);
62 // files section ----
63 if (!fileExists(mInputFile)) {
64 LOG(error) << "The input file " << mInputFile << " does not exist at this time.";
65 throw TH_FILENOTEXISTS;
66 }
67 // open the file
68 fh = fopen(mInputFile, "rb");
69 if (fh == 0) {
70 LOG(error) << "ERROR to open Input file ! [" << mInputFile << "]";
71 throw TH_OPENFILE;
72 }
73
74 mActualStreamPtr = 0; // sets the pointer to the Buffer
75 mEndStreamPtr = 0; //sets the End of buffer
77
78 return (true);
79}
80
91bool HmpidDecodeRawFile::getBlockFromStream(uint32_t** streamPtr, uint32_t Size)
92{
94 return (false);
95 int nr = fread(mFileBuffer, sizeof(int32_t), HEADERDIMENSION_W, fh);
96 if (nr != HEADERDIMENSION_W) {
97 throw TH_WRONGFILELEN;
98 }
99 Size = ((mFileBuffer[2] & 0x0000FFFF) / sizeof(int32_t)) - HEADERDIMENSION_W;
100 nr = fread(mFileBuffer + HEADERDIMENSION_W, sizeof(int32_t), Size, fh);
101 LOG(debug) << " getBlockFromStream read " << nr << " of " << Size + HEADERDIMENSION_W << " words !";
102 if (nr != Size) {
103 throw TH_WRONGFILELEN;
104 }
105 *streamPtr = mFileBuffer;
106 mStartStreamPtr = mFileBuffer;
107 mActualStreamPtr = mFileBuffer;
108 mEndStreamPtr = mFileBuffer + Size;
109 return (true);
110}
111
115bool HmpidDecodeRawFile::getHeaderFromStream(uint32_t** streamPtr)
116{
117 bool flag = getBlockFromStream(streamPtr, RAWBLOCKDIMENSION_W); // reads the 8k block
118 mActualStreamPtr += HEADERDIMENSION_W; // Move forward for the first word
119 return (flag);
120}
121
125bool HmpidDecodeRawFile::getWordFromStream(uint32_t* word)
126{
127 *word = *mActualStreamPtr;
129 return (true);
130}
131
141void HmpidDecodeRawFile::setPad(HmpidEquipment* eq, int col, int dil, int ch, uint16_t charge)
142{
143 eq->setPad(col, dil, ch, charge);
144 return;
145}
146
150int HmpidDecodeRawFile::fileExists(char* filewithpath)
151{
152 if (access(filewithpath, F_OK) != -1) {
153 return (true);
154 } else {
155 return (false);
156 }
157}
int16_t charge
Definition RawEventData.h:5
Derived Class for decoding Raw Data File stream.
#define MAXRAWFILEBUFFER
#define RAWBLOCKDIMENSION_W
#define HEADERDIMENSION_W
uint32_t col
Definition RawData.h:4
std::ostringstream debug
HMPID Digit declaration.
Definition Digit.h:36
HmpidDecodeRawFile(int *EqIds, int *CruIds, int *LinkIds, int numOfEquipments)
bool setUpStream(void *InpuFileName, long Size)
void setPad(int col, int dil, int cha, uint16_t charge)
GLuint GLint GLboolean GLint GLenum access
Definition glcorearb.h:2196
const int TH_FILENOTEXISTS
const int TH_WRONGFILELEN
const int TH_OPENFILE
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"