REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
TRestEventTimeSelectionProcess.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 RestProcess_TRestEventTimeSelectionProcess
24#define RestProcess_TRestEventTimeSelectionProcess
25
26#include <TRestEventProcess.h>
27
28#include <iostream>
29
31 private:
32 TRestEvent* fEvent;
33 std::string fFileWithTimes;
34 Bool_t fIsActiveTime;
35 Char_t fDelimiter;
36 Long_t fTimeOffsetInSeconds;
37 Long_t fTimeStartMarginInSeconds;
38 Long_t fTimeEndMarginInSeconds;
39 std::vector<std::pair<std::string, std::string>> fStartEndTimes;
40
42
44 Int_t fNEventsSelected;
45 Double_t fTotalTimeInSeconds;
46
47 void Initialize() override;
48
49 protected:
50 public:
51 RESTValue GetInputEvent() const override { return fEvent; }
52 RESTValue GetOutputEvent() const override { return fEvent; }
53
54 void InitProcess() override;
55 TRestEvent* ProcessEvent(TRestEvent* inputEvent) override;
56 void EndProcess() override;
57
58 void PrintMetadata() override;
59
60 // Constructor
62 // Destructor
64
65 const char* GetProcessName() const override { return "EventTimeSelectionProcess"; }
66
67 std::string GetFileWithTimes() const { return fFileWithTimes; }
68
69 Bool_t GetIsActiveTime() const { return fIsActiveTime; }
70 Char_t GetDelimiter() const { return fDelimiter; }
71
72 std::vector<std::pair<std::string, std::string>> GetStartEndTimes() const { return fStartEndTimes; }
73 std::string GetTimeStampCut(std::string timeStampObsName = "timeStamp", Bool_t useOffset = true,
74 Bool_t useMargins = true, Int_t nTimes = -1);
75 Int_t GetNEventsRejected() const { return fNEventsRejected; }
76 Int_t GetNEventsSelected() const { return fNEventsSelected; }
77 Double_t GetTotalTimeInSeconds() const { return fTotalTimeInSeconds; }
78 Long_t GetTimeOffsetInSeconds() const { return fTimeOffsetInSeconds; }
79 Long_t GetTimeStartMarginInSeconds() const { return fTimeStartMarginInSeconds; }
80 Long_t GetTimeEndMarginInSeconds() const { return fTimeEndMarginInSeconds; }
81
83 static std::vector<std::pair<std::string, std::string>> ReadFileWithTimes(std::string fileWithTimes,
84 Char_t delimiter = ',');
85
86 void SetAsActiveTime() { fIsActiveTime = true; }
87 void SetAsDeadTime() { fIsActiveTime = false; }
88 void SetFileWithTimes(const std::string& fileWithTimes) { fFileWithTimes = fileWithTimes; }
89 void SetIsActiveTime(Bool_t isActiveTime) { fIsActiveTime = isActiveTime; }
90 void SetDelimiter(Char_t delimiter) { fDelimiter = delimiter; }
91 void SetStartEndTimes(const std::vector<std::pair<std::string, std::string>>& startEndTimes) {
92 fStartEndTimes = startEndTimes;
93 }
94 void SetTimeOffsetInSeconds(Long_t timeOffsetInSeconds) { fTimeOffsetInSeconds = timeOffsetInSeconds; }
95 void SetTimeStartMarginInSeconds(Long_t timeStartMarginInSeconds) {
96 fTimeStartMarginInSeconds = timeStartMarginInSeconds;
97 }
98 void SetTimeEndMarginInSeconds(Long_t timeEndMarginInSeconds) {
99 fTimeEndMarginInSeconds = timeEndMarginInSeconds;
100 }
101
102 ClassDefOverride(TRestEventTimeSelectionProcess, 1);
103};
104#endif
A base class for any REST event process.
RESTValue GetOutputEvent() const override
Get pointer to output event. Must be implemented in the derived class.
Double_t CalculateTotalTimeInSeconds()
Function to calculate the total time in seconds of all the time ranges (active or dead periods of tim...
void PrintMetadata() override
Prints on screen the process data members.
void EndProcess() override
Function to include required actions after all events have been processed.
Int_t fNEventsRejected
Information about the events processed.
TRestEvent * ProcessEvent(TRestEvent *inputEvent) override
The main processing event function.
void Initialize() override
Function to initialize input/output event members and define the section name.
std::string GetTimeStampCut(std::string timeStampObsName="timeStamp", Bool_t useOffset=true, Bool_t useMargins=true, Int_t nTimes=-1)
Function to get the cut string that reproduce the time selection done by this process (useful for TRe...
void InitProcess() override
Process initialization.
RESTValue GetInputEvent() const override
Get pointer to input event. Must be implemented in the derived class.
A base class for any REST event.
Definition TRestEvent.h:38