CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CaloID.cc
Go to the documentation of this file.
2 #include <iostream>
3 
4 using namespace reco;
5 using namespace std;
6 
7 
8 void CaloID::setDetector(Detectors theDetector, bool value) {
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 }
18 
19 
20 
21 bool CaloID::detector(Detectors theDetector) const {
22 
23  return (detectors_>>theDetector) & 1;
24 }
25 
26 
28  if( ! isSingleDetector() ) return DET_NONE;
29 
30  int pos = leastSignificantBitPosition( detectors_ );
31 
32  CaloID::Detectors det = static_cast<CaloID::Detectors>(pos);
33 
34  return det;
35 }
36 
37 
38 
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 }
52 
53 
54 std::ostream& reco::operator<<(std::ostream& out,
55  const CaloID& id) {
56  if(!out) return out;
57 
58  out<<"CaloID: "<<id.detectors();
59  return out;
60 }
Detectors detector() const
Definition: CaloID.cc:27
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:64
tuple out
Definition: dbtoconf.py:99
void setDetector(CaloID::Detectors theDetector, bool value)
tells the CaloID that it describes a given detector
Definition: CaloID.cc:8
int leastSignificantBitPosition(unsigned n) const
Definition: CaloID.cc:39