CMS 3D CMS Logo

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

CaloSubdetectorGeometry Class Reference

#include <CaloSubdetectorGeometry.h>

Inheritance diagram for CaloSubdetectorGeometry:
CaloTowerGeometry CastorGeometry EcalBarrelGeometry EcalEndcapGeometry EcalPreshowerGeometry EcalTBHodoscopeGeometry HcalDDDGeometry HcalGeometry ZdcGeometry

List of all members.

Public Types

typedef CaloCellGeometry::CCGFloat CCGFloat
typedef std::set< DetIdDetIdSet
typedef std::vector< CCGFloatDimVec
typedef std::vector< unsigned int > IVec
typedef CaloCellGeometry::ParMgr ParMgr
typedef CaloCellGeometry::ParVec ParVec
typedef CaloCellGeometry::ParVecVec ParVecVec
typedef std::vector< CCGFloatTrVec

Public Member Functions

void allocateCorners (CaloCellGeometry::CornersVec::size_type n)
void allocatePar (ParVec::size_type n, unsigned int m)
 CaloSubdetectorGeometry ()
CaloCellGeometry::CornersMgrcornersMgr ()
CCGFloat deltaEta (const DetId &detId) const
CCGFloat deltaPhi (const DetId &detId) const
virtual void fillDefaultNamedParameters () const
virtual DetIdSet getCells (const GlobalPoint &r, double dR) const
 Get a list of all cells within a dR of the given cell.
virtual DetId getClosestCell (const GlobalPoint &r) const
virtual const CaloCellGeometrygetGeometry (const DetId &id) const
 Get the cell geometry of a given detector id. Should return false if not found.
void getSummary (TrVec &trVector, IVec &iVector, DimVec &dimVector) const
virtual const std::vector
< DetId > & 
getValidDetIds (DetId::Detector det=DetId::Detector(0), int subdet=0) const
 Get a list of valid detector ids (for the given subdetector)
virtual void initializeParms ()
virtual void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)=0
virtual unsigned int numberOfParametersPerShape () const
virtual unsigned int numberOfShapes () const
virtual unsigned int numberOfTransformParms () const
ParMgrparMgr ()
const ParMgrparMgrConst () const
const ParVecVecparVecVec () const
ParVecVecparVecVec ()
virtual bool present (const DetId &id) const
 is this detid present in the geometry?
virtual ~CaloSubdetectorGeometry ()
 The base class DOES assume that it owns the CaloCellGeometry objects.

Protected Member Functions

virtual const CaloCellGeometrycellGeomPtr (uint32_t index) const =0

Static Protected Member Functions

static CCGFloat deltaR (const GlobalPoint &p1, const GlobalPoint &p2)

Protected Attributes

ParVecVec m_parVecVec
std::vector< DetIdm_validIds

Private Member Functions

 CaloSubdetectorGeometry (const CaloSubdetectorGeometry &)
 avoid copies
CaloSubdetectorGeometryoperator= (const CaloSubdetectorGeometry &)

Private Attributes

CaloCellGeometry::CornersMgrm_cmgr
std::vector< CCGFloat > * m_deltaEta
std::vector< CCGFloat > * m_deltaPhi
ParMgrm_parMgr
bool m_sortedIds

Detailed Description

Base class for a geometry container for a specific calorimetry subdetector.

Date:
2011/06/04 18:58:48
Revision:
1.27
Author:
J. Mans - Minnesota

Definition at line 21 of file CaloSubdetectorGeometry.h.


Member Typedef Documentation

Definition at line 27 of file CaloSubdetectorGeometry.h.

Definition at line 35 of file CaloSubdetectorGeometry.h.

typedef std::vector<unsigned int> CaloSubdetectorGeometry::IVec

Definition at line 34 of file CaloSubdetectorGeometry.h.

Definition at line 29 of file CaloSubdetectorGeometry.h.

Reimplemented in EcalPreshowerGeometry.

Definition at line 30 of file CaloSubdetectorGeometry.h.

Reimplemented in EcalPreshowerGeometry.

Definition at line 31 of file CaloSubdetectorGeometry.h.

Definition at line 33 of file CaloSubdetectorGeometry.h.


Constructor & Destructor Documentation

CaloSubdetectorGeometry::CaloSubdetectorGeometry ( )

Definition at line 13 of file CaloSubdetectorGeometry.cc.

                                                 : 
   m_parMgr ( 0 ) ,
   m_cmgr   ( 0 ) ,
   m_sortedIds (false) ,
   m_deltaPhi  ( 0 ) ,
   m_deltaEta  ( 0 )  
{
}
CaloSubdetectorGeometry::~CaloSubdetectorGeometry ( ) [virtual]

The base class DOES assume that it owns the CaloCellGeometry objects.

Definition at line 23 of file CaloSubdetectorGeometry.cc.

References m_cmgr, m_deltaEta, m_deltaPhi, and m_parMgr.

{ 
   delete m_cmgr ;
   delete m_parMgr ; 
   delete m_deltaPhi ;
   delete m_deltaEta ;
}
CaloSubdetectorGeometry::CaloSubdetectorGeometry ( const CaloSubdetectorGeometry ) [private]

avoid copies


Member Function Documentation

void CaloSubdetectorGeometry::allocateCorners ( CaloCellGeometry::CornersVec::size_type  n)
void CaloSubdetectorGeometry::allocatePar ( ParVec::size_type  n,
unsigned int  m 
)
virtual const CaloCellGeometry* CaloSubdetectorGeometry::cellGeomPtr ( uint32_t  index) const [protected, pure virtual]
CaloCellGeometry::CornersMgr* CaloSubdetectorGeometry::cornersMgr ( ) [inline]
CCGFloat CaloSubdetectorGeometry::deltaEta ( const DetId detId) const

Definition at line 261 of file CaloSubdetectorGeometry.cc.

References cellGeomPtr(), CaloGenericDetId::denseIndex(), PV3DBase< T, PVType, FrameType >::eta(), CaloCellGeometry::getCorners(), i, m_deltaEta, and CaloGenericDetId::sizeForDenseIndexing().

{
   const CaloGenericDetId cgId ( detId ) ;

   if( 0 == m_deltaEta )
   {
      const uint32_t kSize ( cgId.sizeForDenseIndexing() ) ;
      m_deltaEta = new std::vector<CCGFloat> ( kSize ) ;
      for( uint32_t i ( 0 ) ; i != kSize ; ++i )
      {
         const CaloCellGeometry* cellPtr ( cellGeomPtr( i ) ) ;
         if( 0 != cellPtr )
         {
            const CaloCellGeometry& cell ( *cellPtr ) ;
            const CCGFloat dEta1 ( fabs(
                                      GlobalPoint( ( cell.getCorners()[0].x() + 
                                                     cell.getCorners()[1].x() )/2. ,
                                                   ( cell.getCorners()[0].y() + 
                                                     cell.getCorners()[1].y() )/2. ,
                                                   ( cell.getCorners()[0].z() + 
                                                     cell.getCorners()[1].z() )/2.  ).eta() -
                                      GlobalPoint( ( cell.getCorners()[2].x() + 
                                                     cell.getCorners()[3].x() )/2. ,
                                                   ( cell.getCorners()[2].y() + 
                                                     cell.getCorners()[3].y() )/2. ,
                                                   ( cell.getCorners()[2].z() + 
                                                     cell.getCorners()[3].z() )/2.  ).eta() ) ) ;
            const CCGFloat dEta2 ( fabs(
                                      GlobalPoint( ( cell.getCorners()[0].x() + 
                                                     cell.getCorners()[3].x() )/2. ,
                                                   ( cell.getCorners()[0].y() + 
                                                     cell.getCorners()[3].y() )/2. ,
                                                   ( cell.getCorners()[0].z() + 
                                                     cell.getCorners()[3].z() )/2.  ).eta() -
                                      GlobalPoint( ( cell.getCorners()[2].x() + 
                                                     cell.getCorners()[1].x() )/2. ,
                                                   ( cell.getCorners()[2].y() + 
                                                     cell.getCorners()[1].y() )/2. ,
                                                   ( cell.getCorners()[2].z() + 
                                                     cell.getCorners()[1].z() )/2.  ).eta() ) ) ;
            (*m_deltaEta)[i] = dEta1>dEta2 ? dEta1 : dEta2 ;
         }
      }
   }
   return (*m_deltaEta)[ cgId.denseIndex() ] ;
}
CCGFloat CaloSubdetectorGeometry::deltaPhi ( const DetId detId) const

Definition at line 211 of file CaloSubdetectorGeometry.cc.

References cellGeomPtr(), CaloGenericDetId::denseIndex(), CaloCellGeometry::getCorners(), i, m_deltaPhi, M_PI, PV3DBase< T, PVType, FrameType >::phi(), and CaloGenericDetId::sizeForDenseIndexing().

{
   const CaloGenericDetId cgId ( detId ) ;

   if( 0 == m_deltaPhi )
   {
      const uint32_t kSize ( cgId.sizeForDenseIndexing() ) ;
      m_deltaPhi = new std::vector<CCGFloat> ( kSize ) ;
      for( uint32_t i ( 0 ) ; i != kSize ; ++i )
      {
         const CaloCellGeometry* cellPtr ( cellGeomPtr( i ) ) ;
         if( 0 != cellPtr )
         {
            const CaloCellGeometry& cell ( *cellPtr ) ;
            CCGFloat dPhi1 ( fabs(
                                GlobalPoint( ( cell.getCorners()[0].x() + 
                                               cell.getCorners()[1].x() )/2. ,
                                             ( cell.getCorners()[0].y() + 
                                               cell.getCorners()[1].y() )/2. ,
                                             ( cell.getCorners()[0].z() + 
                                               cell.getCorners()[1].z() )/2.  ).phi() -
                                GlobalPoint( ( cell.getCorners()[2].x() + 
                                               cell.getCorners()[3].x() )/2. ,
                                             ( cell.getCorners()[2].y() + 
                                               cell.getCorners()[3].y() )/2. ,
                                             ( cell.getCorners()[2].z() + 
                                               cell.getCorners()[3].z() )/2.  ).phi() ) ) ;
            CCGFloat dPhi2 ( fabs(
                                GlobalPoint( ( cell.getCorners()[0].x() + 
                                               cell.getCorners()[3].x() )/2. ,
                                             ( cell.getCorners()[0].y() + 
                                               cell.getCorners()[3].y() )/2. ,
                                             ( cell.getCorners()[0].z() + 
                                               cell.getCorners()[3].z() )/2.  ).phi() -
                                GlobalPoint( ( cell.getCorners()[2].x() + 
                                               cell.getCorners()[1].x() )/2. ,
                                             ( cell.getCorners()[2].y() + 
                                               cell.getCorners()[1].y() )/2. ,
                                             ( cell.getCorners()[2].z() + 
                                               cell.getCorners()[1].z() )/2.  ).phi() ) ) ;
            if( M_PI < dPhi1 ) dPhi1 = fabs( dPhi1 - 2.*M_PI ) ;
            if( M_PI < dPhi2 ) dPhi2 = fabs( dPhi2 - 2.*M_PI ) ;
            (*m_deltaPhi)[i] = dPhi1>dPhi2 ? dPhi1 : dPhi2 ;
         }
      }
   }
   return (*m_deltaPhi)[ cgId.denseIndex() ] ;
}
static CCGFloat CaloSubdetectorGeometry::deltaR ( const GlobalPoint p1,
const GlobalPoint p2 
) [inline, static, protected]

Definition at line 106 of file CaloSubdetectorGeometry.h.

      { return reco::deltaR( p1, p2 ) ; }
virtual void CaloSubdetectorGeometry::fillDefaultNamedParameters ( ) const [inline, virtual]

Definition at line 92 of file CaloSubdetectorGeometry.h.

{ return ; }
CaloSubdetectorGeometry::DetIdSet CaloSubdetectorGeometry::getCells ( const GlobalPoint r,
double  dR 
) const [virtual]

Get a list of all cells within a dR of the given cell.

The default implementation makes a loop over all cell geometries. Cleverer implementations are suggested to use rough conversions between eta/phi and ieta/iphi and test on the boundaries.

Reimplemented in EcalBarrelGeometry, EcalEndcapGeometry, and HcalGeometry.

Definition at line 85 of file CaloSubdetectorGeometry.cc.

References reco::deltaR2(), eta(), PV3DBase< T, PVType, FrameType >::eta(), getGeometry(), CaloCellGeometry::getPosition(), i, M_PI, m_validIds, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), and phi.

Referenced by egammaisolation::EgammaRecHitExtractor::collect(), EgammaRecHitIsolation::getSum_(), CaloConeSelector::select(), and CaloDualConeSelector::select().

{
   const double dR2 ( dR*dR ) ;
   const double eta ( r.eta() ) ;
   const double phi ( r.phi() ) ;

   DetIdSet dss;
   
   if( 0.000001 < dR )
   {
      for( uint32_t i ( 0 ); i != m_validIds.size() ; ++i ) 
      {
         const CaloCellGeometry* cell ( getGeometry( m_validIds[i] ) ) ;
         if( 0 != cell )
         {
            const GlobalPoint& p ( cell->getPosition() ) ;
            const CCGFloat eta0 ( p.eta() ) ;
            if( fabs( eta - eta0 ) < dR )
            {
               const CCGFloat phi0 ( p.phi() ) ;
               CCGFloat delp ( fabs( phi - phi0 ) ) ;
               if( delp > M_PI ) delp = 2*M_PI - delp ;
               if( delp < dR )
               {
                  const CCGFloat dist2 ( reco::deltaR2( eta0, phi0, eta, phi ) ) ;
                  if( dist2 < dR2 ) dss.insert( m_validIds[i] ) ;
               }
            }
         }
      }   
   }
   return dss;
}
DetId CaloSubdetectorGeometry::getClosestCell ( const GlobalPoint r) const [virtual]
const CaloCellGeometry * CaloSubdetectorGeometry::getGeometry ( const DetId id) const [virtual]

Get the cell geometry of a given detector id. Should return false if not found.

Definition at line 44 of file CaloSubdetectorGeometry.cc.

References cellGeomPtr().

Referenced by BetaCalculatorECAL::addStepToXtal(), EcalTPGParamBuilder::analyze(), EcalSelectiveReadoutValidation::analyzeEB(), EcalSelectiveReadoutValidation::analyzeEE(), CaloRecoTauAlgorithm::buildCaloTau(), CaloGeometryHelper::buildCrystalArray(), SuperClusterShapeAlgo::Calculate_Covariances(), ClusterShapeAlgo::Calculate_Covariances(), ClusterShapeAlgo::Calculate_EnergyDepTopology(), PositionCalc::Calculate_Location(), CaloCellCrossing::CaloCellCrossing(), compEcalEnergySum(), compHcalEnergySum(), CaloTowersCreationAlgo::convert(), EcalClusterTools::covariances(), PFRecHitProducerECAL::createEcalRecHit(), PFRecHitProducerHCAL::createHcalRecHit(), DistanceToCell::DistanceToCell(), EcalHitMaker::EcalHitMaker(), InvRingCalib::EERingDef(), HCALRecHitAnalyzer::FillGeometry(), PFRecHitProducerECAL::findEcalRecHitGeometry(), getCells(), EcalEndcapGeometry::getCells(), HcalGeometry::getCells(), EcalBarrelGeometry::getCells(), EcalEndcapGeometry::getClosestBarrelCells(), HcalGeometry::getClosestCell(), getClosestCell(), CaloGeometryHelper::getClosestCell(), CastorGeometry::getClosestCell(), EcalBarrelGeometry::getClosestCell(), EcalEndcapGeometry::getClosestCell(), EcalPreshowerGeometry::getClosestCellInPlane(), HCaloDetIdAssociator::getDetIdPoints(), CaloDetIdAssociator::getDetIdPoints(), L2TauModularIsolationProducer::getECALHits(), L2TauNarrowConeIsolationProducer::getECALHits(), L2TauIsolationProducer::getECALHits(), EcalShowerProperties::getEndpoints(), EcalClusterTools::getEnergyDepTopology(), CaloGeometry::getGeometry(), CaloGeometry::getPosition(), CaloDetIdAssociator::getPosition(), HCaloDetIdAssociator::getPosition(), EcalClusterCrackCorrection::getValue(), EcalClusterLocalContCorrection::getValue(), EcalEndcapRecHitsMaker::init(), EcalBarrelRecHitsMaker::init(), CaloGeometryHelper::initialize(), EcalRingCalibrationTools::initializeFromGeometry(), EcalPreshowerGeometry::initializeParms(), CaloDetIdAssociator::insideElement(), HCaloDetIdAssociator::insideElement(), CosmicClusterAlgo::makeClusters(), Multi5x5ClusterAlgo::makeClusters(), IslandClusterAlgo::makeClusters(), PreshowerClusterAlgo::makeOneCluster(), JetMaker::makeSpecific(), EcalClusterTools::meanClusterPosition(), DistanceToCell::operator()(), present(), PlotEcalRecHits::printEcalRecHits(), PlotSimTracks::printSimTracks(), EcalShowerProperties::processEcalRecHits(), CastorEventDisplay::processEvent(), EcalRecHitWorkerRecover::run(), EcalSelectiveReadoutValidation::setTtEtSums(), EcalSelectiveReadoutSuppressor::setTtFlags(), EcalGeomPhiSymHelper::setup(), CaloHitResponse::timeOfFlight(), and ValidateGeometry::validateCaloGeometry().

{
   return cellGeomPtr( CaloGenericDetId( id ).denseIndex() ) ;
}
void CaloSubdetectorGeometry::getSummary ( CaloSubdetectorGeometry::TrVec tVec,
CaloSubdetectorGeometry::IVec iVec,
CaloSubdetectorGeometry::DimVec dVec 
) const

Definition at line 139 of file CaloSubdetectorGeometry.cc.

References begin, EZArrayFL< T >::begin(), cellGeomPtr(), EZArrayFL< T >::end(), CaloCellGeometry::getPosition(), CaloCellGeometry::getTransform(), i, gen::k, m_validIds, numberOfParametersPerShape(), numberOfShapes(), numberOfTransformParms(), convertSQLiteXML::ok, CaloCellGeometry::param(), and parVecVec().

Referenced by CaloGeometryDBEP< T, U >::produceAligned().

{
   tVec.reserve( m_validIds.size()*numberOfTransformParms() ) ;
   iVec.reserve( numberOfShapes()==1 ? 1 : m_validIds.size() ) ;
   dVec.reserve( numberOfShapes()*numberOfParametersPerShape() ) ;

   for( ParVecVec::const_iterator ivv ( parVecVec().begin() ) ; ivv != parVecVec().end() ; ++ivv )
   {
      const ParVec& pv ( *ivv ) ;
      for( ParVec::const_iterator iv ( pv.begin() ) ; iv != pv.end() ; ++iv )
      {
         dVec.push_back( *iv ) ;
      }
   }

   for( uint32_t i ( 0 ) ; i != m_validIds.size() ; ++i )
   {
      Tr3D tr ;
      const CaloCellGeometry* ptr ( cellGeomPtr( i ) ) ;
      assert( 0 != ptr ) ;
      ptr->getTransform( tr, ( Pt3DVec* ) 0 ) ;

      if( Tr3D() == tr ) // for preshower there is no rotation
      {
         const GlobalPoint& gp ( ptr->getPosition() ) ; 
         tr = HepGeom::Translate3D( gp.x(), gp.y(), gp.z() ) ;
      }

      const CLHEP::Hep3Vector  tt ( tr.getTranslation() ) ;
      tVec.push_back( tt.x() ) ;
      tVec.push_back( tt.y() ) ;
      tVec.push_back( tt.z() ) ;
      if( 6 == numberOfTransformParms() )
      {
         const CLHEP::HepRotation rr ( tr.getRotation() ) ;
         const ROOT::Math::Transform3D rtr ( rr.xx(), rr.xy(), rr.xz(), tt.x(),
                                             rr.yx(), rr.yy(), rr.yz(), tt.y(),
                                             rr.zx(), rr.zy(), rr.zz(), tt.z()  ) ;
         ROOT::Math::EulerAngles ea ;
         rtr.GetRotation( ea ) ;
         tVec.push_back( ea.Phi() ) ;
         tVec.push_back( ea.Theta() ) ;
         tVec.push_back( ea.Psi() ) ;
      }

      const CCGFloat* par ( ptr->param() ) ;

      unsigned int ishape ( 9999 ) ;
      for( unsigned int ivv ( 0 ) ; ivv != parVecVec().size() ; ++ivv )
      {
         bool ok ( true ) ;
         const CCGFloat* pv ( &(*parVecVec()[ivv].begin() ) ) ;
         for( unsigned int k ( 0 ) ; k != numberOfParametersPerShape() ; ++k )
         {
            ok = ok && ( fabs( par[k] - pv[k] ) < 1.e-6 ) ;
         }
         if( ok ) 
         {
            ishape = ivv ;
            break ;
         }
      }
      assert( 9999 != ishape ) ;

      const unsigned int nn (( numberOfShapes()==1) ? (unsigned int)1 : m_validIds.size() ) ; 
      if( iVec.size() < nn ) iVec.push_back( ishape ) ;
   }
}
const std::vector< DetId > & CaloSubdetectorGeometry::getValidDetIds ( DetId::Detector  det = DetId::Detector(0),
int  subdet = 0 
) const [virtual]
virtual void CaloSubdetectorGeometry::initializeParms ( ) [inline, virtual]

Reimplemented in EcalEndcapGeometry, and EcalPreshowerGeometry.

Definition at line 98 of file CaloSubdetectorGeometry.h.

{ return ; } 
virtual void CaloSubdetectorGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
) [pure virtual]
virtual unsigned int CaloSubdetectorGeometry::numberOfParametersPerShape ( ) const [inline, virtual]
virtual unsigned int CaloSubdetectorGeometry::numberOfShapes ( ) const [inline, virtual]
virtual unsigned int CaloSubdetectorGeometry::numberOfTransformParms ( ) const [inline, virtual]

Reimplemented in EcalPreshowerGeometry, and CastorGeometry.

Definition at line 90 of file CaloSubdetectorGeometry.h.

Referenced by getSummary().

{ return 6 ; }
CaloSubdetectorGeometry& CaloSubdetectorGeometry::operator= ( const CaloSubdetectorGeometry ) [private]
ParMgr* CaloSubdetectorGeometry::parMgr ( ) [inline]
const ParMgr* CaloSubdetectorGeometry::parMgrConst ( ) const [inline]

Definition at line 83 of file CaloSubdetectorGeometry.h.

References m_parMgr.

{ return m_parMgr ; }
const ParVecVec& CaloSubdetectorGeometry::parVecVec ( ) const [inline]

Definition at line 86 of file CaloSubdetectorGeometry.h.

References m_parVecVec.

{ return m_parVecVec ; }
ParVecVec& CaloSubdetectorGeometry::parVecVec ( ) [inline]
bool CaloSubdetectorGeometry::present ( const DetId id) const [virtual]

is this detid present in the geometry?

Definition at line 50 of file CaloSubdetectorGeometry.cc.

References getGeometry().

Referenced by spr::extraIds(), EcalBarrelGeometry::getClosestCell(), EcalPreshowerGeometry::getClosestCellInPlane(), EcalShowerProperties::getEndpoints(), and CaloGeometry::present().

{
   return ( 0 != getGeometry( id ) ) ;
}

Member Data Documentation

std::vector<CCGFloat>* CaloSubdetectorGeometry::m_deltaEta [mutable, private]

Definition at line 125 of file CaloSubdetectorGeometry.h.

Referenced by deltaEta(), and ~CaloSubdetectorGeometry().

std::vector<CCGFloat>* CaloSubdetectorGeometry::m_deltaPhi [mutable, private]

Definition at line 124 of file CaloSubdetectorGeometry.h.

Referenced by deltaPhi(), and ~CaloSubdetectorGeometry().

Definition at line 104 of file CaloSubdetectorGeometry.h.

Referenced by parVecVec().

bool CaloSubdetectorGeometry::m_sortedIds [mutable, private]

Definition at line 122 of file CaloSubdetectorGeometry.h.

Referenced by getValidDetIds().

std::vector<DetId> CaloSubdetectorGeometry::m_validIds [mutable, protected]