CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
JetResolution Class Reference

#include <JetResolution.h>

Public Member Functions

void initialize (const std::string &fileName, bool doGaussian=false)
 
 JetResolution ()
 
 JetResolution (const std::string &fileName, bool doGaussian=false)
 
const std::string & name () const
 
TF1 * parameter (const std::string &parameterName, const std::vector< float > &x)
 
TF1 * parameterEta (const std::string &parameterName, float eta)
 
const JetCorrectorParametersparameters (int i) const
 
TF1 * resolution (const std::vector< float > &x, const std::vector< float > &y) const
 
TF1 * resolutionEtaPt (float eta, float pt) const
 
virtual ~JetResolution ()
 

Private Attributes

std::string name_
 
std::vector< TF1 * > parameterFncs_
 
std::vector
< JetCorrectorParameters * > 
parameters_
 
TF1 * resolutionFnc_
 

Detailed Description

Definition at line 13 of file JetResolution.h.

Constructor & Destructor Documentation

JetResolution::JetResolution ( )

Definition at line 40 of file JetResolution.cc.

References resolutionFnc_.

41  : resolutionFnc_(0)
42 {
43  resolutionFnc_ = new TF1();
44 }
TF1 * resolutionFnc_
Definition: JetResolution.h:46
JetResolution::JetResolution ( const std::string &  fileName,
bool  doGaussian = false 
)
JetResolution::~JetResolution ( )
virtual

Definition at line 56 of file JetResolution.cc.

References i, parameterFncs_, parameters_, and resolutionFnc_.

57 {
58  delete resolutionFnc_;
59  for (unsigned i=0;i<parameterFncs_.size();i++) delete parameterFncs_[i];
60  for (unsigned i=0;i<parameters_.size();i++) delete parameters_[i];
61 }
int i
Definition: DBlmapReader.cc:9
TF1 * resolutionFnc_
Definition: JetResolution.h:46
std::vector< TF1 * > parameterFncs_
Definition: JetResolution.h:47
std::vector< JetCorrectorParameters * > parameters_
Definition: JetResolution.h:48

Member Function Documentation

void JetResolution::initialize ( const std::string &  fileName,
bool  doGaussian = false 
)

Definition at line 69 of file JetResolution.cc.

References JetCorrectorParameters::definitions(), convertXMLtoSQLite_cfg::fileName, fnc_dscb(), fnc_gaussalpha(), fnc_gaussalpha1alpha2(), JetCorrectorParameters::Definitions::formula(), EcalElecEmulExample_cfg::formula, JetCorrectorParameters::Definitions::level(), name(), name_, parameterFncs_, parameters_, pos, resolutionFnc_, and tmp.

70 {
71  size_t pos;
72 
73  name_ = fileName;
74  pos = name_.find_last_of('.'); name_ = name_.substr(0,pos);
75  pos = name_.find_last_of('/'); name_ = name_.substr(pos+1);
76 
77  JetCorrectorParameters resolutionPars(fileName,"resolution");
78  string fncname = "fResolution_" + name_;
79  string formula = resolutionPars.definitions().formula();
80  if (doGaussian) resolutionFnc_=new TF1(fncname.c_str(),"gaus",0.,5.);
81  else if (formula=="DSCB") resolutionFnc_=new TF1(fncname.c_str(),fnc_dscb,0.,5.,7);
82  else if (formula=="GaussAlpha1Alpha2") resolutionFnc_=new TF1(fncname.c_str(),fnc_gaussalpha1alpha2,-5.,5.,5);
83  else if (formula=="GaussAlpha") resolutionFnc_=new TF1(fncname.c_str(),fnc_gaussalpha,-5.,5.,4);
84  else resolutionFnc_=new TF1(fncname.c_str(),formula.c_str(),0.,5.);
85 
86  resolutionFnc_->SetNpx(200);
87  resolutionFnc_->SetParName(0,"N");
88  resolutionFnc_->SetParameter(0,1.0);
89  unsigned nPar(1);
90 
91  string tmp = resolutionPars.definitions().level();
92  pos = tmp.find(':');
93  while (!tmp.empty()) {
94  string paramAsStr = tmp.substr(0,pos);
95  if (!doGaussian||paramAsStr=="mean"||paramAsStr=="sigma") {
96  parameters_.push_back(new JetCorrectorParameters(fileName,paramAsStr));
97  formula = parameters_.back()->definitions().formula();
98  parameterFncs_.push_back(new TF1(("f"+paramAsStr+"_"+name()).c_str(),formula.c_str(),
99  parameters_.back()->record(0).parameters()[0],
100  parameters_.back()->record(0).parameters()[1]));
101  resolutionFnc_->SetParName(nPar,parameters_.back()->definitions().level().c_str());
102  nPar++;
103  }
104  tmp = (pos==string::npos) ? "" : tmp.substr(pos+1);
105  pos = tmp.find(':');
106  }
107 
108  assert(nPar==(unsigned)resolutionFnc_->GetNpar());
109  assert(!doGaussian||nPar==3);
110 }
const std::string & name() const
Definition: JetResolution.h:30
std::string name_
Definition: JetResolution.h:45
TF1 * resolutionFnc_
Definition: JetResolution.h:46
double fnc_dscb(double *xx, double *pp)
double fnc_gaussalpha(double *xx, double *pp)
std::vector< TF1 * > parameterFncs_
Definition: JetResolution.h:47
std::vector< JetCorrectorParameters * > parameters_
Definition: JetResolution.h:48
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double fnc_gaussalpha1alpha2(double *xx, double *pp)
const std::string& JetResolution::name ( ) const
inline

Definition at line 30 of file JetResolution.h.

References name_.

Referenced by BeautifulSoup.Tag::_invert(), initialize(), and Vispa.Views.PropertyView.Property::valueChanged().

30 { return name_; }
std::string name_
Definition: JetResolution.h:45
TF1 * JetResolution::parameter ( const std::string &  parameterName,
const std::vector< float > &  x 
)

Definition at line 153 of file JetResolution.cc.

References newFWLiteAna::bin, dtNoiseDBValidation_cfg::cerr, i, N, parameterFncs_, parameters_, query::result, and findQualityFiles::size.

Referenced by parameterEta().

154 {
155  TF1* result(0);
156  for (unsigned i=0;i<parameterFncs_.size()&&result==0;i++) {
157  string fncname = parameterFncs_[i]->GetName();
158  if (fncname.find("f"+parameterName)==0) {
159  stringstream ssname; ssname<<parameterFncs_[i]->GetName();
160  for (unsigned ii=0;ii<x.size();ii++)
161  ssname<<"_"<<parameters_[i]->definitions().binVar(ii)<<x[ii];
162  result = (TF1*)parameterFncs_[i]->Clone();
163  result->SetName(ssname.str().c_str());
164  int N = parameters_[i]->definitions().nParVar();
165  int bin = parameters_[i]->binIndex(x);
166  assert(bin>=0);
167  assert(bin<(int)parameters_[i]->size());
168  const std::vector<float>& pars = parameters_[i]->record(bin).parameters();
169  for (unsigned ii=2*N;ii<pars.size();ii++) result->SetParameter(ii-2*N,pars[ii]);
170  }
171  }
172 
173  if (0==result) cerr<<"JetResolution::parameter() ERROR: no parameter "
174  <<parameterName<<" found."<<endl;
175 
176  return result;
177 }
int i
Definition: DBlmapReader.cc:9
std::vector< TF1 * > parameterFncs_
Definition: JetResolution.h:47
std::vector< JetCorrectorParameters * > parameters_
Definition: JetResolution.h:48
tuple result
Definition: query.py:137
#define N
Definition: blowfish.cc:9
Definition: DDAxes.h:10
tuple size
Write out results.
TF1 * JetResolution::parameterEta ( const std::string &  parameterName,
float  eta 
)

Definition at line 145 of file JetResolution.cc.

References parameter(), and x.

Referenced by main().

146 {
147  vector<float> x; x.push_back(eta);
148  return parameter(parameterName,x);
149 }
T eta() const
TF1 * parameter(const std::string &parameterName, const std::vector< float > &x)
Definition: DDAxes.h:10
const JetCorrectorParameters& JetResolution::parameters ( int  i) const
inline
TF1 * JetResolution::resolution ( const std::vector< float > &  x,
const std::vector< float > &  y 
) const

Definition at line 123 of file JetResolution.cc.

References newFWLiteAna::bin, i, N, parameterFncs_, parameters_, resolutionFnc_, and findQualityFiles::size.

Referenced by resolutionEtaPt().

125 {
126  unsigned N(y.size());
127  for (unsigned iPar=0;iPar<parameters_.size();iPar++) {
128  int bin = parameters_[iPar]->binIndex(x);
129  assert(bin>=0);
130  assert(bin<(int)parameters_[iPar]->size());
131  const std::vector<float>& pars = parameters_[iPar]->record(bin).parameters();
132  for (unsigned i=2*N;i<pars.size();i++)
133  parameterFncs_[iPar]->SetParameter(i-2*N,pars[i]);
134  float yy[4];
135  for (unsigned i=0;i<N;i++)
136  yy[i] = (y[i] < pars[2*i]) ? pars[2*i] : (y[i] > pars[2*i+1]) ? pars[2*i+1] : y[i];
137  resolutionFnc_->SetParameter(iPar+1,
138  parameterFncs_[iPar]->Eval(yy[0],yy[1],yy[2],yy[3]));
139  }
140  return resolutionFnc_;
141 }
int i
Definition: DBlmapReader.cc:9
TF1 * resolutionFnc_
Definition: JetResolution.h:46
std::vector< TF1 * > parameterFncs_
Definition: JetResolution.h:47
std::vector< JetCorrectorParameters * > parameters_
Definition: JetResolution.h:48
#define N
Definition: blowfish.cc:9
Definition: DDAxes.h:10
tuple size
Write out results.
TF1 * JetResolution::resolutionEtaPt ( float  eta,
float  pt 
) const

Definition at line 114 of file JetResolution.cc.

References resolution(), x, and detailsBasic3DVector::y.

Referenced by main().

115 {
116  vector<float> x; x.push_back(eta);
117  vector<float> y; y.push_back(pt);
118  return resolution(x,y);
119 }
T eta() const
TF1 * resolution(const std::vector< float > &x, const std::vector< float > &y) const
Definition: DDAxes.h:10

Member Data Documentation

std::string JetResolution::name_
private

Definition at line 45 of file JetResolution.h.

Referenced by initialize(), and name().

std::vector<TF1*> JetResolution::parameterFncs_
private

Definition at line 47 of file JetResolution.h.

Referenced by initialize(), parameter(), resolution(), and ~JetResolution().

std::vector<JetCorrectorParameters*> JetResolution::parameters_
private
TF1* JetResolution::resolutionFnc_
mutableprivate

Definition at line 46 of file JetResolution.h.

Referenced by initialize(), JetResolution(), resolution(), and ~JetResolution().