24 for(
unsigned i=0;
i<fBinVar.size();
i++)
26 for(
unsigned i=0;i<fParVar.size();i++)
38 std::vector<std::string> tokens = getTokens(fLine);
41 if (tokens.size() < 6)
43 std::stringstream sserr;
44 sserr<<
"(line "<<fLine<<
"): less than 6 expected tokens:"<<tokens.size();
45 handleError(
"JetCorrectorParameters::Definitions",sserr.str());
47 unsigned nvar = getUnsigned(tokens[0]);
48 unsigned npar = getUnsigned(tokens[nvar+1]);
49 for(
unsigned i=0;
i<nvar;
i++)
50 mBinVar.push_back(tokens[
i+1]);
51 for(
unsigned i=0;
i<npar;
i++)
52 mParVar.push_back(tokens[nvar+2+
i]);
53 mFormula = tokens[npar+nvar+2];
54 std::string ss = tokens[npar+nvar+3];
57 else if (ss ==
"Correction")
59 else if (ss ==
"Resolution")
61 else if (ss.find(
"PAR")==0)
65 std::stringstream sserr;
66 sserr<<
"unknown option ("<<ss<<
")";
67 handleError(
"JetCorrectorParameters::Definitions",sserr.str());
69 mLevel = tokens[npar+nvar+4];
80 std::vector<std::string> tokens = getTokens(fLine);
83 if (tokens.size() < 3)
85 std::stringstream sserr;
86 sserr<<
"(line "<<fLine<<
"): "<<
"three tokens expected, "<<tokens.size()<<
" provided.";
87 handleError(
"JetCorrectorParameters::Record",sserr.str());
91 mMin.push_back(getFloat(tokens[
i*mNvar]));
92 mMax.push_back(getFloat(tokens[
i*mNvar+1]));
94 unsigned nParam = getUnsigned(tokens[2*mNvar]);
95 if (nParam != tokens.size()-(2*mNvar+1))
97 std::stringstream sserr;
98 sserr<<
"(line "<<fLine<<
"): "<<tokens.size()-(2*mNvar+1)<<
" parameters, but nParam="<<nParam<<
".";
99 handleError(
"JetCorrectorParameters::Record",sserr.str());
101 for (
unsigned i = (2*mNvar+1);
i < tokens.size(); ++
i)
111 std::ifstream
input(fFile.c_str());
112 std::string currentSection =
"";
114 std::string currentDefinitions =
"";
115 while (std::getline(
input,line))
118 std::string
tmp = getDefinitions(line);
119 if (!section.empty() && tmp.empty())
121 currentSection = section;
124 if (currentSection == fSection)
128 currentDefinitions =
tmp;
145 if (currentDefinitions==
"")
146 handleError(
"JetCorrectorParameters",
"No definitions found!!!");
148 if (
mRecords.empty() && currentSection !=
"")
150 std::stringstream sserr;
151 sserr<<
"the requested section "<<fSection<<
" doesn't exist!";
152 handleError(
"JetCorrectorParameters",sserr.str());
166 std::stringstream sserr;
167 sserr<<
"# bin variables "<<N<<
" doesn't correspont to requested #: "<<fX.size();
168 handleError(
"JetCorrectorParameters",sserr.str());
171 for (
unsigned i = 0;
i <
size(); ++
i)
174 for (
unsigned j=0;
j<
N;
j++)
194 std::stringstream sserr;
195 sserr<<
"# of bin variables "<<N<<
" doesn't correspond to requested #: "<<fVar;
196 handleError(
"JetCorrectorParameters",sserr.str());
199 for (
unsigned i = 0;
i <
size(); ++
i)
202 for (
unsigned j=0;
j<fVar;
j++)
205 for (
unsigned j=fVar+1;
j<
N;
j++)
213 if (fabs(
record(
i).xMin(fVar)-
record(fIndex).xMax(fVar))<0.0001)
216 if (fabs(
record(
i).xMax(fVar)-
record(fIndex).xMin(fVar))<0.0001)
234 std::stringstream sserr;
235 sserr<<
"requested bin variable index "<<fVar<<
" is greater than number of variables "<<
mDefinitions.
nBinVar();
236 handleError(
"JetCorrectorParameters",sserr.str());
239 float tmpMin(-9999),tmpMax(-9999);
240 for (
unsigned i = 0;
i <
size(); ++
i)
254 std::vector<float>
result;
255 for (
unsigned i = 0;
i <
size(); ++
i)
256 result.push_back(
record(
i).xMiddle(fVar));
264 std::cout<<
"--------------------------------------------"<<std::endl;
265 std::cout<<
"//////// PARAMETERS: //////////////////////"<<std::endl;
266 std::cout<<
"--------------------------------------------"<<std::endl;
268 std::cout<<
"Names of binning variables: ";
272 std::cout<<
"--------------------------------------------"<<std::endl;
274 std::cout<<
"Names of parameter variables: ";
278 std::cout<<
"--------------------------------------------"<<std::endl;
281 std::cout<<
"Type (Response or Correction): "<<
"Response"<<std::endl;
283 std::cout<<
"Type (Response or Correction): "<<
"Correction"<<std::endl;
285 std::cout<<
"--------------------------------------------"<<std::endl;
286 std::cout<<
"------- Bin contents -----------------------"<<std::endl;
302 std::ofstream txtFile;
303 txtFile.open(fFileName.c_str());
304 txtFile.setf(std::ios::right);
313 txtFile<<
"Response"<<std::setw(15);
315 txtFile<<
"Correction"<<std::setw(15);
345 "UncertaintyAbsolute",
346 "UncertaintyHighPtExtra",
347 "UncertaintySinglePion",
350 "UncertaintyRelativeJEREC1",
351 "UncertaintyRelativeJEREC2",
352 "UncertaintyRelativeJERHF",
353 "UncertaintyRelativeStatEC2",
354 "UncertaintyRelativeStatHF",
355 "UncertaintyRelativeFSR",
356 "UncertaintyPileUpDataMC",
357 "UncertaintyPileUpOOT",
358 "UncertaintyPileUpPt",
359 "UncertaintyPileUpBias",
360 "UncertaintyPileUpJetRate"
391 std::vector<std::string>
393 labelsArray_ +
sizeof(labelsArray_)/
sizeof(*labelsArray_) );
395 std::vector<std::string>
397 l5FlavorArray_ +
sizeof(l5FlavorArray_)/
sizeof(*l5FlavorArray_) );
399 std::vector<std::string>
401 l7PartonArray_ +
sizeof(l7PartonArray_)/
sizeof(*l7PartonArray_) );
405 std::vector<std::string> & outputs )
408 std::ifstream
input( inputFile.c_str() );
409 while( !
input.eof() ) {
411 input.getline(buff,10000);
412 std::string
in(buff);
413 if ( in[0] ==
'[' ) {
416 outputs.push_back( tok );
420 std::cout <<
"Found these sections for file: " << std::endl;
421 copy(outputs.begin(),outputs.end(), std::ostream_iterator<std::string>(
std::cout,
"\n") );
428 std::cout <<
"flav = " << flav << std::endl;
430 std::cout <<
"This is L5, getL5Bin = " << getL5Bin(flav) << std::endl;
431 correctionsL5_.push_back(
pair_type(getL5Bin(flav),j) );
433 else if ( isL7(i) ) {
434 std::cout <<
"This is L7, getL7Bin = " << getL7Bin(flav) << std::endl;
435 correctionsL7_.push_back(
pair_type(getL7Bin(flav),j) );
437 else if ( flav ==
"" ) {
438 corrections_.push_back(
pair_type(i,j) );
440 std::cout <<
"***** NOT ADDING " << flav <<
", corresponding position in JetCorrectorParameters is not found." << std::endl;
448 collection_type::const_iterator ibegin, iend,
i;
450 ibegin = correctionsL5_.begin();
451 iend = correctionsL5_.end();
453 }
else if ( isL7(k) ) {
454 ibegin = correctionsL7_.begin();
455 iend = correctionsL7_.end();
458 ibegin = corrections_.begin();
459 iend = corrections_.end();
462 for ( ; i != iend; ++
i ) {
463 if ( k == i->first )
return i->second;
465 throw cms::Exception(
"InvalidInput") <<
" cannot find key " <<
static_cast<int>(
k)
466 <<
" in the JEC payload, this usually means you have to change the global tag" << std::endl;
473 for ( collection_type::const_iterator ibegin = corrections_.begin(),
474 iend = corrections_.end(),
i = ibegin;
i != iend; ++
i ) {
475 keys.push_back(
i->first );
477 for ( collection_type::const_iterator ibegin = correctionsL5_.begin(),
478 iend = correctionsL5_.end(),
i = ibegin;
i != iend; ++
i ) {
479 keys.push_back(
i->first );
481 for ( collection_type::const_iterator ibegin = correctionsL7_.begin(),
482 iend = correctionsL7_.end(),
i = ibegin;
i != iend; ++
i ) {
483 keys.push_back(
i->first );
491 std::vector<std::string>::const_iterator
found =
492 find( l5Flavors_.begin(), l5Flavors_.end(), flav );
493 if ( found != l5Flavors_.end() ) {
494 return (found - l5Flavors_.begin() + 1) * 100;
496 else return L5Flavor;
501 std::vector<std::string>::const_iterator
found =
502 find( l7Partons_.begin(), l7Partons_.end(), flav );
503 if ( found != l7Partons_.end() ) {
504 return (found - l7Partons_.begin() + 1) * 1000;
506 else return L7Parton;
511 return k == L5Flavor ||
512 ( k / 100 > 0 && k / 1000 == 0 );
516 return k == L7Parton ||
526 std::vector<std::string>::const_iterator found1 =
527 find( l5Flavors_.begin(), l5Flavors_.end(),
label );
528 if ( found1 != l5Flavors_.end() ) {
529 return getL5Bin(label);
533 std::vector<std::string>::const_iterator found2 =
534 find( l7Partons_.begin(), l7Partons_.end(),
label );
535 if ( found2 != l7Partons_.end() ) {
536 return getL7Bin(label);
540 std::vector<std::string>::const_iterator found3 =
541 find( labels_.begin(), labels_.end(),
label );
542 if ( found3 != labels_.end() ) {
543 return static_cast<key_type>(found3 - labels_.begin());
547 throw cms::Exception(
"InvalidInput") <<
" Cannot find label " << label << std::endl;
float xMin(unsigned fVar) const
std::vector< float > mMax
static std::vector< std::string > labels_
void push_back(key_type i, value_type const &j, label_type const &flav="")
std::vector< float > mMin
const Definitions & definitions() const
static key_type getL5Bin(std::string const &flav)
static const char * l5FlavorArray_[N_L5_SPECIES]
static const char * labelsArray_[N_LEVELS]
std::vector< JetCorrectorParameters::Record > mRecords
const Record & record(unsigned fBin) const
std::vector< float > mParameters
std::vector< std::string > parVar() const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
std::string formula() const
float parameter(unsigned fIndex) const
void printFile(const std::string &fFileName) const
int binIndex(const std::vector< float > &fX) const
std::vector< float > binCenters(unsigned fVar) const
bool check(const DataFrame &df, bool capcheck, bool dvercheck)
static const char * l7PartonArray_[N_L7_SPECIES]
static std::vector< std::string > l7Partons_
key_type findKey(std::string const &label) const
static bool isL7(key_type k)
float xMax(unsigned fVar) const
#define TYPELOOKUP_DATA_REG(_dataclass_)
std::string level() const
static bool isL5(key_type k)
std::vector< std::string > mParVar
std::vector< std::string > mBinVar
static key_type getL7Bin(std::string const &flav)
std::vector< std::vector< double > > tmp
static std::vector< std::string > l5Flavors_
unsigned nParameters() const
static void getSections(std::string inputFile, std::vector< std::string > &outputs)
void validKeys(std::vector< key_type > &keys) const
std::vector< std::string > binVar() const
JetCorrectorParameters::Definitions mDefinitions
int neighbourBin(unsigned fIndex, unsigned fVar, bool fNext) const
JetCorrectorParameters const & operator[](key_type k) const