// Find the key corresponding to each label
JetCorrectorParametersCollection::key_type
JetCorrectorParametersCollection::findKey( std::string const & label ) const {

  // First check L5 corrections
  std::vector<std::string>::const_iterator found1 =
    find( l5Flavors_.begin(), l5Flavors_.end(), label );
  if ( found1 != l5Flavors_.end() ) {
    return getL5Bin(label);
  }

  // Next check L7 corrections
  std::vector<std::string>::const_iterator found2 =
    find( l7Partons_.begin(), l7Partons_.end(), label );
  if ( found2 != l7Partons_.end() ) {
    return getL7Bin(label);
  }

  // Finally check the default corrections
  std::vector<std::string>::const_iterator found3 =
    find( labels_.begin(), labels_.end(), label );
  if ( found3 != labels_.end() ) {
    return static_cast<key_type>(found3 - labels_.begin());
  }

  // Didn't find default corrections, throw exception
  handleError("InvalidInput","Cannot find label "+ label ) ;

}
Example #2
0
// Find the key corresponding to each label
JetCorrectorParametersCollection::key_type 
JetCorrectorParametersCollection::findKey( std::string const & label ) const {

  // First check L5 corrections
  std::vector<std::string>::const_iterator found1 =
    find( l5Flavors_.begin(), l5Flavors_.end(), label );
  if ( found1 != l5Flavors_.end() ) {
    return getL5Bin(label);
  } 

  // Next check L7 corrections
  std::vector<std::string>::const_iterator found2 =
    find( l7Partons_.begin(), l7Partons_.end(), label );
  if ( found2 != l7Partons_.end() ) {
    return getL7Bin(label);
  } 

  // Finally check the default corrections
  std::vector<std::string>::const_iterator found3 =
    find( labels_.begin(), labels_.end(), label );
  if ( found3 != labels_.end() ) {
    return static_cast<key_type>(found3 - labels_.begin());
  } 

  // Didn't find default corrections, throw exception
  throw std::out_of_range(Form("[JetCorrectorParameterCollecion::findKey()]: cannot find label %s", label.c_str()));
  //std::cout << " Cannot find label " << label << std::endl;
  //assert(0); 
}
// Add a JetCorrectorParameter object, possibly with flavor.
void JetCorrectorParametersCollection::push_back( key_type i, value_type const & j, label_type const & flav) {
  std::cout << "i    = " << i << std::endl;
  std::cout << "flav = " << flav << std::endl;
  if ( isL5(i) ) {
    std::cout << "This is L5, getL5Bin = " << getL5Bin(flav) << std::endl;
    correctionsL5_.push_back( pair_type(getL5Bin(flav),j) );
  }
  else if ( isL7(i) ) {
    std::cout << "This is L7, getL7Bin = " << getL7Bin(flav) << std::endl;
    correctionsL7_.push_back( pair_type(getL7Bin(flav),j) );
  }
  else if ( flav == "" ) {
    corrections_.push_back( pair_type(i,j) );
  } else {
    std::cout << "***** NOT ADDING " << flav << ", corresponding position in JetCorrectorParameters is not found." << std::endl;
  }
}