CMS 3D CMS Logo

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

VertexFitterResult Class Reference

#include <VertexFitterResult.h>

List of all members.

Public Types

typedef std::vector
< reco::TransientTrack
TTrackCont

Public Member Functions

const float * chi2Information () const
void fill (const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0)
void fill (const TransientVertex &recVertex, const TTrackCont &recTrackV, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0)
const int * numberRecTracks ()
const int * numberSimTracks ()
const float * recErrors (const int i) const
const float * recParameters (const int i) const
const int * recTrack_simIndex ()
const float * recTrackWeight ()
const float * recVertexErr () const
const float * recVertexPos () const
const float * refErrors (const int i) const
const float * refParameters (const int i) const
void reset ()
const float * simParameters (const int i) const
const int * simTrack_recIndex ()
const float * simVertexPos () const
const float * time () const
const int * trackInformation () const
 VertexFitterResult (const int maxTracks=100, TrackAssociatorByChi2 *associator=0)
const int * vertexPresent () const
 ~VertexFitterResult ()

Private Member Functions

void fillErrors (const PerigeeTrajectoryError &pte, float *errors[5], int trackNumber)
void fillParameters (const reco::TrackBase::ParameterVector &perigee, float *params[5], int trackNumber)
void fillParameters (const PerigeeTrajectoryParameters &ptp, float *params[5], int trackNumber)

Private Attributes

TrackAssociatorByChi2associatorForParamAtPca
float chi [3]
float fitTime
int numberOfRecTracks
int numberOfSimTracks
float recErr [3]
float * recErrs [5]
int * recIndex
float * recPars [5]
float recPos [3]
float * refErrs [5]
float * refPars [5]
int * simIndex
float * simPars [5]
float simPos [3]
int theMaxTracks
int tracks [3]
float * trackWeight
int vertex

Detailed Description

Very basic class containing only the positions of the simulated and reconstructed vertices, total chi**2, chi**2 probability and number of degrees of freedom. The only thing to be done is to call the method fill for each vertex.

Definition at line 24 of file VertexFitterResult.h.


Member Typedef Documentation

Definition at line 28 of file VertexFitterResult.h.


Constructor & Destructor Documentation

VertexFitterResult::VertexFitterResult ( const int  maxTracks = 100,
TrackAssociatorByChi2 associator = 0 
)

Definition at line 9 of file VertexFitterResult.cc.

References associatorForParamAtPca, i, numberOfRecTracks, numberOfSimTracks, recErrs, recIndex, recPars, refErrs, refPars, reset(), simIndex, simPars, theMaxTracks, and trackWeight.

        : associatorForParamAtPca(associator)
{
  theMaxTracks = maxTracks;
  if (associatorForParamAtPca==0) theMaxTracks=0;
  for ( int i=0; i<5; i++ ) {
    if ( maxTracks>0 ) {
      simPars[i] = new float[maxTracks];
      recPars[i] = new float[maxTracks];
      refPars[i] = new float[maxTracks];
      recErrs[i] = new float[maxTracks];
      refErrs[i] = new float[maxTracks];
    }
    else {
      simPars[i] = 0;
      recPars[i] = 0;
      refPars[i] = 0;
      recErrs[i] = 0;
      refErrs[i] = 0;
    }
  }
  trackWeight = new float[maxTracks];
  simIndex = new int[maxTracks];
  recIndex = new int[maxTracks];
  numberOfRecTracks=theMaxTracks;
  numberOfSimTracks=theMaxTracks;
  reset();
}
VertexFitterResult::~VertexFitterResult ( )

Definition at line 38 of file VertexFitterResult.cc.

References i, recErrs, recIndex, recPars, refErrs, refPars, simIndex, simPars, and trackWeight.

{
    //
    // delete arrays
    //
    for ( int i=0; i<5; i++ ) {
      delete [] simPars[i];
      delete [] recPars[i];
      delete [] refPars[i];
      delete [] recErrs[i];
      delete [] refErrs[i];
    }
    delete trackWeight;
    delete simIndex;
    delete recIndex;
}

Member Function Documentation

const float* VertexFitterResult::chi2Information ( ) const [inline]

Definition at line 46 of file VertexFitterResult.h.

References chi.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return chi;}
void VertexFitterResult::fill ( const TransientVertex recVertex,
const TTrackCont recTrackV,
const TrackingVertex simv = 0,
reco::RecoToSimCollection recSimColl = 0,
const float &  time = 0 
)

Definition at line 64 of file VertexFitterResult.cc.

References associatorForParamAtPca, edm::RefVector< C, T, F >::begin(), chi, ChiSquaredProbability(), GlobalErrorBase< T, ErrorWeightType >::cxx(), GlobalErrorBase< T, ErrorWeightType >::cyy(), GlobalErrorBase< T, ErrorWeightType >::czz(), TrackingVertex::daughterTracks(), TrackingVertex::daughterTracks_begin(), TrackingVertex::daughterTracks_end(), TransientVertex::degreesOfFreedom(), ExpressReco_HICollisions_FallBack::e, edm::RefVector< C, T, F >::end(), fillErrors(), fillParameters(), spr::find(), fitTime, TransientVertex::isValid(), numberOfRecTracks, numberOfSimTracks, TransientVertex::originalTracks(), TrackAssociatorByChi2::parametersAtClosestApproach(), TrajectoryStateClosestToPoint::perigeeError(), TrackingVertex::position(), TransientVertex::position(), TransientVertex::positionError(), recErr, recErrs, recIndex, recPars, recPos, simIndex, simPars, simPos, mathSSE::sqrt(), theMaxTracks, time(), TransientVertex::totalChiSquared(), reco::TrackTransientTrack::trackBaseRef(), tracks, vertex, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{
  TrackingParticleRefVector simTrackV;

  Basic3DVector<double> vert;
  if (recVertex.isValid()) {
    recPos[0] = recVertex.position().x();
    recPos[1] = recVertex.position().y();
    recPos[2] = recVertex.position().z();

    recErr[0] = sqrt(recVertex.positionError().cxx());
    recErr[1] = sqrt(recVertex.positionError().cyy());
    recErr[2] = sqrt(recVertex.positionError().czz());
    vert = (Basic3DVector<double>) recVertex.position();

    chi[0] = recVertex.totalChiSquared();
    chi[1] = recVertex.degreesOfFreedom();
    chi[2] = ChiSquaredProbability(recVertex.totalChiSquared(), 
                                           recVertex.degreesOfFreedom());
    vertex = 2;
    fitTime = time;
    tracks[1] = recVertex.originalTracks().size();
  }

  if (simv!=0) {
    simPos[0] = simv->position().x();
    simPos[1] = simv->position().y();
    simPos[2] = simv->position().z();

    simTrackV = simv->daughterTracks();
    vertex += 1;
    for(TrackingVertex::tp_iterator simTrack = simv->daughterTracks_begin();
                 (simTrack != simv->daughterTracks_end() && (numberOfSimTracks<theMaxTracks));
                 simTrack++) {
      
      Basic3DVector<double> momAtVtx((**simTrack).momentum());

      std::pair<bool, reco::TrackBase::ParameterVector> paramPair =
        associatorForParamAtPca->parametersAtClosestApproach(vert, momAtVtx, 
          (float) (**simTrack).charge(), recTrackV.front().stateAtBeamLine().beamSpot());
        if (paramPair.first) {
          fillParameters(paramPair.second, simPars, numberOfSimTracks);
          simIndex[numberOfSimTracks] = -1;
          ++numberOfSimTracks;
        }
    }
    tracks[0] = numberOfSimTracks;
  }


  // now store all the recTrack...  

  for(TTrackCont::const_iterator recTrack =recTrackV.begin();
               (recTrack != recTrackV.end() 
                && (numberOfRecTracks<theMaxTracks));
               recTrack++) {
    //    std::cout << "Input; 1/Pt " << 1./(*recTrack).momentumAtVertex().transverse() << std::endl;

    //looking for sim tracks corresponding to our reconstructed tracks:  
    simIndex[numberOfRecTracks] = -1;

    std::vector<std::pair<TrackingParticleRef, double> > simFound;
    try {
      const TrackTransientTrack* ttt = dynamic_cast<const TrackTransientTrack*>(recTrack->basicTransientTrack());
      if ((ttt!=0) && (recSimColl!=0)) simFound = (*recSimColl)[ttt->trackBaseRef()];
//       if (recSimColl!=0) simFound = (*recSimColl)[recTrack->persistentTrackRef()];
//      if (recSimColl!=0) simFound = (*recSimColl)[recTrack];

    } catch (cms::Exception e) {
//       LogDebug("TrackValidator") << "reco::Track #" << rT << " with pt=" << track->pt() 
//                               << " NOT associated to any TrackingParticle" << "\n";
//       edm::LogError("TrackValidator") << e.what() << "\n";
    }

    if(simFound.size() != 0) {
      //OK, it was associated, so get the state on the same surface as the 'SimState'
      TrackingParticleRefVector::const_iterator simTrackI = 
        find(simTrackV.begin(), simTrackV.end(), simFound[0].first);
      if (simTrackI!=simTrackV.end()) ++tracks[2];
      int simTrackIndex = simTrackI-simTrackV.begin();
      if (simTrackIndex<numberOfSimTracks) {
        simIndex[numberOfRecTracks] = simTrackIndex;
        recIndex[simTrackIndex] = numberOfRecTracks;
        //      cout << "Assoc; 1/Pt " << 1./(*recTrack).momentumAtVertex().transverse() << std::endl;
      }
    }

    TrajectoryStateClosestToPoint tscp = recTrack->trajectoryStateClosestToPoint(recVertex.position());
    fillParameters(recTrack->track().parameters(), recPars, numberOfRecTracks);
    fillErrors(tscp.perigeeError(), recErrs, numberOfRecTracks);
//     trackWeight[numberOfRecTracks] = recVertex.trackWeight(*recTrack);
// 
//     if ((recVertex.isValid())&&(recVertex.hasRefittedTracks())) {
//       //looking for corresponding refitted tracks:
//       TrajectoryStateOnSurface refip;
//       RecTrackCont::iterator refTrackI = 
//                      find_if(refTracks.begin(), refTracks.end(), RecTrackMatch(*recTrack));
//       if (refTrackI!=refTracks.end()) {
//         // If it was not found, it would mean that it was not used in the fit,
//      // or with a low weight such that the track was then discarded.
//      if(simFound.size() != 0) {
//        refip = refTrackI->stateOnSurface(simFound[0]->impactPointStateOnSurface().surface());
//      } else {
//           refip = refTrackI->innermostState();
//      }
// 
//      fillParameters(refip, refPars, numberOfRecTracks);
//      fillErrors(refip, refErrs, numberOfRecTracks);
//       }
//     }
// 
    ++numberOfRecTracks;
  }
  
}
void VertexFitterResult::fill ( const TransientVertex recv,
const TrackingVertex simv = 0,
reco::RecoToSimCollection recSimColl = 0,
const float &  time = 0 
)

Definition at line 55 of file VertexFitterResult.cc.

References TransientVertex::isValid(), and TransientVertex::originalTracks().

Referenced by SimpleVertexTree::fill().

{
  TTrackCont recTrackV;
  if (recVertex.isValid()) recTrackV = recVertex.originalTracks();
  fill(recVertex, recTrackV, simv, recSimColl, time);
}
void VertexFitterResult::fillErrors ( const PerigeeTrajectoryError pte,
float *  errors[5],
int  trackNumber 
) [private]
void VertexFitterResult::fillParameters ( const PerigeeTrajectoryParameters ptp,
float *  params[5],
int  trackNumber 
) [private]

Definition at line 192 of file VertexFitterResult.cc.

References PerigeeTrajectoryParameters::vector_old().

{
  const AlgebraicVector & perigee = ptp.vector_old();
  params[0][trackNumber] = perigee[0];
  params[1][trackNumber] = perigee[1];
  params[2][trackNumber] = perigee[2];
  params[3][trackNumber] = perigee[3];
  params[4][trackNumber] = perigee[4];
}
void VertexFitterResult::fillParameters ( const reco::TrackBase::ParameterVector perigee,
float *  params[5],
int  trackNumber 
) [private]

Definition at line 182 of file VertexFitterResult.cc.

Referenced by fill().

{
  params[0][trackNumber] = perigee[0];
  params[1][trackNumber] = perigee[1];
  params[2][trackNumber] = perigee[2];
  params[3][trackNumber] = perigee[3];
  params[4][trackNumber] = perigee[4];
}
const int* VertexFitterResult::numberRecTracks ( ) [inline]

Definition at line 51 of file VertexFitterResult.h.

References numberOfRecTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return &numberOfRecTracks;}
const int* VertexFitterResult::numberSimTracks ( ) [inline]

Definition at line 50 of file VertexFitterResult.h.

References numberOfSimTracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return &numberOfSimTracks;}
const float* VertexFitterResult::recErrors ( const int  i) const [inline]

Definition at line 72 of file VertexFitterResult.h.

References i, and recErrs.

Referenced by SimpleVertexTree::SimpleVertexTree().

  {
    if ( i<0 || i>=5 )  return 0;
    return recErrs[i];
  }
const float* VertexFitterResult::recParameters ( const int  i) const [inline]

Definition at line 57 of file VertexFitterResult.h.

References i, and recPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

  {
    if ( i<0 || i>=5 )  return 0;
    return recPars[i];
  }
const int* VertexFitterResult::recTrack_simIndex ( ) [inline]

Definition at line 55 of file VertexFitterResult.h.

References simIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return simIndex;}
const float* VertexFitterResult::recTrackWeight ( ) [inline]

Definition at line 56 of file VertexFitterResult.h.

References trackWeight.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return trackWeight;}
const float* VertexFitterResult::recVertexErr ( ) const [inline]

Definition at line 44 of file VertexFitterResult.h.

References recErr.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return recErr;}
const float* VertexFitterResult::recVertexPos ( ) const [inline]

Definition at line 43 of file VertexFitterResult.h.

References recPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return recPos;}
const float* VertexFitterResult::refErrors ( const int  i) const [inline]

Definition at line 77 of file VertexFitterResult.h.

References i, and refErrs.

Referenced by SimpleVertexTree::SimpleVertexTree().

  {
    if ( i<0 || i>=5 )  return 0;
    return refErrs[i];
  }
const float* VertexFitterResult::refParameters ( const int  i) const [inline]

Definition at line 62 of file VertexFitterResult.h.

References i, and refPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

  {
    if ( i<0 || i>=5 )  return 0;
    return refPars[i];
  }
void VertexFitterResult::reset ( void  )

Definition at line 213 of file VertexFitterResult.cc.

References chi, fitTime, i, j, numberOfRecTracks, numberOfSimTracks, recErr, recErrs, recIndex, recPars, recPos, refErrs, refPars, simIndex, simPars, simPos, tracks, trackWeight, and vertex.

Referenced by SimpleVertexTree::fill(), and VertexFitterResult().

{
  for ( int i=0; i<3; ++i ) {
    simPos[i] = 0.;
    recPos[i] = 0.;
    recErr[i] = 0.;
    chi[i] = 0.;
    tracks[i] = 0;
  }
  vertex =0;
  fitTime = 0;

  for ( int j=0; j<numberOfRecTracks; ++j ) {
    for ( int i=0; i<5; ++i ) {
       recPars[i][j] = 0;
       refPars[i][j] = 0;
       recErrs[i][j] = 0;
       refErrs[i][j] = 0;
    }
    trackWeight[j] = 0;
    simIndex[j] = -1;
  }
  for ( int j=0; j<numberOfSimTracks; ++j ) {
    for ( int i=0; i<5; ++i ) {
       simPars[i][j] = 0;
    }
    recIndex[j] = -1;
  }

  numberOfRecTracks=0;
  numberOfSimTracks=0;
}
const float* VertexFitterResult::simParameters ( const int  i) const [inline]

Definition at line 67 of file VertexFitterResult.h.

References i, and simPars.

Referenced by SimpleVertexTree::SimpleVertexTree().

  {
    if ( i<0 || i>=5 )  return 0;
    return simPars[i];
  }
const int* VertexFitterResult::simTrack_recIndex ( ) [inline]

Definition at line 53 of file VertexFitterResult.h.

References recIndex.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return recIndex;}
const float* VertexFitterResult::simVertexPos ( ) const [inline]

Definition at line 42 of file VertexFitterResult.h.

References simPos.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return simPos;}
const float* VertexFitterResult::time ( ) const [inline]

Definition at line 48 of file VertexFitterResult.h.

References fitTime.

Referenced by fill(), and SimpleVertexTree::SimpleVertexTree().

{return &fitTime;}
const int* VertexFitterResult::trackInformation ( ) const [inline]

Definition at line 45 of file VertexFitterResult.h.

References tracks.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return tracks;}
const int* VertexFitterResult::vertexPresent ( ) const [inline]

Definition at line 47 of file VertexFitterResult.h.

References vertex.

Referenced by SimpleVertexTree::SimpleVertexTree().

{return &vertex;}

Member Data Documentation

Definition at line 114 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

float VertexFitterResult::chi[3] [private]

Definition at line 119 of file VertexFitterResult.h.

Referenced by chi2Information(), fill(), and reset().

float VertexFitterResult::fitTime [private]

Definition at line 122 of file VertexFitterResult.h.

Referenced by fill(), reset(), and time().

Definition at line 130 of file VertexFitterResult.h.

Referenced by fill(), numberRecTracks(), reset(), and VertexFitterResult().

Definition at line 130 of file VertexFitterResult.h.

Referenced by fill(), numberSimTracks(), reset(), and VertexFitterResult().

float VertexFitterResult::recErr[3] [private]

Definition at line 118 of file VertexFitterResult.h.

Referenced by fill(), recVertexErr(), and reset().

float* VertexFitterResult::recErrs[5] [private]

Definition at line 128 of file VertexFitterResult.h.

Referenced by fill(), recErrors(), reset(), VertexFitterResult(), and ~VertexFitterResult().

float* VertexFitterResult::recPars[5] [private]
float VertexFitterResult::recPos[3] [private]

Definition at line 117 of file VertexFitterResult.h.

Referenced by fill(), recVertexPos(), and reset().

float* VertexFitterResult::refErrs[5] [private]

Definition at line 129 of file VertexFitterResult.h.

Referenced by refErrors(), reset(), VertexFitterResult(), and ~VertexFitterResult().

float* VertexFitterResult::refPars[5] [private]
float* VertexFitterResult::simPars[5] [private]
float VertexFitterResult::simPos[3] [private]

Definition at line 116 of file VertexFitterResult.h.

Referenced by fill(), reset(), and simVertexPos().

Definition at line 124 of file VertexFitterResult.h.

Referenced by fill(), and VertexFitterResult().

int VertexFitterResult::tracks[3] [private]

Definition at line 120 of file VertexFitterResult.h.

Referenced by fill(), reset(), and trackInformation().

Definition at line 121 of file VertexFitterResult.h.

Referenced by fill(), reset(), and vertexPresent().