CMS 3D CMS Logo

FFTJetESParameterParser.h
Go to the documentation of this file.
1 #ifndef JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h
2 #define JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h
3 
6 
11 
14 
15 // Parser for the adjuster of the adjustable :-)
16 template <class Jet, class Adjustable>
17 std::shared_ptr<AbsFFTJetAdjuster<Jet, Adjustable> > parseFFTJetAdjuster(const edm::ParameterSet& ps,
18  const bool /* verbose */) {
19  typedef std::shared_ptr<AbsFFTJetAdjuster<Jet, Adjustable> > Result;
20 
21  const std::string& adjuster_type = ps.getParameter<std::string>("Class");
22 
23  if (!adjuster_type.compare("FFTSimpleScalingAdjuster"))
24  return Result(new FFTSimpleScalingAdjuster<Jet, Adjustable>());
25 
26  else if (!adjuster_type.compare("FFTUncertaintyAdjuster"))
27  return Result(new FFTUncertaintyAdjuster<Jet, Adjustable>());
28 
29  else if (!adjuster_type.compare("FFTScalingAdjusterWithUncertainty"))
31 
32  else
33  throw cms::Exception("FFTJetBadConfig")
34  << "In parseFFTJetAdjuster: unknown adjuster type \"" << adjuster_type << "\"\n";
35 }
36 
37 // Parser for the mapper/scaler
38 template <class Jet, class Adjustable>
39 std::shared_ptr<AbsFFTJetScaleCalculator<Jet, Adjustable> > parseFFTJetScaleCalculator(const edm::ParameterSet& ps,
40  gs::StringArchive& ar,
41  const bool verbose) {
42  typedef std::shared_ptr<AbsFFTJetScaleCalculator<Jet, Adjustable> > Result;
43 
44  std::string mapper_type(ps.getParameter<std::string>("Class"));
45 
46  // Initially, check for mappers which do not need to load
47  // a data table from the archive
48  // if (!mapper_type.compare("SomeClass"))
49  // {
50  // Do something ....
51  // return Result(...);
52  // }
53 
54  // Load the table from the archive
55  std::unique_ptr<npstat::StorableMultivariateFunctor> autof = loadFFTJetInterpolationTable(ps, ar, verbose);
56  std::shared_ptr<npstat::StorableMultivariateFunctor> f(autof.release());
57 
58  // Swap the class name if it is supposed to be determined
59  // from the table description
60  if (!mapper_type.compare("auto"))
61  mapper_type = f->description();
62 
63  if (!mapper_type.compare("FFTEtaLogPtConeRadiusMapper"))
65 
66  else if (!mapper_type.compare("FFTSpecificScaleCalculator")) {
67  const edm::ParameterSet& subclass = ps.getParameter<edm::ParameterSet>("Subclass");
69  return Result(new FFTSpecificScaleCalculator<Jet, Adjustable>(f, p));
70  }
71 
72  else
73  throw cms::Exception("FFTJetBadConfig")
74  << "In parseFFTJetScaleCalculator: unknown mapper type \"" << mapper_type << '"' << std::endl;
75 }
76 
77 // Parser for a single corrector of FFTJets
78 template <class Corrector>
79 Corrector parseFFTJetCorrector(const edm::ParameterSet& ps, gs::StringArchive& ar, const bool verbose) {
80  typedef typename Corrector::jet_type MyJet;
81  typedef typename Corrector::adjustable_type Adjustable;
82 
83  // "level" is an unsigned
84  const unsigned level(ps.getParameter<unsigned>("level"));
85 
86  // "applyTo" is a string
87  const std::string& applyTo(ps.getParameter<std::string>("applyTo"));
88 
89  // "adjuster" is a PSet
90  const edm::ParameterSet& adjuster = ps.getParameter<edm::ParameterSet>("adjuster");
91  std::shared_ptr<const AbsFFTJetAdjuster<MyJet, Adjustable> > adj =
92  parseFFTJetAdjuster<MyJet, Adjustable>(adjuster, verbose);
93 
94  // "scalers" is a VPSet
95  const std::vector<edm::ParameterSet>& scalers = ps.getParameter<std::vector<edm::ParameterSet> >("scalers");
96  const unsigned nScalers = scalers.size();
97  std::vector<std::shared_ptr<const AbsFFTJetScaleCalculator<MyJet, Adjustable> > > sVec;
98  sVec.reserve(nScalers);
99  for (unsigned i = 0; i < nScalers; ++i) {
100  std::shared_ptr<AbsFFTJetScaleCalculator<MyJet, Adjustable> > s =
101  parseFFTJetScaleCalculator<MyJet, Adjustable>(scalers[i], ar, verbose);
102  sVec.push_back(s);
103  }
104  return Corrector(adj, sVec, level, parseFFTJetCorrectorApp(applyTo));
105 }
106 
107 #endif // JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h
Multidimensional functor which picks one of the elements from an array of doubles.
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
bool verbose
Corrector parseFFTJetCorrector(const edm::ParameterSet &ps, gs::StringArchive &ar, const bool verbose)
std::shared_ptr< AbsFFTJetAdjuster< Jet, Adjustable > > parseFFTJetAdjuster(const edm::ParameterSet &ps, const bool)
double f[11][100]
AbsFFTSpecificScaleCalculator * parseFFTSpecificScaleCalculator(const edm::ParameterSet &ps, const std::string &tableDescription)
FFTJetCorrectorApp parseFFTJetCorrectorApp(const std::string &config)
std::unique_ptr< npstat::StorableMultivariateFunctor > loadFFTJetInterpolationTable(const edm::ParameterSet &ps, gs::StringArchive &ar, bool verbose)
std::shared_ptr< AbsFFTJetScaleCalculator< Jet, Adjustable > > parseFFTJetScaleCalculator(const edm::ParameterSet &ps, gs::StringArchive &ar, const bool verbose)