REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Attributes
TRestEventProcess Class Referenceabstract

Detailed Description

A base class for any REST event process.

One of the core classes of REST. Absract class from which all REST "event process classes" must derive. An event process in REST is an atomic operation on one single (input) event, potentially producing a different (output) event. Which type of (input/output) events will depent on the type of process. Processes can be tailored via metadata classes. All this needs to be defined in the inherited class. TRestEventProcess provides the basic structure (virtual functions)


RESTsoft - Software for Rare Event Searches with TPCs

History of developments:

2014-june: First concept. As part of conceptualization of previous REST code (REST v2) Igor G. Irastorza

2017-Aug: Major change: added for multi-thread capability Kaixiang Ni


Definition at line 37 of file TRestEventProcess.h.

#include <TRestEventProcess.h>

Inheritance diagram for TRestEventProcess:
TRestMetadata TRestAxionAnalysisProcess TRestAxionEventProcess TRestAxionGeneratorProcess TRestBenchMarkProcess TRestDataQualityProcess TRestDetectorAvalancheProcess TRestDetectorDaqChannelSwitchingProcess TRestDetectorElectronDiffusionProcess TRestDetectorFiducializationProcess TRestDetectorGarfieldDriftProcess TRestDetectorHitmapAnalysisProcess TRestDetectorHits3DReconstructionProcess TRestDetectorHitsAnalysisProcess TRestDetectorHitsGaussAnalysisProcess TRestDetectorHitsNormalizationProcess TRestDetectorHitsReadoutAnalysisProcess TRestDetectorHitsReductionProcess TRestDetectorHitsRotationProcess TRestDetectorHitsShuffleProcess TRestDetectorHitsSmearingProcess TRestDetectorHitsSpecularProcess TRestDetectorHitsToSignalProcess TRestDetectorHitsToTrackFastProcess TRestDetectorHitsToTrackProcess TRestDetectorHitsTranslationProcess TRestDetectorLightAttenuationProcess TRestDetectorPositionMappingProcess TRestDetectorSignalChannelActivityProcess TRestDetectorSignalRecoveryProcess TRestDetectorSignalToHitsProcess TRestDetectorSignalToRawSignalProcess TRestDetectorSignalViewerProcess TRestDetectorSingleChannelAnalysisProcess TRestDetectorTriggerAnalysisProcess TRestEventRateAnalysisProcess TRestEventSelectionProcess TRestGeant4AnalysisProcess TRestGeant4BlobAnalysisProcess TRestGeant4NeutronTaggingProcess TRestGeant4QuenchingProcess TRestGeant4ToDetectorHitsProcess TRestGeant4VetoAnalysisProcess TRestLegacyProcess TRestMySQLToAnalysisProcess TRestRawBaseLineCorrectionProcess TRestRawBiPoAnalysisProcess TRestRawCommonNoiseReductionProcess TRestRawFindResponseSignalProcess TRestRawMemoryBufferToSignalProcess TRestRawPeaksFinderProcess TRestRawReadoutAnalysisProcess TRestRawReadoutMetadataProcess TRestRawSignalAddNoiseProcess TRestRawSignalAnalysisProcess TRestRawSignalChannelActivityProcess TRestRawSignalConvolutionFittingProcess TRestRawSignalFittingProcess TRestRawSignalGeneralFitProcess TRestRawSignalIdTaggingProcess TRestRawSignalRangeReductionProcess TRestRawSignalRemoveChannelsProcess TRestRawSignalShapingProcess TRestRawSignalViewerProcess TRestRawToDetectorSignalProcess TRestRawToSignalProcess TRestRawVetoAnalysisProcess TRestRealTimeAddInputFileProcess TRestRealTimeDrawingProcess TRestSummaryProcess TRestTrackAnalysisProcess TRestTrackBlobAnalysisProcess TRestTrackDetachIsolatedNodesProcess TRestTrackLineAnalysisProcess TRestTrackLinearizationProcess TRestTrackPathMinimizationProcess TRestTrackPointLikeAnalysisProcess TRestTrackReconnectionProcess TRestTrackReductionProcess TRestTrackToDetectorHitsProcess TRestTrackViewerProcess

Public Member Functions

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()
 
virtual void EndProcess ()
 To be executed at the end of the run (outside event loop)
 
TRestAnalysisTreeGetAnalysisTree () const
 Return the local analysis tree (dummy)
 
TCanvas * GetCanvas () const
 Get canvas.
 
TRestAnalysisTreeGetFullAnalysisTree ()
 
virtual RESTValue GetInputEvent () const =0
 Get pointer to input event. Must be implemented in the derived class.
 
std::vector< std::string > GetListOfAddedObservables ()
 
virtual RESTValue GetOutputEvent () const =0
 Get pointer to output event. Must be implemented in the derived class.
 
virtual const char * GetProcessName () const =0
 
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.
 
virtual void InitProcess ()
 To be executed at the beginning of the run (outside event loop)
 
Bool_t isExternal () const
 Return whether this process is external process.
 
Int_t LoadSectionMetadata () override
 This method does some preparation of xml section. More...
 
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)
 
virtual TRestEventProcessEvent (TRestEvent *inputEvent)=0
 Process one event.
 
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 ()
 

Protected Types

enum  REST_Process_Output { No_Output , Observable , Internal_Var , Full_Output }
 

Protected Member Functions

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. More...
 
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. More...
 
template<class T >
void SetObservableValue (const std::string &name, const T &value)
 Set observable value for AnalysisTree. More...
 

Protected Attributes

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. More...
 
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. More...
 
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.
 

Private Attributes

std::vector< TRestEventProcess * > fFriendlyProcesses
 /// not used More...
 
TRestEventfInputEvent = nullptr
 < not used, keep for compatibility
 
TRestEventfOutputEvent = nullptr
 < not used, keep for compatibility
 
REST_Process_Output fOutputLevel
 not used, keep for compatibility
 
std::vector< TRestEventProcess * > fParallelProcesses
 Stores a list of parallel processes if multithreading is enabled.
 

Member Enumeration Documentation

◆ REST_Process_Output

Enumerator
No_Output 

creates no branch in analysis tree, user can still manually save what he wants.

Observable 

+saving observables as branches in root directory of the tree

Internal_Var 

+saving the process itself as a branch. branch name is the process name. Internal variables can be found as leaf of the branch

Full_Output 

+saving output event as another branch. branch name is process name+"_evtBranch"

Definition at line 39 of file TRestEventProcess.h.

Constructor & Destructor Documentation

◆ TRestEventProcess()

TRestEventProcess::TRestEventProcess ( )

TRestEventProcess default constructor

Definition at line 69 of file TRestEventProcess.cxx.

◆ ~TRestEventProcess()

TRestEventProcess::~TRestEventProcess ( )

TRestEventProcess destructor

Definition at line 79 of file TRestEventProcess.cxx.

Member Function Documentation

◆ GetMetadata()

template<class T >
T* TRestEventProcess::GetMetadata ( )
inlineprotected

Get a metadata object from the host TRestRun.

Directly input the type as template argument. This helps to simplify the code and prevents mis-spelling. For example: fReadout = GetMetadata<TRestReadout>();. No need for type conversion.

Definition at line 104 of file TRestEventProcess.h.

◆ GetParallelDataMembers()

template<class T >
std::vector<T> TRestEventProcess::GetParallelDataMembers ( T *  member_of_process)
inlineprotected

Get a list of data members from parallel processes which is same to this process's certain data member.

This method can be used in merging and exporting histograms at the end of the process, to support multi-thread run.

Because all the parallel processes are in same data structure, this method directly gets the data members by accessing certain offset.

Usage: (suppose we defined fHist as data member) auto hists = this->GetParallelObjects(&fHist); for (auto h : hists) { fHist->Add(h); }

Definition at line 128 of file TRestEventProcess.h.

◆ GetTotalBytes()

virtual Long64_t TRestEventProcess::GetTotalBytes ( ) const
inlinevirtual

Interface to external file reading, get the total bytes of input binary file. To be implemented in external processes.

Reimplemented in TRestRawToSignalProcess.

Definition at line 255 of file TRestEventProcess.h.

◆ LoadSectionMetadata()

Int_t TRestEventProcess::LoadSectionMetadata ( )
overridevirtual

This method does some preparation of xml section.

Preparation includes: setting the name, title and verbose level of the current class. Finding out and saving the env sections.

By calling TRestMetadata::ReadElement(), is also expands for loops and include definitions, and replaces env and expressions in rml config section.

Reimplemented from TRestMetadata.

◆ SetObservableValue()

template<class T >
void TRestEventProcess::SetObservableValue ( const std::string &  name,
const T &  value 
)
inlineprotected

Set observable value for AnalysisTree.

It will rename the observable to "processName_obsName" If use dynamic observable, it will try to create new observable in the AnalysisTree if the observable is not found

Definition at line 151 of file TRestEventProcess.h.

Field Documentation

◆ fAnalysisTree

TRestAnalysisTree* TRestEventProcess::fAnalysisTree = nullptr
protected

< Pointer to the analysis tree where to store observable definitions and values. Note that this tree does not write data to disk. It only keeps a list of observables and their addresses. It is the one from TRestRun that reads this tree's structure, calls Fill() method, and writes data to disk. In other words, this tree is dummy and has zero entries. To get the real one, use GetFullAnalysisTree()

Definition at line 72 of file TRestEventProcess.h.

◆ fCuts

std::vector<std::pair<std::string, TVector2> > TRestEventProcess::fCuts
protected

Stores cut definitions. Any listed observables should be in the range.

[name, id in AnalysisTree]

Definition at line 92 of file TRestEventProcess.h.

◆ fFriendlyProcesses

std::vector<TRestEventProcess*> TRestEventProcess::fFriendlyProcesses
private

/// not used

Stores a list of friendly processes. Sometimes the process may behave differently according to the friend processes added. It can also get parameter or output event from friend processes

Definition at line 59 of file TRestEventProcess.h.

◆ fObservablesDefined

std::map<std::string, int> TRestEventProcess::fObservablesDefined
protected

Stores the list of all the appeared process observables in the code.

[name, id in AnalysisTree]

Definition at line 90 of file TRestEventProcess.h.

◆ fSingleThreadOnly

bool TRestEventProcess::fSingleThreadOnly = false
protected

It defines if the process can run only under single std::thread mode. If true, the whole process chain will not use multithreading. Useful for processes with viewing functionality. Always true for external processes.

Definition at line 80 of file TRestEventProcess.h.


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