CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

StackedTrackerGeometry Class Reference

#include <StackedTrackerGeometry.h>

List of all members.

Public Types

typedef __gnu_cxx::hash_map
< unsigned int,
StackedTrackerDetUnit * > 
mapIdToStack
typedef std::vector
< StackedTrackerDetUnit * > 
StackContainer
typedef std::vector
< StackedTrackerDetUnit * >
::const_iterator 
StackContainerIterator
typedef std::vector
< StackedTrackerDetId
StackIdContainer
typedef std::vector
< StackedTrackerDetId >
::const_iterator 
StackIdContainerIterator

Public Member Functions

void addStack (StackedTrackerDetUnit *aStack)
template<typename T >
void checkSimTrack (L1TkCluster< T > *cluster, edm::Handle< edm::DetSetVector< PixelDigiSimLink > > thePixelDigiSimLinkHandle, edm::Handle< edm::SimTrackContainer > simTrackHandle) const
template<>
void checkSimTrack (L1TkCluster< edm::Ref< edm::PSimHitContainer > > *cluster, edm::Handle< edm::DetSetVector< PixelDigiSimLink > > thePixelDigiSimLinkHandle, edm::Handle< edm::SimTrackContainer > simTrackHandle) const
template<typename T >
GlobalPoint findAverageGlobalPosition (const L1TkCluster< T > *cluster) const
 Unweighted average cluster position.
template<typename T >
LocalPoint findAverageLocalPosition (const L1TkCluster< T > *cluster) const
 Unweighted average local cluster position.
template<typename T >
GlobalVector findGlobalDirection (const L1TkStub< T > *stub) const
template<typename T >
GlobalPoint findGlobalPosition (const L1TkStub< T > *stub) const
template<>
GlobalPoint findHitGlobalPosition (const L1TkCluster< edm::Ref< edm::PSimHitContainer > > *cluster, unsigned int hitIdx) const
template<typename T >
GlobalPoint findHitGlobalPosition (const L1TkCluster< T > *cluster, unsigned int hitIdx) const
template<>
LocalPoint findHitLocalPosition (const L1TkCluster< edm::Ref< edm::PSimHitContainer > > *cluster, unsigned int hitIdx) const
template<typename T >
LocalPoint findHitLocalPosition (const L1TkCluster< T > *cluster, unsigned int hitIdx) const
template<typename T >
double findRoughPt (double aMagneticFieldStrength, const L1TkStub< T > *stub) const
const GeomDetidToDet (StackedTrackerDetId anId, unsigned int stackMemberIdentifier) const
const GeomDetUnitidToDetUnit (StackedTrackerDetId anId, unsigned int stackMemberIdentifier) const
const StackedTrackerDetUnitidToStack (StackedTrackerDetId anId) const
Plane::PlanePointer meanPlane (StackedTrackerDetId anId) const
 StackedTrackerGeometry (const TrackerGeometry *i)
const StackIdContainerstackIds () const
const StackContainerstacks () const
virtual ~StackedTrackerGeometry ()

Private Attributes

mapIdToStack theMap
StackIdContainer theStackIds
StackContainer theStacks
const TrackerGeometrytheTracker

Detailed Description

Definition at line 30 of file StackedTrackerGeometry.h.


Member Typedef Documentation

typedef __gnu_cxx::hash_map< unsigned int, StackedTrackerDetUnit*> StackedTrackerGeometry::mapIdToStack

Definition at line 36 of file StackedTrackerGeometry.h.

Definition at line 32 of file StackedTrackerGeometry.h.

Definition at line 33 of file StackedTrackerGeometry.h.

Definition at line 34 of file StackedTrackerGeometry.h.

Definition at line 35 of file StackedTrackerGeometry.h.


Constructor & Destructor Documentation

StackedTrackerGeometry::StackedTrackerGeometry ( const TrackerGeometry i)

//////////////////////////////////////// Stacked Tracker Simulations /// Written by: /// Andrew W. Rose /// 2008 /// //////////////////////////////////////

Definition at line 14 of file StackedTrackerGeometry.cc.

: theTracker(i) {}
StackedTrackerGeometry::~StackedTrackerGeometry ( ) [virtual]

Definition at line 15 of file StackedTrackerGeometry.cc.

{}

Member Function Documentation

void StackedTrackerGeometry::addStack ( StackedTrackerDetUnit aStack)

Definition at line 27 of file StackedTrackerGeometry.cc.

References StackedTrackerDetUnit::Id(), theMap, theStackIds, and theStacks.

Referenced by StackedTrackerGeometryBuilder::build().

{
  theStacks.push_back( aStack );
  theStackIds.push_back( aStack->Id() );
  theMap.insert( std::make_pair(aStack->Id(),aStack) );
}
void StackedTrackerGeometry::checkSimTrack ( L1TkCluster< edm::Ref< edm::PSimHitContainer > > *  cluster,
edm::Handle< edm::DetSetVector< PixelDigiSimLink > >  thePixelDigiSimLinkHandle,
edm::Handle< edm::SimTrackContainer simTrackHandle 
) const

Collect MC truth Default template for PixelDigis in *.h Specialize the template for PSimHits

Loop over all the hits composing the L1TkCluster

Get SimTrack Id and type

This version of the collection of the SimTrack ID and PDG may not be fast and optimal, but is safer since the SimTrack ID is shifted by 1 wrt the index in the vector, and this may not be so true on a general basis...

End of Loop over all the hits composing the L1TkCluster

Definition at line 142 of file StackedTrackerGeometry.cc.

References i, and j.

{
  std::vector< edm::Ref< edm::PSimHitContainer > > hits=cluster->getHits();
  for ( unsigned int i = 0; i < hits.size(); i++ ) {

    unsigned int curSimTrkId = hits.at(i)->trackId();

    bool foundSimTrack = false;
    for ( unsigned int j = 0; j < simTrackHandle->size() && !foundSimTrack; j++ )
      {
        if ( simTrackHandle->at(j).trackId() == curSimTrkId )
          {
            foundSimTrack = true;
            edm::Ptr< SimTrack > testSimTrack( simTrackHandle, j );
            cluster->addSimTrack( testSimTrack );
          }
      }
    if ( !foundSimTrack )
      {
        edm::Ptr< SimTrack > testSimTrack;
        cluster->addSimTrack( testSimTrack );
      }
  } 
}
template<typename T >
void StackedTrackerGeometry::checkSimTrack ( L1TkCluster< T > *  cluster,
edm::Handle< edm::DetSetVector< PixelDigiSimLink > >  thePixelDigiSimLinkHandle,
edm::Handle< edm::SimTrackContainer simTrackHandle 
) const

Discrimination between MC and data in Builder!

Get the PixelDigiSimLink

Loop over all the hits composing the L1TkCluster

Loop over PixelDigiSimLink

Threshold (redundant, already applied within L1TkClusterBuilder)

Find the link and, if there's not, skip

Get SimTrack Id and type

This version of the collection of the SimTrack ID and PDG may not be fast and optimal, but is safer since the SimTrack ID is shifted by 1 wrt the index in the vector, and this may not be so true on a general basis...

End of Loop over all the hits composing the L1TkCluster

Definition at line 277 of file StackedTrackerGeometry.h.

References L1TkCluster< T >::addSimTrack(), edm::DetSet< T >::data, L1TkCluster< T >::getDetId(), L1TkCluster< T >::getHits(), L1TkCluster< T >::getStackMember(), i, idToDet(), j, and DetId::rawId().

{

  const DetId detId = idToDet( cluster->getDetId(), cluster->getStackMember() )->geographicalId();
  edm::DetSet<PixelDigiSimLink> thisDigiSimLink = (*(thePixelDigiSimLinkHandle) )[detId.rawId()];
  edm::DetSet<PixelDigiSimLink>::const_iterator iterSimLink;

  std::vector<T> hits=cluster->getHits(); 
  for ( unsigned int i = 0; i < hits.size(); i++ )
    {
      for ( iterSimLink = thisDigiSimLink.data.begin();
            iterSimLink != thisDigiSimLink.data.end();
            iterSimLink++ )
        {
          //if ( theHit.adc() <= 30 ) continue;
          if ( (int)iterSimLink->channel() != hits.at(i)->channel() ) continue;

          unsigned int curSimTrkId = iterSimLink->SimTrackId();
          bool foundSimTrack = false;
          for ( unsigned int j = 0; j < simTrackHandle->size() && !foundSimTrack; j++ )
            {
              if ( simTrackHandle->at(j).trackId() == curSimTrkId )
                {
                  foundSimTrack = true;
                  edm::Ptr< SimTrack > testSimTrack( simTrackHandle, j );
                  cluster->addSimTrack( testSimTrack );
                }
            }

          if ( !foundSimTrack )
            {
              edm::Ptr< SimTrack > testSimTrack;
              cluster->addSimTrack( testSimTrack );
            }
        }
    } 
}
template<typename T >
GlobalPoint StackedTrackerGeometry::findAverageGlobalPosition ( const L1TkCluster< T > *  cluster) const

Unweighted average cluster position.

Loop over the hits and calculate the average coordinates

Definition at line 251 of file StackedTrackerGeometry.h.

References findHitGlobalPosition(), L1TkCluster< T >::getHits(), i, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by findGlobalDirection(), findGlobalPosition(), and findRoughPt().

{
  double averageX = 0.0;
  double averageY = 0.0;
  double averageZ = 0.0;

  std::vector<T> hits=cluster->getHits();

  if ( hits.size() != 0 )
    {
      for ( unsigned int i = 0; i < hits.size(); i++ )
        {
          GlobalPoint thisHitPosition = findHitGlobalPosition( cluster, i );
          averageX += thisHitPosition.x();
          averageY += thisHitPosition.y();
          averageZ += thisHitPosition.z();
        }
      averageX /= hits.size();
      averageY /= hits.size();
      averageZ /= hits.size();
    }
  return GlobalPoint( averageX, averageY, averageZ );
}
template<typename T >
LocalPoint StackedTrackerGeometry::findAverageLocalPosition ( const L1TkCluster< T > *  cluster) const

Unweighted average local cluster position.

Loop over the hits and calculate the average coordinates

Definition at line 227 of file StackedTrackerGeometry.h.

References findHitLocalPosition(), L1TkCluster< T >::getHits(), i, PV3DBase< T, PVType, FrameType >::x(), and PV3DBase< T, PVType, FrameType >::y().

Referenced by findRoughPt().

{
  double averageX = 0.0;
  double averageY = 0.0;

  std::vector<T> hits=cluster->getHits();

  if ( hits.size() != 0 )
    {
      for ( unsigned int i = 0; i < hits.size(); i++ )
        {
          LocalPoint thisHitPosition = findHitLocalPosition( cluster, i );
          averageX += thisHitPosition.x();
          averageY += thisHitPosition.y();
        }
      averageX /= hits.size();
      averageY /= hits.size();
    }
  return LocalPoint( averageX, averageY );
}
template<typename T >
GlobalVector StackedTrackerGeometry::findGlobalDirection ( const L1TkStub< T > *  stub) const

Get average position of Clusters composing the Stub

Calculate the direction

Definition at line 187 of file StackedTrackerGeometry.h.

References findAverageGlobalPosition(), L1TkStub< T >::getClusterPtr(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

{
  GlobalPoint innerHitPosition = findAverageGlobalPosition( stub->getClusterPtr(0).get() );
  GlobalPoint outerHitPosition = findAverageGlobalPosition( stub->getClusterPtr(1).get() );

  GlobalVector directionVector( outerHitPosition.x()-innerHitPosition.x(),
                                outerHitPosition.y()-innerHitPosition.y(),
                                outerHitPosition.z()-innerHitPosition.z() );

  return directionVector;
}
template<typename T >
GlobalPoint StackedTrackerGeometry::findGlobalPosition ( const L1TkStub< T > *  stub) const

Fast version: only inner cluster matters

Definition at line 180 of file StackedTrackerGeometry.h.

References findAverageGlobalPosition(), and L1TkStub< T >::getClusterPtr().

Referenced by HitDump::analyze(), and L1TrackProducer::produce().

{
  return findAverageGlobalPosition( stub->getClusterPtr(0).get() );
}
GlobalPoint StackedTrackerGeometry::findHitGlobalPosition ( const L1TkCluster< edm::Ref< edm::PSimHitContainer > > *  cluster,
unsigned int  hitIdx 
) const

Get hit global position Default template for PixelDigis in *.h Specialize the template for PSimHits

Definition at line 131 of file StackedTrackerGeometry.cc.

References idToDetUnit(), GeomDet::surface(), and Surface::toGlobal().

{
  const GeomDetUnit* geomDetUnit = idToDetUnit( cluster->getDetId(), cluster->getStackMember() );
  return geomDetUnit->surface().toGlobal( cluster->getHits().at(hitIdx)->localPosition() );
}
template<typename T >
GlobalPoint StackedTrackerGeometry::findHitGlobalPosition ( const L1TkCluster< T > *  cluster,
unsigned int  hitIdx 
) const

Get hit global position Default template for PixelDigis

Add 0.5 to get the center of the pixel

Definition at line 216 of file StackedTrackerGeometry.h.

References L1TkCluster< T >::getDetId(), L1TkCluster< T >::getHits(), L1TkCluster< T >::getStackMember(), idToDetUnit(), Topology::localPosition(), GeomDet::surface(), Surface::toGlobal(), and GeomDetUnit::topology().

Referenced by findAverageGlobalPosition().

{
  const GeomDetUnit* geomDetUnit = idToDetUnit( cluster->getDetId(), cluster->getStackMember() );
  T hit=cluster->getHits().at(hitIdx); 
  MeasurementPoint mp( hit->row() + 0.5, hit->column() + 0.5 );
  return geomDetUnit->surface().toGlobal( geomDetUnit->topology().localPosition( mp ) );
}
LocalPoint StackedTrackerGeometry::findHitLocalPosition ( const L1TkCluster< edm::Ref< edm::PSimHitContainer > > *  cluster,
unsigned int  hitIdx 
) const

Definition at line 121 of file StackedTrackerGeometry.cc.

{
  return cluster->getHits().at(hitIdx)->localPosition();
}
template<typename T >
LocalPoint StackedTrackerGeometry::findHitLocalPosition ( const L1TkCluster< T > *  cluster,
unsigned int  hitIdx 
) const

Get hit local position Default template for PixelDigis

Add 0.5 to get the center of the pixel

Definition at line 204 of file StackedTrackerGeometry.h.

References L1TkCluster< T >::getDetId(), L1TkCluster< T >::getHits(), L1TkCluster< T >::getStackMember(), idToDetUnit(), Topology::localPosition(), and GeomDetUnit::topology().

Referenced by findAverageLocalPosition().

{
  const GeomDetUnit* geomDetUnit = idToDetUnit( cluster->getDetId(), cluster->getStackMember() );
  T hit=cluster->getHits().at(hitIdx); 
  MeasurementPoint mp( hit->row() + 0.5, hit->column() + 0.5 );
  return geomDetUnit->topology().localPosition( mp );
}
template<typename T >
double StackedTrackerGeometry::findRoughPt ( double  aMagneticFieldStrength,
const L1TkStub< T > *  stub 
) const

Fit Stub as in Builder To be used for out-of-Builder Stubs

Get the magnetic field Usually it is done like the following three lines

Calculate factor for rough Pt estimate B rounded to 4.0 or 3.8 This is B * C / 2 * appropriate power of 10 So it's B * 0.0015

Get average position of Clusters composing the Stub

Get useful quantities

Here a switch on Barrel/Endcap is introduced

Calculate angular displacement from hit phi locations and renormalize it, if needed

Return the rough Pt

Test approximated formula for Endcap stubs Check always to be consistent with HitMatchingAlgorithm_window2012.h

Return the rough Pt

Default Should never get here

Definition at line 122 of file StackedTrackerGeometry.h.

References dtNoiseDBValidation_cfg::cerr, SiPixelRawToDigiRegional_cfi::deltaPhi, findAverageGlobalPosition(), findAverageLocalPosition(), L1TkStub< T >::getClusterPtr(), L1TkStub< T >::getDetId(), M_PI, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), and x.

Referenced by HitDump::analyze(), and L1TrackProducer::produce().

                                                                                                          {
    //iSetup.get<IdealMagneticFieldRecord>().get(magnet);
    //magnet_ = magnet.product();
    //mMagneticFieldStrength = magnet_->inTesla(GlobalPoint(0,0,0)).z();
    double mPtFactor = (floor(aMagneticFieldStrength*10.0 + 0.5))/10.0*0.0015;

    GlobalPoint innerHitPosition = findAverageGlobalPosition( stub->getClusterPtr(0).get() );
    GlobalPoint outerHitPosition = findAverageGlobalPosition( stub->getClusterPtr(1).get() );

    double outerPointRadius = outerHitPosition.perp();
    double innerPointRadius = innerHitPosition.perp();
    double outerPointPhi = outerHitPosition.phi();
    double innerPointPhi = innerHitPosition.phi();
    double deltaRadius = outerPointRadius - innerPointRadius;

    StackedTrackerDetId tempDetId(stub->getDetId());
    if (tempDetId.isBarrel())
    {
      double deltaPhi = outerPointPhi - innerPointPhi;
      if (deltaPhi < 0)
        deltaPhi = -deltaPhi;
      if (deltaPhi > M_PI)
        deltaPhi = 2*M_PI - deltaPhi;

      return ( deltaRadius * mPtFactor / deltaPhi );
    }
    else if (tempDetId.isEndcap())
    {
      double roughPt = innerPointRadius * innerPointRadius * mPtFactor / fabs(findAverageLocalPosition( stub->getClusterPtr(0).get() ).x()) ;
      roughPt +=       outerPointRadius * outerPointRadius * mPtFactor / fabs(findAverageLocalPosition( stub->getClusterPtr(1).get() ).x()) ;
      roughPt = roughPt / 2.;

      return roughPt;
    }

    std::cerr << "W A R N I N G! L1TkStub::findRoughPt() \t we should never get here" << std::endl;
    return 99999.9;
  }
const GeomDet * StackedTrackerGeometry::idToDet ( StackedTrackerDetId  anId,
unsigned int  stackMemberIdentifier 
) const

Definition at line 55 of file StackedTrackerGeometry.cc.

References TrackerGeometry::idToDet(), idToStack(), NULL, groupFilesInBlocks::temp, and theTracker.

Referenced by HitDump::analyze(), checkSimTrack(), and L1TrackProducer::produce().

  {
  if ( const StackedTrackerDetUnit* temp=(this->idToStack(anId)) )
  {
    return theTracker->idToDet( temp->stackMember(stackMemberIdentifier) );
  }
  return NULL;
}
const GeomDetUnit * StackedTrackerGeometry::idToDetUnit ( StackedTrackerDetId  anId,
unsigned int  stackMemberIdentifier 
) const

The following methods are analagous to the methods in TrackerGeomety except that you pass it a stack id and an identifier to a stack member

Definition at line 45 of file StackedTrackerGeometry.cc.

References TrackerGeometry::idToDetUnit(), idToStack(), NULL, groupFilesInBlocks::temp, and theTracker.

Referenced by findHitGlobalPosition(), findHitLocalPosition(), getPixelRayEndpoints(), and WindowFinder::getWindow().

{
  if ( const StackedTrackerDetUnit* temp=(this->idToStack(anId)) )
  {
    return theTracker->idToDetUnit( temp->stackMember(stackMemberIdentifier) );
  }
  return NULL;
}
const StackedTrackerDetUnit * StackedTrackerGeometry::idToStack ( StackedTrackerDetId  anId) const

Definition at line 34 of file StackedTrackerGeometry.cc.

References NULL, and theMap.

Referenced by HitDump::analyze(), StackedTrackerGeometryBuilder::build(), idToDet(), idToDetUnit(), and meanPlane().

{
  if ( theMap.find(anId) != theMap.end() )
  {
    return theMap.find(anId)->second;
  }
  return NULL;
}
Plane::PlanePointer StackedTrackerGeometry::meanPlane ( StackedTrackerDetId  anId) const

Definition at line 65 of file StackedTrackerGeometry.cc.

References newFWLiteAna::build, i, TrackerGeometry::idToDet(), idToStack(), NULL, pos, GeomDet::position(), makeMuonMisalignmentScenario::rot, GeomDet::rotation(), StackedTrackerDetUnit::theStackMembers(), theTracker, PV3DBase< T, PVType, FrameType >::x(), x, TkRotation< T >::xx(), TkRotation< T >::xy(), xy(), TkRotation< T >::xz(), PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::y, TkRotation< T >::yx(), TkRotation< T >::yy(), TkRotation< T >::yz(), PV3DBase< T, PVType, FrameType >::z(), z, TkRotation< T >::zx(), TkRotation< T >::zy(), and TkRotation< T >::zz().

{
  double x = 0.0,  y = 0.0,  z = 0.0;
  double xx = 0.0, xy = 0.0, xz = 0.0, yx = 0.0, yy = 0.0, yz = 0.0, zx = 0.0, zy = 0.0, zz = 0.0;

  const StackedTrackerDetUnit* theStack = this->idToStack( anId );

  if ( theStack == NULL )
  {
    return NULL;
  }
  else
  {
    for ( StackedTrackerDetUnit::StackContentsIterator i = theStack->theStackMembers().begin();
          i != theStack->theStackMembers().end();
          ++i )
    {
      Surface::RotationType rot = theTracker->idToDet(i->second)->rotation();
      Surface::PositionType pos = theTracker->idToDet(i->second)->position();

      x  += pos.x();
      y  += pos.y();
      z  += pos.z();
      xx += rot.xx();
      xy += rot.xy();
      xz += rot.xz();
      yx += rot.yx();
      yy += rot.yy();
      yz += rot.yz();
      zx += rot.zx();
      zy += rot.zy();
      zz += rot.zz();
    }

    float sizeInv = 1.0/theStack->theStackMembers().size();
    x  *= sizeInv;
    y  *= sizeInv;
    z  *= sizeInv;
    xx *= sizeInv;
    xy *= sizeInv;
    xz *= sizeInv;
    yx *= sizeInv;
    yy *= sizeInv;
    yz *= sizeInv;
    zx *= sizeInv;
    zy *= sizeInv;
    zz *= sizeInv;

    Surface::PositionType meanPos( x , y , z );
    Surface::RotationType meanRot( xx , xy , xz , yx , yy , yz , zx , zy , zz );

    return Plane::build( meanPos, meanRot );
  }
}
const StackedTrackerGeometry::StackIdContainer & StackedTrackerGeometry::stackIds ( ) const

Definition at line 22 of file StackedTrackerGeometry.cc.

References theStackIds.

{
  return theStackIds;
}
const StackedTrackerGeometry::StackContainer & StackedTrackerGeometry::stacks ( ) const

Definition at line 17 of file StackedTrackerGeometry.cc.

References theStacks.

Referenced by HitDump::analyze(), and StackedTrackerGeometryBuilder::build().

{
  return theStacks;
}

Member Data Documentation

Definition at line 92 of file StackedTrackerGeometry.h.

Referenced by addStack(), and idToStack().

Definition at line 90 of file StackedTrackerGeometry.h.

Referenced by addStack(), and stackIds().

Definition at line 89 of file StackedTrackerGeometry.h.

Referenced by addStack(), and stacks().

Definition at line 87 of file StackedTrackerGeometry.h.

Referenced by idToDet(), idToDetUnit(), and meanPlane().