CMS 3D CMS Logo

Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes

PFDisplacedVertexHelper Class Reference

Displaced Vertex Finder Algorithm. More...

#include <PFDisplacedVertexHelper.h>

List of all members.

Classes

struct  TracksSelector
 Tool which store the information for the tracks selection. More...
struct  VertexIdentifier
 Tool which store the information for the vertex identification. More...

Public Member Functions

void Dump (std::ostream &out=std::cout) const
reco::PFDisplacedVertex::VertexType identifyVertex (const reco::PFDisplacedVertex &v) const
 Vertex identification tool.
bool isTrackSelected (const reco::Track &trk, const reco::PFDisplacedVertex::VertexTrackType vertexTrackType) const
 Select tracks tool.
 PFDisplacedVertexHelper ()
math::XYZPoint primaryVertex () const
 Set Vertex direction using the primary vertex.
void setPrimaryVertex (edm::Handle< reco::VertexCollection > mainVertexHandle, edm::Handle< reco::BeamSpot > beamSpotHandle)
 Update the primary vertex information.
void setTracksSelector (const edm::ParameterSet &ps)
 Set Tracks selector parameters.
void setVertexIdentifier (const edm::ParameterSet &ps)
 Set Vertex identifier parameters.
 ~PFDisplacedVertexHelper ()

Private Member Functions

bool isKaonMass (const reco::PFDisplacedVertex &v) const
int lambdaCP (const reco::PFDisplacedVertex &v) const
 Tools used to calculate quantities for vertex identification.

Private Attributes

math::XYZPoint pvtx_
 Primary vertex information updated for each event.
TracksSelector tracksSelector_
VertexIdentifier vertexIdentifier_

Static Private Attributes

static const double muon_mass2 = 0.106*0.106
static const double pion_mass2 = 0.0194
 Masses2 taken from PDG.
static const double proton_mass2 = 0.938*0.938

Detailed Description

Displaced Vertex Finder Algorithm.

Author:
Maxime Gouzevitch
Date:
October 2009

Definition at line 17 of file PFDisplacedVertexHelper.h.


Constructor & Destructor Documentation

PFDisplacedVertexHelper::PFDisplacedVertexHelper ( )

Definition at line 19 of file PFDisplacedVertexHelper.cc.

PFDisplacedVertexHelper::~PFDisplacedVertexHelper ( )

Definition at line 24 of file PFDisplacedVertexHelper.cc.

{}

Member Function Documentation

void PFDisplacedVertexHelper::Dump ( std::ostream &  out = std::cout) const
reco::PFDisplacedVertex::VertexType PFDisplacedVertexHelper::identifyVertex ( const reco::PFDisplacedVertex v) const

Vertex identification tool.

Definition at line 94 of file PFDisplacedVertexHelper.cc.

References reco::PFDisplacedVertex::angle_io(), PFDisplacedVertexHelper::VertexIdentifier::angle_max(), PFDisplacedVertexHelper::VertexIdentifier::angle_V0Conv_max(), cscdqm::ANY, alignmentValidation::c1, DeDxDiscriminatorTools::charge(), sistrip::FAKE, PFDisplacedVertexHelper::VertexIdentifier::identifyVertices(), isKaonMass(), reco::PFDisplacedVertex::isThereMergedTracks(), reco::PFDisplacedVertex::isTherePrimaryTracks(), lambdaCP(), PFDisplacedVertexHelper::VertexIdentifier::logPrimSec_min(), PFDisplacedVertexHelper::VertexIdentifier::looper_eta_max(), PFDisplacedVertexHelper::VertexIdentifier::mConv_max(), PFDisplacedVertexHelper::VertexIdentifier::mK0_max(), PFDisplacedVertexHelper::VertexIdentifier::mK0_min(), PFDisplacedVertexHelper::VertexIdentifier::mNucl_min(), reco::PFDisplacedVertex::nSecondaryTracks(), reco::PFDisplacedVertex::nTracks(), reco::Vertex::originalTrack(), reco::Vertex::position(), reco::PFDisplacedVertex::primaryMomentum(), PFDisplacedVertexHelper::VertexIdentifier::pt_kink_min(), PFDisplacedVertexHelper::VertexIdentifier::pt_min(), reco::Vertex::refittedTracks(), reco::PFDisplacedVertex::secondaryMomentum(), and vertexIdentifier_.

Referenced by PFDisplacedVertexFinder::rejectAndLabelVertex().

                                                                           {

  if (!vertexIdentifier_.identifyVertices()) return PFDisplacedVertex::ANY;

  PFDisplacedVertex::M_Hypo massElec = PFDisplacedVertex::M_MASSLESS;
  PFDisplacedVertex::M_Hypo massPion = PFDisplacedVertex::M_PION;

  math::XYZTLorentzVector mom_ee = v.secondaryMomentum(massElec, true);
  math::XYZTLorentzVector mom_pipi = v.secondaryMomentum(massPion, true);

  // ===== (1) Identify fake and looper vertices ===== //

  double ang = v.angle_io();
  double pt_ee = mom_ee.Pt();
  double eta_vtx = v.position().eta();

  //cout << "Angle = " << ang << endl;

  bool bDirectionFake = ang > vertexIdentifier_.angle_max();
  bool bLowPt = pt_ee < vertexIdentifier_.pt_min();
  bool bLooperEta = fabs(eta_vtx) < vertexIdentifier_.looper_eta_max();

  bool isFake = bDirectionFake ||(bLowPt && !bLooperEta); 
  bool isLooper = !bDirectionFake && bLowPt && bLooperEta;

  if (isFake) return  PFDisplacedVertex::FAKE;
  if (isLooper) return PFDisplacedVertex::LOOPER;

  // ===== (2) Identify Decays and Conversions ===== //

  int c1 = v.originalTrack(v.refittedTracks()[0])->charge();
  int c2 = v.originalTrack(v.refittedTracks()[1])->charge();
  double mass_ee = mom_ee.M();

  int nTracks = v.nTracks();
  int nSecondaryTracks = v.nSecondaryTracks();
  bool bPrimaryTracks = v.isTherePrimaryTracks();
  bool bMergedTracks = v.isThereMergedTracks();

  bool bPair = (nTracks == nSecondaryTracks) && (nTracks == 2);
  bool bOpposite = (c1*c2 < -0.1);
  bool bDirection = ang < vertexIdentifier_.angle_V0Conv_max();
  bool bConvMass = mass_ee < vertexIdentifier_.mConv_max();

  bool bV0Conv = bPair && bOpposite && bDirection;

  // If the basic configuration of conversions and V0 decays is respected
  // pair of secondary track with opposite charge and going in the right direction
  // the selection is then based on mass limits
  if (bV0Conv){

    // == (2.1) Identify Conversions == //

    bool isConv = bConvMass;

    if (isConv) return PFDisplacedVertex::CONVERSION_LOOSE;
 
    // == (2.2) Identify K0 == //

    double mass_pipi = mom_pipi.M();

    bool bK0Mass = 
      mass_pipi < vertexIdentifier_.mK0_max() 
      &&  mass_pipi > vertexIdentifier_.mK0_min();

    bool isK0 =  bK0Mass;

    if (isK0) return PFDisplacedVertex::K0_DECAY;

    // == (2.3) Identify Lambda == //

    int lambdaKind = lambdaCP(v); 
    

    bool isLambda = (lambdaKind == 1);
    bool isLambdaBar = (lambdaKind == -1);

    if (isLambda) return PFDisplacedVertex::LAMBDA_DECAY;
    if (isLambdaBar) return PFDisplacedVertex::LAMBDABAR_DECAY;

  }

  // == (2.4) Identify K- and K+ ==
  bool bK = 
    (nSecondaryTracks == 1) && bPrimaryTracks && !bMergedTracks
    && !bOpposite;

  if(bK){

    bool bKMass = isKaonMass(v);
 
    bool isKPlus = bKMass && c1 > 0;
    bool isKMinus = bKMass && c1 < 0;

    if(isKMinus) return PFDisplacedVertex::KMINUS_DECAY_LOOSE;
    if(isKPlus) return PFDisplacedVertex::KPLUS_DECAY_LOOSE;

  }

  // ===== (3) Identify Nuclears, Kinks and Remaining Fakes ===== //

  math::XYZTLorentzVector mom_prim = v.primaryMomentum(massPion, true);
  
  double p_prim = mom_prim.P();
  double p_sec = mom_pipi.P();
  double pt_prim = mom_prim.Pt();
  
  bool bLog = false;
  if (p_prim > 0.05 && p_sec > 0.05)  bLog = log10(p_prim/p_sec) > vertexIdentifier_.logPrimSec_min();
  bool bPtMin = pt_prim >  vertexIdentifier_.pt_kink_min();

  // A vertex with at least 3 tracks is considered as high purity nuclear interaction
  // the only exception is K- decay into 3 prongs. To be studied.
  bool isNuclearHighPurity = nTracks > 2 && mass_ee > vertexIdentifier_.mNucl_min(); 
  bool isFakeHighPurity = nTracks > 2 && mass_ee < vertexIdentifier_.mNucl_min();
  // Two secondary tracks with some minimal tracks angular opening are still accepted
  // as nuclear interactions
  bool isNuclearLowPurity = 
    (nTracks == nSecondaryTracks)
    && (nTracks == 2)
    && mass_ee > vertexIdentifier_.mNucl_min();

  bool isFakeNucl = 
    (nTracks == nSecondaryTracks)
    && (nTracks == 2)
    && mass_ee < vertexIdentifier_.mNucl_min();

  // Kinks: 1 primary + 1 secondary is accepted only if the primary tracks 
  // has more energy than the secondary and primary have some minimal pT 
  // to produce a nuclear interaction
  bool isNuclearKink = 
    (nSecondaryTracks == 1) && bPrimaryTracks && !bMergedTracks 
    && bLog && bPtMin;

  // Here some loopers may hide appearing in Particle Isolation plots. To be studied...
  bool isFakeKink = 
    ( (nSecondaryTracks == 1) && bMergedTracks && !bPrimaryTracks )
    ||
    ( (nSecondaryTracks == 1) && bPrimaryTracks && !bMergedTracks 
    && (!bLog || !bPtMin) );

  if (isNuclearHighPurity) return PFDisplacedVertex::NUCL;
  if (isNuclearLowPurity) return PFDisplacedVertex::NUCL_LOOSE;
  if (isFakeKink || isFakeNucl || isFakeHighPurity) return  PFDisplacedVertex::FAKE;
  if (isNuclearKink)  return  PFDisplacedVertex::NUCL_KINK;
  

  return PFDisplacedVertex::ANY;

}
bool PFDisplacedVertexHelper::isKaonMass ( const reco::PFDisplacedVertex v) const [private]

Definition at line 333 of file PFDisplacedVertexHelper.cc.

References PFDisplacedVertexHelper::VertexIdentifier::mK_max(), PFDisplacedVertexHelper::VertexIdentifier::mK_min(), muon_mass2, reco::Vertex::refittedTracks(), mathSSE::sqrt(), reco::PFDisplacedVertex::trackTypes(), and vertexIdentifier_.

Referenced by identifyVertex().

                                                                         {

  math::XYZVector  trkInit = v.refittedTracks()[1].momentum(), 
    trkFinal = v.refittedTracks()[0].momentum();

  if (v.trackTypes()[0] == PFDisplacedVertex::T_TO_VERTEX)
    trkInit = v.refittedTracks()[0].momentum(),
      trkFinal =  v.refittedTracks()[1].momentum();


    math::XYZVector trkNeutre(trkInit.x()-trkFinal.x(),  trkInit.y()-trkFinal.y(),
                          trkInit.z()-trkFinal.z());

    double Ec = sqrt(muon_mass2 + trkFinal.Mag2());
    double En = sqrt(0*0        + trkNeutre.Mag2());



    math::XYZTLorentzVectorD trkMuNu(trkInit.x(), trkInit.y(), trkInit.z(), Ec+En);
    double massMuNu = trkMuNu.M();

    bool bKMass = 
      massMuNu > vertexIdentifier_.mK_min() 
      && massMuNu < vertexIdentifier_.mK_max(); 

    return bKMass; 

}
bool PFDisplacedVertexHelper::isTrackSelected ( const reco::Track trk,
const reco::PFDisplacedVertex::VertexTrackType  vertexTrackType 
) const

Select tracks tool.

Definition at line 45 of file PFDisplacedVertexHelper.cc.

References reco::TrackBase::dxy(), PFDisplacedVertexHelper::TracksSelector::dxy_min(), PFDisplacedVertexHelper::TracksSelector::nChi2_max(), PFDisplacedVertexHelper::TracksSelector::nChi2_min(), PFDisplacedVertexHelper::TracksSelector::nHits_min(), reco::TrackBase::normalizedChi2(), PFDisplacedVertexHelper::TracksSelector::nOuterHits_max(), reco::HitPattern::numberOfHits(), reco::TrackBase::numberOfValidHits(), reco::TrackBase::pt(), PFDisplacedVertexHelper::TracksSelector::pt_min(), pvtx_, reco::TrackBase::quality(), PFDisplacedVertexHelper::TracksSelector::quality(), reco::TrackBase::qualityByName(), PFDisplacedVertexHelper::TracksSelector::selectTracks(), reco::PFDisplacedVertex::T_MERGED, reco::PFDisplacedVertex::T_TO_VERTEX, reco::TrackBase::trackerExpectedHitsOuter(), and tracksSelector_.

Referenced by PFDisplacedVertexFinder::fitVertexFromSeed().

                                                                                                           {
    

  if (!tracksSelector_.selectTracks()) return true;

  bool isGoodTrack = false;
    
  bool isHighPurity = trk.quality( trk.qualityByName(tracksSelector_.quality().data()) );
        
  double nChi2  = trk.normalizedChi2(); 
  double pt = trk.pt();
  int nHits = trk.numberOfValidHits();

  bool bIsPrimary = 
    (
     (vertexTrackType == reco::PFDisplacedVertex::T_TO_VERTEX)
     ||
     (vertexTrackType == reco::PFDisplacedVertex::T_MERGED)
     );  
    
  
  if (bIsPrimary) {
    // Primary or merged track selection
    isGoodTrack = 
      ( ( nChi2 > tracksSelector_.nChi2_min()
          && nChi2 <  tracksSelector_.nChi2_max())
        || isHighPurity )
      && pt >  tracksSelector_.pt_min();
  } else {
    // Secondary tracks selection
    int nOuterHits = trk.trackerExpectedHitsOuter().numberOfHits();

    double dxy = trk.dxy(pvtx_);
      
    isGoodTrack =   
      nChi2 <  tracksSelector_.nChi2_max() 
      && pt >  tracksSelector_.pt_min() 
      && fabs(dxy) >  tracksSelector_.dxy_min() 
      && nHits >=  tracksSelector_.nHits_min() 
      && nOuterHits <=  tracksSelector_.nOuterHits_max();
      
  }
    
  return isGoodTrack;
      
}
int PFDisplacedVertexHelper::lambdaCP ( const reco::PFDisplacedVertex v) const [private]

Tools used to calculate quantities for vertex identification.

Definition at line 246 of file PFDisplacedVertexHelper.cc.

References alignmentValidation::c1, DeDxDiscriminatorTools::charge(), PFDisplacedVertexHelper::VertexIdentifier::mLambda_max(), PFDisplacedVertexHelper::VertexIdentifier::mLambda_min(), reco::Vertex::originalTrack(), reco::TrackBase::p(), pion_mass2, proton_mass2, reco::TrackBase::px(), reco::TrackBase::py(), reco::TrackBase::pz(), reco::Vertex::refittedTracks(), mathSSE::sqrt(), and vertexIdentifier_.

Referenced by identifyVertex().

                                                                      {

  int lambdaCP = 0;

  vector <Track> refittedTracks = v.refittedTracks();

  math::XYZTLorentzVector totalMomentumDcaRefit_lambda;
  math::XYZTLorentzVector totalMomentumDcaRefit_lambdabar;


  reco::Track tMomentumDcaRefit_0 = refittedTracks[0];
  reco::Track tMomentumDcaRefit_1 = refittedTracks[1];

  double mass2_0 = 0, mass2_1 = 0;

  int c1 = v.originalTrack(v.refittedTracks()[1])->charge();

  // --------------------------- lambda --------------------


  if (c1 > 0.1) mass2_0 = pion_mass2, mass2_1 = proton_mass2;
  else mass2_0 = proton_mass2, mass2_1 = pion_mass2;
      
  double E = sqrt(tMomentumDcaRefit_0.p()*tMomentumDcaRefit_0.p() + mass2_0);

  math::XYZTLorentzVector momentumDcaRefit_0(tMomentumDcaRefit_0.px(), tMomentumDcaRefit_0.py(), 
                                    tMomentumDcaRefit_0.pz(), E); 



  E = sqrt(tMomentumDcaRefit_1.p()*tMomentumDcaRefit_1.p() + mass2_1);

  math::XYZTLorentzVector momentumDcaRefit_1(tMomentumDcaRefit_1.px(), tMomentumDcaRefit_1.py(), 
                                    tMomentumDcaRefit_1.pz(), E); 


  totalMomentumDcaRefit_lambda = momentumDcaRefit_0 + momentumDcaRefit_1;



  // --------------------------- anti - lambda --------------------

  if (c1 > 0.1) mass2_1 = pion_mass2, mass2_0 = proton_mass2;
  else mass2_1 = proton_mass2, mass2_0 = pion_mass2;
  
      
  E = sqrt(tMomentumDcaRefit_0.p()*tMomentumDcaRefit_0.p() + mass2_0);

  math::XYZTLorentzVector momentumDcaRefit_01(tMomentumDcaRefit_0.px(), tMomentumDcaRefit_0.py(), 
                                    tMomentumDcaRefit_0.pz(), E); 



  E = sqrt(tMomentumDcaRefit_1.p()*tMomentumDcaRefit_1.p() + mass2_1);

  math::XYZTLorentzVector momentumDcaRefit_11(tMomentumDcaRefit_1.px(), tMomentumDcaRefit_1.py(), 
                                    tMomentumDcaRefit_1.pz(), E); 


  totalMomentumDcaRefit_lambdabar = momentumDcaRefit_01 + momentumDcaRefit_11;

  double mass_l    = totalMomentumDcaRefit_lambda.M();
  double mass_lbar = totalMomentumDcaRefit_lambdabar.M();

  //  cout << "mass_l = " << mass_l << " mass_lbar = " <<  mass_lbar << endl;


  if (
      mass_l < mass_lbar 
      && mass_l > vertexIdentifier_.mLambda_min()
      && mass_l < vertexIdentifier_.mLambda_max()) 
    lambdaCP = 1;
  else if (mass_lbar < mass_l 
           && mass_lbar > vertexIdentifier_.mLambda_min()
           && mass_lbar < vertexIdentifier_.mLambda_max()) 
    lambdaCP = -1;
  else 
    lambdaCP = 0;

  //cout << "lambdaCP = " << lambdaCP << endl;

  return lambdaCP;

}
math::XYZPoint PFDisplacedVertexHelper::primaryVertex ( ) const [inline]

Set Vertex direction using the primary vertex.

Definition at line 47 of file PFDisplacedVertexHelper.h.

References pvtx_.

Referenced by PFDisplacedVertexFinder::fitVertexFromSeed().

{ return pvtx_;}
void PFDisplacedVertexHelper::setPrimaryVertex ( edm::Handle< reco::VertexCollection mainVertexHandle,
edm::Handle< reco::BeamSpot beamSpotHandle 
)

Update the primary vertex information.

Definition at line 26 of file PFDisplacedVertexHelper.cc.

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

Referenced by PFDisplacedVertexFinder::setPrimaryVertex().

                                                                                        {

  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;
}
void PFDisplacedVertexHelper::setTracksSelector ( const edm::ParameterSet ps) [inline]

Set Tracks selector parameters.

Definition at line 25 of file PFDisplacedVertexHelper.h.

References tracksSelector_.

Referenced by PFDisplacedVertexFinder::setTracksSelector().

                                                   {
    tracksSelector_ = TracksSelector(ps);
  };
void PFDisplacedVertexHelper::setVertexIdentifier ( const edm::ParameterSet ps) [inline]

Set Vertex identifier parameters.

Definition at line 30 of file PFDisplacedVertexHelper.h.

References vertexIdentifier_.

Referenced by PFDisplacedVertexFinder::setVertexIdentifier().

                                                     {
    vertexIdentifier_ = VertexIdentifier(ps);
  };

Member Data Documentation

const double PFDisplacedVertexHelper::muon_mass2 = 0.106*0.106 [static, private]

Definition at line 207 of file PFDisplacedVertexHelper.h.

Referenced by isKaonMass().

const double PFDisplacedVertexHelper::pion_mass2 = 0.0194 [static, private]

Masses2 taken from PDG.

Definition at line 206 of file PFDisplacedVertexHelper.h.

Referenced by lambdaCP().

const double PFDisplacedVertexHelper::proton_mass2 = 0.938*0.938 [static, private]

Definition at line 208 of file PFDisplacedVertexHelper.h.

Referenced by lambdaCP().

Primary vertex information updated for each event.

Definition at line 203 of file PFDisplacedVertexHelper.h.

Referenced by Dump(), isTrackSelected(), primaryVertex(), and setPrimaryVertex().

Definition at line 200 of file PFDisplacedVertexHelper.h.

Referenced by Dump(), isTrackSelected(), and setTracksSelector().