CMS 3D CMS Logo

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