59 #include "TRestRawToSignalProcess.h"
65 #include "TTimeStamp.h"
69 TRestRawToSignalProcess::TRestRawToSignalProcess() { Initialize(); }
71 TRestRawToSignalProcess::TRestRawToSignalProcess(
const char* configFilename) {
74 if (LoadConfigFromFile(configFilename)) LoadDefaultConfig();
77 TRestRawToSignalProcess::~TRestRawToSignalProcess() {
82 void TRestRawToSignalProcess::LoadConfig(
const string& configFilename,
const string& name) {
83 if (LoadConfigFromFile(configFilename, name) == -1) {
84 cout <<
"Loading default" << endl;
90 SetSectionName(this->ClassName());
91 SetLibraryVersion(LIBRARY_VERSION);
96 fInputBinFile =
nullptr;
100 fSingleThreadOnly =
true;
102 fgKeepFileOpen =
true;
105 totalBytesReaded = 0;
109 fElectronicsType = GetParameter(
"electronics");
115 if (fElectronicsType ==
"SingleFeminos" || fElectronicsType ==
"TCMFeminos" || fElectronicsType ==
"TDS")
118 if (fElectronicsType ==
"FEUDream") {
119 fgKeepFileOpen =
false;
123 if (GetVerboseLevel() >= TRestStringOutput::REST_Verbose_Level::REST_Warning) {
124 cout <<
"REST WARNING: TRestRawToSignalProcess::InitFromConfigFile" << endl;
125 cout <<
"Electronic type " << fElectronicsType <<
" not found " << endl;
132 void TRestRawToSignalProcess::LoadDefaultConfig() {
133 fElectronicsType =
"SingleFeminos";
137 Bool_t TRestRawToSignalProcess::OpenInputFiles(
const vector<string>& files) {
140 fInputFileNames.clear();
142 totalBytesReaded = 0;
144 for (
const auto& file : files) {
149 fInputBinFile = fInputFiles[0];
151 RESTError <<
"No input file is opened, in process: " << this->ClassName() <<
"!" << RESTendl;
155 RESTDebug << this->GetName() <<
" : opened " << nFiles <<
" files" << RESTendl;
159 Bool_t TRestRawToSignalProcess::AddInputFile(
const string& file) {
160 for (
auto& inputFileName : fInputFileNames) {
161 if (inputFileName == file) {
162 RESTError <<
"file: \"" << file <<
"\" already added!" << RESTendl;
167 FILE* f = fopen(file.c_str(),
"rb");
170 RESTWarning <<
"REST WARNING. Input file for " << this->ClassName() <<
" does not exist!" << RESTendl;
171 RESTWarning <<
"File : " << file << RESTendl;
175 fInputFiles.push_back(f);
176 fInputFileNames.push_back(file);
179 stat(file.c_str(), &statbuf);
180 totalBytes += statbuf.st_size;
187 Bool_t TRestRawToSignalProcess::ResetEntry() {
188 for (
auto f : fInputFiles) {
190 if (fseek(f, 0, 0) != 0)
return false;
201 RESTMetadata <<
" " << RESTendl;
202 RESTMetadata <<
" ==================================== " << RESTendl;
203 RESTMetadata <<
"DAQ : " << GetTitle() << RESTendl;
204 RESTMetadata <<
"Electronics type : " << fElectronicsType << RESTendl;
205 RESTMetadata <<
"Minimum number of points : " << fMinPoints << RESTendl;
206 RESTMetadata <<
"All raw files open at beginning : " << fgKeepFileOpen << RESTendl;
207 RESTMetadata <<
" ==================================== " << RESTendl;
209 RESTMetadata <<
" " << RESTendl;
214 Bool_t TRestRawToSignalProcess::GoToNextFile() {
216 if (iCurFile < nFiles) {
217 if (fgKeepFileOpen) {
218 fInputBinFile = fInputFiles[iCurFile];
220 fclose(fInputBinFile);
221 fInputBinFile = fopen(fInputFileNames[iCurFile].c_str(),
"rb");
223 RESTInfo <<
"GoToNextFile(): Going to the next raw input file number " << iCurFile <<
" over "
224 << nFiles << RESTendl;
225 RESTInfo <<
" Reading file name: " << fInputFileNames[iCurFile] << RESTendl;
228 RESTInfo <<
"GoToNextFile(): No more file to read" << RESTendl;
An event container for time rawdata signals with fixed length.
A base class for any process reading a binary external file as input to REST.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void Initialize() override
Making default settings.
virtual void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
Int_t StringToInteger(std::string in)
Gets an integer from a string.