CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

FastPixelHitMatcher Class Reference

#include <FastPixelHitMatcher.h>

List of all members.

Public Types

typedef
TransientTrackingRecHit::ConstRecHitPointer 
ConstRecHitPointer
typedef
TransientTrackingRecHit::RecHitContainer 
RecHitContainer
typedef
TransientTrackingRecHit::RecHitPointer 
RecHitPointer

Public Member Functions

bool checkRZCompatibility (double zCluster, double rCluster, double zVertex, float rzMin, float rzMax, GlobalPoint &theHit, bool forward)
std::vector< std::pair
< ConstRecHitPointer,
ConstRecHitPointer > > 
compatibleHits (const GlobalPoint &xmeas, const GlobalPoint &vprim, float energy, std::vector< TrackerRecHit > &theHits)
 FastPixelHitMatcher (float, float, float, float, float, float, float, float, float, float, float, float, bool)
double getVertex ()
bool isASeed (const ParticlePropagator &myElec, const ParticlePropagator &myPosi, const GlobalPoint &theVertex, double rCluster, double zCluster, const TrackerRecHit &hit1, const TrackerRecHit &hit2)
bool propagateToLayer (ParticlePropagator &myPart, const GlobalPoint &theVertex, GlobalPoint &theHit, double phimin, double phimax, unsigned layer)
void set1stLayer (float ephimin, float ephimax, float pphimin, float pphimax)
void set1stLayerZRange (double zmin1, double zmax1)
void set2ndLayer (float phimin, float phimax)
void setES (const MagneticFieldMap *aFieldMap, const TrackerGeometry *aTrackerGeometry, const GeometricSearchTracker *geomSearchTracker, const TrackerInteractionGeometry *interactionGeometry)
double zVertex (double zCluster, double rCluster, GlobalPoint &theHit)
virtual ~FastPixelHitMatcher ()

Private Attributes

const TrackerInteractionGeometry_theGeometry
float ephi1max
float ephi1min
RecHitContainer hitsInTrack
float phi2max
float phi2min
float pphi1max
float pphi1min
float r2maxF
float r2minF
float rMaxI
float rMinI
bool searchInTIDTEC
const MagneticFieldMaptheFieldMap
const GeometricSearchTrackertheGeomSearchTracker
const MagneticFieldtheMagneticField
std::vector< const TrackerLayer * > thePixelLayers
const TrackerGeometrytheTrackerGeometry
double vertex
float z1max
float z1min
float z2maxB
float z2minB

Detailed Description

Description: Class to match an ECAL cluster to the pixel hits. Two compatible hits in the pixel layers are required.

Implementation: future redesign

Description: central class for finding compatible hits

Implementation: <Notes on="" implementation>="">

Definition at line 38 of file FastPixelHitMatcher.h.


Member Typedef Documentation

Definition at line 42 of file FastPixelHitMatcher.h.

Definition at line 44 of file FastPixelHitMatcher.h.

Definition at line 43 of file FastPixelHitMatcher.h.


Constructor & Destructor Documentation

FastPixelHitMatcher::FastPixelHitMatcher ( float  ephi1min,
float  ephi1max,
float  pphi1min,
float  pphi1max,
float  phi2min,
float  phi2max,
float  z2minB,
float  z2maxB,
float  r2minF,
float  r2maxF,
float  rMinI,
float  rMaxI,
bool  searchInTIDTEC 
)
FastPixelHitMatcher::~FastPixelHitMatcher ( ) [virtual]

Definition at line 53 of file FastPixelHitMatcher.cc.

{ }

Member Function Documentation

bool FastPixelHitMatcher::checkRZCompatibility ( double  zCluster,
double  rCluster,
double  zVertex,
float  rzMin,
float  rzMax,
GlobalPoint theHit,
bool  forward 
)

Definition at line 323 of file FastPixelHitMatcher.cc.

References PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::z(), and zVertex().

Referenced by isASeed().

{

  // The hit position
  double zHit = theHit.z();
  double rHit = theHit.perp();

  // Compute the intersection of a line joining the cluster position 
  // and the predicted z origin (zVertex) with the layer hit 
  // (returns R for a forward layer, and Z for a barrel layer)
  double checkRZ = forward ?
    (zHit-zVertex)/(zCluster-zVertex) * rCluster
    :
    zVertex + rHit * (zCluster-zVertex)/rCluster;

  // This value is then compared to check with the actual hit position 
  // (in R for a forward layer, in Z for a barrel layer)

  return forward ?
    checkRZ+rzMin < rHit && rHit < checkRZ+rzMax 
    :
    checkRZ+rzMin < zHit && zHit < checkRZ+rzMax;
    
}
std::vector< std::pair< FastPixelHitMatcher::ConstRecHitPointer, FastPixelHitMatcher::ConstRecHitPointer > > FastPixelHitMatcher::compatibleHits ( const GlobalPoint xmeas,
const GlobalPoint vprim,
float  energy,
std::vector< TrackerRecHit > &  theHits 
)

Definition at line 83 of file FastPixelHitMatcher.cc.

References newFWLiteAna::build, gather_cfg::cout, isASeed(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::perp(), ParticlePropagator::propagateToNominalVertex(), query::result, theFieldMap, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by FastElectronSeedGenerator::addASeedToThisCluster().

                                                                     { 
  
  std::vector< std::pair<FastPixelHitMatcher::ConstRecHitPointer, 
    FastPixelHitMatcher::ConstRecHitPointer> > result;
#ifdef FAMOS_DEBUG
  std::cout << "[FastPixelHitMatcher::compatibleHits] entering .. " << std::endl;
#endif
  
  double zCluster = thePos.z();
  double rCluster = thePos.perp();
  
  // The cluster inferred energy-momentum
  double theLength = thePos.mag();
  XYZTLorentzVector theMom(thePos.x(), thePos.y(), thePos.z(), theLength);
  theMom *= energy / theLength;
  XYZTLorentzVector theVert(thePos.x(),thePos.y(),thePos.z(),0.);
  XYZTLorentzVector theNominalVertex(theVertex.x(), theVertex.y(), theVertex.z(), 0.);
  
  // The corresponding RawParticles (to be propagated for e- and e+
  ParticlePropagator myElec(theMom,theVert,-1.,theFieldMap);
  ParticlePropagator myPosi(theMom,theVert,+1.,theFieldMap); 
#ifdef FAMOS_DEBUG
  std::cout << "elec/posi before propagation " << std::endl << myElec << std::endl << myPosi << std::endl;
#endif
  
  // Propagate the e- and the e+ hypothesis to the nominal vertex
  // by modifying the pT direction in an appropriate manner.
  myElec.propagateToNominalVertex(theNominalVertex);
  myPosi.propagateToNominalVertex(theNominalVertex);
#ifdef FAMOS_DEBUG
  std::cout << "elec/posi after propagation " << std::endl << myElec << std::endl << myPosi << std::endl;
#endif
  
  // Look for an appropriate see in the pixel detector
  bool thereIsASeed = false;
  unsigned nHits = theHits.size();
  
  for ( unsigned firstHit=0; firstHit<nHits-1; ++firstHit ) { 
    for ( unsigned secondHit=firstHit+1; secondHit<nHits; ++secondHit ) {      

      // Is there a seed associated to this pair of Pixel hits?
      thereIsASeed = isASeed(myElec,myPosi,theVertex,
                             rCluster,zCluster,
                             theHits[firstHit],
                             theHits[secondHit]);

#ifdef FAMOS_DEBUG
      std::cout << "Is there a seed with hits " << firstHit << " & "<< secondHit << "? " << thereIsASeed << std::endl;
#endif
      if ( !thereIsASeed ) continue;
      
      ConstRecHitPointer theFirstHit = 
        GenericTransientTrackingRecHit::build(theHits[firstHit].geomDet(),
                                              theHits[firstHit].hit());
      ConstRecHitPointer theSecondHit = 
        GenericTransientTrackingRecHit::build(theHits[secondHit].geomDet(),
                                              theHits[secondHit].hit());
      result.push_back(std::pair<
                       FastPixelHitMatcher::ConstRecHitPointer,
                       FastPixelHitMatcher::ConstRecHitPointer>(theFirstHit,theSecondHit));
      
    }
  }
  
  return result;
}
double FastPixelHitMatcher::getVertex ( ) [inline]

Definition at line 62 of file FastPixelHitMatcher.h.

References vertex.

Referenced by FastElectronSeedGenerator::addASeedToThisCluster().

{ return vertex; }
bool FastPixelHitMatcher::isASeed ( const ParticlePropagator myElec,
const ParticlePropagator myPosi,
const GlobalPoint theVertex,
double  rCluster,
double  zCluster,
const TrackerRecHit hit1,
const TrackerRecHit hit2 
)

Definition at line 153 of file FastPixelHitMatcher.cc.

References checkRZCompatibility(), gather_cfg::cout, TrackerRecHit::cylinderNumber(), ephi1max, ephi1min, TrackerRecHit::globalPosition(), TrackerRecHit::isOnTheSameLayer(), phi2max, phi2min, pphi1max, pphi1min, propagateToLayer(), r2maxF, r2minF, rMaxI, rMinI, TrackerRecHit::subDetId(), vertex, z1max, z1min, z2maxB, z2minB, and zVertex().

Referenced by compatibleHits().

                                                           {
  
  // Check that the two hits are not on the same layer
  if ( hit2.isOnTheSameLayer(hit1) ) return false;
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: The two hits are not on the same layer - OK " << std::endl;
#endif

  // Check that the first hit is on PXB or PXD
  if ( hit1.subDetId() > 2 ) return false;
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: The first hits is on the pixel detector " << std::endl;
#endif

  // Impose the track to originate from zVertex = 0. and check the 
  // compatibility with the first hit (beam spot constraint)
  GlobalPoint firstHit = hit1.globalPosition();
  bool rzok = checkRZCompatibility(zCluster, rCluster, 0., z1min, z1max, firstHit, hit1.subDetId()>1);
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: rzok (1) = " << rzok << std::endl;
#endif
  if ( !rzok ) return false;
  
  // Refine the Z vertex by imposing the track to pass through the first RecHit, 
  // and check the compatibility with the second rechit 
  GlobalPoint secondHit = hit2.globalPosition(); 
  rzok = false;

  // The orgin Z vertex for thet track passing through the first rechit
  vertex = zVertex(zCluster, rCluster, firstHit);

  // Compute R (forward) or Z (barrel) predicted for the second hit and check compatibility
  if ( hit2.subDetId() == 1 ) {
    rzok = checkRZCompatibility(zCluster, rCluster, vertex, z2minB, z2maxB, secondHit, false);
  } else if ( hit2.subDetId() == 2 ) {  
    rzok = checkRZCompatibility(zCluster, rCluster, vertex, r2minF, r2maxF, secondHit, true);
  } else { 
    rzok = checkRZCompatibility(zCluster, rCluster, vertex, rMinI, rMaxI, secondHit, true);
  }
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: rzok (2) = " << rzok << std::endl;
#endif
  if ( !rzok ) return false;

  // Propagate the inferred electron (positron) to the first layer,
  // check the compatibility with the first hit, and propagate back
  // to the nominal vertex with the hit constraint
  ParticlePropagator elec(myElec);
  ParticlePropagator posi(myPosi);
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: elec1 to be propagated to first layer" << std::endl;
#endif
  bool elec1 = propagateToLayer(elec,theVertex,firstHit,
                                ephi1min,ephi1max,hit1.cylinderNumber());
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: posi1 to be propagated to first layer" << std::endl;
#endif
  bool posi1 = propagateToLayer(posi,theVertex,firstHit,
                                pphi1min,pphi1max,hit1.cylinderNumber());

#ifdef FAMOS_DEBUG
  std::cout << "isASeed: elec1 / posi1 " << elec1 << " " << posi1 << std::endl;
#endif
  // Neither the electron not the positron hypothesis work...
  if ( !elec1 && !posi1 ) return false;
  
  // Otherwise, propagate to the second layer, check the compatibility
  // with the second hit and propagate back to the nominal vertex with 
  // the hit constraint
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: elec2 to be propagated to second layer" << std::endl;
#endif
  bool elec2 = elec1 && propagateToLayer(elec,theVertex,secondHit,
                                         phi2min,phi2max,hit2.cylinderNumber());
  
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: posi2 to be propagated to second layer" << std::endl;
#endif
  bool posi2 = posi1 && propagateToLayer(posi,theVertex,secondHit,
                                         phi2min,phi2max,hit2.cylinderNumber());
  
#ifdef FAMOS_DEBUG
  std::cout << "isASeed: elec2 / posi2 " << elec2 << " " << posi2 << std::endl;
#endif
  if ( !elec2 && !posi2 ) return false;

  return true;

}
bool FastPixelHitMatcher::propagateToLayer ( ParticlePropagator myPart,
const GlobalPoint theVertex,
GlobalPoint theHit,
double  phimin,
double  phimax,
unsigned  layer 
)

Definition at line 250 of file FastPixelHitMatcher.cc.

References gather_cfg::cout, M_PI, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), BaseParticlePropagator::propagate(), ParticlePropagator::propagateToNominalVertex(), BaseParticlePropagator::setPropagationConditions(), RawParticle::setVertex(), summarizeEdmComparisonLogfiles::success, thePixelLayers, vertex, RawParticle::vertex(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by isASeed().

                                                    {

  // Set the z position of the particle to the predicted one
  XYZTLorentzVector theNominalVertex(theVertex.x(), theVertex.y(), vertex, 0.);
  myPart.setVertex(theNominalVertex);
#ifdef FAMOS_DEBUG
  std::cout << "propagateToLayer: propagateToLayer: Before propagation (0) " << myPart << std::endl;
#endif

  // Propagate the inferred electron (positron) to the first layer
  // Use the radius (barrel) or the z (forward) of the hit instead 
  // of the inaccurate layer radius and z.
  double rCyl = thePixelLayers[layer]->forward() ? 999. : theHit.perp();
  double zCyl = thePixelLayers[layer]->forward() ? fabs(theHit.z()) : 999.;
  BaseParticlePropagator* myBasePart = (BaseParticlePropagator*)(&myPart);
  myBasePart->setPropagationConditions(rCyl,zCyl);
  // myPart.setPropagationConditions(*(thePixelLayers[layer]));

  // bool success = myPart.propagateToBoundSurface(*(thePixelLayers[layer]));
  bool success = myPart.propagate();
#ifdef FAMOS_DEBUG
  std::cout << "propagateToLayer: Success ? " << success << std::endl;
  std::cout << "propagateToLayer: After  propagation (1) " << myPart << std::endl;
  std::cout << "propagateToLayer: The hit               " << theHit << std::endl; 
#endif
      
  // Check that propagated particle is within the proper phi range.
  if ( success ) {
    double dphi = myPart.vertex().phi() - theHit.phi();
    if ( dphi < -M_PI ) 
      dphi = dphi + 2.*M_PI;
    else if ( dphi > M_PI ) 
      dphi = dphi - 2.*M_PI;
#ifdef FAMOS_DEBUG
    std::cout << "propagateToLayer: Phi range ? " << phimin << " < " << dphi << " < " << phimax << std::endl; 
#endif
    if ( dphi < phimin || dphi > phimax ) success = false;
  }
      
  // Impose the track to go through the hit and propagate back to 
  // the nominal vertex
  if ( success ) {
    myPart.setVertex( XYZTLorentzVector(theHit.x(), theHit.y(), theHit.z(), 0.) );
    myPart.propagateToNominalVertex(theNominalVertex);
#ifdef FAMOS_DEBUG
    std::cout << "propagateToLayer: After  propagation (2) " << myPart << std::endl;
#endif
  }

  return success;

}
void FastPixelHitMatcher::set1stLayer ( float  ephimin,
float  ephimax,
float  pphimin,
float  pphimax 
) [inline]

Definition at line 64 of file FastPixelHitMatcher.h.

References ephi1max, ephi1min, pphi1max, and pphi1min.

Referenced by FastElectronSeedGenerator::addASeedToThisCluster().

                                                  {

    ephi1min = ephimin;
    ephi1max = ephimax;
    pphi1min = pphimin;
    pphi1max = pphimax;

  }
void FastPixelHitMatcher::set1stLayerZRange ( double  zmin1,
double  zmax1 
) [inline]

Definition at line 105 of file FastPixelHitMatcher.h.

References z1max, and z1min.

Referenced by FastElectronSeedGenerator::run().

                                                     {
    z1max = zmax1;
    z1min = zmin1;
  }
void FastPixelHitMatcher::set2ndLayer ( float  phimin,
float  phimax 
) [inline]

Definition at line 74 of file FastPixelHitMatcher.h.

References phi2max, and phi2min.

Referenced by FastElectronSeedGenerator::addASeedToThisCluster().

                                                {
    phi2min = phimin;
    phi2max = phimax;
  }
void FastPixelHitMatcher::setES ( const MagneticFieldMap aFieldMap,
const TrackerGeometry aTrackerGeometry,
const GeometricSearchTracker geomSearchTracker,
const TrackerInteractionGeometry interactionGeometry 
)

Definition at line 56 of file FastPixelHitMatcher.cc.

References _theGeometry, TrackerInteractionGeometry::cylinderBegin(), TrackerInteractionGeometry::cylinderEnd(), theFieldMap, theGeomSearchTracker, thePixelLayers, and theTrackerGeometry.

Referenced by FastElectronSeedGenerator::setupES().

                                                                                {
  
  // initialize the tracker geometry and the magnetic field map
  theTrackerGeometry = aTrackerGeometry; 
  //theMagneticField = aMagField;
  theGeomSearchTracker = geomSearchTracker;
  _theGeometry = interactionGeometry;
  theFieldMap = aFieldMap;
  
  // Initialize (if not already done) the simplified magnetic field geometry
  // MagneticFieldMap::instance( theMagneticField, _theGeometry );
  
  // The pixel layers in the simplified geometry 
  unsigned layer = 1;
  std::list<TrackerLayer>::const_iterator cyliter = _theGeometry->cylinderBegin();
  for ( ; cyliter != _theGeometry->cylinderEnd() ; ++cyliter ) {
    if ( layer != cyliter->layerNumber() ) continue;
    thePixelLayers[layer++] = &(*cyliter);
  }
  
}
double FastPixelHitMatcher::zVertex ( double  zCluster,
double  rCluster,
GlobalPoint theHit 
)

Definition at line 309 of file FastPixelHitMatcher.cc.

References PV3DBase< T, PVType, FrameType >::perp(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by checkRZCompatibility(), and isASeed().

{

  // Refine the Z vertex by imposing the track to pass through the RecHit
  double pxHitz = theHit.z();
  double pxHitr = theHit.perp();
  return pxHitz - pxHitr*(zCluster-pxHitz)/(rCluster-pxHitr);

}

Member Data Documentation

Definition at line 126 of file FastPixelHitMatcher.h.

Referenced by setES().

Definition at line 114 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayer().

Definition at line 114 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayer().

Definition at line 112 of file FastPixelHitMatcher.h.

Definition at line 116 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set2ndLayer().

Definition at line 116 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set2ndLayer().

Definition at line 115 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayer().

Definition at line 115 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayer().

float FastPixelHitMatcher::r2maxF [private]

Definition at line 119 of file FastPixelHitMatcher.h.

Referenced by isASeed().

float FastPixelHitMatcher::r2minF [private]

Definition at line 119 of file FastPixelHitMatcher.h.

Referenced by isASeed().

float FastPixelHitMatcher::rMaxI [private]

Definition at line 120 of file FastPixelHitMatcher.h.

Referenced by isASeed().

float FastPixelHitMatcher::rMinI [private]

Definition at line 120 of file FastPixelHitMatcher.h.

Referenced by isASeed().

Definition at line 121 of file FastPixelHitMatcher.h.

Definition at line 127 of file FastPixelHitMatcher.h.

Referenced by compatibleHits(), and setES().

Definition at line 125 of file FastPixelHitMatcher.h.

Referenced by setES().

Definition at line 124 of file FastPixelHitMatcher.h.

std::vector<const TrackerLayer*> FastPixelHitMatcher::thePixelLayers [private]

Definition at line 128 of file FastPixelHitMatcher.h.

Referenced by propagateToLayer(), and setES().

Definition at line 123 of file FastPixelHitMatcher.h.

Referenced by setES().

double FastPixelHitMatcher::vertex [private]

Definition at line 129 of file FastPixelHitMatcher.h.

Referenced by getVertex(), isASeed(), and propagateToLayer().

float FastPixelHitMatcher::z1max [private]

Definition at line 117 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayerZRange().

float FastPixelHitMatcher::z1min [private]

Definition at line 117 of file FastPixelHitMatcher.h.

Referenced by isASeed(), and set1stLayerZRange().

float FastPixelHitMatcher::z2maxB [private]

Definition at line 118 of file FastPixelHitMatcher.h.

Referenced by isASeed().

float FastPixelHitMatcher::z2minB [private]

Definition at line 118 of file FastPixelHitMatcher.h.

Referenced by isASeed().