CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Friends
JME::JetResolutionObject::Definition Class Reference

#include <JetResolutionObject.h>

Public Member Functions

 Definition ()
 
 Definition (const std::string &definition)
 
std::string getBinName (size_t bin) const
 
const std::vector< Binning > & getBins () const
 
const std::vector< std::string > & getBinsName () const
 
const reco::FormulaEvaluatorgetFormula () const
 
std::string getFormulaString () const
 
const std::vector< std::string > & getParametersName () const
 
std::string getVariableName (size_t variable) const
 
const std::vector< Binning > & getVariables () const
 
const std::vector< std::string > & getVariablesName () const
 
void init ()
 
size_t nBins () const
 
size_t nParameters () const
 
size_t nVariables () const
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Private Attributes

std::vector< Binningm_bins
 
std::vector< std::string > m_bins_name
 
std::shared_ptr< reco::FormulaEvaluatorm_formula
 
std::string m_formula_str
 
std::vector< std::string > m_parameters_name
 
std::vector< Binningm_variables
 
std::vector< std::string > m_variables_name
 

Friends

class boost::serialization::access
 
template<typename CondSerializationT , typename Enabled >
struct cond::serialization::access
 

Detailed Description

Definition at line 136 of file JetResolutionObject.h.

Constructor & Destructor Documentation

◆ Definition() [1/2]

JME::JetResolutionObject::Definition::Definition ( )
inline

Definition at line 138 of file JetResolutionObject.h.

138  {
139  // Empty
140  }

◆ Definition() [2/2]

JME::JetResolutionObject::Definition::Definition ( const std::string &  definition)

Definition at line 133 of file JetResolutionObject.cc.

133  {
134  std::vector<std::string> tokens = getTokens(definition);
135 
136  // We need at least 3 tokens
137  if (tokens.size() < 3) {
139  "Definition line needs at least three tokens. Please check file format.");
140  }
141 
142  size_t n_bins = std::stoul(tokens[0]);
143 
144  if (tokens.size() < (n_bins + 2)) {
145  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
146  }
147 
148  for (size_t i = 0; i < n_bins; i++) {
149  m_bins_name.push_back(tokens[i + 1]);
150  }
151 
152  size_t n_variables = std::stoul(tokens[n_bins + 1]);
153 
154  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1)) {
155  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
156  }
157 
158  for (size_t i = 0; i < n_variables; i++) {
159  m_variables_name.push_back(tokens[n_bins + 2 + i]);
160  }
161 
162  m_formula_str = tokens[n_bins + n_variables + 2];
163 
164  std::string formula_str_lower = m_formula_str;
165  std::transform(formula_str_lower.begin(), formula_str_lower.end(), formula_str_lower.begin(), ::tolower);
166 
167  if (formula_str_lower == "none") {
168  m_formula_str = "";
169 
170  if ((tokens.size() > n_bins + n_variables + 3) && (std::atoi(tokens[n_bins + n_variables + 3].c_str()))) {
171  size_t n_parameters = std::stoul(tokens[n_bins + n_variables + 3]);
172 
173  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1 + 1 + n_parameters)) {
174  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
175  }
176 
177  for (size_t i = 0; i < n_parameters; i++) {
178  m_formula_str += tokens[n_bins + n_variables + 4 + i] + " ";
179  }
180  }
181  }
182 
183  init();
184  }

References edm::errors::ConfigFileReadError, mps_fire::i, init(), m_bins_name, m_formula_str, m_variables_name, AlCaHLTBitMon_QueryRunRegistry::string, JME::throwException(), and HcalDetIdTransform::transform().

Member Function Documentation

◆ getBinName()

std::string JME::JetResolutionObject::Definition::getBinName ( size_t  bin) const
inline

Definition at line 148 of file JetResolutionObject.h.

148 { return m_bins_name[bin]; }

References newFWLiteAna::bin, and m_bins_name.

Referenced by JME::JetResolutionObject::dump().

◆ getBins()

const std::vector<Binning>& JME::JetResolutionObject::Definition::getBins ( ) const
inline

Definition at line 146 of file JetResolutionObject.h.

146 { return m_bins; }

References m_bins.

Referenced by JME::JetResolutionObject::getRecord().

◆ getBinsName()

const std::vector<std::string>& JME::JetResolutionObject::Definition::getBinsName ( ) const
inline

Definition at line 144 of file JetResolutionObject.h.

144 { return m_bins_name; }

References m_bins_name.

Referenced by JME::JetResolutionObject::dump(), and JME::JetResolutionObject::saveToFile().

◆ getFormula()

const reco::FormulaEvaluator* JME::JetResolutionObject::Definition::getFormula ( ) const
inline

Definition at line 167 of file JetResolutionObject.h.

167 { return m_formula.get(); }

References m_formula.

Referenced by JME::JetResolutionObject::evaluateFormula().

◆ getFormulaString()

std::string JME::JetResolutionObject::Definition::getFormulaString ( ) const
inline

Definition at line 164 of file JetResolutionObject.h.

164 { return m_formula_str; }

References m_formula_str.

Referenced by JME::JetResolutionObject::dump(), and JME::JetResolutionObject::saveToFile().

◆ getParametersName()

const std::vector<std::string>& JME::JetResolutionObject::Definition::getParametersName ( ) const
inline

Definition at line 160 of file JetResolutionObject.h.

160 { return m_parameters_name; }

References m_parameters_name.

◆ getVariableName()

std::string JME::JetResolutionObject::Definition::getVariableName ( size_t  variable) const
inline

Definition at line 156 of file JetResolutionObject.h.

156 { return m_variables_name[variable]; }

References m_variables_name, and taus_updatedMVAIds_cff::variable.

Referenced by JME::JetResolutionObject::dump().

◆ getVariables()

const std::vector<Binning>& JME::JetResolutionObject::Definition::getVariables ( ) const
inline

Definition at line 154 of file JetResolutionObject.h.

154 { return m_variables; }

References m_variables.

Referenced by JME::JetResolutionObject::evaluateFormula().

◆ getVariablesName()

const std::vector<std::string>& JME::JetResolutionObject::Definition::getVariablesName ( ) const
inline

Definition at line 152 of file JetResolutionObject.h.

152 { return m_variables_name; }

References m_variables_name.

Referenced by JME::JetResolutionObject::dump(), and JME::JetResolutionObject::saveToFile().

◆ init()

void JME::JetResolutionObject::Definition::init ( void  )

Definition at line 186 of file JetResolutionObject.cc.

186  {
187  if (!m_formula_str.empty()) {
188  if (m_formula_str.find(' ') == std::string::npos)
189 #ifndef STANDALONE
190  m_formula = std::make_shared<reco::FormulaEvaluator>(m_formula_str);
191 #else
192  m_formula = std::make_shared<TFormula>("jet_resolution_formula", m_formula_str.c_str());
193 #endif
194  else
195  m_parameters_name = getTokens(m_formula_str);
196  }
197  for (const auto& bin : m_bins_name) {
198  const auto& b = JetParameters::binning_to_string.right.find(bin);
199  if (b == JetParameters::binning_to_string.right.cend()) {
200  throwException(edm::errors::UnimplementedFeature, "Bin name not supported: '" + bin + "'");
201  }
202  m_bins.push_back(b->second);
203  }
204 
205  for (const auto& v : m_variables_name) {
206  const auto& var = JetParameters::binning_to_string.right.find(v);
207  if (var == JetParameters::binning_to_string.right.cend()) {
208  throwException(edm::errors::UnimplementedFeature, "Variable name not supported: '" + v + "'");
209  }
210  m_variables.push_back(var->second);
211  }
212  }

References b, newFWLiteAna::bin, JME::JetParameters::binning_to_string, JME::bimap< T, U >::right, JME::throwException(), edm::errors::UnimplementedFeature, findQualityFiles::v, and trigObjTnPSource_cfi::var.

Referenced by Definition(), and JME::JetResolutionObject::JetResolutionObject().

◆ nBins()

size_t JME::JetResolutionObject::Definition::nBins ( ) const
inline

◆ nParameters()

size_t JME::JetResolutionObject::Definition::nParameters ( ) const
inline

Definition at line 162 of file JetResolutionObject.h.

162 { return m_parameters_name.size(); }

References m_parameters_name.

◆ nVariables()

size_t JME::JetResolutionObject::Definition::nVariables ( ) const
inline

◆ serialize()

template<class Archive >
void JME::JetResolutionObject::Definition::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 187 of file JetResolutionObject.h.

◆ cond::serialization::access

template<typename CondSerializationT , typename Enabled >
friend struct cond::serialization::access
friend

Definition at line 187 of file JetResolutionObject.h.

Member Data Documentation

◆ m_bins

std::vector<Binning> JME::JetResolutionObject::Definition::m_bins
private

Definition at line 183 of file JetResolutionObject.h.

Referenced by getBins().

◆ m_bins_name

std::vector<std::string> JME::JetResolutionObject::Definition::m_bins_name
private

Definition at line 174 of file JetResolutionObject.h.

Referenced by Definition(), getBinName(), getBinsName(), and nBins().

◆ m_formula

std::shared_ptr<reco::FormulaEvaluator> JME::JetResolutionObject::Definition::m_formula
private

Definition at line 179 of file JetResolutionObject.h.

Referenced by getFormula().

◆ m_formula_str

std::string JME::JetResolutionObject::Definition::m_formula_str
private

Definition at line 176 of file JetResolutionObject.h.

Referenced by Definition(), and getFormulaString().

◆ m_parameters_name

std::vector<std::string> JME::JetResolutionObject::Definition::m_parameters_name
private

Definition at line 185 of file JetResolutionObject.h.

Referenced by getParametersName(), and nParameters().

◆ m_variables

std::vector<Binning> JME::JetResolutionObject::Definition::m_variables
private

Definition at line 184 of file JetResolutionObject.h.

Referenced by getVariables(), and nVariables().

◆ m_variables_name

std::vector<std::string> JME::JetResolutionObject::Definition::m_variables_name
private

Definition at line 175 of file JetResolutionObject.h.

Referenced by Definition(), getVariableName(), and getVariablesName().

mps_fire.i
i
Definition: mps_fire.py:428
JME::JetResolutionObject::Definition::m_variables_name
std::vector< std::string > m_variables_name
Definition: JetResolutionObject.h:175
findQualityFiles.v
v
Definition: findQualityFiles.py:179
JME::JetResolutionObject::Definition::m_variables
std::vector< Binning > m_variables
Definition: JetResolutionObject.h:184
trigObjTnPSource_cfi.var
var
Definition: trigObjTnPSource_cfi.py:21
JME::bimap::right
right_type right
Definition: JetResolutionObject.h:43
JME::JetResolutionObject::Definition::m_formula_str
std::string m_formula_str
Definition: JetResolutionObject.h:176
JME::throwException
void throwException(uint32_t code, const std::string &message)
Definition: JetResolutionObject.cc:36
JME::JetParameters::binning_to_string
static const bimap< Binning, std::string > binning_to_string
Definition: JetResolutionObject.h:108
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
b
double b
Definition: hdecay.h:118
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
taus_updatedMVAIds_cff.variable
variable
Definition: taus_updatedMVAIds_cff.py:33
edm::errors::ConfigFileReadError
Definition: EDMException.h:25
JME::JetResolutionObject::Definition::m_parameters_name
std::vector< std::string > m_parameters_name
Definition: JetResolutionObject.h:185
JME::JetResolutionObject::Definition::init
void init()
Definition: JetResolutionObject.cc:186
JME::JetResolutionObject::Definition::m_bins
std::vector< Binning > m_bins
Definition: JetResolutionObject.h:183
JME::JetResolutionObject::Definition::m_bins_name
std::vector< std::string > m_bins_name
Definition: JetResolutionObject.h:174
JME::JetResolutionObject::Definition::m_formula
std::shared_ptr< reco::FormulaEvaluator > m_formula
Definition: JetResolutionObject.h:179
edm::errors::UnimplementedFeature
Definition: EDMException.h:38