Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrkrHitv2.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrkrHitv2.cc
1 #include "TrkrHitv2.h"
2 #include <climits>
3 
5 {
6 }
7 
8  // these set and get the energy before digitization
9 void TrkrHitv2::addEnergy(const double edep)
10 {
11  double max_adc = (double) USHRT_MAX;
12 
13  // overflow occurs if (sum of the existing + new ADC values) > USHRT_MAX
14  double ein = edep* TrkrDefs::EdepScaleFactor;
15  if( (double) m_adc + ein > max_adc)
16  {
17  m_adc = USHRT_MAX;
18  }
19  else
20  {
21  m_adc += (unsigned short) (ein);
22  }
23 }
24 
26 {
27  return ((double) m_adc) / TrkrDefs::EdepScaleFactor;
28 }
29 
30 void TrkrHitv2::setAdc(const unsigned int adc)
31  {
32  if(adc > USHRT_MAX)
33  m_adc = USHRT_MAX;
34  else
35  m_adc = (unsigned short) adc;
36  }
37 
38 unsigned int TrkrHitv2::getAdc() {
39  return (unsigned int) m_adc;
40  }