CMS 3D CMS Logo

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

HcalGeometry Class Reference

#include <HcalGeometry.h>

Inheritance diagram for HcalGeometry:
CaloSubdetectorGeometry

List of all members.

Public Types

enum  { k_NumberOfParametersPerShape = 5 }
typedef HcalGeometryRecord AlignedRecord
typedef HcalAlignmentRcd AlignmentRecord
typedef CaloCellGeometry::CCGFloat CCGFloat
typedef HcalDetId DetIdType
typedef std::vector
< IdealObliquePrism
HBCellVec
typedef std::vector
< IdealObliquePrism
HECellVec
typedef std::vector< IdealZPrismHFCellVec
typedef std::vector
< IdealObliquePrism
HOCellVec
typedef PHcalRcd PGeometryRecord
typedef CaloCellGeometry::Pt3D Pt3D
typedef CaloCellGeometry::Pt3DVec Pt3DVec

Public Member Functions

virtual
CaloSubdetectorGeometry::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.
virtual void getSummary (CaloSubdetectorGeometry::TrVec &trVector, CaloSubdetectorGeometry::IVec &iVector, CaloSubdetectorGeometry::DimVec &dimVector, std::vector< uint32_t > &dins) 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)
 HcalGeometry (const HcalTopology &topology)
void localCorners (Pt3DVec &lc, const CCGFloat *pv, unsigned int i, Pt3D &ref)
virtual void newCell (const GlobalPoint &f1, const GlobalPoint &f2, const GlobalPoint &f3, const CCGFloat *parm, const DetId &detId)
virtual unsigned int numberOfParametersPerShape () const
virtual unsigned int numberOfShapes () const
virtual ~HcalGeometry ()
 The HcalGeometry will delete all its cell geometries at destruction time.

Static Public Member Functions

static unsigned int alignmentBarEndForIndexLocal (const DetId &id, unsigned int nD)
static unsigned int alignmentBarrelIndexLocal (const DetId &id)
static unsigned int alignmentEndcapIndexLocal (const DetId &id)
static unsigned int alignmentForwardIndexLocal (const DetId &id)
static unsigned int alignmentOuterIndexLocal (const DetId &id)
static unsigned int alignmentTransformIndexGlobal (const DetId &id)
static unsigned int alignmentTransformIndexLocal (const DetId &id)
static std::string dbString ()
static DetId detIdFromBarrelAlignmentIndex (unsigned int i)
static DetId detIdFromEndcapAlignmentIndex (unsigned int i)
static DetId detIdFromForwardAlignmentIndex (unsigned int i)
static DetId detIdFromLocalAlignmentIndex (unsigned int i)
static DetId detIdFromOuterAlignmentIndex (unsigned int i)
static unsigned int numberOfAlignments ()
static unsigned int numberOfBarrelAlignments ()
static unsigned int numberOfEndcapAlignments ()
static unsigned int numberOfForwardAlignments ()
static unsigned int numberOfOuterAlignments ()
static std::string producerTag ()

Protected Member Functions

virtual const CaloCellGeometrycellGeomPtr (uint32_t index) const
virtual unsigned int indexFor (const DetId &id) const
virtual unsigned int sizeForDenseIndex (const DetId &id) const

Private Member Functions

int etaRing (HcalSubdetector bc, double abseta) const
 helper methods for getClosestCell
void fillDetIds () const
void init ()
int phiBin (double phi, int etaring) const

Private Attributes

std::vector< uint32_t > m_dins
std::vector< DetIdm_emptyIds
HBCellVec m_hbCellVec
std::vector< DetIdm_hbIds
HECellVec m_heCellVec
std::vector< DetIdm_heIds
HFCellVec m_hfCellVec
std::vector< DetIdm_hfIds
HOCellVec m_hoCellVec
std::vector< DetIdm_hoIds
const HcalTopologytheTopology

Detailed Description

Definition at line 12 of file HcalGeometry.h.


Member Typedef Documentation

Definition at line 26 of file HcalGeometry.h.

Definition at line 25 of file HcalGeometry.h.

Reimplemented from CaloSubdetectorGeometry.

Definition at line 21 of file HcalGeometry.h.

Definition at line 28 of file HcalGeometry.h.

Definition at line 16 of file HcalGeometry.h.

Definition at line 17 of file HcalGeometry.h.

typedef std::vector<IdealZPrism> HcalGeometry::HFCellVec

Definition at line 19 of file HcalGeometry.h.

Definition at line 18 of file HcalGeometry.h.

Definition at line 27 of file HcalGeometry.h.

Definition at line 22 of file HcalGeometry.h.

Definition at line 23 of file HcalGeometry.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
k_NumberOfParametersPerShape 

Definition at line 31 of file HcalGeometry.h.


Constructor & Destructor Documentation

HcalGeometry::HcalGeometry ( const HcalTopology topology) [explicit]

Definition at line 15 of file HcalGeometry.cc.

References init().

                                                         :
  theTopology( topology ) {
  init();
}
HcalGeometry::~HcalGeometry ( ) [virtual]

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

Definition at line 21 of file HcalGeometry.cc.

{}

Member Function Documentation

unsigned int HcalGeometry::alignmentBarEndForIndexLocal ( const DetId id,
unsigned int  nD 
) [static]

Definition at line 358 of file HcalGeometry.cc.

References HcalDetId::ieta(), getHLTprescales::index, createXMLFile::iphi, and HcalDetId::iphi().

Referenced by alignmentBarrelIndexLocal(), alignmentEndcapIndexLocal(), and alignmentForwardIndexLocal().

{
   const HcalDetId hid ( id ) ;
   const unsigned int iphi ( hid.iphi() ) ;
   const int ieta ( hid.ieta() ) ;
   const unsigned int index ( ( 0 < ieta ? nD/2 : 0 ) + ( iphi + 1 )%72/4 ) ;
   assert( index < nD ) ;
   return index ;
}
unsigned int HcalGeometry::alignmentBarrelIndexLocal ( const DetId id) [static]
unsigned int HcalGeometry::alignmentEndcapIndexLocal ( const DetId id) [static]
unsigned int HcalGeometry::alignmentForwardIndexLocal ( const DetId id) [static]
unsigned int HcalGeometry::alignmentOuterIndexLocal ( const DetId id) [static]

Definition at line 387 of file HcalGeometry.cc.

References HcalDetId::ieta(), getHLTprescales::index, createXMLFile::iphi, HcalDetId::iphi(), numberOfOuterAlignments(), and relativeConstraints::ring.

Referenced by alignmentTransformIndexLocal().

{
   const HcalDetId hid ( id ) ;
   const int ieta ( hid.ieta() ) ;
   const int iphi ( hid.iphi() ) ;
   const int ring ( ieta < -10 ? 0 :
                    ( ieta < -4 ? 1 :
                      ( ieta < 5 ? 2 :
                        ( ieta < 11 ? 3 : 4 ) ) ) ) ;

   const unsigned int index ( 12*ring + ( iphi - 1 )/6 ) ;
   assert( index < numberOfOuterAlignments() ) ;
   return index ;
}
unsigned int HcalGeometry::alignmentTransformIndexGlobal ( const DetId id) [static]

Definition at line 430 of file HcalGeometry.cc.

References DetId::Hcal.

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

{
   return (unsigned int)DetId::Hcal - 1 ;
}
unsigned int HcalGeometry::alignmentTransformIndexLocal ( const DetId id) [static]

Definition at line 403 of file HcalGeometry.cc.

References alignmentBarrelIndexLocal(), alignmentEndcapIndexLocal(), alignmentForwardIndexLocal(), alignmentOuterIndexLocal(), DetId::Hcal, HcalBarrel, HcalEndcap, HcalForward, getHLTprescales::index, isHB(), isHE(), isHF(), numberOfAlignments(), numberOfBarrelAlignments(), numberOfEndcapAlignments(), numberOfForwardAlignments(), and HcalDetId::subdet().

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

{
   assert(id.det() == DetId::Hcal) ;

   const HcalDetId hid ( id ) ;
   bool isHB = (hid.subdet() == HcalBarrel);
   bool isHE = (hid.subdet() == HcalEndcap);
   bool isHF = (hid.subdet() == HcalForward);
   // bool isHO = (hid.subdet() == HcalOuter);

   const unsigned int nB ( numberOfBarrelAlignments()  ) ;
   const unsigned int nE ( numberOfEndcapAlignments()  ) ;
   const unsigned int nF ( numberOfForwardAlignments() ) ;
   // const unsigned int nO ( numberOfOuterAlignments()   ) ;

   const unsigned int index ( 
      isHB ? alignmentBarrelIndexLocal(id) :
      isHE ? alignmentEndcapIndexLocal(id) + nB :
      isHF ? alignmentForwardIndexLocal( id ) + nB + nE :
      alignmentOuterIndexLocal(id) + nB + nE + nF
                              );

   assert( index < numberOfAlignments() ) ;
   return index ;
}
const CaloCellGeometry * HcalGeometry::cellGeomPtr ( uint32_t  index) const [protected, virtual]

Implements CaloSubdetectorGeometry.

Definition at line 494 of file HcalGeometry.cc.

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

Referenced by getGeometry(), and getSummary().

{
   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 ) ;
}
static std::string HcalGeometry::dbString ( ) [inline, static]

Definition at line 33 of file HcalGeometry.h.

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

{ return "PHcalRcd" ; }
DetId HcalGeometry::detIdFromBarrelAlignmentIndex ( unsigned int  i) [static]

Definition at line 302 of file HcalGeometry.cc.

References HcalBarrel, createXMLFile::iphi, and numberOfBarrelAlignments().

Referenced by detIdFromLocalAlignmentIndex(), FakeCaloAlignmentEP::produceHBAli(), and TestCaloAlignmentEP::produceHBAli().

{
   assert( i < numberOfBarrelAlignments() ) ;
   const int ieta  ( i < numberOfBarrelAlignments()/2 ? -1 : 1 ) ;
   const int iphi ( 1 + (4*i)%72 ) ;
   return HcalDetId( HcalBarrel, ieta, iphi, 1 ) ;
}
DetId HcalGeometry::detIdFromEndcapAlignmentIndex ( unsigned int  i) [static]

Definition at line 311 of file HcalGeometry.cc.

References HcalEndcap, createXMLFile::iphi, and numberOfEndcapAlignments().

Referenced by detIdFromLocalAlignmentIndex(), TestCaloAlignmentEP::produceHEAli(), and FakeCaloAlignmentEP::produceHEAli().

{
   assert( i < numberOfEndcapAlignments() ) ;
   const int ieta  ( i < numberOfEndcapAlignments()/2 ? -16 : 16 ) ;
   const int iphi ( 1 + (4*i)%72 ) ;
   return HcalDetId( HcalEndcap, ieta, iphi, 1 ) ;
}
DetId HcalGeometry::detIdFromForwardAlignmentIndex ( unsigned int  i) [static]

Definition at line 320 of file HcalGeometry.cc.

References HcalForward, createXMLFile::iphi, and numberOfForwardAlignments().

Referenced by detIdFromLocalAlignmentIndex(), FakeCaloAlignmentEP::produceHFAli(), and TestCaloAlignmentEP::produceHFAli().

{
   assert( i < numberOfForwardAlignments() ) ;
   const int ieta ( i < numberOfForwardAlignments()/2 ? -29 : 29 ) ;
   const int iphi ( 1 + (4*i)%72 ) ;
   return HcalDetId( HcalForward, ieta, iphi, 1 ) ;
}
DetId HcalGeometry::detIdFromLocalAlignmentIndex ( unsigned int  i) [static]

Definition at line 342 of file HcalGeometry.cc.

References detIdFromBarrelAlignmentIndex(), detIdFromEndcapAlignmentIndex(), detIdFromForwardAlignmentIndex(), detIdFromOuterAlignmentIndex(), numberOfAlignments(), numberOfBarrelAlignments(), numberOfEndcapAlignments(), and numberOfForwardAlignments().

{
   assert( i < numberOfAlignments() ) ;

   const unsigned int nB ( numberOfBarrelAlignments()  ) ;
   const unsigned int nE ( numberOfEndcapAlignments()  ) ;
   const unsigned int nF ( numberOfForwardAlignments() ) ;
//   const unsigned int nO ( numberOfOuterAlignments()   ) ;

   return (  i < nB       ? detIdFromBarrelAlignmentIndex( i ) :
             i < nB+nE    ? detIdFromEndcapAlignmentIndex( i - nB ) :
             i < nB+nE+nF ? detIdFromForwardAlignmentIndex( i - nB - nE ) :
             detIdFromOuterAlignmentIndex( i - nB - nE - nF ) ) ;
}
DetId HcalGeometry::detIdFromOuterAlignmentIndex ( unsigned int  i) [static]

Definition at line 329 of file HcalGeometry.cc.

References HcalOuter, createXMLFile::iphi, numberOfOuterAlignments(), and relativeConstraints::ring.

Referenced by detIdFromLocalAlignmentIndex(), FakeCaloAlignmentEP::produceHOAli(), and TestCaloAlignmentEP::produceHOAli().

{
   assert( i < numberOfOuterAlignments() ) ;
   const int ring ( i/12 ) ;
   const int ieta ( 0 == ring ? -11 :
                    1 == ring ? -5  :
                    2 == ring ?  1  :
                    3 == ring ?  5  : 11 ) ;
   const int iphi ( 1 + ( i - ring*12 )*6 ) ;
   return HcalDetId( HcalOuter, ieta, iphi, 4 ) ;
}
int HcalGeometry::etaRing ( HcalSubdetector  bc,
double  abseta 
) const [private]

helper methods for getClosestCell

Definition at line 170 of file HcalGeometry.cc.

References HcalTopology::firstHFRing(), HcalForward, HcalTopology::lastHERing(), HcalTopology::lastHFRing(), theHBHEEtaBounds, theHFEtaBounds, and theTopology.

Referenced by getCells(), and getClosestCell().

{
  int etaring;
  if( bc == HcalForward ) {
    for(etaring = theTopology.firstHFRing();
        etaring <= theTopology.lastHFRing(); ++etaring)
    {
      if(theHFEtaBounds[etaring-theTopology.firstHFRing()+1] > abseta) break;
    }
  }
  else
  {
    for(etaring = 1;
        etaring <= theTopology.lastHERing(); ++etaring)
    {
      if(theHBHEEtaBounds[etaring] >= abseta) break;
    }
  }

  return etaring;
}
void HcalGeometry::fillDetIds ( ) const [private]

Definition at line 38 of file HcalGeometry.cc.

References CaloSubdetectorGeometry::getValidDetIds(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, i, m_emptyIds, m_hbIds, m_heIds, m_hfIds, m_hoIds, and python::multivaluedict::sort().

Referenced by getValidDetIds().

{
   const std::vector<DetId>& baseIds ( CaloSubdetectorGeometry::getValidDetIds() ) ;
   for( unsigned int i ( 0 ) ; i != baseIds.size() ; ++i ) 
   {
      const DetId id ( baseIds[i] );
      if( id.subdetId() == HcalBarrel )
      { 
         m_hbIds.push_back( id ) ;
      }
      else
      {
         if( id.subdetId() == HcalEndcap )
         { 
            m_heIds.push_back( id ) ;
         }
         else
         {
            if( id.subdetId() == HcalOuter )
            { 
               m_hoIds.push_back( id ) ;
            }
            else
            {
               if( id.subdetId() == HcalForward )
               { 
                  m_hfIds.push_back( id ) ;
               }
            }
         }
      }
   }
   std::sort( m_hbIds.begin(), m_hbIds.end() ) ;
   std::sort( m_heIds.begin(), m_heIds.end() ) ;
   std::sort( m_hoIds.begin(), m_hoIds.end() ) ;
   std::sort( m_hfIds.begin(), m_hfIds.end() ) ;

   m_emptyIds.resize( 0 ) ;
}
CaloSubdetectorGeometry::DetIdSet HcalGeometry::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 from CaloSubdetectorGeometry.

Definition at line 222 of file HcalGeometry.cc.

References reco::deltaR2(), eta, PV3DBase< T, PVType, FrameType >::eta(), etaRing(), HcalTopology::firstHFRing(), getGeometry(), CaloCellGeometry::getPosition(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, createXMLFile::iphi, HcalTopology::lastHFRing(), M_PI, AlCaHLTBitMon_ParallelJobs::p, PV3DBase< T, PVType, FrameType >::phi(), phi, phiBin(), theHFEtaBounds, theTopology, and HcalTopology::valid().

{
   CaloSubdetectorGeometry::DetIdSet dis;  // this is the return object

   if( 0.000001 < dR )
   {
      if( dR > M_PI/2. ) // this version needs "small" dR
      {
         dis = CaloSubdetectorGeometry::getCells( r, dR ) ; // base class version
      }
      else
      {
         const double dR2     ( dR*dR ) ;
         const double reta    ( r.eta() ) ;
         const double rphi    ( r.phi() ) ;
         const double lowEta  ( reta - dR ) ;
         const double highEta ( reta + dR ) ;
         const double lowPhi  ( rphi - dR ) ;
         const double highPhi ( rphi + dR ) ;
         
         const double hfEtaHi ( theHFEtaBounds[ theTopology.lastHFRing() -
                                                theTopology.firstHFRing() + 1 ] ) ;
         
         if( highEta > -hfEtaHi &&
             lowEta  <  hfEtaHi    ) // in hcal
         {
            const HcalSubdetector hs[] = { HcalBarrel, HcalOuter, HcalEndcap, HcalForward } ;

            for( unsigned int is ( 0 ) ; is != 4 ; ++is )
            {
               const int sign        (  reta>0 ? 1 : -1 ) ;
               const int ieta_center ( sign*etaRing( hs[is], fabs( reta ) ) ) ;
               const int ieta_lo     ( ( 0 < lowEta*sign ? sign : -sign )*etaRing( hs[is], fabs( lowEta ) ) ) ;
               const int ieta_hi     ( ( 0 < highEta*sign ? sign : -sign )*etaRing( hs[is], fabs( highEta ) ) ) ;
               const int iphi_lo     ( phiBin( lowPhi , ieta_center ) ) ;
               const int iphi_hi     ( phiBin( highPhi, ieta_center ) ) ;
               const int jphi_lo     ( iphi_lo>iphi_hi ? iphi_lo - 72 : iphi_lo ) ;
               const int jphi_hi     ( iphi_hi ) ;

               const int idep_lo     ( 1 == is ? 4 : 1 ) ;
               const int idep_hi     ( 1 == is ? 4 :
                                       ( 2 == is ? 3 : 2 ) ) ;
               for( int ieta ( ieta_lo ) ; ieta <= ieta_hi ; ++ieta ) // over eta limits
               {
                  if( ieta != 0 )
                  {
                     for( int jphi ( jphi_lo ) ; jphi <= jphi_hi ; ++jphi )  // over phi limits
                     {
                        const int iphi ( 1 > jphi ? jphi+72 : jphi ) ;

                        for( int idep ( idep_lo ) ; idep <= idep_hi ; ++idep )
                          {
                            const HcalDetId did ( hs[is], ieta, iphi, idep ) ;
                            if( theTopology.valid(did) ) 

                              {
                              const CaloCellGeometry* cell ( getGeometry( did ) );
                              if( 0 != cell )
                              {
                                 const GlobalPoint& p   ( cell->getPosition() ) ;
                                 const double       eta ( p.eta() ) ;
                                 const double       phi ( p.phi() ) ;
                                 if( reco::deltaR2( eta, phi, reta, rphi ) < dR2 ) dis.insert( did ) ;
                              }
                           }
                        }
                     }
                  }
               }
            }
         }
      }
   }
   return dis;
}
DetId HcalGeometry::getClosestCell ( const GlobalPoint r) const [virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 91 of file HcalGeometry.cc.

References abs, PV3DBase< T, PVType, FrameType >::eta(), etaRing(), getGeometry(), CaloCellGeometry::getPosition(), HcalBarrel, HcalEmpty, HcalEndcap, HcalForward, HcalTopology::incrementDepth(), HcalTopology::lastHBRing(), HcalTopology::lastHERing(), HcalTopology::lastHFRing(), PV3DBase< T, PVType, FrameType >::mag(), PV3DBase< T, PVType, FrameType >::phi(), phiBin(), theHBHEEtaBounds, theTopology, and PV3DBase< T, PVType, FrameType >::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());
  
  // figure out subdetector, giving preference to HE in HE/HF overlap region
  HcalSubdetector bc= HcalEmpty;
  if (abseta <= theHBHEEtaBounds[theTopology.lastHBRing()] ) {
    bc = HcalBarrel;
  } else if (abseta <= theHBHEEtaBounds[theTopology.lastHERing()] ) {
    bc = HcalEndcap;
  } else {
    bc = HcalForward;
  }

  if (bc == HcalForward) {
    static const double z_short=1137.0;
    int etaring = etaRing(bc, abseta);  // This is safer
    /*
      static const double z_long=1115.0;
      // determine front-face eta
      double radius=sqrt(pow(r.x(),2)+pow(r.y(),2));
      double trueAeta=asinh(z_long/radius);
      // find eta bin
      int etaring = etaRing(bc, trueAeta);
    */
    if (etaring>theTopology.lastHFRing()) etaring=theTopology.lastHFRing(); 
  
    int phibin = phiBin(r.phi(), etaring);

    // add a sign to the etaring
    int etabin = (r.z() > 0) ? etaring : -etaring;
    // Next line is premature depth 1 and 2 can coexist for large z-extent
    //    HcalDetId bestId(bc,etabin,phibin,((fabs(r.z())>=z_short)?(2):(1)));
    // above line is no good with finite precision
    HcalDetId bestId(bc,etabin,phibin,((fabs(r.z()) - z_short >-0.1)?(2):(1)));
    return bestId;
  } else {

    // find eta bin
    int etaring = etaRing(bc, abseta);
    
    int phibin = phiBin(r.phi(), etaring);
    
    // add a sign to the etaring
    int etabin = (r.z() > 0) ? etaring : -etaring;
    
    //Now do depth if required
    int dbin = 1;
    double pointrz=0, drz=99999.;
    HcalDetId currentId(bc, etabin, phibin, dbin);
    if (bc == HcalBarrel) pointrz = r.mag();
    else                  pointrz = std::abs(r.z());
    HcalDetId bestId;
//    std::cout << "Current ID " << currentId << std::endl;
    for ( ; currentId != HcalDetId(); theTopology.incrementDepth(currentId)) {
//      std::cout << "Incremented Current ID " << currentId << std::endl;
      const CaloCellGeometry * cell = getGeometry(currentId);
      if (cell == 0) {
//      std::cout << "Cell 0 for " << currentId << " Best " << bestId << " dummy " << HcalDetId() << std::endl;
        assert (bestId != HcalDetId());
        break;
      } else {
        double rz;
        if (bc == HcalEndcap) rz = std::abs(cell->getPosition().z());
        else                  rz = cell->getPosition().mag();
        if (std::abs(pointrz-rz)<drz) {
          bestId = currentId;
          drz    = std::abs(pointrz-rz);
        }
      }
    }
    
    return bestId;
  }
}
virtual const CaloCellGeometry* HcalGeometry::getGeometry ( const DetId id) const [inline, virtual]

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

Reimplemented from CaloSubdetectorGeometry.

Definition at line 97 of file HcalGeometry.h.

References cellGeomPtr(), HcalTopology::detId2denseId(), and theTopology.

Referenced by getCells(), and getClosestCell().

                                                                       {
      return cellGeomPtr( theTopology.detId2denseId( id ) ) ;
  }
void HcalGeometry::getSummary ( CaloSubdetectorGeometry::TrVec trVector,
CaloSubdetectorGeometry::IVec iVector,
CaloSubdetectorGeometry::DimVec dimVector,
std::vector< uint32_t > &  dins 
) const [virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 541 of file HcalGeometry.cc.

References begin, EZArrayFL< T >::begin(), cellGeomPtr(), gather_cfg::cout, EZArrayFL< T >::end(), CaloCellGeometry::getPosition(), CaloCellGeometry::getTransform(), i, gen::k, m_dins, CaloSubdetectorGeometry::m_validIds, numberOfParametersPerShape(), numberOfShapes(), CaloSubdetectorGeometry::numberOfTransformParms(), convertSQLiteXML::ok, CaloCellGeometry::param(), CaloSubdetectorGeometry::parVecVec(), findQualityFiles::rr, and groupFilesInBlocks::tt.

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

   std::cout << "HcalGeometry::m_dins size " << m_dins.size() << std::endl;
   std::cout << "Filled dins size " << dins.size() << ", m_validIds.size() " << m_validIds.size() << std::endl;
   
   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( dins[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 > & HcalGeometry::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 79 of file HcalGeometry.cc.

References fillDetIds(), CaloSubdetectorGeometry::getValidDetIds(), HcalBarrel, HcalEndcap, HcalForward, HcalOuter, m_emptyIds, m_hbIds, m_heIds, m_hfIds, and m_hoIds.

{
   if( 0 != subdet &&
       0 == m_hbIds.size() ) fillDetIds() ;
   return ( 0 == subdet ? CaloSubdetectorGeometry::getValidDetIds() :
            ( HcalBarrel == subdet ? m_hbIds :
              ( HcalEndcap == subdet ? m_heIds :
                ( HcalOuter == subdet ? m_hoIds :
                  ( HcalForward == subdet ? m_hfIds : m_emptyIds ) ) ) ) ) ;
}
virtual unsigned int HcalGeometry::indexFor ( const DetId id) const [inline, protected, virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 110 of file HcalGeometry.h.

References HcalTopology::detId2denseId(), and theTopology.

{ return  theTopology.detId2denseId(id); }
void HcalGeometry::init ( void  ) [private]
void HcalGeometry::localCorners ( Pt3DVec lc,
const CCGFloat pv,
unsigned int  i,
Pt3D ref 
)

Definition at line 436 of file HcalGeometry.cc.

References HcalTopology::denseId2detId(), HcalForward, HcalDetId::subdet(), and theTopology.

{
  HcalDetId hid=HcalDetId(theTopology.denseId2detId(i));

   if( hid.subdet() == HcalForward )
   {
      IdealZPrism::localCorners( lc, pv, ref ) ;
   }
   else
   {
      IdealObliquePrism::localCorners( lc, pv, ref ) ;
   }
}
void HcalGeometry::newCell ( const GlobalPoint f1,
const GlobalPoint f2,
const GlobalPoint f3,
const CCGFloat parm,
const DetId detId 
) [virtual]

Implements CaloSubdetectorGeometry.

Definition at line 454 of file HcalGeometry.cc.

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

                                                    {

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

  static int counter=0;
  edm::LogInfo("HcalGeometry") << counter++ << ": newCell subdet "
                               << detId.subdetId() << ", raw ID " 
                               << detId.rawId() << ", hid " << hid << ", din " 
                               << din;
  
  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 {
    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 ) ; 
  m_dins.push_back( din );
}
static unsigned int HcalGeometry::numberOfAlignments ( ) [inline, static]
static unsigned int HcalGeometry::numberOfBarrelAlignments ( ) [inline, static]
static unsigned int HcalGeometry::numberOfEndcapAlignments ( ) [inline, static]
static unsigned int HcalGeometry::numberOfForwardAlignments ( ) [inline, static]
static unsigned int HcalGeometry::numberOfOuterAlignments ( ) [inline, static]
virtual unsigned int HcalGeometry::numberOfParametersPerShape ( ) const [inline, virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 36 of file HcalGeometry.h.

References k_NumberOfParametersPerShape.

Referenced by getSummary().

virtual unsigned int HcalGeometry::numberOfShapes ( ) const [inline, virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 35 of file HcalGeometry.h.

References HcalTopology::getNumberOfShapes(), and theTopology.

Referenced by getSummary().

int HcalGeometry::phiBin ( double  phi,
int  etaring 
) const [private]

Definition at line 193 of file HcalGeometry.cc.

References HcalTopology::firstHFQuadPhiRing(), createXMLFile::iphi, M_PI, HcalTopology::nPhiBins(), and theTopology.

Referenced by getCells(), and getClosestCell().

{
   static const double twopi = M_PI+M_PI;
  //put phi in correct range (0->2pi)
  if(phi<0.0) phi += twopi;
  if(phi>twopi) phi -= twopi;
  int nphibins = theTopology.nPhiBins(etaring);
  int phibin= static_cast<int>(phi/twopi*nphibins)+1;
  int iphi;

  // rings 40 and 41 are offset wrt the other phi numbering
  //  1        1         1         2
  //  ------------------------------
  //  72       36        36        1
  if(etaring >= theTopology.firstHFQuadPhiRing())
  {
    phi+=(twopi/36); //shift by half tower.    
    phibin=static_cast<int>(phi/twopi*nphibins);
    if (phibin==0) phibin=18;
    iphi=phibin*4-1; // 71,3,5,
  } else {
    // convert to the convention of numbering 1,3,5, in 36 phi bins
    iphi=(phibin-1)*(72/nphibins) + 1;
  }

  return iphi;
}
static std::string HcalGeometry::producerTag ( ) [inline, static]
virtual unsigned int HcalGeometry::sizeForDenseIndex ( const DetId id) const [inline, protected, virtual]

Reimplemented from CaloSubdetectorGeometry.

Definition at line 111 of file HcalGeometry.h.

References HcalTopology::ncells(), and theTopology.

{ return theTopology.ncells(); }

Member Data Documentation

std::vector<uint32_t> HcalGeometry::m_dins [mutable, private]

Definition at line 131 of file HcalGeometry.h.

Referenced by getSummary(), and newCell().

std::vector<DetId> HcalGeometry::m_emptyIds [mutable, private]

Definition at line 130 of file HcalGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

Definition at line 133 of file HcalGeometry.h.

Referenced by cellGeomPtr(), init(), and newCell().

std::vector<DetId> HcalGeometry::m_hbIds [mutable, private]

Definition at line 126 of file HcalGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

Definition at line 134 of file HcalGeometry.h.

Referenced by cellGeomPtr(), init(), and newCell().

std::vector<DetId> HcalGeometry::m_heIds [mutable, private]

Definition at line 127 of file HcalGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

Definition at line 136 of file HcalGeometry.h.

Referenced by cellGeomPtr(), init(), and newCell().

std::vector<DetId> HcalGeometry::m_hfIds [mutable, private]

Definition at line 129 of file HcalGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().

Definition at line 135 of file HcalGeometry.h.

Referenced by cellGeomPtr(), init(), and newCell().

std::vector<DetId> HcalGeometry::m_hoIds [mutable, private]

Definition at line 128 of file HcalGeometry.h.

Referenced by fillDetIds(), and getValidDetIds().