CMS 3D CMS Logo

Public Member Functions | Private Attributes

CSCSegment Class Reference

#include <CSCSegment.h>

Inheritance diagram for CSCSegment:
RecSegment TrackingRecHit

List of all members.

Public Member Functions

double chi2 () const
 Chi2 of the segment fit.
CSCSegmentclone () const
CSCDetId cscDetId () const
 CSCSegment ()
 Default constructor.
 CSCSegment (std::vector< const CSCRecHit2D * > proto_segment, LocalPoint origin, LocalVector direction, AlgebraicSymMatrix errors, double chi2)
 Constructor.
virtual int degreesOfFreedom () const
 Degrees of freedom of the segment fit.
virtual int dimension () const
 Dimension (in parameter space)
const std::vector< CSCSegment > & duplicateSegments () const
bool isME11a_duplicate () const
LocalVector localDirection () const
 Local direction.
LocalError localDirectionError () const
 Error on the local direction.
LocalPoint localPosition () const
LocalError localPositionError () const
int nRecHits () const
AlgebraicVector parameters () const
 Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )
AlgebraicSymMatrix parametersError () const
 Covariance matrix of parameters()
void print () const
virtual AlgebraicMatrix projectionMatrix () const
 The projection matrix relates the trajectory state parameters to the segment parameters().
virtual std::vector< const
TrackingRecHit * > 
recHits () const
 Access to component RecHits (if any)
virtual std::vector
< TrackingRecHit * > 
recHits ()
 Non-const access to component RecHits (if any)
void setDuplicateSegments (std::vector< CSCSegment * > &duplicates)
bool sharesRecHits (const CSCSegment &anotherSegment) const
bool sharesRecHits (const CSCSegment &anotherSegment, CSCRecHit2D::SharedInputType sharesInput) const
const std::vector< CSCRecHit2D > & specificRecHits () const
bool testSharesAllInSpecificRecHits (const std::vector< CSCRecHit2D > &specificRecHits_1, const std::vector< CSCRecHit2D > &specificRecHits_2, CSCRecHit2D::SharedInputType) const
float time () const
virtual ~CSCSegment ()
 Destructor.

Private Attributes

bool aME11a_duplicate
double theChi2
AlgebraicSymMatrix theCovMatrix
std::vector< CSCRecHit2DtheCSCRecHits
std::vector< CSCSegmenttheDuplicateSegments
LocalVector theLocalDirection
LocalPoint theOrigin

Detailed Description

Describes a reconstructed track segment in the 6 layers of a CSC chamber. This is 4-dimensional since it has an origin (x,y) and a direction (x,y) in the local coordinate system of the chamber.

Date:
2011/03/30 16:02:52
Author:
Matteo Sani
Rick Wilkinson
Tim Cox

Definition at line 22 of file CSCSegment.h.


Constructor & Destructor Documentation

CSCSegment::CSCSegment ( ) [inline]

Default constructor.

Definition at line 27 of file CSCSegment.h.

Referenced by clone().

: theChi2(0.), aME11a_duplicate(false) {}
CSCSegment::CSCSegment ( std::vector< const CSCRecHit2D * >  proto_segment,
LocalPoint  origin,
LocalVector  direction,
AlgebraicSymMatrix  errors,
double  chi2 
)

Constructor.

Definition at line 19 of file CSCSegment.cc.

References i, and theCSCRecHits.

                                                                       : 
  RecSegment(buildDetId(proto_segment.front()->cscDetId())),
  theOrigin(origin), 
  theLocalDirection(direction), theCovMatrix(errors), theChi2(chi2), aME11a_duplicate(false) {

  for(unsigned int i=0; i<proto_segment.size(); ++i)
    theCSCRecHits.push_back(*proto_segment[i]);
}
CSCSegment::~CSCSegment ( ) [virtual]

Destructor.

Definition at line 29 of file CSCSegment.cc.

{}

Member Function Documentation

double CSCSegment::chi2 ( ) const [inline, virtual]
CSCSegment* CSCSegment::clone ( void  ) const [inline, virtual]

Implements TrackingRecHit.

Definition at line 37 of file CSCSegment.h.

References CSCSegment().

{ return new CSCSegment(*this); }
CSCDetId CSCSegment::cscDetId ( ) const [inline]

Definition at line 70 of file CSCSegment.h.

References TrackingRecHit::geographicalId().

Referenced by FWCSCSegmentProxyBuilder::build().

{ return  geographicalId(); }
virtual int CSCSegment::degreesOfFreedom ( ) const [inline, virtual]

Degrees of freedom of the segment fit.

Implements RecSegment.

Definition at line 62 of file CSCSegment.h.

References nRecHits().

Referenced by operator<<(), and MuonTrackCSCChamberResidual::setSegmentResidual().

{ return 2*nRecHits() - 4;}      
virtual int CSCSegment::dimension ( ) const [inline, virtual]

Dimension (in parameter space)

Implements RecSegment.

Definition at line 60 of file CSCSegment.h.

{ return 4; }
const std::vector< CSCSegment>& CSCSegment::duplicateSegments ( ) const [inline]

Definition at line 76 of file CSCSegment.h.

References theDuplicateSegments.

Referenced by operator<<().

bool CSCSegment::isME11a_duplicate ( ) const [inline]

Definition at line 74 of file CSCSegment.h.

References theDuplicateSegments.

{ return (theDuplicateSegments.size() > 0 ? true : false); }
LocalVector CSCSegment::localDirection ( ) const [inline, virtual]
LocalError CSCSegment::localDirectionError ( ) const [virtual]

Error on the local direction.

Implements RecSegment.

Definition at line 52 of file CSCSegment.cc.

References theCovMatrix.

Referenced by operator<<(), and CSCSegmentValidation::plotResolution().

                                                 {
  return LocalError(theCovMatrix[0][0], theCovMatrix[0][1], theCovMatrix[1][1]); 
}
LocalPoint CSCSegment::localPosition ( ) const [inline, virtual]
LocalError CSCSegment::localPositionError ( ) const [virtual]

Implements TrackingRecHit.

Definition at line 48 of file CSCSegment.cc.

References theCovMatrix.

Referenced by operator<<(), and CSCSegmentValidation::plotResolution().

                                                {
  return LocalError(theCovMatrix[2][2], theCovMatrix[2][3], theCovMatrix[3][3]);
}
int CSCSegment::nRecHits ( ) const [inline]
AlgebraicVector CSCSegment::parameters ( void  ) const [virtual]

Parameters of the segment, for the track fit in the order (dx/dz, dy/dz, x, y )

Implements TrackingRecHit.

Definition at line 57 of file CSCSegment.cc.

References query::result, theLocalDirection, theOrigin, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by ChamberSegmentUtility::getCSCRHmap(), and StateSegmentMatcher::StateSegmentMatcher().

                                             {
  // For consistency with DT and what we require for the TrackingRecHit interface,
  // the order of the parameters in the returned vector should be (dx/dz, dy/dz, x, z)
  
  AlgebraicVector result(4);

  result[0] = theLocalDirection.x()/theLocalDirection.z();
  result[1] = theLocalDirection.y()/theLocalDirection.z();    
  result[2] = theOrigin.x();
  result[3] = theOrigin.y();

  return result;
}
AlgebraicSymMatrix CSCSegment::parametersError ( ) const [inline, virtual]

Covariance matrix of parameters()

Implements TrackingRecHit.

Definition at line 49 of file CSCSegment.h.

References theCovMatrix.

Referenced by StateSegmentMatcher::StateSegmentMatcher().

{ return theCovMatrix; }
void CSCSegment::print ( void  ) const

Definition at line 185 of file CSCSegment.cc.

References gather_cfg::cout.

                             {
  std::cout << *this << std::endl;
}
AlgebraicMatrix CSCSegment::projectionMatrix ( ) const [virtual]

The projection matrix relates the trajectory state parameters to the segment parameters().

Implements TrackingRecHit.

Definition at line 72 of file CSCSegment.cc.

                                                   {
  static AlgebraicMatrix theProjectionMatrix( 4, 5, 0);
  static bool isInitialized = false;
  if (!isInitialized) {
    theProjectionMatrix[0][1] = 1;
    theProjectionMatrix[1][2] = 1;
    theProjectionMatrix[2][3] = 1;
    theProjectionMatrix[3][4] = 1;
    isInitialized=true;
  }    
  return theProjectionMatrix;
}
std::vector< TrackingRecHit * > CSCSegment::recHits ( ) [virtual]

Non-const access to component RecHits (if any)

Implements TrackingRecHit.

Definition at line 39 of file CSCSegment.cc.

References theCSCRecHits.

                                               {
  
  std::vector<TrackingRecHit*> pointersOfRecHits;
  for (std::vector<CSCRecHit2D>::iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
    pointersOfRecHits.push_back(&(*irh));
  }
  return pointersOfRecHits;
}
std::vector< const TrackingRecHit * > CSCSegment::recHits ( ) const [virtual]

Access to component RecHits (if any)

Implements TrackingRecHit.

Definition at line 31 of file CSCSegment.cc.

References theCSCRecHits.

Referenced by MuonAssociatorByHits::getMatchedIds(), TrackerMuonHitExtractor::getMuonHits(), and MuonTrackProducer::produce().

                                                          {
  std::vector<const TrackingRecHit*> pointersOfRecHits;
  for (std::vector<CSCRecHit2D>::const_iterator irh = theCSCRecHits.begin(); irh!=theCSCRecHits.end(); ++irh) {
    pointersOfRecHits.push_back(&(*irh));
  }
  return pointersOfRecHits;
}
void CSCSegment::setDuplicateSegments ( std::vector< CSCSegment * > &  duplicates)

Definition at line 85 of file CSCSegment.cc.

References i, and theDuplicateSegments.

                                                                        {
  theDuplicateSegments.clear();
  for(unsigned int i=0; i<duplicates.size(); ++i){
    theDuplicateSegments.push_back(*duplicates[i]);
    //avoid copying duplicates of duplicates of duplicates...
    theDuplicateSegments.back().theDuplicateSegments.resize(0);
 }
}
bool CSCSegment::sharesRecHits ( const CSCSegment anotherSegment) const
bool CSCSegment::sharesRecHits ( const CSCSegment anotherSegment,
CSCRecHit2D::SharedInputType  sharesInput 
) const
const std::vector<CSCRecHit2D>& CSCSegment::specificRecHits ( ) const [inline]

Definition at line 66 of file CSCSegment.h.

References theCSCRecHits.

Referenced by operator<<(), and sharesRecHits().

{ return theCSCRecHits; }
bool CSCSegment::testSharesAllInSpecificRecHits ( const std::vector< CSCRecHit2D > &  specificRecHits_1,
const std::vector< CSCRecHit2D > &  specificRecHits_2,
CSCRecHit2D::SharedInputType  sharesInput 
) const

Definition at line 94 of file CSCSegment.cc.

Referenced by sharesRecHits().

                                                                                              {
  const std::vector<CSCRecHit2D> * rhContainer_1 = &specificRecHits_1;
  const std::vector<CSCRecHit2D> * rhContainer_2 = &specificRecHits_2;
  if(specificRecHits_1.size()>specificRecHits_2.size()){
    rhContainer_2 = &specificRecHits_1;
    rhContainer_1 = &specificRecHits_2;
  }
  //
  bool shareConditionPassed = true;
  for ( std::vector<CSCRecHit2D>::const_iterator itRH = rhContainer_1->begin();
        itRH != rhContainer_1->end(); ++itRH) {
    const  CSCRecHit2D *firstRecHit = &(*itRH);
    bool sharedHit = false;
    for ( std::vector<CSCRecHit2D>::const_iterator itRH2 = rhContainer_2->begin();
          itRH2 != rhContainer_2->end(); ++itRH2) {
      if(itRH2->sharesInput(firstRecHit,sharesInput)){
        sharedHit = true;
        break;
      }
    }
    if(!sharedHit){
      shareConditionPassed = false;
      break;
    }
  }
  return shareConditionPassed;
}
float CSCSegment::time ( ) const

Definition at line 148 of file CSCSegment.cc.

References diffTreeTool::diff, reco::castor::maxDiff(), N, theCSCRecHits, CSCRecHit2D::tpeak(), and CSCRecHit2D::wireTime().

                             {
  float averageTime=0;
  std::vector<float> wireTimes;
  for (std::vector<CSCRecHit2D>::const_iterator itRH = theCSCRecHits.begin();
       itRH != theCSCRecHits.end(); ++itRH) {
    const  CSCRecHit2D *recHit = &(*itRH);
    averageTime+=recHit->tpeak();
    averageTime+=recHit->wireTime();
    wireTimes.push_back(recHit->wireTime());
  }
  averageTime=averageTime/(2*theCSCRecHits.size());

  //The wire times have a long tail that has to be pruned.  The strip times (tpeak) are fine
  bool modified=true;
  while(modified) {
    modified=false;
    double maxDiff=-1;
    std::vector<float>::iterator maxHit;
    for (std::vector<float>::iterator itWT=wireTimes.begin();
         itWT!=wireTimes.end(); ++itWT) {
      float diff=fabs(*itWT-averageTime);
      if (diff>maxDiff) {
        maxDiff=diff;
        maxHit=itWT;
      }
    }
    if (maxDiff>26) {
      int N=theCSCRecHits.size()+wireTimes.size();
      averageTime=(averageTime*N-(*maxHit))/(N-1);
      wireTimes.erase(maxHit);
      modified=true;
    }
  }
  return averageTime;
}

Member Data Documentation

Definition at line 99 of file CSCSegment.h.

double CSCSegment::theChi2 [private]

Definition at line 98 of file CSCSegment.h.

Referenced by chi2().

Definition at line 97 of file CSCSegment.h.

Referenced by localDirectionError(), localPositionError(), and parametersError().

std::vector<CSCRecHit2D> CSCSegment::theCSCRecHits [private]

Definition at line 94 of file CSCSegment.h.

Referenced by CSCSegment(), nRecHits(), recHits(), sharesRecHits(), specificRecHits(), and time().

Definition at line 100 of file CSCSegment.h.

Referenced by duplicateSegments(), isME11a_duplicate(), and setDuplicateSegments().

Definition at line 96 of file CSCSegment.h.

Referenced by localDirection(), and parameters().

Definition at line 95 of file CSCSegment.h.

Referenced by localPosition(), and parameters().