CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
VertexBeamspotOrigins Class Reference

#include <VertexBeamspotOrigins.h>

Public Types

enum  OperationMode { OperationMode::BEAM_SPOT_FIXED, OperationMode::BEAM_SPOT_SIGMA, OperationMode::VERTICES_FIXED, OperationMode::VERTICES_SIGMA }
 
using Origins = std::vector< std::pair< GlobalPoint, float > >
 

Public Member Functions

Origins origins (const edm::Event &iEvent) const
 
 VertexBeamspotOrigins (const edm::ParameterSet &regPSet, edm::ConsumesCollector &&iC)
 
 VertexBeamspotOrigins (const edm::ParameterSet &regPSet, edm::ConsumesCollector &iC)
 
 ~VertexBeamspotOrigins ()=default
 

Static Public Member Functions

static void fillDescriptions (edm::ParameterSetDescription &desc, const std::string &defaultBeamSpot="offlineBeamSpot", const std::string &defaultVertex="firstStepPrimaryVertices", int defaultMaxVertices=-1)
 

Private Attributes

int m_maxNVertices
 
float m_nSigmaZBeamSpot
 
float m_nSigmaZVertex
 
OperationMode m_operationMode
 
float m_zErrorBeamSpot
 
float m_zErrorVertex
 
edm::EDGetTokenT< reco::BeamSpottoken_beamSpot
 
edm::EDGetTokenT< reco::VertexCollectiontoken_vertex
 

Detailed Description

Definition at line 15 of file VertexBeamspotOrigins.h.

Member Typedef Documentation

using VertexBeamspotOrigins::Origins = std::vector< std::pair< GlobalPoint, float > >

Definition at line 18 of file VertexBeamspotOrigins.h.

Member Enumeration Documentation

Enumerator
BEAM_SPOT_FIXED 
BEAM_SPOT_SIGMA 
VERTICES_FIXED 
VERTICES_SIGMA 

Definition at line 19 of file VertexBeamspotOrigins.h.

19 {BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, VERTICES_FIXED, VERTICES_SIGMA};

Constructor & Destructor Documentation

VertexBeamspotOrigins::VertexBeamspotOrigins ( const edm::ParameterSet regPSet,
edm::ConsumesCollector &&  iC 
)
inline

Definition at line 21 of file VertexBeamspotOrigins.h.

References fillDescriptions(), iEvent, origins(), AlCaHLTBitMon_QueryRunRegistry::string, and ~VertexBeamspotOrigins().

21 : VertexBeamspotOrigins(regPSet, iC) {}
VertexBeamspotOrigins(const edm::ParameterSet &regPSet, edm::ConsumesCollector &&iC)
VertexBeamspotOrigins::VertexBeamspotOrigins ( const edm::ParameterSet regPSet,
edm::ConsumesCollector iC 
)

Definition at line 3 of file VertexBeamspotOrigins.cc.

References BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, edm::ConsumesCollector::consumes(), Exception, edm::ParameterSet::getParameter(), m_maxNVertices, m_nSigmaZBeamSpot, m_nSigmaZVertex, m_operationMode, m_zErrorBeamSpot, m_zErrorVertex, AlCaHLTBitMon_QueryRunRegistry::string, token_beamSpot, token_vertex, VERTICES_FIXED, and VERTICES_SIGMA.

3  {
4  // operation mode
5  std::string operationModeString = regPSet.getParameter<std::string>("operationMode");
6  if (operationModeString == "BeamSpotFixed") m_operationMode = OperationMode::BEAM_SPOT_FIXED;
7  else if (operationModeString == "BeamSpotSigma") m_operationMode = OperationMode::BEAM_SPOT_SIGMA;
8  else if (operationModeString == "VerticesFixed") m_operationMode = OperationMode::VERTICES_FIXED;
9  else if (operationModeString == "VerticesSigma") m_operationMode = OperationMode::VERTICES_SIGMA;
10  else throw cms::Exception("Configuration") <<"Unknown operation mode string: "<<operationModeString;
11 
13  m_maxNVertices = 1;
15  token_vertex = iC.consumes<reco::VertexCollection>(regPSet.getParameter<edm::InputTag>("vertexCollection"));
16  m_maxNVertices = regPSet.getParameter<int>("maxNVertices");
17  }
18 
19  // mode-dependent z-halflength of tracking regions
20  m_zErrorBeamSpot = regPSet.getParameter<double>("zErrorBeamSpot");
21  if (m_operationMode == OperationMode::VERTICES_SIGMA) m_nSigmaZVertex = regPSet.getParameter<double>("nSigmaZVertex");
22  if (m_operationMode == OperationMode::VERTICES_FIXED) m_zErrorVertex = regPSet.getParameter<double>("zErrorVertex");
23  m_nSigmaZBeamSpot = -1.;
25  m_nSigmaZBeamSpot = regPSet.getParameter<double>("nSigmaZBeamSpot");
26  if (m_nSigmaZBeamSpot < 0.)
27  throw cms::Exception("Configuration") << "nSigmaZBeamSpot must be positive for BeamSpotSigma mode!";
28  }
29 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::VertexCollection > token_vertex
VertexBeamspotOrigins::~VertexBeamspotOrigins ( )
default

Referenced by VertexBeamspotOrigins().

Member Function Documentation

void VertexBeamspotOrigins::fillDescriptions ( edm::ParameterSetDescription desc,
const std::string &  defaultBeamSpot = "offlineBeamSpot",
const std::string &  defaultVertex = "firstStepPrimaryVertices",
int  defaultMaxVertices = -1 
)
static

Definition at line 31 of file VertexBeamspotOrigins.cc.

References edm::ParameterSetDescription::add(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::fillDescriptions(), AreaSeededTrackingRegionsProducer::fillDescriptions(), CandidatePointSeededTrackingRegionsProducer::fillDescriptions(), and VertexBeamspotOrigins().

32  {
33  desc.add<std::string>("operationMode", "BeamSpotFixed");
34  desc.add<edm::InputTag>("beamSpot", defaultBeamSpot);
35  desc.add<edm::InputTag>("vertexCollection", defaultVertex);
36  desc.add<int>("maxNVertices", defaultMaxVertices);
37 
38  desc.add<double>("nSigmaZBeamSpot", 4.);
39  desc.add<double>("zErrorBeamSpot", 24.2);
40  desc.add<double>("nSigmaZVertex", 3.);
41  desc.add<double>("zErrorVertex", 0.2);
42 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
VertexBeamspotOrigins::Origins VertexBeamspotOrigins::origins ( const edm::Event iEvent) const

Definition at line 44 of file VertexBeamspotOrigins.cc.

References BEAM_SPOT_FIXED, BEAM_SPOT_SIGMA, edm::Event::getByToken(), edm::HandleBase::isValid(), m_maxNVertices, m_nSigmaZBeamSpot, m_nSigmaZVertex, m_operationMode, m_zErrorBeamSpot, m_zErrorVertex, reco::BeamSpot::sigmaZ(), token_beamSpot, token_vertex, findQualityFiles::v, electrons_cff::vertices, VERTICES_FIXED, VERTICES_SIGMA, reco::BeamSpot::x0(), reco::BeamSpot::y0(), reco::BeamSpot::z0(), and reco::BeamSpot::z0Error().

Referenced by PixelInactiveAreaTrackingRegionsSeedingLayersProducer::produce(), AreaSeededTrackingRegionsProducer::regions(), CandidatePointSeededTrackingRegionsProducer::regions(), and VertexBeamspotOrigins().

44  {
45  Origins ret;
46 
47  // always need the beam spot (as a fall back strategy for vertex modes)
49  iEvent.getByToken( token_beamSpot, bs );
50  if( !bs.isValid() ) return ret;
51 
52  // this is a default origin for all modes
53  GlobalPoint default_origin( bs->x0(), bs->y0(), bs->z0() );
54 
55  // fill the origins and halfLengths depending on the mode
57  ret.emplace_back(default_origin,
61  iEvent.getByToken( token_vertex, vertices );
62  int n_vert = 0;
63  for(const auto& v: *vertices) {
64  if(v.isFake() || !v.isValid()) continue;
65 
66  ret.emplace_back( GlobalPoint( v.x(), v.y(), v.z() ),
68  ++n_vert;
69  if(m_maxNVertices >= 0 && n_vert >= m_maxNVertices) {
70  break;
71  }
72  }
73  // no-vertex fall-back case:
74  if(ret.empty()) {
75  ret.emplace_back( default_origin,
77  }
78  }
79 
80  return ret;
81 }
double z0() const
z coordinate
Definition: BeamSpot.h:68
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
std::vector< std::pair< GlobalPoint, float > > Origins
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
bool isValid() const
Definition: HandleBase.h:74
double z0Error() const
error on z
Definition: BeamSpot.h:94
edm::EDGetTokenT< reco::VertexCollection > token_vertex
double sigmaZ() const
sigma z
Definition: BeamSpot.h:80
double y0() const
y coordinate
Definition: BeamSpot.h:66
double x0() const
x coordinate
Definition: BeamSpot.h:64

Member Data Documentation

int VertexBeamspotOrigins::m_maxNVertices
private

Definition at line 38 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

float VertexBeamspotOrigins::m_nSigmaZBeamSpot
private

Definition at line 40 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

float VertexBeamspotOrigins::m_nSigmaZVertex
private

Definition at line 42 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

OperationMode VertexBeamspotOrigins::m_operationMode
private

Definition at line 33 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

float VertexBeamspotOrigins::m_zErrorBeamSpot
private

Definition at line 41 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

float VertexBeamspotOrigins::m_zErrorVertex
private

Definition at line 43 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

edm::EDGetTokenT<reco::BeamSpot> VertexBeamspotOrigins::token_beamSpot
private

Definition at line 36 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().

edm::EDGetTokenT<reco::VertexCollection> VertexBeamspotOrigins::token_vertex
private

Definition at line 35 of file VertexBeamspotOrigins.h.

Referenced by origins(), and VertexBeamspotOrigins().