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 Attributes
DivisiveVertexFinder Class Reference

#include <RecoPixelVertexing/PixelVertexFinding/interface/DivisiveVertexFinder.h>

Public Member Functions

 DivisiveVertexFinder (double track_pt_min, double track_pt_max, double track_chi2_max, double track_prob_min, double zOffset=5.0, int ntrkMin=5, bool useError=true, double zSeparation=0.05, bool wtAverage=true, int verbosity=0)
 
bool findVertexes (const reco::TrackRefVector &trks, reco::VertexCollection &vertexes)
 Run the divisive algorithm and return a vector of vertexes for the input track collection. More...
 
bool findVertexesAlt (const reco::TrackRefVector &trks, reco::VertexCollection &vertexes, const math::XYZPoint &bs)
 
 ~DivisiveVertexFinder ()
 

Private Attributes

pixeltemp::DivisiveClusterizer1D
< reco::Track
divmeth_
 We use Wolfgang's templated class that implements the actual divisive method. More...
 
int ntrkMin_
 
PVClusterComparerpvComparer_
 
bool useError_
 
int verbose_
 
bool wtAverage_
 
double zOffset_
 Cuts on vertex formation and other options. More...
 
double zSeparation_
 

Detailed Description

Description: Fits a primary vertex in 1D (z) using the "divisive method"

Implementation: This class was ported from ORCA by me (Aaron). It was originally written by ... Find the PV candidates with a simple divisive method. Divide the luminosity region in several regions according to the track distance and for each of them make a PVCluster. Iteratively discard tracks and recover them in a new PVCluster. Return a sorted vector<Vertex> (aka VertexCollection) with the z coordinate of PV candidates

Parameters
ntkminMinimum number of tracks required to form a cluster.
useErrorphysical distances or weighted distances.
zsepMaximum distance between two adjacent tracks that belong to the same initial cluster.
weiCompute the cluster "center" with an unweighted or a weighted average of the tracks. Weighted means weighted with the error of the data point.
Author
Aaron Dominguez (UNL)

Definition at line 34 of file DivisiveVertexFinder.h.

Constructor & Destructor Documentation

DivisiveVertexFinder::DivisiveVertexFinder ( double  track_pt_min,
double  track_pt_max,
double  track_chi2_max,
double  track_prob_min,
double  zOffset = 5.0,
int  ntrkMin = 5,
bool  useError = true,
double  zSeparation = 0.05,
bool  wtAverage = true,
int  verbosity = 0 
)

Definition at line 13 of file DivisiveVertexFinder.cc.

References pvComparer_.

17  : zOffset_(zOffset), zSeparation_(zSeparation), ntrkMin_(ntrkMin), useError_(useError),
18  wtAverage_(wtAverage),
19  divmeth_(zOffset, ntrkMin, useError, zSeparation, wtAverage),
21 {
22 
24 
25 }
pixeltemp::DivisiveClusterizer1D< reco::Track > divmeth_
We use Wolfgang&#39;s templated class that implements the actual divisive method.
PVClusterComparer * pvComparer_
double zOffset_
Cuts on vertex formation and other options.
DivisiveVertexFinder::~DivisiveVertexFinder ( )

Definition at line 27 of file DivisiveVertexFinder.cc.

27 {}

Member Function Documentation

bool DivisiveVertexFinder::findVertexes ( const reco::TrackRefVector trks,
reco::VertexCollection vertexes 
)

Run the divisive algorithm and return a vector of vertexes for the input track collection.

Definition at line 29 of file DivisiveVertexFinder.cc.

References PVPositionBuilder::average(), Measurement1D::error(), i, edm::isNotFinite(), edm::RefVector< C, T, F >::size(), findQualityFiles::v, Measurement1D::value(), PVPositionBuilder::wtAverage(), and wtAverage_.

Referenced by PixelVertexProducer::produce().

30  { // output
32  Measurement1D vz;
33  if (wtAverage_) {
34  vz = pos.wtAverage(trks);
35  }
36  else {
37  vz = pos.average(trks);
38  }
40  err(2,2) = vz.error()*vz.error();
41 
42  reco::Vertex v( reco::Vertex::Point(0,0,vz.value()), err, 0, 1, trks.size() );
43  for (unsigned int i=0; i<trks.size(); i++) {
44  double vz = trks[i]->vz();
45  if(edm::isNotFinite(vz)) continue;
46  v.add(reco::TrackBaseRef(trks[i]));
47  }
48 
49  vertexes.push_back(v);
50 
51  return true;
52 }
int i
Definition: DBlmapReader.cc:9
double error() const
Definition: Measurement1D.h:30
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
bool isNotFinite(T x)
Definition: isFinite.h:10
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
Measurement1D average(const reco::TrackRefVector &trks) const
Calculate unweighted average of Z of tracks from const collection of track pointers.
double value() const
Definition: Measurement1D.h:28
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
Measurement1D wtAverage(const reco::TrackRefVector &trks) const
Calculate Error-Weighted average of Z of tracks from const collection of track pointers.
bool DivisiveVertexFinder::findVertexesAlt ( const reco::TrackRefVector trks,
reco::VertexCollection vertexes,
const math::XYZPoint bs 
)

Definition at line 54 of file DivisiveVertexFinder.cc.

References divmeth_, i, recoMuon::in, edm::isNotFinite(), GenerateHcalLaserBadRunList::out, pvComparer_, pixeltemp::DivisiveClusterizer1D< T >::setBeamSpot(), edm::RefVector< C, T, F >::size(), mathSSE::sqrt(), groupFilesInBlocks::temp, findQualityFiles::v, and verbose_.

Referenced by PixelVertexProducer::produce().

55  { // output
56  std::vector< PVCluster > in;
57  std::pair< std::vector< PVCluster >, std::vector< const reco::Track* > > out;
58 
59  // Convert input track collection into container needed by Wolfgang's templated code
60  // Need to save a map to reconvert from bare pointers, oy vey
61  std::map< const reco::Track*, reco::TrackRef > mapa;
62  // std::vector< std::vector< const reco::Track* > > trkps;
63  for (unsigned int i=0; i<trks.size(); ++i) {
64  double vz = trks[i]->vz();
65  if(edm::isNotFinite(vz)) continue;
66  std::vector< const reco::Track* > temp;
67  temp.clear();
68  temp.push_back( &(*trks[i]) );
69 
70  in.push_back( PVCluster( Measurement1D(trks[i]->dz(bs), trks[i]->dzError() ), temp ) );
71  mapa[temp[0]] = trks[i];
72  }
73 
74  if (verbose_ > 0 ) {
75  edm::LogInfo("DivisiveVertexFinder") << "size of input vector of clusters " << in.size();
76  for (unsigned int i=0; i<in.size(); ++i) {
77  edm::LogInfo("DivisiveVertexFinder") << "Track " << i << " addr " << in[i].tracks()[0]
78  << " dz " << in[i].tracks()[0]->dz(bs)
79  << " +- " << in[i].tracks()[0]->dzError()
80  << " prodID " << mapa[in[i].tracks()[0]].id()
81  << " dz from RefTrack " << mapa[in[i].tracks()[0]]->dz(bs)
82  << " +- " << mapa[in[i].tracks()[0]]->dzError();
83  }
84  }
85 
86  // Run the darn thing
88  out = divmeth_(in);
89 
90  if (verbose_ > 0) edm::LogInfo("DivisiveVertexFinder") << " DivisiveClusterizer1D found "
91  << out.first.size() << " vertexes";
92 
93  // Now convert the output yet again into something we can safely store in the event
94  for (unsigned int iv=0; iv<out.first.size(); ++iv) { // loop over output vertexes
96  err(2,2) = out.first[iv].position().error()*out.first[iv].position().error();
97 
98  reco::Vertex v( reco::Vertex::Point(0,0,out.first[iv].position().value()), err, 0, 1, out.second.size() );
99  if (verbose_ > 0 ) edm::LogInfo("DivisiveVertexFinder") << " DivisiveClusterizer1D vertex " << iv
100  << " has " << out.first[iv].tracks().size()
101  << " tracks and a position of " << v.z()
102  << " +- " << std::sqrt(v.covariance(2,2));
103  for (unsigned int itrk=0; itrk<out.first[iv].tracks().size(); ++itrk) {
104  v.add( reco::TrackBaseRef(mapa[out.first[iv].tracks()[itrk]] ) );
105  }
106  vertexes.push_back(v); // Done with horrible conversion, save it
107  }
108 
109  // Finally, sort the vertexes in decreasing sumPtSquared
110  // std::sort(vertexes.begin(), vertexes.end(), PVClusterComparer());
111  std::sort(vertexes.begin(), vertexes.end(), *pvComparer_);
112 
113  return true;
114 }
int i
Definition: DBlmapReader.cc:9
pixeltemp::DivisiveClusterizer1D< reco::Track > divmeth_
We use Wolfgang&#39;s templated class that implements the actual divisive method.
PVClusterComparer * pvComparer_
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
bool isNotFinite(T x)
Definition: isFinite.h:10
T sqrt(T t)
Definition: SSEVec.h:18
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
void setBeamSpot(const math::XYZPoint &bs)
size_type size() const
Size of the RefVector.
Definition: RefVector.h:107
Cluster1D< reco::Track > PVCluster
Definition: PVCluster.h:14

Member Data Documentation

pixeltemp::DivisiveClusterizer1D< reco::Track > DivisiveVertexFinder::divmeth_
private

We use Wolfgang's templated class that implements the actual divisive method.

Definition at line 53 of file DivisiveVertexFinder.h.

Referenced by findVertexesAlt().

int DivisiveVertexFinder::ntrkMin_
private

Definition at line 49 of file DivisiveVertexFinder.h.

PVClusterComparer* DivisiveVertexFinder::pvComparer_
private

Definition at line 60 of file DivisiveVertexFinder.h.

Referenced by DivisiveVertexFinder(), and findVertexesAlt().

bool DivisiveVertexFinder::useError_
private

Definition at line 50 of file DivisiveVertexFinder.h.

int DivisiveVertexFinder::verbose_
private

Definition at line 57 of file DivisiveVertexFinder.h.

Referenced by findVertexesAlt().

bool DivisiveVertexFinder::wtAverage_
private

Definition at line 50 of file DivisiveVertexFinder.h.

Referenced by findVertexes().

double DivisiveVertexFinder::zOffset_
private

Cuts on vertex formation and other options.

Definition at line 48 of file DivisiveVertexFinder.h.

double DivisiveVertexFinder::zSeparation_
private

Definition at line 48 of file DivisiveVertexFinder.h.