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::METCorrectorParameters ( )
inline

Definition at line 73 of file METCorrectorParameters.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and valid_.

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

Definition at line 111 of file METCorrectorParameters.cc.

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

112 {
113  std::ifstream input(fFile.c_str());
114  std::string currentSection = "";
116  std::string currentDefinitions = "";
117  while (std::getline(input,line))
118  {
119  //std::cout << " Line of parameters " << line << std::endl;
121  std::string tmp = getDefinitions(line);
122  if (!section.empty() && tmp.empty())
123  {
124  currentSection = section;
125  continue;
126  }
127  if (currentSection == fSection)
128  {
129  if (!tmp.empty())
130  {
131  currentDefinitions = tmp;
132  continue;
133  }
134  Definitions definitions(currentDefinitions);
135  if (!(definitions.nBinVar()==0 && definitions.formula()==""))
138  bool check(true);
139  for(unsigned i=0;i<mDefinitions.nBinVar();++i)
140  if (record.xMin(i)==0 && record.xMax(i)==0)
141  check = false;
142  if (record.nParameters() == 0)
143  check = false;
144  if (check)
145  mRecords.push_back(record);
146  }
147  }
148  if (currentDefinitions=="")
149  handleError("METCorrectorParameters","No definitions found!!!");
150  if (mRecords.empty() && currentSection == "") mRecords.push_back(Record());
151  if (mRecords.empty() && currentSection != "")
152  {
153  std::stringstream sserr;
154  sserr<<"the requested section "<<fSection<<" doesn't exist!";
155  handleError("METCorrectorParameters",sserr.str());
156  }
157  std::sort(mRecords.begin(), mRecords.end());
158  valid_ = true;
159 }
const Record & record(unsigned fBin) const
std::vector< METCorrectorParameters::Record > mRecords
static std::string const input
Definition: EdmProvDump.cc:48
const Definitions & definitions() const
float xMax(unsigned fVar) const
METCorrectorParameters::Definitions mDefinitions
def getSection(rootNode, name)
float xMin(unsigned fVar) const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
def check(config)
Definition: trackerTree.py:14
METCorrectorParameters::METCorrectorParameters ( const METCorrectorParameters::Definitions fDefinitions,
const std::vector< METCorrectorParameters::Record > &  fRecords 
)
inline

Definition at line 75 of file METCorrectorParameters.h.

References valid_.

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

Member Function Documentation

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

Referenced by size().

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

Referenced by size().

const Definitions& METCorrectorParameters::definitions ( ) const
inline

Definition at line 80 of file METCorrectorParameters.h.

References mDefinitions.

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

80 {return mDefinitions; }
METCorrectorParameters::Definitions mDefinitions
bool METCorrectorParameters::isValid ( void  ) const
inline
int METCorrectorParameters::neighbourBin ( unsigned  fIndex,
unsigned  fVar,
bool  fNext 
) const

Referenced by size().

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

Definition at line 306 of file METCorrectorParameters.cc.

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

Referenced by size().

307 {
308  std::ofstream txtFile;
309  txtFile.open(fFileName.c_str());
310  txtFile.setf(std::ios::right);
311  txtFile<<"{"<<definitions().nBinVar()<<std::setw(15);
312  for(unsigned i=0;i<definitions().nBinVar();i++)
313  txtFile<<definitions().binVar(i)<<std::setw(15);
314  txtFile<<definitions().nParVar()<<std::setw(15);
315  for(unsigned i=0;i<definitions().nParVar();i++)
316  txtFile<<definitions().parVar(i)<<std::setw(15);
317  txtFile<<std::setw(definitions().formula().size()+15)<<definitions().formula()<<std::setw(15);
318  txtFile<<"}"<<"\n";
319  for(unsigned i=0;i<size();i++)
320  {
321  for(unsigned j=0;j<definitions().nBinVar();j++)
322  txtFile<<record(i).xMin(j)<<std::setw(15)<<record(i).xMax(j)<<std::setw(15);
323  txtFile<<record(i).nParameters()<<std::setw(15);
324  for(unsigned j=0;j<record(i).nParameters();j++)
325  txtFile<<record(i).parameter(j)<<std::setw(15);
326  txtFile<<"\n";
327  }
328  txtFile.close();
329 }
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 273 of file METCorrectorParameters.cc.

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

Referenced by size().

274 {
275  std::cout<<"--------------------------------------------"<<std::endl;
276  std::cout<<"//////// PARAMETERS: //////////////////////"<<std::endl;
277  std::cout<<"--------------------------------------------"<<std::endl;
278  std::cout<<"Number of binning variables: "<<definitions().nBinVar()<<std::endl;
279  std::cout<<"Names of binning variables: ";
280  for(unsigned i=0;i<definitions().nBinVar();i++)
281  std::cout<<definitions().binVar(i)<<" ";
282  std::cout<<std::endl;
283  std::cout<<"--------------------------------------------"<<std::endl;
284  std::cout<<"Number of parameter variables: "<<definitions().nParVar()<<std::endl;
285  std::cout<<"Names of parameter variables: ";
286  for(unsigned i=0;i<definitions().nParVar();i++)
287  std::cout<<definitions().parVar(i)<<" ";
288  std::cout<<std::endl;
289  std::cout<<"--------------------------------------------"<<std::endl;
290  std::cout<<"Parametrization Formula: "<<definitions().formula()<<std::endl;
291  std::cout<<"--------------------------------------------"<<std::endl;
292  std::cout<<"------- Bin contents -----------------------"<<std::endl;
293  for(unsigned i=0;i<size();i++)
294  {
295  for(unsigned j=0;j<definitions().nBinVar();j++)
296  std::cout<<record(i).xMin(j)<<" "<<record(i).xMax(j)<<" ";
297  std::cout<<record(i).nParameters()<<" ";
298  for(unsigned j=0;j<record(i).nParameters();j++)
299  std::cout<<record(i).parameter(j)<<" ";
300  std::cout<<std::endl;
301  }
302 }
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
const Record& METCorrectorParameters::record ( unsigned  fBin) const
inline

Definition at line 79 of file METCorrectorParameters.h.

References mRecords.

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

79 {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
unsigned METCorrectorParameters::size ( unsigned  fVar) const

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 96 of file METCorrectorParameters.h.

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

Definition at line 96 of file METCorrectorParameters.h.

Member Data Documentation

METCorrectorParameters::Definitions METCorrectorParameters::mDefinitions
private

Definition at line 92 of file METCorrectorParameters.h.

Referenced by definitions(), and METCorrectorParameters().

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

Definition at line 93 of file METCorrectorParameters.h.

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

bool METCorrectorParameters::valid_
private

Definition at line 94 of file METCorrectorParameters.h.

Referenced by isValid(), and METCorrectorParameters().