CMS 3D CMS Logo

HcalTrigTowerGeometry.cc

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     // short fibers don't count
00026     if(cellId.depth() == 1 || useShortFibers_) {
00027       // first do eta
00028       int hfRing = cellId.ietaAbs();
00029       int ieta = firstHFTower(); 
00030       // find the tower that contains this ring
00031       while(hfRing >= firstHFRingInTower(ieta+1)) {
00032         ++ieta;
00033       }
00034 
00035       ieta *= cellId.zside();
00036 
00037       // now for phi
00038       // HF towers are quad, 18 in phi.
00039       // go two cells per trigger tower.
00040       int iphi = (((cellId.iphi()+1)/4) * 4 + 1)%72; // 71+1 --> 1, 3+5 --> 5
00041       if (useHFQuadPhiRings_ || cellId.ietaAbs() < theTopology.firstHFQuadPhiRing())
00042         results.push_back( HcalTrigTowerDetId(ieta, iphi) );
00043     }
00044       
00045   } else {
00046     // the first twenty rings are one-to-one
00047     if(cellId.ietaAbs() < theTopology.firstHEDoublePhiRing()) {    
00048       results.push_back( HcalTrigTowerDetId(cellId.ieta(), cellId.iphi()) );
00049     } else {
00050       // the remaining rings are two-to-one in phi
00051       int iphi1 = cellId.iphi();
00052       int ieta = cellId.ieta();
00053       // the last eta ring in HE is split.  Recombine.
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 &) const {
00068   std::vector<HcalDetId> results;
00069   return results;
00070 }
00071 
00072 
00073 int HcalTrigTowerGeometry::hfTowerEtaSize(int ieta) const {
00074   int ietaAbs = abs(ieta); 
00075   assert(ietaAbs >= firstHFTower() && ietaAbs <= nTowers());
00076   // the first three come from rings 29-31, 32-34, 35-37. The last has 4 rings: 38-41
00077   return (ietaAbs == nTowers()) ? 4 : 3;
00078 }
00079 
00080 
00081 int HcalTrigTowerGeometry::firstHFRingInTower(int ietaTower) const {
00082   // count up to the correct HF ring
00083   int inputTower = abs(ietaTower);
00084   int result = theTopology.firstHFRing();
00085   for(int iTower = firstHFTower(); iTower != inputTower; ++iTower) {
00086     result += hfTowerEtaSize(iTower);
00087   }
00088   
00089   // negative in, negative out.
00090   if(ietaTower < 0) result *= -1;
00091   return result;
00092 }
00093 
00094 
00095 void HcalTrigTowerGeometry::towerEtaBounds(int ieta, double & eta1, double & eta2) const {
00096   int ietaAbs = abs(ieta);
00097   if(ietaAbs < firstHFTower()) {
00098     eta1 = theHBHEEtaBounds[ietaAbs-1];
00099     eta2 = theHBHEEtaBounds[ietaAbs];
00100     // the last tower is split, so get tower 29, too
00101     if(ietaAbs == theTopology.lastHERing()-1) {
00102       eta2 = theHBHEEtaBounds[ietaAbs+1];
00103     } 
00104   } else {
00105     // count from 0
00106     int hfIndex = firstHFRingInTower(ietaAbs) - theTopology.firstHFRing();
00107     eta1 = theHFEtaBounds[hfIndex];
00108     eta2 = theHFEtaBounds[hfIndex + hfTowerEtaSize(ieta)];
00109   }
00110 
00111   // get the signs and order right
00112   if(ieta < 0) {
00113     double tmp = eta1;
00114     eta1 = -eta2;
00115     eta2 = -tmp;
00116   }
00117 }

Generated on Tue Jun 9 17:37:31 2009 for CMSSW by  doxygen 1.5.4