00001 #include "DQM/SiStripMonitorHardware/interface/BinCounters.h"
00002
00003 BinCounters::BinCounters()
00004 :f(32),
00005 number_(0),
00006 counter0(0),
00007 counter1(0),
00008 counter2(0),
00009 counter3(0),
00010 counter4(0),
00011 counter5(0),
00012 counter6(0),
00013 counter7(0),
00014 counter8(0),
00015 counter9(0),
00016 counter10(0),
00017 counter11(0),
00018 counter12(0),
00019 counter13(0),
00020 counter14(0),
00021 counter15(0),
00022 counter16(0),
00023 counter17(0),
00024 counter18(0),
00025 counter19(0),
00026 counter20(0),
00027 counter21(0),
00028 counter22(0),
00029 counter23(0),
00030 counter24(0),
00031 counter25(0),
00032 counter26(0),
00033 counter27(0),
00034 counter28(0),
00035 counter29(0),
00036 counter30(0),
00037 counter31(0)
00038
00039 {
00040
00041 }
00042
00043 BinCounters::~BinCounters(){
00044 }
00045
00046
00047 void BinCounters::setBinCounters(unsigned int number_){
00048
00049 for(int i = (f-1); i>=0; i--){
00050 if( convert(number_, i) == 0 ){
00051 if(i == 31)counter31++;
00052 else if(i == 30)counter30++;
00053 else if(i == 29)counter29++;
00054 else if(i == 28)counter28++;
00055 else if(i == 27)counter27++;
00056 else if(i == 26)counter26++;
00057 else if(i == 25)counter25++;
00058 else if(i == 24)counter24++;
00059 else if(i == 23)counter23++;
00060 else if(i == 22)counter22++;
00061 else if(i == 21)counter21++;
00062 else if(i == 20)counter20++;
00063 else if(i == 19)counter19++;
00064 else if(i == 18)counter18++;
00065 else if(i == 17)counter17++;
00066 else if(i == 16)counter16++;
00067 else if(i == 15)counter15++;
00068 else if(i == 14)counter14++;
00069 else if(i == 13)counter13++;
00070 else if(i == 12)counter12++;
00071 else if(i == 11)counter11++;
00072 else if(i == 10)counter10++;
00073 else if(i == 9)counter9++;
00074 else if(i == 8)counter8++;
00075 else if(i == 7)counter7++;
00076 else if(i == 6)counter6++;
00077 else if(i == 5)counter5++;
00078 else if(i == 4)counter4++;
00079 else if(i == 3)counter3++;
00080 else if(i == 2)counter2++;
00081 else if(i == 1)counter1++;
00082 else if(i == 0)counter0++;
00083 }
00084 }
00085
00086 }
00087
00088 int BinCounters::getBinCounters(int counterNumber){
00089
00090 if(counterNumber == 0)return counter0;
00091 else if(counterNumber == 1)return counter1;
00092 else if(counterNumber == 2)return counter2;
00093 else if(counterNumber == 3)return counter3;
00094 else if(counterNumber == 4)return counter4;
00095 else if(counterNumber == 5)return counter5;
00096 else if(counterNumber == 6)return counter6;
00097 else if(counterNumber == 7)return counter7;
00098 else if(counterNumber == 8)return counter8;
00099 else if(counterNumber == 9)return counter9;
00100 else if(counterNumber == 10)return counter10;
00101 else if(counterNumber == 11)return counter11;
00102 else if(counterNumber == 12)return counter12;
00103 else if(counterNumber == 13)return counter13;
00104 else if(counterNumber == 14)return counter14;
00105 else if(counterNumber == 15)return counter15;
00106 else if(counterNumber == 16)return counter16;
00107 else if(counterNumber == 17)return counter17;
00108 else if(counterNumber == 18)return counter18;
00109 else if(counterNumber == 19)return counter19;
00110 else if(counterNumber == 20)return counter20;
00111 else if(counterNumber == 21)return counter21;
00112 else if(counterNumber == 22)return counter22;
00113 else if(counterNumber == 23)return counter23;
00114 else if(counterNumber == 24)return counter24;
00115 else if(counterNumber == 25)return counter25;
00116 else if(counterNumber == 26)return counter26;
00117 else if(counterNumber == 27)return counter27;
00118 else if(counterNumber == 28)return counter28;
00119 else if(counterNumber == 29)return counter29;
00120 else if(counterNumber == 30)return counter30;
00121 else if(counterNumber == 31)return counter31;
00122 else return 0;
00123 }
00124
00125 bool BinCounters::convert(unsigned int input, int bitval){
00126
00127 return ( 0x1 & (input >> bitval));
00128 }
00129
00130 int BinCounters::invert8(int input){
00131
00132 int inverted = ( ( ((0x1 & (input >> 0))&0xFF)<<7) |
00133 ( ((0x1 & (input >> 1))&0xFF)<<6) |
00134 ( ((0x1 & (input >> 2))&0xFF)<<5) |
00135 ( ((0x1 & (input >> 3))&0xFF)<<4) |
00136 ( ((0x1 & (input >> 4))&0xFF)<<3) |
00137 ( ((0x1 & (input >> 5))&0xFF)<<2) |
00138 ( ((0x1 & (input >> 6))&0xFF)<<1) |
00139 ( ((0x1 & (input >> 7))&0xFF)<<0) );
00140
00141 return inverted;
00142 }