CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DataFormats/HcalDetId/src/HcalElectronicsId.cc

Go to the documentation of this file.
00001 #include "DataFormats/HcalDetId/interface/HcalElectronicsId.h"
00002 
00003 
00004 HcalElectronicsId::HcalElectronicsId() {
00005   hcalElectronicsId_=0xffffffffu;
00006 }
00007 
00008 HcalElectronicsId::HcalElectronicsId(uint32_t id) {
00009   hcalElectronicsId_=id;
00010 }
00011 
00012 HcalElectronicsId::HcalElectronicsId(int fiberChan, int fiberIndex, int spigot, int dccid) {
00013   hcalElectronicsId_=(fiberChan&0x3) | (((fiberIndex-1)&0x7)<<2) |
00014     ((spigot&0xF)<<5) | ((dccid&0x1F)<<9);
00015 }
00016 
00017 HcalElectronicsId::HcalElectronicsId(int slbChan, int slbSite, int spigot, int dccid, int crate, int slot, int tb) {
00018   hcalElectronicsId_=(slbChan&0x3) | (((slbSite)&0x7)<<2) |
00019     ((spigot&0xF)<<5) | ((dccid&0x1F)<<9);
00020   hcalElectronicsId_|=((tb&0x1)<<19) | ((slot&0x1f)<<14) | ((crate&0x3f)<<20);
00021   hcalElectronicsId_|=0x02000000;
00022 }
00023 
00024 std::string HcalElectronicsId::slbChannelCode() const {
00025   std::string retval;
00026   if (isTriggerChainId()) {
00027     if (htrTopBottom()) { // top
00028       switch (slbChannelIndex()) {
00029       case (0): retval="A0"; break;
00030       case (1): retval="A1"; break;
00031       case (2): retval="C0"; break;
00032       case (3): retval="C1"; break;
00033       }
00034     } else {
00035       switch (slbChannelIndex()) {
00036       case (0): retval="B0"; break;
00037       case (1): retval="B1"; break;
00038       case (2): retval="D0"; break;
00039       case (3): retval="D1"; break;
00040       }
00041     }
00042   }
00043   return retval;
00044 }
00045 
00046 void HcalElectronicsId::setHTR(int crate, int slot, int tb) {
00047   hcalElectronicsId_&=0x3FFF; // keep the readout chain info
00048   hcalElectronicsId_|=((tb&0x1)<<19) | ((slot&0x1f)<<14) | ((crate&0x3f)<<20);
00049 }
00050 
00051 std::ostream& operator<<(std::ostream& os,const HcalElectronicsId& id) {
00052   if (id.isTriggerChainId()) {
00053     return os << id.dccid() << ',' << id.spigot() << ",SLB" << id.slbSiteNumber() << ',' << id.slbChannelIndex() << " (HTR "
00054               << id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom()==1)?('t'):('b')) << ')'; 
00055     
00056   } else {
00057     return os << id.dccid() << ',' << id.spigot() << ',' << id.fiberIndex() << ',' << id.fiberChanId() << " (HTR "
00058               << id.readoutVMECrateId() << ":" << id.htrSlot() << ((id.htrTopBottom()==1)?('t'):('b')) << ')'; 
00059   }
00060 }
00061 
00062