29 if (trackSelectionAlgorithm ==
"filter") {
31 }
else if (trackSelectionAlgorithm ==
"filterWithThreshold") {
34 throw VertexException(
"PrimaryVertexProducer: unknown track selection algorithm: " + trackSelectionAlgorithm);
40 if (clusteringAlgorithm ==
"gap") {
43 }
else if (clusteringAlgorithm ==
"DA") {
48 else if (clusteringAlgorithm ==
"DA_vect") {
51 }
else if (clusteringAlgorithm ==
"DA2D_vect") {
58 throw VertexException(
"PrimaryVertexProducer: unknown clustering algorithm: " + clusteringAlgorithm);
67 if (conf.
exists(
"vertexCollections")) {
69 conf.
getParameter<std::vector<edm::ParameterSet> >(
"vertexCollections");
71 for (std::vector<edm::ParameterSet>::const_iterator algoconf = vertexCollections.begin();
72 algoconf != vertexCollections.end();
76 if (fitterAlgorithm ==
"KalmanVertexFitter") {
78 }
else if (fitterAlgorithm ==
"AdaptiveVertexFitter") {
81 throw VertexException(
"PrimaryVertexProducer: unknown algorithm: " + fitterAlgorithm);
84 algorithm.
minNdof = algoconf->getParameter<
double>(
"minNdof");
90 produces<reco::VertexCollection>(algorithm.
label);
94 <<
"this module's configuration has changed, please update to have a vertexCollections=cms.VPSet parameter.";
98 if (fitterAlgorithm ==
"KalmanVertexFitter") {
100 }
else if (fitterAlgorithm ==
"AdaptiveVertexFitter") {
103 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
105 algorithm.
label =
"";
114 produces<reco::VertexCollection>(algorithm.
label);
121 throw VertexException(
"PrimaryVertexProducer: No algorithm specified. ");
124 "PrimaryVertexProducer: Running in Recovery mode and more than one algorithm specified. Please "
125 "only one algorithm.");
149 if (recoBeamSpotHandle.
isValid()) {
150 beamSpot = *recoBeamSpotHandle;
152 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot available from EventSetup";
157 if ((beamVertexState.
error().
cxx() <= 0.) || (beamVertexState.
error().
cyy() <= 0.) ||
158 (beamVertexState.
error().
czz() <= 0.)) {
167 for (
auto const& old : oldVertices) {
168 if (!(old.isFake())) {
171 auto result = std::make_unique<reco::VertexCollection>();
186 std::vector<reco::TransientTrack> t_tks;
193 t_tks = (*theB).build(tks, beamSpot, *(trackTimesH.
product()), *(trackTimeResosH.
product()));
195 t_tks = (*theB).build(tks, beamSpot);
198 std::cout <<
"RecoVertex/PrimaryVertexProducer"
199 <<
"Found: " << t_tks.size() <<
" reconstructed tracks"
210 std::cout <<
" clustering returned " << clusters.size() <<
" clusters from " << seltks.size()
211 <<
" selected tracks" << std::endl;
216 auto result = std::make_unique<reco::VertexCollection>();
219 std::vector<TransientVertex> pvs;
220 for (
std::vector<std::vector<reco::TransientTrack> >::const_iterator iclus = clusters.begin();
221 iclus != clusters.end();
226 double meantime = 0.;
229 for (
const auto& tk : *iclus) {
230 const double time = tk.timeExt();
231 const double err = tk.dtErrorExt();
232 const double inverr = err > 0. ? 1.0 / err : 0.;
233 const double w = inverr * inverr;
235 sumwt2 += w * time * time;
238 meantime = sumwt / sumw;
239 double sumsq = sumwt2 - sumwt * sumwt / sumw;
240 double chisq = iclus->size() > 1 ? sumsq / double(iclus->size() - 1) : sumsq /
double(iclus->size());
241 vartime = chisq / sumw;
245 if (
algorithm->useBeamConstraint && validBS && (iclus->size() > 1)) {
246 v =
algorithm->fitter->vertex(*iclus, beamSpot);
247 }
else if (!(
algorithm->useBeamConstraint) && (iclus->size() > 1)) {
268 std::cout <<
" cluster size = " << (*iclus).size() << std::endl;
270 std::cout <<
"Invalid fitted vertex, cluster size=" << (*iclus).size() << std::endl;
275 (!validBS || (*(
algorithm->vertexSelector))(
v, beamVertexState)))
280 std::cout <<
"PrimaryVertexProducerAlgorithm::vertices candidates =" << pvs.size() << std::endl;
283 if (clusters.size() > 2 && clusters.size() > 2 * pvs.size())
285 <<
"more than half of candidate vertices lost " << pvs.size() <<
' ' << clusters.size();
287 if (pvs.empty() && seltks.size() > 5)
289 <<
"no vertex found with " << seltks.size() <<
" tracks and " << clusters.size() <<
" vertex-candidates";
292 if (pvs.size() > 1) {
297 for (std::vector<TransientVertex>::const_iterator
iv = pvs.begin();
iv != pvs.end();
iv++) {
304 if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
311 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
312 <<
"Beamspot with invalid errors " << bse.matrix() << std::endl;
313 std::cout <<
"Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
318 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
319 <<
" will put Vertex derived from BeamSpot into Event.\n";
326 for (reco::VertexCollection::const_iterator
v = vColl.begin();
v != vColl.end(); ++
v) {
327 std::cout <<
"recvtx " << ivtx++ <<
"#trk " << std::setw(3) <<
v->tracksSize() <<
" chi2 " << std::setw(4)
328 <<
v->chi2() <<
" ndof " << std::setw(3) <<
v->ndof() <<
" x " << std::setw(6) <<
v->position().x()
329 <<
" dx " << std::setw(6) <<
v->xError() <<
" y " << std::setw(6) <<
v->position().y() <<
" dy "
330 << std::setw(6) <<
v->yError() <<
" z " << std::setw(6) <<
v->position().z() <<
" dz " << std::setw(6)
333 std::cout <<
" t " << std::setw(6) <<
v->t() <<
" dt " << std::setw(6) <<
v->tError();
348 vpsd1.
add<
double>(
"maxDistanceToBeam", 1.0);
350 vpsd1.
add<
bool>(
"useBeamConstraint",
false);
352 vpsd1.
add<
double>(
"chi2cutoff", 2.5);
353 vpsd1.
add<
double>(
"minNdof", 0.0);
354 std::vector<edm::ParameterSet> temp1;
364 temp1.push_back(temp2);
374 temp1.push_back(temp2);
376 desc.
addVPSet(
"vertexCollections", vpsd1, temp1);
382 psd0.
add<
int>(
"numTracksThreshold", 0);
405 desc.
add<
bool>(
"isRecoveryIteration",
false);
408 descriptions.
add(
"primaryVertexProducer", desc);
GlobalError positionError() const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
edm::EDGetTokenT< reco::BeamSpot > bsToken
const edm::ESGetToken< TransientTrackBuilder, TransientTrackRecord > theTTBToken
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
VertexFitter< 5 > * fitter
std::vector< algo > algorithms
~PrimaryVertexProducer() override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
edm::EDGetTokenT< reco::VertexCollection > recoveryVtxToken
const AlgebraicSymMatrix33 matrix() const
float totalChiSquared() const
edm::EDGetTokenT< reco::TrackCollection > trkToken
TrackClusterizerInZ * theTrackClusterizer
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
Log< level::Error, false > LogError
edm::EDGetTokenT< edm::ValueMap< float > > trkTimesToken
const AlgebraicSymMatrix44 & matrix4D() const
bool getData(T &iHolder) const
std::vector< reco::TransientTrack > const & originalTracks() const
edm::EDGetTokenT< edm::ValueMap< float > > trkTimeResosToken
float degreesOfFreedom() const
static void fillPSetDescription(edm::ParameterSetDescription &desc)
VertexCompatibleWithBeam * vertexSelector
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
GlobalPoint position() const
void addParameter(std::string const &name, T const &value)
bool get(ProductID const &oid, Handle< PROD > &result) const
TrackFilterForPVFindingBase * theTrackFilter
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T const * product() const
static void fillPSetDescription(edm::ParameterSetDescription &desc)
T getParameter(std::string const &) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void produce(edm::Event &, const edm::EventSetup &) override
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
PrimaryVertexProducer(const edm::ParameterSet &)
static void fillPSetDescription(edm::ParameterSetDescription &desc)
GlobalError error() const
const Point & position() const
position
Covariance3DMatrix rotatedCovariance3D() const
Log< level::Warning, false > LogWarning
TransientTrackToFloatMap weightMap() const