HGCal Test Beam  03a93d6239a951948e06fb3ef8dae4cbdebfad30
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
HGCSSRecoHit.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <cmath>
3 #include <stdlib.h>
4 
5 #include "HGCal/TBStandaloneSimulator/interface/HGCSSRecoHit.hh"
6 
7 HGCSSRecoHit::HGCSSRecoHit(const HGCSSSimHit & aSimHit,
8  const bool isScintillator,
9  const HGCSSGeometryConversion & aGeom)
10 {
11  energy_ = aSimHit.energy();
12  adcCounts_ = 0;
13  zpos_ = aSimHit.get_z();
14 
15 
16  layer_ = aSimHit.layer();
17  noiseFrac_ = 0;
18 
19  std::pair<double, double> xy = aSimHit.get_xy(isScintillator, aGeom);
20  xpos_ = xy.first;
21  ypos_ = xy.second;
22 
23  time_ = aSimHit.time();
24 
25  //cellid encoding:
26  //bool x_side = x>0 ? true : false;
27  //bool y_side = y>0 ? true : false;
28  //unsigned x_cell = static_cast<unsigned>(fabs(x)/(cellSize*granularity));
29  //unsigned y_cell = static_cast<unsigned>(fabs(y)/(cellSize*granularity));
30  //encodeCellId(x_side,y_side,x_cell,y_cell,granularity);
31 
32 }
33 
34 
35 double HGCSSRecoHit::theta() const
36 {
37  return 2 * atan(exp(-1.*eta()));
38 }
39 
40 double HGCSSRecoHit::eta() const
41 {
42  return position().eta();
43 }
44 
45 double HGCSSRecoHit::phi() const
46 {
47  return position().phi();
48 }
49 
50 // void HGCSSRecoHit::encodeCellId(const bool x_side,const bool y_side,const unsigned x_cell,const unsigned y_cell, const unsigned granularity){
51 // cellid_ =
52 // x_side | ((x_cell & 0xFFF)<<1) |
53 // (y_side<<13) | ((y_cell & 0xFFF)<<14) |
54 // ((granularity & 0x3F) <<26) ;
55 
56 // // std::cout << " Cross-check of encoding: cellid=" << cellid_ << std::endl
57 // // << " x_side " << x_side << " " << get_x_side() << std::endl
58 // // << " y_side " << y_side << " " << get_y_side() << std::endl
59 // // << " x_cell " << x_cell << " " << get_x_cell() << std::endl
60 // // << " y_cell " << y_cell << " " << get_y_cell() << std::endl
61 // // << " granularity " << granularity << " " << getGranularity() << std::endl
62 // // ;
63 // }
64 
65 void HGCSSRecoHit::Add(const HGCSSSimHit & aSimHit)
66 {
67  time_ = time_ * energy_;
68  energy_ += aSimHit.energy();
69  time_ += aSimHit.energy() * aSimHit.time();
70  if (energy_ > 0) time_ = time_ / energy_;
71 }
72 
73 void HGCSSRecoHit::Print(std::ostream & aOs) const
74 {
75  aOs << "====================================" << std::endl
76  << " = Layer " << layer_ //<< " cellid " << cellid_
77  << std::endl
78  << " = Energy " << energy_ << " noiseFrac " << noiseFrac_ << std::endl
79  << " = Digi E " << adcCounts_ << " adcCounts." << std::endl
80  << " = time " << time_ << std::endl
81  << "====================================" << std::endl;
82 
83 }