53#include "TRestEventProcess.h"
57#include <TDataMember.h>
59#include "TRestManager.h"
99vector<string> TRestEventProcess::ReadObservables() {
101 vector<string> obsNames;
102 vector<string> obsTypes;
103 vector<string> obsDesc;
105 while (e !=
nullptr) {
106 const char* obschr = e->Attribute(
"name");
107 const char* _value = e->Attribute(
"value");
108 const char* _type = e->Attribute(
"type");
109 const char* _desc = e->Attribute(
"description");
112 if (_value ==
nullptr)
117 if (_type ==
nullptr)
122 if (_desc ==
nullptr)
128 if (obschr !=
nullptr) {
129 RESTDebug << this->ClassName() <<
" : setting observable \"" << obschr <<
"\"" <<
RESTendl;
131 obsNames.emplace_back(obschr);
132 obsTypes.push_back(type);
133 obsDesc.push_back(description);
137 e = e->NextSiblingElement(
"observable");
141 for (
unsigned int i = 0; i < obsNames.size(); i++) {
142 string obsName = this->GetName() + (string)
"_" + obsNames[i];
143 fAnalysisTree->AddObservable(obsName, obsTypes[i], obsDesc[i]);
164 if (p ==
nullptr)
return;
166 if (fFriendlyProcess->GetName() == p->GetName()) {
175 if (p ==
nullptr)
return;
177 if (fParallelProcess == p ||
this == p) {
186Bool_t TRestEventProcess::OpenInputFiles(
const vector<string>& files) {
return false; }
203 TiXmlElement* ele =
fElement->FirstChildElement();
204 while (ele !=
nullptr) {
205 if (ele->Value() !=
nullptr && (
string)ele->Value() ==
"cut") {
206 if (ele->Attribute(
"name") !=
nullptr && ele->Attribute(
"value") !=
nullptr) {
207 string name = ele->Attribute(
"name");
208 name = (string)this->GetName() +
"_" + name;
210 if (value.X() != value.Y())
fCuts.push_back(pair<string, TVector2>(name, value));
214 else if (ele->Value() !=
nullptr && (
string)ele->Value() ==
"parameter") {
215 if (ele->Attribute(
"name") !=
nullptr && ele->Attribute(
"value") !=
nullptr) {
216 string name = ele->Attribute(
"name");
217 if (name.find(
"Cut") == name.size() - 3 || name.find(
"CutRange") == name.size() - 8) {
218 name = name.substr(0, name.find(
"Cut") + 3);
220 if (value.X() != value.Y())
fCuts.push_back(pair<string, TVector2>(name, value));
225 ele = ele->NextSiblingElement();
241 if (m ==
nullptr) m =
fRunInfo->GetMetadataClass(name);
264 if (proc ==
nullptr) {
266 if (friendfromfile !=
nullptr && friendfromfile->InheritsFrom(
"TRestEventProcess")) {
281 if ((
string)fFriendlyProcess->GetName() == nameOrType ||
282 (
string)fFriendlyProcess->ClassName() == nameOrType) {
283 return fFriendlyProcess;
309bool TRestEventProcess::ApplyCut() {
310 for (
auto cut :
fCuts) {
314 if (val > cut.second.Y() || val < cut.second.X()) {
320 if (val > cut.second.Y() || val < cut.second.X()) {
347 RESTDebug <<
"Entering " << ClassName() <<
"::BeginOfEventProcess, Initializing output event..."
353 outEv->SetID(inEv->GetID());
354 outEv->SetSubID(inEv->GetSubID());
355 outEv->SetSubEventTag(inEv->GetSubEventTag());
357 outEv->SetRunOrigin(inEv->GetRunOrigin());
358 outEv->SetSubRunOrigin(inEv->GetSubRunOrigin());
360 outEv->
SetTime(inEv->GetTime());
382 RESTDebug <<
"Entering TRestEventProcess::EndOfEventProcess (" << ClassName() <<
")" <<
RESTendl;
389 <<
"The observable '" << x.first <<
"' is defined but not set by "
391 <<
", the event is empty? Makesure all observables are set through ProcessEvent()"
416 RESTMetadata.setcolor(COLOR_BOLDGREEN);
417 RESTMetadata.setborder(
"||");
418 RESTMetadata.setlength(100);
422 RESTMetadata <<
"Process : " << ClassName() <<
RESTendl;
423 RESTMetadata <<
"Name: " << GetName() <<
" Title: " << GetTitle()
425 RESTMetadata <<
" ----------------------------------------------- " <<
RESTendl;
429 RESTMetadata <<
" Analysis tree observables added by this process " <<
RESTendl;
430 RESTMetadata <<
" +++++++++++++++++++++++++++++++++++++++++++++++ " <<
RESTendl;
435 RESTMetadata <<
" ++ " << iter->first <<
RESTendl;
440 RESTMetadata <<
" +++++++++++++++++++++++++++++++++++++++++++++++ " <<
RESTendl;
450void TRestEventProcess::EndPrintProcess() {
451 if (
fCuts.size() > 0) {
452 RESTMetadata <<
"Cuts enabled" <<
RESTendl;
453 RESTMetadata <<
"------------" <<
RESTendl;
455 auto iter =
fCuts.begin();
456 while (iter !=
fCuts.end()) {
457 if (iter->second.X() != iter->second.Y())
458 RESTMetadata << iter->first <<
", range : ( " << iter->second.X() <<
" , " << iter->second.Y()
467 RESTMetadata.resetcolor();
468 RESTMetadata.setborder(
"");
469 RESTMetadata.setlength(10000);
506 return fHostmgr->GetProcessRunner()->GetOutputAnalysisTree();
512std::vector<string> TRestEventProcess::GetListOfAddedObservables() {
516 list.push_back(iter->first);
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.
TString GetObservableType(Int_t n)
Get the observable type according to id.
A base class for any REST event process.
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
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 fValidateObservables
It defines if observable names should be added to the validation list.
virtual void BeginOfEventProcess(TRestEvent *inputEvent=nullptr)
Begin of event process, preparation work. Called right before ProcessEvent()
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.
Int_t LoadSectionMetadata() override
This method does some preparation of xml section.
bool fDynamicObs
It defines whether to use added observables only or all the observables appear in the code.
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.
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.
A base class for any REST event.
void SetTime(Double_t time)
virtual void Initialize()=0
TRestMetadata * GetMetadataClass(std::string type)
Get the application metadata class, according to the type.
TRestMetadata * GetMetadata(std::string name)
Get the application metadata class, according to the name.
std::string ToUpper(std::string in)
Convert string to its upper case. Alternative of TString::ToUpper.
TVector2 StringTo2DVector(std::string in)
Gets a 2D-vector from a string.