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 137 of file JetResolutionObject.h.

Constructor & Destructor Documentation

◆ Definition() [1/2]

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

Definition at line 139 of file JetResolutionObject.h.

139  {
140  // Empty
141  }

◆ Definition() [2/2]

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

Definition at line 155 of file JetResolutionObject.cc.

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().

155  {
156  std::vector<std::string> tokens = getTokens(definition);
157 
158  // We need at least 3 tokens
159  if (tokens.size() < 3) {
161  "Definition line needs at least three tokens. Please check file format.");
162  }
163 
164  size_t n_bins = std::stoul(tokens[0]);
165 
166  if (tokens.size() < (n_bins + 2)) {
167  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
168  }
169 
170  for (size_t i = 0; i < n_bins; i++) {
171  m_bins_name.push_back(tokens[i + 1]);
172  }
173 
174  size_t n_variables = std::stoul(tokens[n_bins + 1]);
175 
176  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1)) {
177  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
178  }
179 
180  for (size_t i = 0; i < n_variables; i++) {
181  m_variables_name.push_back(tokens[n_bins + 2 + i]);
182  }
183 
184  m_formula_str = tokens[n_bins + n_variables + 2];
185 
186  std::string formula_str_lower = m_formula_str;
187  std::transform(formula_str_lower.begin(), formula_str_lower.end(), formula_str_lower.begin(), ::tolower);
188 
189  if (formula_str_lower == "none") {
190  m_formula_str = "";
191 
192  if ((tokens.size() > n_bins + n_variables + 3) && (std::atoi(tokens[n_bins + n_variables + 3].c_str()))) {
193  size_t n_parameters = std::stoul(tokens[n_bins + n_variables + 3]);
194 
195  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1 + 1 + n_parameters)) {
196  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
197  }
198 
199  for (size_t i = 0; i < n_parameters; i++) {
200  m_formula_str += tokens[n_bins + n_variables + 4 + i] + " ";
201  }
202  }
203  }
204 
205  init();
206  }
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
void throwException(uint32_t code, const std::string &message)
unsigned transform(const HcalDetId &id, unsigned transformCode)

Member Function Documentation

◆ getBinName()

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

Definition at line 149 of file JetResolutionObject.h.

References newFWLiteAna::bin, and m_bins_name.

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

149 { return m_bins_name[bin]; }
std::vector< std::string > m_bins_name

◆ getBins()

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

Definition at line 147 of file JetResolutionObject.h.

References m_bins.

147 { return m_bins; }

◆ getBinsName()

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

◆ getFormula()

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

Definition at line 168 of file JetResolutionObject.h.

References m_formula.

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

168 { return m_formula.get(); }
std::shared_ptr< reco::FormulaEvaluator > m_formula

◆ getFormulaString()

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

◆ getParametersName()

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

Definition at line 161 of file JetResolutionObject.h.

References m_parameters_name.

161 { return m_parameters_name; }
std::vector< std::string > m_parameters_name

◆ getVariableName()

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

◆ getVariables()

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

Definition at line 155 of file JetResolutionObject.h.

References m_variables.

155 { return m_variables; }

◆ getVariablesName()

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

◆ init()

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

Definition at line 208 of file JetResolutionObject.cc.

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().

208  {
209  if (!m_formula_str.empty()) {
210  if (m_formula_str.find(' ') == std::string::npos)
211 #ifndef STANDALONE
212  m_formula = std::make_shared<reco::FormulaEvaluator>(m_formula_str);
213 #else
214  m_formula = std::make_shared<TFormula>("jet_resolution_formula", m_formula_str.c_str());
215 #endif
216  else
217  m_parameters_name = getTokens(m_formula_str);
218  }
219  for (const auto& bin : m_bins_name) {
220  const auto& b = JetParameters::binning_to_string.right.find(bin);
221  if (b == JetParameters::binning_to_string.right.cend()) {
222  throwException(edm::errors::UnimplementedFeature, "Bin name not supported: '" + bin + "'");
223  }
224  m_bins.push_back(b->second);
225  }
226 
227  for (const auto& v : m_variables_name) {
228  const auto& var = JetParameters::binning_to_string.right.find(v);
229  if (var == JetParameters::binning_to_string.right.cend()) {
230  throwException(edm::errors::UnimplementedFeature, "Variable name not supported: '" + v + "'");
231  }
232  m_variables.push_back(var->second);
233  }
234  }
std::vector< std::string > m_parameters_name
std::shared_ptr< reco::FormulaEvaluator > m_formula
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
right_type right
double b
Definition: hdecay.h:120
void throwException(uint32_t code, const std::string &message)
static const bimap< Binning, std::string > binning_to_string

◆ nBins()

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

◆ nParameters()

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

Definition at line 163 of file JetResolutionObject.h.

References m_parameters_name.

163 { return m_parameters_name.size(); }
std::vector< std::string > 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 188 of file JetResolutionObject.h.

◆ cond::serialization::access

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

Definition at line 188 of file JetResolutionObject.h.

Member Data Documentation

◆ m_bins

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

Definition at line 184 of file JetResolutionObject.h.

Referenced by getBins().

◆ m_bins_name

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

Definition at line 175 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 180 of file JetResolutionObject.h.

Referenced by getFormula().

◆ m_formula_str

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

Definition at line 177 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 186 of file JetResolutionObject.h.

Referenced by getParametersName(), and nParameters().

◆ m_variables

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

Definition at line 185 of file JetResolutionObject.h.

Referenced by getVariables().

◆ m_variables_name

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

Definition at line 176 of file JetResolutionObject.h.

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