79#include "TRestRawFeminosRootToSignalProcess.h"
85TRestRawFeminosRootToSignalProcess::TRestRawFeminosRootToSignalProcess() {
Initialize(); }
87TRestRawFeminosRootToSignalProcess::TRestRawFeminosRootToSignalProcess(
const char* configFilename) {
91TRestRawFeminosRootToSignalProcess::~TRestRawFeminosRootToSignalProcess() {}
103 const auto inputFilename =
fRunInfo->GetInputFileName(0);
106 if (inputFilename.substr(inputFilename.size() - 5) !=
".root") {
107 cerr <<
"TRestRawFeminosRootToSignalProcess::InitProcess: Input file is not a root file" << endl;
111 fInputFile = TFile::Open(inputFilename.c_str(),
"READ");
113 cerr <<
"TRestRawFeminosRootToSignalProcess::InitProcess: Error opening input file" << endl;
118 fInputRunTree = fInputFile->Get<TTree>(
"run");
119 fInputEventTree = fInputFile->Get<TTree>(
"events");
121 if (!fInputRunTree || !fInputEventTree) {
122 cerr <<
"TRestRawFeminosRootToSignalProcess::InitProcess: Error opening input trees" << endl;
126 if (fUseFeminosDaqRunInfo) {
127 ULong64_t startTimeStampMilliseconds = 0;
128 ULong64_t runNumber = 0;
129 std::string* runTag =
new std::string();
130 std::string* runDescription =
new std::string();
131 fInputRunTree->SetBranchAddress(
"timestamp", &startTimeStampMilliseconds);
132 fInputRunTree->SetBranchAddress(
"number", &runNumber);
133 fInputRunTree->SetBranchAddress(
"tag", &runTag);
134 fInputRunTree->SetBranchAddress(
"comments", &runDescription);
150 fInputRunTree->GetEntry(0);
153 Double_t startTimeStamp = startTimeStampMilliseconds / 1000.0;
154 fRunInfo->SetStartTimeStamp(startTimeStamp);
157 if (*runTag ==
"\n") {
160 if (*runDescription ==
"\n") {
161 runDescription->clear();
164 fRunInfo->SetRunDescription(*runDescription);
165 fRunInfo->SetFeminosDaqTotalEvents(fInputEventTree->GetEntries());
168 fInputEventTree->SetBranchAddress(
"timestamp", &fInputEventTreeTimestamp);
169 fInputEventTree->SetBranchAddress(
"signal_ids", &fInputEventTreeSignalIds);
170 fInputEventTree->SetBranchAddress(
"signal_values", &fInputEventTreeSignalValues);
176 fInputEventTree->GetEntry(fInputTreeEntry);
178 fSignalEvent->SetID(fInputTreeEntry);
181 fSignalEvent->
SetTime(fInputEventTreeTimestamp / 1000, fInputEventTreeTimestamp % 1000 * 1000000);
185 if (!fUseFeminosDaqRunInfo && fInputEventTreeTimestamp < fStartTimestamp) {
186 fStartTimestamp = fInputEventTreeTimestamp;
189 if (fInputEventTreeTimestamp > fEndTimestamp) {
190 fEndTimestamp = fInputEventTreeTimestamp;
193 for (
size_t i = 0; i < fInputEventTreeSignalIds->size(); i++) {
197 const auto id = fInputEventTreeSignalIds->at(i);
200 for (
int j = 0; j < 512; j++) {
201 signal.AddPoint(
short(fInputEventTreeSignalValues->at(i * 512 + j)));
204 fSignalEvent->AddSignal(signal);
207 fInputTreeEntry += 1;
209 if (fInputTreeEntry >= fInputEventTree->GetEntries()) {
218 if (!fUseFeminosDaqRunInfo) {
219 fRunInfo->SetStartTimeStamp(fStartTimestamp / 1000.0);
222 fRunInfo->SetEndTimeStamp(fEndTimestamp / 1000.0);
bool fIsExternal
It defines if the process reads event data from an external source.
TRestRun * fRunInfo
< Pointer to TRestRun object where to find metadata.
A base class for any REST event.
void SetTime(Double_t time)
void InitProcess() override
To be executed at the beginning of the run (outside event loop)
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
Process one event.
void EndProcess() override
To be executed at the end of the run (outside event loop)
void Initialize() override
Making default settings.
An event container for time rawdata signals with fixed length.
It defines a Short_t array with a physical parameter that evolves in time using a fixed time bin.