Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:51

0001 //////////////////////////////////////////////////////////////////////////////
0002 // File: CaloHitID.cc
0003 // Description: Identifier for a calorimetric hit
0004 ///////////////////////////////////////////////////////////////////////////////
0005 #include "SimG4CMS/Calo/interface/CaloHitID.h"
0006 
0007 #include <iomanip>
0008 
0009 CaloHitID::CaloHitID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth, float tSlice, bool ignoreTkID)
0010     : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID), isFinecaloTrackID_(false) {
0011   setID(unitID, timeSlice, trackID, depth);
0012 }
0013 
0014 CaloHitID::CaloHitID(float tSlice, bool ignoreTkID) : timeSliceUnit(tSlice), ignoreTrackID(ignoreTkID) { reset(); }
0015 
0016 CaloHitID::CaloHitID(const CaloHitID& id) {
0017   theUnitID = id.theUnitID;
0018   theTimeSlice = id.theTimeSlice;
0019   theTrackID = id.theTrackID;
0020   theTimeSliceID = id.theTimeSliceID;
0021   theDepth = id.theDepth;
0022   timeSliceUnit = id.timeSliceUnit;
0023   ignoreTrackID = id.ignoreTrackID;
0024   isFinecaloTrackID_ = id.isFinecaloTrackID_;
0025 }
0026 
0027 const CaloHitID& CaloHitID::operator=(const CaloHitID& id) {
0028   theUnitID = id.theUnitID;
0029   theTimeSlice = id.theTimeSlice;
0030   theTrackID = id.theTrackID;
0031   theTimeSliceID = id.theTimeSliceID;
0032   theDepth = id.theDepth;
0033   timeSliceUnit = id.timeSliceUnit;
0034   ignoreTrackID = id.ignoreTrackID;
0035   isFinecaloTrackID_ = id.isFinecaloTrackID_;
0036   return *this;
0037 }
0038 
0039 CaloHitID::~CaloHitID() {}
0040 
0041 void CaloHitID::setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth) {
0042   theUnitID = unitID;
0043   theTimeSlice = timeSlice;
0044   theTrackID = trackID;
0045   theTimeSliceID = (int)(theTimeSlice / timeSliceUnit);
0046   theDepth = depth;
0047 }
0048 
0049 void CaloHitID::reset() {
0050   theUnitID = 0;
0051   theTimeSlice = -2 * timeSliceUnit;
0052   theTrackID = -2;
0053   theTimeSliceID = (int)(theTimeSlice / timeSliceUnit);
0054   theDepth = 0;
0055   isFinecaloTrackID_ = false;
0056 }
0057 
0058 bool CaloHitID::operator==(const CaloHitID& id) const {
0059   return ((theUnitID == id.unitID()) && (theTrackID == id.trackID() || ignoreTrackID) &&
0060           (theTimeSliceID == id.timeSliceID()) && (theDepth == id.depth()))
0061              ? true
0062              : false;
0063 }
0064 
0065 bool CaloHitID::operator<(const CaloHitID& id) const {
0066   if (theTrackID != id.trackID()) {
0067     return (theTrackID > id.trackID());
0068   } else if (theUnitID != id.unitID()) {
0069     return (theUnitID > id.unitID());
0070   } else if (theDepth != id.depth()) {
0071     return (theDepth > id.depth());
0072   } else {
0073     return (theTimeSliceID > id.timeSliceID());
0074   }
0075 }
0076 
0077 bool CaloHitID::operator>(const CaloHitID& id) const {
0078   if (theTrackID != id.trackID()) {
0079     return (theTrackID < id.trackID());
0080   } else if (theUnitID != id.unitID()) {
0081     return (theUnitID < id.unitID());
0082   } else if (theDepth != id.depth()) {
0083     return (theDepth < id.depth());
0084   } else {
0085     return (theTimeSliceID < id.timeSliceID());
0086   }
0087 }
0088 
0089 std::ostream& operator<<(std::ostream& os, const CaloHitID& id) {
0090   os << "UnitID 0x" << std::hex << id.unitID() << std::dec << " Depth " << std::setw(6) << id.depth() << " Time "
0091      << std::setw(6) << id.timeSlice() << " TrackID " << std::setw(8) << id.trackID();
0092   return os;
0093 }