File indexing completed on 2023-03-17 11:23:48
0001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalShapes.h"
0002 #include "SimCalorimetry/CaloSimAlgos/interface/CaloCachedShapeIntegrator.h"
0003 #include "CondFormats/HcalObjects/interface/HcalMCParam.h"
0004 #include "CondFormats/HcalObjects/interface/HcalMCParams.h"
0005 #include "CondFormats/DataRecord/interface/HcalMCParamsRcd.h"
0006 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008 #include "Geometry/CaloTopology/interface/HcalTopology.h"
0009
0010 HcalShapes::HcalShapes() : theDbService(nullptr) {
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 std::vector<int> theHcalShapeNums = {101, 102, 103, 104, 105, 123, 124, 125, 201, 202, 203, 205, 206, 207, 208, 301};
0027
0028 theHcalShapes.resize(theHcalShapeNums.size());
0029 for (unsigned inum = 0; inum < theHcalShapeNums.size(); ++inum) {
0030 int num = theHcalShapeNums[inum];
0031 theHcalShapes[inum].setShape(num);
0032 theShapesPrecise[num] = &theHcalShapes[inum];
0033 theShapes[num] = new CaloCachedShapeIntegrator(&theHcalShapes[inum]);
0034 }
0035
0036
0037 theShapesPrecise[ZDC] = &theZDCShape;
0038 theShapes[ZDC] = new CaloCachedShapeIntegrator(&theZDCShape);
0039 }
0040
0041 HcalShapes::~HcalShapes() {
0042 for (auto& shapeItr : theShapes) {
0043 delete shapeItr.second;
0044 }
0045 theShapes.clear();
0046 }
0047
0048 const CaloVShape* HcalShapes::shape(const DetId& detId, bool precise) const {
0049 if (!theDbService) {
0050 return defaultShape(detId);
0051 }
0052 int shapeType = theDbService->getHcalMCParam(detId)->signalShape();
0053 const auto& myShapes = getShapeMap(precise);
0054 auto shapeMapItr = myShapes.find(shapeType);
0055 if (shapeMapItr == myShapes.end()) {
0056 edm::LogWarning("HcalShapes") << "HcalShapes::shape - shapeType ? = " << shapeType << std::endl;
0057 return defaultShape(detId, precise);
0058 } else {
0059 return shapeMapItr->second;
0060 }
0061 }
0062
0063 const CaloVShape* HcalShapes::defaultShape(const DetId& detId, bool precise) const {
0064
0065 const CaloVShape* result;
0066 const auto& myShapes = getShapeMap(precise);
0067 HcalGenericDetId::HcalGenericSubdetector subdet = HcalGenericDetId(detId).genericSubdet();
0068 if (subdet == HcalGenericDetId::HcalGenBarrel || subdet == HcalGenericDetId::HcalGenEndcap)
0069 result = myShapes.find(HPD)->second;
0070 else if (subdet == HcalGenericDetId::HcalGenOuter)
0071 result = myShapes.find(HPD)->second;
0072 else if (subdet == HcalGenericDetId::HcalGenForward)
0073 result = myShapes.find(HF)->second;
0074 else if (subdet == HcalGenericDetId::HcalGenZDC)
0075 result = myShapes.find(ZDC)->second;
0076 else
0077 result = nullptr;
0078
0079 edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params, so the default one is taken for subdet " << subdet;
0080
0081 return result;
0082 }
0083
0084 const HcalShapes::ShapeMap& HcalShapes::getShapeMap(bool precise) const {
0085 return precise ? theShapesPrecise : theShapes;
0086 }