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  CPP11_auto_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
personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:428
FFTJetCorrectionsTypemap.h
parseFFTSpecificScaleCalculator
AbsFFTSpecificScaleCalculator * parseFFTSpecificScaleCalculator(const edm::ParameterSet &ps, const std::string &tableDescription)
Definition: AbsFFTSpecificScaleCalculator.cc:23
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
FFTJetScaleCalculators.h
loadFFTJetInterpolationTable.h
FFTUncertaintyAdjuster
Definition: FFTJetAdjusters.h:26
parseFFTJetScaleCalculator
std::shared_ptr< AbsFFTJetScaleCalculator< Jet, Adjustable > > parseFFTJetScaleCalculator(const edm::ParameterSet &ps, gs::StringArchive &ar, const bool verbose)
Definition: FFTJetESParameterParser.h:39
LumiMonitor_cff.scalers
scalers
Definition: LumiMonitor_cff.py:11
parseFFTJetCorrectorApp
FFTJetCorrectorApp parseFFTJetCorrectorApp(const std::string &config)
Definition: FFTJetCorrectorApp.cc:4
CoordinateSelector.h
Multidimensional functor which picks one of the elements from an array of doubles.
alignCSCRings.s
s
Definition: alignCSCRings.py:92
loadFFTJetInterpolationTable
std::unique_ptr< npstat::StorableMultivariateFunctor > loadFFTJetInterpolationTable(const edm::ParameterSet &ps, gs::StringArchive &ar, bool verbose)
Definition: loadFFTJetInterpolationTable.cc:28
FFTEtaLogPtConeRadiusMapper
Definition: FFTJetScaleCalculators.h:12
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
FFTJetAdjusters.h
parseFFTJetAdjuster
std::shared_ptr< AbsFFTJetAdjuster< Jet, Adjustable > > parseFFTJetAdjuster(const edm::ParameterSet &ps, const bool)
Definition: FFTJetESParameterParser.h:17
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
FFTSimpleScalingAdjuster
Definition: FFTJetAdjusters.h:7
FFTScalingAdjusterWithUncertainty
Definition: FFTJetAdjusters.h:46
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FFTSpecificScaleCalculator
Definition: FFTJetScaleCalculators.h:30
AbsFFTSpecificScaleCalculator
Definition: AbsFFTSpecificScaleCalculator.h:13
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
parseFFTJetCorrector
Corrector parseFFTJetCorrector(const edm::ParameterSet &ps, gs::StringArchive &ar, const bool verbose)
Definition: FFTJetESParameterParser.h:79
ParameterSet.h