CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
InclusiveVertexFinder Class Reference
Inheritance diagram for InclusiveVertexFinder:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

Public Member Functions

 InclusiveVertexFinder (const edm::ParameterSet &params)
 
virtual void produce (edm::Event &event, const edm::EventSetup &es)
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
boost::function< void(const
BranchDescription &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 

Private Member Functions

std::pair< std::vector
< reco::TransientTrack >
, GlobalPoint
nearTracks (const reco::TransientTrack &seed, const std::vector< reco::TransientTrack > &tracks, const reco::Vertex &primaryVertex) const
 
bool trackFilter (const reco::TrackRef &track) const
 

Private Attributes

edm::InputTag beamSpotCollection
 
double clusterMaxDistance
 
double clusterMaxSignificance
 
double clusterMinAngleCosine
 
double clusterScale
 
double min3DIPSignificance
 
double min3DIPValue
 
unsigned int minHits
 
double minPt
 
edm::InputTag primaryVertexCollection
 
edm::InputTag trackCollection
 
double vertexMinAngleCosine
 
double vertexMinDLen2DSig
 
double vertexMinDLenSig
 
std::auto_ptr
< VertexReconstructor
vtxReco
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDProducer
CurrentProcessingContext const * currentContext () const
 
- Protected Member Functions inherited from edm::ProducerBase
template<class TProducer , class TMethod >
void callWhenNewProductsRegistered (TProducer *iProd, TMethod iMethod)
 

Detailed Description

Definition at line 29 of file InclusiveVertexFinder.cc.

Constructor & Destructor Documentation

InclusiveVertexFinder::InclusiveVertexFinder ( const edm::ParameterSet params)

Definition at line 58 of file InclusiveVertexFinder.cc.

58  :
59  beamSpotCollection(params.getParameter<edm::InputTag>("beamSpot")),
60  primaryVertexCollection(params.getParameter<edm::InputTag>("primaryVertices")),
61  trackCollection(params.getParameter<edm::InputTag>("tracks")),
62  minHits(params.getParameter<unsigned int>("minHits")),
63  minPt(params.getParameter<double>("minPt")), //0.8
64  min3DIPSignificance(params.getParameter<double>("seedMin3DIPSignificance")),
65  min3DIPValue(params.getParameter<double>("seedMin3DIPValue")),
66  clusterMaxDistance(params.getParameter<double>("clusterMaxDistance")),
67  clusterMaxSignificance(params.getParameter<double>("clusterMaxSignificance")), //3
68  clusterScale(params.getParameter<double>("clusterScale")),//10.
69  clusterMinAngleCosine(params.getParameter<double>("clusterMinAngleCosine")), //0.0
70  vertexMinAngleCosine(params.getParameter<double>("vertexMinAngleCosine")), //0.98
71  vertexMinDLen2DSig(params.getParameter<double>("vertexMinDLen2DSig")), //2.5
72  vertexMinDLenSig(params.getParameter<double>("vertexMinDLenSig")), //0.5
74 
75 {
76  produces<reco::VertexCollection>();
77  //produces<reco::VertexCollection>("multi");
78 }
T getParameter(std::string const &) const
edm::InputTag primaryVertexCollection
std::auto_ptr< VertexReconstructor > vtxReco

Member Function Documentation

std::pair< std::vector< reco::TransientTrack >, GlobalPoint > InclusiveVertexFinder::nearTracks ( const reco::TransientTrack seed,
const std::vector< reco::TransientTrack > &  tracks,
const reco::Vertex primaryVertex 
) const
private

Definition at line 90 of file InclusiveVertexFinder.cc.

References IPTools::absoluteImpactParameter3D(), TwoTrackMinimumDistance::calculate(), TrajectoryStateOnSurface::cartesianError(), clusterMaxDistance, clusterMaxSignificance, clusterMinAngleCosine, clusterScale, CommonMethods::cp(), TwoTrackMinimumDistance::crossingPoint(), VertexDistance3D::distance(), TwoTrackMinimumDistance::distance(), Vector3DBase< T, FrameTag >::dot(), TrajectoryStateOnSurface::globalDirection(), reco::TransientTrack::impactPointState(), m, mag(), TwoTrackMinimumDistance::points(), CartesianTrajectoryError::position(), reco::Vertex::position(), query::result, Measurement1D::significance(), csvLumiCalc::unit, Vector3DBase< T, FrameTag >::unit(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by produce().

91 {
92  VertexDistance3D distanceComputer;
93  GlobalPoint pv(primaryVertex.position().x(),primaryVertex.position().y(),primaryVertex.position().z());
94  std::vector<reco::TransientTrack> result;
96  GlobalPoint seedingPoint;
97  float sumWeights=0;
98  std::pair<bool,Measurement1D> ipSeed = IPTools::absoluteImpactParameter3D(seed,primaryVertex);
99  float pvDistance = ipSeed.second.value();
100 
101  for(std::vector<reco::TransientTrack>::const_iterator tt = tracks.begin();tt!=tracks.end(); ++tt ) {
102 
103  if(*tt==seed) continue;
104 
105  std::pair<bool,Measurement1D> ip = IPTools::absoluteImpactParameter3D(*tt,primaryVertex);
106  if(dist.calculate(tt->impactPointState(),seed.impactPointState()))
107  {
108  GlobalPoint ttPoint = dist.points().first;
109  GlobalError ttPointErr = tt->impactPointState().cartesianError().position();
110  GlobalPoint seedPosition = dist.points().second;
111  GlobalError seedPositionErr = seed.impactPointState().cartesianError().position();
112  Measurement1D m = distanceComputer.distance(VertexState(seedPosition,seedPositionErr), VertexState(ttPoint, ttPointErr));
113  GlobalPoint cp(dist.crossingPoint());
114 
115 
116  float distanceFromPV = (dist.points().second-pv).mag();
117  float distance = dist.distance();
118  GlobalVector trackDir2D(tt->impactPointState().globalDirection().x(),tt->impactPointState().globalDirection().y(),0.);
119  GlobalVector seedDir2D(seed.impactPointState().globalDirection().x(),seed.impactPointState().globalDirection().y(),0.);
120  float dotprodTrackSeed2D = trackDir2D.unit().dot(seedDir2D.unit());
121 
122  float dotprodTrack = (dist.points().first-pv).unit().dot(tt->impactPointState().globalDirection().unit());
123  float dotprodSeed = (dist.points().second-pv).unit().dot(seed.impactPointState().globalDirection().unit());
124 
125  float w = distanceFromPV*distanceFromPV/(pvDistance*distance);
126 
128  dotprodSeed > clusterMinAngleCosine && //Angles between PV-PCAonSeed vectors and seed directions
129  dotprodTrack > clusterMinAngleCosine && //Angles between PV-PCAonTrack vectors and track directions
130  dotprodTrackSeed2D > clusterMinAngleCosine && //Angle between track and seed
131  distance*clusterScale < distanceFromPV*distanceFromPV/pvDistance && // cut scaling with track density
132  distance < clusterMaxDistance) // absolute distance cut
133  {
134  result.push_back(*tt);
135  seedingPoint = GlobalPoint(cp.x()*w+seedingPoint.x(),cp.y()*w+seedingPoint.y(),cp.z()*w+seedingPoint.z());
136  sumWeights+=w;
137  }
138  }
139  }
140 
141 seedingPoint = GlobalPoint(seedingPoint.x()/sumWeights,seedingPoint.y()/sumWeights,seedingPoint.z()/sumWeights);
142 return std::pair<std::vector<reco::TransientTrack>,GlobalPoint>(result,seedingPoint);
143 
144 }
virtual float distance() const
virtual Measurement1D distance(const GlobalPoint &vtx1Position, const GlobalError &vtx1PositionError, const GlobalPoint &vtx2Position, const GlobalError &vtx2PositionError) const
virtual bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb)
virtual GlobalPoint crossingPoint() const
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
T y() const
Definition: PV3DBase.h:57
const Point & position() const
position
Definition: Vertex.h:93
const CartesianTrajectoryError & cartesianError() const
string unit
Definition: csvLumiCalc.py:46
T z() const
Definition: PV3DBase.h:58
tuple result
Definition: query.py:137
GlobalError position() const
Position error submatrix.
Vector3DBase unit() const
Definition: Vector3DBase.h:57
double significance() const
Definition: Measurement1D.h:32
tuple tracks
Definition: testEve_cfg.py:39
TrajectoryStateOnSurface impactPointState() const
T x() const
Definition: PV3DBase.h:56
virtual std::pair< GlobalPoint, GlobalPoint > points() const
GlobalVector globalDirection() const
void InclusiveVertexFinder::produce ( edm::Event event,
const edm::EventSetup es 
)
virtual

Implements edm::EDProducer.

Definition at line 147 of file InclusiveVertexFinder.cc.

References IPTools::absoluteImpactParameter3D(), beamSpotCollection, dir, Vector3DBase< T, FrameTag >::dot(), edm::EventSetup::get(), i, TransientVertex::isValid(), j, min3DIPSignificance, min3DIPValue, nearTracks(), primaryVertexCollection, dt_dqm_sourceclient_common_cff::reco, asciidump::s, reco::TransientTrack::setBeamSpot(), Measurement1D::significance(), matplotRender::t, trackCollection, trackFilter(), testEve_cfg::tracks, csvLumiCalc::unit, Vector3DBase< T, FrameTag >::unit(), Unknown, v, AdaptiveVertexFitter::vertex(), vertexMinAngleCosine, vertexMinDLen2DSig, vertexMinDLenSig, and vtxReco.

148 {
149  using namespace reco;
150 
151  double sigmacut = 3.0;
152  double Tini = 256.;
153  double ratio = 0.25;
154  VertexDistance3D vdist;
155  VertexDistanceXY vdist2d;
156  MultiVertexFitter theMultiVertexFitter;
157  AdaptiveVertexFitter theAdaptiveFitter(
158  GeometricAnnealing(sigmacut, Tini, ratio),
163 
164 
165  edm::Handle<BeamSpot> beamSpot;
166  event.getByLabel(beamSpotCollection, beamSpot);
167 
168  edm::Handle<VertexCollection> primaryVertices;
169  event.getByLabel(primaryVertexCollection, primaryVertices);
170 
172  event.getByLabel(trackCollection, tracks);
173 
175  es.get<TransientTrackRecord>().get("TransientTrackBuilder",
176  trackBuilder);
177 
178 
179  const reco::Vertex &pv = (*primaryVertices)[0];
180 
181  std::vector<TransientTrack> tts;
182  std::vector<TransientTrack> seeds;
183  //Fill transient track vector and find seeds
184  for(TrackCollection::const_iterator track = tracks->begin();
185  track != tracks->end(); ++track) {
186  TrackRef ref(tracks, track - tracks->begin());
187  if (!trackFilter(ref))
188  continue;
189 
190  TransientTrack tt = trackBuilder->build(ref);
191  tt.setBeamSpot(*beamSpot);
192  tts.push_back(tt);
193  std::pair<bool,Measurement1D> ip = IPTools::absoluteImpactParameter3D(tt,pv);
194 // std::cout << "track: " << ip.second.value() << " " << ip.second.significance() << " " << track->hitPattern().trackerLayersWithMeasurement() << " " << track->pt() << " " << track->eta() << std::endl;
195  if(ip.first && ip.second.value() >= min3DIPValue && ip.second.significance() >= min3DIPSignificance)
196  {
197  // std::cout << "new seed " << ip.second.value() << " " << ip.second.significance() << " " << track->hitPattern().trackerLayersWithMeasurement() << " " << track->pt() << " " << track->eta() << std::endl;
198  seeds.push_back(tt);
199  }
200 
201  }
202 
203 
204  //Create BS object from PV to feed in the AVR
206  for(unsigned int i = 0; i < 7; i++) {
207  for(unsigned int j = 0; j < 7; j++) {
208  if (i < 3 && j < 3)
209  cov(i, j) = pv.covariance(i, j);
210  else
211  cov(i, j) = 0.0;
212  }
213  }
214  BeamSpot bs(pv.position(), 0.0, 0.0, 0.0, 0.0, cov, BeamSpot::Unknown);
215  std::auto_ptr<VertexCollection> recoVertices(new VertexCollection);
216  int i=0;
217  std::vector< std::vector<TransientTrack> > clusters;
218  for(std::vector<TransientTrack>::const_iterator s = seeds.begin();
219  s != seeds.end(); ++s,++i)
220  {
221 
222 // std::cout << "Match pvd = "<< pvd[i] << std::endl;
223  std::pair<std::vector<reco::TransientTrack>,GlobalPoint> ntracks = nearTracks(*s,tts,pv);
224  if(ntracks.first.size() == 0 ) continue;
225  ntracks.first.push_back(*s);
226  clusters.push_back(ntracks.first);
227  std::vector<TransientVertex> vertices;
228 // try {
229  vertices = vtxReco->vertices(ntracks.first, bs);
230  TransientVertex singleFitVertex;
231  singleFitVertex = theAdaptiveFitter.vertex(ntracks.first,ntracks.second); //edPoint);
232  if(singleFitVertex.isValid())
233  vertices.push_back(singleFitVertex);
234 // } catch(...) {
235 // vertices.clear();
236 // }
237 
238 // std::cout << "for this seed I found " << vertices.size() << " vertices"<< std::endl;
239  for(std::vector<TransientVertex>::const_iterator v = vertices.begin();
240  v != vertices.end(); ++v) {
241 // if(v->degreesOfFreedom() > 0.2)
242  {
243  Measurement1D dlen= vdist.distance(pv,*v);
244  Measurement1D dlen2= vdist2d.distance(pv,*v);
245  reco::Vertex vv(*v);
246  // std::cout << "V chi2/n: " << v->normalisedChiSquared() << " ndof: " <<v->degreesOfFreedom() ;
247  // std::cout << " dlen: " << dlen.value() << " error: " << dlen.error() << " signif: " << dlen.significance();
248  // std::cout << " dlen2: " << dlen2.value() << " error2: " << dlen2.error() << " signif2: " << dlen2.significance();
249  // std::cout << " pos: " << vv.position() << " error: " <<vv.xError() << " " << vv.yError() << " " << vv.zError() << std::endl;
250  GlobalVector dir;
251  std::vector<reco::TransientTrack> ts = v->originalTracks();
252  for(std::vector<reco::TransientTrack>::const_iterator i = ts.begin();
253  i != ts.end(); ++i) {
254  reco::TrackRef t = i->trackBaseRef().castTo<reco::TrackRef>();
255  float w = v->trackWeight(*i);
256  if (w > 0.5) dir+=i->impactPointState().globalDirection();
257  // std::cout << "\t[" << (*t).pt() << ": "
258  // << (*t).eta() << ", "
259  // << (*t).phi() << "], "
260  // << w << std::endl;
261  }
262  GlobalPoint ppv(pv.position().x(),pv.position().y(),pv.position().z());
263  GlobalPoint sv((*v).position().x(),(*v).position().y(),(*v).position().z());
264  float vscal = dir.unit().dot((sv-ppv).unit()) ;
265 // std::cout << "Vscal: " << vscal << std::endl;
266  if(dlen.significance() > vertexMinDLenSig && vscal > vertexMinAngleCosine && v->normalisedChiSquared() < 10 && dlen2.significance() > vertexMinDLen2DSig)
267  recoVertices->push_back(*v);
268 
269 
270  }
271  }
272  }
273  event.put(recoVertices);
274 
275 }
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:32
int i
Definition: DBlmapReader.cc:9
void setBeamSpot(const reco::BeamSpot &beamSpot)
edm::InputTag primaryVertexCollection
std::pair< bool, Measurement1D > absoluteImpactParameter3D(const reco::TransientTrack &transientTrack, const reco::Vertex &vertex)
Definition: IPTools.cc:37
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Definition: Vector3DBase.h:107
bool trackFilter(const reco::TrackRef &track) const
string unit
Definition: csvLumiCalc.py:46
std::auto_ptr< VertexReconstructor > vtxReco
int j
Definition: DBlmapReader.cc:9
std::pair< std::vector< reco::TransientTrack >, GlobalPoint > nearTracks(const reco::TransientTrack &seed, const std::vector< reco::TransientTrack > &tracks, const reco::Vertex &primaryVertex) const
Vector3DBase unit() const
Definition: Vector3DBase.h:57
double significance() const
Definition: Measurement1D.h:32
tuple tracks
Definition: testEve_cfg.py:39
const T & get() const
Definition: EventSetup.h:55
string s
Definition: asciidump.py:422
dbl *** dir
Definition: mlp_gen.cc:35
bool isValid() const
mathSSE::Vec4< T > v
bool InclusiveVertexFinder::trackFilter ( const reco::TrackRef track) const
private

Definition at line 80 of file InclusiveVertexFinder.cc.

References minHits, and minPt.

Referenced by produce().

81 {
82  if (track->hitPattern().trackerLayersWithMeasurement() < (int)minHits)
83  return false;
84  if (track->pt() < minPt )
85  return false;
86 
87  return true;
88 }

Member Data Documentation

edm::InputTag InclusiveVertexFinder::beamSpotCollection
private

Definition at line 39 of file InclusiveVertexFinder.cc.

Referenced by produce().

double InclusiveVertexFinder::clusterMaxDistance
private

Definition at line 46 of file InclusiveVertexFinder.cc.

Referenced by nearTracks().

double InclusiveVertexFinder::clusterMaxSignificance
private

Definition at line 47 of file InclusiveVertexFinder.cc.

Referenced by nearTracks().

double InclusiveVertexFinder::clusterMinAngleCosine
private

Definition at line 49 of file InclusiveVertexFinder.cc.

Referenced by nearTracks().

double InclusiveVertexFinder::clusterScale
private

Definition at line 48 of file InclusiveVertexFinder.cc.

Referenced by nearTracks().

double InclusiveVertexFinder::min3DIPSignificance
private

Definition at line 44 of file InclusiveVertexFinder.cc.

Referenced by produce().

double InclusiveVertexFinder::min3DIPValue
private

Definition at line 45 of file InclusiveVertexFinder.cc.

Referenced by produce().

unsigned int InclusiveVertexFinder::minHits
private

Definition at line 42 of file InclusiveVertexFinder.cc.

Referenced by trackFilter().

double InclusiveVertexFinder::minPt
private

Definition at line 43 of file InclusiveVertexFinder.cc.

Referenced by trackFilter().

edm::InputTag InclusiveVertexFinder::primaryVertexCollection
private

Definition at line 40 of file InclusiveVertexFinder.cc.

Referenced by produce().

edm::InputTag InclusiveVertexFinder::trackCollection
private

Definition at line 41 of file InclusiveVertexFinder.cc.

Referenced by produce().

double InclusiveVertexFinder::vertexMinAngleCosine
private

Definition at line 50 of file InclusiveVertexFinder.cc.

Referenced by produce().

double InclusiveVertexFinder::vertexMinDLen2DSig
private

Definition at line 51 of file InclusiveVertexFinder.cc.

Referenced by produce().

double InclusiveVertexFinder::vertexMinDLenSig
private

Definition at line 52 of file InclusiveVertexFinder.cc.

Referenced by produce().

std::auto_ptr<VertexReconstructor> InclusiveVertexFinder::vtxReco
private

Definition at line 54 of file InclusiveVertexFinder.cc.

Referenced by produce().