10 #include <boost/iterator/transform_iterator.hpp>
53 struct RefToBaseLess :
public std::binary_function<edm::RefToBase<T>,
59 return r1.
id() < r2.
id() ||
79 CONSTRAINT_PV_PRIMARIES_IN_FIT
105 return CONSTRAINT_NONE;
106 else if (name ==
"BeamSpot")
107 return CONSTRAINT_BEAMSPOT;
108 else if (name ==
"BeamSpot+PVPosition")
109 return CONSTRAINT_PV_BEAMSPOT_SIZE;
110 else if (name ==
"BeamSpotZ+PVErrorScaledXY")
111 return CONSTRAINT_PV_BS_Z_ERRORS_SCALED;
112 else if (name ==
"PVErrorScaled")
113 return CONSTRAINT_PV_ERROR_SCALED;
114 else if (name ==
"BeamSpot+PVTracksInFit")
115 return CONSTRAINT_PV_PRIMARIES_IN_FIT;
118 <<
"SecondaryVertexProducer: ``constraint'' parameter "
119 "value \"" << name <<
"\" not understood."
126 if (name ==
"AlwaysWithGhostTrack")
128 else if (name ==
"SingleTracksWithGhostTrack")
130 else if (name ==
"RefitGhostTrackWithVertices")
134 <<
"SecondaryVertexProducer: ``fitType'' "
135 "parameter value \"" << name <<
"\" for "
136 "GhostTrackVertexFinder settings not "
137 "understood." << std::endl;
142 sortCriterium(TrackSorting::
getCriterium(params.getParameter<std::
string>(
"trackSort"))),
144 constraint(getConstraintType(params.getParameter<std::
string>(
"constraint"))),
145 constraintScaling(1.0),
146 vtxRecoPSet(params.getParameter<edm::
ParameterSet>(
"vertexReco")),
147 useGhostTrack(vtxRecoPSet.getParameter<std::
string>(
"finder") ==
"gtvr"),
148 withPVError(params.getParameter<bool>(
"usePVError")),
149 minTrackWeight(params.getParameter<double>(
"minimumTrackWeight")),
150 vertexFilter(params.getParameter<edm::
ParameterSet>(
"vertexCuts")),
151 vertexSorting(params.getParameter<edm::
ParameterSet>(
"vertexSelection"))
169 produces<SecondaryVertexTagInfoCollection>();
178 public std::unary_function<const Vertex&, SecondaryVertex> {
183 pv(pv), direction(direction),
184 withPVError(withPVError) {}
195 public std::unary_function<const SecondaryVertex&, bool> {
199 filter(filter), pv(pv), direction(direction) {}
202 {
return !
filter(pv, sv, direction); }
215 RefToBaseLess<Track> > TransientTrackMap;
230 unsigned int bsCovSrc[7] = { 0, };
231 double sigmaZ = 0.0, beamWidth = 0.0;
235 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = bsCovSrc[6] = 1;
236 sigmaZ = beamSpot->sigmaZ();
237 beamWidth = beamSpot->BeamWidthX();
242 bsCovSrc[0] = bsCovSrc[1] = 2;
243 bsCovSrc[3] = bsCovSrc[4] = bsCovSrc[5] = 1;
244 sigmaZ = beamSpot->sigmaZ();
248 bsCovSrc[0] = bsCovSrc[1] = bsCovSrc[2] = 2;
260 std::auto_ptr<ConfigurableVertexReconstructor> vertexReco;
261 std::auto_ptr<GhostTrackVertexFinder> vertexRecoGT;
273 TransientTrackMap primariesMap;
277 std::auto_ptr<SecondaryVertexTagInfoCollection>
280 for(TrackIPTagInfoCollection::const_iterator iterJets =
281 trackIPTagInfos->begin(); iterJets != trackIPTagInfos->end();
283 std::vector<SecondaryVertexTagInfo::IndexedTrackData> trackData;
286 const Vertex &pv = *iterJets->primaryVertex();
288 std::set<TransientTrack> primaries;
292 TransientTrackMap::iterator pos =
293 primariesMap.lower_bound(*
iter);
295 if (pos != primariesMap.end() &&
297 primaries.insert(pos->second);
299 TransientTrack track =
302 primariesMap.insert(pos,
303 std::make_pair(*
iter, track));
304 primaries.insert(track);
315 std::vector<std::size_t> indices =
320 const std::vector<TrackIPTagInfo::TrackIPData> &ipData =
321 iterJets->impactParameterData();
325 std::vector<TransientTrack> fitTracks;
326 std::vector<GhostTrackState> gtStates;
327 std::auto_ptr<GhostTrackPrediction> gtPred;
330 *iterJets->ghostTrack()));
332 for(
unsigned int i = 0;
i < indices.size();
i++) {
338 trackData.back().first = indices[
i];
345 trackData.back().second.svStatus =
346 SecondaryVertexTagInfo::TrackData::trackSelected;
350 TransientTrackMap::const_iterator pos =
353 TransientTrack fitTrack;
354 if (pos != primariesMap.end()) {
355 primaries.erase(pos->second);
356 fitTrack = pos->second;
358 fitTrack = trackBuilder->build(trackRef);
359 fitTracks.push_back(fitTrack);
361 trackData.back().second.svStatus =
362 SecondaryVertexTagInfo::TrackData::trackUsedForVertexFit;
367 ipData[indices[
i]].closestToGhostTrack;
369 gtPred->lambda(pos));
370 gtState.
setWeight(ipData[indices[i]].ghostTrackWeight);
371 gtStates.push_back(gtState);
382 iterJets->ghostTrack()->px(),
383 iterJets->ghostTrack()->py(),
384 iterJets->ghostTrack()->pz()),
387 iterJets->ghostTrack()->chi2(),
388 iterJets->ghostTrack()->ndof()));
393 std::vector<reco::Vertex> extAssoCollection;
394 std::vector<TransientVertex> fittedSVs;
395 std::vector<SecondaryVertex> SVs;
400 fittedSVs = vertexRecoGT->vertices(
403 fittedSVs = vertexReco->vertices(fitTracks);
408 fittedSVs = vertexRecoGT->vertices(
409 pv, *beamSpot, *ghostTrack);
411 fittedSVs = vertexReco->vertices(fitTracks,
419 for(
unsigned int i = 0;
i < 7;
i++) {
420 unsigned int covSrc = bsCovSrc[
i];
421 for(
unsigned int j = 0;
j < 7;
j++) {
423 if (!covSrc || bsCovSrc[
j] != covSrc)
425 else if (covSrc == 1)
426 v = beamSpot->covariance(
i,
j);
435 beamSpot.
isValid() ? beamSpot->dxdz() : 0.,
436 beamSpot.
isValid() ? beamSpot->dydz() : 0.,
440 fittedSVs = vertexRecoGT->vertices(
441 pv, bs, *ghostTrack);
443 fittedSVs = vertexReco->vertices(fitTracks, bs);
447 std::vector<TransientTrack> primaries_(
448 primaries.begin(), primaries.end());
450 fittedSVs = vertexRecoGT->vertices(
451 pv, *beamSpot, primaries_,
454 fittedSVs = vertexReco->vertices(
455 primaries_, fitTracks,
463 std::remove_copy_if(boost::make_transform_iterator(
464 fittedSVs.begin(), svBuilder),
465 boost::make_transform_iterator(
466 fittedSVs.end(), svBuilder),
467 std::back_inserter(SVs),
472 for(
size_t iExtSv = 0; iExtSv < extSecVertex->size(); iExtSv++){
473 const reco::Vertex & extVertex = (*extSecVertex)[iExtSv];
480 extAssoCollection.push_back( extVertex );
483 std::remove_copy_if(boost::make_transform_iterator( extAssoCollection.begin(), svBuilder),
484 boost::make_transform_iterator(extAssoCollection.end(), svBuilder),
485 std::back_inserter(SVs),
496 extAssoCollection.clear();
502 std::vector<SecondaryVertexTagInfo::VertexData> svData;
504 svData.resize(vtxIndices.size());
505 for(
unsigned int idx = 0;
idx < vtxIndices.size();
idx++) {
508 svData[
idx].vertex = sv;
511 svData[
idx].direction =
527 if (pos == trackRefs.
end() ) {
530 <<
"Could not find track from secondary "
531 "vertex in original tracks."
535 trackData[
index].second.svStatus =
537 ((
unsigned int)SecondaryVertexTagInfo::TrackData::trackAssociatedToVertex +
idx);
546 trackData, svData, SVs.size(),
548 iterJets - trackIPTagInfos->begin())));
math::Error< dimension >::type CovarianceMatrix
reco::Vertex::Point convertPos(const GlobalPoint &p)
T getParameter(std::string const &) const
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
reco::TrackIPTagInfo::SortCriteria getCriterium(const std::string &name)
trackRef_iterator tracks_end() const
last iterator over tracks
static ConstraintType getConstraintType(const std::string &name)
VertexFilter vertexFilter
Measurement1D dist3d() const
#define DEFINE_FWK_MODULE(type)
double y() const
y coordinate
SecondaryVertexProducer(const edm::ParameterSet ¶ms)
reco::Vertex::Error convertError(const GlobalError &ge)
virtual Vector momentum() const
spatial momentum vector
edm::EDGetTokenT< reco::VertexCollection > token_extSVCollection
void setWeight(double weight)
double covariance(int i, int j) const
(i, j)-th element of error matrix, i, j = 0, ... 2
const_iterator end() const
Termination of iteration.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const Point & position() const
position
TrackIPTagInfo::SortCriteria sortCriterium
const_iterator begin() const
Initialize an iterator over the RefVector.
edm::EDGetTokenT< reco::BeamSpot > token_BeamSpot
std::vector< SecondaryVertexTagInfo > SecondaryVertexTagInfoCollection
edm::Ref< TrackIPTagInfoCollection > TrackIPTagInfoRef
edm::RefToBase< reco::Track > TrackBaseRef
persistent reference to a Track, using views
float trackWeight(const TrackBaseRef &r) const
returns the weight with which a Track has contributed to the vertex-fit.
edm::ParameterSet vtxRecoPSet
double z() const
y coordinate
ConstraintType constraint
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
Measurement1D dist2d() const
TrackSelector trackSelector
double deltaR(double eta1, double eta2, double phi1, double phi2)
edm::EDGetTokenT< reco::TrackIPTagInfoCollection > token_trackIPTagInfo
double x() const
x coordinate
std::pair< unsigned int, TrackData > IndexedTrackData
bool linearize(const GhostTrackPrediction &pred, bool initial=false, double lambda=0.)
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
math::XYZTLorentzVectorD p4(float mass=0.13957018, float minWeight=0.5) const
Returns the four momentum of the sum of the tracks, assuming the given mass for the decay products...
Error error() const
return SMatrix
~SecondaryVertexProducer()
VertexSorting vertexSorting
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
trackRef_iterator tracks_begin() const
first iterator over tracks
static GhostTrackVertexFinder::FitType getGhostTrackFitType(const std::string &name)
virtual void produce(edm::Event &event, const edm::EventSetup &es) override
Global3DVector GlobalVector
tuple trackSelector
Tracks selection.