/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
PhysicsTools/UtilAlgos/plugins/VariableEventSelector.h
84 строки
3 KB
Tamas
Deprecate VariableHelperService
29 июл 2025, 22:42
29 июл 2025, 22:42
f3ac579
Код
Авторство
О чём код?
#ifndef _VariableEventSelector_H #define _VariableEventSelector_H #include "FWCore/Framework/interface/ConsumesCollector.h" #include "CommonTools/UtilAlgos/interface/EventSelector.h" #include "TFormula.h" #include "TString.h" class VariableFormulaEventSelector : public EventSelector { public: VariableFormulaEventSelector(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC) : VariableFormulaEventSelector(pset, iC) {} VariableFormulaEventSelector(const edm::ParameterSet& pset, edm::ConsumesCollector& iC) : EventSelector(pset, iC) { const std::string name_ = pset.getParameter<std::string>("fname"); TString ts(pset.getParameter<std::string>("formula")); //find the variables. register and replace int open = ts.Index("["); int close = ts.Index("]"); while (open > 0) { ++open; TString sub(ts(open, close - open)); //std::cout<<"found:"<< sub <<std::endl; vars_.insert(sub.Data()); //vars_.insert( ts(open,close-open)); open = ts.Index("[", open); close = ts.Index("]", open); } unsigned int v_i; std::set<std::string>::iterator v_it; for (v_i = 0, v_it = vars_.begin(); v_i != vars_.size(); ++v_i, ++v_it) { ts.ReplaceAll(TString::Format("[%s]", v_it->c_str()), TString::Format("[%d]", v_i)); } //std::cout<<" formula found:"<< ts <<std::endl; formula_ = new TFormula(name_.c_str(), ts); //vars_ = pset.getParameter<std::vector<std::string>>("variables"); threshold_ = pset.getParameter<double>("threshold"); } private: //std::string formula_; TFormula* formula_; std::set<std::string> vars_; double threshold_; }; class VariableEventSelector : public EventSelector { public: VariableEventSelector(const edm::ParameterSet& pset, edm::ConsumesCollector&& iC) : VariableEventSelector(pset, iC) {} VariableEventSelector(const edm::ParameterSet& pset, edm::ConsumesCollector& iC) : EventSelector(pset, iC) { var_ = pset.getParameter<std::string>("var"); doMin_ = pset.exists("min"); if (doMin_) min_ = pset.getParameter<double>("min"); doMax_ = pset.exists("max"); if (doMax_) max_ = pset.getParameter<double>("max"); std::stringstream ss; ss << "event selector based on VariableHelper variable: " << var_; description_.push_back(ss.str()); ss.str(""); if (doMin_) { ss << "with minimum boundary: " << min_; description_.push_back(ss.str()); ss.str(""); } if (doMax_) { ss << "with maximum boundary: " << max_; description_.push_back(ss.str()); ss.str(""); } } private: std::string var_; bool doMin_; double min_; bool doMax_; double max_; }; #endif