CMS 3D CMS Logo

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::RecordmRecords
 
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() [1/3]

METCorrectorParameters::METCorrectorParameters ( )
inline

Definition at line 78 of file METCorrectorParameters.h.

References valid_.

◆ METCorrectorParameters() [2/3]

METCorrectorParameters::METCorrectorParameters ( const std::string &  fFile,
const std::string &  fSection = "" 
)

Definition at line 103 of file METCorrectorParameters.cc.

References RPCNoise_example::check, definitions(), mps_fire::i, input, mps_splice::line, mDefinitions, mRecords, METCorrectorParameters::Definitions::nBinVar(), METCorrectorParameters::Record::nParameters(), record(), hgcalPlots::section, jetUpdater_cfi::sort, 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 }
float xMin(unsigned fVar) const
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
tmp
align.sh
Definition: createJobs.py:716

◆ METCorrectorParameters() [3/3]

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

◆ binCenters()

std::vector<float> METCorrectorParameters::binCenters ( unsigned  fVar) const

◆ binIndex()

int METCorrectorParameters::binIndex ( const std::vector< float > &  fX) const

◆ definitions()

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

◆ isValid()

bool METCorrectorParameters::isValid ( void  ) const
inline

◆ neighbourBin()

int METCorrectorParameters::neighbourBin ( unsigned  fIndex,
unsigned  fVar,
bool  fNext 
) const

◆ printFile()

void METCorrectorParameters::printFile ( const std::string &  fFileName) const

Definition at line 291 of file METCorrectorParameters.cc.

References METCorrectorParameters::Definitions::binVar(), definitions(), METCorrectorParameters::Definitions::formula(), pfMETCorrectionType0_cfi::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 }
float xMin(unsigned fVar) const
std::vector< std::string > parVar() const
const Record & record(unsigned fBin) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
float parameter(unsigned fIndex) const
std::vector< std::string > binVar() const

◆ printScreen()

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 }
float xMin(unsigned fVar) const
std::vector< std::string > parVar() const
const Record & record(unsigned fBin) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
float parameter(unsigned fIndex) const
std::vector< std::string > binVar() const

◆ record()

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

◆ serialize()

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

is this a valid set?

◆ size() [1/2]

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

◆ size() [2/2]

unsigned METCorrectorParameters::size ( unsigned  fVar) const

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 103 of file METCorrectorParameters.h.

◆ cond::serialization::access

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

Definition at line 103 of file METCorrectorParameters.h.

Member Data Documentation

◆ mDefinitions

METCorrectorParameters::Definitions METCorrectorParameters::mDefinitions
private

Definition at line 99 of file METCorrectorParameters.h.

Referenced by definitions(), and METCorrectorParameters().

◆ mRecords

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

Definition at line 100 of file METCorrectorParameters.h.

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

◆ valid_

bool METCorrectorParameters::valid_
private

Definition at line 101 of file METCorrectorParameters.h.

Referenced by isValid(), and METCorrectorParameters().