00001 #include "DataFormats/HcalDetId/interface/HcalCastorDetId.h"
00002 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005 HcalCastorDetId::HcalCastorDetId() : DetId() {
00006 }
00007
00008 HcalCastorDetId::HcalCastorDetId(uint32_t rawid) : DetId(rawid) {
00009 }
00010
00011 HcalCastorDetId::HcalCastorDetId(Section section,
00012 bool true_for_positive_eta,
00013 int sector,
00014 int module)
00015 : DetId(DetId::Calo, SubdetectorId)
00016 {
00017
00018
00019
00020
00021
00022
00023
00024
00025 sector -= 1;
00026
00027 id_ |= ( true_for_positive_eta << 8 ) | ( sector << 4 ) | module;
00028 }
00029
00030
00031 HcalCastorDetId::HcalCastorDetId(bool true_for_positive_eta,
00032 int sector,
00033 int module)
00034 : DetId(DetId::Calo, SubdetectorId)
00035 {
00036
00037
00038
00039
00040
00041
00042
00043
00044 sector -= 1;
00045
00046 id_ |= ( true_for_positive_eta << 8 ) | ( sector << 4 ) | module;
00047 }
00048
00049 HcalCastorDetId::HcalCastorDetId(const DetId& gen)
00050 {
00051 if (!gen.null() && (gen.det() != DetId::Calo || gen.subdetId() != SubdetectorId))
00052 {
00053 throw cms::Exception("Invalid DetId") << "Cannot initialize CASTORDetId from " << std::hex << gen.rawId() << std::dec;
00054 }
00055
00056 id_= gen.rawId();
00057 }
00058
00059 HcalCastorDetId& HcalCastorDetId::operator=(const DetId& gen)
00060 {
00061 if (!gen.null() && (gen.det() != DetId::Calo || gen.subdetId() != SubdetectorId))
00062 {
00063 throw cms::Exception("Invalid DetId") << "Cannot assign Castor DetId from " << std::hex << gen.rawId() << std::dec;
00064 }
00065
00066 id_ = gen.rawId();
00067
00068 return *this;
00069 }
00070
00071
00072
00073
00074
00075
00076
00077
00078 std::ostream& operator<<(std::ostream& s,const HcalCastorDetId& id)
00079 {
00080 s << "(CASTOR" << ((id.zside()==1)?("+"):("-"));
00081
00082 switch (id.section())
00083 {
00084 case(HcalCastorDetId::EM) : s << " EM "; break;
00085 case(HcalCastorDetId::HAD) : s << " HAD "; break;
00086 default : s <<" UNKNOWN ";
00087 }
00088
00089 return s << id.sector() << ',' << id.module() << ',' << ')';
00090 }
00091