CMS 3D CMS Logo

reco::CaloID Class Reference

ID information for all calorimeters. More...

#include <DataFormats/CaloRecHit/interface/CaloID.h>

List of all members.

Public Types

enum  Detectors {
  DET_ECAL_BARREL = 0, DET_ECAL_ENDCAP, DET_PS1, DET_PS2,
  DET_HCAL_BARREL, DET_HCAL_ENDCAP, DET_HF, DET_HO,
  DET_NONE
}

Public Member Functions

 CaloID (Detectors det)
 CaloID ()
 default constructor. Sets energy and position to zero
Detectors detector () const
 
Returns:
the described detector if isSingleDetector(), and DET_NONE otherwise.

bool detector (CaloID::Detectors theDetector) const
 
Returns:
true if this CaloID is in a given detector

unsigned detectors () const
 
Returns:
packed detector information

bool isSingleDetector () const
 
Returns:
true if this CaloID describes a single detector

CaloIDoperator= (const CaloID &rhs)
void setDetector (CaloID::Detectors theDetector, bool value)
 tells the CaloID that it describes a given detector
virtual ~CaloID ()
 abstract class

Private Member Functions

int leastSignificantBitPosition (unsigned n) const
 
Returns:
lsb position in an integer


Private Attributes

unsigned detectors_
 packs the detector information into a bitmask.

Friends

std::ostream & operator<< (std::ostream &out, const CaloID &id)


Detailed Description

ID information for all calorimeters.

Author:
Colin Bernet, LLR

Definition at line 17 of file CaloID.h.


Member Enumeration Documentation

enum reco::CaloID::Detectors

Enumerator:
DET_ECAL_BARREL 
DET_ECAL_ENDCAP 
DET_PS1 
DET_PS2 
DET_HCAL_BARREL 
DET_HCAL_ENDCAP 
DET_HF 
DET_HO 
DET_NONE 

Definition at line 21 of file CaloID.h.

00021                    {
00022       DET_ECAL_BARREL = 0,
00023       DET_ECAL_ENDCAP,
00024       DET_PS1,
00025       DET_PS2,
00026       DET_HCAL_BARREL,
00027       DET_HCAL_ENDCAP,
00028       DET_HF,
00029       DET_HO,
00030       DET_NONE
00031     };


Constructor & Destructor Documentation

reco::CaloID::CaloID (  )  [inline]

default constructor. Sets energy and position to zero

Definition at line 34 of file CaloID.h.

00034 : detectors_(0) {}

reco::CaloID::CaloID ( Detectors  det  )  [inline]

Definition at line 36 of file CaloID.h.

References setDetector().

00036 : detectors_(0) { setDetector(det, true); }

virtual reco::CaloID::~CaloID (  )  [inline, virtual]

abstract class

Definition at line 39 of file CaloID.h.

00039 {}


Member Function Documentation

CaloID::Detectors CaloID::detector (  )  const

Returns:
the described detector if isSingleDetector(), and DET_NONE otherwise.

Definition at line 26 of file CaloID.cc.

References DET_NONE, detectors_, isSingleDetector(), and leastSignificantBitPosition().

00026                                         {
00027   if( ! isSingleDetector() ) return DET_NONE;
00028   
00029   int pos =  leastSignificantBitPosition( detectors_ );
00030   
00031   CaloID::Detectors det = static_cast<CaloID::Detectors>(pos);
00032                                                                
00033   return det;
00034 }

bool CaloID::detector ( CaloID::Detectors  theDetector  )  const

Returns:
true if this CaloID is in a given detector

Definition at line 20 of file CaloID.cc.

References detectors_.

00020                                                  {
00021 
00022   return (detectors_>>theDetector) & 1;
00023 }

unsigned reco::CaloID::detectors (  )  const [inline]

Returns:
packed detector information

Definition at line 45 of file CaloID.h.

References detectors_.

00045 {return detectors_;}

bool reco::CaloID::isSingleDetector (  )  const [inline]

Returns:
true if this CaloID describes a single detector

Definition at line 51 of file CaloID.h.

References detectors_.

Referenced by detector().

00051                                   {
00052       // check that detectors_ is a power of 2
00053       return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
00054     }

int CaloID::leastSignificantBitPosition ( unsigned  n  )  const [private]

Returns:
lsb position in an integer

Definition at line 38 of file CaloID.cc.

Referenced by detector().

00038                                                         {
00039     if (n == 0)
00040       return -1;
00041  
00042     int pos = 31;
00043 
00044     if (n & 0x000000000000FFFFLL) { pos -= 16; } else { n >>= 16; }
00045     if (n & 0x00000000000000FFLL) { pos -=  8; } else { n >>=  8; }
00046     if (n & 0x000000000000000FLL) { pos -=  4; } else { n >>=  4; }
00047     if (n & 0x0000000000000003LL) { pos -=  2; } else { n >>=  2; }
00048     if (n & 0x0000000000000001LL) { pos -=  1; }
00049     return pos;
00050 }

CaloID& reco::CaloID::operator= ( const CaloID rhs  )  [inline]

Definition at line 60 of file CaloID.h.

References detectors_.

00060                                          { 
00061       detectors_ = rhs.detectors_;
00062       return *this;
00063     }

void CaloID::setDetector ( CaloID::Detectors  theDetector,
bool  value 
)

tells the CaloID that it describes a given detector

Definition at line 7 of file CaloID.cc.

References detectors_.

Referenced by CaloID().

00007                                                           {
00008   
00009   //  cout<<"CaloID::setDetector "<<theDetector<<" "<<(1<<theDetector)<<endl;
00010   if(value)
00011     detectors_ = detectors_ | (1<<theDetector);
00012   else 
00013     detectors_ = detectors_ ^ (1<<theDetector);
00014 
00015   // cout<<detectors_<<endl;
00016 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const CaloID id 
) [friend]

Definition at line 53 of file CaloID.cc.

00054                                                  {
00055   if(!out) return out;
00056 
00057   out<<"CaloID: "<<id.detectors();
00058   return out;
00059 }


Member Data Documentation

unsigned reco::CaloID::detectors_ [private]

packs the detector information into a bitmask.

a CaloID can describe several detectors (bit or)

Definition at line 75 of file CaloID.h.

Referenced by detector(), detectors(), isSingleDetector(), operator=(), and setDetector().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:50:59 2009 for CMSSW by  doxygen 1.5.4