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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
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)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
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::ProducerBase
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 92 of file FFTJetVertexAdder.cc.

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

96  init_param(bool, useBeamSpot),
98  init_param(double, fixedX),
99  init_param(double, fixedY),
100  init_param(double, fixedZ),
101  init_param(double, sigmaX),
102  init_param(double, sigmaY),
103  init_param(double, sigmaZ),
104  init_param(double, nDof),
105  init_param(double, chi2),
106  init_param(double, errX),
107  init_param(double, errY),
108  init_param(double, errZ),
109  init_param(unsigned, nVerticesToMake) {
110  if (useBeamSpot)
111  beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
113  existingVerticesToken = consumes<reco::VertexCollection>(existingVerticesLabel);
114  produces<reco::VertexCollection>(outputLabel);
115 }
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 117 of file FFTJetVertexAdder.cc.

117 {}
FFTJetVertexAdder::FFTJetVertexAdder ( )
privatedelete
FFTJetVertexAdder::FFTJetVertexAdder ( const FFTJetVertexAdder )
privatedelete

Member Function Documentation

void FFTJetVertexAdder::beginJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 187 of file FFTJetVertexAdder.cc.

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

187  {
189  if (!rng.isAvailable()) {
190  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetVertexAdder:"
191  " failed to initialize the random number generator"
192  << std::endl;
193  }
194 }
bool isAvailable() const
Definition: Service.h:40
void FFTJetVertexAdder::endJob ( void  )
overrideprotectedvirtual

Reimplemented from edm::EDProducer.

Definition at line 197 of file FFTJetVertexAdder.cc.

References DEFINE_FWK_MODULE.

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

Definition at line 120 of file FFTJetVertexAdder.cc.

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

120  {
122  CLHEP::RandGauss rGauss(rng->getEngine(iEvent.streamID()));
123 
124  // get PFCandidates
125  auto pOutput = std::make_unique<reco::VertexCollection>();
126 
127  double xmean = fixedX;
128  double ymean = fixedY;
129  double zmean = fixedZ;
130 
131  double xwidth = sigmaX;
132  double ywidth = sigmaY;
133  double zwidth = sigmaZ;
134 
135  if (useBeamSpot) {
136  edm::Handle<reco::BeamSpot> beamSpotHandle;
137  iEvent.getByToken(beamSpotToken, beamSpotHandle);
138  if (!beamSpotHandle.isValid())
139  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetVertexAdder:"
140  " could not find beam spot information"
141  << std::endl;
142 
143  xmean = beamSpotHandle->x0();
144  ymean = beamSpotHandle->y0();
145  zmean = beamSpotHandle->z0();
146 
147  xwidth = beamSpotHandle->BeamWidthX();
148  ywidth = beamSpotHandle->BeamWidthY();
149  zwidth = beamSpotHandle->sigmaZ();
150  }
151 
153  for (unsigned i = 0; i < 3; ++i)
154  for (unsigned j = 0; j < 3; ++j)
155  err[i][j] = 0.0;
156  err[0][0] = errX * errX;
157  err[1][1] = errY * errY;
158  err[2][2] = errZ * errZ;
159 
160  for (unsigned iv = 0; iv < nVerticesToMake; ++iv) {
161  const double x0 = rGauss(xmean, xwidth);
162  const double y0 = rGauss(ymean, ywidth);
163  const double z0 = rGauss(zmean, zwidth);
164  const reco::Vertex::Point position(x0, y0, z0);
165  pOutput->push_back(reco::Vertex(position, err, chi2, nDof, 0));
166  }
167 
168  if (addExistingVertices) {
169  typedef reco::VertexCollection::const_iterator IV;
170 
172  iEvent.getByToken(existingVerticesToken, vertices);
173  if (!vertices.isValid())
174  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetVertexAdder:"
175  " could not find existing collection of vertices"
176  << std::endl;
177 
178  const IV vertend(vertices->end());
179  for (IV iv = vertices->begin(); iv != vertend; ++iv)
180  pOutput->push_back(*iv);
181  }
182 
183  iEvent.put(std::move(pOutput), outputLabel);
184 }
double z0() const
z coordinate
Definition: BeamSpot.h:65
const std::string outputLabel
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
const bool addExistingVertices
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:82
bool isValid() const
Definition: HandleBase.h:70
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
static int position[264][3]
Definition: ReadPGInfo.cc:289
StreamID streamID() const
Definition: Event.h:96
double y0() const
y coordinate
Definition: BeamSpot.h:63
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
def move(src, dest)
Definition: eostools.py:511
double x0() const
x coordinate
Definition: BeamSpot.h:61

Member Data Documentation

const bool FFTJetVertexAdder::addExistingVertices
private

Definition at line 70 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const edm::InputTag FFTJetVertexAdder::beamSpotLabel
private

Definition at line 61 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

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

Definition at line 64 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::chi2
private

Definition at line 81 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errX
private

Definition at line 82 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errY
private

Definition at line 83 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::errZ
private

Definition at line 84 of file FFTJetVertexAdder.cc.

Referenced by produce().

const edm::InputTag FFTJetVertexAdder::existingVerticesLabel
private

Definition at line 62 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

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

Definition at line 65 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::fixedX
private

Definition at line 72 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::fixedY
private

Definition at line 73 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::fixedZ
private

Definition at line 74 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::nDof
private

Definition at line 80 of file FFTJetVertexAdder.cc.

Referenced by produce().

const unsigned FFTJetVertexAdder::nVerticesToMake
private

Definition at line 86 of file FFTJetVertexAdder.cc.

Referenced by produce().

const std::string FFTJetVertexAdder::outputLabel
private

Definition at line 67 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

const double FFTJetVertexAdder::sigmaX
private

Definition at line 76 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::sigmaY
private

Definition at line 77 of file FFTJetVertexAdder.cc.

Referenced by produce().

const double FFTJetVertexAdder::sigmaZ
private

Definition at line 78 of file FFTJetVertexAdder.cc.

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

const bool FFTJetVertexAdder::useBeamSpot
private

Definition at line 69 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().