00001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTRegion.h"
00002
00003 #include <vector>
00004 using std::vector;
00005
00006 #include <iostream>
00007 using std::cout;
00008 using std::cerr;
00009 using std::endl;
00010
00011 L1RCTRegion::L1RCTRegion() : totalRegionEt(36),
00012 totalRegionHE_FG(36),
00013 etIn9Bits(16),
00014 muonBit(16),
00015 activityBit(16)
00016 {
00017 }
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 unsigned short L1RCTRegion::getEtIn7Bits(int i, int j){
00030
00031 return totalRegionEt.at(6*(i+1) + j+1);
00032 }
00033
00034 void L1RCTRegion::setEtIn7Bits(int i, int j,unsigned short energy){
00035
00036 if(energy <= 127)
00037 totalRegionEt.at(6*(i+1) + j+1) = energy;
00038 else
00039 totalRegionEt.at(6*(i+1) + j+1) = 127;
00040 }
00041
00042
00043 unsigned short L1RCTRegion::getHE_FGBit(int i, int j){
00044 return totalRegionHE_FG.at(6*(i+1)+j+1);
00045 }
00046
00047 void L1RCTRegion::setHE_FGBit(int i, int j, unsigned short HE_FG){
00048 totalRegionHE_FG.at(6*(i+1)+j+1) = HE_FG;
00049 }
00050
00051
00052
00053
00054
00055 unsigned short L1RCTRegion::getEtIn9Bits(int i, int j){
00056 return etIn9Bits.at(4*i + j);
00057 }
00058
00059 void L1RCTRegion::setEtIn9Bits(int i, int j,unsigned short energy){
00060 if(energy <=511)
00061 etIn9Bits.at(4*i+j) = energy;
00062 else
00063 etIn9Bits.at(4*i+j) = 511;
00064 }
00065
00066 unsigned short L1RCTRegion::getMuonBit(int i, int j){
00067 return muonBit.at(4*i+j);
00068 }
00069
00070 void L1RCTRegion::setMuonBit(int i, int j,unsigned short muon){
00071 muonBit.at(4*i+j) = muon;
00072 }
00073
00074 void L1RCTRegion::setActivityBit(int i, int j, unsigned short activity){
00075 activityBit.at(4*i+j) = activity;
00076 }
00077
00078 unsigned short L1RCTRegion::getActivityBit(int i, int j){
00079 return activityBit.at(4*i+j);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093 vector<unsigned short> L1RCTRegion::giveNorthEt(){
00094 vector<unsigned short> north(4);
00095 for(int i = 0; i<4;i++)
00096 north.at(i) = getEtIn7Bits(3,i);
00097 return north;
00098 }
00099 void L1RCTRegion::setNorthEt(vector<unsigned short> north){
00100 for(int i = 0; i<4; i++)
00101 totalRegionEt.at(i+1) = north.at(i);
00102 }
00103 vector<unsigned short> L1RCTRegion::giveNorthHE_FG(){
00104 vector<unsigned short> north(4);
00105 for(int i = 0; i<4; i++)
00106 north.at(i) = getHE_FGBit(3,i);
00107 return north;
00108 }
00109 void L1RCTRegion::setNorthHE_FG(vector<unsigned short> north){
00110 for(int i = 0; i<4; i++)
00111 totalRegionHE_FG.at(i+1) = north.at(i);
00112 }
00113
00114 vector<unsigned short> L1RCTRegion::giveSouthEt(){
00115 vector<unsigned short> south(4);
00116 for(int i = 0; i<4; i++)
00117 south.at(i) = getEtIn7Bits(0,i);
00118 return south;
00119 }
00120 void L1RCTRegion::setSouthEt(vector<unsigned short> south){
00121 for(int i = 0; i<4; i++)
00122 totalRegionEt.at(31+i) = south.at(i);
00123 }
00124
00125 vector<unsigned short> L1RCTRegion::giveSouthHE_FG(){
00126 vector<unsigned short> south(4);
00127 for(int i = 0; i<4; i++)
00128 south.at(i) = getHE_FGBit(0,i);
00129 return south;
00130 }
00131 void L1RCTRegion::setSouthHE_FG(vector<unsigned short> south){
00132 for(int i=0; i<4; i++)
00133 totalRegionHE_FG.at(31+i) = south.at(i);
00134 }
00135
00136 vector<unsigned short> L1RCTRegion::giveWestEt(){
00137 vector<unsigned short> west(4);
00138 for(int i =0; i<4; i++)
00139 west.at(i) = getEtIn7Bits(i,3);
00140 return west;
00141 }
00142 void L1RCTRegion::setWestEt(vector<unsigned short> west){
00143 for(int i = 0; i<4; i++)
00144 totalRegionEt.at(6*(i+1)) = west.at(i);
00145 }
00146
00147 vector<unsigned short> L1RCTRegion::giveWestHE_FG(){
00148 vector<unsigned short> west(4);
00149 for(int i = 0; i<4; i++)
00150 west.at(i) = getHE_FGBit(i,3);
00151 return west;
00152 }
00153 void L1RCTRegion::setWestHE_FG(vector<unsigned short> west){
00154 for(int i = 0; i<4; i++)
00155 totalRegionHE_FG.at(6*(i+1)) = west.at(i);
00156 }
00157
00158 vector<unsigned short> L1RCTRegion::giveEastEt(){
00159 vector<unsigned short> east(4);
00160 for(int i = 0; i<4; i++)
00161 east.at(i) = getEtIn7Bits(i,0);
00162 return east;
00163 }
00164 void L1RCTRegion::setEastEt(vector<unsigned short> east){
00165 for(int i = 0; i<4; i++)
00166 totalRegionEt.at(6*(i+1) + 5) = east.at(i);
00167 }
00168
00169 vector<unsigned short> L1RCTRegion::giveEastHE_FG(){
00170 vector<unsigned short> east(4);
00171 for(int i = 0; i<4; i++)
00172 east.at(i) = getHE_FGBit(i,0);
00173 return east;
00174 }
00175 void L1RCTRegion::setEastHE_FG(vector<unsigned short> east){
00176 for(int i = 0; i<4; i++)
00177 totalRegionHE_FG.at(6*(i+1) + 5) = east.at(i);
00178 }
00179
00180 unsigned short L1RCTRegion::giveNEEt(){
00181 unsigned short et = getEtIn7Bits(3,0);
00182 if(et > 7)
00183 return 7;
00184 else
00185 return et;
00186 }
00187 unsigned short L1RCTRegion::giveNEHE_FG(){
00188 return getHE_FGBit(3,0);
00189 }
00190 void L1RCTRegion::setNEEt(unsigned short ne){
00191 totalRegionEt.at(5) = ne;
00192 }
00193 void L1RCTRegion::setNEHE_FG(unsigned short ne){
00194 totalRegionHE_FG.at(5) = ne;
00195 }
00196
00197 unsigned short L1RCTRegion::giveNWEt(){
00198 unsigned short et = getEtIn7Bits(3,3);
00199 if(et > 7)
00200 return 7;
00201 else
00202 return et;
00203 }
00204 unsigned short L1RCTRegion::giveNWHE_FG(){
00205 return getHE_FGBit(3,3);
00206 }
00207 void L1RCTRegion::setNWEt(unsigned short nw){
00208 totalRegionEt.at(0) = nw;
00209 }
00210 void L1RCTRegion::setNWHE_FG(unsigned short nw){
00211 totalRegionHE_FG.at(0) = nw;
00212 }
00213
00214 unsigned short L1RCTRegion::giveSWEt(){
00215 unsigned short et = getEtIn7Bits(0,3);
00216 if(et > 7)
00217 return 7;
00218 else
00219 return et;
00220 }
00221 unsigned short L1RCTRegion::giveSWHE_FG(){
00222 return getHE_FGBit(0,3);
00223 }
00224 void L1RCTRegion::setSWEt(unsigned short sw){
00225 totalRegionEt.at(30) = sw;
00226 }
00227 void L1RCTRegion::setSWHE_FG(unsigned short sw){
00228 totalRegionHE_FG.at(30) = sw;
00229 }
00230
00231 unsigned short L1RCTRegion::giveSEEt(){
00232 unsigned short et = getEtIn7Bits(0,0);
00233 if(et > 7)
00234 return 7;
00235 else
00236 return et;
00237 }
00238 unsigned short L1RCTRegion::giveSEHE_FG(){
00239 return getHE_FGBit(0,0);
00240 }
00241 void L1RCTRegion::setSEEt(unsigned short se){
00242 totalRegionEt.at(35) = se;
00243 }
00244 void L1RCTRegion::setSEHE_FG(unsigned short se){
00245 totalRegionHE_FG.at(35) = se;
00246 }
00247
00248 void L1RCTRegion::print() {
00249
00250 cout << " 7 Bit Energies ";
00251 for(int i = 0; i<4; i++){
00252 cout << endl;
00253 for(int j = 0; j<4; j++){
00254 cout << " " << getEtIn7Bits(i,j) << " ";
00255 }
00256 }
00257
00258 cout << endl << endl;
00259 cout << " 9 Bit Energies ";
00260 for(int i = 0; i<4; i++){
00261 cout << endl;
00262 for(int j = 0; j<4; j++){
00263 cout << " " << getEtIn9Bits(i,j) << " ";
00264 }
00265 }
00266
00267 cout << endl << endl;
00268 cout << " HE || FG bit ";
00269 for(int i = 0; i<4; i++){
00270 cout << endl;
00271 for(int j = 0; j<4; j++){
00272 cout << " " << getHE_FGBit(i,j) << " ";
00273 }
00274 }
00275
00276 cout << endl << endl;
00277 cout << " Muon Bit ";
00278 for(int i = 0; i<4; i++){
00279 cout << endl;
00280 for(int j = 0; j<4; j++){
00281 cout << " " << getMuonBit(i,j) << " ";
00282 }
00283 }
00284 cout << endl;
00285 }
00286
00287 void L1RCTRegion::printEdges(){
00288 cout << "North" << endl;
00289 for(int i=0; i<4;i++)
00290 cout << totalRegionEt.at(i+1) << endl;
00291
00292 cout << "West" << endl;
00293 for(int i=0; i<4;i++)
00294 cout << totalRegionEt.at(6*(i+1)) << endl;
00295
00296 cout << "East" << endl;
00297 for(int i=0; i<4;i++)
00298 cout << totalRegionEt.at(6*(i+1)+5) << endl;
00299
00300 cout << "South" << endl;
00301 for(int i=0; i<4;i++)
00302 cout << totalRegionEt.at(31+i) << endl;
00303
00304 cout << "NE " << totalRegionEt.at(5) << endl;
00305 cout << "SE " << totalRegionEt.at(35) << endl;
00306 cout << "NW " << totalRegionEt.at(0) << endl;
00307 cout << "SW " << totalRegionEt.at(30) << endl;
00308 }