00001 #include "DataFormats/RPCDigi/interface/RPCDigiL1Link.h" 00002 #include "FWCore/Utilities/interface/Exception.h" 00003 00004 RPCDigiL1Link::RPCDigiL1Link() 00005 { 00006 for (unsigned int i=0;i<7;i++){ 00007 std::pair<unsigned int, int > c(0,0); 00008 _link.push_back(c); 00009 } 00010 } 00011 00012 00013 RPCDigiL1Link::~RPCDigiL1Link() 00014 {} 00015 00016 00017 bool 00018 RPCDigiL1Link::empty() const 00019 { 00020 bool e=true; 00021 for (unsigned int l=1;l<=6;l++){ 00022 if (!this->empty(l)) e=false; 00023 } 00024 return e; 00025 } 00026 00027 00028 bool 00029 RPCDigiL1Link::empty(unsigned int layer) const 00030 { 00031 this->checklayer(layer); 00032 return this->rawdetId(layer)==0; 00033 } 00034 00035 00036 unsigned int 00037 RPCDigiL1Link::rawdetId(unsigned int layer) const 00038 { 00039 this->checklayer(layer); 00040 return _link[layer-1].first; 00041 } 00042 00043 00044 int 00045 RPCDigiL1Link::strip(unsigned int layer) const 00046 { 00047 this->checklayer(layer); 00048 return abs(_link[layer-1].second)%1000; 00049 } 00050 00051 int 00052 RPCDigiL1Link::bx(unsigned int layer) const 00053 { 00054 this->checklayer(layer); 00055 return _link[layer-1].second/1000; 00056 } 00057 00058 unsigned int 00059 RPCDigiL1Link::nlayer() const 00060 { 00061 return _link.size()-1; 00062 } 00063 00064 00065 void 00066 RPCDigiL1Link::setLink(unsigned int layer, 00067 unsigned int rpcdetId, 00068 int strip, int bx) 00069 { 00070 this->checklayer(layer); 00071 int pdigi=abs(bx)*1000+strip; 00072 if (bx<0) 00073 pdigi*=-1; 00074 std::pair<unsigned int, int> digi(rpcdetId,pdigi); 00075 _link[layer-1]=digi; 00076 00077 } 00078 00079 00080 void 00081 RPCDigiL1Link::checklayer(unsigned int layer)const { 00082 if (layer == 0 || layer > 6) 00083 throw cms::Exception("RPCException") 00084 <<"RPCDigiL1Link: layer must be in the range from 1 to 6" 00085 <<std::endl; 00086 }