#include <CaloID.h>
Public Types | |
enum | Detectors { DET_ECAL_BARREL = 0, DET_ECAL_ENDCAP, DET_PS1, DET_PS2, DET_HCAL_BARREL, DET_HCAL_ENDCAP, DET_HF, DET_HF_EM, DET_HF_HAD, DET_HO, DET_NONE } |
Public Member Functions | |
CaloID () | |
default constructor. Sets energy and position to zero | |
CaloID (Detectors det) | |
Detectors | detector () const |
bool | detector (CaloID::Detectors theDetector) const |
unsigned | detectors () const |
bool | isSingleDetector () const |
CaloID & | operator= (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 |
Private Attributes | |
unsigned | detectors_ |
Friends | |
std::ostream & | operator<< (std::ostream &out, const CaloID &id) |
DET_ECAL_BARREL | |
DET_ECAL_ENDCAP | |
DET_PS1 | |
DET_PS2 | |
DET_HCAL_BARREL | |
DET_HCAL_ENDCAP | |
DET_HF | |
DET_HF_EM | |
DET_HF_HAD | |
DET_HO | |
DET_NONE |
Definition at line 21 of file CaloID.h.
{ DET_ECAL_BARREL = 0, DET_ECAL_ENDCAP, DET_PS1, DET_PS2, DET_HCAL_BARREL, DET_HCAL_ENDCAP, DET_HF, DET_HF_EM, DET_HF_HAD, DET_HO, DET_NONE };
reco::CaloID::CaloID | ( | ) | [inline] |
default constructor. Sets energy and position to zero
Definition at line 36 of file CaloID.h.
: detectors_(0) {}
reco::CaloID::CaloID | ( | Detectors | det | ) | [inline] |
Definition at line 38 of file CaloID.h.
References setDetector().
: detectors_(0) { setDetector(det, true); }
virtual reco::CaloID::~CaloID | ( | ) | [inline, virtual] |
bool CaloID::detector | ( | CaloID::Detectors | theDetector | ) | const |
Definition at line 21 of file CaloID.cc.
{ return (detectors_>>theDetector) & 1; }
CaloID::Detectors CaloID::detector | ( | ) | const |
Definition at line 27 of file CaloID.cc.
References pos.
{ if( ! isSingleDetector() ) return DET_NONE; int pos = leastSignificantBitPosition( detectors_ ); CaloID::Detectors det = static_cast<CaloID::Detectors>(pos); return det; }
unsigned reco::CaloID::detectors | ( | ) | const [inline] |
Definition at line 47 of file CaloID.h.
References detectors_.
{return detectors_;}
bool reco::CaloID::isSingleDetector | ( | ) | const [inline] |
Definition at line 53 of file CaloID.h.
References detectors_.
{ // check that detectors_ is a power of 2 return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ )); }
int CaloID::leastSignificantBitPosition | ( | unsigned | n | ) | const [private] |
Definition at line 39 of file CaloID.cc.
References pos.
{ if (n == 0) return -1; int pos = 31; if (n & 0x000000000000FFFFLL) { pos -= 16; } else { n >>= 16; } if (n & 0x00000000000000FFLL) { pos -= 8; } else { n >>= 8; } if (n & 0x000000000000000FLL) { pos -= 4; } else { n >>= 4; } if (n & 0x0000000000000003LL) { pos -= 2; } else { n >>= 2; } if (n & 0x0000000000000001LL) { pos -= 1; } return pos; }
Definition at line 62 of file CaloID.h.
References detectors_.
{ detectors_ = rhs.detectors_; return *this; }
void CaloID::setDetector | ( | CaloID::Detectors | theDetector, |
bool | value | ||
) |
tells the CaloID that it describes a given detector
Definition at line 8 of file CaloID.cc.
Referenced by CaloID().
{ // cout<<"CaloID::setDetector "<<theDetector<<" "<<(1<<theDetector)<<endl; if(value) detectors_ = detectors_ | (1<<theDetector); else detectors_ = detectors_ ^ (1<<theDetector); // cout<<detectors_<<endl; }
std::ostream& operator<< | ( | std::ostream & | out, |
const CaloID & | id | ||
) | [friend] |
unsigned reco::CaloID::detectors_ [private] |
packs the detector information into a bitmask. a CaloID can describe several detectors (bit or)
Definition at line 77 of file CaloID.h.
Referenced by detectors(), isSingleDetector(), and operator=().