CMS 3D CMS Logo

CaloID.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 using namespace reco;
5 using namespace std;
6 
7 void CaloID::setDetector(Detectors theDetector, bool value) {
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 }
16 
17 bool CaloID::detector(Detectors theDetector) const { return (detectors_ >> theDetector) & 1; }
18 
20  if (!isSingleDetector())
21  return DET_NONE;
22 
23  int pos = leastSignificantBitPosition(detectors_);
24 
25  CaloID::Detectors det = static_cast<CaloID::Detectors>(pos);
26 
27  return det;
28 }
29 
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 }
61 
62 std::ostream& reco::operator<<(std::ostream& out, const CaloID& id) {
63  if (!out)
64  return out;
65 
66  out << "CaloID: " << id.detectors();
67  return out;
68 }
Detectors detector() const
Definition: CaloID.cc:19
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
Definition: value.py:1
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:7
fixed size matrix
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:30