Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 14, 2025
1 parent 6ff8b6a commit 66f5fc4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
14 changes: 10 additions & 4 deletions source/framework/analysis/inc/TRestEventTimeSelectionProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class TRestEventTimeSelectionProcess : public TRestEventProcess {
Long_t fTimeOffsetInSeconds;
Long_t fTimeStartMarginInSeconds;
Long_t fTimeEndMarginInSeconds;
std::vector<std::pair<std::string,std::string>> fStartEndTimes;
std::vector<std::pair<std::string, std::string>> fStartEndTimes;

/// Information about the events processed

Expand Down Expand Up @@ -84,10 +84,16 @@ class TRestEventTimeSelectionProcess : public TRestEventProcess {
void SetFileWithTimes(const std::string& fileWithTimes) { fFileWithTimes = fileWithTimes; }
void SetIsActiveTime(Bool_t isActiveTime) { fIsActiveTime = isActiveTime; }
void SetDelimiter(Char_t delimiter) { fDelimiter = delimiter; }
void SetStartEndTimes(const std::vector<std::pair<std::string,std::string>>& startEndTimes) { fStartEndTimes = startEndTimes; }
void SetStartEndTimes(const std::vector<std::pair<std::string, std::string>>& startEndTimes) {
fStartEndTimes = startEndTimes;
}
void SetTimeOffsetInSeconds(Long_t timeOffsetInSeconds) { fTimeOffsetInSeconds = timeOffsetInSeconds; }
void SetTimeStartMarginInSeconds(Long_t timeStartMarginInSeconds) { fTimeStartMarginInSeconds = timeStartMarginInSeconds; }
void SetTimeEndMarginInSeconds(Long_t timeEndMarginInSeconds) { fTimeEndMarginInSeconds = timeEndMarginInSeconds; }
void SetTimeStartMarginInSeconds(Long_t timeStartMarginInSeconds) {
fTimeStartMarginInSeconds = timeStartMarginInSeconds;
}
void SetTimeEndMarginInSeconds(Long_t timeEndMarginInSeconds) {
fTimeEndMarginInSeconds = timeEndMarginInSeconds;
}

ClassDefOverride(TRestEventTimeSelectionProcess, 1);
};
Expand Down
13 changes: 8 additions & 5 deletions source/framework/analysis/src/TRestEventTimeSelectionProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void TRestEventTimeSelectionProcess::InitProcess() {
fNEventsSelected = 0;
}

Double_t TRestEventTimeSelectionProcess::CalculateTotalTimeInSeconds(){
Double_t TRestEventTimeSelectionProcess::CalculateTotalTimeInSeconds() {
Double_t totalTime = 0;
for (auto id : fStartEndTimes) {
TTimeStamp startTime = TTimeStamp(StringToTimeStamp(id.first), 0);
Expand All @@ -161,7 +161,8 @@ Double_t TRestEventTimeSelectionProcess::CalculateTotalTimeInSeconds(){
endTime.Add(TTimeStamp(-fTimeEndMarginInSeconds));
auto timeDiff = endTime.AsDouble() - startTime.AsDouble();
if (timeDiff < 0) {
RESTDebug << "End time is before start time in time range: " << id.first << " to " << id.second << RESTendl;
RESTDebug << "End time is before start time in time range: " << id.first << " to " << id.second
<< RESTendl;
continue;
}
totalTime += endTime.AsDouble() - startTime.AsDouble();
Expand Down Expand Up @@ -250,9 +251,11 @@ std::string TRestEventTimeSelectionProcess::GetTimeStampCut(std::string timeStam
// Reduce the time by the margin in both sides
startTime += fTimeStartMarginInSeconds;
endTime -= fTimeEndMarginInSeconds;
if (!timeCut.empty()){
if (fIsActiveTime) timeCut += " || ";
else timeCut += " && ";
if (!timeCut.empty()) {
if (fIsActiveTime)
timeCut += " || ";
else
timeCut += " && ";
}
if (!fIsActiveTime) timeCut += "!";
timeCut += "(";
Expand Down

0 comments on commit 66f5fc4

Please sign in to comment.