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 METCorrectorParameters::Definitions &fDefinitions, const std::vector< METCorrectorParameters::Record > &fRecords)
 
 METCorrectorParameters (const std::string &fFile, const std::string &fSection="")
 
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.

78 { valid_ = false; }

References valid_.

◆ METCorrectorParameters() [2/3]

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

Definition at line 103 of file METCorrectorParameters.cc.

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 }

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

◆ METCorrectorParameters() [3/3]

METCorrectorParameters::METCorrectorParameters ( const METCorrectorParameters::Definitions fDefinitions,
const std::vector< METCorrectorParameters::Record > &  fRecords 
)
inline

Definition at line 80 of file METCorrectorParameters.h.

82  : mDefinitions(fDefinitions), mRecords(fRecords) {
83  valid_ = true;
84  }

References valid_.

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.

87 { return mDefinitions; }

References mDefinitions.

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

◆ isValid()

bool METCorrectorParameters::isValid ( void  ) const
inline

Definition at line 95 of file METCorrectorParameters.h.

95 { return valid_; }

References valid_.

Referenced by ntupleDataFormat._Object::_checkIsValid(), and core.AutoHandle.AutoHandle::ReallyLoad().

◆ 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.

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 }

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

◆ printScreen()

void METCorrectorParameters::printScreen ( ) const

Definition at line 260 of file METCorrectorParameters.cc.

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 }

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

◆ record()

const Record& METCorrectorParameters::record ( unsigned  fBin) const
inline

Definition at line 86 of file METCorrectorParameters.h.

86 { return mRecords[fBin]; }

References mRecords.

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

◆ 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

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

METCorrectorParameters::Definitions::binVar
std::vector< std::string > binVar() const
Definition: METCorrectorParameters.h:32
mps_fire.i
i
Definition: mps_fire.py:428
input
static const std::string input
Definition: EdmProvDump.cc:48
METCorrectorParameters::valid_
bool valid_
Definition: METCorrectorParameters.h:101
pfMETCorrectionType0_cfi.formula
formula
Definition: pfMETCorrectionType0_cfi.py:46
METCorrectorParameters::Record::nParameters
unsigned nParameters() const
Definition: METCorrectorParameters.h:64
gather_cfg.cout
cout
Definition: gather_cfg.py:144
METCorrectorParameters::mDefinitions
METCorrectorParameters::Definitions mDefinitions
Definition: METCorrectorParameters.h:99
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
METCorrectorParameters::Definitions::nBinVar
unsigned nBinVar() const
Definition: METCorrectorParameters.h:29
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
METCorrectorParameters::Definitions::nParVar
unsigned nParVar() const
Definition: METCorrectorParameters.h:30
METCorrectorParameters::Record::xMax
float xMax(unsigned fVar) const
Definition: METCorrectorParameters.h:60
METCorrectorParameters::Definitions::formula
std::string formula() const
Definition: METCorrectorParameters.h:35
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
METCorrectorParameters::size
unsigned size() const
Definition: METCorrectorParameters.h:88
definitions
Definition: definitions.py:1
METCorrectorParameters::Record::parameter
float parameter(unsigned fIndex) const
Definition: METCorrectorParameters.h:62
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
METCorrectorParameters::Definitions::parVar
std::vector< std::string > parVar() const
Definition: METCorrectorParameters.h:31
Record
METCorrectorParameters::record
const Record & record(unsigned fBin) const
Definition: METCorrectorParameters.h:86
hgcalPlots.section
section
Definition: hgcalPlots.py:2679
METCorrectorParameters::Record::xMin
float xMin(unsigned fVar) const
Definition: METCorrectorParameters.h:59
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
mps_splice.line
line
Definition: mps_splice.py:76
METCorrectorParameters::mRecords
std::vector< METCorrectorParameters::Record > mRecords
Definition: METCorrectorParameters.h:100
METCorrectorParameters::definitions
const Definitions & definitions() const
Definition: METCorrectorParameters.h:87