CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/L1Trigger/RegionalCaloTrigger/src/L1RCTORCAMap.cc

Go to the documentation of this file.
00001 #include "L1Trigger/RegionalCaloTrigger/interface/L1RCTORCAMap.h"
00002 
00003 #include <vector>
00004 using std::vector;
00005 
00006 L1RCTORCAMap::L1RCTORCAMap(){
00007   rawEMET = std::vector<unsigned short>(56*72);
00008   rawHDET = std::vector<unsigned short>(56*72);
00009   rawEMFG = std::vector<unsigned short>(56*72);
00010   rawHDFG = std::vector<unsigned short>(56*72);
00011   rawHFET = std::vector<unsigned short>(8*18);
00012   combEM = std::vector<unsigned short>(56*72);
00013   combHD = std::vector<unsigned short>(56*72);
00014 
00015   barrelData = std::vector<std::vector<std::vector<unsigned short> > >(18,std::vector<std::vector<unsigned short> >(7,
00016                                                            std::vector<unsigned short>(64)));
00017   hfData = std::vector<std::vector<unsigned short> >(18,std::vector<unsigned short>(8));
00018   
00019 }
00020 vector<std::vector<std::vector<unsigned short> > > L1RCTORCAMap::giveBarrel(){
00021   return barrelData;
00022 }
00023 
00024 vector<std::vector<unsigned short> > L1RCTORCAMap::giveHF(){
00025   return hfData;
00026 }
00027 void L1RCTORCAMap::makeHFData(){
00028   std::vector<unsigned short> crate(16);
00029   for(int i = 0; i< 9; i++){
00030     for(int j = 0; j<16; j++){
00031       crate.at(j) = rawHFET.at(16*i+j);
00032     }
00033     hfData.at(i) = crate;
00034   }  
00035 }  
00036 
00037 void L1RCTORCAMap::makeBarrelData(){
00038   std::vector<int> indices;
00039   for(int phi = 0; phi<72;phi++){
00040     for(int eta = 0; eta<56;eta++){
00041       indices = orcamap(eta,phi);
00042       (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2)) = combEM.at(phi*56 + eta);
00043       (barrelData.at(indices.at(0))).at(indices.at(1)).at(indices.at(2)+32) = combHD.at(phi*56 + eta);
00044     }
00045   }
00046 }
00047 
00048 void L1RCTORCAMap::readData(std::vector<unsigned> emet, std::vector<unsigned>  hdet,
00049                             std::vector<bool> emfg, std::vector<bool> hdfg,
00050                             std::vector<unsigned> hfet){
00051   for(int i = 0; i<4032; i++){
00052     rawEMET.at(i) = emet.at(i);
00053     rawHDET.at(i) = hdet.at(i);
00054     rawEMFG.at(i) = emfg.at(i);
00055     rawHDFG.at(i) = hdfg.at(i);
00056   }
00057   for(int i = 0; i<144; i++)
00058     rawHFET.at(i) = hfet.at(i);
00059 
00060   combEM = combVec(rawEMET,rawEMFG);
00061   combHD = combVec(rawHDET,rawHDFG);
00062 
00063   makeBarrelData();
00064   makeHFData();
00065 }
00066 
00067 unsigned short L1RCTORCAMap::combine(unsigned short et, unsigned short fg){
00068   unsigned short newfg = fg << 8;
00069   return newfg + et;
00070 }
00071 
00072 vector<unsigned short> L1RCTORCAMap::combVec(std::vector<unsigned short> et, 
00073                                              std::vector<unsigned short> fg){
00074   std::vector<unsigned short> comb(56*72);
00075   for(int i = 0; i<(int)et.size(); i++)
00076     comb.at(i) = combine(et.at(i),fg.at(i));
00077   return comb;
00078 }
00079 
00080 vector<int> L1RCTORCAMap::orcamap(int eta, int phi){
00081   int crateNum(20);
00082   std::vector<int> cardTower(2,0);
00083   std::vector<int> returnVec(3,0);
00084   int modEta = eta%28;
00085   int modPhi = phi%8;
00086   if(phi < 8)
00087     crateNum = 0;  
00088   else if( phi < 16)
00089     crateNum = 1;
00090   else if( phi < 24)
00091     crateNum = 2;
00092   else if( phi < 32)
00093     crateNum = 3;
00094   else if( phi < 40)
00095     crateNum = 4;
00096   else if( phi < 48)
00097     crateNum = 5;
00098   else if( phi < 56)
00099     crateNum = 6;
00100   else if( phi < 64)
00101     crateNum = 7;
00102   else if( phi < 72)
00103     crateNum = 8;
00104 
00105   if(eta < 28)
00106     cardTower = lowEtaMap(modEta,modPhi);
00107   else {
00108     cardTower = highEtaMap(modEta,modPhi);
00109     crateNum = crateNum + 9;
00110   }
00111 
00112   returnVec.at(0) = crateNum;
00113   for(int i =0; i<2; i++){
00114     returnVec.at(i+1) = cardTower.at(i);
00115   }
00116   return returnVec;
00117 }
00118     
00119 
00120 vector<int> L1RCTORCAMap::lowEtaMap(int eta, int phi){
00121   int cardnum = 0;
00122   int towernum = 0;
00123   std::vector<int> returnVec(2);
00124   if(eta < 4){
00125     cardnum = 6;
00126     if(phi < 4)
00127       towernum = (3-eta)*4 + phi;
00128     else
00129       towernum = eta*4 + phi + 12;
00130   }
00131   else if(eta <12){
00132     if(phi < 4){
00133       cardnum = 4;
00134       if(eta < 8)
00135         towernum = (7-eta)*4+phi+16;
00136       else
00137         towernum = (11-eta)*4+phi;
00138     }
00139     else{
00140       cardnum = 5;
00141       if(eta < 8)
00142         towernum = (7-eta)*4+(phi-4)+16;
00143       else
00144         towernum = (11-eta)*4+(phi-4);
00145     }
00146   }
00147   else if(eta < 20){
00148     if(phi < 4){
00149       cardnum = 2;
00150       if(eta < 16)
00151         towernum = (15-eta)*4+phi+16;
00152       else
00153         towernum = (19-eta)*4+phi;
00154     }
00155     else{
00156       cardnum = 3;
00157       if(eta < 16)
00158         towernum = (15-eta)*4+(phi-4)+16;
00159       else
00160         towernum = (19-eta)*4+(phi-4);
00161     }
00162   }
00163   else if(eta < 28){
00164     if(phi < 4){
00165       cardnum = 0;
00166       if(eta < 24)
00167         towernum = (23-eta)*4+phi+16;
00168       else
00169         towernum = (27-eta)*4+phi;
00170     }
00171     else{
00172       cardnum = 1;
00173       if(eta < 24)
00174         towernum = (23-eta)*4+(phi-4)+16;
00175       else
00176         towernum = (27-eta)*4+(phi-4);
00177     }
00178   }
00179   
00180   returnVec.at(0) = cardnum;
00181   returnVec.at(1) = towernum;
00182   return returnVec;
00183 }
00184 
00185 
00186 vector<int> L1RCTORCAMap::highEtaMap(int eta, int phi){
00187   int cardnum;
00188   int towernum;
00189   std::vector<int> returnVec(2);
00190   if(eta < 8){
00191     if(phi < 4){
00192       cardnum = 0;
00193       towernum = eta*4+phi;
00194     }
00195     else{
00196       cardnum = 1;
00197       towernum = eta*4+(phi-4);
00198     }
00199   }
00200   else if(eta < 16){
00201     if(phi < 4){
00202       cardnum = 2;
00203       towernum = (eta-8)*4+phi;
00204     }
00205     else{
00206       cardnum = 3;
00207       towernum = (eta-8)*4+(phi-4);
00208     }
00209   }
00210   else if(eta < 24){
00211     if(phi < 4){
00212       cardnum = 4;
00213       towernum = (eta-16)*4+phi;
00214     }
00215     else{
00216       cardnum = 5;
00217       towernum = (eta-16)*4+(phi-4);
00218     }
00219   }
00220   else{
00221     cardnum = 6;
00222     if(phi < 4)
00223       towernum = (27-eta)*4+phi;
00224     else
00225       towernum = (27-eta)*4+phi+12;
00226   }
00227 
00228   returnVec.at(0)=cardnum;
00229   returnVec.at(1)=towernum;
00230   return returnVec;
00231 }