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);
138 if (recoBeamSpotHandle.
isValid()) {
141 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot available from EventSetup";
146 if ((beamVertexState.
error().
cxx() <= 0.) || (beamVertexState.
error().
cyy() <= 0.) ||
147 (beamVertexState.
error().
czz() <= 0.)) {
160 std::vector<reco::TransientTrack> t_tks;
169 t_tks = (*theB).build(tks,
beamSpot);
172 std::cout <<
"RecoVertex/PrimaryVertexProducer"
173 <<
"Found: " << t_tks.size() <<
" reconstructed tracks"
184 std::cout <<
" clustering returned " <<
clusters.size() <<
" clusters from " << seltks.size()
185 <<
" selected tracks" << std::endl;
190 auto result = std::make_unique<reco::VertexCollection>();
193 std::vector<TransientVertex>
pvs;
194 for (std::vector<std::vector<reco::TransientTrack> >::const_iterator iclus =
clusters.begin();
200 double meantime = 0.;
203 for (
const auto& tk : *iclus) {
204 const double time = tk.timeExt();
205 const double err = tk.dtErrorExt();
206 const double inverr =
err > 0. ? 1.0 /
err : 0.;
207 const double w = inverr * inverr;
212 meantime = sumwt / sumw;
213 double sumsq = sumwt2 - sumwt * sumwt / sumw;
214 double chisq = iclus->size() > 1 ? sumsq / double(iclus->size() - 1) : sumsq /
double(iclus->size());
215 vartime = chisq / sumw;
219 if (
algorithm->useBeamConstraint && validBS && ((*iclus).size() > 1)) {
224 auto err =
v.positionError().matrix4D();
230 }
else if (!(
algorithm->useBeamConstraint) && ((*iclus).size() > 1)) {
235 auto err =
v.positionError().matrix4D();
248 std::cout <<
"=" <<
v.position().x() <<
" " <<
v.position().y() <<
" " <<
v.position().z();
251 std::cout <<
" cluster size = " << (*iclus).size() << std::endl;
253 std::cout <<
"Invalid fitted vertex, cluster size=" << (*iclus).size() << std::endl;
257 if (
v.isValid() && (
v.degreesOfFreedom() >=
algorithm->minNdof) &&
258 (!validBS || (*(
algorithm->vertexSelector))(
v, beamVertexState)))
263 std::cout <<
"PrimaryVertexProducerAlgorithm::vertices candidates =" <<
pvs.size() << std::endl;
268 <<
"more than half of candidate vertices lost " <<
pvs.size() <<
' ' <<
clusters.size();
270 if (
pvs.empty() && seltks.size() > 5)
272 <<
"no vertex found with " << seltks.size() <<
" tracks and " <<
clusters.size() <<
" vertex-candidates";
275 if (
pvs.size() > 1) {
280 for (std::vector<TransientVertex>::const_iterator iv =
pvs.begin(); iv !=
pvs.end(); iv++) {
287 if ((bse.cxx() <= 0.) || (bse.cyy() <= 0.) || (bse.czz() <= 0.)) {
294 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
295 <<
"Beamspot with invalid errors " << bse.matrix() << std::endl;
296 std::cout <<
"Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
301 std::cout <<
"RecoVertex/PrimaryVertexProducer: "
302 <<
" will put Vertex derived from BeamSpot into Event.\n";
309 for (reco::VertexCollection::const_iterator
v = vColl.begin();
v != vColl.end(); ++
v) {
310 std::cout <<
"recvtx " << ivtx++ <<
"#trk " << std::setw(3) <<
v->tracksSize() <<
" chi2 " << std::setw(4)
311 <<
v->chi2() <<
" ndof " << std::setw(3) <<
v->ndof() <<
" x " << std::setw(6) <<
v->position().x()
312 <<
" dx " << std::setw(6) <<
v->xError() <<
" y " << std::setw(6) <<
v->position().y() <<
" dy "
313 << std::setw(6) <<
v->yError() <<
" z " << std::setw(6) <<
v->position().z() <<
" dz " << std::setw(6)
316 std::cout <<
" t " << std::setw(6) <<
v->t() <<
" dt " << std::setw(6) <<
v->tError();
331 vpsd1.
add<
double>(
"maxDistanceToBeam", 1.0);
333 vpsd1.
add<
bool>(
"useBeamConstraint",
false);
335 vpsd1.
add<
double>(
"chi2cutoff", 2.5);
336 vpsd1.
add<
double>(
"minNdof", 0.0);
337 std::vector<edm::ParameterSet> temp1;
347 temp1.push_back(temp2);
357 temp1.push_back(temp2);
359 desc.
addVPSet(
"vertexCollections", vpsd1, temp1);
364 psd0.
add<
double>(
"maxNormalizedChi2", 10.0);
365 psd0.
add<
double>(
"minPt", 0.0);
367 psd0.
add<
double>(
"maxEta", 2.4);
368 psd0.
add<
double>(
"maxD0Significance", 4.0);
369 psd0.
add<
double>(
"maxD0Error", 1.0);
370 psd0.
add<
double>(
"maxDzError", 1.0);
372 psd0.
add<
int>(
"minPixelLayersWithHits", 2);
373 psd0.
add<
int>(
"minSiliconLayersWithHits", 5);
374 psd0.
add<
int>(
"numTracksThreshold", 0);
389 psd1.
add<
double>(
"d0CutOff", 3.0);
390 psd1.
add<
double>(
"Tmin", 2.0);
391 psd1.
add<
double>(
"delta_lowT", 0.001);
392 psd1.
add<
double>(
"zmerge", 0.01);
393 psd1.
add<
double>(
"dzCutOff", 3.0);
394 psd1.
add<
double>(
"Tpurge", 2.0);
395 psd1.
add<
int>(
"convergence_mode", 0);
396 psd1.
add<
double>(
"delta_highT", 0.01);
397 psd1.
add<
double>(
"Tstop", 0.5);
398 psd1.
add<
double>(
"coolingFactor", 0.6);
399 psd1.
add<
double>(
"vertexSize", 0.006);
400 psd1.
add<
double>(
"uniquetrkweight", 0.8);
401 psd1.
add<
double>(
"zrange", 4.0);
403 psd1.
add<
double>(
"tmerge", 0.01);
404 psd1.
add<
double>(
"dtCutOff", 4.);
405 psd1.
add<
double>(
"t0Max", 1.0);
406 psd1.
add<
double>(
"vertexSizeTime", 0.008);
411 psd2.
add<
double>(
"zSeparation", 1.0);
418 descriptions.
add(
"primaryVertexProducer", desc);