59#include "TRestRawToSignalProcess.h"
65#include "TTimeStamp.h"
69TRestRawToSignalProcess::TRestRawToSignalProcess() {
Initialize(); }
71TRestRawToSignalProcess::TRestRawToSignalProcess(
const char* configFilename) {
77TRestRawToSignalProcess::~TRestRawToSignalProcess() {
82void TRestRawToSignalProcess::LoadConfig(
const string& configFilename,
const string& name) {
84 cout <<
"Loading default" << endl;
96 fInputBinFile =
nullptr;
102 fgKeepFileOpen =
true;
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;
132void TRestRawToSignalProcess::LoadDefaultConfig() {
133 fElectronicsType =
"SingleFeminos";
137Bool_t TRestRawToSignalProcess::OpenInputFiles(
const vector<string>& files) {
140 fInputFileNames.clear();
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;
159Bool_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;
187Bool_t TRestRawToSignalProcess::ResetEntry() {
188 for (
auto f : fInputFiles) {
190 if (fseek(f, 0, 0) != 0)
return false;
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;
214Bool_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 "
225 RESTInfo <<
" Reading file name: " << fInputFileNames[iCurFile] <<
RESTendl;
228 RESTInfo <<
"GoToNextFile(): No more file to read" <<
RESTendl;
bool fIsExternal
It defines if the process reads event data from an external source.
void BeginPrintProcess()
[name, cut range]
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.
virtual void InitProcess() override
To be executed at the beginning of the run (outside event loop)
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
Int_t fShowSamples
true if need to open all raw files at the beginning
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.