53#include "TRestEventProcess.h"
57#include <TDataMember.h>
59#include "TRestManager.h"
99vector<string> TRestEventProcess::ReadObservables() {
100 std::cout <<
"Entering ReadObservables" << std::endl;
102 vector<string> obsNames;
103 vector<string> obsTypes;
104 vector<string> obsDesc;
106 while (e !=
nullptr) {
107 const char* obschr = e->Attribute(
"name");
108 const char* _value = e->Attribute(
"value");
109 const char* _type = e->Attribute(
"type");
110 const char* _desc = e->Attribute(
"description");
112 std::cout <<
"Name: " << obschr << std::endl;
115 if (_value ==
nullptr)
120 if (_type ==
nullptr)
125 if (_desc ==
nullptr)
131 if (obschr !=
nullptr) {
132 RESTDebug << this->ClassName() <<
" : setting observable \"" << obschr <<
"\"" <<
RESTendl;
134 obsNames.emplace_back(obschr);
135 obsTypes.push_back(type);
136 obsDesc.push_back(description);
140 e = e->NextSiblingElement(
"observable");
144 for (
unsigned int i = 0; i < obsNames.size(); i++) {
145 string obsName = this->GetName() + (string)
"_" + obsNames[i];
146 std::cout <<
"ADDING OBSERVABLE : " << obsName << std::endl;
147 fAnalysisTree->AddObservable(obsName, obsTypes[i], obsDesc[i]);
168 if (p ==
nullptr)
return;
170 if (fFriendlyProcess->GetName() == p->GetName()) {
179 if (p ==
nullptr)
return;
181 if (fParallelProcess == p ||
this == p) {
190Bool_t TRestEventProcess::OpenInputFiles(
const vector<string>& files) {
return false; }
207 TiXmlElement* ele =
fElement->FirstChildElement();
208 while (ele !=
nullptr) {
209 if (ele->Value() !=
nullptr && (
string)ele->Value() ==
"cut") {
210 if (ele->Attribute(
"name") !=
nullptr && ele->Attribute(
"value") !=
nullptr) {
211 string name = ele->Attribute(
"name");
212 name = (string)this->GetName() +
"_" + name;
214 if (value.X() != value.Y())
fCuts.push_back(pair<string, TVector2>(name, value));
218 else if (ele->Value() !=
nullptr && (
string)ele->Value() ==
"parameter") {
219 if (ele->Attribute(
"name") !=
nullptr && ele->Attribute(
"value") !=
nullptr) {
220 string name = ele->Attribute(
"name");
221 if (name.find(
"Cut") == name.size() - 3 || name.find(
"CutRange") == name.size() - 8) {
222 name = name.substr(0, name.find(
"Cut") + 3);
224 if (value.X() != value.Y())
fCuts.push_back(pair<string, TVector2>(name, value));
229 ele = ele->NextSiblingElement();
245 if (m ==
nullptr) m =
fRunInfo->GetMetadataClass(name);
268 if (proc ==
nullptr) {
270 if (friendfromfile !=
nullptr && friendfromfile->InheritsFrom(
"TRestEventProcess")) {
285 if ((
string)fFriendlyProcess->GetName() == nameOrType ||
286 (
string)fFriendlyProcess->ClassName() == nameOrType) {
287 return fFriendlyProcess;
313bool TRestEventProcess::ApplyCut() {
314 for (
auto cut :
fCuts) {
318 if (val > cut.second.Y() || val < cut.second.X()) {
324 if (val > cut.second.Y() || val < cut.second.X()) {
351 RESTDebug <<
"Entering " << ClassName() <<
"::BeginOfEventProcess, Initializing output event..."
357 outEv->SetID(inEv->GetID());
358 outEv->SetSubID(inEv->GetSubID());
359 outEv->SetSubEventTag(inEv->GetSubEventTag());
361 outEv->SetRunOrigin(inEv->GetRunOrigin());
362 outEv->SetSubRunOrigin(inEv->GetSubRunOrigin());
364 outEv->
SetTime(inEv->GetTime());
386 RESTDebug <<
"Entering TRestEventProcess::EndOfEventProcess (" << ClassName() <<
")" <<
RESTendl;
393 <<
"The observable '" << x.first <<
"' is defined but not set by "
395 <<
", the event is empty? Makesure all observables are set through ProcessEvent()"
420 RESTMetadata.setcolor(COLOR_BOLDGREEN);
421 RESTMetadata.setborder(
"||");
422 RESTMetadata.setlength(100);
426 RESTMetadata <<
"Process : " << ClassName() <<
RESTendl;
427 RESTMetadata <<
"Name: " << GetName() <<
" Title: " << GetTitle()
429 RESTMetadata <<
" ----------------------------------------------- " <<
RESTendl;
433 RESTMetadata <<
" Analysis tree observables added by this process " <<
RESTendl;
434 RESTMetadata <<
" +++++++++++++++++++++++++++++++++++++++++++++++ " <<
RESTendl;
439 RESTMetadata <<
" ++ " << iter->first <<
RESTendl;
444 RESTMetadata <<
" +++++++++++++++++++++++++++++++++++++++++++++++ " <<
RESTendl;
454void TRestEventProcess::EndPrintProcess() {
455 if (
fCuts.size() > 0) {
456 RESTMetadata <<
"Cuts enabled" <<
RESTendl;
457 RESTMetadata <<
"------------" <<
RESTendl;
459 auto iter =
fCuts.begin();
460 while (iter !=
fCuts.end()) {
461 if (iter->second.X() != iter->second.Y())
462 RESTMetadata << iter->first <<
", range : ( " << iter->second.X() <<
" , " << iter->second.Y()
471 RESTMetadata.resetcolor();
472 RESTMetadata.setborder(
"");
473 RESTMetadata.setlength(10000);
510 return fHostmgr->GetProcessRunner()->GetOutputAnalysisTree();
516std::vector<string> TRestEventProcess::GetListOfAddedObservables() {
520 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.