30 if (trackSelectionAlgorithm ==
"filter") {
32 }
else if (trackSelectionAlgorithm ==
"filterWithThreshold") {
35 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown track selection algorithm: " +
36 trackSelectionAlgorithm);
42 if (clusteringAlgorithm ==
"gap") {
45 }
else if (clusteringAlgorithm ==
"DA") {
50 else if (clusteringAlgorithm ==
"DA_vect") {
53 }
else if (clusteringAlgorithm ==
"DA2D_vect") {
60 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
69 if (conf.
exists(
"vertexCollections")) {
71 conf.
getParameter<std::vector<edm::ParameterSet> >(
"vertexCollections");
73 for (std::vector<edm::ParameterSet>::const_iterator algoconf =
vertexCollections.begin();
78 if (fitterAlgorithm ==
"KalmanVertexFitter") {
80 }
else if (fitterAlgorithm ==
"AdaptiveVertexFitter") {
83 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
86 algorithm.minNdof = algoconf->getParameter<
double>(
"minNdof");
87 algorithm.useBeamConstraint = algoconf->getParameter<
bool>(
"useBeamConstraint");
92 produces<reco::VertexCollection>(
algorithm.label);
96 <<
"this module's configuration has changed, please update to have a vertexCollections=cms.VPSet parameter.";
100 if (fitterAlgorithm ==
"KalmanVertexFitter") {
102 }
else if (fitterAlgorithm ==
"AdaptiveVertexFitter") {
105 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
116 produces<reco::VertexCollection>(
algorithm.label);
123 throw VertexException(
"PrimaryVertexProducerAlgorithm: No algorithm specified. ");
126 "PrimaryVertexProducerAlgorithm: Running in Recovery mode and more than one algorithm specified. Please "
127 "only one algorithm.");
151 if (recoBeamSpotHandle.
isValid()) {
154 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot available from EventSetup";
159 if ((beamVertexState.
error().
cxx() <= 0.) || (beamVertexState.
error().
cyy() <= 0.) ||
160 (beamVertexState.
error().
czz() <= 0.)) {
169 for (
auto const& old : oldVertices) {
170 if (!(old.isFake())) {
173 auto result = std::make_unique<reco::VertexCollection>();
189 std::vector<reco::TransientTrack> t_tks;
198 t_tks = (*theB).build(tks,
beamSpot);
201 std::cout <<
"RecoVertex/PrimaryVertexProducer"
202 <<
"Found: " << t_tks.size() <<
" reconstructed tracks"
213 std::cout <<
" clustering returned " <<
clusters.size() <<
" clusters from " << seltks.size()
214 <<
" selected tracks" << std::endl;
219 auto result = std::make_unique<reco::VertexCollection>();
222 std::vector<TransientVertex>
pvs;
223 for (
std::vector<std::vector<reco::TransientTrack> >::const_iterator iclus =
clusters.begin();
229 double meantime = 0.;
232 for (
const auto& tk : *iclus) {
233 const double time = tk.timeExt();
234 const double err = tk.dtErrorExt();
235 const double inverr =
err > 0. ? 1.0 /
err : 0.;
236 const double w = inverr * inverr;
241 meantime = sumwt / sumw;
242 double sumsq = sumwt2 - sumwt * sumwt / sumw;
243 double chisq = iclus->size() > 1 ? sumsq / double(iclus->size() - 1) : sumsq /
double(iclus->size());
244 vartime = chisq / sumw;
248 if (
algorithm->useBeamConstraint && validBS && ((*iclus).size() > 1)) {
253 auto err =
v.positionError().matrix4D();
259 }
else if (!(
algorithm->useBeamConstraint) && ((*iclus).size() > 1)) {
264 auto err =
v.positionError().matrix4D();
277 std::cout <<
"=" <<
v.position().x() <<
" " <<
v.position().y() <<
" " <<
v.position().z();
280 std::cout <<
" cluster size = " << (*iclus).size() << std::endl;
282 std::cout <<
"Invalid fitted vertex, cluster size=" << (*iclus).size() << std::endl;
286 if (
v.isValid() && (
v.degreesOfFreedom() >=
algorithm->minNdof) &&
287 (!validBS || (*(
algorithm->vertexSelector))(
v, beamVertexState)))
292 std::cout <<
"PrimaryVertexProducerAlgorithm::vertices candidates =" <<
pvs.size() << std::endl;
297 <<
"more than half of candidate vertices lost " <<
pvs.size() <<
' ' <<
clusters.size();
299 if (
pvs.empty() && seltks.size() > 5)
301 <<
"no vertex found with " << seltks.size() <<
" tracks and " <<
clusters.size() <<
" vertex-candidates";
304 if (
pvs.size() > 1) {
309 for (std::vector<TransientVertex>::const_iterator iv =
pvs.begin(); iv !=
pvs.end(); iv++) {
316 if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
323 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
324 <<
"Beamspot with invalid errors " << bse.matrix() << std::endl;
325 std::cout <<
"Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
330 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
331 <<
" will put Vertex derived from BeamSpot into Event.\n";
338 for (reco::VertexCollection::const_iterator
v = vColl.begin();
v != vColl.end(); ++
v) {
339 std::cout <<
"recvtx " << ivtx++ <<
"#trk " << std::setw(3) <<
v->tracksSize() <<
" chi2 " << std::setw(4)
340 <<
v->chi2() <<
" ndof " << std::setw(3) <<
v->ndof() <<
" x " << std::setw(6) <<
v->position().x()
341 <<
" dx " << std::setw(6) <<
v->xError() <<
" y " << std::setw(6) <<
v->position().y() <<
" dy "
342 << std::setw(6) <<
v->yError() <<
" z " << std::setw(6) <<
v->position().z() <<
" dz " << std::setw(6)
345 std::cout <<
" t " << std::setw(6) <<
v->t() <<
" dt " << std::setw(6) <<
v->tError();
360 vpsd1.
add<
double>(
"maxDistanceToBeam", 1.0);
362 vpsd1.
add<
bool>(
"useBeamConstraint",
false);
364 vpsd1.
add<
double>(
"chi2cutoff", 2.5);
365 vpsd1.
add<
double>(
"minNdof", 0.0);
366 std::vector<edm::ParameterSet> temp1;
376 temp1.push_back(temp2);
386 temp1.push_back(temp2);
388 desc.addVPSet(
"vertexCollections", vpsd1, temp1);
390 desc.addUntracked<
bool>(
"verbose",
false);
393 psd0.
add<
double>(
"maxNormalizedChi2", 10.0);
394 psd0.
add<
double>(
"minPt", 0.0);
396 psd0.
add<
double>(
"maxEta", 2.4);
397 psd0.
add<
double>(
"maxD0Significance", 4.0);
398 psd0.
add<
double>(
"maxD0Error", 1.0);
399 psd0.
add<
double>(
"maxDzError", 1.0);
401 psd0.
add<
int>(
"minPixelLayersWithHits", 2);
402 psd0.
add<
int>(
"minSiliconLayersWithHits", 5);
403 psd0.
add<
int>(
"numTracksThreshold", 0);
418 psd1.
add<
double>(
"d0CutOff", 3.0);
419 psd1.
add<
double>(
"Tmin", 2.0);
420 psd1.
add<
double>(
"delta_lowT", 0.001);
421 psd1.
add<
double>(
"zmerge", 0.01);
422 psd1.
add<
double>(
"dzCutOff", 3.0);
423 psd1.
add<
double>(
"Tpurge", 2.0);
424 psd1.
add<
int>(
"convergence_mode", 0);
425 psd1.
add<
double>(
"delta_highT", 0.01);
426 psd1.
add<
double>(
"Tstop", 0.5);
427 psd1.
add<
double>(
"coolingFactor", 0.6);
428 psd1.
add<
double>(
"vertexSize", 0.006);
429 psd1.
add<
double>(
"uniquetrkweight", 0.8);
430 psd1.
add<
double>(
"zrange", 4.0);
432 psd1.
add<
double>(
"tmerge", 0.01);
433 psd1.
add<
double>(
"dtCutOff", 4.);
434 psd1.
add<
double>(
"t0Max", 1.0);
435 psd1.
add<
double>(
"vertexSizeTime", 0.008);
440 psd2.
add<
double>(
"zSeparation", 1.0);
446 desc.add<
bool>(
"isRecoveryIteration",
false);
449 descriptions.
add(
"primaryVertexProducer",
desc);