CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
FFTJetVertexAdder Class Reference

#include <RecoJets/FFTJetProducers/plugins/FFTJetVertexAdder.cc>

Inheritance diagram for FFTJetVertexAdder:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 FFTJetVertexAdder (const edm::ParameterSet &)
 
 ~FFTJetVertexAdder () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void beginJob () override
 
void endJob () override
 
void produce (edm::Event &, const edm::EventSetup &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Member Functions

 FFTJetVertexAdder ()=delete
 
 FFTJetVertexAdder (const FFTJetVertexAdder &)=delete
 
FFTJetVertexAdderoperator= (const FFTJetVertexAdder &)=delete
 

Private Attributes

const bool addExistingVertices
 
const edm::InputTag beamSpotLabel
 
edm::EDGetTokenT< reco::BeamSpotbeamSpotToken
 
const double chi2
 
const double errX
 
const double errY
 
const double errZ
 
const edm::InputTag existingVerticesLabel
 
edm::EDGetTokenT< reco::VertexCollectionexistingVerticesToken
 
const double fixedX
 
const double fixedY
 
const double fixedZ
 
const double nDof
 
const unsigned nVerticesToMake
 
const std::string outputLabel
 
const double sigmaX
 
const double sigmaY
 
const double sigmaZ
 
const bool useBeamSpot
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex >>
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

Detailed Description

Description: adds a collection of fake vertices to the event record

Implementation: [Notes on implementation]

Definition at line 45 of file FFTJetVertexAdder.cc.

Constructor & Destructor Documentation

FFTJetVertexAdder::FFTJetVertexAdder ( const edm::ParameterSet ps)
explicit

Definition at line 93 of file FFTJetVertexAdder.cc.

References addExistingVertices, beamSpotLabel, beamSpotToken, existingVerticesLabel, existingVerticesToken, outputLabel, and useBeamSpot.

97  init_param(bool, useBeamSpot),
99  init_param(double, fixedX),
100  init_param(double, fixedY),
101  init_param(double, fixedZ),
102  init_param(double, sigmaX),
103  init_param(double, sigmaY),
104  init_param(double, sigmaZ),
105  init_param(double, nDof),
106  init_param(double, chi2),
107  init_param(double, errX),
108  init_param(double, errY),
109  init_param(double, errZ),
110  init_param(unsigned, nVerticesToMake)
111 {
112  if (useBeamSpot)
113  beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
115  existingVerticesToken = consumes<reco::VertexCollection>(existingVerticesLabel);
116  produces<reco::VertexCollection>(outputLabel);
117 }
const std::string outputLabel
const bool addExistingVertices
#define init_param(type, varname)
edm::EDGetTokenT< reco::VertexCollection > existingVerticesToken
const unsigned nVerticesToMake
const edm::InputTag beamSpotLabel
const edm::InputTag existingVerticesLabel
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
FFTJetVertexAdder::~FFTJetVertexAdder ( )
override

Definition at line 120 of file FFTJetVertexAdder.cc.

121 {
122 }
FFTJetVertexAdder::FFTJetVertexAdder ( )
privatedelete
FFTJetVertexAdder::FFTJetVertexAdder ( const FFTJetVertexAdder )
privatedelete

Member Function Documentation

void FFTJetVertexAdder::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 201 of file FFTJetVertexAdder.cc.

References Exception, and edm::Service< T >::isAvailable().

202 {
204  if ( !rng.isAvailable() ) {
205  throw cms::Exception("FFTJetBadConfig")
206  << "ERROR in FFTJetVertexAdder:"
207  " failed to initialize the random number generator"
208  << std::endl;
209  }
210 }
bool isAvailable() const
Definition: Service.h:46
void FFTJetVertexAdder::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 214 of file FFTJetVertexAdder.cc.

References DEFINE_FWK_MODULE.

215 {
216 }
FFTJetVertexAdder& FFTJetVertexAdder::operator= ( const FFTJetVertexAdder )
privatedelete
void FFTJetVertexAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 126 of file FFTJetVertexAdder.cc.

References addExistingVertices, beamSpotToken, reco::BeamSpot::BeamWidthX(), reco::BeamSpot::BeamWidthY(), chi2, errX, errY, errZ, existingVerticesToken, fixedX, fixedY, fixedZ, edm::Event::getByToken(), edm::RandomNumberGenerator::getEngine(), mps_fire::i, edm::HandleBase::isValid(), eostools::move(), nDof, nVerticesToMake, outputLabel, position, edm::Event::put(), sigmaX, sigmaY, sigmaZ, reco::BeamSpot::sigmaZ(), edm::Event::streamID(), useBeamSpot, electrons_cff::vertices, reco::BeamSpot::x0(), reco::BeamSpot::y0(), and reco::BeamSpot::z0().

128 {
130  CLHEP::RandGauss rGauss(rng->getEngine(iEvent.streamID()));
131 
132  // get PFCandidates
133  auto pOutput = std::make_unique<reco::VertexCollection>();
134 
135  double xmean = fixedX;
136  double ymean = fixedY;
137  double zmean = fixedZ;
138 
139  double xwidth = sigmaX;
140  double ywidth = sigmaY;
141  double zwidth = sigmaZ;
142 
143  if (useBeamSpot)
144  {
145  edm::Handle<reco::BeamSpot> beamSpotHandle;
146  iEvent.getByToken(beamSpotToken, beamSpotHandle);
147  if (!beamSpotHandle.isValid())
148  throw cms::Exception("FFTJetBadConfig")
149  << "ERROR in FFTJetVertexAdder:"
150  " could not find beam spot information"
151  << std::endl;
152 
153  xmean = beamSpotHandle->x0();
154  ymean = beamSpotHandle->y0();
155  zmean = beamSpotHandle->z0();
156 
157  xwidth = beamSpotHandle->BeamWidthX();
158  ywidth = beamSpotHandle->BeamWidthY();
159  zwidth = beamSpotHandle->sigmaZ();
160  }
161 
163  for (unsigned i=0; i<3; ++i)
164  for (unsigned j=0; j<3; ++j)
165  err[i][j] = 0.0;
166  err[0][0] = errX*errX;
167  err[1][1] = errY*errY;
168  err[2][2] = errZ*errZ;
169 
170  for (unsigned iv=0; iv<nVerticesToMake; ++iv)
171  {
172  const double x0 = rGauss(xmean, xwidth);
173  const double y0 = rGauss(ymean, ywidth);
174  const double z0 = rGauss(zmean, zwidth);
175  const reco::Vertex::Point position(x0, y0, z0);
176  pOutput->push_back(reco::Vertex(position, err, chi2, nDof, 0));
177  }
178 
180  {
181  typedef reco::VertexCollection::const_iterator IV;
182 
184  iEvent.getByToken(existingVerticesToken, vertices);
185  if (!vertices.isValid())
186  throw cms::Exception("FFTJetBadConfig")
187  << "ERROR in FFTJetVertexAdder:"
188  " could not find existing collection of vertices"
189  << std::endl;
190 
191  const IV vertend(vertices->end());
192  for (IV iv=vertices->begin(); iv!=vertend; ++iv)
193  pOutput->push_back(*iv);
194  }
195 
196  iEvent.put(std::move(pOutput), outputLabel);
197 }
double z0() const
z coordinate
Definition: BeamSpot.h:68
const std::string outputLabel
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
const bool addExistingVertices
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::EDGetTokenT< reco::VertexCollection > existingVerticesToken
const unsigned nVerticesToMake
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:86
bool isValid() const
Definition: HandleBase.h:74
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:88
static int position[264][3]
Definition: ReadPGInfo.cc:509
StreamID streamID() const
Definition: Event.h:96
double y0() const
y coordinate
Definition: BeamSpot.h:66
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
def move(src, dest)
Definition: eostools.py:510
double x0() const
x coordinate
Definition: BeamSpot.h:64

Member Data Documentation

const bool FFTJetVertexAdder::addExistingVertices
private

Definition at line 71 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const edm::InputTag FFTJetVertexAdder::beamSpotLabel
private

Definition at line 62 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

edm::EDGetTokenT<reco::BeamSpot> FFTJetVertexAdder::beamSpotToken
private

Definition at line 65 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::chi2
private

Definition at line 82 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errX
private

Definition at line 83 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errY
private

Definition at line 84 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errZ
private

Definition at line 85 of file FFTJetVertexAdder.cc.

Referenced by produce().

const edm::InputTag FFTJetVertexAdder::existingVerticesLabel
private

Definition at line 63 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

edm::EDGetTokenT<reco::VertexCollection> FFTJetVertexAdder::existingVerticesToken
private

Definition at line 66 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::fixedX
private

Definition at line 73 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::fixedY
private

Definition at line 74 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::fixedZ
private

Definition at line 75 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::nDof
private

Definition at line 81 of file FFTJetVertexAdder.cc.

Referenced by produce().

const unsigned FFTJetVertexAdder::nVerticesToMake
private

Definition at line 87 of file FFTJetVertexAdder.cc.

Referenced by produce().

const std::string FFTJetVertexAdder::outputLabel
private

Definition at line 68 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::sigmaX
private

Definition at line 77 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::sigmaY
private

Definition at line 78 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::sigmaZ
private

Definition at line 79 of file FFTJetVertexAdder.cc.

Referenced by produce(), and BeamSpotObj.BeamSpot::Reset().

const bool FFTJetVertexAdder::useBeamSpot
private

Definition at line 70 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().