CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/JetMETCorrections/FFTJetModules/interface/FFTJetESParameterParser.h

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 // Parser for the adjuster of the adjustable :-)
00016 template<class Jet, class Adjustable>
00017 boost::shared_ptr<AbsFFTJetAdjuster<Jet, Adjustable> >
00018 parseFFTJetAdjuster(const edm::ParameterSet& ps, const bool /* verbose */)
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 // Parser for the mapper/scaler
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     // Initially, check for mappers which do not need to load
00052     // a data table from the archive
00053 //     if (!mapper_type.compare("SomeClass"))
00054 //     {
00055 //         Do something ....
00056 //         return Result(...);
00057 //     }
00058 
00059     // Load the table from the archive
00060     CPP11_auto_ptr<npstat::StorableMultivariateFunctor> autof = 
00061         loadFFTJetInterpolationTable(ps, ar, verbose);
00062     CPP11_shared_ptr<npstat::StorableMultivariateFunctor> f(autof.release());
00063 
00064     // Swap the class name if it is supposed to be determined
00065     // from the table description
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 // Parser for a single corrector of FFTJets
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     // "level" is an unsigned
00098     const unsigned level(ps.getParameter<unsigned>("level"));
00099 
00100     // "applyTo" is a string
00101     const std::string& applyTo(ps.getParameter<std::string>("applyTo"));
00102 
00103     // "adjuster" is a PSet
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     // "scalers" is a VPSet
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