CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/src/RecoJets/FFTJetAlgorithms/src/EtaDependentPileup.cc

Go to the documentation of this file.
00001 #include <fstream>
00002 
00003 #include "RecoJets/FFTJetAlgorithms/interface/EtaDependentPileup.h"
00004 
00005 namespace fftjetcms {
00006     EtaDependentPileup::EtaDependentPileup(
00007         const fftjet::LinearInterpolator2d& interp,
00008         const double inputRhoFactor, const double outputRhoFactor)
00009         : interp_(interp),
00010           inputRhoFactor_(inputRhoFactor),
00011           outputRhoFactor_(outputRhoFactor),
00012           etaMin_(interp.xMin()),
00013           etaMax_(interp.xMax()),
00014           rhoMin_(interp.yMin()),
00015           rhoMax_(interp.yMax()),
00016           rhoStep_((rhoMax_ - rhoMin_)/interp.ny())
00017     {
00018         const double etaStep = (etaMax_ - etaMin_)/interp.nx();
00019         etaMin_ += etaStep*0.5;
00020         etaMax_ -= etaStep*0.5;
00021         rhoMin_ += rhoStep_*0.5;
00022         rhoMax_ -= rhoStep_*0.5;
00023         assert(etaMin_ < etaMax_);
00024         assert(rhoMin_ < rhoMax_);
00025     }
00026 
00027     double EtaDependentPileup::operator()(
00028         double eta, double /* phi */,
00029         const reco::FFTJetPileupSummary& summary) const
00030     {
00031         double value = 0.0;
00032         const double rho = summary.pileupRho()*inputRhoFactor_;
00033         if (eta < etaMin_)
00034             eta = etaMin_;
00035         if (eta > etaMax_)
00036             eta = etaMax_;
00037         if (rho >= rhoMin_ && rho <= rhoMax_)
00038             value = interp_(eta, rho);
00039         else
00040         {
00041             double x0, x1;
00042             if (rho < rhoMin_)
00043             {
00044                 x0 = rhoMin_;
00045                 x1 = rhoMin_ + rhoStep_*0.5;
00046             }
00047             else
00048             {
00049                 x0 = rhoMax_;
00050                 x1 = rhoMax_ - rhoStep_*0.5;
00051             }
00052             const double z0 = interp_(eta, x0);
00053             const double z1 = interp_(eta, x1);
00054             value = z0 + (z1 - z0)*((rho - x0)/(x1 - x0));
00055         }
00056         return (value > 0.0 ? value : 0.0)*outputRhoFactor_;
00057     }
00058 }