79 string fncname =
"fResolution_" +
name_;
81 if (doGaussian)
resolutionFnc_=
new TF1(fncname.c_str(),
"gaus",0.,5.);
85 else resolutionFnc_=
new TF1(fncname.c_str(),formula.c_str(),0.,5.);
87 resolutionFnc_->SetNpx(200);
88 resolutionFnc_->SetParName(0,
"N");
89 resolutionFnc_->SetParameter(0,1.0);
94 while (!tmp.empty()) {
95 string paramAsStr = tmp.substr(0,pos);
96 if (!doGaussian||paramAsStr==
"mean"||paramAsStr==
"sigma") {
98 formula =
parameters_.back()->definitions().formula();
102 resolutionFnc_->SetParName(nPar,
parameters_.back()->definitions().level().c_str());
105 tmp = (pos==string::npos) ?
"" : tmp.substr(pos+1);
109 assert(nPar==(
unsigned)resolutionFnc_->GetNpar());
110 assert(!doGaussian||nPar==3);
117 vector<float>
x; x.push_back(eta);
118 vector<float>
y; y.push_back(pt);
125 const vector<float>&
y)
const
127 unsigned N(y.size());
128 for (
unsigned iPar=0;iPar<
parameters_.size();iPar++) {
132 const std::vector<float>& pars =
parameters_[iPar]->record(bin).parameters();
133 for (
unsigned i=2*
N;
i<pars.size();
i++)
136 for (
unsigned i=0;i<
N;i++)
137 yy[i] = (y[i] < pars[2*i]) ? pars[2*
i] : (y[
i] > pars[2*i+1]) ? pars[2*i+1] : y[i];
148 vector<float>
x; x.push_back(eta);
159 if (fncname.find(
"f"+parameterName)==0) {
161 for (
unsigned ii=0;
ii<x.size();
ii++)
164 result->SetName(ssname.str().c_str());
169 const std::vector<float>& pars =
parameters_[
i]->record(bin).parameters();
170 for (
unsigned ii=2*N;
ii<pars.size();
ii++) result->SetParameter(
ii-2*N,pars[
ii]);
174 if (0==result)
cerr<<
"JetResolution::parameter() ERROR: no parameter "
175 <<parameterName<<
" found."<<endl;
189 if ( !(fncname.find(
"f"+parameterName) == 0) )
continue;
196 edm::LogError(
"ParameterNotFound") <<
"JetResolution::parameterEtaEval(): no parameter \""
197 << parameterName <<
"\" found" << std::endl;
199 std::vector<float> etas; etas.push_back(eta);
202 if ( !(0 <= bin && bin < (
int)params->
size() ) )
203 edm::LogError(
"ParameterNotFound") <<
"JetResolution::parameterEtaEval(): bin out of range: "
209 for (
unsigned ii = 2*N;
ii < pars.size(); ++
ii)
211 func->SetParameter(
ii-2*N, pars[
ii]);
214 return func->Eval(pt);
234 double u = (x-
mu)/sig;
235 double A1 = TMath::Power(p1/TMath::Abs(a1),p1)*TMath::Exp(-a1*a1/2);
236 double A2 = TMath::Power(p2/TMath::Abs(a2),p2)*TMath::Exp(-a2*a2/2);
237 double B1 = p1/TMath::Abs(a1) - TMath::Abs(a1);
238 double B2 = p2/TMath::Abs(a2) - TMath::Abs(a2);
241 if (u<-a1) result *= A1*TMath::Power(B1-u,-p1);
242 else if (u<a2) result *= TMath::Exp(-u*u/2);
243 else result *= A2*TMath::Power(B2+u,-p2);
255 double t =TMath::Abs((v[0]-mean)/sigma);
257 return (t<=cut) ? N*TMath::Exp(-0.5*t*t) : N*TMath::Exp(-0.5*(alpha*(t-cut)+cut*cut));
266 double sigma =par[2];
267 double alpha1=par[3];
268 double alpha2=par[4];
269 double t =TMath::Abs((v[0]-mean)/sigma);
272 (t<=cut) ? N*TMath::Exp(-0.5*t*t) :
273 ((v[0]-
mean)>=0) ? N*TMath::Exp(-0.5*(alpha1*(t-cut)+cut*cut)) :
274 N*TMath::Exp(-0.5*(alpha2*(t-cut)+cut*cut));
const std::string & name() const
void initialize(const std::string &fileName, bool doGaussian=false)
double fnc_dscb(double *xx, double *pp)
TF1 * parameterEta(const std::string ¶meterName, float eta)
double fnc_gaussalpha(double *xx, double *pp)
std::vector< float > parameters() const
const Definitions & definitions() const
std::vector< TF1 * > parameterFncs_
const Record & record(unsigned fBin) const
std::vector< JetCorrectorParameters * > parameters_
double parameterEtaEval(const std::string ¶meterName, float eta, float pt)
std::string formula() const
int binIndex(const std::vector< float > &fX) const
TF1 * resolution(const std::vector< float > &x, const std::vector< float > &y) const
TF1 * parameter(const std::string ¶meterName, const std::vector< float > &x)
std::string level() const
std::vector< std::vector< double > > tmp
TF1 * resolutionEtaPt(float eta, float pt) const
double fnc_gaussalpha1alpha2(double *xx, double *pp)
tuple size
Write out results.