59#include "TRestDataBase.h"
60#include "TRestManager.h"
61#include "TRestProcessRunner.h"
62#include "TRestStringOutput.h"
73 while (ele !=
nullptr) {
75 if (name.empty() || name ==
"Not defined") {
76 RESTError <<
"< cut does not contain a name!" <<
RESTendl;
84 if (!cutStr.empty()) {
85 cutStr =
Replace(cutStr,
" AND ",
" && ");
86 cutStr =
Replace(cutStr,
" OR ",
" || ");
88 AddCut(TCut(name.c_str(), cutStr.c_str()));
89 }
else if (!variable.empty() && !condition.empty()) {
90 fParamCut.push_back(std::make_pair(variable, condition));
91 string cutVar = variable + condition;
92 AddCut(TCut(name.c_str(), cutVar.c_str()));
94 RESTError <<
"TRestCut does not contain a valid parameter/condition or cut string!" <<
RESTendl;
95 RESTError <<
"<cut name='cc1' value='XX>10 AND XX<90'/>" <<
RESTendl;
96 RESTError <<
"<cut name='cc3' variable='sAna_ThresholdIntegral' condition='>0'" <<
RESTendl;
105 SetName(cut.GetName());
106 SetTitle(cut.GetTitle());
107 fCuts = cut.GetCuts();
113void TRestCut::AddCut(
const TCut& cut) {
114 if ((
string)cut.GetName() ==
"") {
115 RESTWarning <<
"TRestCut::AddCut: cannot add cut without name!" <<
RESTendl;
118 if ((
string)cut.GetTitle() ==
"") {
119 RESTWarning <<
"TRestCut::AddCut: cannot add empty cut!" <<
RESTendl;
122 for (
const auto& c :
fCuts) {
123 if ((
string)c.GetName() == (
string)cut.GetName()) {
124 RESTWarning <<
"TRestCut::AddCut: cut with name \"" << c.GetName() <<
"\" already added!"
129 fCuts.push_back(cut);
132TCut TRestCut::GetCut(
string name) {
133 for (
auto c :
fCuts) {
134 if ((
string)c.GetName() == name) {
141void TRestCut::AddCut(
TRestCut* cut) {
142 if (cut ==
nullptr) {
143 RESTWarning <<
"Cut to be added is nullptr, skipping" <<
RESTendl;
146 for (
const auto& c : cut->GetCuts()) {
150 const auto paramCut = cut->GetParamCut();
153 const auto cutStrings = cut->GetCutStrings();
160 RESTMetadata <<
"Cuts added: " <<
RESTendl;
161 for (
const auto& cut :
fCuts) {
162 RESTMetadata << cut.GetName() <<
" " << cut.GetTitle() <<
RESTendl;
170 for (
auto c :
fCuts) {
A class to help on cuts definitions. To be used with TRestAnalysisTree.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
Int_t Write(const char *name, Int_t option, Int_t bufsize) override
overwriting the write() method with fStore considered
void Initialize() override
Making default settings.
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
std::vector< TCut > fCuts
Vector of TCuts.
std::vector< std::pair< std::string, std::string > > fParamCut
Vector of parameter cuts, first item is parameter and second is the condition.
std::vector< std::string > fCutStrings
Vector of cut strings e.g. when you use a complex cut.
std::string Replace(std::string in, std::string thisString, std::string byThisString, size_t fromPosition=0, Int_t N=0)
Replace any occurences of thisSring by byThisString inside string in.