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 
7 
8 //#define DEBUG
9 
11  // try to make sure the memory gets pinned in place
12  m_segmentation.resize(29);
13  m_CorrectPhi = ps.getUntrackedParameter<bool>("CorrectPhi",false);
14  for (int i=0; i<29; i++) {
15  char name[10];
16  snprintf(name,10,"Eta%d",i+1);
17  if (i>0) {
18  m_segmentation[i]=ps.getUntrackedParameter<std::vector<int> >(name,m_segmentation[i-1]);
19  } else {
20  m_segmentation[i]=ps.getUntrackedParameter<std::vector<int> >(name);
21  }
22  }
23 #ifdef DEBUG
24  for (int i=0; i<29; i++) {
25  std::cout << "Segmentation[" << i << "] with " << m_segmentation[i].size() << " elements:";
26  for (unsigned int k=0; k<m_segmentation[i].size(); ++k)
27  std::cout << " " << m_segmentation[i][k];
28  std::cout << std::endl;
29  }
30  std::cout << "correctPhi " << m_CorrectPhi << std::endl;
31 #endif
32 }
33 
34 void HcalHitRelabeller::process(std::vector<PCaloHit>& hcalHits) {
35 
36  for (unsigned int ii=0; ii<hcalHits.size(); ++ii) {
37 
38 #ifdef DEBUG
39  std::cout << "Hit[" << ii << "] " << std::hex << hcalHits[ii].id() << std::dec << '\n';
40 #endif
41  DetId newid = relabel(hcalHits[ii].id());
42 #ifdef DEBUG
43  std::cout << "Hit " << ii << " out of " << hcalHits.size() << " " << std::hex << newid.rawId() << std::dec << '\n';
44  HcalDetId newcell(newid);
45  const CaloCellGeometry *cellGeometry =
47  GlobalPoint globalposition = (GlobalPoint)(cellGeometry->getPosition());
48 
49  std::cout << "PCaloHit " << newcell << " position: " << globalposition << std::endl;
50  std::cout.flush();
51 #endif
52  hcalHits[ii].setID(newid.rawId());
53 #ifdef DEBUG
54  std::cout << "Modified Hit " << hcalHits[ii] << std::endl;
55 #endif
56  }
57  //End Change by Wetzel
58 
59 }
60 
61 
63  theGeometry = geom;
64 }
65 
66 DetId HcalHitRelabeller::relabel(const uint32_t testId) const {
67 
68 #ifdef DEBUG
69  std::cout << "Enter HcalHitRelabeller::relabel " << std::endl;
70 #endif
71  HcalDetId hid;
72  int det, z, depth, eta, phi, layer, sign;
73  HcalTestNumbering::unpackHcalIndex(testId,det,z,depth,eta,phi,layer);
74 
75  layer-=1; // one is added in the simulation, here used for indexing
76 
77  sign=(z==0)?(-1):(1);
78 #ifdef DEBUG
79  std::cout << "det: " << det << " "
80  << "z: " << z << " "
81  << "depth: " << depth << " "
82  << "ieta: " << eta << " "
83  << "iphi: " << phi << " "
84  << "layer: " << layer << " ";
85  std::cout.flush();
86 #endif
87  int newDepth = 0; // moved out of if's just for printing purposes...
88  int phi_skip = phi;
89  if (m_CorrectPhi) {
90  if (eta >= 40) phi_skip = (phi-1)*4 - 1;
91  else if (eta > 20) phi_skip = (phi-1)*2 + 1;
92  if (phi_skip < 0) phi_skip += 72;
93  }
94 
95  if (det==int(HcalBarrel)) {
96  newDepth=m_segmentation[eta-1][layer];
97  if(eta==16 && newDepth > 2) newDepth=2;// tower 16 HACK to be watched out..
98  hid=HcalDetId(HcalBarrel,eta*sign,phi_skip,newDepth);
99  }
100  if (det==int(HcalEndcap)) {
101  newDepth=m_segmentation[eta-1][layer];
102  if (eta==16 && newDepth<3) newDepth=3; // tower 16 HACK to be watched out..
103  hid=HcalDetId(HcalEndcap,eta*sign,phi_skip,newDepth);
104  }
105  if (det==int(HcalOuter)) {
106  hid=HcalDetId(HcalOuter,eta*sign,phi_skip,4);
107  newDepth = 4;
108  }
109  if (det==int(HcalForward)) {
110  hid=HcalDetId(HcalForward,eta*sign,phi_skip,depth);
111  newDepth = depth;
112  }
113 #ifdef DEBUG
114  std::cout << " new HcalDetId -> hex.RawID = "
115  << std::hex << hid.rawId() << std::dec;
116  std::cout.flush();
117  std::cout << " det, z, depth, eta, phi = "
118  << det << " "
119  << z << " "
120  << newDepth << " "
121  << eta << " "
122  << phi << " " << phi_skip << " "
123  << " ---> " << hid << std::endl;
124 #endif
125  return hid;
126 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const CaloGeometry * theGeometry
double sign(double x)
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
T eta() const
int ii
Definition: cuy.py:588
void setGeometry(const CaloGeometry *&theGeometry)
float float float z
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
HcalHitRelabeller(const edm::ParameterSet &ps)
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
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)
std::vector< std::vector< int > > m_segmentation
tuple cout
Definition: gather_cfg.py:121
DetId relabel(const uint32_t testId) const
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
Definition: DDAxes.h:10