CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends

PFDisplacedVertexCandidateFinder Class Reference

#include <PFDisplacedVertexCandidateFinder.h>

List of all members.

Public Types

typedef
reco::PFDisplacedVertexCandidateCollection::const_iterator 
IBC
typedef std::list
< reco::TrackBaseRef >
::iterator 
IE
typedef std::list
< reco::TrackBaseRef >
::const_iterator 
IEC
typedef std::vector< bool > Mask
 Mask used to spot if a track is free or not.

Public Member Functions

void findDisplacedVertexCandidates ()
 -------- Main function which find vertices -------- ///
 PFDisplacedVertexCandidateFinder ()
void setDebug (bool debug)
 sets debug printout flag
void setInput (const edm::Handle< reco::TrackCollection > &trackh, const MagneticField *magField)
void setParameters (double dcaCut, double primaryVertexCut, double dcaPInnerHitCut, const edm::ParameterSet &ps_trk)
 --------- Set different algo parameters ------ ///
void setPrimaryVertex (edm::Handle< reco::VertexCollection > mainVertexHandle, edm::Handle< reco::BeamSpot > beamSpotHandle)
std::auto_ptr
< reco::PFDisplacedVertexCandidateCollection
transferVertexCandidates ()
const std::auto_ptr
< reco::PFDisplacedVertexCandidateCollection > & 
vertexCandidates () const
 ~PFDisplacedVertexCandidateFinder ()

Private Member Functions

IE associate (IE next, IE last, reco::PFDisplacedVertexCandidate &tempVertexCandidate)
 -------- Different steps of the finder algorithm -------- ///
GlobalTrajectoryParameters getGlobalTrajectoryParameters (const reco::Track *) const
 -------- TOOLS -------- //
bool goodPtResolution (const reco::TrackBaseRef &trackref) const
 Quality Criterion on the Pt resolution to select a Track.
bool isSelected (const reco::TrackBaseRef &trackref)
void link (const reco::TrackBaseRef &el1, const reco::TrackBaseRef &el2, double &dist, GlobalPoint &P, reco::PFDisplacedVertexCandidate::VertexLinkTest &linktest)
 Check whether 2 elements are linked and fill the link parameters.
void packLinks (reco::PFDisplacedVertexCandidate &vertexCandidate)

Private Attributes

double dcaCut_
 ----- Algo parameters for the vertex finder ---- ///
double dcaPInnerHitCut2_
 Maximum distance between the DCA Point and the inner hit of the track.
bool debug_
 if true, debug printouts activated
double dxy_
std::list< reco::TrackBaseRefeventTracks_
 The track refs.
std::vector
< GlobalTrajectoryParameters
eventTrackTrajectories_
const MagneticFieldmagField_
double nChi2_max_
double primaryVertexCut2_
 Do not reconstruct vertices wich are too close to the beam pipe.
double pt_min_
double pt_min_prim_
math::XYZPoint pvtx_
TwoTrackMinimumDistance theMinimum_
Mask trackMask_
std::auto_ptr
< reco::PFDisplacedVertexCandidateCollection
vertexCandidates_
 -------- Members -------- ///
unsigned vertexCandidatesSize_

Friends

std::ostream & operator<< (std::ostream &, const PFDisplacedVertexCandidateFinder &)

Detailed Description

Definition at line 24 of file PFDisplacedVertexCandidateFinder.h.


Member Typedef Documentation

typedef reco::PFDisplacedVertexCandidateCollection::const_iterator PFDisplacedVertexCandidateFinder::IBC

Definition at line 38 of file PFDisplacedVertexCandidateFinder.h.

Definition at line 36 of file PFDisplacedVertexCandidateFinder.h.

typedef std::list< reco::TrackBaseRef >::const_iterator PFDisplacedVertexCandidateFinder::IEC

Definition at line 37 of file PFDisplacedVertexCandidateFinder.h.

typedef std::vector<bool> PFDisplacedVertexCandidateFinder::Mask

Mask used to spot if a track is free or not.

Definition at line 34 of file PFDisplacedVertexCandidateFinder.h.


Constructor & Destructor Documentation

PFDisplacedVertexCandidateFinder::PFDisplacedVertexCandidateFinder ( )
PFDisplacedVertexCandidateFinder::~PFDisplacedVertexCandidateFinder ( )

Definition at line 28 of file PFDisplacedVertexCandidateFinder.cc.

References gather_cfg::cout, debug_, and eventTracks_.

                                                                    {

#ifdef PFLOW_DEBUG
  if(debug_)
    cout<<"~PFDisplacedVertexCandidateFinder - number of remaining elements: "
        <<eventTracks_.size()<<endl;
#endif
  
}

Member Function Documentation

PFDisplacedVertexCandidateFinder::IE PFDisplacedVertexCandidateFinder::associate ( IE  next,
IE  last,
reco::PFDisplacedVertexCandidate tempVertexCandidate 
) [private]

-------- Different steps of the finder algorithm -------- ///

Recursive procedure to associate tracks together

Definition at line 129 of file PFDisplacedVertexCandidateFinder.cc.

References reco::PFDisplacedVertexCandidate::addElement(), gather_cfg::cout, debug_, eventTracks_, i, link(), P, trackMask_, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by findDisplacedVertexCandidates().

                                                                                             {

    
#ifdef PFLOW_DEBUG
  if(debug_ ) cout<<"== Start the association procedure =="<<endl;
#endif

  if( last!= eventTracks_.end() ) {
    double dist = -1;
    GlobalPoint P(0,0,0);
    PFDisplacedVertexCandidate::VertexLinkTest linktest;
    link( (*last), (*next), dist, P, linktest); 


    if(dist<-0.5) {
#ifdef PFLOW_DEBUG
      if(debug_ ) cout<<"link failed"<<endl;
#endif
      return ++next; // association failed
    }
    else {
      // add next element to the current pflowblock
      tempVertexCandidate.addElement( (*next));  
      trackMask_[(*next).key()] = false;
#ifdef PFLOW_DEBUG   
      if(debug_ ) 
        cout<<"link parameters "
            << " *next = " << (*next).key()
            << " *last = " << (*last).key()
            << "  dist = " << dist
            << " P.x = " << P.x() 
            << " P.y = " << P.y()
            << " P.z = " << P.z()
            << endl;
#endif
    }
  }
  else {
    // add next element to this eflowblock
#ifdef PFLOW_DEBUG   
    if(debug_ ) cout<<"adding to block element "
                    << (*next).key()
                    <<endl;
#endif
    tempVertexCandidate.addElement( (*next));  
    trackMask_[(*next).key()] = false;


  }

  // recursive call: associate next and other unused elements 
#ifdef PFLOW_DEBUG  
  if(debug_ ) {
    for(unsigned i=0; i<trackMask_.size(); i++) 
      cout << " Mask[" << i << "] = " << trackMask_[i];
    cout << "" << endl;
  }
#endif

  for(IE ie = eventTracks_.begin(); 
      ie != eventTracks_.end();) {
    
    if( ie == last || ie == next ) { ++ie; continue;} 

    // *ie already included to a block
    if( !trackMask_[(*ie).key()] ) { ++ie; continue;}

#ifdef PFLOW_DEBUG      
    if(debug_ ) cout<<"calling associate "
                    << (*next).key()
                    <<" & "
                    << (*ie).key()
                    <<endl;
#endif
    ie = associate(next, ie, tempVertexCandidate);
    
  }       

#ifdef PFLOW_DEBUG
  if(debug_ ) {
    cout<<"**** removing element "<<endl;
  }
#endif

  IE iteratorToNextFreeElement = eventTracks_.erase( next );

#ifdef PFLOW_DEBUG
  if(debug_ ) cout<< "== End the association procedure ==" <<endl;
#endif

  return iteratorToNextFreeElement;
}
void PFDisplacedVertexCandidateFinder::findDisplacedVertexCandidates ( )

-------- Main function which find vertices -------- ///

Definition at line 94 of file PFDisplacedVertexCandidateFinder.cc.

References associate(), gather_cfg::cout, debug_, eventTracks_, reco::PFDisplacedVertexCandidate::isValid(), packLinks(), vertexCandidates_, and vertexCandidatesSize_.

                                                                {

  if (debug_) cout << "========= Start Finding Displaced Vertex Candidates =========" << endl;
  
  // The vertexCandidates have not been passed to the event, and need to be cleared
  if(vertexCandidates_.get() )vertexCandidates_->clear();
  else 
    vertexCandidates_.reset( new PFDisplacedVertexCandidateCollection );

  vertexCandidates_->reserve(vertexCandidatesSize_);
  for(IE ie = eventTracks_.begin(); 
      ie != eventTracks_.end();) {

    // Run the recursive procedure to find all tracks link together 
    // In one blob called Candidate

    PFDisplacedVertexCandidate tempVertexCandidate;

    ie = associate( eventTracks_.end() , ie, tempVertexCandidate);

    // Build remaining links in current block
    if(tempVertexCandidate.isValid()) {
      packLinks( tempVertexCandidate );
      vertexCandidates_->push_back( tempVertexCandidate );
    }
  }       

  if(debug_) cout << "========= End Finding Displaced Vertex Candidates =========" << endl;

}
GlobalTrajectoryParameters PFDisplacedVertexCandidateFinder::getGlobalTrajectoryParameters ( const reco::Track track) const [private]

-------- TOOLS -------- //

Allows to calculate the helix aproximation for a given track which may be then extrapolated to any point.

Definition at line 341 of file PFDisplacedVertexCandidateFinder.cc.

References reco::TrackBase::charge(), reco::TrackBase::momentum(), position, reco::TrackBase::vx(), reco::TrackBase::vy(), and reco::TrackBase::vz().

Referenced by setInput().

{

  const GlobalPoint position(track->vx(),
                             track->vy(),
                             track->vz());
 
  const GlobalVector momentum(track->momentum().x(),
                              track->momentum().y(),
                              track->momentum().z());

  GlobalTrajectoryParameters gtp(position,momentum,
                                 track->charge(),magField_);

  return gtp;
}
bool PFDisplacedVertexCandidateFinder::goodPtResolution ( const reco::TrackBaseRef trackref) const [private]

Quality Criterion on the Pt resolution to select a Track.

Definition at line 361 of file PFDisplacedVertexCandidateFinder.cc.

References gather_cfg::cout, debug_, dxy_, nChi2_max_, pt_min_, pt_min_prim_, and pvtx_.

Referenced by isSelected().

                                                                                      {

  double nChi2 = trackref->normalizedChi2(); 
  double pt = trackref->pt();
  double dpt = trackref->ptError();
  double dxy = trackref->dxy(pvtx_);

  double pt_error = dpt/pt*100;

  if (debug_) cout << " PFDisplacedVertexFinder: PFrecTrack->Track Pt= "
                   << pt << " dPt/Pt = " << pt_error << "% nChi2 = " << nChi2 << endl;
  if (nChi2 > nChi2_max_ || pt < pt_min_){

    if (debug_) cout << " PFBlockAlgo: skip badly measured or low pt track"
                     << " nChi2_cut = " << 5 
                     << " pt_cut = " << 0.2 << endl;
    return false;
  }
  //  cout << "dxy = " << dxy << endl; 
  if (fabs(dxy) < dxy_ && pt < pt_min_prim_) return false;
  //  if (fabs(dxy) < 0.2 && pt < 0.8) return false;

  

  return true;
}
bool PFDisplacedVertexCandidateFinder::isSelected ( const reco::TrackBaseRef trackref) [inline, private]

A function which gather the information if a track is available for vertexing

Definition at line 110 of file PFDisplacedVertexCandidateFinder.h.

References goodPtResolution().

Referenced by setInput().

    { return goodPtResolution(trackref);}
void PFDisplacedVertexCandidateFinder::link ( const reco::TrackBaseRef el1,
const reco::TrackBaseRef el2,
double &  dist,
GlobalPoint P,
reco::PFDisplacedVertexCandidate::VertexLinkTest linktest 
) [private]

Check whether 2 elements are linked and fill the link parameters.

Definition at line 37 of file DDHtmlFormatter.cc.

Referenced by associate().

{
  pre();
  os_ << lnk(url,txt,target) << endl;
  return *this;
}
void PFDisplacedVertexCandidateFinder::packLinks ( reco::PFDisplacedVertexCandidate vertexCandidate) [private]

Compute missing links in the displacedVertexCandidates (the recursive procedure does not build all links)

Definition at line 237 of file PFBlockAlgo.cc.

References reco::PFBlock::bookLinkData(), gather_cfg::cout, PFBlockAlgo::debug_, reco::PFBlock::elements(), asciidump::els, PFBlockAlgo::link(), reco::PFBlock::linkData(), PFBlockAlgo::linkPrefilter(), NONE, reco::PFBlock::setLink(), and edm::OwnVector< T, P >::size().

Referenced by findDisplacedVertexCandidates().

                                                                 {
  
  
  const edm::OwnVector< reco::PFBlockElement >& els = block.elements();
  
  block.bookLinkData();

  unsigned elsize = els.size();
  unsigned ilStart = 0;
  //First Loop: update all link data
  for( unsigned i1=0; i1<elsize; ++i1 ) {
    for( unsigned i2=0; i2<i1; ++i2 ) {
      
      // no reflexive link
      //if( i1==i2 ) continue;
      
      double dist = -1;
      
      bool linked = false;
      PFBlock::LinkTest linktest 
        = PFBlock::LINKTEST_RECHIT; 

      // are these elements already linked ?
      // this can be optimized

      unsigned linksize = links.size();
      for( unsigned il = ilStart; il<linksize; ++il ) {
        // The following three lines exploits the increasing-element2 ordering of links.
        if ( links[il].element2() < i1 ) ilStart = il;
        if ( links[il].element2() > i1 ) break;
        if( (links[il].element1() == i2 && 
             links[il].element2() == i1) ) { // yes
          
          dist = links[il].dist();
          linked = true;

          //modif-beg     
          //retrieve type of test used to get distance
          linktest = links[il].test();
#ifdef PFLOW_DEBUG
          if( debug_ )
            cout << "Reading link vector: linktest used=" 
                 << linktest 
                 << " distance = " << dist 
                 << endl; 
#endif
          //modif-end
          
          break;
        } 
      }
      
      if(!linked) {
        PFBlockLink::Type linktype = PFBlockLink::NONE;
        bool bTestLink = linkPrefilter(&els[i1], &els[i2]);
        if (bTestLink) link( & els[i1], & els[i2], linktype, linktest, dist);
      }

      //loading link data according to link test used: RECHIT 
      //block.setLink( i1, i2, chi2, block.linkData() );
#ifdef PFLOW_DEBUG
      if( debug_ )
        cout << "Setting link between elements " << i1 << " and " << i2
             << " of dist =" << dist << " computed from link test "
             << linktest << endl;
#endif
      block.setLink( i1, i2, dist, block.linkData(), linktest );
    }
  }

}
void PFDisplacedVertexCandidateFinder::setDebug ( bool  debug) [inline]

sets debug printout flag

Definition at line 56 of file PFDisplacedVertexCandidateFinder.h.

References debug, and debug_.

void PFDisplacedVertexCandidateFinder::setInput ( const edm::Handle< reco::TrackCollection > &  trackh,
const MagneticField magField 
)

Set the imput collection of tracks and calculate their trajectory parameters the Global Trajectory Parameters

Definition at line 60 of file PFDisplacedVertexCandidateFinder.cc.

References eventTracks_, eventTrackTrajectories_, edm::Ref< C, T, F >::get(), getGlobalTrajectoryParameters(), i, isSelected(), edm::HandleBase::isValid(), magField_, and trackMask_.

                                                                          {

  magField_ = magField;
  trackMask_.clear();
  trackMask_.resize(trackh->size());
  eventTrackTrajectories_.clear();
  eventTrackTrajectories_.resize(trackh->size());

  for(unsigned i=0;i<trackMask_.size(); i++) trackMask_[i] = true; 

  eventTracks_.clear();
  if(trackh.isValid()) {
    for(unsigned i=0;i<trackh->size(); i++) {

      TrackRef tref( trackh, i); 
      TrackBaseRef tbref(tref);

      if( !isSelected( tbref ) ) {
        trackMask_[i] = false;
        continue;      
      }
      
      const Track* trk = tref.get();
      eventTracks_.push_back( tbref );
      eventTrackTrajectories_[i] = getGlobalTrajectoryParameters(trk);
    }
  }
}
void PFDisplacedVertexCandidateFinder::setParameters ( double  dcaCut,
double  primaryVertexCut,
double  dcaPInnerHitCut,
const edm::ParameterSet ps_trk 
) [inline]

--------- Set different algo parameters ------ ///

Sets algo parameters for the vertex candidate finder

Definition at line 44 of file PFDisplacedVertexCandidateFinder.h.

References dcaCut_, dcaPInnerHitCut2_, dxy_, edm::ParameterSet::getParameter(), nChi2_max_, primaryVertexCut2_, pt_min_, and pt_min_prim_.

                                                    {
    dcaCut_ = dcaCut;
    primaryVertexCut2_ = primaryVertexCut*primaryVertexCut;
    dcaPInnerHitCut2_ = dcaPInnerHitCut*dcaPInnerHitCut;
    nChi2_max_ = ps_trk.getParameter<double>("nChi2_max");
    pt_min_ = ps_trk.getParameter<double>("pt_min");
    pt_min_prim_ = ps_trk.getParameter<double>("pt_min_prim");
    dxy_ = ps_trk.getParameter<double>("dxy");
  }
void PFDisplacedVertexCandidateFinder::setPrimaryVertex ( edm::Handle< reco::VertexCollection mainVertexHandle,
edm::Handle< reco::BeamSpot beamSpotHandle 
)

Definition at line 39 of file PFDisplacedVertexCandidateFinder.cc.

References SiPixelRawToDigiRegional_cfi::beamSpot, edm::HandleBase::isValid(), and pvtx_.

                                                                                        {

  const math::XYZPoint beamSpot = beamSpotHandle.isValid() ? 
    math::XYZPoint(beamSpotHandle->x0(), beamSpotHandle->y0(), beamSpotHandle->z0()) : 
    math::XYZPoint(0, 0, 0);

  // The primary vertex is taken from the refitted list, 
  // if does not exist from the average offline beam spot position  
  // if does not exist (0,0,0) is used
  pvtx_ = mainVertexHandle.isValid() ? 
    math::XYZPoint(mainVertexHandle->begin()->x(), 
                   mainVertexHandle->begin()->y(), 
                   mainVertexHandle->begin()->z()) :
    beamSpot;
}
std::auto_ptr< reco::PFDisplacedVertexCandidateCollection > PFDisplacedVertexCandidateFinder::transferVertexCandidates ( ) [inline]
Returns:
auto_ptr to collection of DisplacedVertexCandidates

Definition at line 65 of file PFDisplacedVertexCandidateFinder.h.

References vertexCandidates_.

const std::auto_ptr< reco::PFDisplacedVertexCandidateCollection >& PFDisplacedVertexCandidateFinder::vertexCandidates ( ) const [inline]

Definition at line 67 of file PFDisplacedVertexCandidateFinder.h.

References vertexCandidates_.

Referenced by operator<<().

    {return vertexCandidates_;}

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const PFDisplacedVertexCandidateFinder a 
) [friend]

Definition at line 398 of file PFDisplacedVertexCandidateFinder.cc.

                                                                                {
  if(! out) return out;
  
  out<<"====== Particle Flow Block Algorithm ======= ";
  out<<endl;
  out<<"number of unassociated elements : "<<a.eventTracks_.size()<<endl;
  out<<endl;
  
  out << " Tracks selection based on " << std::endl;
  out << " pvtx_ = " << a.pvtx_ << std::endl;
  out << " fabs(dxy) < " << a.dxy_ << " and pt < "<< a.pt_min_prim_ << std::endl;
  out << " nChi2 < " << a.nChi2_max_ << " and pt < "<< a.pt_min_ << std::endl;

  out<<endl;


  for(PFDisplacedVertexCandidateFinder::IEC ie = a.eventTracks_.begin(); 
      ie != a.eventTracks_.end(); ie++) {

    double pt = (*ie).get()->pt(); 

    math::XYZPoint Pi = (*ie).get()->innerPosition(); 
    math::XYZPoint Po = (*ie).get()->outerPosition(); 

    double innermost_radius = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y() + Pi.z()*Pi.z());
    double outermost_radius = sqrt(Po.x()*Po.x() + Po.y()*Po.y() + Po.z()*Po.z());
    double innermost_rho = sqrt(Pi.x()*Pi.x() + Pi.y()*Pi.y());
    double outermost_rho = sqrt(Po.x()*Po.x() + Po.y()*Po.y());
    
    out<<"ie = " << (*ie).key() 
       <<" pt = " << pt
       <<" innermost hit radius = " << innermost_radius << " rho = " << innermost_rho
       <<" outermost hit radius = " << outermost_radius << " rho = " << outermost_rho
       <<endl;
  }


  const std::auto_ptr< reco::PFDisplacedVertexCandidateCollection >& vertexCandidates
    = a.vertexCandidates(); 
    
  if(!vertexCandidates.get() ) {
    out<<"vertexCandidates already transfered"<<endl;
  }
  else {
    out<<"number of vertexCandidates : "<<vertexCandidates->size()<<endl;
    out<<endl;
 
    
    for(PFDisplacedVertexCandidateFinder::IBC ib=vertexCandidates->begin(); 
        ib != vertexCandidates->end(); ib++)
      ib->Dump();


    
  }
 
  return out;
}

Member Data Documentation

----- Algo parameters for the vertex finder ---- ///

Distance of minimal approach below which two tracks are considered as linked together

Definition at line 138 of file PFDisplacedVertexCandidateFinder.h.

Referenced by setParameters().

Maximum distance between the DCA Point and the inner hit of the track.

Definition at line 142 of file PFDisplacedVertexCandidateFinder.h.

Referenced by setParameters().

Definition at line 151 of file PFDisplacedVertexCandidateFinder.h.

Referenced by goodPtResolution(), operator<<(), and setParameters().

The Trajectories vector allow to calculate snd to store only once the track trajectory parameters

Definition at line 132 of file PFDisplacedVertexCandidateFinder.h.

Referenced by setInput().

Definition at line 166 of file PFDisplacedVertexCandidateFinder.h.

Referenced by setInput().

Tracks preselection to reduce the combinatorics in PFDisplacedVertexCandidates this cuts are repeated then in a smarter way in the PFDisplacedVertexFinder be sure you are consistent between them

Definition at line 147 of file PFDisplacedVertexCandidateFinder.h.

Referenced by goodPtResolution(), operator<<(), and setParameters().

Do not reconstruct vertices wich are too close to the beam pipe.

Definition at line 140 of file PFDisplacedVertexCandidateFinder.h.

Referenced by setParameters().

Definition at line 148 of file PFDisplacedVertexCandidateFinder.h.

Referenced by goodPtResolution(), operator<<(), and setParameters().

Definition at line 150 of file PFDisplacedVertexCandidateFinder.h.

Referenced by goodPtResolution(), operator<<(), and setParameters().

The trackMask allows to keep the information on the tracks which are still free and those which are already used or disabled.

Definition at line 129 of file PFDisplacedVertexCandidateFinder.h.

Referenced by associate(), and setInput().

-------- Members -------- ///

Definition at line 119 of file PFDisplacedVertexCandidateFinder.h.

Referenced by findDisplacedVertexCandidates(), transferVertexCandidates(), and vertexCandidates().

Max number of expected vertexCandidates in the event Used to allocate the memory and avoid multiple copy

Definition at line 155 of file PFDisplacedVertexCandidateFinder.h.

Referenced by findDisplacedVertexCandidates().