CMS 3D CMS Logo

ZdcGeometry.cc

Go to the documentation of this file.
00001 #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
00002 #include "Geometry/ForwardGeometry/interface/ZdcGeometry.h"
00003 #include "ZdcHardcodeGeometryData.h"
00004 
00005 ZdcGeometry::ZdcGeometry(const ZdcTopology * topology) 
00006 : theTopology(topology),
00007   lastReqDet_(DetId::Detector(0)), 
00008   lastReqSubdet_(0) 
00009 {
00010 }
00011 
00012 ZdcGeometry::~ZdcGeometry() {
00013 }
00014 
00015 std::vector<DetId> const & ZdcGeometry::getValidDetIds(DetId::Detector det, int subdet) const {
00016   if (lastReqDet_!=det || lastReqSubdet_!=subdet) {
00017     lastReqDet_=det;
00018     lastReqSubdet_=subdet;
00019     m_validIds.clear();
00020   }
00021   if (m_validIds.empty()) {
00022     m_validIds.reserve(cellGeometries().size());
00023     CaloSubdetectorGeometry::CellCont::const_iterator i;
00024     for (i=cellGeometries().begin(); i!=cellGeometries().end(); i++) {
00025       DetId id(i->first);
00026       if (id.det()==det && id.subdetId()==subdet) 
00027         m_validIds.push_back(id);
00028     }
00029       std::sort(m_validIds.begin(),m_validIds.end());
00030   }
00031 
00032   return m_validIds;
00033 }
00034 
00035 
00036 DetId ZdcGeometry::getClosestCell(const GlobalPoint& r) const
00037 {
00038   // first find the side
00039   double z = r.z();
00040   double x = r.x();
00041   double y = r.y();
00042   double dz = 0.;
00043   double zt = 0.;
00044 
00045   int zside = 0;
00046   if(z >= 0)
00047     zside = 1;
00048   else
00049     zside =-1;
00050 
00051   bool isPositive = false;
00052   if(z>0)isPositive = true;
00053   z = fabs(z);
00054   
00055   // figure out if is closer to EM, HAD or LUM section
00056   HcalZDCDetId::Section section = HcalZDCDetId::Unknown;
00057   if(z<= theZSectionBoundaries[1])section = HcalZDCDetId::EM;
00058   if(theZSectionBoundaries[1]<z<= theZSectionBoundaries[2])section = HcalZDCDetId::LUM;
00059   if(z>theZSectionBoundaries[2])section = HcalZDCDetId::HAD;
00060 
00061   // figure out channel
00062   int channel = -1;
00063   if(section ==HcalZDCDetId::EM){
00064     if(x < theXChannelBoundaries[1]) channel = 1;
00065     if(theXChannelBoundaries[1]<= x <theXChannelBoundaries[2])channel = 2;
00066     if(theXChannelBoundaries[2]<= x <theXChannelBoundaries[3])channel = 3;
00067     if(theXChannelBoundaries[3]<= x <theXChannelBoundaries[4])channel = 4;
00068     if(x > theXChannelBoundaries[4])channel = 5;
00069   }
00070   
00071   if(section == HcalZDCDetId::LUM){
00072     if(z <= theZLUMChannelBoundaries[1])channel = 1;
00073     if(z > theZLUMChannelBoundaries[1])channel = 2;
00074   } 
00075   if(section == HcalZDCDetId::HAD){
00076     if(fabs(y) > dYPlate*sin(tiltangle))
00077       dz = (y > 0.) ?  dYPlate*cos(tiltangle) : -  dYPlate*sin(tiltangle);
00078     else
00079       dz = (y > 0.) ?  y/tan(tiltangle) : -y/tan(tiltangle); 
00080     zt = z - dz;
00081     if(zt< theZHadChannelBoundaries[1]) channel = 1;
00082     if(theZHadChannelBoundaries[1]<=  zt <theZHadChannelBoundaries[2])channel = 2;
00083     if(theZHadChannelBoundaries[2]<=  zt <theZHadChannelBoundaries[3])channel = 3;
00084     if(zt > theZHadChannelBoundaries[4])channel = 4;
00085   }
00086   
00087   HcalZDCDetId bestId  = HcalZDCDetId(section,isPositive,channel);
00088   return bestId;
00089 }
00090 

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