5 #ifndef PhysicsTools_PatAlgos_ObjectEnergyScale_h
6 #define PhysicsTools_PatAlgos_ObjectEnergyScale_h
30 #include "CLHEP/Random/RandGaussQ.h"
74 shiftFactor_ = iConfig.
getParameter<
double> (
"shiftFactor");
75 useDefaultIniRes_ = iConfig.
getParameter<
bool> (
"useDefaultInitialResolution");
76 iniRes_ = iConfig.
getParameter<
double> (
"initialResolution");
77 useIniResByFraction_ = iConfig.
getParameter<
bool> (
"initialResolutionByFraction");
78 worsenRes_ = iConfig.
getParameter<
double> (
"worsenResolution");
79 useWorsenResByFactor_ = iConfig.
getParameter<
bool> (
"worsenResolutionByFactor");
82 CLHEP::HepRandomEngine& engine = rng->
getEngine();
83 gaussian_ =
new CLHEP::RandGaussQ(engine);
85 produces<std::vector<T> >();
101 std::vector<T> objects = *objectsHandle;
102 std::auto_ptr<std::vector<T> > objectsVector(
new std::vector<T>);
103 objectsVector->reserve(objectsHandle->size());
105 for (
unsigned int i = 0;
i < objects.size();
i++ ) {
106 factor_ = shiftFactor_ * ( objects[
i].energy() > 0. ?
107 getSmearing(objects[
i]) :
109 setScale(objects[i]);
110 objectsVector->push_back(objects[i]);
112 iEvent.
put(objectsVector);
123 if ( useDefaultIniRes_ ) {
126 }
else if ( ! useIniResByFraction_ ) {
128 iniRes_ = iniRes_ /
object.energy();
131 float finalRes = useWorsenResByFactor_ ?
132 (1.+fabs(1.-fabs(worsenRes_))) * fabs(iniRes_) :
133 fabs(worsenRes_)/
object.energy() + fabs(iniRes_);
148 float factorMomentum = useFixedMass_ &&
object.p() > 0. ?
153 factorMomentum*
object.py(),
154 factorMomentum*
object.pz(),
T getParameter(std::string const &) const
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
bool useIniResByFraction_
Energy scale shifting and smearing module.
const T & max(const T &a, const T &b)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Cos< T >::type cos(const T &t)
ObjectEnergyScale(const edm::ParameterSet &iConfig)
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool useWorsenResByFactor_
CLHEP::RandGaussQ * gaussian_
float getSmearing(T &object)
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Power< A, B >::type pow(const A &a, const B &b)