CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/Calibration/IsolatedParticles/src/DetIdFromEtaPhi.cc

Go to the documentation of this file.
00001 #include "Calibration/IsolatedParticles/interface/DetIdFromEtaPhi.h"
00002 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00003 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
00004 #include "DataFormats/Math/interface/Point3D.h"
00005 #include "DataFormats/EcalDetId/interface/EBDetId.h"
00006 #include "DataFormats/EcalDetId/interface/EEDetId.h"
00007 #include "DataFormats/HcalDetId/interface/HcalDetId.h"
00008 
00009 namespace spr{
00010 
00011   const DetId findDetIdECAL( const CaloGeometry* geo, double eta, double phi, bool debug) {
00012     double radius=0;
00013     int    subdet=0;
00014     double theta=2.0*std::atan(exp(-eta));
00015     if (std::abs(eta) > 1.479) {
00016       radius = 319.2/std::abs(std::cos(theta));
00017       subdet = EcalEndcap;
00018     } else {
00019       radius = 129.4/std::sin(theta);
00020       subdet = EcalBarrel;
00021     }
00022     const CaloSubdetectorGeometry* gECAL = geo->getSubdetectorGeometry(DetId::Ecal,subdet);
00023     if (debug) std::cout << "findDetIdECAL: eta " << eta << " theta " << theta <<" phi " << phi << " radius " << radius << " subdet " << subdet << std::endl;
00024     return spr::findDetIdCalo (gECAL, theta, phi, radius, debug);
00025   }
00026 
00027   const DetId findDetIdHCAL( const CaloGeometry* geo, double eta, double phi, bool debug) {
00028     double radius=0;
00029     double theta=2.0*std::atan(exp(-eta));
00030     if (std::abs(eta) > 1.392) radius = 402.7/std::abs(std::cos(theta));
00031     else                       radius = 180.7/std::sin(theta);
00032     const CaloSubdetectorGeometry* gHCAL = geo->getSubdetectorGeometry(DetId::Hcal,HcalBarrel);
00033     if (debug) std::cout << "findDetIdHCAL: eta " << eta <<" theta "<<theta<< " phi " << phi << " radius " << radius << std::endl;
00034     return spr::findDetIdCalo (gHCAL, theta, phi, radius, debug);
00035   }
00036 
00037   const DetId findDetIdCalo( const CaloSubdetectorGeometry* geo, double theta, double phi, double radius, bool debug) {
00038     
00039     double rcyl = radius*std::sin(theta);
00040     double z    = radius*std::cos(theta);
00041     GlobalPoint  point (rcyl*std::cos(phi),rcyl*std::sin(phi),z);
00042     const DetId cell = geo->getClosestCell(point);
00043     if (debug) {
00044       std::cout << "findDetIdCalo: rcyl " << rcyl << " z " << z << " Point " << point << " DetId ";
00045       if (cell.det() == DetId::Ecal) {
00046         if (cell.subdetId() == EcalBarrel) std::cout << (EBDetId)(cell);
00047         else                               std::cout << (EEDetId)(cell);
00048       } else {
00049         std::cout << (HcalDetId)(cell);
00050       }
00051       std::cout << std::endl;
00052     }
00053     return cell;
00054   }
00055 
00056 }