CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Friends
MEtXYcorrectParameters Class Reference

#include <MEtXYcorrectParameters.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
 
 MEtXYcorrectParameters ()
 
 MEtXYcorrectParameters (const std::string &fFile, const std::string &fSection="")
 
 MEtXYcorrectParameters (const MEtXYcorrectParameters::Definitions &fDefinitions, const std::vector< MEtXYcorrectParameters::Record > &fRecords)
 
int neighbourBin (unsigned fIndex, unsigned fVar, bool fNext) const
 
void printFile (const std::string &fFileName) const
 
void printFile (const std::string &fFileName, const std::string &Section) const
 
void printScreen () const
 
void printScreen (const std::string &Section) 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

MEtXYcorrectParameters::Definitions mDefinitions
 
std::vector< MEtXYcorrectParameters::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 MEtXYcorrectParameters.h.

Constructor & Destructor Documentation

MEtXYcorrectParameters::MEtXYcorrectParameters ( )
inline

Definition at line 81 of file MEtXYcorrectParameters.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and valid_.

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

Definition at line 105 of file MEtXYcorrectParameters.cc.

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

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

Definition at line 83 of file MEtXYcorrectParameters.h.

References valid_.

85  : mDefinitions(fDefinitions), mRecords(fRecords) {
86  valid_ = true;
87  }
std::vector< MEtXYcorrectParameters::Record > mRecords
MEtXYcorrectParameters::Definitions mDefinitions

Member Function Documentation

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

Referenced by size().

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

Referenced by size().

const Definitions& MEtXYcorrectParameters::definitions ( ) const
inline

Definition at line 90 of file MEtXYcorrectParameters.h.

References mDefinitions.

Referenced by MEtXYcorrectParameters(), printFile(), printScreen(), and MultShiftMETcorrDBInputProducer::produce().

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

Referenced by size().

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

Definition at line 215 of file MEtXYcorrectParameters.cc.

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

Referenced by size().

215  {
216  std::ofstream txtFile;
217  txtFile.open(fFileName.c_str());
218  txtFile.setf(std::ios::right);
219  txtFile << "{" << definitions().nBinVar() << std::setw(15);
220  for (unsigned i = 0; i < definitions().nBinVar(); i++)
221  txtFile << definitions().binVar(i) << std::setw(15);
222  txtFile << definitions().nParVar() << std::setw(15);
223  for (unsigned i = 0; i < definitions().nParVar(); i++)
224  txtFile << definitions().parVar(i) << std::setw(15);
225  txtFile << std::setw(definitions().formula().size() + 15) << definitions().formula() << std::setw(15);
226  txtFile << "}"
227  << "\n";
228  for (unsigned i = 0; i < size(); i++) {
229  for (unsigned j = 0; j < definitions().nBinVar(); j++)
230  txtFile << record(i).xMin(j) << std::setw(15) << record(i).xMax(j) << std::setw(15);
231  txtFile << record(i).nParameters() << std::setw(15);
232  for (unsigned j = 0; j < record(i).nParameters(); j++)
233  txtFile << record(i).parameter(j) << std::setw(15);
234  txtFile << "\n";
235  }
236  txtFile.close();
237 }
float parameter(unsigned fIndex) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
const Record & record(unsigned fBin) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
std::vector< unsigned > parVar() const
void MEtXYcorrectParameters::printFile ( const std::string &  fFileName,
const std::string &  Section 
) const

Definition at line 238 of file MEtXYcorrectParameters.cc.

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

238  {
239  std::ofstream txtFile;
240  txtFile.open(fFileName.c_str(), std::ofstream::app);
241  txtFile.setf(std::ios::right);
242  txtFile << "[" << Section << "]"
243  << "\n";
244  txtFile << "{"
245  << " " << definitions().PtclType() << " " << definitions().nBinVar();
246  for (unsigned i = 0; i < definitions().nBinVar(); i++)
247  txtFile << " " << definitions().binVar(i);
248  txtFile << " " << definitions().nParVar();
249  for (unsigned i = 0; i < definitions().nParVar(); i++)
250  txtFile << " " << definitions().parVar(i);
251  txtFile << " " << definitions().formula();
252  txtFile << "}"
253  << "\n";
254  for (unsigned i = 0; i < size(); i++) //mRecords size
255  {
256  txtFile << record(i).MetAxis();
257  for (unsigned j = 0; j < definitions().nBinVar(); j++)
258  txtFile << " " << record(i).xMin(j) << " " << record(i).xMax(j);
259  txtFile << " " << record(i).nParameters();
260  for (unsigned j = 0; j < record(i).nParameters(); j++)
261  txtFile << " " << record(i).parameter(j);
262  txtFile << "\n";
263  }
264  txtFile.close();
265 }
float parameter(unsigned fIndex) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
const Record & record(unsigned fBin) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
std::vector< unsigned > parVar() const
void MEtXYcorrectParameters::printScreen ( ) const

Definition at line 151 of file MEtXYcorrectParameters.cc.

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

Referenced by size().

151  {
152  std::cout << "--------------------------------------------" << std::endl;
153  std::cout << "//////// PARAMETERS: //////////////////////" << std::endl;
154  std::cout << "--------------------------------------------" << std::endl;
155  std::cout << "Number of binning variables: " << definitions().nBinVar() << std::endl;
156  std::cout << "Names of binning variables: ";
157  for (unsigned i = 0; i < definitions().nBinVar(); i++)
158  std::cout << definitions().binVar(i) << " ";
159  std::cout << std::endl;
160  std::cout << "--------------------------------------------" << std::endl;
161  std::cout << "Number of parameter variables: " << definitions().nParVar() << std::endl;
162  std::cout << "Names of parameter variables: ";
163  for (unsigned i = 0; i < definitions().nParVar(); i++)
164  std::cout << definitions().parVar(i) << " ";
165  std::cout << std::endl;
166  std::cout << "--------------------------------------------" << std::endl;
167  std::cout << "Parametrization Formula: " << definitions().formula() << std::endl;
168  std::cout << "--------------------------------------------" << std::endl;
169  std::cout << "------- Bin contents -----------------------" << std::endl;
170  for (unsigned i = 0; i < size(); i++) {
171  for (unsigned j = 0; j < definitions().nBinVar(); j++)
172  std::cout << record(i).xMin(j) << " " << record(i).xMax(j) << " ";
173  std::cout << record(i).nParameters() << " ";
174  for (unsigned j = 0; j < record(i).nParameters(); j++)
175  std::cout << record(i).parameter(j) << " ";
176  std::cout << std::endl;
177  }
178 }
float parameter(unsigned fIndex) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
const Record & record(unsigned fBin) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
std::vector< unsigned > parVar() const
void MEtXYcorrectParameters::printScreen ( const std::string &  Section) const

Definition at line 179 of file MEtXYcorrectParameters.cc.

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

179  {
180  std::cout << "--------------------------------------------" << std::endl;
181  std::cout << "//////// PARAMETERS: //////////////////////" << std::endl;
182  std::cout << "--------------------------------------------" << std::endl;
183  std::cout << "[" << Section << "]"
184  << "\n";
185  std::cout << "Number of binning variables: " << definitions().nBinVar() << std::endl;
186  std::cout << "Names of binning variables: ";
187  for (unsigned i = 0; i < definitions().nBinVar(); i++)
188  std::cout << definitions().binVar(i) << " ";
189  std::cout << std::endl;
190  std::cout << "--------------------------------------------" << std::endl;
191  std::cout << "Number of parameter variables: " << definitions().nParVar() << std::endl;
192  std::cout << "Names of parameter variables: ";
193  for (unsigned i = 0; i < definitions().nParVar(); i++)
194  std::cout << definitions().parVar(i) << " ";
195  std::cout << std::endl;
196  std::cout << "--------------------------------------------" << std::endl;
197  std::cout << "Parametrization Formula: " << definitions().formula() << std::endl;
198  std::cout << "--------------------------------------------" << std::endl;
199  std::cout << "------- Bin contents -----------------------" << std::endl;
200  for (unsigned i = 0; i < size(); i++) //mRecords size
201  {
202  std::cout << record(i).MetAxis() << " ";
203  std::cout << "nBinVar (" << definitions().nBinVar() << ") ";
204  for (unsigned j = 0; j < definitions().nBinVar(); j++)
205  std::cout << record(i).xMin(j) << " " << record(i).xMax(j) << " ";
206  std::cout << "nParameters (" << record(i).nParameters() << ") ";
207  for (unsigned j = 0; j < record(i).nParameters(); j++)
208  std::cout << record(i).parameter(j) << " ";
209  std::cout << std::endl;
210  }
211 }
float parameter(unsigned fIndex) const
const Definitions & definitions() const
float xMax(unsigned fVar) const
const Record & record(unsigned fBin) const
std::vector< std::string > binVar() const
float xMin(unsigned fVar) const
std::vector< unsigned > parVar() const
const Record& MEtXYcorrectParameters::record ( unsigned  fBin) const
inline

Definition at line 89 of file MEtXYcorrectParameters.h.

References mRecords.

Referenced by MEtXYcorrectParameters(), printFile(), printScreen(), and MultShiftMETcorrDBInputProducer::produce().

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

is this a valid set?

unsigned MEtXYcorrectParameters::size ( void  ) const
inline
unsigned MEtXYcorrectParameters::size ( unsigned  fVar) const

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 108 of file MEtXYcorrectParameters.h.

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

Definition at line 108 of file MEtXYcorrectParameters.h.

Member Data Documentation

MEtXYcorrectParameters::Definitions MEtXYcorrectParameters::mDefinitions
private

Definition at line 104 of file MEtXYcorrectParameters.h.

Referenced by definitions(), and MEtXYcorrectParameters().

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

Definition at line 105 of file MEtXYcorrectParameters.h.

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

bool MEtXYcorrectParameters::valid_
private

Definition at line 106 of file MEtXYcorrectParameters.h.

Referenced by isValid(), and MEtXYcorrectParameters().