File indexing completed on 2024-04-06 12:11:13
0001 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0002 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0003 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
0004 #include "DataFormats/DetId/interface/DetId.h"
0005 #include "DataFormats/HcalDetId/interface/HcalSubdetector.h"
0006 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
0007 #include "Geometry/EcalAlgo/interface/EcalBarrelGeometry.h"
0008 #include "Geometry/EcalAlgo/interface/EcalEndcapGeometry.h"
0009 #include "Geometry/EcalAlgo/interface/EcalPreshowerGeometry.h"
0010
0011 #include "Geometry/CaloTopology/interface/CaloTopology.h"
0012 #include "FastSimulation/CalorimeterProperties/interface/Calorimeter.h"
0013 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer1Properties.h"
0014 #include "FastSimulation/CalorimeterProperties/interface/PreshowerLayer2Properties.h"
0015 #include "FastSimulation/CalorimeterProperties/interface/ECALBarrelProperties.h"
0016 #include "FastSimulation/CalorimeterProperties/interface/ECALEndcapProperties.h"
0017 #include "FastSimulation/CalorimeterProperties/interface/HCALBarrelProperties.h"
0018 #include "FastSimulation/CalorimeterProperties/interface/HCALEndcapProperties.h"
0019 #include "FastSimulation/CalorimeterProperties/interface/HCALForwardProperties.h"
0020 #include "Geometry/HcalTowerAlgo/interface/HcalHardcodeGeometryLoader.h"
0021
0022 Calorimeter::Calorimeter()
0023 : myPreshowerLayer1Properties_(nullptr),
0024 myPreshowerLayer2Properties_(nullptr),
0025 myECALBarrelProperties_(nullptr),
0026 myECALEndcapProperties_(nullptr),
0027 myHCALBarrelProperties_(nullptr),
0028 myHCALEndcapProperties_(nullptr),
0029 myHCALForwardProperties_(nullptr),
0030 EcalBarrelGeometry_(nullptr),
0031 EcalEndcapGeometry_(nullptr),
0032 HcalGeometry_(nullptr),
0033 PreshowerGeometry_(nullptr) {
0034 ;
0035 }
0036
0037 Calorimeter::Calorimeter(const edm::ParameterSet& fastCalo)
0038 : myPreshowerLayer1Properties_(nullptr),
0039 myPreshowerLayer2Properties_(nullptr),
0040 myECALBarrelProperties_(nullptr),
0041 myECALEndcapProperties_(nullptr),
0042 myHCALBarrelProperties_(nullptr),
0043 myHCALEndcapProperties_(nullptr),
0044 myHCALForwardProperties_(nullptr),
0045 EcalBarrelGeometry_(nullptr),
0046 EcalEndcapGeometry_(nullptr),
0047 HcalGeometry_(nullptr),
0048 PreshowerGeometry_(nullptr) {
0049 edm::ParameterSet fastDet = fastCalo.getParameter<edm::ParameterSet>("CalorimeterProperties");
0050 edm::ParameterSet fastDetHF = fastCalo.getParameter<edm::ParameterSet>("ForwardCalorimeterProperties");
0051
0052 myPreshowerLayer1Properties_ = new PreshowerLayer1Properties(fastDet);
0053 myPreshowerLayer2Properties_ = new PreshowerLayer2Properties(fastDet);
0054 myECALBarrelProperties_ = new ECALBarrelProperties(fastDet);
0055 myECALEndcapProperties_ = new ECALEndcapProperties(fastDet);
0056 myHCALBarrelProperties_ = new HCALBarrelProperties(fastDet);
0057 myHCALEndcapProperties_ = new HCALEndcapProperties(fastDet);
0058 myHCALForwardProperties_ = new HCALForwardProperties(fastDetHF);
0059 }
0060
0061 Calorimeter::~Calorimeter() {
0062 if (myPreshowerLayer1Properties_)
0063 delete myPreshowerLayer1Properties_;
0064 if (myPreshowerLayer2Properties_)
0065 delete myPreshowerLayer2Properties_;
0066 if (myECALBarrelProperties_)
0067 delete myECALBarrelProperties_;
0068 if (myECALEndcapProperties_)
0069 delete myECALEndcapProperties_;
0070 if (myHCALBarrelProperties_)
0071 delete myHCALBarrelProperties_;
0072 if (myHCALEndcapProperties_)
0073 delete myHCALEndcapProperties_;
0074 if (myHCALForwardProperties_)
0075 delete myHCALForwardProperties_;
0076 }
0077
0078 const ECALProperties* Calorimeter::ecalProperties(int onEcal) const {
0079 if (onEcal) {
0080 if (onEcal == 1)
0081 return myECALBarrelProperties_;
0082 else
0083 return myECALEndcapProperties_;
0084 } else
0085 return nullptr;
0086 }
0087
0088 const HCALProperties* Calorimeter::hcalProperties(int onHcal) const {
0089 if (onHcal) {
0090 if (onHcal == 1)
0091 return myHCALBarrelProperties_;
0092 else if (onHcal == 2)
0093 return myHCALEndcapProperties_;
0094 else {
0095 return myHCALForwardProperties_;
0096 edm::LogInfo("CalorimeterProperties")
0097 << " Calorimeter::hcalProperties : set myHCALForwardProperties" << std::endl;
0098 }
0099 } else
0100 return nullptr;
0101 }
0102
0103 const PreshowerLayer1Properties* Calorimeter::layer1Properties(int onLayer1) const {
0104 if (onLayer1)
0105 return myPreshowerLayer1Properties_;
0106 else
0107 return nullptr;
0108 }
0109
0110 const PreshowerLayer2Properties* Calorimeter::layer2Properties(int onLayer2) const {
0111 if (onLayer2)
0112 return myPreshowerLayer2Properties_;
0113 else
0114 return nullptr;
0115 }
0116
0117 void Calorimeter::setupGeometry(const CaloGeometry& pG) {
0118 edm::LogInfo("CalorimeterProperties") << " setupGeometry " << std::endl;
0119 EcalBarrelGeometry_ = dynamic_cast<const EcalBarrelGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal, EcalBarrel));
0120 EcalEndcapGeometry_ = dynamic_cast<const EcalEndcapGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal, EcalEndcap));
0121 HcalGeometry_ = pG.getSubdetectorGeometry(DetId::Hcal, HcalBarrel);
0122
0123 PreshowerGeometry_ =
0124 dynamic_cast<const EcalPreshowerGeometry*>(pG.getSubdetectorGeometry(DetId::Ecal, EcalPreshower));
0125 }
0126
0127 void Calorimeter::setupTopology(const CaloTopology& theTopology) {
0128 EcalBarrelTopology_ = theTopology.getSubdetectorTopology(DetId::Ecal, EcalBarrel);
0129 EcalEndcapTopology_ = theTopology.getSubdetectorTopology(DetId::Ecal, EcalEndcap);
0130 }
0131
0132 const CaloSubdetectorGeometry* Calorimeter::getEcalGeometry(int subdetn) const {
0133 if (subdetn == 1)
0134 return EcalBarrelGeometry_;
0135 if (subdetn == 2)
0136 return EcalEndcapGeometry_;
0137 if (subdetn == 3)
0138 return PreshowerGeometry_;
0139 edm::LogWarning("Calorimeter") << "Requested an invalid ECAL subdetector geometry: " << subdetn << std::endl;
0140 return nullptr;
0141 }
0142
0143 const CaloSubdetectorTopology* Calorimeter::getEcalTopology(int subdetn) const {
0144 if (subdetn == 1)
0145 return EcalBarrelTopology_;
0146 if (subdetn == 2)
0147 return EcalEndcapTopology_;
0148 edm::LogWarning("Calorimeter") << "Requested an invalid ECAL subdetector topology: " << subdetn << std::endl;
0149 return nullptr;
0150 }