CMS 3D CMS Logo

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

PFCheckHitPattern Class Reference

PFCheckHitPatter. More...

#include <PFCheckHitPattern.h>

List of all members.

Public Types

typedef std::pair
< PFTrackHitInfo,
PFTrackHitInfo
PFTrackHitFullInfo
typedef std::pair< unsigned
int, unsigned int > 
PFTrackHitInfo

Public Member Functions

PFTrackHitFullInfo analyze (edm::ESHandle< TrackerGeometry >, const reco::TrackBaseRef track, const TransientVertex &vert)
 PFCheckHitPattern ()
void print (const reco::TrackBaseRef track) const
 Print hit pattern on track.
 ~PFCheckHitPattern ()

Private Types

typedef std::pair< uint32_t,
uint32_t > 
DetInfo
typedef std::map< DetInfo,
std::pair< double, double > > 
RZrangeMap

Private Member Functions

void init (edm::ESHandle< TrackerGeometry >)
 Create map indicating r/z values of all layers/disks.
void print (const reco::HitPattern &hp) const

Static Private Member Functions

static bool barrel (uint32_t subDet)
 Return a bool indicating if a given subdetector is in the barrel.
static DetInfo interpretDetId (DetId detId)

Private Attributes

bool geomInitDone_
 Note if geometry info is already initialized.

Static Private Attributes

static RZrangeMap rangeRorZ_

Detailed Description

PFCheckHitPatter.

Author:
Ian Tomalin, modified by Maxime Gouzevitch
Date:
October 2009

Definition at line 34 of file PFCheckHitPattern.h.


Member Typedef Documentation

typedef std::pair<uint32_t, uint32_t> PFCheckHitPattern::DetInfo [private]

Return a pair<uint32, uint32> consisting of the numbers used by HitPattern to identify subdetector and layer number respectively.

Definition at line 65 of file PFCheckHitPattern.h.

Definition at line 43 of file PFCheckHitPattern.h.

typedef std::pair<unsigned int, unsigned int> PFCheckHitPattern::PFTrackHitInfo

Definition at line 42 of file PFCheckHitPattern.h.

typedef std::map< DetInfo, std::pair< double, double> > PFCheckHitPattern::RZrangeMap [private]

For a given subdetector & layer number, this stores the minimum and maximum r (or z) values if it is barrel (or endcap) respectively.

Definition at line 79 of file PFCheckHitPattern.h.


Constructor & Destructor Documentation

PFCheckHitPattern::PFCheckHitPattern ( ) [inline]

Definition at line 38 of file PFCheckHitPattern.h.

: geomInitDone_(false) {}
PFCheckHitPattern::~PFCheckHitPattern ( ) [inline]

Definition at line 40 of file PFCheckHitPattern.h.

{}

Member Function Documentation

pair< PFCheckHitPattern::PFTrackHitInfo, PFCheckHitPattern::PFTrackHitInfo > PFCheckHitPattern::analyze ( edm::ESHandle< TrackerGeometry tkerGeomHandle_,
const reco::TrackBaseRef  track,
const TransientVertex vert 
)

PFCheck if hit pattern of this track is consistent with it being produced at given vertex. Pair.first gives number of hits on track in front of vertex. Pair.second gives number of missing hits between vertex and innermost hit on track.

Definition at line 107 of file PFCheckHitPattern.cc.

References Reference_intrackfit_cff::barrel, edm::RefToBase< T >::get(), reco::HitPattern::getHitPattern(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), i, init, reco::HitPattern::numberOfHits(), PV3DBase< T, PVType, FrameType >::perp(), TransientVertex::position(), reco::HitPattern::trackerHitFilter(), reco::HitPattern::validHitFilter(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by PFDisplacedVertexFinder::fitVertexFromSeed().

{

  // PFCheck if hit pattern of this track is consistent with it being produced
  // at given vertex. Pair.first gives number of hits on track in front of vertex.
  // Pair.second gives number of missing hits between vertex and innermost hit
  // on track.

  // Initialise geometry info if not yet done.
  if (!geomInitDone_) this->init(tkerGeomHandle_);

  // Get hit patterns of this track
  const reco::HitPattern& hp = track.get()->hitPattern(); 
  const reco::HitPattern& ip = track.get()->trackerExpectedHitsInner(); 

  // Count number of valid hits on track definately in front of the vertex,
  // taking into account finite depth of each layer.
  unsigned int nHitBefore = 0;
  unsigned int nHitAfter = 0;

  for (int i = 0; i < hp.numberOfHits(); i++) {
    uint32_t hit = hp.getHitPattern(i);
    if (hp.trackerHitFilter(hit) && hp.validHitFilter(hit)) {
      uint32_t subDet = hp.getSubStructure(hit);
      uint32_t layer = hp.getLayer(hit);
      DetInfo detInfo(subDet, layer);
      double maxRZ = rangeRorZ_[detInfo].second;

      if (this->barrel(subDet)) {
        if (vert.position().perp() > maxRZ) nHitBefore++;
        else nHitAfter++;
      } else {
        if (fabs(vert.position().z()) > maxRZ) nHitBefore++;
        else nHitAfter++;
      } 
    }
  }

  // Count number of missing hits before the innermost hit on the track,
  // taking into account finite depth of each layer.
  unsigned int nMissHitAfter = 0;
  unsigned int nMissHitBefore = 0;

  for (int i = 0; i < ip.numberOfHits(); i++) {
    uint32_t hit = ip.getHitPattern(i);
    if (ip.trackerHitFilter(hit)) {
      uint32_t subDet = ip.getSubStructure(hit);
      uint32_t layer = ip.getLayer(hit);
      DetInfo detInfo(subDet, layer);
      double minRZ = rangeRorZ_[detInfo].first;

      //      cout << "subDet = " << subDet << " layer = " << layer << " minRZ = " << minRZ << endl;

      if (this->barrel(subDet)) {
        if (vert.position().perp() < minRZ) nMissHitAfter++;
        else nMissHitBefore++;
      } else {
        if (fabs(vert.position().z()) < minRZ) nMissHitAfter++; 
        else nMissHitBefore++;
      } 
    }
  }


  PFTrackHitInfo trackToVertex(nHitBefore, nMissHitBefore);
  PFTrackHitInfo trackFromVertex(nHitAfter, nMissHitAfter);


  return pair< PFTrackHitInfo, PFTrackHitInfo>(trackToVertex, trackFromVertex);
}
bool PFCheckHitPattern::barrel ( uint32_t  subDet) [static, private]

Return a bool indicating if a given subdetector is in the barrel.

Definition at line 99 of file PFCheckHitPattern.cc.

References PixelSubdetector::PixelBarrel, StripSubdetector::TIB, and StripSubdetector::TOB.

                                              {
  // Determines if given sub-detector is in the barrel.
  return (subDet == StripSubdetector::TIB || subDet == StripSubdetector::TOB ||
          subDet == PixelSubdetector::PixelBarrel); 
}
void PFCheckHitPattern::init ( edm::ESHandle< TrackerGeometry tkerGeomHandle_) [private]

Create map indicating r/z values of all layers/disks.

Definition at line 30 of file PFCheckHitPattern.cc.

References Reference_intrackfit_cff::barrel, i, position, and z.

                                                                         {

  //
  // Note min/max radius (z) of each barrel layer (endcap disk).
  //

  geomInitDone_ = true;

  // Get Tracker geometry
  const TrackingGeometry::DetContainer& dets = tkerGeomHandle_->dets();

  // Loop over all modules in the Tracker.
  for (unsigned int i = 0; i < dets.size(); i++) {    

    // Get subdet and layer of this module
    DetInfo detInfo = this->interpretDetId(dets[i]->geographicalId());
    uint32_t subDet = detInfo.first;

    // Note r (or z) of module if barrel (or endcap).
    double r_or_z;
    if (this->barrel(subDet)) {
      r_or_z = dets[i]->position().perp();
    } else {
      r_or_z = fabs(dets[i]->position().z());
    }

    // Recover min/max r/z value of this layer/disk found so far.
    double minRZ = 999.;
    double maxRZ = 0.;
    if (rangeRorZ_.find(detInfo) != rangeRorZ_.end()) {
      minRZ = rangeRorZ_[detInfo].first;
      maxRZ = rangeRorZ_[detInfo].second;
    }

    // Update with those of this module if it exceeds them.
    if (minRZ > r_or_z) minRZ = r_or_z; 
    if (maxRZ < r_or_z) maxRZ = r_or_z;     
    rangeRorZ_[detInfo] = pair<double, double>(minRZ, maxRZ);
  }

#ifdef DEBUG_CHECKHITPATTERN
  RZrangeMap::const_iterator d;
  for (d = rangeRorZ_.begin(); d != rangeRorZ_.end(); d++) {
    DetInfo detInfo = d->first;
    pair<double, double> rangeRZ = d->second;
  }
#endif
}
PFCheckHitPattern::DetInfo PFCheckHitPattern::interpretDetId ( DetId  detId) [static, private]

Definition at line 79 of file PFCheckHitPattern.cc.

References PXFDetId::disk(), TIBDetId::layer(), TOBDetId::layer(), PXBDetId::layer(), GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, DetId::subdetId(), sistripsummary::TEC, sistripsummary::TIB, sistripsummary::TID, sistripsummary::TOB, TIDDetId::wheel(), and TECDetId::wheel().

                                                                      {
  // Convert detId to a pair<uint32, uint32> consisting of the numbers used by HitPattern 
  // to identify subdetector and layer number respectively.
  if (detId.subdetId() == StripSubdetector::TIB) {
    return DetInfo( detId.subdetId() , TIBDetId(detId).layer() );
  } else if (detId.subdetId() == StripSubdetector::TOB) {
    return DetInfo( detId.subdetId() , TOBDetId(detId).layer() );
  } else if (detId.subdetId() == StripSubdetector::TID) {
    return DetInfo( detId.subdetId() , TIDDetId(detId).wheel() );
  } else if (detId.subdetId() == StripSubdetector::TEC) {
    return DetInfo( detId.subdetId() , TECDetId(detId).wheel() );
  } else if (detId.subdetId() == PixelSubdetector::PixelBarrel) {
    return DetInfo( detId.subdetId() , PXBDetId(detId).layer() );
  } else if (detId.subdetId() == PixelSubdetector::PixelEndcap) {
    return DetInfo( detId.subdetId() , PXFDetId(detId).disk() );
  } else {
    throw Genexception("Found DetId that is not in Tracker");
  }   
}
void PFCheckHitPattern::print ( const reco::HitPattern hp) const [private]

Definition at line 190 of file PFCheckHitPattern.cc.

References gather_cfg::cout, reco::HitPattern::getHitPattern(), reco::HitPattern::getHitType(), reco::HitPattern::getLayer(), reco::HitPattern::getSubStructure(), i, reco::HitPattern::numberOfHits(), and reco::HitPattern::trackerHitFilter().

                                                            {
  for (int i = 0; i < hp.numberOfHits(); i++) {
    uint32_t hit = hp.getHitPattern(i);
    if (hp.trackerHitFilter(hit)) {
      uint32_t subdet = hp.getSubStructure(hit);
      uint32_t layer = hp.getLayer(hit);
      cout<<"hit "<<i<<" subdet="<<subdet<<" layer="<<layer<<" type "<<hp.getHitType(hit)<<endl;
    }
  } 
}
void PFCheckHitPattern::print ( const reco::TrackBaseRef  track) const

Print hit pattern on track.

Definition at line 179 of file PFCheckHitPattern.cc.

References gather_cfg::cout, edm::RefToBase< T >::get(), and reco::print().

                                                            {
  // Get hit patterns of this track
  const reco::HitPattern& hp = track.get()->hitPattern(); 
  const reco::HitPattern& ip = track.get()->trackerExpectedHitsInner(); 

  cout<<"=== Hits on Track ==="<<endl;
  this->print(hp);
  cout<<"=== Hits before track ==="<<endl;
  this->print(ip);
}

Member Data Documentation

Note if geometry info is already initialized.

Definition at line 75 of file PFCheckHitPattern.h.

Definition at line 80 of file PFCheckHitPattern.h.