5 #ifndef PhysicsTools_PatAlgos_ObjectSpatialResolution_h
6 #define PhysicsTools_PatAlgos_ObjectSpatialResolution_h
32 #include "CLHEP/Random/RandGaussQ.h"
77 useDefaultIniRes_ = iConfig.
getParameter<
bool> (
"useDefaultInitialResolutions");
78 iniResPhi_ = iConfig.
getParameter<
double> (
"initialResolutionPhi");
79 worsenResPhi_ = iConfig.
getParameter<
double> (
"worsenResolutionPhi");
80 useWorsenResPhiByFactor_ = iConfig.
getParameter<
bool> (
"worsenResolutionPhiByFactor");
81 usePolarTheta_ = iConfig.
getParameter<
bool> (
"usePolarTheta");
82 iniResPolar_ = iConfig.
getParameter<
double> (
"initialResolutionPolar");
83 worsenResPolar_ = iConfig.
getParameter<
double> (
"worsenResolutionPolar");
84 useWorsenResPolarByFactor_ = iConfig.
getParameter<
bool> (
"worsenResolutionPolarByFactor");
87 CLHEP::HepRandomEngine& engine = rng->
getEngine();
88 gaussian_ =
new CLHEP::RandGaussQ(engine);
90 produces<std::vector<T> >();
106 std::vector<T> objects = *objectsHandle;
107 std::auto_ptr<std::vector<T> > objectsVector(
new std::vector<T>);
108 objectsVector->reserve(objectsHandle->size());
110 for (
unsigned int i = 0;
i < objects.size();
i++ ) {
111 smearAngles(objects[
i]);
112 objectsVector->push_back(objects[i]);
114 iEvent.
put(objectsVector);
124 if ( useDefaultIniRes_ ) {
126 iniResPhi_ =
object.resolutionPhi();
127 iniResPolar_ = usePolarTheta_ ?
128 object.resolutionTheta():
129 object.resolutionEta();
132 double finalResPhi = useWorsenResPhiByFactor_ ?
133 (1.+fabs(1.-fabs(worsenResPhi_))) * fabs(iniResPhi_):
134 fabs(worsenResPhi_) + fabs(iniResPhi_);
136 double finalResPolar = useWorsenResPolarByFactor_ ?
137 (1.+fabs(1.-fabs(worsenResPolar_))) * fabs(iniResPolar_):
138 fabs(worsenResPolar_) + fabs(iniResPolar_);
140 const double thetaMin = 2.*atan(
exp(-ROOT::Math::etaMax<double>()));
143 if ( usePolarTheta_ ) {
146 while ( fabs(smearedTheta) >
M_PI ) smearedTheta = smearedTheta < 0. ?
147 smearedTheta + 2.*
M_PI:
148 smearedTheta - 2.*
M_PI;
149 if ( smearedTheta < 0. ) {
150 smearedTheta = -smearedTheta;
153 smearedEta = smearedTheta < thetaMin ?
154 ROOT::Math::etaMax<double>() :
155 ( smearedTheta >
M_PI-thetaMin ?
156 -ROOT::Math::etaMax<double>():
157 -
log(
tan(smearedTheta/2.)) );
160 if ( fabs(smearedEta) > ROOT::Math::etaMax<double>() ) smearedEta = smearedEta < 0. ?
161 -ROOT::Math::etaMax<double>():
162 ROOT::Math::etaMax<double>();
163 smearedTheta = 2. * atan(
exp(-smearedEta));
171 newLorentzVector.Py(),
172 newLorentzVector.Pz(),
173 newLorentzVector.E() ));
T getParameter(std::string const &) const
void smearAngles(T &object)
bool useWorsenResPolarByFactor_
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
bool useWorsenResPhiByFactor_
virtual void produce(edm::Event &iEvent, const edm::EventSetup &iSetup)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Energy scale shifting and smearing module.
Tan< T >::type tan(const T &t)
ObjectSpatialResolution(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
~ObjectSpatialResolution()
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
CLHEP::RandGaussQ * gaussian_
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Power< A, B >::type pow(const A &a, const B &b)