CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/DataFormats/CSCDigi/src/CSCWireDigi.cc

Go to the documentation of this file.
00001 
00009 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
00010 
00011 #include <iostream>
00012 #include <stdint.h>
00013 
00015 
00016 CSCWireDigi::CSCWireDigi (int wire, unsigned int tbinb){
00018   wire_  = wire & 0x0000FFFF;
00019   tbinb_ = tbinb;
00021   wireBX_= (wire >> 16) & 0x0000FFFF;
00023   wireBXandWires_=wire;
00024 }
00025 
00027 CSCWireDigi::CSCWireDigi (){
00028   wire_ = 0;
00029   tbinb_ = 0;
00030   wireBX_=0;
00031   wireBXandWires_=0;
00032 }
00033 
00035 int CSCWireDigi::getBeamCrossingTag() const {
00036   return getTimeBin();
00037 }
00039 int CSCWireDigi::getTimeBin() const {
00040   uint32_t tbit=1;
00041   int tbin=-1;
00042   for(int i=0;i<32;i++) {
00043     if(tbit & tbinb_) tbin=i;
00044     if(tbin>-1) break;
00045     tbit=tbit<<1;
00046   }
00047   return tbin;
00048 }
00050 std::vector<int> CSCWireDigi::getTimeBinsOn() const {
00051   std::vector<int> tbins;
00052   uint32_t tbit=tbinb_;
00053   uint32_t one=1;
00054   for(int i=0;i<32;i++) {
00055     if(tbit & one) tbins.push_back(i);
00056     tbit=tbit>>1;
00057     if(tbit==0) break;
00058   }
00059   return tbins;
00060 }
00061 
00063 
00064 void CSCWireDigi::print() const {
00065   std::cout << " CSC Wire " << getWireGroup() << " | "
00066             << " CSC Wire BX # " << getWireGroupBX() << " | " 
00067             << " CSC BX + Wire " << std::hex << getBXandWireGroup() << " | " << std::dec
00068             << " CSC Wire First Time Bin On " << getTimeBin()  
00069             << std::endl;
00070   std::cout << " CSC Time Bins On ";
00071   std::vector<int> tbins=getTimeBinsOn();
00072   for(unsigned int i=0; i<tbins.size();i++) std::cout<<tbins[i]<<" ";
00073   std::cout<<std::endl; 
00074 }
00075 
00076 std::ostream & operator<<(std::ostream & o, const CSCWireDigi& digi) {
00077   o << " CSC Wire " << digi.getWireGroup()
00078            << " CSC Wire First Time Bin On " << digi.getTimeBin()
00079            << " CSC Time Bins On ";
00080   for (unsigned int i = 0; i<digi.getTimeBinsOn().size(); ++i ){
00081     o <<" " <<digi.getTimeBinsOn()[i]; }
00082   return o;
00083 }
00084