CMS 3D CMS Logo

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