5 #include "HGCal/TBStandaloneSimulator/interface/HGCSSSimHit.hh"
6 #include "HGCal/TBStandaloneSimulator/interface/HGCSSGeometryConversion.hh"
7 #include "HGCal/TBStandaloneSimulator/interface/G4SiHit.hh"
11 HGCSSSimHit::HGCSSSimHit(
const G4SiHit & aSiHit,
12 const unsigned & asilayer,
16 energy_ = aSiHit.energy;
20 time_ = aSiHit.time * aSiHit.energy;
22 setLayer(aSiHit.layer, asilayer);
25 double x = aSiHit.hit_x;
26 double y = aSiHit.hit_y;
28 cellid_ = map->FindBin(x, y);
40 if(abs(aSiHit.pdgId) == 22) nGammas_++;
41 else if(abs(aSiHit.pdgId) == 11) nElectrons_++;
42 else if(abs(aSiHit.pdgId) == 13) nMuons_++;
43 else if(abs(aSiHit.pdgId) == 2112) nNeutrons_++;
44 else if(abs(aSiHit.pdgId) == 2212) nProtons_++;
47 trackIDMainParent_ = aSiHit.parentId;
48 energyMainParent_ = aSiHit.energy;
52 void HGCSSSimHit::Add(
const G4SiHit & aSiHit)
55 time_ = time_ + aSiHit.time * aSiHit.energy;
59 if(abs(aSiHit.pdgId) == 22) nGammas_++;
60 else if(abs(aSiHit.pdgId) == 11) nElectrons_++;
61 else if(abs(aSiHit.pdgId) == 13) nMuons_++;
62 else if(abs(aSiHit.pdgId) == 2112) nNeutrons_++;
63 else if(abs(aSiHit.pdgId) == 2212) nProtons_++;
66 energy_ += aSiHit.energy;
67 if (aSiHit.energy > energyMainParent_) {
68 trackIDMainParent_ = aSiHit.parentId;
69 energyMainParent_ = aSiHit.energy;
75 std::pair<double, double> HGCSSSimHit::get_xy(
const bool isScintillator,
76 const HGCSSGeometryConversion & aGeom)
const
78 if (isScintillator)
return aGeom.squareGeom.find(cellid_)->second;
79 else return aGeom.hexaGeom.find(cellid_)->second;
83 ROOT::Math::XYZPoint HGCSSSimHit::position(
const bool isScintillator,
84 const HGCSSGeometryConversion & aGeom)
const
86 std::pair<double, double> xy = get_xy(isScintillator, aGeom);
87 return ROOT::Math::XYZPoint(xy.first / 10., xy.second / 10., zpos_ / 10.);
90 double HGCSSSimHit::theta(
const bool isScintillator,
91 const HGCSSGeometryConversion & aGeom)
const
93 return 2 * atan(exp(-1.*eta(isScintillator, aGeom)));
96 double HGCSSSimHit::eta(
const bool isScintillator,
97 const HGCSSGeometryConversion & aGeom)
const
99 return position(isScintillator, aGeom).eta();
102 double HGCSSSimHit::phi(
const bool isScintillator,
103 const HGCSSGeometryConversion & aGeom)
const
105 return position(isScintillator, aGeom).phi();
108 void HGCSSSimHit::Print(std::ostream & aOs)
const
110 aOs <<
"====================================" << std::endl
111 <<
" = Layer " << layer() <<
" siLayer " << silayer() <<
" cellid " << cellid_ << std::endl
112 <<
" = Energy " << energy_ <<
" time " << time_ << std::endl
113 <<
" = g " << nGammas_
114 <<
" e " << nElectrons_
116 <<
" neutron " << nNeutrons_
117 <<
" proton " << nProtons_
118 <<
" had " << nHadrons_
120 <<
" = main parent: trackID " << trackIDMainParent_ <<
" efrac " << mainParentEfrac()
122 <<
"====================================" << std::endl;