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  205 - SiPMs from Data (HE data 2017)
24  206 - SiPMs Hamamatsu shape (HE 2018)
25  207 - SiPMs from Data (HE 2017)
26  301 - regular HF PMT shape
27  401 - regular ZDC shape
28  */
29 
30  std::vector<int> theHcalShapeNums = {101,102,103,104,105,123,124,125,201,202,203,205,206,207,301};
31  // use resize so vector won't invalidate pointers by reallocating memory while filling
32  theHcalShapes.resize(theHcalShapeNums.size());
33  for(unsigned inum = 0; inum < theHcalShapeNums.size(); ++inum){
34  int num = theHcalShapeNums[inum];
35  theHcalShapes[inum].setShape(num);
38  }
39 
40  // ZDC not yet defined in CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc
43 }
44 
45 
47 {
48  for(auto& shapeItr : theShapes)
49  {
50  delete shapeItr.second;
51  }
52  theShapes.clear();
53  if (theMCParams!=nullptr) delete theMCParams;
54  if (theTopology!=nullptr) delete theTopology;
55 }
56 
57 
59 {
61  es.get<HcalMCParamsRcd>().get(p);
62  theMCParams = new HcalMCParams(*p.product());
63 
64 // here we are making a _copy_ so we need to add a copy of the topology...
65 
67  es.get<HcalRecNumberingRecord>().get(htopo);
68  theTopology=new HcalTopology(*htopo);
70 }
71 
72 
74 {
75  if (theMCParams) delete theMCParams;
76  theMCParams = nullptr;
77  if (theTopology) delete theTopology;
78  theTopology = nullptr;
79 }
80 
81 
82 const CaloVShape * HcalShapes::shape(const DetId & detId, bool precise) const
83 {
84  if(!theMCParams) {
85  return defaultShape(detId);
86  }
87  int shapeType = theMCParams->getValues(detId)->signalShape();
88  const auto& myShapes = getShapeMap(precise);
89  auto shapeMapItr = myShapes.find(shapeType);
90  if(shapeMapItr == myShapes.end()) {
91  edm::LogWarning("HcalShapes") << "HcalShapes::shape - shapeType ? = "
92  << shapeType << std::endl;
93  return defaultShape(detId,precise);
94  } else {
95  return shapeMapItr->second;
96  }
97 }
98 
99 const CaloVShape * HcalShapes::defaultShape(const DetId & detId, bool precise) const
100 {
101  // try to figure the appropriate shape
102  const CaloVShape * result;
103  const auto& myShapes = getShapeMap(precise);
105  = HcalGenericDetId(detId).genericSubdet();
106  if(subdet == HcalGenericDetId::HcalGenBarrel
107  || subdet == HcalGenericDetId::HcalGenEndcap) result = myShapes.find(HPD)->second;
108  else if(subdet == HcalGenericDetId::HcalGenOuter) result = myShapes.find(HPD)->second;
109  else if(subdet == HcalGenericDetId::HcalGenForward) result = myShapes.find(HF)->second;
110  else if(subdet == HcalGenericDetId::HcalGenZDC) result = myShapes.find(ZDC)->second;
111  else result = nullptr;
112 
113  edm::LogWarning("HcalShapes") << "Cannot find HCAL MC Params, so the default one is taken for subdet " << subdet;
114 
115  return result;
116 }
117 
119  return precise ? theShapesPrecise : theShapes;
120 }
Electronic response of the preamp.
Definition: CaloVShape.h:11
const Item * getValues(DetId fId, bool throwOnFail=true) const
#define nullptr
const CaloVShape * shape(const DetId &detId, bool precise=false) const override
Definition: HcalShapes.cc:82
std::map< int, const CaloVShape * > ShapeMap
Definition: HcalShapes.h:32
const CaloVShape * defaultShape(const DetId &detId, bool precise=false) const
Definition: HcalShapes.cc:99
~HcalShapes() override
Definition: HcalShapes.cc:46
void endRun()
Definition: HcalShapes.cc:73
Definition: DetId.h:18
const ShapeMap & getShapeMap(bool precise) const
Definition: HcalShapes.cc:118
const HcalTopology * theTopology
Definition: HcalShapes.h:37
ZDCShape theZDCShape
Definition: HcalShapes.h:40
const T & get() const
Definition: EventSetup.h:58
unsigned int signalShape() const
Definition: HcalMCParam.h:40
void beginRun(edm::EventSetup const &es)
Definition: HcalShapes.cc:58
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