CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/FastSimulation/CalorimeterProperties/src/Calorimeter.cc

Go to the documentation of this file.
00001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00003 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00004 #include "DataFormats/DetId/interface/DetId.h"
00005 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00006 #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
00007 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
00008 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
00009 
00010 #include "Geometry/CaloTopology/interface/CaloTopology.h"
00011 #include "FastSimulation/CalorimeterProperties/interface/Calorimeter.h"
00012 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer1Properties.h"
00013 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer2Properties.h"
00014 #include "FastSimulation/CalorimeterProperties/interface/ECALBarrelProperties.h"
00015 #include "FastSimulation/CalorimeterProperties/interface/ECALEndcapProperties.h"
00016 #include "FastSimulation/CalorimeterProperties/interface/HCALBarrelProperties.h"
00017 #include "FastSimulation/CalorimeterProperties/interface/HCALEndcapProperties.h"
00018 #include "FastSimulation/CalorimeterProperties/interface/HCALForwardProperties.h"
00019 #include "Geometry/HcalTowerAlgo/interface/HcalHardcodeGeometryLoader.h"
00020 
00021 Calorimeter::Calorimeter():
00022   myPreshowerLayer1Properties_(NULL),
00023   myPreshowerLayer2Properties_(NULL),  
00024   myECALBarrelProperties_     (NULL),  
00025   myECALEndcapProperties_     (NULL),  
00026   myHCALBarrelProperties_     (NULL),  
00027   myHCALEndcapProperties_     (NULL),  
00028   myHCALForwardProperties_    (NULL),
00029   EcalBarrelGeometry_         (NULL),
00030   EcalEndcapGeometry_         (NULL),
00031   HcalGeometry_               (NULL),
00032   PreshowerGeometry_          (NULL)
00033 {
00034 ;
00035 }
00036 
00037 Calorimeter::Calorimeter(const edm::ParameterSet& fastCalo):
00038   myPreshowerLayer1Properties_(NULL),
00039   myPreshowerLayer2Properties_(NULL),  
00040   myECALBarrelProperties_     (NULL),  
00041   myECALEndcapProperties_     (NULL),  
00042   myHCALBarrelProperties_     (NULL),  
00043   myHCALEndcapProperties_     (NULL),  
00044   myHCALForwardProperties_    (NULL),
00045   EcalBarrelGeometry_        (NULL),
00046   EcalEndcapGeometry_          (NULL),
00047   HcalGeometry_               (NULL),
00048   PreshowerGeometry_          (NULL)  
00049 {
00050   edm::ParameterSet fastDet = fastCalo.getParameter<edm::ParameterSet>("CalorimeterProperties");
00051   myPreshowerLayer1Properties_  = new PreshowerLayer1Properties(fastDet); 
00052   myPreshowerLayer2Properties_  = new PreshowerLayer2Properties(fastDet);
00053   myECALBarrelProperties_       = new ECALBarrelProperties     (fastDet);
00054   myECALEndcapProperties_       = new ECALEndcapProperties     (fastDet);
00055   myHCALBarrelProperties_       = new HCALBarrelProperties     (fastDet);
00056   myHCALEndcapProperties_       = new HCALEndcapProperties     (fastDet);
00057   myHCALForwardProperties_      = new HCALForwardProperties    (fastDet);
00058 
00059 }
00060 
00061 Calorimeter::~Calorimeter()
00062 {
00063   if(myPreshowerLayer1Properties_        )  delete myPreshowerLayer1Properties_      ;
00064   if(myPreshowerLayer2Properties_        )  delete myPreshowerLayer2Properties_      ;
00065   if(myECALBarrelProperties_             )  delete myECALBarrelProperties_           ;
00066   if(myECALEndcapProperties_             )  delete myECALEndcapProperties_           ;
00067   if(myHCALBarrelProperties_             )  delete myHCALBarrelProperties_           ;
00068   if(myHCALEndcapProperties_             )  delete myHCALEndcapProperties_           ;
00069   if(myHCALForwardProperties_            )  delete myHCALForwardProperties_          ;
00070 }
00071 
00072 const ECALProperties*
00073 Calorimeter::ecalProperties(int onEcal) const {
00074   if ( onEcal ) {
00075     if ( onEcal == 1 ) 
00076       return myECALBarrelProperties_;
00077     else
00078       return myECALEndcapProperties_;
00079   } else
00080     return NULL;
00081 }
00082 
00083 const HCALProperties*
00084 Calorimeter::hcalProperties(int onHcal) const {
00085   if ( onHcal ) {
00086     if ( onHcal == 1 ) 
00087       return myHCALBarrelProperties_;
00088     else 
00089       if ( onHcal == 2 ) 
00090         return myHCALEndcapProperties_;
00091       else {
00092         return myHCALForwardProperties_;
00093         edm::LogInfo("CalorimeterProperties") << " Calorimeter::hcalProperties : set myHCALForwardProperties" << std::endl;
00094       }
00095   } else
00096     return NULL;
00097 }
00098 
00099 const PreshowerLayer1Properties*
00100 Calorimeter::layer1Properties(int onLayer1) const {
00101   if ( onLayer1 ) 
00102     return myPreshowerLayer1Properties_;
00103   else
00104     return NULL;
00105 }
00106 
00107 const PreshowerLayer2Properties*
00108 Calorimeter::layer2Properties(int onLayer2) const {
00109   if ( onLayer2 ) 
00110     return myPreshowerLayer2Properties_;
00111   else
00112     return NULL;
00113 }
00114 
00115 void Calorimeter::setupGeometry(const CaloGeometry& pG)
00116 {
00117   edm::LogInfo("CalorimeterProperties") << " setupGeometry " << std::endl;
00118   EcalBarrelGeometry_ = dynamic_cast<const EcalBarrelGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal,EcalBarrel));
00119   EcalEndcapGeometry_ = dynamic_cast<const EcalEndcapGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal,EcalEndcap));
00120   HcalGeometry_ = pG.getSubdetectorGeometry(DetId::Hcal,HcalBarrel);
00121   // Takes a lot of time
00122   PreshowerGeometry_  = dynamic_cast<const EcalPreshowerGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal,EcalPreshower));
00123 }
00124 
00125 void Calorimeter::setupTopology(const CaloTopology& theTopology)
00126 {
00127   EcalBarrelTopology_ = theTopology.getSubdetectorTopology(DetId::Ecal,EcalBarrel);
00128   EcalEndcapTopology_ = theTopology.getSubdetectorTopology(DetId::Ecal,EcalEndcap);
00129 }
00130 
00131 
00132 
00133 const CaloSubdetectorGeometry * Calorimeter::getEcalGeometry(int subdetn) const
00134 {
00135   if(subdetn==1) return EcalBarrelGeometry_;
00136   if(subdetn==2) return EcalEndcapGeometry_;
00137   if(subdetn==3) return PreshowerGeometry_;
00138   edm::LogWarning("Calorimeter") << "Requested an invalid ECAL subdetector geometry: " << subdetn << std::endl;
00139   return 0;
00140 }
00141 
00142 const CaloSubdetectorTopology * Calorimeter::getEcalTopology(int subdetn) const
00143 {
00144   if(subdetn==1) return EcalBarrelTopology_;
00145   if(subdetn==2) return EcalEndcapTopology_;
00146   edm::LogWarning("Calorimeter") << "Requested an invalid ECAL subdetector topology: " << subdetn << std::endl;
00147   return 0;
00148 }