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