CMS 3D CMS Logo

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