Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion inc/TRestRawFemDAQToSignalProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class TRestRawFemDAQToSignalProcess : public TRestEventProcess {
Double_t fStartTimestamp = std::numeric_limits<double>::max(); //!
Double_t fEndTimestamp = 0; //!
Bool_t fUseFeminosDaqRunInfo = true; //<
Bool_t fSetRunStartEndFromEvents = false; //<

public:
RESTValue GetInputEvent() const override { return RESTValue((TRestEvent*)nullptr); }
Expand All @@ -64,7 +65,9 @@ class TRestRawFemDAQToSignalProcess : public TRestEventProcess {
inline void PrintMetadata() override {
BeginPrintProcess();
std::string useFemDaqRunInfoStr = fUseFeminosDaqRunInfo ? "true" : "false";
std::string setRunStartEndFromEventsStr = fSetRunStartEndFromEvents ? "true" : "false";
RESTMetadata << "Use fem-daq run information: " << useFemDaqRunInfoStr << RESTendl;
RESTMetadata << "Set run start/end times from events: " << setRunStartEndFromEventsStr << RESTendl;

EndPrintProcess();
}
Expand All @@ -76,7 +79,7 @@ class TRestRawFemDAQToSignalProcess : public TRestEventProcess {
~TRestRawFemDAQToSignalProcess();

ClassDefOverride(TRestRawFemDAQToSignalProcess,
0); // Template for a REST "event process" class inherited from
1); // Template for a REST "event process" class inherited from
// TRestEventProcess
};
#endif
39 changes: 23 additions & 16 deletions src/TRestRawFemDAQToSignalProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,19 @@
///
/// ### Parameters
/// - **fUseFeminosDaqRunInfo**: Flag to determine if Feminos DAQ run info is transferred
/// to the TRestRun object. If `true` (default), the run info such as start time,
/// to the TRestRun object. If `true` (default), the run info such as
/// run number, tag, and description are set from the FEMDAQ info (stored
/// in the .root file as a yaml dump). If `false`, this behavior is disabled and the
/// start time is set from the first processed event timestamp. *Note: if you are using
/// in the .root file as a yaml dump). *Note: if you are using
/// inputFormat in TRestRun to extract the run information (run number and tag usually),
/// be aware that this happens before TRestRawFemDAQToSignalProcess. The process,
/// with fUseFeminosDaqRunInfo set to true, will overwrite the run info so the final
/// values in the TRestRun will come from the .root file generated by feminos-daq,
/// not the filename.*
/// - **fSetRunStartEndFromEvents**: Flag to determine if the start and end timestamps
/// of the run are set from the event with the lowest and highest timestamp respectively.
/// If `false` (default), the start and end timestamps are set from the "startTime" and
/// "endTime" entries in the .root file generated by FemDaq acquisition program, which are
/// the times when the acquisition was started and stopped.
///
///
/// <hr>
Expand Down Expand Up @@ -118,12 +122,21 @@ void TRestRawFemDAQToSignalProcess::InitProcess() {
exit(1);
}

TObjString* tsObj = (TObjString*)fInputFile->Get("startTime");
TObjString* etObj = (TObjString*)fInputFile->Get("endTime");
if (tsObj) {
Double_t startTimestamp = std::stod(tsObj->GetString().Data());
fRunInfo->SetStartTimeStamp(startTimestamp);
}
if (etObj) {
Double_t endTimestamp = std::stod(etObj->GetString().Data());
fRunInfo->SetEndTimeStamp(endTimestamp);
}

#ifndef NO_YAML_CPP
if (fUseFeminosDaqRunInfo) {
TObjString* yamlConfigObj = (TObjString*)fInputFile->Get("RunConfigYAML");
TObjString* yamlfNameObj = (TObjString*)fInputFile->Get("yaml_fileName");
TObjString* tsObj = (TObjString*)fInputFile->Get("startTime");
TObjString* etObj = (TObjString*)fInputFile->Get("endTime");

if (yamlConfigObj) {
std::string yamlConfig = yamlConfigObj->GetString().Data();
Expand All @@ -143,14 +156,6 @@ void TRestRawFemDAQToSignalProcess::InitProcess() {
std::string fileName = yamlfNameObj->GetString().Data();
std::cout << "Config fileName: " << fileName << std::endl;
}

if (tsObj) {
fStartTimestamp = std::stod(tsObj->GetString().Data());
}

if (etObj) {
fEndTimestamp = std::stod(etObj->GetString().Data());
}
}
#else
fUseFeminosDaqRunInfo = false;
Expand All @@ -172,7 +177,7 @@ TRestEvent* TRestRawFemDAQToSignalProcess::ProcessEvent(TRestEvent* inputEvent)
// fTimestamp is in seconds
fSignalEvent->SetTime(fTimestamp);

// Check if start timestamp is lower than event timestamp
// get the first event timestamp
if (fTimestamp < fStartTimestamp) {
fStartTimestamp = fTimestamp;
}
Expand Down Expand Up @@ -205,6 +210,8 @@ TRestEvent* TRestRawFemDAQToSignalProcess::ProcessEvent(TRestEvent* inputEvent)
}

void TRestRawFemDAQToSignalProcess::EndProcess() {
fRunInfo->SetStartTimeStamp(fStartTimestamp);
fRunInfo->SetEndTimeStamp(fEndTimestamp);
if (fSetRunStartEndFromEvents) {
fRunInfo->SetStartTimeStamp(fStartTimestamp);
fRunInfo->SetEndTimeStamp(fEndTimestamp);
}
}
Loading