SimCalorimetry
HcalSimAlgos
src
HcalShapes.cc
Go to the documentation of this file.
1
#include "
SimCalorimetry/HcalSimAlgos/interface/HcalShapes.h
"
2
#include "
FWCore/Framework/interface/ESHandle.h
"
3
#include "
FWCore/Framework/interface/EventSetup.h
"
4
#include "
SimCalorimetry/CaloSimAlgos/interface/CaloCachedShapeIntegrator.h
"
5
#include "
CondFormats/HcalObjects/interface/HcalMCParam.h
"
6
#include "
CondFormats/HcalObjects/interface/HcalMCParams.h
"
7
#include "
CondFormats/DataRecord/interface/HcalMCParamsRcd.h
"
8
#include "
DataFormats/HcalDetId/interface/HcalGenericDetId.h
"
9
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
10
#include "
Geometry/CaloTopology/interface/HcalTopology.h
"
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
208 - SiPMs from Data, 2021 MC phase scan
24
301 - regular HF PMT shape
25
401 - regular ZDC shape
26
*/
27
28
std::vector<int> theHcalShapeNums = {101, 102, 103, 104, 105, 123, 124, 125, 201, 202, 203, 205, 206, 207, 208, 301};
29
// use resize so vector won't invalidate pointers by reallocating memory while filling
30
theHcalShapes
.resize(theHcalShapeNums.size());
31
for
(
unsigned
inum = 0; inum < theHcalShapeNums.size(); ++inum) {
32
int
num
= theHcalShapeNums[inum];
33
theHcalShapes
[inum].setShape(
num
);
34
theShapesPrecise
[
num
] = &
theHcalShapes
[inum];
35
theShapes
[
num
] =
new
CaloCachedShapeIntegrator
(&
theHcalShapes
[inum]);
36
}
37
38
// ZDC not yet defined in CalibCalorimetry/HcalAlgos/src/HcalPulseShapes.cc
39
theShapesPrecise
[
ZDC
] = &
theZDCShape
;
40
theShapes
[
ZDC
] =
new
CaloCachedShapeIntegrator
(&
theZDCShape
);
41
}
42
43
HcalShapes::~HcalShapes
() {
44
for
(
auto
& shapeItr :
theShapes
) {
45
delete
shapeItr.second;
46
}
47
theShapes
.clear();
48
}
49
50
const
CaloVShape
*
HcalShapes::shape
(
const
DetId
& detId,
bool
precise
)
const
{
51
if
(!
theDbService
) {
52
return
defaultShape
(detId);
53
}
54
int
shapeType =
theDbService
->
getHcalMCParam
(detId)->
signalShape
();
55
const
auto
& myShapes =
getShapeMap
(
precise
);
56
auto
shapeMapItr = myShapes.find(shapeType);
57
if
(shapeMapItr == myShapes.end()) {
58
edm::LogWarning
(
"HcalShapes"
) <<
"HcalShapes::shape - shapeType ? = "
<< shapeType << std::endl;
59
return
defaultShape
(detId,
precise
);
60
}
else
{
61
return
shapeMapItr->second;
62
}
63
}
64
65
const
CaloVShape
*
HcalShapes::defaultShape
(
const
DetId
& detId,
bool
precise
)
const
{
66
// try to figure the appropriate shape
67
const
CaloVShape
*
result
;
68
const
auto
& myShapes =
getShapeMap
(
precise
);
69
HcalGenericDetId::HcalGenericSubdetector
subdet =
HcalGenericDetId
(detId).
genericSubdet
();
70
if
(subdet ==
HcalGenericDetId::HcalGenBarrel
|| subdet ==
HcalGenericDetId::HcalGenEndcap
)
71
result
= myShapes.find(
HPD
)->second;
72
else
if
(subdet ==
HcalGenericDetId::HcalGenOuter
)
73
result
= myShapes.find(
HPD
)->second;
74
else
if
(subdet ==
HcalGenericDetId::HcalGenForward
)
75
result
= myShapes.find(
HF
)->second;
76
else
if
(subdet ==
HcalGenericDetId::HcalGenZDC
)
77
result
= myShapes.find(
ZDC
)->second;
78
else
79
result
=
nullptr
;
80
81
edm::LogWarning
(
"HcalShapes"
) <<
"Cannot find HCAL MC Params, so the default one is taken for subdet "
<< subdet;
82
83
return
result
;
84
}
85
86
const
HcalShapes::ShapeMap
&
HcalShapes::getShapeMap
(
bool
precise
)
const
{
87
return
precise
?
theShapesPrecise
:
theShapes
;
88
}
HcalShapes::getShapeMap
const ShapeMap & getShapeMap(bool precise) const
Definition:
HcalShapes.cc:86
MessageLogger.h
hltPixelTracks_cff.precise
precise
Definition:
hltPixelTracks_cff.py:32
ESHandle.h
HcalGenericDetId
Definition:
HcalGenericDetId.h:15
HcalShapes::theShapesPrecise
ShapeMap theShapesPrecise
Definition:
HcalShapes.h:35
HcalShapes::HcalShapes
HcalShapes()
Definition:
HcalShapes.cc:12
HcalShapes.h
HcalGenericDetId::HcalGenEndcap
Definition:
HcalGenericDetId.h:20
HcalGenericDetId.h
HcalShapes::theZDCShape
ZDCShape theZDCShape
Definition:
HcalShapes.h:36
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition:
MessageLogger.h:122
HcalShapes::theDbService
const HcalDbService * theDbService
Definition:
HcalShapes.h:33
HcalDbService::getHcalMCParam
const HcalMCParam * getHcalMCParam(const HcalGenericDetId &fId) const
Definition:
HcalDbService.cc:398
HcalGenericDetId::HcalGenZDC
Definition:
HcalGenericDetId.h:24
DetId
Definition:
DetId.h:17
HcalShapes::~HcalShapes
~HcalShapes() override
Definition:
HcalShapes.cc:43
HcalShapes::theShapes
ShapeMap theShapes
Definition:
HcalShapes.h:34
HcalShapes::defaultShape
const CaloVShape * defaultShape(const DetId &detId, bool precise=false) const
Definition:
HcalShapes.cc:65
HcalShapes::shape
const CaloVShape * shape(const DetId &detId, bool precise=false) const override
Definition:
HcalShapes.cc:50
CaloCachedShapeIntegrator
Definition:
CaloCachedShapeIntegrator.h:12
HcalShapes::theHcalShapes
std::vector< HcalShape > theHcalShapes
Definition:
HcalShapes.h:38
HcalGenericDetId::HcalGenericSubdetector
HcalGenericSubdetector
Definition:
HcalGenericDetId.h:17
HcalMCParams.h
HcalShapes::HF
Definition:
HcalShapes.h:20
HcalShapes::ZDC
Definition:
HcalShapes.h:20
HcalShapes::HPD
Definition:
HcalShapes.h:20
HcalGenericDetId::HcalGenBarrel
Definition:
HcalGenericDetId.h:19
CaloVShape
Electronic response of the preamp.
Definition:
CaloVShape.h:11
EgammaValidation_cff.num
num
Definition:
EgammaValidation_cff.py:34
HcalMCParam::signalShape
unsigned int signalShape() const
Definition:
HcalMCParam.h:38
HcalTopology.h
CaloCachedShapeIntegrator.h
HcalGenericDetId::genericSubdet
HcalGenericSubdetector genericSubdet() const
Definition:
HcalGenericDetId.cc:21
HcalMCParamsRcd.h
EventSetup.h
HcalMCParam.h
HcalGenericDetId::HcalGenOuter
Definition:
HcalGenericDetId.h:21
mps_fire.result
result
Definition:
mps_fire.py:311
HcalGenericDetId::HcalGenForward
Definition:
HcalGenericDetId.h:22
HcalShapes::ShapeMap
std::map< int, const CaloVShape * > ShapeMap
Definition:
HcalShapes.h:29
Generated for CMSSW Reference Manual by
1.8.16