CMS 3D CMS Logo

Public Member Functions | Private Attributes

HcalDDDGeometry Class Reference

#include <HcalDDDGeometry.h>

Inheritance diagram for HcalDDDGeometry:
CaloSubdetectorGeometry

List of all members.

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 ()
int insertCell (std::vector< HcalCellType > const &)
virtual ~HcalDDDGeometry ()
 The HcalDDDGeometry will delete all its cell geometries at destruction time.

Private Attributes

double deg
double etaMax_
double firstHFQuadRing_
std::vector< HcalCellTypehcalCells_
DetId::Detector lastReqDet_
int lastReqSubdet_
std::vector< DetIdm_validIds
double twopi

Detailed Description

Definition at line 10 of file HcalDDDGeometry.h.


Constructor & Destructor Documentation

HcalDDDGeometry::HcalDDDGeometry ( ) [explicit]

Definition at line 10 of file HcalDDDGeometry.cc.

References deg, M_PI, and twopi.

HcalDDDGeometry::~HcalDDDGeometry ( ) [virtual]

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

Definition at line 18 of file HcalDDDGeometry.cc.

{}

Member Function Documentation

DetId HcalDDDGeometry::getClosestCell ( const GlobalPoint r) const [virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 55 of file HcalDDDGeometry.cc.

References deg, PV3DBase< T, PVType, FrameType >::eta(), etaMax_, ExpressReco_HICollisions_FallBack::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 21 of file HcalDDDGeometry.cc.

References CaloSubdetectorGeometry::getValidDetIds(), i, ExpressReco_HICollisions_FallBack::id, 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 118 of file HcalDDDGeometry.cc.

References ExpressReco_HICollisions_FallBack::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;
}

Member Data Documentation

double HcalDDDGeometry::deg [private]

Definition at line 33 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and HcalDDDGeometry().

double HcalDDDGeometry::etaMax_ [private]

Definition at line 34 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

Definition at line 34 of file HcalDDDGeometry.h.

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

Definition at line 29 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and insertCell().

Definition at line 30 of file HcalDDDGeometry.h.

Referenced by getValidDetIds().

int HcalDDDGeometry::lastReqSubdet_ [mutable, private]

Definition at line 31 of file HcalDDDGeometry.h.

Referenced by getValidDetIds().

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

Reimplemented from CaloSubdetectorGeometry.

Definition at line 27 of file HcalDDDGeometry.h.

Referenced by getValidDetIds().

double HcalDDDGeometry::twopi [private]

Definition at line 33 of file HcalDDDGeometry.h.

Referenced by getClosestCell(), and HcalDDDGeometry().