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  uint32_t hid;
27  int det, z, depth, eta, phi, layer;
28  HcalTestNumbering::unpackHcalIndex(hcalHit.id(), det, z, depth, eta, phi, layer);
29  if ((det == 2) && (layer == 2) && (eta == 18))
30  depth = 2;
32  double wt = (neutralDensity_) ? (energyWt(hid)) : 1.0;
33  double energy = wt * (hcalHit.energy());
34  hcalHit.setEnergy(energy);
35  uint32_t newid = relabel(hid).rawId();
36 #ifdef EDM_ML_DEBUG
37  edm::LogVerbatim("HcalSim") << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid
38  << std::dec << " E " << energy << " wt " << wt;
39 #endif
40  hcalHit.setID(newid);
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("HcalSim") << "Final Setting::subdet: " << HcalDetId(newid).subdet()
43  << " z: " << HcalDetId(newid).zside() << " depth: " << HcalDetId(newid).depth()
44  << " ieta: " << HcalDetId(newid).ietaAbs() << " iphi: " << HcalDetId(newid).iphi()
45  << " wt " << wt;
46  ++ii;
47 #endif
48  }
49  } else {
50  edm::LogWarning("HcalSim") << "HcalHitRelabeller: no valid HcalDDDRecConstants";
51  }
52 }
53 
55 
56 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
58 }
59 
60 DetId HcalHitRelabeller::relabel(const uint32_t testId, const HcalDDDRecConstants* theRecNumber) {
61 #ifdef EDM_ML_DEBUG
62  edm::LogVerbatim("HcalSim") << "Enter HcalHitRelabeller::relabel";
63 #endif
64  HcalDetId hid;
65  int det, z, depth, eta, phi, layer, sign;
67 
68  sign = (z == 0) ? (-1) : (1);
70  int depth0 = ((det == 1) && (layer == 2) && (eta == 15)) ? depth : id.depth;
71 
72  if (id.subdet == int(HcalBarrel)) {
73  hid = HcalDetId(HcalBarrel, sign * id.eta, id.phi, depth0);
74  } else if (id.subdet == int(HcalEndcap)) {
75  hid = HcalDetId(HcalEndcap, sign * id.eta, id.phi, depth0);
76  } else if (id.subdet == int(HcalOuter)) {
77  hid = HcalDetId(HcalOuter, sign * id.eta, id.phi, depth0);
78  } else if (id.subdet == int(HcalForward)) {
79  hid = HcalDetId(HcalForward, sign * id.eta, id.phi, depth0);
80  }
81 #ifdef EDM_ML_DEBUG
82  edm::LogVerbatim("HcalSim") << "Initial indices:"
83  << "subdet: " << det << " "
84  << "z: " << z << " "
85  << "depth: " << depth << " "
86  << "ieta: " << eta << " "
87  << "iphi: " << phi << " "
88  << "layer: " << layer << " new HcalDetId -> hex.RawID = " << std::hex << hid.rawId()
89  << std::dec << " subdet, z, depth, eta, phi = " << det << " " << z << " " << id.depth
90  << " " << id.eta << " " << id.phi << " ---> " << hid;
91 #endif
92  return hid;
93 }
94 
95 double HcalHitRelabeller::energyWt(const uint32_t testId) const {
96  int det, z, depth, eta, phi, layer;
98  int zside = (z == 0) ? (-1) : (1);
99  double wt = ((((det == 1) && (layer <= 1)) || ((det == 2) && (layer <= 2))) && (depth == 1))
101  : 1.0;
102 #ifdef EDM_ML_DEBUG
103  edm::LogVerbatim("HcalSim") << "EnergyWT::det: " << det << " z: " << z << ":" << zside << " depth: " << depth
104  << " ieta: " << eta << " iphi: " << phi << " layer: " << layer << " wt " << wt;
105 #endif
106  return wt;
107 }
Log< level::Info, true > LogVerbatim
constexpr int zside() const
get the z-side of the cell (1/-1)
Definition: HcalDetId.h:141
constexpr int ietaAbs() const
get the absolute value of the cell ieta
Definition: HcalDetId.h:148
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
int zside(DetId const &)
void setGeometry(const HcalDDDRecConstants *&)
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay)
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
constexpr int iphi() const
get the cell iphi
Definition: HcalDetId.h:157
constexpr int depth() const
get the tower depth
Definition: HcalDetId.h:164