CMS 3D CMS Logo

DTChamberId.cc

Go to the documentation of this file.
00001 
00009 #include <DataFormats/MuonDetId/interface/DTChamberId.h>
00010 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h> 
00011 #include <FWCore/Utilities/interface/Exception.h>
00012 
00013 using namespace std;
00014 
00015 DTChamberId::DTChamberId() : DetId(DetId::Muon, MuonSubdetId::DT){}
00016 
00017 
00018 DTChamberId::DTChamberId(uint32_t id) :
00019   DetId(id & chamberIdMask_) { // Mask the bits outside DTChamberId fields
00020   checkMuonId();               // Check this is a valid id for muon DTs.
00021 }
00022 DTChamberId::DTChamberId(DetId id) :
00023   DetId(id.rawId() & chamberIdMask_) { // Mask the bits outside DTChamberId fields
00024   checkMuonId();               // Check this is a valid id for muon DTs.
00025 }
00026 
00027 
00028 
00029 DTChamberId::DTChamberId(int wheel, int station, int sector):
00030   DetId(DetId::Muon, MuonSubdetId::DT) {
00031     // Check that arguments are within the range
00032     if (wheel      < minWheelId      || wheel      > maxWheelId ||
00033         station    < minStationId    || station    > maxStationId ||
00034         sector     < minSectorId     || sector     > maxSectorId) {
00035       throw cms::Exception("InvalidDetId") << "DTChamberId ctor:" 
00036                                            << " Invalid parameters: " 
00037                                            << " Wh:"<< wheel
00038                                            << " St:"<< station
00039                                            << " Se:"<< sector
00040                                            << std::endl;
00041     }
00042 
00043     int tmpwheelid = wheel- minWheelId +1;
00044     id_ |= (tmpwheelid& wheelMask_) << wheelStartBit_   |
00045       (station & stationMask_)      << stationStartBit_ |
00046       (sector  &sectorMask_ )       << sectorStartBit_;
00047 
00048 }
00049 
00050 
00051 
00052 DTChamberId::DTChamberId(const DTChamberId& chId) :
00053   DetId(chId.rawId() & chamberIdMask_) {   // The mask is required for proper slicing, i.e. if chId is actually a derived class.
00054 }
00055 
00056 
00057 
00058 void DTChamberId::checkMuonId() {
00059   if (det()!=DetId::Muon || subdetId()!=MuonSubdetId::DT) {
00060     throw cms::Exception("InvalidDetId") << "DTChamberId ctor:"
00061                                          << " det: " << det()
00062                                          << " subdet: " << subdetId()
00063                                          << " is not a valid DT id";  
00064   }
00065 }
00066 
00067 
00068 
00069 std::ostream& operator<<( std::ostream& os, const DTChamberId& id ){
00070   os << " Wh:"<< id.wheel()
00071      << " St:"<< id.station() 
00072      << " Se:"<< id.sector()
00073      <<" ";
00074 
00075   return os;
00076 }
00077 
00078 
00079 

Generated on Tue Jun 9 17:31:20 2009 for CMSSW by  doxygen 1.5.4