REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestRawToSignalProcess.h
1 /*************************************************************************
2  * This file is part of the REST software framework. *
3  * *
4  * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5  * For more information see http://gifna.unizar.es/trex *
6  * *
7  * REST is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * REST is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have a copy of the GNU General Public License along with *
18  * REST in $REST_PATH/LICENSE. *
19  * If not, see http://www.gnu.org/licenses/. *
20  * For the list of contributors see $REST_PATH/CREDITS. *
21  *************************************************************************/
22 
23 #ifndef RestCore_TRestRawToSignalProcess
24 #define RestCore_TRestRawToSignalProcess
25 
26 #include <TRestEventProcess.h>
27 #include <TRestRawSignalEvent.h>
28 
31  protected:
32  void InitFromConfigFile() override;
33  unsigned int payload;
34  unsigned int frameBits;
35  std::string fElectronicsType; // AFTER or AGET
36  Int_t fMinPoints;
37 
38  Double_t tStart;
39  Long64_t totalBytesReaded;
40  Long64_t totalBytes;
41 
42  TRestRawSignalEvent* fSignalEvent = nullptr;
43 #ifndef __CINT__
44  FILE* fInputBinFile;
45 
46  Int_t fRunOrigin;
47  Int_t fSubRunOrigin;
48 
49  Int_t nFiles;
50  Int_t iCurFile;
51  std::vector<FILE*> fInputFiles;
52  std::vector<std::string> fInputFileNames;
53  bool fgKeepFileOpen;
54 
55  Int_t fShowSamples;
56 #endif
57 
58  void LoadDefaultConfig();
59 
60  public:
61  RESTValue GetInputEvent() const override { return RESTValue((TRestEvent*)nullptr); }
62  RESTValue GetOutputEvent() const override { return fSignalEvent; }
63 
64  virtual void InitProcess() override {
65  fRunOrigin = fRunInfo->GetRunNumber();
66  fSubRunOrigin = fRunInfo->GetSubRunNumber();
67  }
68 
69  virtual void PrintMetadata() override;
70  void Initialize() override;
71  TRestMetadata* GetProcessMetadata() const { return nullptr; }
72 
73  inline void SetRunOrigin(Int_t runOrigin) { fRunOrigin = runOrigin; }
74  inline void SetSubRunOrigin(Int_t subRunOrigin) { fSubRunOrigin = subRunOrigin; }
75 
76  void LoadConfig(const std::string& configFilename, const std::string& name = "");
77 
78  Bool_t OpenInputFiles(const std::vector<std::string>& files) override;
79  virtual Bool_t AddInputFile(const std::string& file) override;
80 
81  Bool_t ResetEntry() override;
82 
83  Long64_t GetTotalBytesRead() const override { return totalBytesReaded; }
84  Long64_t GetTotalBytes() const override { return totalBytes; }
85  virtual std::string GetElectronicsType() const { return fElectronicsType; }
86 
87  Bool_t GoToNextFile();
88 
89  // Constructor
91  TRestRawToSignalProcess(const char* configFilename);
92  // Destructor
94 
95  ClassDefOverride(TRestRawToSignalProcess, 1);
96 };
97 #endif
A base class for any REST event process.
TRestRun * fRunInfo
< Pointer to TRestRun object where to find metadata.
A base class for any REST event.
Definition: TRestEvent.h:38
A base class for any REST metadata class.
Definition: TRestMetadata.h:74
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.
Long64_t GetTotalBytes() const override
RESTValue GetOutputEvent() const override
Get pointer to output event. Must be implemented in the derived class.
Int_t fShowSamples
true if need to open all raw files at the beginning
RESTValue GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
void Initialize() override
Making default settings.
Long64_t GetTotalBytesRead() const override
Interface to external file reading, get the read bytes. To be implemented in external processes.
virtual void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.