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 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
 
TFormula * getFormula () const
 
std::string getFormulaString () 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 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< TFormula > m_formula
 
std::string m_formula_str
 
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 144 of file JetResolutionObject.h.

Constructor & Destructor Documentation

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

Definition at line 147 of file JetResolutionObject.h.

147  {
148  // Empty
149  }
JME::JetResolutionObject::Definition::Definition ( const std::string &  definition)

Definition at line 138 of file JetResolutionObject.cc.

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

138  {
139 
140  std::vector<std::string> tokens = getTokens(definition);
141 
142  // We need at least 3 tokens
143  if (tokens.size() < 3) {
144  throwException(edm::errors::ConfigFileReadError, "Definition line needs at least three tokens. Please check file format.");
145  }
146 
147  size_t n_bins = std::stoul(tokens[0]);
148 
149  if (tokens.size() < (n_bins + 2)) {
150  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
151  }
152 
153  for (size_t i = 0; i < n_bins; i++) {
154  m_bins_name.push_back(tokens[i + 1]);
155  }
156 
157  size_t n_variables = std::stoul(tokens[n_bins + 1]);
158 
159  if (tokens.size() < (1 + n_bins + 1 + n_variables + 1)) {
160  throwException(edm::errors::ConfigFileReadError, "Invalid file format. Please check.");
161  }
162 
163  for (size_t i = 0; i < n_variables; i++) {
164  m_variables_name.push_back(tokens[n_bins + 2 + i]);
165  }
166 
167  m_formula_str = tokens[n_bins + n_variables + 2];
168 
169  std::string formula_str_lower = m_formula_str;
170  std::transform(formula_str_lower.begin(), formula_str_lower.end(), formula_str_lower.begin(), ::tolower);
171 
172  if (formula_str_lower == "none")
173  m_formula_str = "";
174 
175  init();
176  }
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
void throwException(uint32_t code, const std::string &message)

Member Function Documentation

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

Definition at line 161 of file JetResolutionObject.h.

References newFWLiteAna::bin, and m_bins_name.

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

161  {
162  return m_bins_name[bin];
163  }
std::vector< std::string > m_bins_name
const std::vector<Binning>& JME::JetResolutionObject::Definition::getBins ( ) const
inline

Definition at line 157 of file JetResolutionObject.h.

References m_bins.

Referenced by JetResolutionDemo::analyze(), and JME::JetResolutionObject::getRecord().

157  {
158  return m_bins;
159  }
const std::vector<std::string>& JME::JetResolutionObject::Definition::getBinsName ( ) const
inline

Definition at line 153 of file JetResolutionObject.h.

References m_bins_name.

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

153  {
154  return m_bins_name;
155  }
std::vector< std::string > m_bins_name
TFormula* JME::JetResolutionObject::Definition::getFormula ( ) const
inline

Definition at line 189 of file JetResolutionObject.h.

References m_formula.

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

189  {
190  return m_formula.get();
191  }
std::shared_ptr< TFormula > m_formula
std::string JME::JetResolutionObject::Definition::getFormulaString ( ) const
inline

Definition at line 185 of file JetResolutionObject.h.

References m_formula_str.

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

185  {
186  return m_formula_str;
187  }
std::string JME::JetResolutionObject::Definition::getVariableName ( size_t  variable) const
inline

Definition at line 177 of file JetResolutionObject.h.

References m_variables_name.

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

177  {
178  return m_variables_name[variable];
179  }
std::vector< std::string > m_variables_name
const std::vector<Binning>& JME::JetResolutionObject::Definition::getVariables ( ) const
inline

Definition at line 173 of file JetResolutionObject.h.

References m_variables.

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

173  {
174  return m_variables;
175  }
const std::vector<std::string>& JME::JetResolutionObject::Definition::getVariablesName ( ) const
inline

Definition at line 169 of file JetResolutionObject.h.

References m_variables_name.

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

169  {
170  return m_variables_name;
171  }
std::vector< std::string > m_variables_name
void JME::JetResolutionObject::Definition::init ( void  )

Definition at line 178 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 MetTreeProducer::var().

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

178  {
179  if (m_formula_str.size())
180  m_formula = std::shared_ptr<TFormula>(new TFormula("jet_resolution_formula", m_formula_str.c_str()));
181 
182  for (const auto& bin: m_bins_name) {
183  const auto& b = JetParameters::binning_to_string.right.find(bin);
184  if (b == JetParameters::binning_to_string.right.cend()) {
185  throwException(edm::errors::UnimplementedFeature, "Bin name not supported: '" + bin + "'");
186  }
187  m_bins.push_back(b->second);
188  }
189 
190  for (const auto& v: m_variables_name) {
191  const auto& var = JetParameters::binning_to_string.right.find(v);
192  if (var == JetParameters::binning_to_string.right.cend()) {
193  throwException(edm::errors::UnimplementedFeature, "Variable name not supported: '" + v + "'");
194  }
195  m_variables.push_back(var->second);
196  }
197  }
std::vector< std::string > m_variables_name
std::vector< std::string > m_bins_name
std::shared_ptr< TFormula > m_formula
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
size_t JME::JetResolutionObject::Definition::nBins ( ) const
inline
size_t JME::JetResolutionObject::Definition::nVariables ( ) const
inline
template<class Archive >
void JME::JetResolutionObject::Definition::serialize ( Archive &  ar,
const unsigned int  version 
)
private

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 205 of file JetResolutionObject.h.

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

Definition at line 205 of file JetResolutionObject.h.

Member Data Documentation

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

Definition at line 202 of file JetResolutionObject.h.

Referenced by getBins().

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

Definition at line 196 of file JetResolutionObject.h.

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

std::shared_ptr<TFormula> JME::JetResolutionObject::Definition::m_formula
private

Definition at line 200 of file JetResolutionObject.h.

Referenced by getFormula().

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

Definition at line 198 of file JetResolutionObject.h.

Referenced by Definition(), and getFormulaString().

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

Definition at line 203 of file JetResolutionObject.h.

Referenced by getVariables(), and nVariables().

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

Definition at line 197 of file JetResolutionObject.h.

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