CMS 3D CMS Logo

HcalHitRelabeller.cc
Go to the documentation of this file.
4 
6 
7 //#define EDM_ML_DEBUG
8 
10  theRecNumber(nullptr),
11  neutralDensity_(nd) { }
12 
13 void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
14 
15  if (theRecNumber) {
16  for (auto & hcalHit : hcalHits) {
17 
18 #ifdef EDM_ML_DEBUG
19  std::cout << "Hit[" << ii << "] " << std::hex << hcalHits[ii].id()
20  << std::dec << " Neutral density " << neutralDensity_ << "\n";
21 #endif
22  double energy = (hcalHit.energy());
23  if (neutralDensity_) {
24  energy *= (energyWt(hcalHit.id()));
25  hcalHit.setEnergy(energy);
26  }
27  DetId newid = relabel(hcalHit.id());
28 #ifdef EDM_ML_DEBUG
29  std::cout << "Hit " << ii << " out of " << hcalHits.size() << " "
30  << std::hex << newid.rawId() << std::dec << " E " << energy
31  << std::endl;
32 #endif
33  hcalHit.setID(newid.rawId());
34 #ifdef EDM_ML_DEBUG
35  std::cout << "Modified Hit " << HcalDetId(hcalHits[ii].id()) <<std::endl;
36 #endif
37  }
38  } else {
39  edm::LogWarning("HcalSim") << "HcalHitRelabeller: no valid HcalDDDRecConstants";
40  }
41 
42 }
43 
45  theRecNumber = recNum;
46 }
47 
48 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
50 }
51 
53 
54 #ifdef EDM_ML_DEBUG
55  std::cout << "Enter HcalHitRelabeller::relabel " << std::endl;
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  std::cout << "det: " << det << " "
62  << "z: " << z << " "
63  << "depth: " << depth << " "
64  << "ieta: " << eta << " "
65  << "iphi: " << phi << " "
66  << "layer: " << layer << std::endl;
67 #endif
68  sign=(z==0)?(-1):(1);
69  HcalDDDRecConstants::HcalID id = theRecNumber->getHCID(det,sign*eta,phi,layer,depth);
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  std::cout << " new HcalDetId -> hex.RawID = "
82  << std::hex << hid.rawId() << std::dec;
83  std::cout.flush();
84  std::cout << " det, z, depth, eta, phi = " << det << " "
85  << z << " "<< id.depth << " " << id.eta << " "
86  << id.phi << " ---> " << hid << std::endl;
87 #endif
88  return hid;
89 }
90 
91 double HcalHitRelabeller::energyWt(const uint32_t testId) const {
92 
93  HcalDetId hid;
94  int det, z, depth, eta, phi, layer;
95  HcalTestNumbering::unpackHcalIndex(testId,det,z,depth,eta,phi,layer);
96  int zside = (z==0) ? (-1) : (1);
97  double wt = (((det==1) || (det==2)) && (depth == 1)) ?
98  theRecNumber->getLayer0Wt(det,phi,zside) : 1.0;
99 #ifdef EDM_ML_DEBUG
100  std::cout << "EnergyWT::det: " << det << " z: " << z << ":" << zside
101  << " depth: " << depth << " ieta: " << eta << " iphi: " << phi
102  << " layer: " << layer << " wt " << wt << std::endl;
103 #endif
104  return wt;
105 }
#define nullptr
void setGeometry(const HcalDDDRecConstants *&)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
HcalID getHCID(int subdet, int ieta, int iphi, int lay, int idepth) const
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
double getLayer0Wt(const int &det, const int &phi, const int &zside) const
ii
Definition: cuy.py:588
Definition: DetId.h:18
void process(std::vector< PCaloHit > &hcalHits)
HcalHitRelabeller(bool nd=false)
const HcalDDDRecConstants * theRecNumber
DetId relabel(const uint32_t testId) const
double energyWt(const uint32_t testId) const