RecoTracker
TkTrackingRegions
plugins
VertexBeamspotOrigins.cc
Go to the documentation of this file.
1
#include "
VertexBeamspotOrigins.h
"
2
3
VertexBeamspotOrigins::VertexBeamspotOrigins
(
const
edm::ParameterSet
& regPSet,
edm::ConsumesCollector
& iC) {
4
// operation mode
5
std::string
operationModeString = regPSet.
getParameter
<
std::string
>(
"operationMode"
);
6
if
(operationModeString ==
"BeamSpotFixed"
)
7
m_operationMode
=
OperationMode::BEAM_SPOT_FIXED
;
8
else
if
(operationModeString ==
"BeamSpotSigma"
)
9
m_operationMode
=
OperationMode::BEAM_SPOT_SIGMA
;
10
else
if
(operationModeString ==
"VerticesFixed"
)
11
m_operationMode
=
OperationMode::VERTICES_FIXED
;
12
else
if
(operationModeString ==
"VerticesSigma"
)
13
m_operationMode
=
OperationMode::VERTICES_SIGMA
;
14
else
15
throw
cms::Exception
(
"Configuration"
) <<
"Unknown operation mode string: "
<< operationModeString;
16
17
token_beamSpot
= iC.
consumes
<
reco::BeamSpot
>(regPSet.
getParameter
<
edm::InputTag
>(
"beamSpot"
));
18
m_maxNVertices
= 1;
19
if
(
m_operationMode
==
OperationMode::VERTICES_FIXED
||
m_operationMode
==
OperationMode::VERTICES_SIGMA
) {
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"
);
26
if
(
m_operationMode
==
OperationMode::VERTICES_SIGMA
)
27
m_nSigmaZVertex
= regPSet.
getParameter
<
double
>(
"nSigmaZVertex"
);
28
if
(
m_operationMode
==
OperationMode::VERTICES_FIXED
)
29
m_zErrorVertex
= regPSet.
getParameter
<
double
>(
"zErrorVertex"
);
30
m_nSigmaZBeamSpot
= -1.;
31
if
(
m_operationMode
==
OperationMode::BEAM_SPOT_SIGMA
) {
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
38
void
VertexBeamspotOrigins::fillDescriptions
(
edm::ParameterSetDescription
&
desc
,
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
53
VertexBeamspotOrigins::Origins
VertexBeamspotOrigins::origins
(
const
edm::Event
&
iEvent
)
const
{
54
Origins
ret
;
55
56
// always need the beam spot (as a fall back strategy for vertex modes)
57
edm::Handle<reco::BeamSpot>
bs
;
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
66
if
(
m_operationMode
==
OperationMode::BEAM_SPOT_FIXED
||
m_operationMode
==
OperationMode::BEAM_SPOT_SIGMA
) {
67
ret
.emplace_back(
68
default_origin,
69
(
m_operationMode
==
OperationMode::BEAM_SPOT_FIXED
) ?
m_zErrorBeamSpot
:
m_nSigmaZBeamSpot
*
bs
->sigmaZ());
70
}
else
if
(
m_operationMode
==
OperationMode::VERTICES_FIXED
||
m_operationMode
==
OperationMode::VERTICES_SIGMA
) {
71
edm::Handle<reco::VertexCollection>
vertices
;
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()),
80
(
m_operationMode
==
OperationMode::VERTICES_FIXED
) ?
m_zErrorVertex
:
m_nSigmaZVertex
*
v
.zError());
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:367
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:246
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition:
ParameterSet.h:303
VertexBeamspotOrigins::VertexBeamspotOrigins
VertexBeamspotOrigins(const edm::ParameterSet ®PSet, 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
Generated for CMSSW Reference Manual by
1.8.16