CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes | Friends
reco::CaloID Class Reference

#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_HGCAL_ENDCAP, DET_NONE
}
 

Public Member Functions

 CaloID ()
 default constructor. Sets energy and position to zero More...
 
 CaloID (Detectors det)
 
bool detector (CaloID::Detectors theDetector) const
 
Detectors detector () const
 
unsigned detectors () const
 
bool isSingleDetector () const
 
CaloIDoperator= (const CaloID &rhs)
 
void setDetector (CaloID::Detectors theDetector, bool value)
 tells the CaloID that it describes a given detector More...
 
virtual ~CaloID ()
 abstract class More...
 

Private Member Functions

int leastSignificantBitPosition (unsigned n) const
 

Private Attributes

unsigned detectors_
 

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

Enumerator
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_HGCAL_ENDCAP 
DET_NONE 

Definition at line 21 of file CaloID.h.

Constructor & Destructor Documentation

reco::CaloID::CaloID ( )
inline

default constructor. Sets energy and position to zero

Definition at line 37 of file CaloID.h.

37 : detectors_(0) {}
unsigned detectors_
Definition: CaloID.h:78
reco::CaloID::CaloID ( Detectors  det)
inline

Definition at line 39 of file CaloID.h.

References setDetector().

39 : detectors_(0) { setDetector(det, true); }
unsigned detectors_
Definition: CaloID.h:78
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:8
virtual reco::CaloID::~CaloID ( )
inlinevirtual

abstract class

Definition at line 42 of file CaloID.h.

References setDetector().

42 {}

Member Function Documentation

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

Definition at line 21 of file CaloID.cc.

21  {
22 
23  return (detectors_>>theDetector) & 1;
24 }
unsigned detectors_
Definition: CaloID.h:78
CaloID::Detectors CaloID::detector ( ) const
Returns
the described detector if isSingleDetector(), and DET_NONE otherwise.

Definition at line 27 of file CaloID.cc.

Referenced by detectors(), and isSingleDetector().

27  {
28  if( ! isSingleDetector() ) return DET_NONE;
29 
31 
32  CaloID::Detectors det = static_cast<CaloID::Detectors>(pos);
33 
34  return det;
35 }
bool isSingleDetector() const
Definition: CaloID.h:54
unsigned detectors_
Definition: CaloID.h:78
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:39
unsigned reco::CaloID::detectors ( ) const
inline
Returns
packed detector information

Definition at line 48 of file CaloID.h.

References detector(), and detectors_.

48 {return detectors_;}
unsigned detectors_
Definition: CaloID.h:78
bool reco::CaloID::isSingleDetector ( ) const
inline
Returns
true if this CaloID describes a single detector

Definition at line 54 of file CaloID.h.

References detector(), and detectors_.

54  {
55  // check that detectors_ is a power of 2
56  return static_cast<bool>(detectors_ && !( (detectors_-1) & detectors_ ));
57  }
unsigned detectors_
Definition: CaloID.h:78
int CaloID::leastSignificantBitPosition ( unsigned  n) const
private
Returns
lsb position in an integer

Definition at line 39 of file CaloID.cc.

Referenced by operator=().

39  {
40  if (n == 0)
41  return -1;
42 
43  int pos = 31;
44 
45  if (n & 0x000000000000FFFFLL) { pos -= 16; } else { n >>= 16; }
46  if (n & 0x00000000000000FFLL) { pos -= 8; } else { n >>= 8; }
47  if (n & 0x000000000000000FLL) { pos -= 4; } else { n >>= 4; }
48  if (n & 0x0000000000000003LL) { pos -= 2; } else { n >>= 2; }
49  if (n & 0x0000000000000001LL) { pos -= 1; }
50  return pos;
51 }
CaloID& reco::CaloID::operator= ( const CaloID rhs)
inline

Definition at line 63 of file CaloID.h.

References detectors_, leastSignificantBitPosition(), gen::n, operator<<, and MillePedeFileConverter_cfg::out.

63  {
64  detectors_ = rhs.detectors_;
65  return *this;
66  }
unsigned detectors_
Definition: CaloID.h:78
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(), and ~CaloID().

8  {
9 
10  // cout<<"CaloID::setDetector "<<theDetector<<" "<<(1<<theDetector)<<endl;
11  if(value)
12  detectors_ = detectors_ | (1<<theDetector);
13  else
14  detectors_ = detectors_ ^ (1<<theDetector);
15 
16  // cout<<detectors_<<endl;
17 }
Definition: value.py:1
unsigned detectors_
Definition: CaloID.h:78

Friends And Related Function Documentation

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

Referenced by operator=().

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 78 of file CaloID.h.

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