CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
JetCorrectorParametersCollection Class Reference

#include <JetCorrectorParameters.h>

Public Types

typedef std::vector< pair_typecollection_type
 
typedef int key_type
 
enum  L5_Species_t {
  L5_bJ =0, L5_cJ, L5_qJ, L5_gJ,
  L5_bT, L5_cT, L5_qT, L5_gT,
  N_L5_SPECIES
}
 
enum  L7_Species_t {
  L7_gJ =0, L7_qJ, L7_cJ, L7_bJ,
  L7_jJ, L7_qT, L7_cT, L7_bT,
  L7_jT, N_L7_SPECIES
}
 
typedef std::string label_type
 
enum  Level_t {
  L1Offset =0, L1JPTOffset =7, L1FastJet = 10, L2Relative =1,
  L3Absolute =2, L2L3Residual =8, L4EMF =3, L5Flavor =4,
  L6UE =5, L7Parton =6, Uncertainty =9, N_LEVELS =11
}
 
typedef std::pair< key_type,
value_type
pair_type
 
typedef JetCorrectorParameters value_type
 

Public Member Functions

 JetCorrectorParametersCollection ()
 
JetCorrectorParameters const & operator[] (key_type k) const
 
JetCorrectorParameters const & operator[] (std::string const &label) const
 
void push_back (key_type i, value_type const &j, label_type const &flav="")
 
void validKeys (std::vector< key_type > &keys) const
 

Static Public Member Functions

static std::string findL5Flavor (key_type k)
 
static std::string findL7Parton (key_type k)
 
static std::string findLabel (key_type k)
 
static key_type getL5Bin (std::string const &flav)
 
static key_type getL7Bin (std::string const &flav)
 
static void getSections (std::string inputFile, std::vector< std::string > &outputs)
 
static bool isL5 (key_type k)
 
static bool isL7 (key_type k)
 

Protected Member Functions

key_type findKey (std::string const &label) const
 

Protected Attributes

collection_type corrections_
 
collection_type correctionsL5_
 
collection_type correctionsL7_
 

Static Protected Attributes

static const char * l5FlavorArray_ [N_L5_SPECIES]
 
static std::vector< std::string > l5Flavors_
 
static const char * l7PartonArray_ [N_L7_SPECIES]
 
static std::vector< std::string > l7Partons_
 
static std::vector< std::string > labels_
 
static const char * labelsArray_ [N_LEVELS]
 

Detailed Description

Definition at line 100 of file JetCorrectorParameters.h.

Member Typedef Documentation

Definition at line 126 of file JetCorrectorParameters.h.

Definition at line 122 of file JetCorrectorParameters.h.

Definition at line 123 of file JetCorrectorParameters.h.

Definition at line 125 of file JetCorrectorParameters.h.

Definition at line 124 of file JetCorrectorParameters.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

JetCorrectorParametersCollection::JetCorrectorParametersCollection ( )
inline

Member Function Documentation

JetCorrectorParametersCollection::key_type JetCorrectorParametersCollection::findKey ( std::string const &  label) const
protected

Definition at line 506 of file JetCorrectorParameters.cc.

References edm::hlt::Exception, spr::find(), and label.

Referenced by operator[]().

506  {
507 
508  // First check L5 corrections
509  std::vector<std::string>::const_iterator found1 =
510  find( l5Flavors_.begin(), l5Flavors_.end(), label );
511  if ( found1 != l5Flavors_.end() ) {
512  return getL5Bin(label);
513  }
514 
515  // Next check L7 corrections
516  std::vector<std::string>::const_iterator found2 =
517  find( l7Partons_.begin(), l7Partons_.end(), label );
518  if ( found2 != l7Partons_.end() ) {
519  return getL7Bin(label);
520  }
521 
522  // Finally check the default corrections
523  std::vector<std::string>::const_iterator found3 =
524  find( labels_.begin(), labels_.end(), label );
525  if ( found3 != labels_.end() ) {
526  return static_cast<key_type>(found3 - labels_.begin());
527  }
528 
529  // Didn't find default corrections, throw exception
530  throw cms::Exception("InvalidInput") << " Cannot find label " << label << std::endl;
531 
532 }
static std::vector< std::string > labels_
const std::string & label
Definition: MVAComputer.cc:186
static key_type getL5Bin(std::string const &flav)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static std::vector< std::string > l7Partons_
static key_type getL7Bin(std::string const &flav)
static std::vector< std::string > l5Flavors_
static std::string JetCorrectorParametersCollection::findL5Flavor ( key_type  k)
inlinestatic

Definition at line 172 of file JetCorrectorParameters.h.

References L5Flavor, l5Flavors_, and labels_.

Referenced by findLabel().

172  {
173  if ( k == L5Flavor ) return labels_[L5Flavor];
174  else
175  return l5Flavors_[k / 100 - 1];
176  }
static std::vector< std::string > labels_
int k[5][pyjets_maxn]
static std::vector< std::string > l5Flavors_
static std::string JetCorrectorParametersCollection::findL7Parton ( key_type  k)
inlinestatic

Definition at line 178 of file JetCorrectorParameters.h.

References L7Parton, l7Partons_, and labels_.

Referenced by findLabel().

178  {
179  if ( k == L7Parton ) return labels_[L7Parton];
180  else
181  return l7Partons_[k / 1000 - 1];
182  }
static std::vector< std::string > labels_
static std::vector< std::string > l7Partons_
int k[5][pyjets_maxn]
static std::string JetCorrectorParametersCollection::findLabel ( key_type  k)
inlinestatic

Definition at line 166 of file JetCorrectorParameters.h.

References findL5Flavor(), findL7Parton(), isL5(), isL7(), gen::k, and labels_.

Referenced by JetCorrectorDBWriter::beginJob().

166  {
167  if ( isL5(k) ) return findL5Flavor(k);
168  else if ( isL7(k) ) return findL7Parton(k);
169  else return labels_[k];
170  }
static std::vector< std::string > labels_
static std::string findL7Parton(key_type k)
static std::string findL5Flavor(key_type k)
int k[5][pyjets_maxn]
JetCorrectorParametersCollection::key_type JetCorrectorParametersCollection::getL5Bin ( std::string const &  flav)
static

Definition at line 473 of file JetCorrectorParameters.cc.

References spr::find(), and newFWLiteAna::found.

473  {
474  std::vector<std::string>::const_iterator found =
475  find( l5Flavors_.begin(), l5Flavors_.end(), flav );
476  if ( found != l5Flavors_.end() ) {
477  return (found - l5Flavors_.begin() + 1) * 100;
478  }
479  else return L5Flavor;
480 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static std::vector< std::string > l5Flavors_
JetCorrectorParametersCollection::key_type JetCorrectorParametersCollection::getL7Bin ( std::string const &  flav)
static

Definition at line 483 of file JetCorrectorParameters.cc.

References spr::find(), and newFWLiteAna::found.

483  {
484  std::vector<std::string>::const_iterator found =
485  find( l7Partons_.begin(), l7Partons_.end(), flav );
486  if ( found != l7Partons_.end() ) {
487  return (found - l7Partons_.begin() + 1) * 1000;
488  }
489  else return L7Parton;
490 }
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
static std::vector< std::string > l7Partons_
void JetCorrectorParametersCollection::getSections ( std::string  inputFile,
std::vector< std::string > &  outputs 
)
static

Definition at line 388 of file JetCorrectorParameters.cc.

References filterCSVwithJSON::copy, gather_cfg::cout, insertMaterial::getSection(), recoMuon::in, and collect_tpl::input.

Referenced by JetCorrectorDBWriter::beginJob().

390 {
391  outputs.clear();
392  std::ifstream input( inputFile.c_str() );
393  while( !input.eof() ) {
394  char buff[10000];
395  input.getline(buff,10000);
396  std::string in(buff);
397  if ( in[0] == '[' ) {
398  std::string tok = getSection(in);
399  if ( tok != "" ) {
400  outputs.push_back( tok );
401  }
402  }
403  }
404  std::cout << "Found these sections for file: " << std::endl;
405  copy(outputs.begin(),outputs.end(), std::ostream_iterator<std::string>(std::cout, "\n") );
406 }
tuple input
Definition: collect_tpl.py:10
tuple cout
Definition: gather_cfg.py:41
bool JetCorrectorParametersCollection::isL5 ( key_type  k)
static

Definition at line 493 of file JetCorrectorParameters.cc.

Referenced by findLabel().

493  {
494  return k == L5Flavor ||
495  ( k / 100 > 0 && k / 1000 == 0 );
496 }
int k[5][pyjets_maxn]
bool JetCorrectorParametersCollection::isL7 ( key_type  k)
static

Definition at line 498 of file JetCorrectorParameters.cc.

Referenced by findLabel().

498  {
499  return k == L7Parton ||
500  ( k / 1000 > 0 );
501 }
int k[5][pyjets_maxn]
JetCorrectorParameters const & JetCorrectorParametersCollection::operator[] ( key_type  k) const

Definition at line 431 of file JetCorrectorParameters.cc.

References edm::hlt::Exception, i, and gen::k.

Referenced by operator[]().

431  {
432  collection_type::const_iterator ibegin, iend, i;
433  if ( isL5(k) ) {
434  ibegin = correctionsL5_.begin();
435  iend = correctionsL5_.end();
436  i = ibegin;
437  } else if ( isL7(k) ) {
438  ibegin = correctionsL7_.begin();
439  iend = correctionsL7_.end();
440  i = ibegin;
441  } else {
442  ibegin = corrections_.begin();
443  iend = corrections_.end();
444  i = ibegin;
445  }
446  for ( ; i != iend; ++i ) {
447  if ( k == i->first ) return i->second;
448  }
449  throw cms::Exception("InvalidInput") << " cannot find key " << static_cast<int>(k) << std::endl;
450 }
int i
Definition: DBlmapReader.cc:9
int k[5][pyjets_maxn]
JetCorrectorParameters const& JetCorrectorParametersCollection::operator[] ( std::string const &  label) const
inline

Definition at line 142 of file JetCorrectorParameters.h.

References findKey(), and operator[]().

142  {
143  return operator[]( findKey(label) );
144  }
const std::string & label
Definition: MVAComputer.cc:186
key_type findKey(std::string const &label) const
JetCorrectorParameters const & operator[](key_type k) const
void JetCorrectorParametersCollection::push_back ( key_type  i,
value_type const &  j,
label_type const &  flav = "" 
)

Definition at line 410 of file JetCorrectorParameters.cc.

References gather_cfg::cout, and pair_type.

Referenced by JetCorrectorDBWriter::beginJob(), and pat::JetCorrFactorsProducer::params().

410  {
411  std::cout << "i = " << i << std::endl;
412  std::cout << "flav = " << flav << std::endl;
413  if ( isL5(i) ) {
414  std::cout << "This is L5, getL5Bin = " << getL5Bin(flav) << std::endl;
415  correctionsL5_.push_back( pair_type(getL5Bin(flav),j) );
416  }
417  else if ( isL7(i) ) {
418  std::cout << "This is L7, getL7Bin = " << getL7Bin(flav) << std::endl;
419  correctionsL7_.push_back( pair_type(getL7Bin(flav),j) );
420  }
421  else if ( flav == "" ) {
422  corrections_.push_back( pair_type(i,j) );
423  } else {
424  std::cout << "***** NOT ADDING " << flav << ", corresponding position in JetCorrectorParameters is not found." << std::endl;
425  }
426 }
int i
Definition: DBlmapReader.cc:9
std::pair< key_type, value_type > pair_type
static key_type getL5Bin(std::string const &flav)
int j
Definition: DBlmapReader.cc:9
static key_type getL7Bin(std::string const &flav)
tuple cout
Definition: gather_cfg.py:41
void JetCorrectorParametersCollection::validKeys ( std::vector< key_type > &  keys) const

Definition at line 454 of file JetCorrectorParameters.cc.

References i.

454  {
455  keys.clear();
456  for ( collection_type::const_iterator ibegin = corrections_.begin(),
457  iend = corrections_.end(), i = ibegin; i != iend; ++i ) {
458  keys.push_back( i->first );
459  }
460  for ( collection_type::const_iterator ibegin = correctionsL5_.begin(),
461  iend = correctionsL5_.end(), i = ibegin; i != iend; ++i ) {
462  keys.push_back( i->first );
463  }
464  for ( collection_type::const_iterator ibegin = correctionsL7_.begin(),
465  iend = correctionsL7_.end(), i = ibegin; i != iend; ++i ) {
466  keys.push_back( i->first );
467  }
468 }
int i
Definition: DBlmapReader.cc:9

Member Data Documentation

collection_type JetCorrectorParametersCollection::corrections_
protected

Definition at line 189 of file JetCorrectorParameters.h.

Referenced by JetCorrectorParametersCollection().

collection_type JetCorrectorParametersCollection::correctionsL5_
protected

Definition at line 190 of file JetCorrectorParameters.h.

Referenced by JetCorrectorParametersCollection().

collection_type JetCorrectorParametersCollection::correctionsL7_
protected

Definition at line 191 of file JetCorrectorParameters.h.

Referenced by JetCorrectorParametersCollection().

const char * JetCorrectorParametersCollection::l5FlavorArray_
staticprotected
Initial value:
=
{
"L5Flavor_bJ",
"L5Flavor_cJ",
"L5Flavor_qJ",
"L5Flavor_gJ",
"L5Flavor_bT",
"L5Flavor_cT",
"L5Flavor_qT",
"L5Flavor_gT"
}

Definition at line 195 of file JetCorrectorParameters.h.

std::vector< std::string > JetCorrectorParametersCollection::l5Flavors_
staticprotected

Definition at line 196 of file JetCorrectorParameters.h.

Referenced by findL5Flavor().

const char * JetCorrectorParametersCollection::l7PartonArray_
staticprotected
Initial value:
=
{
"L7Parton_gJ",
"L7Parton_qJ",
"L7Parton_cJ",
"L7Parton_bJ",
"L7Parton_jJ",
"L7Parton_qT",
"L7Parton_cT",
"L7Parton_bT",
"L7Parton_tT"
}

Definition at line 198 of file JetCorrectorParameters.h.

std::vector< std::string > JetCorrectorParametersCollection::l7Partons_
staticprotected

Definition at line 199 of file JetCorrectorParameters.h.

Referenced by findL7Parton().

std::vector< std::string > JetCorrectorParametersCollection::labels_
staticprotected

Definition at line 193 of file JetCorrectorParameters.h.

Referenced by findL5Flavor(), findL7Parton(), and findLabel().

const char * JetCorrectorParametersCollection::labelsArray_
staticprotected
Initial value:
=
{
"L1Offset",
"L2Relative",
"L3Absolute",
"L4EMF",
"L5Flavor",
"L6UE",
"L7Parton",
"L1JPTOffset",
"L2L3Residual",
"Uncertainty",
"L1FastJet"
}

Definition at line 192 of file JetCorrectorParameters.h.