CMS 3D CMS Logo

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

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

Inheritance diagram for FFTJetVertexAdder:
edm::stream::EDProducer<>

Public Member Functions

 FFTJetVertexAdder (const edm::ParameterSet &)
 
 FFTJetVertexAdder ()=delete
 
 FFTJetVertexAdder (const FFTJetVertexAdder &)=delete
 
FFTJetVertexAdderoperator= (const FFTJetVertexAdder &)=delete
 
 ~FFTJetVertexAdder () override
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

Protected Member Functions

void beginStream (edm::StreamID) override
 
void produce (edm::Event &, const edm::EventSetup &) override
 

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::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

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() [1/3]

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

Definition at line 90 of file FFTJetVertexAdder.cc.

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

94  init_param(bool, useBeamSpot),
96  init_param(double, fixedX),
97  init_param(double, fixedY),
98  init_param(double, fixedZ),
99  init_param(double, sigmaX),
100  init_param(double, sigmaY),
101  init_param(double, sigmaZ),
102  init_param(double, nDof),
103  init_param(double, chi2),
104  init_param(double, errX),
105  init_param(double, errY),
106  init_param(double, errZ),
107  init_param(unsigned, nVerticesToMake) {
108  if (useBeamSpot)
109  beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
111  existingVerticesToken = consumes<reco::VertexCollection>(existingVerticesLabel);
112  produces<reco::VertexCollection>(outputLabel);
113 }
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() [2/3]

FFTJetVertexAdder::FFTJetVertexAdder ( )
delete

◆ FFTJetVertexAdder() [3/3]

FFTJetVertexAdder::FFTJetVertexAdder ( const FFTJetVertexAdder )
delete

◆ ~FFTJetVertexAdder()

FFTJetVertexAdder::~FFTJetVertexAdder ( )
override

Definition at line 115 of file FFTJetVertexAdder.cc.

115 {}

Member Function Documentation

◆ beginStream()

void FFTJetVertexAdder::beginStream ( edm::StreamID  )
overrideprotected

Definition at line 185 of file FFTJetVertexAdder.cc.

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

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

◆ operator=()

FFTJetVertexAdder& FFTJetVertexAdder::operator= ( const FFTJetVertexAdder )
delete

◆ produce()

void FFTJetVertexAdder::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 118 of file FFTJetVertexAdder.cc.

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

118  {
120  CLHEP::RandGauss rGauss(rng->getEngine(iEvent.streamID()));
121 
122  // get PFCandidates
123  auto pOutput = std::make_unique<reco::VertexCollection>();
124 
125  double xmean = fixedX;
126  double ymean = fixedY;
127  double zmean = fixedZ;
128 
129  double xwidth = sigmaX;
130  double ywidth = sigmaY;
131  double zwidth = sigmaZ;
132 
133  if (useBeamSpot) {
134  edm::Handle<reco::BeamSpot> beamSpotHandle;
135  iEvent.getByToken(beamSpotToken, beamSpotHandle);
136  if (!beamSpotHandle.isValid())
137  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetVertexAdder:"
138  " could not find beam spot information"
139  << std::endl;
140 
141  xmean = beamSpotHandle->x0();
142  ymean = beamSpotHandle->y0();
143  zmean = beamSpotHandle->z0();
144 
145  xwidth = beamSpotHandle->BeamWidthX();
146  ywidth = beamSpotHandle->BeamWidthY();
147  zwidth = beamSpotHandle->sigmaZ();
148  }
149 
151  for (unsigned i = 0; i < 3; ++i)
152  for (unsigned j = 0; j < 3; ++j)
153  err[i][j] = 0.0;
154  err[0][0] = errX * errX;
155  err[1][1] = errY * errY;
156  err[2][2] = errZ * errZ;
157 
158  for (unsigned iv = 0; iv < nVerticesToMake; ++iv) {
159  const double x0 = rGauss(xmean, xwidth);
160  const double y0 = rGauss(ymean, ywidth);
161  const double z0 = rGauss(zmean, zwidth);
162  const reco::Vertex::Point position(x0, y0, z0);
163  pOutput->push_back(reco::Vertex(position, err, chi2, nDof, 0));
164  }
165 
166  if (addExistingVertices) {
167  typedef reco::VertexCollection::const_iterator IV;
168 
171  if (!vertices.isValid())
172  throw cms::Exception("FFTJetBadConfig") << "ERROR in FFTJetVertexAdder:"
173  " could not find existing collection of vertices"
174  << std::endl;
175 
176  const IV vertend(vertices->end());
177  for (IV iv = vertices->begin(); iv != vertend; ++iv)
178  pOutput->push_back(*iv);
179  }
180 
181  iEvent.put(std::move(pOutput), outputLabel);
182 }
double BeamWidthX() const
beam width X
Definition: BeamSpot.h:82
const std::string outputLabel
int32_t *__restrict__ iv
const bool addExistingVertices
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
virtual CLHEP::HepRandomEngine & getEngine(StreamID const &)=0
Use this engine in event methods.
edm::EDGetTokenT< reco::VertexCollection > existingVerticesToken
const unsigned nVerticesToMake
double x0() const
x coordinate
Definition: BeamSpot.h:61
int iEvent
Definition: GenABIO.cc:224
double BeamWidthY() const
beam width Y
Definition: BeamSpot.h:84
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
double y0() const
y coordinate
Definition: BeamSpot.h:63
double sigmaZ() const
sigma z
Definition: BeamSpot.h:76
bool isValid() const
Definition: HandleBase.h:70
double z0() const
z coordinate
Definition: BeamSpot.h:65
static int position[264][3]
Definition: ReadPGInfo.cc:289
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
def move(src, dest)
Definition: eostools.py:511

Member Data Documentation

◆ addExistingVertices

const bool FFTJetVertexAdder::addExistingVertices
private

Definition at line 68 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

◆ beamSpotLabel

const edm::InputTag FFTJetVertexAdder::beamSpotLabel
private

Definition at line 59 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

◆ beamSpotToken

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

Definition at line 62 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

◆ chi2

const double FFTJetVertexAdder::chi2
private

Definition at line 79 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ errX

const double FFTJetVertexAdder::errX
private

Definition at line 80 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ errY

const double FFTJetVertexAdder::errY
private

Definition at line 81 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ errZ

const double FFTJetVertexAdder::errZ
private

Definition at line 82 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ existingVerticesLabel

const edm::InputTag FFTJetVertexAdder::existingVerticesLabel
private

Definition at line 60 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder().

◆ existingVerticesToken

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

Definition at line 63 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

◆ fixedX

const double FFTJetVertexAdder::fixedX
private

Definition at line 70 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ fixedY

const double FFTJetVertexAdder::fixedY
private

Definition at line 71 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ fixedZ

const double FFTJetVertexAdder::fixedZ
private

Definition at line 72 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ nDof

const double FFTJetVertexAdder::nDof
private

Definition at line 78 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ nVerticesToMake

const unsigned FFTJetVertexAdder::nVerticesToMake
private

Definition at line 84 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ outputLabel

const std::string FFTJetVertexAdder::outputLabel
private

Definition at line 65 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().

◆ sigmaX

const double FFTJetVertexAdder::sigmaX
private

Definition at line 74 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ sigmaY

const double FFTJetVertexAdder::sigmaY
private

Definition at line 75 of file FFTJetVertexAdder.cc.

Referenced by produce().

◆ sigmaZ

const double FFTJetVertexAdder::sigmaZ
private

Definition at line 76 of file FFTJetVertexAdder.cc.

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

◆ useBeamSpot

const bool FFTJetVertexAdder::useBeamSpot
private

Definition at line 67 of file FFTJetVertexAdder.cc.

Referenced by FFTJetVertexAdder(), and produce().