23#ifndef RestCore_TRestEventProcess
24#define RestCore_TRestEventProcess
31#include "TRestAnalysisTree.h"
32#include "TRestEvent.h"
33#include "TRestMetadata.h"
92 std::vector<std::pair<std::string, TVector2>>
fCuts;
96 void EndPrintProcess();
105 std::string type = REST_Reflection::GetTypeName<T>();
111 inline size_t GetNumberOfParallelProcesses()
const {
return fParallelProcesses.size(); }
129 std::vector<T> result;
130 int offset = (int)((
char*)member_of_process - (
char*)
this);
131 if (offset <= 0 || offset > this->IsA()->GetClassSize()) {
132 std::cout << this->ClassName() <<
"::GetParallelDataMembers(): invalid object input!"
136 for (
int i = 0; i < GetNumberOfParallelProcesses(); i++) {
137 char* proc = (
char*)GetParallel(i);
138 if (proc == (
char*)
this)
continue;
140 result.push_back(*(T*)(proc + offset));
156 std::string obsName = std::string(this->GetName()) +
"_" + name;
183 T GetObservableValue(
const std::string& name) {
187 return std::numeric_limits<T>::quiet_NaN();
201 virtual const char* GetProcessName()
const = 0;
205 for (
auto& p : parameters) {
210 std::vector<std::string> ReadObservables();
212 virtual Bool_t OpenInputFiles(
const std::vector<std::string>& files);
214 virtual Bool_t AddInputFile(
const std::string& file) {
return false; }
216 virtual Bool_t ResetEntry() {
return false; }
220 inline void RegisterAllObservables(Bool_t value =
true) {
fDynamicObs = value; }
269 std::vector<std::string> GetListOfAddedObservables();
279#define _ApplyCut(evt) \
280 if (ApplyCut()) return nullptr; \
REST core data-saving helper based on TTree.
T GetObservableValue(Int_t n)
Get observable in a given type, according to its id.
Int_t GetObservableID(const std::string &obsName)
Get the index of the specified observable.
void SetObservableValue(const Int_t &id, const T &value)
Set the value of observable whose index is id.
void SetObservable(Int_t id, RESTValue obs)
Set the value of observable whose id is as specified.
A base class for any REST event process.
virtual void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
TRestEvent * fOutputEvent
< not used, keep for compatibility
bool fIsExternal
It defines if the process reads event data from an external source.
void SetRunInfo(TRestRun *r)
Set TRestRun for this process.
virtual void EndProcess()
To be executed at the end of the run (outside event loop)
virtual void EndOfEventProcess(TRestEvent *inputEvent=nullptr)
End of event process. Nothing to do. Called directly after ProcessEvent()
std::vector< TRestEventProcess * > fFriendlyProcesses
/// not used
TRestAnalysisTree * fAnalysisTree
virtual void NotifyAnalysisTreeReset()
In case the analysis tree is reset(switched to new file), some process needs to have action.
TRestRun * GetRunInfo() const
Return the pointer of the hosting TRestRun object.
TVector2 fCanvasSize
Canvas size.
void BeginPrintProcess()
[name, cut range]
void SetAnalysisTree(TRestAnalysisTree *tree)
Set analysis tree of this process, then add observables to it.
Bool_t singleThreadOnly() const
Return whether this process is single std::thread only.
bool fValidateObservables
It defines if observable names should be added to the validation list.
TCanvas * GetCanvas() const
Get canvas.
Bool_t isExternal() const
Return whether this process is external process.
TRestAnalysisTree * GetAnalysisTree() const
Return the local analysis tree (dummy)
virtual Long64_t GetTotalBytes() const
@ 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
@ Full_Output
+saving output event as another branch. branch name is process name+"_evtBranch"
virtual void BeginOfEventProcess(TRestEvent *inputEvent=nullptr)
Begin of event process, preparation work. Called right before ProcessEvent()
TCanvas * fCanvas
< Canvas for some viewer event
void SetParallelProcess(TRestEventProcess *p)
Add parallel process to this process.
std::vector< std::pair< std::string, TVector2 > > fCuts
Stores cut definitions. Any listed observables should be in the range.
TRestRun * fRunInfo
< Pointer to TRestRun object where to find metadata.
void CreateCanvas()
Create the canvas.
Int_t LoadSectionMetadata() override
This method does some preparation of xml section.
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 membe...
bool fDynamicObs
It defines whether to use added observables only or all the observables appear in the code.
bool fReadOnly
not used, keep for compatibility
virtual TRestEvent * ProcessEvent(TRestEvent *inputEvent)=0
Process one event.
std::vector< TRestEventProcess * > fParallelProcesses
Stores a list of parallel processes if multithreading is enabled.
virtual RESTValue GetOutputEvent() const =0
Get pointer to output event. Must be implemented in the derived class.
std::map< std::string, int > fObservablesUpdated
Stores the list of process observables updated when processing this event.
virtual void InitProcess()
To be executed at the beginning of the run (outside event loop)
TRestEvent * fInputEvent
< not used, keep for compatibility
virtual Long64_t GetTotalBytesRead() const
Interface to external file reading, get the read bytes. To be implemented in external processes.
void SetCanvasSize(Int_t x, Int_t y)
Set canvas size.
REST_Process_Output fOutputLevel
not used, keep for compatibility
virtual RESTValue GetInputEvent() const =0
Get pointer to input event. Must be implemented in the derived class.
std::map< std::string, int > fObservablesDefined
Stores the list of all the appeared process observables in the code.
T * GetMetadata()
Get a metadata object from the host TRestRun.
void SetFriendProcess(TRestEventProcess *p)
Add friendly process to this process.
void SetObservableValue(const std::string &name, const T &value)
Set observable value for AnalysisTree.
A base class for any REST event.
Data provider and manager in REST.
std::string ReplaceMetadataMembers(const std::string &instr, Int_t precision=8)
It will replace the data members contained inside the string given as input. The data members in the ...
std::string ReplaceMathematicalExpressions(std::string buffer, Int_t precision=0, std::string errorMessage="")
Evaluates and replaces valid mathematical expressions found in the input string buffer.