00001 #include "SimDataFormats/EcalTestBeam/interface/HodoscopeDetId.h" 00002 #include "FWCore/Utilities/interface/Exception.h" 00003 00004 #include <iostream> 00005 HodoscopeDetId::HodoscopeDetId() : DetId() { 00006 } 00007 00008 HodoscopeDetId::HodoscopeDetId(uint32_t rawid) : DetId(rawid) { 00009 } 00010 00011 // use the LaserPnDiode as sub-detector to avoid to create a new one 00012 00013 HodoscopeDetId::HodoscopeDetId(int indexPlane, int indexFibr) 00014 : DetId(Ecal,EcalLaserPnDiode) 00015 { 00016 int iPlane = indexPlane; 00017 int iFibr = indexFibr; 00018 if (iPlane < MIN_PLANE || iPlane > MAX_PLANE || 00019 iFibr < MIN_FIBR || iFibr > MAX_FIBR) { 00020 throw cms::Exception("InvalidDetId") << "HodoscopeDetId: Cannot create object. Indexes out of bounds."; 00021 } 00022 id_ |= ((iPlane&0x3) | ((iFibr&0x3F)<<2)) ; 00023 } 00024 00025 HodoscopeDetId::HodoscopeDetId(const DetId& gen) { 00026 if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalLaserPnDiode )) { 00027 throw cms::Exception("InvalidDetId"); 00028 } 00029 id_=gen.rawId(); 00030 } 00031 00032 HodoscopeDetId& HodoscopeDetId::operator=(const DetId& gen) { 00033 if (!gen.null() && ( gen.det()!=Ecal || gen.subdetId()!=EcalLaserPnDiode )) { 00034 throw cms::Exception("InvalidDetId"); 00035 } 00036 id_=gen.rawId(); 00037 return *this; 00038 } 00039 00040 std::ostream& operator<<(std::ostream& s,const HodoscopeDetId& id) { 00041 return s << "(Plane " << id.planeId() << ", fiber " << id.fibrId() << ')'; 00042 } 00043