CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalHitRelabeller.cc
Go to the documentation of this file.
4 
8 
9 //#define EDM_ML_DEBUG
10 
12  theGeometry(0), theRecNumber(0),
13  neutralDensity_(ps.getParameter<bool>("doNeutralDensityFilter")) { }
14 
15 void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
16 
17  if (theRecNumber) {
18  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
19 
20 #ifdef EDM_ML_DEBUG
21  std::cout << "Hit[" << ii << "] " << std::hex << hcalHits[ii].id() << std::dec << '\n';
22 #endif
23  double energy = (hcalHits[ii].energy());
24  if (neutralDensity_) {
25  energy *= (energyWt(hcalHits[ii].id()));
26  hcalHits[ii].setEnergy(energy);
27  }
28  DetId newid = relabel(hcalHits[ii].id());
29 #ifdef EDM_ML_DEBUG
30  std::cout << "Hit " << ii << " out of " << hcalHits.size() << " "
31  << std::hex << newid.rawId() << std::dec << " E " << energy
32  << std::endl;
33 #endif
34  hcalHits[ii].setID(newid.rawId());
35 #ifdef EDM_ML_DEBUG
36  std::cout << "Modified Hit " << hcalHits[ii] << std::endl;
37 #endif
38  }
39  } else {
40  edm::LogWarning("HcalSim") << "HcalHitRelabeller: no valid HcalDDDRecConstants";
41  }
42 
43 }
44 
45 
47  const HcalDDDRecConstants *& recNum) {
48  theGeometry = geom;
49  theRecNumber = recNum;
50 }
51 
52 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
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  HcalDDDRecConstants::HcalID id = theRecNumber->getHCID(det,eta,phi,layer,depth);
69  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  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 == 0)) ?
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 }
void setGeometry(const CaloGeometry *&, const HcalDDDRecConstants *&)
const CaloGeometry * theGeometry
double sign(double x)
int zside(DetId const &)
int ii
Definition: cuy.py:588
HcalHitRelabeller(const edm::ParameterSet &ps)
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)
Definition: DetId.h:18
void process(std::vector< PCaloHit > &hcalHits)
tuple cout
Definition: gather_cfg.py:145
const HcalDDDRecConstants * theRecNumber
DetId relabel(const uint32_t testId) const
double getLayer0Wt(int det, int phi, int zside) const
double energyWt(const uint32_t testId) const