REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Loading...
Searching...
No Matches
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):

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

  • fileWithTimes: name of the file that contains the time ranges.
  • isActiveTime: if true (default) the time ranges represent active periods of time, if false the time ranges represent dead periods of time.
  • delimiter: delimiter used in the file with the time ranges (default is ,).
  • offsetTimeInSeconds: offset time in seconds to be added to the event time (default is 0). This is useful to correct the time of the events if needed. This number of seconds will be added to the event time before checking if it is within the time ranges.
  • startMarginTimeInSeconds: margin time in seconds to be added to the start time of the time ranges (default is 0). This is useful to consider the events that are close to the start time of the time ranges. Meant to be a positive number, as the process will take care of adding or subtracting it if the time ranges represent active or dead periods of time respectively.
  • endMarginTimeInSeconds: margin time in seconds to be subtracted from the end time of the time ranges (default is 0). This is useful to consider the events that are close to the end time of the time ranges. Meant to be a positive number, as the process will take care of subtracting or adding it if the time ranges represent active or dead periods of time respectively.

useRunStartAndEndTimes: if true (default) the start and end times of the TRestRun will be used to restrict the time ranges to those involved (those that are between the run start and end times).

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:

  • nEventsRejected: number of events rejected.
  • nEventsSelected: number of events selected.

Examples

Examples for rml files:


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 32 of file TRestEventTimeSelectionProcess.h.

Inheritance diagram for TRestEventTimeSelectionProcess:
TRestEventProcess TRestMetadata

Public Member Functions

void ApplyEndRunTime (const TTimeStamp &runEndTime)
void ApplyStartRunTime (const TTimeStamp &runStartTime)
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, 2)
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< Interval > 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.
TRestEvent * ProcessEvent (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< Interval > &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 ()
 Apply cut according to the cut conditions saved in fCut.
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().
TRestAnalysisTree * GetAnalysisTree () const
 Return the local analysis tree (dummy).
TCanvas * GetCanvas () const
 Get canvas.
TRestAnalysisTree * GetFullAnalysisTree ()
 Get the full analysis tree from TRestRun, with non-empty entries.
std::vector< std::string > GetListOfAddedObservables ()
 Get list of observables, convert map to vector.
TRestRun * GetRunInfo () 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
 Load extra section metadata: outputlevel after calling TRestMetadata::LoadSectionMetadata().
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)
 Interface to external file reading, open input file. To be implemented in external processes.
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< Interval > 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
TRestEvent * fEvent
std::string fFileWithTimes
Bool_t fIsActiveTime
Int_t fNEventsRejected
 Information about the events processed.
Int_t fNEventsSelected
std::vector< Interval > fStartEndTimes
Long_t fTimeEndMarginInSeconds
Long_t fTimeOffsetInSeconds
Long_t fTimeStartMarginInSeconds
Double_t fTotalTimeInSeconds
Bool_t fUseRunStartAndEndTimes

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 ()
 Pre-defined printer, can be used at the ending in the implementation of PrintMetadata().
TRestEventProcess * GetFriend (const std::string &nameOrType)
 Get friendly TRestEventProcess object.
TRestEventProcess * GetFriendLive (const std::string &nameOrType)
 Get friendly TRestEventProcess object.
template<class T>
T * GetMetadata ()
 Get a metadata object from the host TRestRun.
TRestMetadata * GetMetadata (const std::string &nameOrType)
 Get a metadata object from the host TRestRun.
size_t GetNumberOfParallelProcesses () const
template<class T>
T GetObservableValue (const std::string &name)
TRestEventProcess * GetParallel (int i)
 Get a list of parallel processes from this process.
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
TRestAnalysisTree * fAnalysisTree = 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
TRestRun * fRunInfo = 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 125 of file TRestEventTimeSelectionProcess.cxx.

◆ ~TRestEventTimeSelectionProcess()

TRestEventTimeSelectionProcess::~TRestEventTimeSelectionProcess ( )
inline

Definition at line 66 of file TRestEventTimeSelectionProcess.h.

Member Function Documentation

◆ ApplyEndRunTime()

void TRestEventTimeSelectionProcess::ApplyEndRunTime ( const TTimeStamp & runEndTime)

Definition at line 313 of file TRestEventTimeSelectionProcess.cxx.

◆ ApplyStartRunTime()

void TRestEventTimeSelectionProcess::ApplyStartRunTime ( const TTimeStamp & runStartTime)

Definition at line 285 of file TRestEventTimeSelectionProcess.cxx.

◆ 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 210 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 281 of file TRestEventTimeSelectionProcess.cxx.

◆ GetDelimiter()

Char_t TRestEventTimeSelectionProcess::GetDelimiter ( ) const
inline

Definition at line 73 of file TRestEventTimeSelectionProcess.h.

◆ GetFileWithTimes()

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

Definition at line 70 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 54 of file TRestEventTimeSelectionProcess.h.

◆ GetIsActiveTime()

Bool_t TRestEventTimeSelectionProcess::GetIsActiveTime ( ) const
inline

Definition at line 72 of file TRestEventTimeSelectionProcess.h.

◆ GetNEventsRejected()

Int_t TRestEventTimeSelectionProcess::GetNEventsRejected ( ) const
inline

Definition at line 78 of file TRestEventTimeSelectionProcess.h.

◆ GetNEventsSelected()

Int_t TRestEventTimeSelectionProcess::GetNEventsSelected ( ) const
inline

Definition at line 79 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 55 of file TRestEventTimeSelectionProcess.h.

◆ GetProcessName()

const char * TRestEventTimeSelectionProcess::GetProcessName ( ) const
inlineoverridevirtual

Implements TRestEventProcess.

Definition at line 68 of file TRestEventTimeSelectionProcess.h.

◆ GetStartEndTimes()

std::vector< Interval > TRestEventTimeSelectionProcess::GetStartEndTimes ( ) const
inline

Definition at line 75 of file TRestEventTimeSelectionProcess.h.

◆ GetTimeEndMarginInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeEndMarginInSeconds ( ) const
inline

Definition at line 83 of file TRestEventTimeSelectionProcess.h.

◆ GetTimeOffsetInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeOffsetInSeconds ( ) const
inline

Definition at line 81 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
to increase the maximum number of operators allowed in a formula.

Definition at line 354 of file TRestEventTimeSelectionProcess.cxx.

◆ GetTimeStartMarginInSeconds()

Long_t TRestEventTimeSelectionProcess::GetTimeStartMarginInSeconds ( ) const
inline

Definition at line 82 of file TRestEventTimeSelectionProcess.h.

◆ GetTotalTimeInSeconds()

Double_t TRestEventTimeSelectionProcess::GetTotalTimeInSeconds ( ) const
inline

Definition at line 80 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 131 of file TRestEventTimeSelectionProcess.cxx.

◆ InitProcess()

void TRestEventTimeSelectionProcess::InitProcess ( )
overridevirtual

Process initialization.

Reimplemented from TRestEventProcess.

Definition at line 151 of file TRestEventTimeSelectionProcess.cxx.

◆ PrintMetadata()

void TRestEventTimeSelectionProcess::PrintMetadata ( )
overridevirtual

Prints on screen the process data members.

Reimplemented from TRestMetadata.

Definition at line 404 of file TRestEventTimeSelectionProcess.cxx.

◆ ProcessEvent()

TRestEvent * TRestEventTimeSelectionProcess::ProcessEvent ( TRestEvent * inputEvent)
overridevirtual

The main processing event function.

Implements TRestEventProcess.

Definition at line 232 of file TRestEventTimeSelectionProcess.cxx.

◆ ReadFileWithTimes()

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

Definition at line 172 of file TRestEventTimeSelectionProcess.cxx.

◆ SetAsActiveTime()

void TRestEventTimeSelectionProcess::SetAsActiveTime ( )
inline

Definition at line 90 of file TRestEventTimeSelectionProcess.h.

◆ SetAsDeadTime()

void TRestEventTimeSelectionProcess::SetAsDeadTime ( )
inline

Definition at line 91 of file TRestEventTimeSelectionProcess.h.

◆ SetDelimiter()

void TRestEventTimeSelectionProcess::SetDelimiter ( Char_t delimiter)
inline

Definition at line 94 of file TRestEventTimeSelectionProcess.h.

◆ SetFileWithTimes()

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

Definition at line 92 of file TRestEventTimeSelectionProcess.h.

◆ SetIsActiveTime()

void TRestEventTimeSelectionProcess::SetIsActiveTime ( Bool_t isActiveTime)
inline

Definition at line 93 of file TRestEventTimeSelectionProcess.h.

◆ SetStartEndTimes()

void TRestEventTimeSelectionProcess::SetStartEndTimes ( const std::vector< Interval > & startEndTimes)
inline

Definition at line 95 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeEndMarginInSeconds()

void TRestEventTimeSelectionProcess::SetTimeEndMarginInSeconds ( Long_t timeEndMarginInSeconds)
inline

Definition at line 100 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeOffsetInSeconds()

void TRestEventTimeSelectionProcess::SetTimeOffsetInSeconds ( Long_t timeOffsetInSeconds)
inline

Definition at line 96 of file TRestEventTimeSelectionProcess.h.

◆ SetTimeStartMarginInSeconds()

void TRestEventTimeSelectionProcess::SetTimeStartMarginInSeconds ( Long_t timeStartMarginInSeconds)
inline

Definition at line 97 of file TRestEventTimeSelectionProcess.h.

Field Documentation

◆ fDelimiter

Char_t TRestEventTimeSelectionProcess::fDelimiter
private

Definition at line 37 of file TRestEventTimeSelectionProcess.h.

◆ fEvent

TRestEvent* TRestEventTimeSelectionProcess::fEvent
private

Definition at line 34 of file TRestEventTimeSelectionProcess.h.

◆ fFileWithTimes

std::string TRestEventTimeSelectionProcess::fFileWithTimes
private

Definition at line 35 of file TRestEventTimeSelectionProcess.h.

◆ fIsActiveTime

Bool_t TRestEventTimeSelectionProcess::fIsActiveTime
private

Definition at line 36 of file TRestEventTimeSelectionProcess.h.

◆ fNEventsRejected

Int_t TRestEventTimeSelectionProcess::fNEventsRejected
private

Information about the events processed.

Definition at line 46 of file TRestEventTimeSelectionProcess.h.

◆ fNEventsSelected

Int_t TRestEventTimeSelectionProcess::fNEventsSelected
private

Definition at line 47 of file TRestEventTimeSelectionProcess.h.

◆ fStartEndTimes

std::vector<Interval> TRestEventTimeSelectionProcess::fStartEndTimes
private

Definition at line 41 of file TRestEventTimeSelectionProcess.h.

◆ fTimeEndMarginInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeEndMarginInSeconds
private

Definition at line 40 of file TRestEventTimeSelectionProcess.h.

◆ fTimeOffsetInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeOffsetInSeconds
private

Definition at line 38 of file TRestEventTimeSelectionProcess.h.

◆ fTimeStartMarginInSeconds

Long_t TRestEventTimeSelectionProcess::fTimeStartMarginInSeconds
private

Definition at line 39 of file TRestEventTimeSelectionProcess.h.

◆ fTotalTimeInSeconds

Double_t TRestEventTimeSelectionProcess::fTotalTimeInSeconds
private

Definition at line 48 of file TRestEventTimeSelectionProcess.h.

◆ fUseRunStartAndEndTimes

Bool_t TRestEventTimeSelectionProcess::fUseRunStartAndEndTimes
private

Definition at line 42 of file TRestEventTimeSelectionProcess.h.


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