33 if(trackSelectionAlgorithm==
"filter"){
35 }
else if (trackSelectionAlgorithm==
"filterWithThreshold"){
38 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown track selection algorithm: " + trackSelectionAlgorithm);
44 if (clusteringAlgorithm==
"gap"){
46 }
else if(clusteringAlgorithm==
"DA"){
50 else if(clusteringAlgorithm ==
"DA_vect") {
53 else if( clusteringAlgorithm==
"DA2D" ) {
59 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown clustering algorithm: " + clusteringAlgorithm);
69 if (conf.
exists(
"vertexCollections")){
72 for( std::vector< edm::ParameterSet >::const_iterator algoconf = vertexCollections.begin(); algoconf != vertexCollections.end(); algoconf++){
76 if (fitterAlgorithm==
"KalmanVertexFitter") {
78 }
else if( fitterAlgorithm==
"AdaptiveVertexFitter") {
81 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
84 algorithm.
minNdof = algoconf->getParameter<
double>(
"minNdof");
89 produces<reco::VertexCollection>(algorithm.
label);
92 edm::LogWarning(
"MisConfiguration")<<
"this module's configuration has changed, please update to have a vertexCollections=cms.VPSet parameter.";
96 if (fitterAlgorithm==
"KalmanVertexFitter") {
98 }
else if( fitterAlgorithm==
"AdaptiveVertexFitter") {
101 throw VertexException(
"PrimaryVertexProducerAlgorithm: unknown algorithm: " + fitterAlgorithm);
103 algorithm.
label =
"";
110 produces<reco::VertexCollection>(algorithm.
label);
135 if (recoBeamSpotHandle.
isValid()){
136 beamSpot = *recoBeamSpotHandle;
138 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot available from EventSetup";
143 if ( (beamVertexState.
error().
cxx() <= 0.) ||
144 (beamVertexState.
error().
cyy() <= 0.) ||
145 (beamVertexState.
error().
czz() <= 0.) ) {
160 std::vector<reco::TransientTrack> t_tks;
167 t_tks = (*theB).build(tks, beamSpot, *(trackTimesH.
product()), *(trackTimeResosH.
product()));
169 t_tks = (*theB).build(tks, beamSpot);
172 <<
"Found: " << t_tks.size() <<
" reconstructed tracks" <<
"\n";
182 if (
fVerbose){
std::cout <<
" clustering returned "<< clusters.size() <<
" clusters from " << seltks.size() <<
" selected tracks" <<std::endl;}
189 auto result = std::make_unique<reco::VertexCollection>();
193 std::vector<TransientVertex> pvs;
194 for (std::vector< std::vector<reco::TransientTrack> >::const_iterator iclus
195 = clusters.begin(); iclus != clusters.end(); iclus++) {
197 double meantime = 0.;
201 for(
const auto& tk : *iclus ) {
202 const double time = tk.timeExt();
203 const double inverr = 1.0/tk.dtErrorExt();
204 meantime += time*inverr;
205 expv_x2 += time*time*inverr;
208 meantime = meantime/normw;
209 expv_x2 = expv_x2/normw;
211 const double time_var = (
f4D ? expv_x2 - meantime*meantime : 0. );
215 if(
algorithm->useBeamConstraint && validBS &&((*iclus).size()>1) ){
217 v =
algorithm->fitter->vertex(*iclus, beamSpot);
222 err(3,3) = time_var/(double)iclus->size();
227 }
else if( !(
algorithm->useBeamConstraint) && ((*iclus).size()>1) ) {
234 err(3,3) = time_var/(double)iclus->size();
248 std::cout <<
" cluster size = " << (*iclus).size() << std::endl;
251 std::cout <<
"Invalid fitted vertex, cluster size=" << (*iclus).size() << std::endl;
257 && (!validBS || (*(
algorithm->vertexSelector))(
v,beamVertexState))
262 std::cout <<
"PrimaryVertexProducerAlgorithm::vertices candidates =" << pvs.size() << std::endl;
266 if (clusters.size()>2 && clusters.size() > 2*pvs.size())
267 edm::LogWarning(
"PrimaryVertexProducer") <<
"more than half of candidate vertices lost " << pvs.size() <<
' ' << clusters.size();
269 if (pvs.empty() && seltks.size()>5)
270 edm::LogWarning(
"PrimaryVertexProducer") <<
"no vertex found with " << seltks.size() <<
" tracks and " << clusters.size() <<
" vertex-candidates";
280 for (std::vector<TransientVertex>::const_iterator iv = pvs.begin();
281 iv != pvs.end(); iv++) {
288 if ( (bse.cxx() <= 0.) ||
290 (bse.czz() <= 0.) ) {
292 we(0,0)=10000; we(1,1)=10000; we(2,2)=10000;
295 std::cout <<
"RecoVertex/PrimaryVertexProducer: " 296 <<
"Beamspot with invalid errors "<<bse.matrix()<<std::endl;
297 std::cout <<
"Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
303 std::cout <<
"RecoVertex/PrimaryVertexProducer: " 304 <<
" will put Vertex derived from BeamSpot into Event.\n";
311 for(reco::VertexCollection::const_iterator
v=vColl.begin();
312 v!=vColl.end(); ++
v){
314 <<
"#trk " << std::setw(3) <<
v->tracksSize()
315 <<
" chi2 " << std::setw(4) <<
v->chi2()
316 <<
" ndof " << std::setw(3) <<
v->ndof()
317 <<
" x " << std::setw(6) <<
v->position().x()
318 <<
" dx " << std::setw(6) <<
v->xError()
319 <<
" y " << std::setw(6) <<
v->position().y()
320 <<
" dy " << std::setw(6) <<
v->yError()
321 <<
" z " << std::setw(6) <<
v->position().z()
322 <<
" dz " << std::setw(6) <<
v->zError();
325 <<
" dt " << std::setw(6) <<
v->tError();
GlobalError positionError() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
vertexCollections
1 cm max separation between clusters
edm::EDGetTokenT< reco::BeamSpot > bsToken
VertexFitter< 5 > * fitter
bool getByToken(EDGetToken token, Handle< PROD > &result) const
#define DEFINE_FWK_MODULE(type)
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
edm::EDGetTokenT< edm::ValueMap< float > > trkTimesToken
const AlgebraicSymMatrix44 & matrix4D() const
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
std::vector< reco::TransientTrack > const & originalTracks() const
edm::EDGetTokenT< edm::ValueMap< float > > trkTimeResosToken
float degreesOfFreedom() const
VertexCompatibleWithBeam * vertexSelector
GlobalPoint position() const
TrackFilterForPVFindingBase * theTrackFilter
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
virtual void produce(edm::Event &, const edm::EventSetup &)
T const * product() const
std::vector< algo > algorithms
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
PrimaryVertexProducer(const edm::ParameterSet &)
GlobalError error() const
const Point & position() const
position
Covariance3DMatrix rotatedCovariance3D() const