134 if (recoBeamSpotHandle.
isValid()){
135 beamSpot = *recoBeamSpotHandle;
137 edm::LogError(
"UnusableBeamSpot") <<
"No beam spot available from EventSetup";
142 if ( (beamVertexState.error().cxx() <= 0.) ||
143 (beamVertexState.error().cyy() <= 0.) ||
144 (beamVertexState.error().czz() <= 0.) ) {
146 edm::LogError(
"UnusableBeamSpot") <<
"Beamspot with invalid errors "<<beamVertexState.error().matrix();
159 std::vector<reco::TransientTrack> t_tks;
166 t_tks = (*theB).build(tks, beamSpot, *(trackTimesH.
product()), *(trackTimeResosH.
product()));
168 t_tks = (*theB).build(tks, beamSpot);
171 <<
"Found: " << t_tks.size() <<
" reconstructed tracks" <<
"\n";
181 if (
fVerbose){
std::cout <<
" clustering returned "<< clusters.size() <<
" clusters from " << seltks.size() <<
" selected tracks" <<std::endl;}
188 auto result = std::make_unique<reco::VertexCollection>();
192 std::vector<TransientVertex> pvs;
193 for (std::vector< std::vector<reco::TransientTrack> >::const_iterator iclus
194 = clusters.begin(); iclus != clusters.end(); iclus++) {
199 double meantime = 0.;
202 for(
const auto& tk : *iclus ) {
203 const double time = tk.timeExt();
204 const double err = tk.dtErrorExt();
205 const double inverr = err > 0. ? 1.0/err : 0.;
206 const double w = inverr*inverr;
208 sumwt2 += w*time*
time;
211 meantime = sumwt/sumw;
212 double sumsq = sumwt2 - sumwt*sumwt/sumw;
213 double chisq = iclus->size()>1 ? sumsq/double(iclus->size()-1) : sumsq/
double(iclus->size());
214 vartime = chisq/sumw;
218 if(
algorithm->useBeamConstraint && validBS &&((*iclus).size()>1) ){
220 v =
algorithm->fitter->vertex(*iclus, beamSpot);
230 }
else if( !(
algorithm->useBeamConstraint) && ((*iclus).size()>1) ) {
251 std::cout <<
" cluster size = " << (*iclus).size() << std::endl;
254 std::cout <<
"Invalid fitted vertex, cluster size=" << (*iclus).size() << std::endl;
260 && (!validBS || (*(
algorithm->vertexSelector))(
v,beamVertexState))
265 std::cout <<
"PrimaryVertexProducerAlgorithm::vertices candidates =" << pvs.size() << std::endl;
269 if (clusters.size()>2 && clusters.size() > 2*pvs.size())
270 edm::LogWarning(
"PrimaryVertexProducer") <<
"more than half of candidate vertices lost " << pvs.size() <<
' ' << clusters.size();
272 if (pvs.empty() && seltks.size()>5)
273 edm::LogWarning(
"PrimaryVertexProducer") <<
"no vertex found with " << seltks.size() <<
" tracks and " << clusters.size() <<
" vertex-candidates";
283 for (std::vector<TransientVertex>::const_iterator iv = pvs.begin();
284 iv != pvs.end(); iv++) {
291 if ( (bse.cxx() <= 0.) ||
293 (bse.czz() <= 0.) ) {
295 we(0,0)=10000; we(1,1)=10000; we(2,2)=10000;
298 std::cout <<
"RecoVertex/PrimaryVertexProducer: " 299 <<
"Beamspot with invalid errors "<<bse.matrix()<<std::endl;
300 std::cout <<
"Will put Vertex derived from dummy-fake BeamSpot into Event.\n";
306 std::cout <<
"RecoVertex/PrimaryVertexProducer: " 307 <<
" will put Vertex derived from BeamSpot into Event.\n";
314 for(reco::VertexCollection::const_iterator v=vColl.begin();
315 v!=vColl.end(); ++
v){
318 <<
" chi2 " << std::setw(4) << v->
chi2()
319 <<
" ndof " << std::setw(3) << v->
ndof()
320 <<
" x " << std::setw(6) << v->
position().x()
321 <<
" dx " << std::setw(6) << v->
xError()
322 <<
" y " << std::setw(6) << v->
position().y()
323 <<
" dy " << std::setw(6) << v->
yError()
324 <<
" z " << std::setw(6) << v->
position().z()
325 <<
" dz " << std::setw(6) << v->
zError();
328 <<
" dt " << std::setw(6) << v->
tError();
GlobalError positionError() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
edm::EDGetTokenT< reco::BeamSpot > bsToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double zError() const
error on z
float totalChiSquared() const
edm::EDGetTokenT< reco::TrackCollection > trkToken
TrackClusterizerInZ * theTrackClusterizer
std::vector< Vertex > VertexCollection
collection of Vertex objects
const Point & position() const
position
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
GlobalPoint position() const
double chi2() const
chi-squares
TrackFilterForPVFindingBase * theTrackFilter
virtual std::vector< std::vector< reco::TransientTrack > > clusterize(const std::vector< reco::TransientTrack > &tracks) const =0
double xError() const
error on x
T const * product() const
std::vector< algo > algorithms
virtual std::vector< reco::TransientTrack > select(const std::vector< reco::TransientTrack > &tracks) const =0
const Point & position() const
position
Covariance3DMatrix rotatedCovariance3D() const
double yError() const
error on y
double tError() const
error on t
size_t tracksSize() const
number of tracks
double t() const
t coordinate