CMS 3D CMS Logo

HcalHitRelabeller.cc
Go to the documentation of this file.
4 
6 
7 //#define EDM_ML_DEBUG
8 
9 HcalHitRelabeller::HcalHitRelabeller(bool nd) : theRecNumber(nullptr), neutralDensity_(nd) {
10 #ifdef EDM_ML_DEBUG
11  edm::LogVerbatim("HcalSim") << "HcalHitRelabeller initialized with"
12  << " neutralDensity " << neutralDensity_;
13 #endif
14 }
15 
16 void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
17  if (theRecNumber) {
18 #ifdef EDM_ML_DEBUG
19  int ii(0);
20 #endif
21  for (auto& hcalHit : hcalHits) {
22 #ifdef EDM_ML_DEBUG
23  edm::LogVerbatim("HcalSim") << "Hit[" << ii << "] " << std::hex << hcalHit.id() << std::dec << " Neutral density "
24  << neutralDensity_;
25 #endif
26  double energy = (hcalHit.energy());
27  if (neutralDensity_) {
28  energy *= (energyWt(hcalHit.id()));
29  hcalHit.setEnergy(energy);
30  }
31  DetId newid = relabel(hcalHit.id());
32 #ifdef EDM_ML_DEBUG
33  edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid.rawId()
34  << std::dec << " E " << energy;
35 #endif
36  hcalHit.setID(newid.rawId());
37 #ifdef EDM_ML_DEBUG
38  edm::LogVerbatim("HcalSim") << "Modified Hit " << HcalDetId(hcalHit.id());
39  ++ii;
40 #endif
41  }
42  } else {
43  edm::LogWarning("HcalSim") << "HcalHitRelabeller: no valid HcalDDDRecConstants";
44  }
45 }
46 
48 
49 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
51 }
52 
53 DetId HcalHitRelabeller::relabel(const uint32_t testId, const HcalDDDRecConstants* theRecNumber) {
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HcalSim") << "Enter HcalHitRelabeller::relabel";
56 #endif
57  HcalDetId hid;
58  int det, z, depth, eta, phi, layer, sign;
59  HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer);
60 #ifdef EDM_ML_DEBUG
61  edm::LogVerbatim("HcalSim") << "det: " << det << " "
62  << "z: " << z << " "
63  << "depth: " << depth << " "
64  << "ieta: " << eta << " "
65  << "iphi: " << phi << " "
66  << "layer: " << layer;
67 #endif
68  sign = (z == 0) ? (-1) : (1);
70 
71  if (id.subdet == int(HcalBarrel)) {
72  hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, id.depth);
73  } else if (id.subdet == int(HcalEndcap)) {
74  hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, id.depth);
75  } else if (id.subdet == int(HcalOuter)) {
76  hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, id.depth);
77  } else if (id.subdet == int(HcalForward)) {
78  hid = HcalDetId(HcalForward, sign * id.eta, id.phi, id.depth);
79  }
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("HcalSim") << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId() << std::dec
82  << " det, z, depth, eta, phi = " << det << " " << z << " " << id.depth << " " << id.eta
83  << " " << id.phi << " ---> " << hid;
84 #endif
85  return hid;
86 }
87 
88 double HcalHitRelabeller::energyWt(const uint32_t testId) const {
89  int det, z, depth, eta, phi, layer;
90  HcalTestNumbering::unpackHcalIndex(testId, det, z, depth, eta, phi, layer);
91  int zside = (z == 0) ? (-1) : (1);
92  double wt = (((det == 1) || (det == 2)) && (depth == 1)) ? theRecNumber->getLayer0Wt(det, phi, zside) : 1.0;
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HcalSim") << "EnergyWT::det: " << det << " z: " << z << ":" << zside << " depth: " << depth
95  << " ieta: " << eta << " iphi: " << phi << " layer: " << layer << " wt " << wt;
96 #endif
97  return wt;
98 }
MessageLogger.h
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
HcalHitRelabeller::setGeometry
void setGeometry(const HcalDDDRecConstants *&)
Definition: HcalHitRelabeller.cc:47
Validation_hcalonly_cfi.sign
sign
Definition: Validation_hcalonly_cfi.py:32
HcalDDDRecConstants::getLayer0Wt
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
Definition: HcalDDDRecConstants.h:85
HcalTestNumbering.h
HcalBarrel
Definition: HcalAssistant.h:33
HcalHitRelabeller::neutralDensity_
bool neutralDensity_
Definition: HcalHitRelabeller.h:22
DetId
Definition: DetId.h:17
HcalTestNumbering::unpackHcalIndex
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
Definition: HcalTestNumbering.cc:18
PVValHelper::eta
Definition: PVValidationHelpers.h:69
DDAxes::z
HcalOuter
Definition: HcalAssistant.h:35
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
edm::LogWarning
Definition: MessageLogger.h:141
HcalDetId.h
HcalHitRelabeller.h
HcalDetId
Definition: HcalDetId.h:12
edm::LogVerbatim
Definition: MessageLogger.h:297
HcalForward
Definition: HcalAssistant.h:36
DDAxes::phi
HcalHitRelabeller::relabel
DetId relabel(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:49
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
HcalEndcap
Definition: HcalAssistant.h:34
HcalHitRelabeller::theRecNumber
const HcalDDDRecConstants * theRecNumber
Definition: HcalHitRelabeller.h:21
HcalHitRelabeller::process
void process(std::vector< PCaloHit > &hcalHits)
Definition: HcalHitRelabeller.cc:16
HcalDDDRecConstants::HcalID
Definition: HcalDDDRecConstants.h:28
HcalDDDRecConstants
Definition: HcalDDDRecConstants.h:23
HcalHitRelabeller::energyWt
double energyWt(const uint32_t testId) const
Definition: HcalHitRelabeller.cc:88
HcalHitRelabeller::HcalHitRelabeller
HcalHitRelabeller(bool nd=false)
Definition: HcalHitRelabeller.cc:9
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
cuy.ii
ii
Definition: cuy.py:590
HcalDDDRecConstants::getHCID
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
Definition: HcalDDDRecConstants.cc:161