REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
TRestEventTimeSelectionProcess Class Reference

Detailed Description

The TRestEventTimeSelectionProcess allows processing of events that are within a certain time range. The time ranges are read from a file that contains the start and end times of the periods. The file should have the following format (it can have more columns separated by the same delimiter, but the first two columns should be the start and end times and all the other columns will be ignored):

# This is a comment
# Start time,End time
2021-01-01 00:00:00,2021-01-01 01:00:00
2021-01-01 02:00:00,2021-01-01 03:00:00
2021-01-01 04:00:00,2021-01-01 05:00:00

The default delimiter is a comma, but it can be changed by setting the delimiter parameter (single character only). The time format is given by the accepted formats of the StringToTimeStamp function.

The time ranges can be active or dead periods of time. If the time ranges are active periods of time, the events that are within the time ranges will be selected. If the time ranges are dead periods of time, the events that are outside the time ranges will be selected. Set the isActiveTime parameter to true to select the events within the time ranges (they represent active periods of time) or to false to select the events outside the time ranges (they represent dead periods of time).

The number of events selected, rejected and the total time selected are stored in the metadata members. The total time selected is calculated as the sum of the time of all the time ranges, so it represents the total active time in the case of active periods of time, or the total dead time in the case of dead periods of time.

Parameters

Observables

The process does not produce event observables but it keeps track of the number of events selected and rejected and the total time of the time ranges in the metadata members:

Examples

Examples for rml files:

<addProcess type="TRestEventTimeSelectionProcess" name="timeSel" value="ON" verboseLevel="info">
<parameter name="isActiveTime" value="true" /> <!-- default is true-->
<parameter name="fileWithTimes" value="/path/to/fileWithTimes.txt" />
<parameter name="timeOffsetInSeconds" value="-58" /> <!-- default is 0 -->
<parameter name="timeStartMarginInSeconds" value="5" /> <!-- default is 0 -->
<parameter name="timeEndMarginInSeconds" value="5" /> <!-- default is 0 -->
</addProcess>

Warning
** REST is under continuous development.** This documentation is offered to you by the REST community. Your HELP is needed to keep this code up to date. Your feedback will be worth to support this software, please report any problems/suggestions you may find while using it at The REST Framework forum. You are welcome to contribute fixing typos, updating information or adding/proposing new contributions. See also our Contribution Guide.

RESTsoft - Software for Rare Event Searches with TPCs

History of developments: 2025-Jan - First version of the code Alvaro Ezquerro

Author
Alvaro Ezquerro

Definition at line 30 of file TRestEventTimeSelectionProcess.h.

Inheritance diagram for TRestEventTimeSelectionProcess:
TRestEventProcess TRestMetadata

Public Member Functions

Double_t CalculateTotalTimeInSeconds ()
 Function to calculate the total time in seconds of all the time ranges (active or dead periods of time). It takes into account the time offset, and both the start and end margins.
 
 ClassDefOverride (TRestEventTimeSelectionProcess, 1)
 
void EndProcess () override
 Function to include required actions after all events have been processed.
 
Char_t GetDelimiter () const
 
std::string GetFileWithTimes () const
 
RESTValue GetInputEvent () const override
 Get pointer to input event. Must be implemented in the derived class.
 
Bool_t GetIsActiveTime () const
 
Int_t GetNEventsRejected () const
 
Int_t GetNEventsSelected () const
 
RESTValue GetOutputEvent () const override
 Get pointer to output event. Must be implemented in the derived class.
 
const char * GetProcessName () const override
 
std::vector< std::pair< std::string, std::string > > GetStartEndTimes () const
 
Long_t GetTimeEndMarginInSeconds () const
 
Long_t GetTimeOffsetInSeconds () const
 
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 TRestDataSet::MakeCut() for example).
 
Long_t GetTimeStartMarginInSeconds () const
 
Double_t GetTotalTimeInSeconds () const
 
void InitProcess () override
 Process initialization.
 
void PrintMetadata () override
 Prints on screen the process data members.
 
TRestEventProcessEvent (TRestEvent *inputEvent) override
 The main processing event function.
 
void SetAsActiveTime ()
 
void SetAsDeadTime ()
 
void SetDelimiter (Char_t delimiter)
 
void SetFileWithTimes (const std::string &fileWithTimes)
 
void SetIsActiveTime (Bool_t isActiveTime)
 
void SetStartEndTimes (const std::vector< std::pair< std::string, std::string > > &startEndTimes)
 
void SetTimeEndMarginInSeconds (Long_t timeEndMarginInSeconds)
 
void SetTimeOffsetInSeconds (Long_t timeOffsetInSeconds)
 
void SetTimeStartMarginInSeconds (Long_t timeStartMarginInSeconds)
 
 TRestEventTimeSelectionProcess ()
 Default constructor.
 
- Public Member Functions inherited from TRestEventProcess
virtual Bool_t AddInputFile (const std::string &file)
 
bool ApplyCut ()
 
virtual void BeginOfEventProcess (TRestEvent *inputEvent=nullptr)
 Begin of event process, preparation work. Called right before ProcessEvent()
 
 ClassDefOverride (TRestEventProcess, 3)
 
virtual void EndOfEventProcess (TRestEvent *inputEvent=nullptr)
 End of event process. Nothing to do. Called directly after ProcessEvent()
 
TRestAnalysisTreeGetAnalysisTree () const
 Return the local analysis tree (dummy)
 
TCanvas * GetCanvas () const
 Get canvas.
 
TRestAnalysisTreeGetFullAnalysisTree ()
 
std::vector< std::string > GetListOfAddedObservables ()
 
TRestRunGetRunInfo () const
 Return the pointer of the hosting TRestRun object.
 
virtual Long64_t GetTotalBytes () const
 
virtual Long64_t GetTotalBytesRead () const
 Interface to external file reading, get the read bytes. To be implemented in external processes.
 
virtual void InitFromConfigFile () override
 To make settings from rml file. This method must be implemented in the derived class.
 
Bool_t isExternal () const
 Return whether this process is external process.
 
Int_t LoadSectionMetadata () override
 This method does some preparation of xml section.
 
virtual void NotifyAnalysisTreeReset ()
 In case the analysis tree is reset(switched to new file), some process needs to have action.
 
virtual Bool_t OpenInputFiles (const std::vector< std::string > &files)
 
std::vector< std::string > ReadObservables ()
 
void RegisterAllObservables (Bool_t value=true)
 
virtual Bool_t ResetEntry ()
 
void SetAnalysisTree (TRestAnalysisTree *tree)
 Set analysis tree of this process, then add observables to it.
 
void SetCanvasSize (Int_t x, Int_t y)
 Set canvas size.
 
void SetFriendProcess (TRestEventProcess *p)
 Add friendly process to this process.
 
void SetObservableValidation (bool validate)
 
void SetParallelProcess (TRestEventProcess *p)
 Add parallel process to this process.
 
void SetRunInfo (TRestRun *r)
 Set TRestRun for this process.
 
Bool_t singleThreadOnly () const
 Return whether this process is single std::thread only.
 
 TRestEventProcess ()
 
 ~TRestEventProcess ()
 

Static Public Member Functions

static std::vector< std::pair< std::string, std::string > > ReadFileWithTimes (std::string fileWithTimes, Char_t delimiter=',')
 

Private Member Functions

void Initialize () override
 Function to initialize input/output event members and define the section name.
 

Private Attributes

Char_t fDelimiter
 
TRestEventfEvent
 
std::string fFileWithTimes
 
Bool_t fIsActiveTime
 
Int_t fNEventsRejected
 Information about the events processed.
 
Int_t fNEventsSelected
 
std::vector< std::pair< std::string, std::string > > fStartEndTimes
 
Long_t fTimeEndMarginInSeconds
 
Long_t fTimeOffsetInSeconds
 
Long_t fTimeStartMarginInSeconds
 
Double_t fTotalTimeInSeconds
 

Additional Inherited Members

- Protected Types inherited from TRestEventProcess
enum  REST_Process_Output { No_Output , Observable , Internal_Var , Full_Output }
 
- Protected Member Functions inherited from TRestEventProcess
void BeginPrintProcess ()
 [name, cut range]
 
void CreateCanvas ()
 Create the canvas.
 
void EndPrintProcess ()
 
TRestEventProcessGetFriend (const std::string &nameOrType)
 
TRestEventProcessGetFriendLive (const std::string &nameOrType)
 
template<class T >
T * GetMetadata ()
 Get a metadata object from the host TRestRun.
 
TRestMetadataGetMetadata (const std::string &nameOrType)
 
size_t GetNumberOfParallelProcesses () const
 
template<class T >
GetObservableValue (const std::string &name)
 
TRestEventProcessGetParallel (int i)
 
template<class T >
std::vector< T > GetParallelDataMembers (T *member_of_process)
 Get a list of data members from parallel processes which is same to this process's certain data member.
 
template<class T >
void SetObservableValue (const std::string &name, const T &value)
 Set observable value for AnalysisTree.
 
- Protected Attributes inherited from TRestEventProcess
TRestAnalysisTreefAnalysisTree = nullptr
 
TCanvas * fCanvas = nullptr
 < Canvas for some viewer event
 
TVector2 fCanvasSize
 Canvas size.
 
std::vector< std::pair< std::string, TVector2 > > fCuts
 Stores cut definitions. Any listed observables should be in the range.
 
bool fDynamicObs = false
 It defines whether to use added observables only or all the observables appear in the code.
 
bool fIsExternal = false
 It defines if the process reads event data from an external source.
 
std::map< std::string, int > fObservablesDefined
 Stores the list of all the appeared process observables in the code.
 
std::map< std::string, int > fObservablesUpdated
 Stores the list of process observables updated when processing this event.
 
bool fReadOnly = false
 not used, keep for compatibility
 
TRestRunfRunInfo = nullptr
 < Pointer to TRestRun object where to find metadata.
 
bool fSingleThreadOnly = false
 
bool fValidateObservables = false
 It defines if observable names should be added to the validation list.
 

Constructor & Destructor Documentation

◆ TRestEventTimeSelectionProcess()

TRestEventTimeSelectionProcess::TRestEventTimeSelectionProcess ( )

Default constructor.

Definition at line 118 of file TRestEventTimeSelectionProcess.cxx.

◆ ~TRestEventTimeSelectionProcess()

TRestEventTimeSelectionProcess::~TRestEventTimeSelectionProcess ( )
inline

Definition at line 63 of file TRestEventTimeSelectionProcess.h.

Member Function Documentation

◆ CalculateTotalTimeInSeconds()

Double_t TRestEventTimeSelectionProcess::CalculateTotalTimeInSeconds ( )

Function to calculate the total time in seconds of all the time ranges (active or dead periods of time). It takes into account the time offset, and both the start and end margins.

Definition at line 186 of file TRestEventTimeSelectionProcess.cxx.

◆ EndProcess()

void TRestEventTimeSelectionProcess::EndProcess ( )
overridevirtual

Function to include required actions after all events have been processed.

Reimplemented from TRestEventProcess.

Definition at line 250 of file TRestEventTimeSelectionProcess.cxx.

◆ GetDelimiter()

Char_t TRestEventTimeSelectionProcess::GetDelimiter ( ) const
inline

Definition at line 70 of file TRestEventTimeSelectionProcess.h.

◆ GetFileWithTimes()

std::string TRestEventTimeSelectionProcess::GetFileWithTimes ( ) const
inline

Definition at line 67 of file TRestEventTimeSelectionProcess.h.

◆ GetInputEvent()

RESTValue TRestEventTimeSelectionProcess::GetInputEvent ( ) const
inlineoverridevirtual

Get pointer to input event. Must be implemented in the derived class.

Implements TRestEventProcess.

Definition at line 51 of file TRestEventTimeSelectionProcess.h.

◆ GetIsActiveTime()

Bool_t TRestEventTimeSelectionProcess::GetIsActiveTime ( ) const
inline

Definition at line 69 of file TRestEventTimeSelectionProcess.h.

◆ GetNEventsRejected()

Int_t TRestEventTimeSelectionProcess::GetNEventsRejected ( ) const
inline

Definition at line 75 of file TRestEventTimeSelectionProcess.h.

◆ GetNEventsSelected()

Int_t TRestEventTimeSelectionProcess::GetNEventsSelected ( ) const
inline

Definition at line 76 of file TRestEventTimeSelectionProcess.h.

◆ GetOutputEvent()

RESTValue TRestEventTimeSelectionProcess::GetOutputEvent ( ) const
inlineoverridevirtual

Get pointer to output event. Must be implemented in the derived class.

Implements TRestEventProcess.

Definition at line 52 of file TRestEventTimeSelectionProcess.h.

◆ GetProcessName()

const char * TRestEventTimeSelectionProcess::GetProcessName ( ) const
inlineoverridevirtual

Implements TRestEventProcess.

Definition at line 65 of file TRestEventTimeSelectionProcess.h.

◆ GetStartEndTimes()

std::vector< std::pair< std::string, std::string > > TRestEventTimeSelectionProcess::GetStartEndTimes ( ) const
inline

Definition at line 72 of file TRestEventTimeSelectionProcess.h.

◆ GetTimeEndMarginInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeEndMarginInSeconds ( ) const
inline

Definition at line 80 of file TRestEventTimeSelectionProcess.h.

◆ GetTimeOffsetInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeOffsetInSeconds ( ) const
inline

Definition at line 78 of file TRestEventTimeSelectionProcess.h.

◆ GetTimeStampCut()

std::string TRestEventTimeSelectionProcess::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 TRestDataSet::MakeCut() for example).

Note
The cut string can be really long if there are many time ranges and this may cause the following error 'Error in <TTreeFormula::Compile>: Too many operators !' when trying to use the cut in TTree->Draw(). In such case, use
ROOT::v5::TFormula::SetMaxima(10000) // or any other big enough number
to increase the maximum number of operators allowed in a formula.

Definition at line 266 of file TRestEventTimeSelectionProcess.cxx.

◆ GetTimeStartMarginInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeStartMarginInSeconds ( ) const
inline

Definition at line 79 of file TRestEventTimeSelectionProcess.h.

◆ GetTotalTimeInSeconds()

Double_t TRestEventTimeSelectionProcess::GetTotalTimeInSeconds ( ) const
inline

Definition at line 77 of file TRestEventTimeSelectionProcess.h.

◆ Initialize()

void TRestEventTimeSelectionProcess::Initialize ( )
overrideprivatevirtual

Function to initialize input/output event members and define the section name.

Reimplemented from TRestMetadata.

Definition at line 124 of file TRestEventTimeSelectionProcess.cxx.

◆ InitProcess()

void TRestEventTimeSelectionProcess::InitProcess ( )
overridevirtual

Process initialization.

Reimplemented from TRestEventProcess.

Definition at line 143 of file TRestEventTimeSelectionProcess.cxx.

◆ PrintMetadata()

void TRestEventTimeSelectionProcess::PrintMetadata ( )
overridevirtual

Prints on screen the process data members.

Reimplemented from TRestMetadata.

Definition at line 309 of file TRestEventTimeSelectionProcess.cxx.

◆ ProcessEvent()

TRestEvent * TRestEventTimeSelectionProcess::ProcessEvent ( TRestEvent inputEvent)
overridevirtual

The main processing event function.

Implements TRestEventProcess.

Definition at line 208 of file TRestEventTimeSelectionProcess.cxx.

◆ ReadFileWithTimes()

std::vector< std::pair< std::string, std::string > > TRestEventTimeSelectionProcess::ReadFileWithTimes ( std::string  fileWithTimes,
Char_t  delimiter = ',' 
)
static

Definition at line 153 of file TRestEventTimeSelectionProcess.cxx.

◆ SetAsActiveTime()

void TRestEventTimeSelectionProcess::SetAsActiveTime ( )
inline

Definition at line 86 of file TRestEventTimeSelectionProcess.h.

◆ SetAsDeadTime()

void TRestEventTimeSelectionProcess::SetAsDeadTime ( )
inline

Definition at line 87 of file TRestEventTimeSelectionProcess.h.

◆ SetDelimiter()

void TRestEventTimeSelectionProcess::SetDelimiter ( Char_t  delimiter)
inline

Definition at line 90 of file TRestEventTimeSelectionProcess.h.

◆ SetFileWithTimes()

void TRestEventTimeSelectionProcess::SetFileWithTimes ( const std::string &  fileWithTimes)
inline

Definition at line 88 of file TRestEventTimeSelectionProcess.h.

◆ SetIsActiveTime()

void TRestEventTimeSelectionProcess::SetIsActiveTime ( Bool_t  isActiveTime)
inline

Definition at line 89 of file TRestEventTimeSelectionProcess.h.

◆ SetStartEndTimes()

void TRestEventTimeSelectionProcess::SetStartEndTimes ( const std::vector< std::pair< std::string, std::string > > &  startEndTimes)
inline

Definition at line 91 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeEndMarginInSeconds()

void TRestEventTimeSelectionProcess::SetTimeEndMarginInSeconds ( Long_t  timeEndMarginInSeconds)
inline

Definition at line 98 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeOffsetInSeconds()

void TRestEventTimeSelectionProcess::SetTimeOffsetInSeconds ( Long_t  timeOffsetInSeconds)
inline

Definition at line 94 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeStartMarginInSeconds()

void TRestEventTimeSelectionProcess::SetTimeStartMarginInSeconds ( Long_t  timeStartMarginInSeconds)
inline

Definition at line 95 of file TRestEventTimeSelectionProcess.h.

Field Documentation

◆ fDelimiter

Char_t TRestEventTimeSelectionProcess::fDelimiter
private

Definition at line 35 of file TRestEventTimeSelectionProcess.h.

◆ fEvent

TRestEvent* TRestEventTimeSelectionProcess::fEvent
private

Definition at line 32 of file TRestEventTimeSelectionProcess.h.

◆ fFileWithTimes

std::string TRestEventTimeSelectionProcess::fFileWithTimes
private

Definition at line 33 of file TRestEventTimeSelectionProcess.h.

◆ fIsActiveTime

Bool_t TRestEventTimeSelectionProcess::fIsActiveTime
private

Definition at line 34 of file TRestEventTimeSelectionProcess.h.

◆ fNEventsRejected

Int_t TRestEventTimeSelectionProcess::fNEventsRejected
private

Information about the events processed.

Definition at line 43 of file TRestEventTimeSelectionProcess.h.

◆ fNEventsSelected

Int_t TRestEventTimeSelectionProcess::fNEventsSelected
private

Definition at line 44 of file TRestEventTimeSelectionProcess.h.

◆ fStartEndTimes

std::vector<std::pair<std::string, std::string> > TRestEventTimeSelectionProcess::fStartEndTimes
private

Definition at line 39 of file TRestEventTimeSelectionProcess.h.

◆ fTimeEndMarginInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeEndMarginInSeconds
private

Definition at line 38 of file TRestEventTimeSelectionProcess.h.

◆ fTimeOffsetInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeOffsetInSeconds
private

Definition at line 36 of file TRestEventTimeSelectionProcess.h.

◆ fTimeStartMarginInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeStartMarginInSeconds
private

Definition at line 37 of file TRestEventTimeSelectionProcess.h.

◆ fTotalTimeInSeconds

Double_t TRestEventTimeSelectionProcess::fTotalTimeInSeconds
private

Definition at line 45 of file TRestEventTimeSelectionProcess.h.


The documentation for this class was generated from the following files: