47 y = scRef->clustersSize();
49 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax)
const{
50 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin &&
y<=nrClusMax;
61 y = scRef->clustersSize();
64 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax,
65 float phiMin,
float phiMax)
const{
66 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin &&
y<=nrClusMax
67 &&
z>=phiMin && z < phiMax;
79 y = scRef->clustersSize();
80 z = scRef->energy()*
sin(scRef->position().Theta());
82 bool pass(
float absEtaMin,
float absEtaMax,
size_t nrClusMin,
size_t nrClusMax,
83 float etMin,
float etMax)
const{
84 return x>=absEtaMin && x<absEtaMax && y>=nrClusMin &&
y<=nrClusMax
85 &&
z>=etMin && z < etMax;
94 template<
typename ParamType,
bool=true>
100 func_(
"func",funcExpr.c_str()){
101 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
102 func_.SetParameter(paraNr,params[paraNr]);
106 return func_.Eval(obj.x);
109 template<
typename ParamType>
116 template<
typename ParamType,
bool=true>
122 func_(
"func",funcExpr.c_str()){
123 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
124 func_.SetParameter(paraNr,params[paraNr]);
128 return func_.Eval(obj.x,obj.y);
131 template<
typename ParamType>
138 template<
typename ParamType,
bool=true>
144 func_(
"func",funcExpr.c_str()){
145 for(
size_t paraNr=0;paraNr<params.size();paraNr++){
146 func_.SetParameter(paraNr,params[paraNr]);
150 return func_.Eval(obj.x,obj.y,obj.z);
153 template<
typename ParamType>
191 template<
typename InputType>
201 size_t pos=inStr.find(
":=");
202 if(pos!=std::string::npos)
return std::make_pair(inStr.substr(0,pos),inStr.substr(pos+2));
205 template<
typename ParamType>
208 auto funcParams = config.
getParameter<std::vector<double> >(
"funcParams");
209 if(
funcType.first==
"TF1" && has1D<ParamType>(0))
return TF1Wrap<ParamType,has1D<ParamType>(0)>(
funcType.second,funcParams);
210 else if(
funcType.first==
"TF2" && has2D<ParamType>(0))
return TF2Wrap<ParamType,has2D<ParamType>(0)>(
funcType.second,funcParams);
211 else if(
funcType.first==
"TF3" && has3D<ParamType>(0))
return TF3Wrap<ParamType,has3D<ParamType>(0)>(
funcType.second,funcParams);
212 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;
216 template<
typename InputType,
typename ParamType>
221 std::function<float(const ParamType&)>
func_;
233 if(!
pass(input))
return 0;
234 else return func_(ParamType(input));
240 template<
typename InputType,
typename ParamType>
247 std::function<float(const ParamType&)>
func_;
262 if(!
pass(input))
return 0;
263 else return func_(ParamType(input));
268 template<
typename InputType,
typename ParamType>
277 std::function<float(const ParamType&)>
func_;
294 if(!
pass(input))
return 0;
295 else return func_(ParamType(input));
302 template<
typename InputType>
304 std::vector<std::unique_ptr<ParamBin<InputType> > >
bins_;
307 std::vector<edm::ParameterSet> binConfigs = config.
getParameter<std::vector<edm::ParameterSet> >(
"bins");
320 if(type==
"AbsEtaClus")
return std::make_unique<ParamBin2D<InputType,AbsEtaNrClus>>(
config);
321 else if(type==
"AbsEtaClusPhi")
return std::make_unique<ParamBin3D<InputType,AbsEtaNrClusPhi>>(
config);
322 else if(type==
"AbsEtaClusEt")
return std::make_unique<ParamBin3D<InputType,AbsEtaNrClusEt>>(
config);
323 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
float operator()(const InputType &input) const override
decltype(ParamType::x) XType
static std::pair< std::string, std::string > readFuncStr(const std::string &inStr)
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)
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
virtual bool pass(const InputType &) const =0
float operator()(const InputType &input) const override
auto has3D(int) -> decltype(T::z, bool())
static std::string const input
CaloClusterRef caloCluster() const
Param(const edm::ParameterSet &config)
AbsEtaNrClus(const reco::ElectronSeed &seed)
T x() const
Cartesian x coordinate.
ParamBin1D(const edm::ParameterSet &config)
std::function< float(const ParamType &)> func_
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)
bool pass(const InputType &input) const override
float operator()(const ParamType &obj)
Abs< T >::type abs(const T &t)
float operator()(const ParamType &obj)
float operator()(const InputType &input) const override
std::unique_ptr< ParamBin< InputType > > createParamBin_(const edm::ParameterSet &config)
bool pass(const InputType &input) const override
TF1Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
AbsEtaNrClusEt(const reco::ElectronSeed &seed)
decltype(ParamType::y) YType
TF3Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)
bool pass(const InputType &input) const override
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_
volatile std::atomic< bool > shutdown_flag false
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)
virtual float operator()(const InputType &) const =0
float operator()(const ParamType &obj)
float operator()(const ParamType &obj)
TF2Wrap(const std::string &funcExpr, const std::vector< double > ¶ms)