CMS 3D CMS Logo

Public Member Functions | Private Attributes

DivisiveVertexFinder Class Reference

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

List of all members.

Public Member Functions

 DivisiveVertexFinder (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.
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.
int ntrkMin_
bool useError_
int verbose_
bool wtAverage_
double zOffset_
 Cuts on vertex formation and other options.
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.
Date:
2010/02/10 14:14:44
Revision:
1.7
Author:
Aaron Dominguez (UNL)

Definition at line 34 of file DivisiveVertexFinder.h.


Constructor & Destructor Documentation

DivisiveVertexFinder::DivisiveVertexFinder ( 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.

  : zOffset_(zOffset), zSeparation_(zSeparation), ntrkMin_(ntrkMin), useError_(useError),
    wtAverage_(wtAverage),
    divmeth_(zOffset, ntrkMin, useError, zSeparation, wtAverage),
    verbose_(verbosity)
{

}
DivisiveVertexFinder::~DivisiveVertexFinder ( )

Definition at line 24 of file DivisiveVertexFinder.cc.

{}

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 26 of file DivisiveVertexFinder.cc.

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

Referenced by PixelVertexProducer::produce().

                                                                       { // output
  PVPositionBuilder pos;
  Measurement1D vz;
  if (wtAverage_) {
    vz = pos.wtAverage(trks);
  }
  else {
    vz = pos.average(trks);
  }
  reco::Vertex::Error err;
  err(2,2) = vz.error()*vz.error();

  reco::Vertex v( reco::Vertex::Point(0,0,vz.value()), err, 0, 1, trks.size() );
    for (unsigned int i=0; i<trks.size(); i++) {
      double vz = trks[i]->vz();
      if(std::isnan(vz)) continue;
      v.add(reco::TrackBaseRef(trks[i]));
    }
    
  vertexes.push_back(v);

  return true;
}
bool DivisiveVertexFinder::findVertexesAlt ( const reco::TrackRefVector trks,
reco::VertexCollection vertexes,
const math::XYZPoint bs 
)

Definition at line 51 of file DivisiveVertexFinder.cc.

References divmeth_, i, recoMuon::in, edm::detail::isnan(), dbtoconf::out, pixeltemp::DivisiveClusterizer1D< T >::setBeamSpot(), edm::RefVector< C, T, F >::size(), python::multivaluedict::sort(), mathSSE::sqrt(), cond::rpcobtemp::temp, v, and verbose_.

Referenced by PixelVertexProducer::produce().

                                                                                                   { // output
  std::vector< PVCluster > in;
  std::pair< std::vector< PVCluster >, std::vector< const reco::Track* > > out;
  
  // Convert input track collection into container needed by Wolfgang's templated code
  // Need to save a map to reconvert from bare pointers, oy vey
  std::map< const reco::Track*, reco::TrackRef > mapa; 
  //  std::vector< std::vector< const reco::Track* > > trkps;
  for (unsigned int i=0; i<trks.size(); ++i) {
    double vz = trks[i]->vz();
    if(std::isnan(vz)) continue;
    std::vector< const reco::Track* > temp;
    temp.clear();
    temp.push_back( &(*trks[i]) );

    in.push_back( PVCluster( Measurement1D(trks[i]->dz(bs), trks[i]->dzError() ), temp ) );
    mapa[temp[0]] = trks[i];
  }

  if (verbose_ > 0 ) {
    edm::LogInfo("DivisiveVertexFinder") << "size of input vector of clusters " << in.size();
    for (unsigned int i=0; i<in.size(); ++i) {
      edm::LogInfo("DivisiveVertexFinder") << "Track " << i << " addr " << in[i].tracks()[0] 
                                           << " dz " << in[i].tracks()[0]->dz(bs)
                                           << " +- " << in[i].tracks()[0]->dzError()
                                           << " prodID " << mapa[in[i].tracks()[0]].id()
                                           << " dz from RefTrack " << mapa[in[i].tracks()[0]]->dz(bs)
                                           << " +- " << mapa[in[i].tracks()[0]]->dzError();
    }
  }

  // Run the darn thing
  divmeth_.setBeamSpot(bs);
  out = divmeth_(in);

  if (verbose_ > 0) edm::LogInfo("DivisiveVertexFinder") << " DivisiveClusterizer1D found " 
                                                         << out.first.size() << " vertexes";

  // Now convert the output yet again into something we can safely store in the event
  for (unsigned int iv=0; iv<out.first.size(); ++iv) { // loop over output vertexes
    reco::Vertex::Error err;
    err(2,2) = out.first[iv].position().error()*out.first[iv].position().error();
    
    reco::Vertex v( reco::Vertex::Point(0,0,out.first[iv].position().value()), err, 0, 1, out.second.size() );
    if (verbose_ > 0 ) edm::LogInfo("DivisiveVertexFinder") << " DivisiveClusterizer1D vertex " << iv 
                                                            << " has " << out.first[iv].tracks().size()
                                                            << " tracks and a position of " << v.z() 
                                                            << " +- " << std::sqrt(v.covariance(2,2));
    for (unsigned int itrk=0; itrk<out.first[iv].tracks().size(); ++itrk) {
      v.add( reco::TrackBaseRef(mapa[out.first[iv].tracks()[itrk]] ) );
    }
    vertexes.push_back(v); // Done with horrible conversion, save it
  }

  // Finally, sort the vertexes in decreasing sumPtSquared
  std::sort(vertexes.begin(), vertexes.end(), PVClusterComparer());

  return true;
}

Member Data Documentation

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

Definition at line 52 of file DivisiveVertexFinder.h.

Referenced by findVertexesAlt().

Definition at line 48 of file DivisiveVertexFinder.h.

Definition at line 49 of file DivisiveVertexFinder.h.

Definition at line 56 of file DivisiveVertexFinder.h.

Referenced by findVertexesAlt().

Definition at line 49 of file DivisiveVertexFinder.h.

Referenced by findVertexes().

Cuts on vertex formation and other options.

Definition at line 47 of file DivisiveVertexFinder.h.

Definition at line 47 of file DivisiveVertexFinder.h.