CMS 3D CMS Logo

CaloHitID.cc
Go to the documentation of this file.
1 // File: CaloHitID.cc
3 // Description: Identifier for a calorimetric hit
6 
7 #include <iomanip>
8 
9 CaloHitID::CaloHitID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth, float tSlice, bool ignoreTkID)
10  : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) {
11  setID(unitID, timeSlice, trackID, depth);
12 }
13 
14 CaloHitID::CaloHitID(float tSlice, bool ignoreTkID) : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { reset(); }
15 
17  theUnitID = id.theUnitID;
18  theTimeSlice = id.theTimeSlice;
19  theTrackID = id.theTrackID;
20  theTimeSliceID = id.theTimeSliceID;
21  theDepth = id.theDepth;
22  timeSliceUnit = id.timeSliceUnit;
23  ignoreTrackID = id.ignoreTrackID;
24 }
25 
27  theUnitID = id.theUnitID;
28  theTimeSlice = id.theTimeSlice;
29  theTrackID = id.theTrackID;
30  theTimeSliceID = id.theTimeSliceID;
31  theDepth = id.theDepth;
32  timeSliceUnit = id.timeSliceUnit;
33  ignoreTrackID = id.ignoreTrackID;
34 
35  return *this;
36 }
37 
39 
40 void CaloHitID::setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth) {
41  theUnitID = unitID;
45  theDepth = depth;
46 }
47 
49  theUnitID = 0;
51  theTrackID = -2;
53  theDepth = 0;
54 }
55 
56 bool CaloHitID::operator==(const CaloHitID& id) const {
57  return ((theUnitID == id.unitID()) && (theTrackID == id.trackID() || ignoreTrackID) &&
58  (theTimeSliceID == id.timeSliceID()) && (theDepth == id.depth()))
59  ? true
60  : false;
61 }
62 
63 bool CaloHitID::operator<(const CaloHitID& id) const {
64  if (theTrackID != id.trackID()) {
65  return (theTrackID > id.trackID());
66  } else if (theUnitID != id.unitID()) {
67  return (theUnitID > id.unitID());
68  } else if (theDepth != id.depth()) {
69  return (theDepth > id.depth());
70  } else {
71  return (theTimeSliceID > id.timeSliceID());
72  }
73 }
74 
75 bool CaloHitID::operator>(const CaloHitID& id) const {
76  if (theTrackID != id.trackID()) {
77  return (theTrackID < id.trackID());
78  } else if (theUnitID != id.unitID()) {
79  return (theUnitID < id.unitID());
80  } else if (theDepth != id.depth()) {
81  return (theDepth < id.depth());
82  } else {
83  return (theTimeSliceID < id.timeSliceID());
84  }
85 }
86 
87 std::ostream& operator<<(std::ostream& os, const CaloHitID& id) {
88  os << "UnitID 0x" << std::hex << id.unitID() << std::dec << " Depth " << std::setw(6) << id.depth() << " Time "
89  << std::setw(6) << id.timeSlice() << " TrackID " << std::setw(8) << id.trackID();
90  return os;
91 }
bool operator<(const CaloHitID &) const
Definition: CaloHitID.cc:63
bool ignoreTrackID
Definition: CaloHitID.h:39
uint32_t theUnitID
Definition: CaloHitID.h:33
bool operator>(const CaloHitID &) const
Definition: CaloHitID.cc:75
double theTimeSlice
Definition: CaloHitID.h:34
double timeSlice() const
Definition: CaloHitID.h:22
uint16_t depth() const
Definition: CaloHitID.h:24
CaloHitID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0, float tSlice=1, bool ignoreTkID=false)
Definition: CaloHitID.cc:9
void reset()
Definition: CaloHitID.cc:48
uint16_t theDepth
Definition: CaloHitID.h:37
std::ostream & operator<<(std::ostream &os, const CaloHitID &id)
Definition: CaloHitID.cc:87
int timeSliceID() const
Definition: CaloHitID.h:21
bool operator==(const CaloHitID &) const
Definition: CaloHitID.cc:56
int trackID() const
Definition: CaloHitID.h:23
float timeSliceUnit
Definition: CaloHitID.h:38
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:40
CSCCFEBTimeSlice const *const timeSlice(T const &data, int nCFEB, int nSample)
const CaloHitID & operator=(const CaloHitID &)
Definition: CaloHitID.cc:26
virtual ~CaloHitID()
Definition: CaloHitID.cc:38
int theTimeSliceID
Definition: CaloHitID.h:36
int theTrackID
Definition: CaloHitID.h:35
uint32_t unitID() const
Definition: CaloHitID.h:20