CMS 3D CMS Logo

VertexBeamspotOrigins.cc
Go to the documentation of this file.
2 
4  // operation mode
5  std::string operationModeString = regPSet.getParameter<std::string>("operationMode");
6  if (operationModeString == "BeamSpotFixed")
8  else if (operationModeString == "BeamSpotSigma")
10  else if (operationModeString == "VerticesFixed")
12  else if (operationModeString == "VerticesSigma")
14  else
15  throw cms::Exception("Configuration") << "Unknown operation mode string: " << operationModeString;
16 
18  m_maxNVertices = 1;
20  token_vertex = iC.consumes<reco::VertexCollection>(regPSet.getParameter<edm::InputTag>("vertexCollection"));
21  m_maxNVertices = regPSet.getParameter<int>("maxNVertices");
22  }
23 
24  // mode-dependent z-halflength of tracking regions
25  m_zErrorBeamSpot = regPSet.getParameter<double>("zErrorBeamSpot");
27  m_nSigmaZVertex = regPSet.getParameter<double>("nSigmaZVertex");
29  m_zErrorVertex = regPSet.getParameter<double>("zErrorVertex");
30  m_nSigmaZBeamSpot = -1.;
32  m_nSigmaZBeamSpot = regPSet.getParameter<double>("nSigmaZBeamSpot");
33  if (m_nSigmaZBeamSpot < 0.)
34  throw cms::Exception("Configuration") << "nSigmaZBeamSpot must be positive for BeamSpotSigma mode!";
35  }
36 }
37 
39  const std::string& defaultBeamSpot,
40  const std::string& defaultVertex,
41  int defaultMaxVertices) {
42  desc.add<std::string>("operationMode", "BeamSpotFixed");
43  desc.add<edm::InputTag>("beamSpot", defaultBeamSpot);
44  desc.add<edm::InputTag>("vertexCollection", defaultVertex);
45  desc.add<int>("maxNVertices", defaultMaxVertices);
46 
47  desc.add<double>("nSigmaZBeamSpot", 4.);
48  desc.add<double>("zErrorBeamSpot", 24.2);
49  desc.add<double>("nSigmaZVertex", 3.);
50  desc.add<double>("zErrorVertex", 0.2);
51 }
52 
54  Origins ret;
55 
56  // always need the beam spot (as a fall back strategy for vertex modes)
58  iEvent.getByToken(token_beamSpot, bs);
59  if (!bs.isValid())
60  return ret;
61 
62  // this is a default origin for all modes
63  GlobalPoint default_origin(bs->x0(), bs->y0(), bs->z0());
64 
65  // fill the origins and halfLengths depending on the mode
67  ret.emplace_back(
68  default_origin,
72  iEvent.getByToken(token_vertex, vertices);
73  int n_vert = 0;
74  for (const auto& v : *vertices) {
75  if (v.isFake() || !v.isValid())
76  continue;
77 
78  ret.emplace_back(
79  GlobalPoint(v.x(), v.y(), v.z()),
81  ++n_vert;
82  if (m_maxNVertices >= 0 && n_vert >= m_maxNVertices) {
83  break;
84  }
85  }
86  // no-vertex fall-back case:
87  if (ret.empty()) {
88  ret.emplace_back(default_origin, (m_nSigmaZBeamSpot > 0.) ? m_nSigmaZBeamSpot * bs->z0Error() : m_zErrorBeamSpot);
89  }
90  }
91 
92  return ret;
93 }
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
VertexBeamspotOrigins::m_operationMode
OperationMode m_operationMode
Definition: VertexBeamspotOrigins.h:33
VertexBeamspotOrigins::OperationMode::BEAM_SPOT_FIXED
VertexBeamspotOrigins::fillDescriptions
static void fillDescriptions(edm::ParameterSetDescription &desc, const std::string &defaultBeamSpot="offlineBeamSpot", const std::string &defaultVertex="firstStepPrimaryVertices", int defaultMaxVertices=-1)
Definition: VertexBeamspotOrigins.cc:38
VertexBeamspotOrigins::OperationMode::VERTICES_SIGMA
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
findQualityFiles.v
v
Definition: findQualityFiles.py:179
VertexBeamspotOrigins::OperationMode::BEAM_SPOT_SIGMA
VertexBeamspotOrigins.h
edm::Handle< reco::BeamSpot >
cms::cuda::bs
bs
Definition: HistoContainer.h:127
VertexBeamspotOrigins::token_vertex
edm::EDGetTokenT< reco::VertexCollection > token_vertex
Definition: VertexBeamspotOrigins.h:35
VertexBeamspotOrigins::token_beamSpot
edm::EDGetTokenT< reco::BeamSpot > token_beamSpot
Definition: VertexBeamspotOrigins.h:36
VertexBeamspotOrigins::m_zErrorVertex
float m_zErrorVertex
Definition: VertexBeamspotOrigins.h:43
VertexBeamspotOrigins::Origins
std::vector< std::pair< GlobalPoint, float > > Origins
Definition: VertexBeamspotOrigins.h:17
VertexBeamspotOrigins::OperationMode::VERTICES_FIXED
reco::BeamSpot
Definition: BeamSpot.h:21
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
VertexBeamspotOrigins::m_maxNVertices
int m_maxNVertices
Definition: VertexBeamspotOrigins.h:38
edm::ParameterSet
Definition: ParameterSet.h:47
VertexBeamspotOrigins::m_zErrorBeamSpot
float m_zErrorBeamSpot
Definition: VertexBeamspotOrigins.h:41
iEvent
int iEvent
Definition: GenABIO.cc:224
VertexBeamspotOrigins::m_nSigmaZBeamSpot
float m_nSigmaZBeamSpot
Definition: VertexBeamspotOrigins.h:40
VertexBeamspotOrigins::m_nSigmaZVertex
float m_nSigmaZVertex
Definition: VertexBeamspotOrigins.h:42
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
Exception
Definition: hltDiff.cc:245
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
VertexBeamspotOrigins::VertexBeamspotOrigins
VertexBeamspotOrigins(const edm::ParameterSet &regPSet, edm::ConsumesCollector &&iC)
Definition: VertexBeamspotOrigins.h:20
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
VertexBeamspotOrigins::origins
Origins origins(const edm::Event &iEvent) const
Definition: VertexBeamspotOrigins.cc:53
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7