CMS 3D CMS Logo

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

#include <METCorrectorParameters.h>

Classes

class  Definitions
 
class  Record
 

Public Member Functions

std::vector< float > binCenters (unsigned fVar) const
 
int binIndex (const std::vector< float > &fX) const
 
const Definitionsdefinitions () const
 
bool isValid () const
 
 METCorrectorParameters ()
 
 METCorrectorParameters (const std::string &fFile, const std::string &fSection="")
 
 METCorrectorParameters (const METCorrectorParameters::Definitions &fDefinitions, const std::vector< METCorrectorParameters::Record > &fRecords)
 
int neighbourBin (unsigned fIndex, unsigned fVar, bool fNext) const
 
void printFile (const std::string &fFileName) const
 
void printScreen () const
 
const Recordrecord (unsigned fBin) const
 
unsigned size () const
 
unsigned size (unsigned fVar) const
 

Private Member Functions

template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 is this a valid set? More...
 

Private Attributes

METCorrectorParameters::Definitions mDefinitions
 
std::vector
< METCorrectorParameters::Record
mRecords
 
bool valid_
 

Friends

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

Detailed Description

Definition at line 14 of file METCorrectorParameters.h.

Constructor & Destructor Documentation

METCorrectorParameters::METCorrectorParameters ( )
inline

Definition at line 78 of file METCorrectorParameters.h.

References valid_.

78 { valid_ = false; }
METCorrectorParameters::METCorrectorParameters ( const std::string &  fFile,
const std::string &  fSection = "" 
)

Definition at line 103 of file METCorrectorParameters.cc.

References trackerTree::check(), definitions(), METCorrectorParameters::Definitions::formula(), mps_fire::i, input, geometryCSVtoXML::line, mDefinitions, mRecords, METCorrectorParameters::Definitions::nBinVar(), METCorrectorParameters::Record::nParameters(), record(), vertexPlots::section, AlCaHLTBitMon_QueryRunRegistry::string, createJobs::tmp, valid_, METCorrectorParameters::Record::xMax(), and METCorrectorParameters::Record::xMin().

103  {
104  std::ifstream input(fFile.c_str());
105  std::string currentSection = "";
107  std::string currentDefinitions = "";
108  while (std::getline(input, line)) {
109  //std::cout << " Line of parameters " << line << std::endl;
110  std::string section = getSection(line);
111  std::string tmp = getDefinitions(line);
112  if (!section.empty() && tmp.empty()) {
113  currentSection = section;
114  continue;
115  }
116  if (currentSection == fSection) {
117  if (!tmp.empty()) {
118  currentDefinitions = tmp;
119  continue;
120  }
121  Definitions definitions(currentDefinitions);
122  if (!(definitions.nBinVar() == 0 && definitions.formula().empty()))
125  bool check(true);
126  for (unsigned i = 0; i < mDefinitions.nBinVar(); ++i)
127  if (record.xMin(i) == 0 && record.xMax(i) == 0)
128  check = false;
129  if (record.nParameters() == 0)
130  check = false;
131  if (check)
132  mRecords.push_back(record);
133  }
134  }
135  if (currentDefinitions.empty())
136  handleError("METCorrectorParameters", "No definitions found!!!");
137  if (mRecords.empty() && currentSection.empty())
138  mRecords.push_back(Record());
139  if (mRecords.empty() && !currentSection.empty()) {
140  std::stringstream sserr;
141  sserr << "the requested section " << fSection << " doesn't exist!";
142  handleError("METCorrectorParameters", sserr.str());
143  }
144  std::sort(mRecords.begin(), mRecords.end());
145  valid_ = true;
146 }
const Record & record(unsigned fBin) const
std::vector< METCorrectorParameters::Record > mRecords
static std::string const input
Definition: EdmProvDump.cc:47
const Definitions & definitions() const
float xMax(unsigned fVar) const
METCorrectorParameters::Definitions mDefinitions
float xMin(unsigned fVar) const
string section
Definition: vertexPlots.py:496
tmp
align.sh
Definition: createJobs.py:716
METCorrectorParameters::METCorrectorParameters ( const METCorrectorParameters::Definitions fDefinitions,
const std::vector< METCorrectorParameters::Record > &  fRecords 
)
inline

Definition at line 80 of file METCorrectorParameters.h.

References valid_.

82  : mDefinitions(fDefinitions), mRecords(fRecords) {
83  valid_ = true;
84  }
std::vector< METCorrectorParameters::Record > mRecords
METCorrectorParameters::Definitions mDefinitions

Member Function Documentation

std::vector<float> METCorrectorParameters::binCenters ( unsigned  fVar) const
int METCorrectorParameters::binIndex ( const std::vector< float > &  fX) const
const Definitions& METCorrectorParameters::definitions ( ) const
inline

Definition at line 87 of file METCorrectorParameters.h.

References mDefinitions.

Referenced by METCorrectorParameters(), printFile(), and printScreen().

87 { return mDefinitions; }
METCorrectorParameters::Definitions mDefinitions
bool METCorrectorParameters::isValid ( void  ) const
inline
int METCorrectorParameters::neighbourBin ( unsigned  fIndex,
unsigned  fVar,
bool  fNext 
) const
void METCorrectorParameters::printFile ( const std::string &  fFileName) const

Definition at line 291 of file METCorrectorParameters.cc.

References METCorrectorParameters::Definitions::binVar(), definitions(), EcalElecEmulTccOnlyExample_cfg::formula, METCorrectorParameters::Definitions::formula(), mps_fire::i, dqmiolumiharvest::j, METCorrectorParameters::Definitions::nBinVar(), METCorrectorParameters::Record::nParameters(), METCorrectorParameters::Definitions::nParVar(), METCorrectorParameters::Record::parameter(), METCorrectorParameters::Definitions::parVar(), record(), size(), METCorrectorParameters::Record::xMax(), and METCorrectorParameters::Record::xMin().

291  {
292  std::ofstream txtFile;
293  txtFile.open(fFileName.c_str());
294  txtFile.setf(std::ios::right);
295  txtFile << "{" << definitions().nBinVar() << std::setw(15);
296  for (unsigned i = 0; i < definitions().nBinVar(); i++)
297  txtFile << definitions().binVar(i) << std::setw(15);
298  txtFile << definitions().nParVar() << std::setw(15);
299  for (unsigned i = 0; i < definitions().nParVar(); i++)
300  txtFile << definitions().parVar(i) << std::setw(15);
301  txtFile << std::setw(definitions().formula().size() + 15) << definitions().formula() << std::setw(15);
302  txtFile << "}"
303  << "\n";
304  for (unsigned i = 0; i < size(); i++) {
305  for (unsigned j = 0; j < definitions().nBinVar(); j++)
306  txtFile << record(i).xMin(j) << std::setw(15) << record(i).xMax(j) << std::setw(15);
307  txtFile << record(i).nParameters() << std::setw(15);
308  for (unsigned j = 0; j < record(i).nParameters(); j++)
309  txtFile << record(i).parameter(j) << std::setw(15);
310  txtFile << "\n";
311  }
312  txtFile.close();
313 }
std::vector< std::string > parVar() const
const Record & record(unsigned fBin) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
float parameter(unsigned fIndex) const
void METCorrectorParameters::printScreen ( ) const

Definition at line 260 of file METCorrectorParameters.cc.

References METCorrectorParameters::Definitions::binVar(), gather_cfg::cout, definitions(), METCorrectorParameters::Definitions::formula(), mps_fire::i, dqmiolumiharvest::j, METCorrectorParameters::Definitions::nBinVar(), METCorrectorParameters::Record::nParameters(), METCorrectorParameters::Definitions::nParVar(), METCorrectorParameters::Record::parameter(), METCorrectorParameters::Definitions::parVar(), record(), size(), METCorrectorParameters::Record::xMax(), and METCorrectorParameters::Record::xMin().

260  {
261  std::cout << "--------------------------------------------" << std::endl;
262  std::cout << "//////// PARAMETERS: //////////////////////" << std::endl;
263  std::cout << "--------------------------------------------" << std::endl;
264  std::cout << "Number of binning variables: " << definitions().nBinVar() << std::endl;
265  std::cout << "Names of binning variables: ";
266  for (unsigned i = 0; i < definitions().nBinVar(); i++)
267  std::cout << definitions().binVar(i) << " ";
268  std::cout << std::endl;
269  std::cout << "--------------------------------------------" << std::endl;
270  std::cout << "Number of parameter variables: " << definitions().nParVar() << std::endl;
271  std::cout << "Names of parameter variables: ";
272  for (unsigned i = 0; i < definitions().nParVar(); i++)
273  std::cout << definitions().parVar(i) << " ";
274  std::cout << std::endl;
275  std::cout << "--------------------------------------------" << std::endl;
276  std::cout << "Parametrization Formula: " << definitions().formula() << std::endl;
277  std::cout << "--------------------------------------------" << std::endl;
278  std::cout << "------- Bin contents -----------------------" << std::endl;
279  for (unsigned i = 0; i < size(); i++) {
280  for (unsigned j = 0; j < definitions().nBinVar(); j++)
281  std::cout << record(i).xMin(j) << " " << record(i).xMax(j) << " ";
282  std::cout << record(i).nParameters() << " ";
283  for (unsigned j = 0; j < record(i).nParameters(); j++)
284  std::cout << record(i).parameter(j) << " ";
285  std::cout << std::endl;
286  }
287 }
std::vector< std::string > parVar() const
const Record & record(unsigned fBin) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
tuple cout
Definition: gather_cfg.py:144
float parameter(unsigned fIndex) const
const Record& METCorrectorParameters::record ( unsigned  fBin) const
inline

Definition at line 86 of file METCorrectorParameters.h.

References mRecords.

Referenced by METCorrectorParameters(), printFile(), and printScreen().

86 { return mRecords[fBin]; }
std::vector< METCorrectorParameters::Record > mRecords
template<class Archive >
void METCorrectorParameters::serialize ( Archive &  ar,
const unsigned int  version 
)
private

is this a valid set?

unsigned METCorrectorParameters::size ( void  ) const
inline

Definition at line 88 of file METCorrectorParameters.h.

References mRecords.

Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), printFile(), and printScreen().

88 { return mRecords.size(); }
std::vector< METCorrectorParameters::Record > mRecords
unsigned METCorrectorParameters::size ( unsigned  fVar) const

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 103 of file METCorrectorParameters.h.

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

Definition at line 103 of file METCorrectorParameters.h.

Member Data Documentation

METCorrectorParameters::Definitions METCorrectorParameters::mDefinitions
private

Definition at line 99 of file METCorrectorParameters.h.

Referenced by definitions(), and METCorrectorParameters().

std::vector<METCorrectorParameters::Record> METCorrectorParameters::mRecords
private

Definition at line 100 of file METCorrectorParameters.h.

Referenced by METCorrectorParameters(), record(), and size().

bool METCorrectorParameters::valid_
private

Definition at line 101 of file METCorrectorParameters.h.

Referenced by isValid(), and METCorrectorParameters().