CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
StringResolutionProvider.cc
Go to the documentation of this file.
1 #include <map>
2 #include <Math/Functions.h>
3 
7 
9 {
10  typedef pat::CandKinResolution::Parametrization Parametrization;
11 
12  //
13  std::vector<double> constr = cfg.getParameter<std::vector<double> > ("constraints");
14  constraints_.insert(constraints_.end(), constr.begin(), constr.end());
15 
16  std::string parametrization(cfg.getParameter<std::string> ("parametrization") );
18 
19  std::vector<edm::ParameterSet> functionSets_ = cfg.getParameter <std::vector<edm::ParameterSet> >("functions");
20  for(std::vector<edm::ParameterSet>::const_iterator iSet = functionSets_.begin(); iSet != functionSets_.end(); ++iSet){
21  if(iSet->exists("bin"))bins_.push_back(iSet->getParameter<std::string>("bin"));
22  else if(functionSets_.size()==1)bins_.push_back("");
23  else throw cms::Exception("WrongConfig") << "Parameter 'bin' is needed if more than one PSet is specified\n";
24 
25  funcEt_.push_back(iSet->getParameter<std::string>("et"));
26  funcEta_.push_back(iSet->getParameter<std::string>("eta"));
27  funcPhi_.push_back(iSet->getParameter<std::string>("phi"));
28  }
29 }
30 
32 {
33 }
34 
37 {
38  int selectedBin=-1;
39  for(unsigned int i=0; i<bins_.size(); ++i){
41  if(select_(cand)){
42  selectedBin = i;
43  break;
44  }
45  }
46  std::vector<pat::CandKinResolution::Scalar> covariances(3);
47  if(selectedBin>=0){
48  covariances[0] = ROOT::Math::Square(Function(funcEt_ [selectedBin]).operator()(cand));
49  covariances[1] = ROOT::Math::Square(Function(funcEta_[selectedBin]).operator()(cand));
50  covariances[2] = ROOT::Math::Square(Function(funcPhi_[selectedBin]).operator()(cand));
51  }
52  // fill 0. for not selected candidates
53  else for(int i=0; i<3; ++i){covariances[i] = 0.;}
54 
56 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
pat::CandKinResolution::Parametrization parametrization_
tuple cfg
Definition: looper.py:259
virtual ~StringResolutionProvider()
default destructor
StringObjectFunction< reco::Candidate > Function
short cut within the common namespace
virtual pat::CandKinResolution getResolution(const reco::Candidate &cand) const
get a CandKinResolution object from the service
std::vector< std::string > funcEt_
vectors for the resolution functions
StringResolutionProvider(const edm::ParameterSet &cfg)
default constructor
std::vector< std::string > funcEta_
std::vector< pat::CandKinResolution::Scalar > constraints_
std::vector< std::string > bins_
a vector of strings for the binning
pat::CandKinResolution::Parametrization fromString(const std::string &name)
Convert a name into a parametrization code.
std::vector< std::string > funcPhi_