00001 #include "DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h" 00002 #include "FWCore/Utilities/interface/Exception.h" 00003 00004 #include <ostream> 00005 00006 00007 EcalTriggerElectronicsId::EcalTriggerElectronicsId() { 00008 EcalTriggerElectronicsId_=0xFFFFFFFFu; 00009 } 00010 00011 EcalTriggerElectronicsId::EcalTriggerElectronicsId(uint32_t id) { 00012 EcalTriggerElectronicsId_=id; 00013 } 00014 00015 EcalTriggerElectronicsId::EcalTriggerElectronicsId(int tccid, int ttid, int pseudostripid, int channelid){ 00016 if ( (tccid < MIN_TCCID) || (tccid > MAX_TCCID) || 00017 (ttid < MIN_TTID) || (ttid > MAX_TTID) || 00018 (pseudostripid < MIN_PSEUDOSTRIPID) || (pseudostripid > MAX_PSEUDOSTRIPID) || 00019 (channelid < MIN_CHANNELID) || (channelid > MAX_CHANNELID) ) 00020 throw cms::Exception("InvalidDetId") << "EcalTriggerElectronicsId: Cannot create object. Indexes out of bounds."; 00021 EcalTriggerElectronicsId_= (channelid&0x7) | ( (pseudostripid&0x7) << 3) | ( (ttid&0x7F) << 6) | ((tccid&0x7F) << 13); 00022 } 00023 00024 int EcalTriggerElectronicsId::zside() const { 00025 int tcc = tccId(); 00026 if ( (tcc >= MIN_TCCID_EEM && tcc <= MAX_TCCID_EEM)) return -1; 00027 if ( (tcc >= MIN_TCCID_EBM && tcc <= MAX_TCCID_EBM)) return -1; 00028 if ( (tcc >= MIN_TCCID_EEP && tcc <= MAX_TCCID_EEP)) return +1; 00029 if ( (tcc >= MIN_TCCID_EBP && tcc <= MAX_TCCID_EBP)) return +1; 00030 return 0; 00031 } 00032 00033 00034 EcalSubdetector EcalTriggerElectronicsId::subdet() const { 00035 int tcc = tccId(); 00036 if ( (tcc >= MIN_TCCID_EBM && tcc <= MAX_TCCID_EBM) || 00037 (tcc >= MIN_TCCID_EBP && tcc <= MAX_TCCID_EBP) ) return EcalBarrel; 00038 else return EcalEndcap; 00039 } 00040 00041 std::ostream& operator<<(std::ostream& os,const EcalTriggerElectronicsId& id) 00042 { 00043 return os << id.tccId() << ',' << id.ttId() << ',' << id.pseudoStripId() << ',' << id.channelId() ; 00044 } 00045