Go to the documentation of this file.00001
00005 #include <DataFormats/MuonDetId/interface/GEMDetId.h>
00006 #include <DataFormats/MuonDetId/interface/MuonSubdetId.h>
00007
00008 GEMDetId::GEMDetId():DetId(DetId::Muon, MuonSubdetId::GEM){}
00009
00010
00011 GEMDetId::GEMDetId(uint32_t id):DetId(id){
00012 if (det()!=DetId::Muon || subdetId()!=MuonSubdetId::GEM) {
00013 throw cms::Exception("InvalidDetId") << "GEMDetId ctor:"
00014 << " det: " << det()
00015 << " subdet: " << subdetId()
00016 << " is not a valid GEM id";
00017 }
00018 }
00019
00020 GEMDetId::GEMDetId(DetId id):DetId(id) {
00021 if (det()!=DetId::Muon || subdetId()!=MuonSubdetId::GEM) {
00022 throw cms::Exception("InvalidDetId") << "GEMDetId ctor:"
00023 << " det: " << det()
00024 << " subdet: " << subdetId()
00025 << " is not a valid GEM id";
00026 }
00027 }
00028
00029 GEMDetId::GEMDetId(int region, int ring, int station, int layer,int chamber, int roll):
00030 DetId(DetId::Muon, MuonSubdetId::GEM)
00031 {
00032 this->init(region,ring,station,layer,chamber,roll);
00033 }
00034
00035 void
00036 GEMDetId::init(int region,int ring,int station,
00037 int layer,int chamber,int roll)
00038 {
00039 if ( region < minRegionId || region > maxRegionId ||
00040 ring < minRingId || ring > maxRingId ||
00041 station < minStationId || station > maxStationId ||
00042 layer < minLayerId || layer > maxLayerId ||
00043 chamber < minChamberId || chamber > maxChamberId ||
00044 roll < minRollId || roll > maxRollId) {
00045 throw cms::Exception("InvalidDetId") << "GEMDetId ctor:"
00046 << " Invalid parameters: "
00047 << " region "<<region
00048 << " ring "<<ring
00049 << " station "<<station
00050 << " layer "<<layer
00051 << " chamber "<<chamber
00052 << " roll "<<roll
00053 << std::endl;
00054 }
00055 int regionInBits=region-minRegionId;
00056 int ringInBits = ring-minRingId;
00057 int stationInBits=station-minStationId;
00058 int layerInBits=layer-minLayerId;
00059 int chamberInBits=chamber-(minChamberId+1);
00060 int rollInBits=roll;
00061
00062 id_ |= ( regionInBits & RegionMask_) << RegionStartBit_ |
00063 ( ringInBits & RingMask_) << RingStartBit_ |
00064 ( stationInBits & StationMask_) << StationStartBit_ |
00065 ( layerInBits & LayerMask_) << LayerStartBit_ |
00066 ( chamberInBits & ChamberMask_) << ChamberStartBit_ |
00067 ( rollInBits & RollMask_) << RollStartBit_ ;
00068
00069 }
00070
00071
00072
00073 std::ostream& operator<<( std::ostream& os, const GEMDetId& id ){
00074
00075
00076 os << " Re "<<id.region()
00077 << " Ri "<<id.ring()
00078 << " St "<<id.station()
00079 << " La "<<id.layer()
00080 << " Ch "<<id.chamber()
00081 << " Ro "<<id.roll()
00082 <<" ";
00083
00084 return os;
00085 }
00086
00087