CMS 3D CMS Logo

HcalShapes.cc
Go to the documentation of this file.
11 
13 : theMCParams(nullptr),
14  theTopology(nullptr)
15  {
16 /*
17  00 - not used (reserved)
18  101 - regular HPD HB/HE/HO shape
19  102 - "special" HB HPD#14 long shape
20  201 - SiPMs Zecotec shape (HO)
21  202 - SiPMs Hamamatsu shape (HO)
22  203 - SiPMs Hamamatsu shape (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,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 
42 
44 {
45  for(auto& shapeItr : theShapes)
46  {
47  delete shapeItr.second;
48  }
49  theShapes.clear();
50  if (theMCParams!=0) delete theMCParams;
51  if (theTopology!=0) delete theTopology;
52 }
53 
54 
56 {
58  es.get<HcalMCParamsRcd>().get(p);
59  theMCParams = new HcalMCParams(*p.product());
60 
61 // here we are making a _copy_ so we need to add a copy of the topology...
62 
64  es.get<HcalRecNumberingRecord>().get(htopo);
65  theTopology=new HcalTopology(*htopo);
67 }
68 
69 
71 {
72  if (theMCParams) delete theMCParams;
73  theMCParams = 0;
74  if (theTopology) delete theTopology;
75  theTopology = 0;
76 }
77 
78 
79 const CaloVShape * HcalShapes::shape(const DetId & detId, bool precise) const
80 {
81  if(!theMCParams) {
82  return defaultShape(detId);
83  }
84  int shapeType = theMCParams->getValues(detId)->signalShape();
85  const auto& myShapes = getShapeMap(precise);
86  auto shapeMapItr = myShapes.find(shapeType);
87  if(shapeMapItr == myShapes.end()) {
88  edm::LogWarning("HcalShapes") << "HcalShapes::shape - shapeType ? = "
89  << shapeType << std::endl;
90  return defaultShape(detId,precise);
91  } else {
92  return shapeMapItr->second;
93  }
94 }
95 
96 const CaloVShape * HcalShapes::defaultShape(const DetId & detId, bool precise) const
97 {
98  // try to figure the appropriate shape
99  const CaloVShape * result;
100  const auto& myShapes = getShapeMap(precise);
102  = HcalGenericDetId(detId).genericSubdet();
103  if(subdet == HcalGenericDetId::HcalGenBarrel
104  || subdet == HcalGenericDetId::HcalGenEndcap) result = myShapes.find(HPD)->second;
105  else if(subdet == HcalGenericDetId::HcalGenOuter) result = myShapes.find(HPD)->second;
106  else if(subdet == HcalGenericDetId::HcalGenForward) result = myShapes.find(HF)->second;
107  else if(subdet == HcalGenericDetId::HcalGenZDC) result = myShapes.find(ZDC)->second;
108  else result = 0;
109 
110  edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params, so the default one is taken for subdet " << subdet;
111 
112  return result;
113 }
114 
116  return precise ? theShapesPrecise : theShapes;
117 }
Electronic response of the preamp.
Definition: CaloVShape.h:11
const Item * getValues(DetId fId, bool throwOnFail=true) const
#define nullptr
std::map< int, const CaloVShape * > ShapeMap
Definition: HcalShapes.h:32
const CaloVShape * defaultShape(const DetId &detId, bool precise=false) const
Definition: HcalShapes.cc:96
void endRun()
Definition: HcalShapes.cc:70
Definition: DetId.h:18
const ShapeMap & getShapeMap(bool precise) const
Definition: HcalShapes.cc:115
const HcalTopology * theTopology
Definition: HcalShapes.h:37
ZDCShape theZDCShape
Definition: HcalShapes.h:40
const T & get() const
Definition: EventSetup.h:56
unsigned int signalShape() const
Definition: HcalMCParam.h:40
void beginRun(edm::EventSetup const &es)
Definition: HcalShapes.cc:55
virtual const CaloVShape * shape(const DetId &detId, bool precise=false) const
Definition: HcalShapes.cc:79
std::vector< HcalShape > theHcalShapes
Definition: HcalShapes.h:42
HcalGenericSubdetector genericSubdet() const
HcalMCParams * theMCParams
Definition: HcalShapes.h:36
T const * product() const
Definition: ESHandle.h:86
void setTopo(const HcalTopology *topo)
ShapeMap theShapes
Definition: HcalShapes.h:38
ShapeMap theShapesPrecise
Definition: HcalShapes.h:39