Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009 #include "RecoMET/METAlgorithms/interface/HcalHPDRBXMap.h"
00010 #include "FWCore/Utilities/interface/EDMException.h"
00011 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00012
00013
00014 HcalHPDRBXMap::HcalHPDRBXMap() {}
00015 HcalHPDRBXMap::~HcalHPDRBXMap() {}
00016
00017
00018 bool HcalHPDRBXMap::isValidHPD(int index)
00019 {
00020 return (index>=0 && index<=NUM_HPDS-1);
00021 }
00022
00023
00024 bool HcalHPDRBXMap::isValidRBX(int index)
00025 {
00026 return (index>=0 && index<=NUM_RBXS-1);
00027 }
00028
00029 bool HcalHPDRBXMap::isValid(const HcalDetId& id)
00030 {
00031 if(id.subdet()!=HcalBarrel && id.subdet()!=HcalEndcap) return false;
00032 return isValid(id.ieta(),id.iphi());
00033 }
00034
00035 bool HcalHPDRBXMap::isValid(int ieta, int iphi)
00036 {
00037 int absieta=abs(ieta);
00038 if(absieta<=29 && absieta>=1 && iphi>=1 && iphi<=72) {
00039 if(absieta<=20) return true;
00040 if(absieta>=21 && iphi%2==1) return true;
00041 }
00042 return false;
00043 }
00044
00045
00046 HcalSubdetector HcalHPDRBXMap::subdetHPD(int index)
00047 {
00048 if(!isValidHPD(index))
00049 throw edm::Exception(edm::errors::LogicError)
00050 << " HPD index " << index << " is invalid in HcalHPDRBXMap::subdetHPD().\n";
00051
00052 if(index/NUM_HPDS_PER_SUBDET<=1) return HcalBarrel;
00053 else return HcalEndcap;
00054 }
00055
00056
00057 HcalSubdetector HcalHPDRBXMap::subdetRBX(int index)
00058 {
00059 if(!isValidRBX(index))
00060 throw edm::Exception(edm::errors::LogicError)
00061 << " RBX index " << index << " is invalid in HcalHPDRBXMap::subdetRBX().\n";
00062
00063 if(index/NUM_RBXS_PER_SUBDET<=1) return HcalBarrel;
00064 else return HcalEndcap;
00065 }
00066
00067
00068 int HcalHPDRBXMap::zsideHPD(int index)
00069 {
00070 if(!isValidHPD(index))
00071 throw edm::Exception(edm::errors::LogicError)
00072 << " HPD index " << index << " is invalid in HcalHPDRBXMap::zsideHPD().\n";
00073
00074 if(index/NUM_HPDS_PER_SUBDET==0 || index/NUM_HPDS_PER_SUBDET==2) return 1;
00075 else return -1;
00076 }
00077
00078
00079 int HcalHPDRBXMap::zsideRBX(int index)
00080 {
00081 if(!isValidRBX(index))
00082 throw edm::Exception(edm::errors::LogicError)
00083 << " RBX index " << index << " is invalid in HcalHPDRBXMap::zsideRBX().\n";
00084
00085 if(index/NUM_RBXS_PER_SUBDET==0 || index/NUM_RBXS_PER_SUBDET==2) return 1;
00086 else return -1;
00087 }
00088
00089
00090 int HcalHPDRBXMap::iphiloHPD(int index)
00091 {
00092 if(!isValidHPD(index))
00093 throw edm::Exception(edm::errors::LogicError)
00094 << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphiloHPD().\n";
00095
00096
00097
00098
00099 int iphi=index%NUM_HPDS_PER_SUBDET-1;
00100 if(iphi<=0) iphi+=NUM_HPDS_PER_SUBDET;
00101
00102
00103 if(subdetHPD(index)==HcalBarrel) return iphi;
00104
00105
00106 if(iphi%2==0) return iphi-1;
00107 else return iphi;
00108 }
00109
00110
00111 int HcalHPDRBXMap::iphiloRBX(int index)
00112 {
00113 if(!isValidRBX(index))
00114 throw edm::Exception(edm::errors::LogicError)
00115 << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphiloRBX().\n";
00116
00117
00118 boost::array<int, NUM_HPDS_PER_RBX> arr;
00119 indicesHPDfromRBX(index, arr);
00120
00121
00122 return iphiloHPD(arr[0]);
00123 }
00124
00125
00126 int HcalHPDRBXMap::iphihiHPD(int index)
00127 {
00128 if(!isValidHPD(index))
00129 throw edm::Exception(edm::errors::LogicError)
00130 << " HPD index " << index << " is invalid in HcalHPDRBXMap::iphihiHPD().\n";
00131
00132
00133
00134
00135 int iphi=index%NUM_HPDS_PER_SUBDET-1;
00136 if(iphi<=0) iphi+=NUM_HPDS_PER_SUBDET;
00137
00138
00139 if(subdetHPD(index)==HcalBarrel) return iphi;
00140
00141
00142 if(iphi%2==0) return iphi;
00143 else return iphi+1;
00144 }
00145
00146
00147 int HcalHPDRBXMap::iphihiRBX(int index)
00148 {
00149 if(!isValidRBX(index))
00150 throw edm::Exception(edm::errors::LogicError)
00151 << " RBX index " << index << " is invalid in HcalHPDRBXMap::iphihiRBX().\n";
00152
00153
00154 boost::array<int, NUM_HPDS_PER_RBX> arr;
00155 indicesHPDfromRBX(index, arr);
00156
00157
00158 return iphihiHPD(arr[NUM_HPDS_PER_RBX-1]);
00159 }
00160
00161
00162
00163 void HcalHPDRBXMap::indicesHPDfromRBX(int rbxindex, boost::array<int, NUM_HPDS_PER_RBX>& hpdindices)
00164 {
00165 if(!isValidRBX(rbxindex))
00166 throw edm::Exception(edm::errors::LogicError)
00167 << " RBX index " << rbxindex << " is invalid in HcalHPDRBXMap::indicesHPD().\n";
00168
00169 for(unsigned int i=0; i<hpdindices.size(); i++)
00170 hpdindices[i]=rbxindex*NUM_HPDS_PER_RBX+i;
00171
00172 return;
00173 }
00174
00175
00176 int HcalHPDRBXMap::indexRBXfromHPD(int hpdindex)
00177 {
00178 if(!isValidHPD(hpdindex))
00179 throw edm::Exception(edm::errors::LogicError)
00180 << " HPD index " << hpdindex << " is invalid in HcalHPDRBXMap::indexRBX().\n";
00181
00182 return hpdindex/NUM_HPDS_PER_RBX;
00183 }
00184
00185
00186
00187 int HcalHPDRBXMap::indexHPD(const HcalDetId& id)
00188 {
00189
00190 if(!isValid(id)) {
00191 throw edm::Exception(edm::errors::LogicError)
00192 << " HcalDetId " << id << " is invalid in HcalHPDRBXMap::indexHPD().\n";
00193 }
00194
00195
00196 int subdet=-1;
00197 if(id.subdet()==HcalBarrel && id.zside()==1) subdet=0;
00198 if(id.subdet()==HcalBarrel && id.zside()==-1) subdet=1;
00199 if(id.subdet()==HcalEndcap && id.zside()==1) subdet=2;
00200 if(id.subdet()==HcalEndcap && id.zside()==-1) subdet=3;
00201
00202 int iphi=id.iphi();
00203 int absieta=abs(id.ieta());
00204
00205
00206
00207
00208 int index=iphi+1;
00209 if(index>=NUM_HPDS_PER_SUBDET) index-=NUM_HPDS_PER_SUBDET;
00210 index+=subdet*NUM_HPDS_PER_SUBDET;
00211
00212
00213 if((subdet==2 || subdet==3) && absieta>=21 && absieta<=29) {
00214 if(iphi%4==3 && absieta%2==1 && absieta!=29) index++;
00215 if(iphi%4==3 && absieta==29 && id.depth()==2) index++;
00216 if(iphi%4==1 && absieta%2==0 && absieta!=29) index++;
00217 if(iphi%4==1 && absieta==29 && id.depth()==1) index++;
00218 }
00219 return index;
00220 }
00221
00222 int HcalHPDRBXMap::indexRBX(const HcalDetId& id)
00223 {
00224 return indexRBXfromHPD(indexHPD(id));
00225 }
00226
00227 void HcalHPDRBXMap::indexHPDfromEtaPhi(int ieta, int iphi, std::vector<int>& hpdindices)
00228 {
00229
00230 hpdindices.clear();
00231 int absieta=abs(ieta);
00232
00233 if(absieta<=15) {
00234 hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
00235 } else if(absieta==16) {
00236 hpdindices.push_back(indexHPD(HcalDetId(HcalBarrel, ieta, iphi, 1)));
00237 hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 3)));
00238 } else if(absieta<29) {
00239 hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
00240 } else {
00241 hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 1)));
00242 hpdindices.push_back(indexHPD(HcalDetId(HcalEndcap, ieta, iphi, 2)));
00243 }
00244
00245 return;
00246 }
00247
00248 void HcalHPDRBXMap::indexRBXfromEtaPhi(int ieta, int iphi, std::vector<int>& rbxindices)
00249 {
00250
00251 rbxindices.clear();
00252 int absieta=abs(ieta);
00253
00254 if(absieta<=15) {
00255 rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
00256 } else if(absieta==16) {
00257 rbxindices.push_back(indexRBX(HcalDetId(HcalBarrel, ieta, iphi, 1)));
00258 rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 3)));
00259 } else {
00260 rbxindices.push_back(indexRBX(HcalDetId(HcalEndcap, ieta, iphi, 1)));
00261 }
00262
00263 return;
00264 }