Go to the documentation of this file.00001 #ifndef JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h
00002 #define JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h
00003
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 #include "FWCore/Utilities/interface/Exception.h"
00006
00007 #include "JetMETCorrections/FFTJetObjects/interface/FFTJetAdjusters.h"
00008 #include "JetMETCorrections/FFTJetObjects/interface/FFTJetScaleCalculators.h"
00009 #include "JetMETCorrections/FFTJetObjects/interface/FFTJetCorrectionsTypemap.h"
00010 #include "JetMETCorrections/FFTJetObjects/interface/loadFFTJetInterpolationTable.h"
00011
00012 #include "JetMETCorrections/InterpolationTables/interface/CoordinateSelector.h"
00013
00014
00015
00016 template<class Jet, class Adjustable>
00017 boost::shared_ptr<AbsFFTJetAdjuster<Jet, Adjustable> >
00018 parseFFTJetAdjuster(const edm::ParameterSet& ps, const bool )
00019 {
00020 typedef boost::shared_ptr<AbsFFTJetAdjuster<Jet,Adjustable> > Result;
00021
00022 const std::string& adjuster_type = ps.getParameter<std::string>("Class");
00023
00024 if (!adjuster_type.compare("FFTSimpleScalingAdjuster"))
00025 return Result(new FFTSimpleScalingAdjuster<Jet,Adjustable>());
00026
00027 else if (!adjuster_type.compare("FFTUncertaintyAdjuster"))
00028 return Result(new FFTUncertaintyAdjuster<Jet,Adjustable>());
00029
00030 else if (!adjuster_type.compare("FFTScalingAdjusterWithUncertainty"))
00031 return Result(new FFTScalingAdjusterWithUncertainty<Jet,Adjustable>());
00032
00033 else
00034 throw cms::Exception("FFTJetBadConfig")
00035 << "In parseFFTJetAdjuster: unknown adjuster type \""
00036 << adjuster_type << "\"\n";
00037 }
00038
00039
00040
00041 template<class Jet, class Adjustable>
00042 boost::shared_ptr<AbsFFTJetScaleCalculator<Jet, Adjustable> >
00043 parseFFTJetScaleCalculator(const edm::ParameterSet& ps,
00044 gs::StringArchive& ar,
00045 const bool verbose)
00046 {
00047 typedef boost::shared_ptr<AbsFFTJetScaleCalculator<Jet,Adjustable> > Result;
00048
00049 std::string mapper_type(ps.getParameter<std::string>("Class"));
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060 CPP11_auto_ptr<npstat::StorableMultivariateFunctor> autof =
00061 loadFFTJetInterpolationTable(ps, ar, verbose);
00062 CPP11_shared_ptr<npstat::StorableMultivariateFunctor> f(autof.release());
00063
00064
00065
00066 if (!mapper_type.compare("auto"))
00067 mapper_type = f->description();
00068
00069 if (!mapper_type.compare("FFTEtaLogPtConeRadiusMapper"))
00070 return Result(new FFTEtaLogPtConeRadiusMapper<Jet,Adjustable>(f));
00071
00072 else if (!mapper_type.compare("FFTSpecificScaleCalculator"))
00073 {
00074 const edm::ParameterSet& subclass =
00075 ps.getParameter<edm::ParameterSet>("Subclass");
00076 AbsFFTSpecificScaleCalculator* p = parseFFTSpecificScaleCalculator(
00077 subclass, f->description());
00078 return Result(new FFTSpecificScaleCalculator<Jet,Adjustable>(f, p));
00079 }
00080
00081 else
00082 throw cms::Exception("FFTJetBadConfig")
00083 << "In parseFFTJetScaleCalculator: unknown mapper type \""
00084 << mapper_type << '"' << std::endl;
00085 }
00086
00087
00088
00089 template<class Corrector>
00090 Corrector parseFFTJetCorrector(const edm::ParameterSet& ps,
00091 gs::StringArchive& ar,
00092 const bool verbose)
00093 {
00094 typedef typename Corrector::jet_type MyJet;
00095 typedef typename Corrector::adjustable_type Adjustable;
00096
00097
00098 const unsigned level(ps.getParameter<unsigned>("level"));
00099
00100
00101 const std::string& applyTo(ps.getParameter<std::string>("applyTo"));
00102
00103
00104 const edm::ParameterSet& adjuster = ps.getParameter<edm::ParameterSet>("adjuster");
00105 boost::shared_ptr<AbsFFTJetAdjuster<MyJet,Adjustable> > adj =
00106 parseFFTJetAdjuster<MyJet,Adjustable>(adjuster, verbose);
00107
00108
00109 const std::vector<edm::ParameterSet>& scalers =
00110 ps.getParameter<std::vector<edm::ParameterSet> >("scalers");
00111 const unsigned nScalers = scalers.size();
00112 std::vector<boost::shared_ptr<AbsFFTJetScaleCalculator<MyJet,Adjustable> > > sVec;
00113 sVec.reserve(nScalers);
00114 for (unsigned i=0; i<nScalers; ++i)
00115 {
00116 boost::shared_ptr<AbsFFTJetScaleCalculator<MyJet,Adjustable> > s =
00117 parseFFTJetScaleCalculator<MyJet,Adjustable>(scalers[i], ar, verbose);
00118 sVec.push_back(s);
00119 }
00120 return Corrector(adj, sVec, level, parseFFTJetCorrectorApp(applyTo));
00121 }
00122
00123 #endif // JetMETCorrections_FFTJetModules_FFTJetESParameterParser_h