test
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 DebugLog
10 
11 HcalHitRelabeller::HcalHitRelabeller(const edm::ParameterSet&) : theGeometry(0), theRecNumber(0) { }
12 
13 void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
14 
15  if (theRecNumber) {
16  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
17 
18 #ifdef DebugLog
19  std::cout << "Hit[" << ii << "] " << std::hex << hcalHits[ii].id() << std::dec << '\n';
20 #endif
21  DetId newid = relabel(hcalHits[ii].id());
22 #ifdef DebugLog
23  std::cout << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid.rawId() << std::dec << '\n';
24 #endif
25  hcalHits[ii].setID(newid.rawId());
26 #ifdef DebugLog
27  std::cout << "Modified Hit " << hcalHits[ii] << std::endl;
28 #endif
29  }
30  } else {
31  edm::LogWarning("HcalSim") << "HcalHitRelabeller: no valid HcalDDDRecConstants";
32  }
33 
34 }
35 
36 
38  const HcalDDDRecConstants *& recNum) {
39  theGeometry = geom;
40  theRecNumber = recNum;
41 }
42 
43 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
44 
45 #ifdef DebugLog
46  std::cout << "Enter HcalHitRelabeller::relabel " << std::endl;
47 #endif
48  HcalDetId hid;
49  int det, z, depth, eta, phi, layer, sign;
50  HcalTestNumbering::unpackHcalIndex(testId,det,z,depth,eta,phi,layer);
51 #ifdef DebugLog
52  std::cout << "det: " << det << " "
53  << "z: " << z << " "
54  << "depth: " << depth << " "
55  << "ieta: " << eta << " "
56  << "iphi: " << phi << " "
57  << "layer: " << layer << std::endl;
58 #endif
59  HcalDDDRecConstants::HcalID id = theRecNumber->getHCID(det,eta,phi,layer,depth);
60  sign=(z==0)?(-1):(1);
61 
62  if (id.subdet==int(HcalBarrel)) {
63  hid=HcalDetId(HcalBarrel,sign*id.eta,id.phi,id.depth);
64  } else if (id.subdet==int(HcalEndcap)) {
65  hid=HcalDetId(HcalEndcap,sign*id.eta,id.phi,id.depth);
66  } else if (id.subdet==int(HcalOuter)) {
67  hid=HcalDetId(HcalOuter,sign*id.eta,id.phi,id.depth);
68  } else if (id.subdet==int(HcalForward)) {
69  hid=HcalDetId(HcalForward,sign*id.eta,id.phi,id.depth);
70  }
71 #ifdef DebugLog
72  std::cout << " new HcalDetId -> hex.RawID = "
73  << std::hex << hid.rawId() << std::dec;
74  std::cout.flush();
75  std::cout << " det, z, depth, eta, phi = " << det << " "
76  << z << " "<< id.depth << " " << id.eta << " "
77  << id.phi << " ---> " << hid << std::endl;
78 #endif
79  return hid;
80 }
void setGeometry(const CaloGeometry *&, const HcalDDDRecConstants *&)
const CaloGeometry * theGeometry
double sign(double x)
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