50 y = scRef->clustersSize();
52 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax)
const{
53 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin && y<=nrClusMax;
64 y = scRef->clustersSize();
67 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax,
69 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin && y<=nrClusMax
70 && z>=phiMin && z <
phiMax;
82 y = scRef->clustersSize();
83 z = scRef->energy()*
sin(scRef->position().Theta());
85 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax,
87 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin && y<=nrClusMax
88 && z>=etMin && z <
etMax;
97 template<
typename ParamType,
bool=true>
103 func_(
"func",funcExpr.c_str()){
104 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
105 func_.SetParameter(paraNr,params[paraNr]);
109 return func_.Eval(obj.x);
112 template<
typename ParamType>
119 template<
typename ParamType,
bool=true>
125 func_(
"func",funcExpr.c_str()){
126 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
127 func_.SetParameter(paraNr,params[paraNr]);
131 return func_.Eval(obj.x,obj.y);
134 template<
typename ParamType>
141 template<
typename ParamType,
bool=true>
147 func_(
"func",funcExpr.c_str()){
148 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
149 func_.SetParameter(paraNr,params[paraNr]);
153 return func_.Eval(obj.x,obj.y,obj.z);
156 template<
typename ParamType>
194 template<
typename InputType>
200 virtual float operator()(
const InputType&)
const=0;
204 size_t pos=inStr.find(
":=");
205 if(pos!=std::string::npos)
return std::make_pair(inStr.substr(0,pos),inStr.substr(pos+2));
208 template<
typename ParamType>
211 auto funcParams = config.
getParameter<std::vector<double> >(
"funcParams");
212 if(
funcType.first==
"TF1" && has1D<ParamType>(0))
return TF1Wrap<ParamType,has1D<ParamType>(0)>(
funcType.second,funcParams);
213 else if(
funcType.first==
"TF2" && has2D<ParamType>(0))
return TF2Wrap<ParamType,has2D<ParamType>(0)>(
funcType.second,funcParams);
214 else if(
funcType.first==
"TF3" && has3D<ParamType>(0))
return TF3Wrap<ParamType,has3D<ParamType>(0)>(
funcType.second,funcParams);
215 else throw cms::Exception(
"InvalidConfig") <<
" type "<<
funcType.first<<
" is not recognised or is imcompatable with the ParamType, configuration is invalid and needs to be fixed"<<std::endl;
219 template<
typename InputType,
typename ParamType>
224 std::function<float(const ParamType&)>
func_;
233 return ParamType(input).pass(xMin_,xMax_);
236 if(!
pass(input))
return 0;
237 else return func_(ParamType(input));
243 template<
typename InputType,
typename ParamType>
250 std::function<float(const ParamType&)>
func_;
262 return ParamType(input).pass(xMin_,xMax_,yMin_,yMax_);
265 if(!
pass(input))
return 0;
266 else return func_(ParamType(input));
271 template<
typename InputType,
typename ParamType>
280 std::function<float(const ParamType&)>
func_;
294 return ParamType(input).pass(xMin_,xMax_,yMin_,yMax_,zMin_,zMax_);
297 if(!
pass(input))
return 0;
298 else return func_(ParamType(input));
305 template<
typename InputType>
307 std::vector<std::unique_ptr<ParamBin<InputType> > >
bins_;
310 std::vector<edm::ParameterSet> binConfigs = config.
getParameter<std::vector<edm::ParameterSet> >(
"bins");
311 for(
auto& binConfig : binConfigs) bins_.emplace_back(createParamBin_(binConfig));
314 for(
auto&
bin : bins_){
323 if(type==
"AbsEtaClus")
return std::make_unique<ParamBin2D<InputType,AbsEtaNrClus>>(
config);
324 else if(type==
"AbsEtaClusPhi")
return std::make_unique<ParamBin3D<InputType,AbsEtaNrClusPhi>>(
config);
325 else if(type==
"AbsEtaClusEt")
return std::make_unique<ParamBin3D<InputType,AbsEtaNrClusEt>>(
config);
326 else throw cms::Exception(
"InvalidConfig") <<
" type "<<type<<
" is not recognised, configuration is invalid and needs to be fixed"<<std::endl;
T getParameter(std::string const &) const
decltype(ParamType::x) XType
static std::pair< std::string, std::string > readFuncStr(const std::string &inStr)
float operator()(const InputType &input) const override
decltype(ParamType::x) XType
std::function< float(const ParamType &)> func_
ParamBin2D(const edm::ParameterSet &config)
bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax, float etMin, float etMax) const
Sin< T >::type sin(const T &t)
AbsEtaNrClusPhi(const reco::ElectronSeed &seed)
const CaloClusterRef & caloCluster() const
TF2Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
float operator()(const ParamType &obj)
bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax, float phiMin, float phiMax) const
auto has3D(int) -> decltype(T::z, bool())
static std::string const input
Param(const edm::ParameterSet &config)
AbsEtaNrClus(const reco::ElectronSeed &seed)
bool pass(const InputType &input) const override
bool pass(const InputType &input) const override
ParamBin1D(const edm::ParameterSet &config)
std::function< float(const ParamType &)> func_
float operator()(const InputType &input) const override
auto has2D(int) -> decltype(T::y, bool())
static std::function< float(const ParamType &)> makeFunc(const edm::ParameterSet &config)
TF1Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
float operator()(const ParamType &obj)
Abs< T >::type abs(const T &t)
float operator()(const ParamType &obj)
def template(fileName, svg, replaceme="REPLACEME")
std::unique_ptr< ParamBin< InputType > > createParamBin_(const edm::ParameterSet &config)
TF1Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
bin
set the eta bin as selection string.
AbsEtaNrClusEt(const reco::ElectronSeed &seed)
decltype(ParamType::y) YType
bool pass(const InputType &input) const override
TF3Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
float operator()(const InputType &input) const
decltype(ParamType::z) ZType
std::function< float(const ParamType &)> func_
TF3Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
std::vector< std::unique_ptr< ParamBin< InputType > > > bins_
float operator()(const InputType &input) const override
auto has1D(int) -> decltype(T::x, bool())
decltype(ParamType::y) YType
bool pass(float absEtaMin, float absEtaMax, size_t nrClusMin, size_t nrClusMax) const
float operator()(const ParamType &obj)
decltype(ParamType::x) XType
ParamBin3D(const edm::ParameterSet &config)
float operator()(const ParamType &obj)
float operator()(const ParamType &obj)
TF2Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)