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;
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;
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 }
Log< level::Info, true > LogVerbatim
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
int zside(DetId const &)
void setGeometry(const HcalDDDRecConstants *&)
constexpr std::array< uint8_t, layerIndexSize > layer
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
DetId relabel(const uint32_t testId) const
ii
Definition: cuy.py:589
Definition: DetId.h:17
void process(std::vector< PCaloHit > &hcalHits)
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
double energyWt(const uint32_t testId) const
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
HcalHitRelabeller(bool nd=false)
const HcalDDDRecConstants * theRecNumber
Log< level::Warning, false > LogWarning