CMS 3D CMS Logo

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

HcalDDDGeometry Class Reference

#include <HcalDDDGeometry.h>

Inheritance diagram for HcalDDDGeometry:
CaloSubdetectorGeometry

List of all members.

Public Types

typedef std::vector
< IdealObliquePrism
HBCellVec
typedef std::vector
< IdealObliquePrism
HECellVec
typedef std::vector< IdealZPrismHFCellVec
typedef std::vector
< IdealObliquePrism
HOCellVec

Public Member Functions

virtual DetId getClosestCell (const GlobalPoint &r) 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)
 HcalDDDGeometry (const HcalTopology &theTopo)
int insertCell (std::vector< HcalCellType > const &)
virtual void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
virtual ~HcalDDDGeometry ()
 The HcalDDDGeometry will delete all its cell geometries at destruction time.

Protected Member Functions

virtual const CaloCellGeometrycellGeomPtr (uint32_t index) const

Private Attributes

double deg
double etaMax_
double firstHFQuadRing_
std::vector< HcalCellTypehcalCells_
DetId::Detector lastReqDet_
int lastReqSubdet_
HBCellVec m_hbCellVec
HECellVec m_heCellVec
HFCellVec m_hfCellVec
HOCellVec m_hoCellVec
std::vector< DetIdm_validIds
const HcalTopologytopo_
double twopi

Detailed Description

Definition at line 18 of file HcalDDDGeometry.h.


Member Typedef Documentation

Definition at line 22 of file HcalDDDGeometry.h.

Definition at line 23 of file HcalDDDGeometry.h.

Definition at line 25 of file HcalDDDGeometry.h.

Definition at line 24 of file HcalDDDGeometry.h.


Constructor & Destructor Documentation

HcalDDDGeometry::HcalDDDGeometry ( const HcalTopology theTopo) [explicit]

Definition at line 10 of file HcalDDDGeometry.cc.

References deg, M_PI, and twopi.

                                                         : topo_(topo),
   lastReqDet_(DetId::Detector(0)), 
   lastReqSubdet_(0),
   etaMax_(0),
   firstHFQuadRing_(40) ,
                                                             m_hbCellVec ( topo.getHBSize() ) ,
                                                             m_heCellVec ( topo.getHESize() ) ,
                                                             m_hoCellVec ( topo.getHOSize() ) ,
                                                             m_hfCellVec ( topo.getHFSize() ) 
{
  twopi = M_PI + M_PI;
  deg   = M_PI/180.;
}
HcalDDDGeometry::~HcalDDDGeometry ( ) [virtual]

The HcalDDDGeometry will delete all its cell geometries at destruction time.

Definition at line 25 of file HcalDDDGeometry.cc.

{
}

Member Function Documentation

const CaloCellGeometry * HcalDDDGeometry::cellGeomPtr ( uint32_t  index) const [protected, virtual]

Implements CaloSubdetectorGeometry.

Definition at line 190 of file HcalDDDGeometry.cc.

References cropTnPTrees::din, getHLTprescales::index, m_hbCellVec, m_heCellVec, m_hfCellVec, m_hoCellVec, and CaloCellGeometry::param().

{
   const CaloCellGeometry* cell ( 0 ) ;
   if( m_hbCellVec.size() > din )
   {
      cell = &m_hbCellVec[ din ] ;
   }
   else
   {
      if( m_hbCellVec.size() +
          m_heCellVec.size() > din )
      {
         const unsigned int index ( din - m_hbCellVec.size() ) ;
         cell = &m_heCellVec[ index ] ;
      }
      else
      {
         if( m_hbCellVec.size() +
             m_heCellVec.size() +
             m_hoCellVec.size() > din )
         {
            const unsigned int index ( din 
                                       - m_hbCellVec.size() 
                                       - m_heCellVec.size() ) ;
            cell = &m_hoCellVec[ index ] ;
         }
         else
         {
            if( m_hbCellVec.size() +
                m_heCellVec.size() +
                m_hoCellVec.size() +
                m_hfCellVec.size() > din )
            {
               const unsigned int index ( din 
                                          - m_hbCellVec.size() 
                                          - m_heCellVec.size() 
                                          - m_hoCellVec.size() ) ;
               cell = &m_hfCellVec[ index ] ;
            }
         }
      }
   }
   return ( 0 == cell || 0 == cell->param() ? 0 : cell ) ;
}
DetId HcalDDDGeometry::getClosestCell ( const GlobalPoint r) const [virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 64 of file HcalDDDGeometry.cc.

References deg, PV3DBase< T, PVType, FrameType >::eta(), etaMax_, jptDQMConfig_cff::etaMin, hcalCells_, HcalForward, i, LogDebug, PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::phi(), phi, CosmicsPD_Skims::radius, twopi, PV3DBase< T, PVType, FrameType >::z(), and z.

                                                                {

  // Now find the closest eta_bin, eta value of a bin i is average
  // of eta[i] and eta[i-1]
  double abseta = fabs(r.eta());
  double phi    = r.phi();
  if (phi < 0) phi += twopi;
  double radius = r.mag();
  double z      = fabs(r.z());
#ifdef DebugLog
  LogDebug("HCalGeom") << "HcalDDDGeometry::getClosestCell for eta "
                       << r.eta() << " phi " << phi/deg << " z " << r.z()
                       << " radius " << radius;
#endif

  HcalDetId bestId;
  if (abseta <= etaMax_) {
    for (unsigned int i=0; i<hcalCells_.size(); i++) {
      if (abseta >=hcalCells_[i].etaMin() && abseta <=hcalCells_[i].etaMax()) {
        HcalSubdetector bc = hcalCells_[i].detType();
        int etaring = hcalCells_[i].etaBin();
        int phibin  = 0;
        if (hcalCells_[i].unitPhi() == 4) {
          // rings 40 and 41 are offset wrt the other phi numbering
          //  1        1         1         2
          //  ------------------------------
          //  72       36        36        1
          phibin = static_cast<int>(((phi/deg)+hcalCells_[i].phiOffset()+
                                     0.5*hcalCells_[i].phiBinWidth())/
                                    hcalCells_[i].phiBinWidth());
          if (phibin == 0) phibin = hcalCells_[i].nPhiBins();
          phibin = phibin*4 - 1; 
        } else {
          phibin = static_cast<int>(((phi/deg)+hcalCells_[i].phiOffset())/
                                    hcalCells_[i].phiBinWidth()) + 1;
          // convert to the convention of numbering 1,3,5, in 36 phi bins
          phibin = (phibin-1)*(hcalCells_[i].unitPhi()) + 1;
        }

        int dbin   = 1;
        int etabin = (r.z() > 0) ? etaring : -etaring;
        if (bc == HcalForward) {
          bestId   = HcalDetId(bc, etabin, phibin, dbin);
          break;
        } else {
          double rz = z;
          if (hcalCells_[i].depthType()) rz = radius;
          if (rz < hcalCells_[i].depthMax()) {
            dbin   = hcalCells_[i].depthSegment();
            bestId = HcalDetId(bc, etabin, phibin, dbin);
            break;
          }
        }
      }
    }
  }
#ifdef DebugLog
  LogDebug("HCalGeom") << "HcalDDDGeometry::getClosestCell " << bestId;
#endif
  return bestId;
}
std::vector< DetId > const & HcalDDDGeometry::getValidDetIds ( DetId::Detector  det = DetId::Detector ( 0 ),
int  subdet = 0 
) const [virtual]

Get a list of valid detector ids (for the given subdetector)

Note:
The implementation in this class is relevant for SubdetectorGeometries which handle only a single subdetector at a time. It does not look at the det and subdet arguments.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 30 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::getValidDetIds(), i, lastReqDet_, lastReqSubdet_, LogDebug, m_validIds, and python::multivaluedict::sort().

                                                                             {

  const std::vector<DetId>& baseIds(CaloSubdetectorGeometry::getValidDetIds());
  if (det    == DetId::Detector( 0 ) && subdet == 0) {
    return baseIds ;
  }
   
  if (lastReqDet_  != det || lastReqSubdet_ != subdet ) {
    lastReqDet_     = det    ;
    lastReqSubdet_  = subdet ;
    m_validIds.clear();
    m_validIds.reserve( baseIds.size() ) ;
  }

  if (m_validIds.empty() ) {
    for (unsigned int i = 0 ; i != baseIds.size() ; ++i ) {
      const DetId id ( baseIds[i] );
      if (id.det()      == det   && id.subdetId() == subdet ) { 
        m_validIds.push_back( id ) ;
      }
    }
    std::sort(m_validIds.begin(),m_validIds.end());
  }
  
#ifdef DebugLog
  LogDebug("HCalGeom") << "HcalDDDGeometry::getValidDetIds: "
                       << m_validIds.size() << " valid IDs found for detector "
                       << det << " Sub-detector " << subdet;
#endif
  return m_validIds;
}
int HcalDDDGeometry::insertCell ( std::vector< HcalCellType > const &  cells)

Definition at line 127 of file HcalDDDGeometry.cc.

References jptDQMConfig_cff::etaMax, etaMax_, hcalCells_, i, and LogDebug.

Referenced by HcalDDDGeometryLoader::fill().

                                                                    {

  hcalCells_.insert(hcalCells_.end(), cells.begin(), cells.end());
  int num = static_cast<int>(hcalCells_.size());
  for (unsigned int i=0; i<cells.size(); i++) {
    if (cells[i].etaMax() > etaMax_ ) etaMax_ = cells[i].etaMax();
  }
#ifdef DebugLog
  LogDebug("HCalGeom") << "HcalDDDGeometry::insertCell " << cells.size()
                       << " cells inserted == Total " << num
                       << " EtaMax = " << etaMax_;
#endif
  return num;
}
void HcalDDDGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
) [virtual]

Implements CaloSubdetectorGeometry.

Definition at line 143 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::cornersMgr(), DetId::det(), HcalTopology::detId2denseId(), cropTnPTrees::din, DetId::Hcal, HcalBarrel, HcalEndcap, HcalOuter, getHLTprescales::index, m_hbCellVec, m_heCellVec, m_hfCellVec, m_hoCellVec, m_validIds, and topo_.

{

   assert( detId.det()==DetId::Hcal );
  
   const unsigned int din(topo_.detId2denseId(detId));

   HcalDetId hId(detId);

   if( hId.subdet()==HcalBarrel )
   {
      m_hbCellVec[ din ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
   }
   else
   {
     if( hId.subdet()==HcalEndcap )
      {
         const unsigned int index ( din - m_hbCellVec.size() ) ;
         m_heCellVec[ index ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
      }
      else
      {
        if( hId.subdet()==HcalOuter )
         {
            const unsigned int index ( din 
                                       - m_hbCellVec.size() 
                                       - m_heCellVec.size() ) ;
            m_hoCellVec[ index ] = IdealObliquePrism( f1, cornersMgr(), parm ) ;
         }
         else
           { // assuming HcalForward here!
            const unsigned int index ( din 
                                       - m_hbCellVec.size() 
                                       - m_heCellVec.size() 
                                       - m_hoCellVec.size() ) ;
            m_hfCellVec[ index ] = IdealZPrism( f1, cornersMgr(), parm ) ;
         }
      }
   }
   m_validIds.push_back( detId ) ;
}

Member Data Documentation

double HcalDDDGeometry::deg [private]

Definition at line 58 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and HcalDDDGeometry().

double HcalDDDGeometry::etaMax_ [private]

Definition at line 59 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

Definition at line 59 of file HcalDDDGeometry.h.

std::vector<HcalCellType> HcalDDDGeometry::hcalCells_ [private]

Definition at line 52 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

Definition at line 55 of file HcalDDDGeometry.h.

Referenced by getValidDetIds().

int HcalDDDGeometry::lastReqSubdet_ [mutable, private]

Definition at line 56 of file HcalDDDGeometry.h.

Referenced by getValidDetIds().

Definition at line 61 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCell().

Definition at line 62 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCell().

Definition at line 64 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCell().

Definition at line 63 of file HcalDDDGeometry.h.

Referenced by cellGeomPtr(), and newCell().

std::vector<DetId> HcalDDDGeometry::m_validIds [mutable, private]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 50 of file HcalDDDGeometry.h.

Referenced by getValidDetIds(), and newCell().

Definition at line 54 of file HcalDDDGeometry.h.

Referenced by newCell().

double HcalDDDGeometry::twopi [private]

Definition at line 58 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and HcalDDDGeometry().