CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
pat::ObjectSpatialResolution< T > Class Template Reference

Energy scale shifting and smearing module. More...

#include "PhysicsTools/PatAlgos/interface/ObjectSpatialResolution.h"

Inheritance diagram for pat::ObjectSpatialResolution< T >:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 ObjectSpatialResolution (const edm::ParameterSet &iConfig)
 
 ~ObjectSpatialResolution ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 
void smearAngles (T &object)
 

Private Attributes

CLHEP::RandGaussQ * gaussian_
 
double iniResPhi_
 
double iniResPolar_
 
edm::InputTag objects_
 
bool useDefaultIniRes_
 
bool usePolarTheta_
 
bool useWorsenResPhiByFactor_
 
bool useWorsenResPolarByFactor_
 
double worsenResPhi_
 
double worsenResPolar_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

template<class T>
class pat::ObjectSpatialResolution< T >

Energy scale shifting and smearing module.

This class provides angular smearing to objects with resolutions for systematic error studies. A detailed documentation is found in PhysicsTools/PatAlgos/data/ObjectSpatialResolution.cfi

Author
Volker Adler
Version
Id:
ObjectSpatialResolution.h,v 1.3 2010/10/20 23:09:25 wmtan Exp

Definition at line 42 of file ObjectSpatialResolution.h.

Constructor & Destructor Documentation

template<class T >
pat::ObjectSpatialResolution< T >::ObjectSpatialResolution ( const edm::ParameterSet iConfig)
explicit

Definition at line 74 of file ObjectSpatialResolution.h.

References edm::RandomNumberGenerator::getEngine(), and edm::ParameterSet::getParameter().

75 {
76  objects_ = iConfig.getParameter<edm::InputTag>("movedObject");
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");
85 
87  CLHEP::HepRandomEngine& engine = rng->getEngine();
88  gaussian_ = new CLHEP::RandGaussQ(engine);
89 
90  produces<std::vector<T> >();
91 }
T getParameter(std::string const &) const
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...

Definition at line 95 of file ObjectSpatialResolution.h.

96 {
97  delete gaussian_;
98 }

Member Function Documentation

template<class T >
void pat::ObjectSpatialResolution< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 102 of file ObjectSpatialResolution.h.

References edm::Event::getByLabel(), i, and edm::Event::put().

103 {
104  edm::Handle<std::vector<T> > objectsHandle;
105  iEvent.getByLabel(objects_, objectsHandle);
106  std::vector<T> objects = *objectsHandle;
107  std::auto_ptr<std::vector<T> > objectsVector(new std::vector<T>);
108  objectsVector->reserve(objectsHandle->size());
109 
110  for ( unsigned int i = 0; i < objects.size(); i++ ) {
111  smearAngles(objects[i]);
112  objectsVector->push_back(objects[i]);
113  }
114  iEvent.put(objectsVector);
115 }
int i
Definition: DBlmapReader.cc:9
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
template<class T >
void pat::ObjectSpatialResolution< T >::smearAngles ( T object)
private

Sets initial resolution to resolution provided by input object if required, smears eta/theta and phi and sets the 4-vector accordingl.

Definition at line 121 of file ObjectSpatialResolution.h.

References relval_parameters_module::energy, eta(), create_public_lumi_plots::exp, create_public_lumi_plots::log, M_PI, normalizedPhi(), AlCaHLTBitMon_ParallelJobs::p, funct::pow(), funct::sin(), mathSSE::sqrt(), funct::tan(), and theta().

122 {
123  // overwrite config file parameters 'initialResolution...' if required
124  if ( useDefaultIniRes_ ) {
125  // get initial resolutions from input object
126  iniResPhi_ = object.resolutionPhi(); // overwrites config file parameter "initialResolution"
128  object.resolutionTheta():
129  object.resolutionEta(); // overwrites config file parameter "initialResolution"
130  }
131  // smear phi
132  double finalResPhi = useWorsenResPhiByFactor_ ?
133  (1.+fabs(1.-fabs(worsenResPhi_))) * fabs(iniResPhi_):
134  fabs(worsenResPhi_) + fabs(iniResPhi_); // conversions as protection from "finalRes_<iniRes_"
135  double smearedPhi = normalizedPhi( gaussian_->fire(object.phi(), sqrt(std::pow(finalResPhi,2)-std::pow(iniResPhi_,2))) );
136  double finalResPolar = useWorsenResPolarByFactor_ ?
137  (1.+fabs(1.-fabs(worsenResPolar_))) * fabs(iniResPolar_):
138  fabs(worsenResPolar_) + fabs(iniResPolar_); // conversions as protection from "finalRes_<iniRes_"
139  // smear theta/eta
140  const double thetaMin = 2.*atan(exp(-ROOT::Math::etaMax<double>())); // to be on the safe side; however, etaMax=22765 ==> thetaMin=0 within double precision
141  double smearedTheta,
142  smearedEta;
143  if ( usePolarTheta_ ) {
144  smearedTheta = gaussian_->fire(object.theta(), sqrt(std::pow(finalResPolar,2)-std::pow(iniResPolar_,2)));
145  // 0<theta<Pi needs to be assured to have proper calculation of eta
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;
151  smearedPhi = normalizedPhi(smearedPhi+M_PI);
152  }
153  smearedEta = smearedTheta < thetaMin ?
154  ROOT::Math::etaMax<double>() :
155  ( smearedTheta > M_PI-thetaMin ?
156  -ROOT::Math::etaMax<double>():
157  -log(tan(smearedTheta/2.)) ); // eta not calculable for theta=0,Pi, which could occur
158  } else {
159  smearedEta = gaussian_->fire(object.eta(), sqrt(std::pow(finalResPolar,2)-std::pow(iniResPolar_,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)); // since exp(x)>0 && atan() returns solution closest to 0, 0<theta<Pi should be assured.
164  }
165  // set smeared new 4-vector
166  math::PtEtaPhiELorentzVector newLorentzVector(object.p()*sin(smearedTheta),
167  smearedEta,
168  smearedPhi,
169  object.energy());
170  object.setP4(reco::Particle::LorentzVector(newLorentzVector.Px(),
171  newLorentzVector.Py(),
172  newLorentzVector.Pz(),
173  newLorentzVector.E() ));
174 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Geom::Theta< T > theta() const
T eta() const
T sqrt(T t)
Definition: SSEVec.h:46
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
#define M_PI
Definition: BFit3D.cc:3
PtEtaPhiELorentzVectorD PtEtaPhiELorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:28
double normalizedPhi(double phi)
Definition: normalizedPhi.cc:5
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Data Documentation

template<class T >
CLHEP::RandGaussQ* pat::ObjectSpatialResolution< T >::gaussian_
private

Definition at line 65 of file ObjectSpatialResolution.h.

template<class T >
double pat::ObjectSpatialResolution< T >::iniResPhi_
private

Definition at line 56 of file ObjectSpatialResolution.h.

template<class T >
double pat::ObjectSpatialResolution< T >::iniResPolar_
private

Definition at line 56 of file ObjectSpatialResolution.h.

template<class T >
edm::InputTag pat::ObjectSpatialResolution< T >::objects_
private

Definition at line 55 of file ObjectSpatialResolution.h.

template<class T >
bool pat::ObjectSpatialResolution< T >::useDefaultIniRes_
private

Definition at line 60 of file ObjectSpatialResolution.h.

template<class T >
bool pat::ObjectSpatialResolution< T >::usePolarTheta_
private

Definition at line 60 of file ObjectSpatialResolution.h.

template<class T >
bool pat::ObjectSpatialResolution< T >::useWorsenResPhiByFactor_
private

Definition at line 60 of file ObjectSpatialResolution.h.

template<class T >
bool pat::ObjectSpatialResolution< T >::useWorsenResPolarByFactor_
private

Definition at line 60 of file ObjectSpatialResolution.h.

template<class T >
double pat::ObjectSpatialResolution< T >::worsenResPhi_
private

Definition at line 56 of file ObjectSpatialResolution.h.

template<class T >
double pat::ObjectSpatialResolution< T >::worsenResPolar_
private

Definition at line 56 of file ObjectSpatialResolution.h.