CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalShapes.cc
Go to the documentation of this file.
11 
12 HcalShapes::HcalShapes() : theDbService(nullptr) {
13  /*
14  00 - not used (reserved)
15  101 - regular HPD HB/HE/HO shape
16  102 - "special" HB HPD#14 long shape
17  201 - SiPMs Zecotec shape (HO)
18  202 - SiPMs Hamamatsu shape (HO)
19  203 - SiPMs Hamamatsu shape (HE 2017)
20  205 - SiPMs from Data (HE data 2017)
21  206 - SiPMs Hamamatsu shape (HE 2018)
22  207 - SiPMs from Data (HE 2017)
23  301 - regular HF PMT shape
24  401 - regular ZDC shape
25  */
26 
27  std::vector<int> theHcalShapeNums = {101, 102, 103, 104, 105, 123, 124, 125, 201, 202, 203, 205, 206, 207, 301};
28  // use resize so vector won't invalidate pointers by reallocating memory while filling
29  theHcalShapes.resize(theHcalShapeNums.size());
30  for (unsigned inum = 0; inum < theHcalShapeNums.size(); ++inum) {
31  int num = theHcalShapeNums[inum];
32  theHcalShapes[inum].setShape(num);
35  }
36 
37  // ZDC not yet defined in CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc
40 }
41 
43  for (auto& shapeItr : theShapes) {
44  delete shapeItr.second;
45  }
46  theShapes.clear();
47 }
48 
49 const CaloVShape* HcalShapes::shape(const DetId& detId, bool precise) const {
50  if (!theDbService) {
51  return defaultShape(detId);
52  }
53  int shapeType = theDbService->getHcalMCParam(detId)->signalShape();
54  const auto& myShapes = getShapeMap(precise);
55  auto shapeMapItr = myShapes.find(shapeType);
56  if (shapeMapItr == myShapes.end()) {
57  edm::LogWarning("HcalShapes") << "HcalShapes::shape - shapeType ? = " << shapeType << std::endl;
58  return defaultShape(detId, precise);
59  } else {
60  return shapeMapItr->second;
61  }
62 }
63 
64 const CaloVShape* HcalShapes::defaultShape(const DetId& detId, bool precise) const {
65  // try to figure the appropriate shape
66  const CaloVShape* result;
67  const auto& myShapes = getShapeMap(precise);
70  result = myShapes.find(HPD)->second;
71  else if (subdet == HcalGenericDetId::HcalGenOuter)
72  result = myShapes.find(HPD)->second;
73  else if (subdet == HcalGenericDetId::HcalGenForward)
74  result = myShapes.find(HF)->second;
75  else if (subdet == HcalGenericDetId::HcalGenZDC)
76  result = myShapes.find(ZDC)->second;
77  else
78  result = nullptr;
79 
80  edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params, so the default one is taken for subdet " << subdet;
81 
82  return result;
83 }
84 
86  return precise ? theShapesPrecise : theShapes;
87 }
std::map< int, const CaloVShape * > ShapeMap
Definition: HcalShapes.h:29
#define nullptr
Electronic response of the preamp.
Definition: CaloVShape.h:11
const CaloVShape * shape(const DetId &detId, bool precise=false) const override
Definition: HcalShapes.cc:49
const CaloVShape * defaultShape(const DetId &detId, bool precise=false) const
Definition: HcalShapes.cc:64
~HcalShapes() override
Definition: HcalShapes.cc:42
const HcalMCParam * getHcalMCParam(const HcalGenericDetId &fId) const
Definition: DetId.h:17
const ShapeMap & getShapeMap(bool precise) const
Definition: HcalShapes.cc:85
ZDCShape theZDCShape
Definition: HcalShapes.h:36
unsigned int signalShape() const
Definition: HcalMCParam.h:38
const HcalDbService * theDbService
Definition: HcalShapes.h:33
std::vector< HcalShape > theHcalShapes
Definition: HcalShapes.h:38
HcalGenericSubdetector genericSubdet() const
ShapeMap theShapes
Definition: HcalShapes.h:34
ShapeMap theShapesPrecise
Definition: HcalShapes.h:35