CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/SimG4CMS/Calo/src/CaloHitID.cc

Go to the documentation of this file.
00001 
00002 // File: CaloHitID.cc
00003 // Description: Identifier for a calorimetric hit
00005 #include "SimG4CMS/Calo/interface/CaloHitID.h"
00006 
00007 #include <iomanip>
00008 
00009 CaloHitID::CaloHitID(uint32_t unitID, double timeSlice, int trackID,
00010                      uint16_t depth, int tSlice, bool ignoreTkID) :
00011   timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) {
00012   setID(unitID, timeSlice, trackID, depth);
00013 }
00014 
00015 CaloHitID::CaloHitID(int tSlice, bool ignoreTkID) :
00016   timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) {
00017   reset();
00018 }
00019 
00020 CaloHitID::CaloHitID(const CaloHitID & id) {
00021   theUnitID      = id.theUnitID;
00022   theTimeSlice   = id.theTimeSlice;
00023   theTrackID     = id.theTrackID;
00024   theTimeSliceID = id.theTimeSliceID;
00025   theDepth       = id.theDepth;
00026   timeSliceUnit  = id.timeSliceUnit;
00027   ignoreTrackID  = id.ignoreTrackID;
00028 }
00029 
00030 const CaloHitID& CaloHitID::operator=(const CaloHitID & id) {
00031   theUnitID      = id.theUnitID;
00032   theTimeSlice   = id.theTimeSlice;
00033   theTrackID     = id.theTrackID;
00034   theTimeSliceID = id.theTimeSliceID;
00035   theDepth       = id.theDepth;
00036   timeSliceUnit  = id.timeSliceUnit;
00037   ignoreTrackID  = id.ignoreTrackID;
00038 
00039   return *this;
00040 }
00041 
00042 CaloHitID::~CaloHitID() {}
00043 
00044 void CaloHitID::setID(uint32_t unitID, double timeSlice, int trackID,
00045                       uint16_t depth) {
00046   theUnitID    = unitID;
00047   theTimeSlice = timeSlice;
00048   theTrackID   = trackID;
00049   theTimeSliceID = (int)(theTimeSlice/timeSliceUnit);
00050   theDepth     = depth;
00051 }
00052 
00053 void CaloHitID::reset() {
00054   theUnitID    = 0;
00055   theTimeSlice =-2*timeSliceUnit;
00056   theTrackID   =-2;
00057   theTimeSliceID = (int)(theTimeSlice/timeSliceUnit);
00058   theDepth     = 0;
00059 }
00060 
00061 bool CaloHitID::operator==(const CaloHitID& id) const {
00062   return ((theUnitID == id.unitID()) && 
00063           (theTrackID == id.trackID() || ignoreTrackID) &&
00064           (theTimeSliceID == id.timeSliceID()) && 
00065           (theDepth == id.depth())) ? true : false;
00066 }
00067 
00068 bool CaloHitID::operator<(const CaloHitID& id) const {
00069   if (theTrackID != id.trackID()) {
00070     return (theTrackID > id.trackID());
00071   } else if  (theUnitID != id.unitID()) {
00072     return (theUnitID > id.unitID());
00073   } else if  (theDepth != id.depth()) {
00074     return (theDepth > id.depth());
00075   } else {
00076     return (theTimeSliceID > id.timeSliceID());
00077   }
00078 }
00079 
00080 bool CaloHitID::operator>(const CaloHitID& id) const {
00081   if (theTrackID != id.trackID()) {
00082     return (theTrackID < id.trackID());
00083   } else if  (theUnitID != id.unitID()) {
00084     return (theUnitID < id.unitID());
00085   } else if  (theDepth != id.depth()) {
00086     return (theDepth < id.depth());
00087   } else {
00088     return (theTimeSliceID < id.timeSliceID());
00089   }
00090 }
00091 
00092 std::ostream& operator<<(std::ostream& os, const CaloHitID& id) {
00093   os << "UnitID 0x" << std::hex << id.unitID() << std::dec << " Depth "
00094      << std::setw(6) << id.depth() << " Time " << std::setw(6) 
00095      << id.timeSlice() << " TrackID " << std::setw(8) << id.trackID();
00096   return os;
00097 }