Go to the documentation of this file.00001 #include "Geometry/HcalTowerAlgo/interface/HcalTrigTowerGeometry.h"
00002 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00003 #include "DataFormats/HcalDetId/interface/HcalTrigTowerDetId.h"
00004 #include "Geometry/HcalTowerAlgo/src/HcalHardcodeGeometryData.h"
00005
00006 #include <iostream>
00007 #include <cassert>
00008
00009 HcalTrigTowerGeometry::HcalTrigTowerGeometry() {
00010 useShortFibers_=true;
00011 useHFQuadPhiRings_=true;
00012 }
00013
00014 void HcalTrigTowerGeometry::setupHF(bool useShortFibers, bool useQuadRings) {
00015 useShortFibers_=useShortFibers;
00016 useHFQuadPhiRings_=useQuadRings;
00017 }
00018
00019 std::vector<HcalTrigTowerDetId>
00020 HcalTrigTowerGeometry::towerIds(const HcalDetId & cellId) const {
00021
00022 std::vector<HcalTrigTowerDetId> results;
00023
00024 if(cellId.subdet() == HcalForward) {
00025
00026 if(cellId.depth() == 1 || useShortFibers_) {
00027
00028 int hfRing = cellId.ietaAbs();
00029 int ieta = firstHFTower();
00030
00031 while(hfRing >= firstHFRingInTower(ieta+1)) {
00032 ++ieta;
00033 }
00034
00035 ieta *= cellId.zside();
00036
00037
00038
00039
00040 int iphi = (((cellId.iphi()+1)/4) * 4 + 1)%72;
00041 if (useHFQuadPhiRings_ || cellId.ietaAbs() < theTopology.firstHFQuadPhiRing())
00042 results.push_back( HcalTrigTowerDetId(ieta, iphi) );
00043 }
00044
00045 } else {
00046
00047 if(cellId.ietaAbs() < theTopology.firstHEDoublePhiRing()) {
00048 results.push_back( HcalTrigTowerDetId(cellId.ieta(), cellId.iphi()) );
00049 } else {
00050
00051 int iphi1 = cellId.iphi();
00052 int ieta = cellId.ieta();
00053
00054 if(ieta == theTopology.lastHERing()) --ieta;
00055 if(ieta == -theTopology.lastHERing()) ++ieta;
00056
00057 results.push_back( HcalTrigTowerDetId(ieta, iphi1) );
00058 results.push_back( HcalTrigTowerDetId(ieta, iphi1+1) );
00059 }
00060 }
00061
00062 return results;
00063 }
00064
00065
00066 std::vector<HcalDetId>
00067 HcalTrigTowerGeometry::detIds(const HcalTrigTowerDetId & hcalTrigTowerDetId) const {
00068
00069 std::vector<HcalDetId> results;
00070
00071 int tower_ieta = hcalTrigTowerDetId.ieta();
00072 int tower_iphi = hcalTrigTowerDetId.iphi();
00073
00074 int cell_ieta = tower_ieta;
00075 int cell_iphi = tower_iphi;
00076
00077 int min_depth, n_depths;
00078
00079
00080
00081 if (abs(cell_ieta) <= theTopology.lastHBRing()){
00082 theTopology.depthBinInformation(HcalBarrel, abs(tower_ieta), n_depths, min_depth);
00083 for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
00084 results.push_back(HcalDetId(HcalBarrel,cell_ieta,cell_iphi,cell_depth));
00085 }
00086
00087
00088
00089 if (abs(cell_ieta) <= theTopology.lastHORing()){
00090 theTopology.depthBinInformation(HcalOuter , abs(tower_ieta), n_depths, min_depth);
00091 for (int ho_depth = min_depth; ho_depth <= min_depth + n_depths - 1; ho_depth++)
00092 results.push_back(HcalDetId(HcalOuter, cell_ieta,cell_iphi,ho_depth));
00093 }
00094
00095
00096
00097 if (abs(cell_ieta) >= theTopology.firstHERing() &&
00098 abs(cell_ieta) < theTopology.lastHERing()){
00099
00100 theTopology.depthBinInformation(HcalEndcap, abs(tower_ieta), n_depths, min_depth);
00101
00102
00103 if (abs(cell_ieta) >= theTopology.firstHEDoublePhiRing())
00104 if (tower_iphi%2 == 0) cell_iphi = tower_iphi - 1;
00105
00106 for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
00107 results.push_back(HcalDetId(HcalEndcap, cell_ieta, cell_iphi, cell_depth));
00108
00109
00110 if (abs(tower_ieta) == 28){
00111 theTopology.depthBinInformation(HcalEndcap, abs(tower_ieta)+1, n_depths, min_depth);
00112 for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++){
00113 if (tower_ieta < 0) results.push_back(HcalDetId(HcalEndcap, tower_ieta - 1, cell_iphi, cell_depth));
00114 if (tower_ieta > 0) results.push_back(HcalDetId(HcalEndcap, tower_ieta + 1, cell_iphi, cell_depth));
00115 }
00116 }
00117
00118 }
00119
00120
00121
00122 if (abs(cell_ieta) >= theTopology.firstHFRing()){
00123
00124 int HfTowerPhiSize = 72 / nPhiBins(tower_ieta);
00125 int HfTowerEtaSize = hfTowerEtaSize(tower_ieta);
00126 int FirstHFRingInTower = firstHFRingInTower(abs(tower_ieta));
00127
00128 for (int iHFTowerPhiSegment = 0; iHFTowerPhiSegment < HfTowerPhiSize; iHFTowerPhiSegment++){
00129
00130 cell_iphi = (tower_iphi / HfTowerPhiSize) * HfTowerPhiSize;
00131 cell_iphi -= 2;
00132 cell_iphi += iHFTowerPhiSegment;
00133 cell_iphi += 72;
00134 cell_iphi = cell_iphi % 72;
00135 cell_iphi += 1;
00136
00137 if (cell_iphi%2 == 0) continue;
00138
00139 for (int iHFTowerEtaSegment = 0; iHFTowerEtaSegment < HfTowerEtaSize; iHFTowerEtaSegment++){
00140
00141 cell_ieta = FirstHFRingInTower + iHFTowerEtaSegment;
00142
00143 if (cell_ieta >= 40 && cell_iphi%4 == 1) continue;
00144
00145 theTopology.depthBinInformation(HcalForward, cell_ieta, n_depths, min_depth);
00146
00147
00148 if (tower_ieta < 0) cell_ieta *= -1;
00149
00150 for (int cell_depth = min_depth; cell_depth <= min_depth + n_depths - 1; cell_depth++)
00151 results.push_back(HcalDetId(HcalForward, cell_ieta, cell_iphi, cell_depth));
00152
00153 }
00154 }
00155 }
00156
00157 return results;
00158 }
00159
00160
00161 int HcalTrigTowerGeometry::hfTowerEtaSize(int ieta) const {
00162 int ietaAbs = abs(ieta);
00163 assert(ietaAbs >= firstHFTower() && ietaAbs <= nTowers());
00164
00165 return (ietaAbs == nTowers()) ? 4 : 3;
00166 }
00167
00168
00169 int HcalTrigTowerGeometry::firstHFRingInTower(int ietaTower) const {
00170
00171 int inputTower = abs(ietaTower);
00172 int result = theTopology.firstHFRing();
00173 for(int iTower = firstHFTower(); iTower != inputTower; ++iTower) {
00174 result += hfTowerEtaSize(iTower);
00175 }
00176
00177
00178 if(ietaTower < 0) result *= -1;
00179 return result;
00180 }
00181
00182
00183 void HcalTrigTowerGeometry::towerEtaBounds(int ieta, double & eta1, double & eta2) const {
00184 int ietaAbs = abs(ieta);
00185 if(ietaAbs < firstHFTower()) {
00186 eta1 = theHBHEEtaBounds[ietaAbs-1];
00187 eta2 = theHBHEEtaBounds[ietaAbs];
00188
00189 if(ietaAbs == theTopology.lastHERing()-1) {
00190 eta2 = theHBHEEtaBounds[ietaAbs+1];
00191 }
00192 } else {
00193
00194 int hfIndex = firstHFRingInTower(ietaAbs) - theTopology.firstHFRing();
00195 eta1 = theHFEtaBounds[hfIndex];
00196 eta2 = theHFEtaBounds[hfIndex + hfTowerEtaSize(ieta)];
00197 }
00198
00199
00200 if(ieta < 0) {
00201 double tmp = eta1;
00202 eta1 = -eta2;
00203 eta2 = -tmp;
00204 }
00205 }