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)
 
Detectors detector () const
 
bool detector (CaloID::Detectors theDetector) 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

◆ Detectors

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

19  {
20  DET_ECAL_BARREL = 0,
22  DET_PS1,
23  DET_PS2,
26  DET_HF,
27  DET_HF_EM,
28  DET_HF_HAD,
29  DET_HO,
31  DET_NONE
32  };

Constructor & Destructor Documentation

◆ CaloID() [1/2]

reco::CaloID::CaloID ( )
inline

default constructor. Sets energy and position to zero

Definition at line 35 of file CaloID.h.

35 : detectors_(0) {}

◆ CaloID() [2/2]

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

Definition at line 37 of file CaloID.h.

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

References setDetector().

◆ ~CaloID()

virtual reco::CaloID::~CaloID ( )
inlinevirtual

abstract class

Definition at line 40 of file CaloID.h.

40 {}

Member Function Documentation

◆ detector() [1/2]

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

Definition at line 19 of file CaloID.cc.

19  {
20  if (!isSingleDetector())
21  return DET_NONE;
22 
24 
25  CaloID::Detectors det = static_cast<CaloID::Detectors>(pos);
26 
27  return det;
28 }

◆ detector() [2/2]

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

Definition at line 17 of file CaloID.cc.

17 { return (detectors_ >> theDetector) & 1; }

◆ detectors()

unsigned reco::CaloID::detectors ( ) const
inline
Returns
packed detector information

Definition at line 46 of file CaloID.h.

46 { return detectors_; }

References detectors_.

◆ isSingleDetector()

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

Definition at line 52 of file CaloID.h.

52  {
53  // check that detectors_ is a power of 2
54  return static_cast<bool>(detectors_ && !((detectors_ - 1) & detectors_));
55  }

References detectors_.

◆ leastSignificantBitPosition()

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

Definition at line 30 of file CaloID.cc.

30  {
31  if (n == 0)
32  return -1;
33 
34  int pos = 31;
35 
36  if (n & 0x000000000000FFFFLL) {
37  pos -= 16;
38  } else {
39  n >>= 16;
40  }
41  if (n & 0x00000000000000FFLL) {
42  pos -= 8;
43  } else {
44  n >>= 8;
45  }
46  if (n & 0x000000000000000FLL) {
47  pos -= 4;
48  } else {
49  n >>= 4;
50  }
51  if (n & 0x0000000000000003LL) {
52  pos -= 2;
53  } else {
54  n >>= 2;
55  }
56  if (n & 0x0000000000000001LL) {
57  pos -= 1;
58  }
59  return pos;
60 }

References dqmiodumpmetadata::n.

◆ operator=()

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

Definition at line 61 of file CaloID.h.

61  {
62  detectors_ = rhs.detectors_;
63  return *this;
64  }

References detectors_.

◆ setDetector()

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.

7  {
8  // cout<<"CaloID::setDetector "<<theDetector<<" "<<(1<<theDetector)<<endl;
9  if (value)
10  detectors_ = detectors_ | (1 << theDetector);
11  else
12  detectors_ = detectors_ ^ (1 << theDetector);
13 
14  // cout<<detectors_<<endl;
15 }

Referenced by CaloID().

Friends And Related Function Documentation

◆ operator<<

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

Member Data Documentation

◆ detectors_

unsigned reco::CaloID::detectors_
private

packs the detector information into a bitmask. a CaloID can describe several detectors (bit or)

Definition at line 74 of file CaloID.h.

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

dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
reco::CaloID::Detectors
Detectors
Definition: CaloID.h:19
reco::CaloID::DET_HGCAL_ENDCAP
Definition: CaloID.h:30
reco::CaloID::DET_ECAL_ENDCAP
Definition: CaloID.h:21
pos
Definition: PixelAliasList.h:18
reco::CaloID::DET_HF
Definition: CaloID.h:26
reco::CaloID::DET_PS2
Definition: CaloID.h:23
reco::CaloID::DET_HF_HAD
Definition: CaloID.h:28
reco::CaloID::DET_HF_EM
Definition: CaloID.h:27
reco::CaloID::DET_HCAL_ENDCAP
Definition: CaloID.h:25
reco::CaloID::DET_PS1
Definition: CaloID.h:22
reco::CaloID::leastSignificantBitPosition
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:30
reco::CaloID::isSingleDetector
bool isSingleDetector() const
Definition: CaloID.h:52
reco::CaloID::detectors_
unsigned detectors_
Definition: CaloID.h:74
reco::CaloID::DET_HCAL_BARREL
Definition: CaloID.h:24
value
Definition: value.py:1
reco::CaloID::DET_NONE
Definition: CaloID.h:31
reco::CaloID::setDetector
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:7
reco::CaloID::DET_HO
Definition: CaloID.h:29
reco::CaloID::DET_ECAL_BARREL
Definition: CaloID.h:20