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 76 of file MEtXYcorrectParameters.h.

References AlCaHLTBitMon_QueryRunRegistry::string, and valid_.

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

Definition at line 114 of file MEtXYcorrectParameters.cc.

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

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

Definition at line 78 of file MEtXYcorrectParameters.h.

References valid_.

80  : mDefinitions(fDefinitions),mRecords(fRecords) { valid_ = true;}
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 83 of file MEtXYcorrectParameters.h.

References mDefinitions.

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

83 {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 231 of file MEtXYcorrectParameters.cc.

References MEtXYcorrectParameters::Definitions::binVar(), definitions(), EcalElecEmulTccOnlyExample_cfg::formula, MEtXYcorrectParameters::Definitions::formula(), mps_fire::i, 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().

232 {
233  std::ofstream txtFile;
234  txtFile.open(fFileName.c_str());
235  txtFile.setf(std::ios::right);
236  txtFile<<"{"<<definitions().nBinVar()<<std::setw(15);
237  for(unsigned i=0;i<definitions().nBinVar();i++)
238  txtFile<<definitions().binVar(i)<<std::setw(15);
239  txtFile<<definitions().nParVar()<<std::setw(15);
240  for(unsigned i=0;i<definitions().nParVar();i++)
241  txtFile<<definitions().parVar(i)<<std::setw(15);
242  txtFile<<std::setw(definitions().formula().size()+15)<<definitions().formula()<<std::setw(15);
243  txtFile<<"}"<<"\n";
244  for(unsigned i=0;i<size();i++)
245  {
246  for(unsigned j=0;j<definitions().nBinVar();j++)
247  txtFile<<record(i).xMin(j)<<std::setw(15)<<record(i).xMax(j)<<std::setw(15);
248  txtFile<<record(i).nParameters()<<std::setw(15);
249  for(unsigned j=0;j<record(i).nParameters();j++)
250  txtFile<<record(i).parameter(j)<<std::setw(15);
251  txtFile<<"\n";
252  }
253  txtFile.close();
254 }
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 255 of file MEtXYcorrectParameters.cc.

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

256 {
257  std::ofstream txtFile;
258  txtFile.open(fFileName.c_str(),std::ofstream::app);
259  txtFile.setf(std::ios::right);
260  txtFile<<"["<<Section<<"]"<<"\n";
261  txtFile<<"{"<<" "<<definitions().PtclType()<<" "<<definitions().nBinVar();
262  for(unsigned i=0;i<definitions().nBinVar();i++)
263  txtFile<<" "<<definitions().binVar(i);
264  txtFile<<" "<<definitions().nParVar();
265  for(unsigned i=0;i<definitions().nParVar();i++)
266  txtFile<<" "<<definitions().parVar(i);
267  txtFile<<" "<<definitions().formula();
268  txtFile<<"}"<<"\n";
269  for(unsigned i=0;i<size();i++) //mRecords size
270  {
271  txtFile<<record(i).MetAxis();
272  for(unsigned j=0;j<definitions().nBinVar();j++)
273  txtFile<<" "<<record(i).xMin(j)<<" "<<record(i).xMax(j);
274  txtFile<<" "<<record(i).nParameters();
275  for(unsigned j=0;j<record(i).nParameters();j++)
276  txtFile<<" "<<record(i).parameter(j);
277  txtFile<<"\n";
278  }
279  txtFile.close();
280 }
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 165 of file MEtXYcorrectParameters.cc.

References MEtXYcorrectParameters::Definitions::binVar(), gather_cfg::cout, definitions(), MEtXYcorrectParameters::Definitions::formula(), mps_fire::i, 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().

166 {
167  std::cout<<"--------------------------------------------"<<std::endl;
168  std::cout<<"//////// PARAMETERS: //////////////////////"<<std::endl;
169  std::cout<<"--------------------------------------------"<<std::endl;
170  std::cout<<"Number of binning variables: "<<definitions().nBinVar()<<std::endl;
171  std::cout<<"Names of binning variables: ";
172  for(unsigned i=0;i<definitions().nBinVar();i++)
173  std::cout<<definitions().binVar(i)<<" ";
174  std::cout<<std::endl;
175  std::cout<<"--------------------------------------------"<<std::endl;
176  std::cout<<"Number of parameter variables: "<<definitions().nParVar()<<std::endl;
177  std::cout<<"Names of parameter variables: ";
178  for(unsigned i=0;i<definitions().nParVar();i++)
179  std::cout<<definitions().parVar(i)<<" ";
180  std::cout<<std::endl;
181  std::cout<<"--------------------------------------------"<<std::endl;
182  std::cout<<"Parametrization Formula: "<<definitions().formula()<<std::endl;
183  std::cout<<"--------------------------------------------"<<std::endl;
184  std::cout<<"------- Bin contents -----------------------"<<std::endl;
185  for(unsigned i=0;i<size();i++)
186  {
187  for(unsigned j=0;j<definitions().nBinVar();j++)
188  std::cout<<record(i).xMin(j)<<" "<<record(i).xMax(j)<<" ";
189  std::cout<<record(i).nParameters()<<" ";
190  for(unsigned j=0;j<record(i).nParameters();j++)
191  std::cout<<record(i).parameter(j)<<" ";
192  std::cout<<std::endl;
193  }
194 }
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 195 of file MEtXYcorrectParameters.cc.

References MEtXYcorrectParameters::Definitions::binVar(), gather_cfg::cout, definitions(), MEtXYcorrectParameters::Definitions::formula(), mps_fire::i, 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().

196 {
197  std::cout<<"--------------------------------------------"<<std::endl;
198  std::cout<<"//////// PARAMETERS: //////////////////////"<<std::endl;
199  std::cout<<"--------------------------------------------"<<std::endl;
200  std::cout<<"["<<Section<<"]"<<"\n";
201  std::cout<<"Number of binning variables: "<<definitions().nBinVar()<<std::endl;
202  std::cout<<"Names of binning variables: ";
203  for(unsigned i=0;i<definitions().nBinVar();i++)
204  std::cout<<definitions().binVar(i)<<" ";
205  std::cout<<std::endl;
206  std::cout<<"--------------------------------------------"<<std::endl;
207  std::cout<<"Number of parameter variables: "<<definitions().nParVar()<<std::endl;
208  std::cout<<"Names of parameter variables: ";
209  for(unsigned i=0;i<definitions().nParVar();i++)
210  std::cout<<definitions().parVar(i)<<" ";
211  std::cout<<std::endl;
212  std::cout<<"--------------------------------------------"<<std::endl;
213  std::cout<<"Parametrization Formula: "<<definitions().formula()<<std::endl;
214  std::cout<<"--------------------------------------------"<<std::endl;
215  std::cout<<"------- Bin contents -----------------------"<<std::endl;
216  for(unsigned i=0;i<size();i++) //mRecords size
217  {
218  std::cout<<record(i).MetAxis()<<" ";
219  std::cout<<"nBinVar ("<<definitions().nBinVar()<<") ";
220  for(unsigned j=0;j<definitions().nBinVar();j++)
221  std::cout<<record(i).xMin(j)<<" "<<record(i).xMax(j)<<" ";
222  std::cout<<"nParameters ("<<record(i).nParameters()<<") ";
223  for(unsigned j=0;j<record(i).nParameters();j++)
224  std::cout<<record(i).parameter(j)<<" ";
225  std::cout<<std::endl;
226  }
227 }
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 82 of file MEtXYcorrectParameters.h.

References mRecords.

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

82 {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 101 of file MEtXYcorrectParameters.h.

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

Definition at line 101 of file MEtXYcorrectParameters.h.

Member Data Documentation

MEtXYcorrectParameters::Definitions MEtXYcorrectParameters::mDefinitions
private

Definition at line 97 of file MEtXYcorrectParameters.h.

Referenced by definitions(), and MEtXYcorrectParameters().

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

Definition at line 98 of file MEtXYcorrectParameters.h.

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

bool MEtXYcorrectParameters::valid_
private

Definition at line 99 of file MEtXYcorrectParameters.h.

Referenced by isValid(), and MEtXYcorrectParameters().