21 std::cout <<
"ERROR TreeCutSelector::Configuration file not specified" << std::endl;
28 for (
auto& el :
_h_selections.items()) std::cout << el.key() <<
" : " << el.value() <<
"\n";
32 range_cuts[cut.key()].first.first = cut.value().at(
"min");
33 range_cuts[cut.key()].first.second = cut.value().at(
"max");
34 range_cuts[cut.key()].second = cut.value().at(
"id");
35 labels[cut.key()] = cut.value().at(
"info");
41 std::cout << it->first <<
" [min:] =" << it->second.first.first <<
" [max:] =" << it->second.first.second
42 <<
" [id:] =" << it->second.second << std::endl;
53 h_cf_->GetXaxis()->SetCanExtend(
true);
55 h_cf_->GetXaxis()->SetBinLabel(1,
"no-cuts");
58 h_cf_->GetXaxis()->SetBinLabel((it->second.second + 2),
labels[(it->first)].c_str());
73 std::string cutstring =
"";
75 std::cout <<
"ERROR " << cutname <<
" cut not implemented" << std::endl;
80 if (cutname ==
"pos_z0" || cutname ==
"ele_z0" || cutname ==
"min_y0") {
81 double zoffset =
range_cuts[cutname].first.first;
82 double alpha =
range_cuts[cutname].first.second;
83 std::string zvertex =
"vertex_z";
84 if (forTree) zvertex =
"vertex.getZ()";
85 cutstring +=
"(" + zvertex +
" * " + std::to_string(alpha) +
" - abs(" + var +
") < " + std::to_string(alpha) +
86 " * " + std::to_string(zoffset) +
")";
89 cutstring += var +
" >= " + std::to_string(
range_cuts[cutname].first.first);
92 if (!cutstring.empty()) cutstring +=
" && ";
93 cutstring += var +
" <= " + std::to_string(
range_cuts[cutname].first.second);
101 std::string full_cutstring =
"";
102 for (std::map<std::string, std::pair<std::pair<double, double>,
int>>::iterator it =
getPointerToCuts()->begin();
104 std::string cutname = it->first;
105 bool exclude =
false;
106 for (std::vector<std::string>::iterator eit = cuts_to_exclude.begin(); eit != cuts_to_exclude.end(); eit++) {
107 if (*eit == cutname) {
112 if (exclude)
continue;
115 if (!cutstring.empty()) {
116 if (!full_cutstring.empty()) full_cutstring +=
" && ";
117 full_cutstring += cutstring;
120 if (full_cutstring.empty()) full_cutstring =
"1";
122 full_cutstring =
"(" + full_cutstring +
")";
123 return full_cutstring;
129 for (std::map<std::string, std::pair<std::pair<double, double>,
int>>::iterator it =
getPointerToCuts()->begin();
131 std::string cutname = it->first;
135 for (std::vector<std::string>::iterator iit = cut_variable_list.begin(); iit != cut_variable_list.end();
137 if ((std::string)*iit == cutname) {
std::string getCutString(std::string cutname, bool forTree=false)
std::map< std::string, std::pair< std::pair< double, double >, int > > * getPointerToCuts()
get pointer to the base class cuts
json _h_selections
description
std::string getFullCutString(std::vector< std::string > cuts_to_exclude={}, bool forTree=false)
bool hasCut(const std::string &cutname)
std::string getCutVar(std::string cutname, bool forTree=false)
void filterCuts(std::vector< std::string > cut_variable_list)
virtual ~TreeCutSelector()
std::shared_ptr< TH1F > h_cf_
description
std::map< std::string, std::pair< std::pair< double, double >, int > >::iterator range_cut_it
description
void makeCutFlowHisto()
description
std::map< std::string, std::pair< std::pair< double, double >, int > > range_cuts
std::string m_cfgFile
description
std::string m_name
description
std::map< std::string, std::string > labels
description