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 MEtXYcorrectParameters::Definitions &fDefinitions, const std::vector< MEtXYcorrectParameters::Record > &fRecords)
 
 MEtXYcorrectParameters (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 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() [1/3]

MEtXYcorrectParameters::MEtXYcorrectParameters ( )
inline

Definition at line 81 of file MEtXYcorrectParameters.h.

81 { valid_ = false; }

References valid_.

◆ MEtXYcorrectParameters() [2/3]

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

Definition at line 105 of file MEtXYcorrectParameters.cc.

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 }

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

◆ MEtXYcorrectParameters() [3/3]

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

Definition at line 83 of file MEtXYcorrectParameters.h.

85  : mDefinitions(fDefinitions), mRecords(fRecords) {
86  valid_ = true;
87  }

References valid_.

Member Function Documentation

◆ binCenters()

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

◆ binIndex()

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

◆ definitions()

const Definitions& MEtXYcorrectParameters::definitions ( ) const
inline

◆ isValid()

bool MEtXYcorrectParameters::isValid ( void  ) const
inline

Definition at line 100 of file MEtXYcorrectParameters.h.

100 { return valid_; }

References valid_.

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

◆ neighbourBin()

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

◆ printFile() [1/2]

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

Definition at line 215 of file MEtXYcorrectParameters.cc.

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 }

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

◆ printFile() [2/2]

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

Definition at line 238 of file MEtXYcorrectParameters.cc.

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 }

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

◆ printScreen() [1/2]

void MEtXYcorrectParameters::printScreen ( ) const

Definition at line 151 of file MEtXYcorrectParameters.cc.

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 }

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

◆ printScreen() [2/2]

void MEtXYcorrectParameters::printScreen ( const std::string &  Section) const

Definition at line 179 of file MEtXYcorrectParameters.cc.

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 }

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

◆ record()

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

Definition at line 89 of file MEtXYcorrectParameters.h.

89 { return mRecords[fBin]; }

References mRecords.

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

◆ serialize()

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

is this a valid set?

◆ size() [1/2]

unsigned MEtXYcorrectParameters::size ( void  ) const
inline

◆ size() [2/2]

unsigned MEtXYcorrectParameters::size ( unsigned  fVar) const

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Definition at line 108 of file MEtXYcorrectParameters.h.

◆ cond::serialization::access

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

Definition at line 108 of file MEtXYcorrectParameters.h.

Member Data Documentation

◆ mDefinitions

MEtXYcorrectParameters::Definitions MEtXYcorrectParameters::mDefinitions
private

Definition at line 104 of file MEtXYcorrectParameters.h.

Referenced by definitions(), and MEtXYcorrectParameters().

◆ mRecords

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

Definition at line 105 of file MEtXYcorrectParameters.h.

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

◆ valid_

bool MEtXYcorrectParameters::valid_
private

Definition at line 106 of file MEtXYcorrectParameters.h.

Referenced by isValid(), and MEtXYcorrectParameters().

mps_fire.i
i
Definition: mps_fire.py:428
MEtXYcorrectParameters::Record::MetAxis
std::string MetAxis() const
Definition: MEtXYcorrectParameters.h:66
input
static const std::string input
Definition: EdmProvDump.cc:48
MEtXYcorrectParameters::Definitions::nBinVar
unsigned nBinVar() const
Definition: MEtXYcorrectParameters.h:29
pfMETCorrectionType0_cfi.formula
formula
Definition: pfMETCorrectionType0_cfi.py:46
MEtXYcorrectParameters::definitions
const Definitions & definitions() const
Definition: MEtXYcorrectParameters.h:90
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MEtXYcorrectParameters::Definitions::formula
std::string formula() const
Definition: MEtXYcorrectParameters.h:36
MEtXYcorrectParameters::Definitions::PtclType
int PtclType() const
Definition: MEtXYcorrectParameters.h:31
MEtXYcorrectParameters::Definitions::binVar
std::vector< std::string > binVar() const
Definition: MEtXYcorrectParameters.h:33
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
MEtXYcorrectParameters::Definitions::parVar
std::vector< unsigned > parVar() const
Definition: MEtXYcorrectParameters.h:32
MEtXYcorrectParameters::size
unsigned size() const
Definition: MEtXYcorrectParameters.h:91
RPCNoise_example.check
check
Definition: RPCNoise_example.py:71
MEtXYcorrectParameters::Definitions::nParVar
unsigned nParVar() const
Definition: MEtXYcorrectParameters.h:30
MEtXYcorrectParameters::valid_
bool valid_
Definition: MEtXYcorrectParameters.h:106
MEtXYcorrectParameters::mDefinitions
MEtXYcorrectParameters::Definitions mDefinitions
Definition: MEtXYcorrectParameters.h:104
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
definitions
Definition: definitions.py:1
MEtXYcorrectParameters::Record::xMax
float xMax(unsigned fVar) const
Definition: MEtXYcorrectParameters.h:61
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
MEtXYcorrectParameters::Record::nParameters
unsigned nParameters() const
Definition: MEtXYcorrectParameters.h:65
Record
hgcalPlots.section
section
Definition: hgcalPlots.py:2679
MEtXYcorrectParameters::Record::xMin
float xMin(unsigned fVar) const
Definition: MEtXYcorrectParameters.h:60
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
mps_splice.line
line
Definition: mps_splice.py:76
MEtXYcorrectParameters::Record::parameter
float parameter(unsigned fIndex) const
Definition: MEtXYcorrectParameters.h:63
MEtXYcorrectParameters::mRecords
std::vector< MEtXYcorrectParameters::Record > mRecords
Definition: MEtXYcorrectParameters.h:105
MEtXYcorrectParameters::record
const Record & record(unsigned fBin) const
Definition: MEtXYcorrectParameters.h:89