CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/ElectroWeakAnalysis/ZMuMu/interface/ZMuMuScaledFunction.h

Go to the documentation of this file.
00001 #ifndef ElectroWeakAnalysis_ZMuMu_ZMuMuScaledFunction_h
00002 #define ElectroWeakAnalysis_ZMuMu_ZMuMuScaledFunction_h
00003 #include "PhysicsTools/Utilities/interface/Parameter.h"
00004 #include "ElectroWeakAnalysis/ZMuMu/interface/ZMuMuFunction.h"
00005 #include <boost/shared_ptr.hpp>
00006 
00007 namespace function {
00008   class ZMuMuScaledFunction {
00009    public: 
00010     static const unsigned int arguments = 1;
00011     ZMuMuScaledFunction(const ZMuMuFunction & zmm, int bin): 
00012       binScaleFactor(bin), zmm_(zmm) {}
00013      ZMuMuScaledFunction(const Parameter & m, const Parameter & g, 
00014                          const Parameter & Ng, const Parameter & Ni, 
00015                          const Parameter & me, const Parameter & s, 
00016                          const Parameter & N, 
00017                          const Parameter & eff_tr, const Parameter & eff_sa, 
00018                          int bin):
00019        mass(m.ptr()), width(g.ptr()), 
00020        Ngamma(Ng.ptr()), Nint(Ni.ptr()), 
00021        mean(me.ptr()), sigma(s.ptr()), 
00022        numberOfEvents(N.ptr()), 
00023        efficiencyTrack(eff_tr.ptr()), efficiencyStandalone(eff_sa.ptr()), 
00024        binScaleFactor(bin), 
00025        zmm_(m, g, Ng, Ni, me, s, N, eff_tr, eff_sa) {}
00026     ZMuMuScaledFunction(boost::shared_ptr<double> m, boost::shared_ptr<double> g, 
00027                         boost::shared_ptr<double> Ng, boost::shared_ptr<double> Ni, 
00028                         boost::shared_ptr<double> me, boost::shared_ptr<double> s, 
00029                         boost::shared_ptr<double> N, 
00030                         boost::shared_ptr<double> eff_tr, boost::shared_ptr<double> eff_sa, 
00031                         int bin):
00032       mass(m), width(g), 
00033       Ngamma(Ng), Nint(Ni), 
00034       mean(me), sigma(s), 
00035       numberOfEvents(N), 
00036       efficiencyTrack(eff_tr), efficiencyStandalone(eff_sa), 
00037       binScaleFactor(bin), 
00038       zmm_(m, g, Ng, Ni, me, s, N, eff_tr, eff_sa) {}
00039     double operator()(double x) const {
00040       return binScaleFactor * zmm_(x);
00041     }
00042     boost::shared_ptr<double> mass, width, Ngamma, Nint, mean, sigma;
00043     boost::shared_ptr<double> numberOfEvents, efficiencyTrack, efficiencyStandalone;
00044     int binScaleFactor;
00045   private:
00046     ZMuMuFunction zmm_;
00047   };
00048 }
00049 
00050 #endif
00051 
00052 /*template<typename F, int arguments = F::arguments, int parameters = F::parameters>
00053 class ScaleFactor{ 
00054   ScaleFactor(const int);
00055   void setParameters(const double *);
00056   double operator()(const double *) const;
00057  private:
00058   int bin_;
00059   F f_;
00060 };
00061 
00062 template <typename F>
00063 double scaleFunction(const double * x, const double * par, const int bin) {
00064   static ScaleFunction<F> f(bin);
00065   f.setParameters(par);
00066   return f(x);
00067 }
00068 
00069 template<typename F, int arguments, int parameters>
00070 ScaleFunction<F, arguments, parameters>::ScaleFunction(const double bin) :
00071   bin_(bin) {
00072 }
00073 
00074 template<typename F, int arguments>
00075 void ScaleFactor<F, arguments, 1>::setParameters(const double * par) {
00076   f_.setParameters(par[0]);
00077 }
00078 
00079 template<typename F, int arguments>
00080 void ScaleFactor<F, arguments, 2>::setParameters(const double * par) {
00081   f_.setParameters(par[0], par[1]);
00082 }
00083 
00084 template<typename F, int arguments>
00085 void ScaleFactor<F, arguments, 3>::setParameters(const double * par) {
00086   f_.setParameters(par[0], par[1], par[2]);
00087 }
00088 
00089 template<typename F, int arguments>
00090 void ScaleFactor<F, arguments, 4>::setParameters(const double * par) {
00091   f_.setParameters(par[0], par[1], par[2], par[3]);
00092 }
00093 
00094 template<typename F, int arguments>
00095 void ScaleFactor<F, arguments, 5>::setParameters(const double * par) {
00096   f_.setParameters(par[0], par[1], par[2], par[3], par[4]);
00097 }
00098 
00099 template<typename F, int arguments>
00100 void ScaleFactor<F, arguments, 6>::setParameters(const double * par) {
00101   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5]);
00102 }
00103 
00104 template<typename F, int arguments>
00105 void ScaleFactor<F, arguments, 7>::setParameters(const double * par) {
00106   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6]);
00107 }
00108 
00109 template<typename F, int arguments>
00110 void ScaleFactor<F, arguments, 8>::setParameters(const double * par) {
00111   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6], par[7]);
00112 }
00113 
00114 template<typename F, int arguments>
00115 void ScaleFactor<F, arguments, 9>::setParameters(const double * par) {
00116   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6], par[7], par[8]);
00117 }
00118 
00119 template<typename F, int arguments>
00120 void ScaleFunction<F, arguments, 10>::setParameters(const double * par) {
00121   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6], par[7], par[8], par[9]);
00122 }
00123 
00124 template<typename F, int arguments>
00125 void ScaleFactor<F, arguments, 11>::setParameters(const double * par) {
00126   f_.setParameters(par[0], par[1], par[2], par[3], par[4], par[5], par[6], par[7], par[8], par[9], par[10]);
00127 }
00128 
00129 template<typename F, int parameters>
00130 double ScaleFactor<F, 1, parameters>::operator()(const double * x) const{
00131   return f_(x[0]);
00132 }
00133 
00134 template<typename F, int parameters>
00135 double ScaleFactor<F, 2, parameters>::operator()(const double * x) const{
00136   return f_(x[0], x[1]);
00137 }
00138 */