CMS 3D CMS Logo

HcalCastorDetId.cc

Go to the documentation of this file.
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       OLD
00019     id_|=(section&0x3)<<7;
00020     id_|=(sector&0x3)<<6;
00021     if (true_for_positive_eta) id_|=0x40;
00022     id_|=module&0x3;
00023     */
00024     
00025     sector -= 1; // we count sector from 1-16 instead of 0-15
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       OLD
00038     id_|=(section&0x3)<<7;
00039     id_|=(sector&0x3)<<6;
00040     if (true_for_positive_eta) id_|=0x40;
00041     id_|=module&0x3;
00042     */
00043     
00044     sector -= 1; // we count sectors from 1-16 instead of 0-15
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 int HcalCastorDetId::channel() const {
00073   int channelid = 16*(sector-1)+module;
00074   return channelid;
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 

Generated on Tue Jun 9 17:30:59 2009 for CMSSW by  doxygen 1.5.4