Public Types | Public Member Functions | Private Attributes | List of all members
SampleTailer Class Reference

#include <SampleTailer.h>

Public Types

using Index = unsigned int
 
using FloatVector = std::vector< float >
 
using Name = std::string
 

Public Member Functions

 SampleTailer (float a_decayTime)
 
 SampleTailer (float a_decayTime, float a_alpha)
 
 ~SampleTailer ()
 
void clear ()
 
int setDecayTime (float val, bool cancelSignal)
 
int setBeta (float val, bool cancelSignal)
 
int setAlpha (float val)
 
int setPedestal (float val)
 
int setPedestalVector (const FloatVector *pval)
 
int setTail0 (float val)
 
int setUnit (Name val)
 
int setData (const FloatVector &inData)
 
int setDataZero (Index nsam)
 
int setSignal (const FloatVector &inSignal)
 
bool isValid () const
 
float decayTime () const
 
float beta () const
 
float alpha () const
 
float pedestal () const
 
float tail0 () const
 
const FloatVectordata () const
 
float data (Index isam) const
 
const FloatVectorsignal () const
 
float signal (Index isam) const
 
const FloatVectortail () const
 
float tail (Index isam) const
 
Index size () const
 
Name unit () const
 
TH1 * dataHist () const
 
TH1 * signalHist () const
 
TH1 * tailHist () const
 
TH1 * dataHist ()
 
TH1 * signalHist ()
 
TH1 * tailHist ()
 
void makeHists ()
 

Private Attributes

float m_decayTime
 
float m_beta
 
float m_alpha
 
float m_pedestal
 
const FloatVectorm_ppedvec
 
float m_tail0
 
Name m_unit
 
FloatVector m_d
 
FloatVector m_s
 
FloatVector m_t
 
TH1 * m_phd =nullptr
 
TH1 * m_phs =nullptr
 
TH1 * m_pht =nullptr
 

Detailed Description

Definition at line 37 of file SampleTailer.h.

Member Typedef Documentation

Definition at line 42 of file SampleTailer.h.

using SampleTailer::Index = unsigned int

Definition at line 41 of file SampleTailer.h.

Definition at line 43 of file SampleTailer.h.

Constructor & Destructor Documentation

SampleTailer::SampleTailer ( float  a_decayTime)

Definition at line 22 of file SampleTailer.cxx.

23 : SampleTailer(a_decayTime, 0) {
24  setDecayTime(a_decayTime, true);
25 }
int setDecayTime(float val, bool cancelSignal)
SampleTailer(float a_decayTime)
SampleTailer::SampleTailer ( float  a_decayTime,
float  a_alpha 
)

Definition at line 9 of file SampleTailer.cxx.

10 : m_decayTime(a_decayTime),
11  m_beta(exp(-1.0/m_decayTime)),
12  m_alpha(a_alpha),
13  m_pedestal(0.0),
14  m_ppedvec(nullptr),
15  m_tail0(0.0) {
16  setDecayTime(a_decayTime, false);
17  setAlpha(a_alpha);
18 }
const FloatVector * m_ppedvec
Definition: SampleTailer.h:112
float m_pedestal
Definition: SampleTailer.h:111
int setDecayTime(float val, bool cancelSignal)
float m_decayTime
Definition: SampleTailer.h:108
int setAlpha(float val)
SampleTailer::~SampleTailer ( )

Definition at line 29 of file SampleTailer.cxx.

29  {
30  clear();
31 }

Member Function Documentation

float SampleTailer::alpha ( ) const
inline

Definition at line 85 of file SampleTailer.h.

85 { return m_alpha; }
float SampleTailer::beta ( ) const
inline

Definition at line 84 of file SampleTailer.h.

84 { return m_beta; }
void SampleTailer::clear ( )

Definition at line 35 of file SampleTailer.cxx.

35  {
36  m_d.clear();
37  m_s.clear();
38  m_t.clear();
39  delete m_phd;
40  m_phd = nullptr;
41  delete m_phs;
42  m_phs = nullptr;
43  delete m_pht;
44  m_pht = nullptr;
45 }
FloatVector m_t
Definition: SampleTailer.h:117
FloatVector m_d
Definition: SampleTailer.h:115
FloatVector m_s
Definition: SampleTailer.h:116
const FloatVector& SampleTailer::data ( ) const
inline

Definition at line 88 of file SampleTailer.h.

88 { return m_d; }
FloatVector m_d
Definition: SampleTailer.h:115
float SampleTailer::data ( Index  isam) const
inline

Definition at line 89 of file SampleTailer.h.

89 { return isam < m_d.size() ? m_d[isam] : 0.0; }
FloatVector m_d
Definition: SampleTailer.h:115
TH1* SampleTailer::dataHist ( ) const
inline

Definition at line 96 of file SampleTailer.h.

96 { return m_phd; }
TH1 * SampleTailer::dataHist ( )

Definition at line 172 of file SampleTailer.cxx.

172  {
173  if ( m_phd != nullptr ) return m_phd;
174  Index nsam = m_d.size();
175  if ( nsam == 0 ) return nullptr;
176  Name hnam = "hst_data";
177  Name httl = "Sample data; Tick;" + unit();
178  TH1* ph = new TH1F(hnam.c_str(), httl.c_str(), nsam, 0, nsam);
179  ph->SetDirectory(nullptr);
180  ph->SetLineWidth(2);
181  ph->SetStats(0);
182  for ( Index isam=0; isam<nsam; ++isam ) {
183  ph->SetBinContent(isam+1, m_d[isam]);
184  }
185  m_phd = ph;
186  return ph;
187 }
ChannelGroupService::Name Name
unsigned int Index
Name unit() const
Definition: SampleTailer.h:95
FloatVector m_d
Definition: SampleTailer.h:115
float SampleTailer::decayTime ( ) const
inline

Definition at line 83 of file SampleTailer.h.

83 { return m_decayTime; }
float m_decayTime
Definition: SampleTailer.h:108
bool SampleTailer::isValid ( ) const
inline

Definition at line 80 of file SampleTailer.h.

80 { return m_beta > 0.0; }
void SampleTailer::makeHists ( )

Definition at line 229 of file SampleTailer.cxx.

229  {
230  dataHist();
231  tailHist();
232  signalHist();
233 }
TH1 * signalHist() const
Definition: SampleTailer.h:97
TH1 * dataHist() const
Definition: SampleTailer.h:96
TH1 * tailHist() const
Definition: SampleTailer.h:98
float SampleTailer::pedestal ( ) const
inline

Definition at line 86 of file SampleTailer.h.

86 { return m_pedestal; }
float m_pedestal
Definition: SampleTailer.h:111
int SampleTailer::setAlpha ( float  val)

Definition at line 83 of file SampleTailer.cxx.

83  {
84  clear();
85  m_alpha = val;
86  return 0;
87 }
int SampleTailer::setBeta ( float  val,
bool  cancelSignal 
)

Definition at line 66 of file SampleTailer.cxx.

66  {
67  clear();
68  if ( val > 0.0 ) {
69  m_beta = val;
70  m_decayTime = -1.0/log(m_beta);
71  if ( cancelSignal ) m_alpha = 1.0/m_beta - 1;
72  } else {
73  m_decayTime = 0.0;
74  m_beta = 0.0;
75  if ( cancelSignal ) m_alpha = 0.0;
76  return 1;
77  }
78  return 0;
79 }
float m_decayTime
Definition: SampleTailer.h:108
int SampleTailer::setData ( const FloatVector inData)

Definition at line 117 of file SampleTailer.cxx.

117  {
118  clear();
119  if ( ! isValid() ) return 1;
120  m_d = inData;
121  Index nsam = m_d.size();
122  bool havePedVector = m_ppedvec != nullptr;
123  if ( havePedVector && m_ppedvec->size() < nsam ) return 2;
124  m_s.resize(nsam, 0.0);
125  m_t.resize(nsam, 0.0);
126  double t = m_tail0;
127  double s = 0.0;
128  double ped = m_pedestal;
129  for ( Index isam=0; isam<nsam; ++isam ) {
130  if ( isam > 0 ) t = m_beta*t - m_alpha*s;
131  if ( havePedVector ) ped = (*m_ppedvec)[isam];
132  s = m_d[isam] - t - ped;
133  m_t[isam] = t;
134  m_s[isam] = s;
135  }
136  return 0;
137 }
bool isValid() const
Definition: SampleTailer.h:80
const FloatVector * m_ppedvec
Definition: SampleTailer.h:112
unsigned int Index
float m_pedestal
Definition: SampleTailer.h:111
FloatVector m_t
Definition: SampleTailer.h:117
FloatVector m_d
Definition: SampleTailer.h:115
FloatVector m_s
Definition: SampleTailer.h:116
static QCString * s
Definition: config.cpp:1042
int SampleTailer::setDataZero ( Index  nsam)

Definition at line 141 of file SampleTailer.cxx.

141  {
142  FloatVector dats(nsam, 0.0);
143  return setData(dats);
144 }
int setData(const FloatVector &inData)
Dft::FloatVector FloatVector
int SampleTailer::setDecayTime ( float  val,
bool  cancelSignal 
)

Definition at line 49 of file SampleTailer.cxx.

49  {
50  clear();
51  if ( val > 0.0 ) {
52  m_decayTime = val;
53  m_beta = exp(-1.0/m_decayTime);
54  if ( cancelSignal ) m_alpha = 1.0/m_beta - 1;
55  } else {
56  m_decayTime = 0.0;
57  m_beta = 0.0;
58  if ( cancelSignal ) m_alpha = 0.0;
59  return 1;
60  }
61  return 0;
62 }
float m_decayTime
Definition: SampleTailer.h:108
int SampleTailer::setPedestal ( float  val)

Definition at line 91 of file SampleTailer.cxx.

91  {
92  clear();
93  m_pedestal = val;
94  m_ppedvec = nullptr;
95  return 0;
96 }
const FloatVector * m_ppedvec
Definition: SampleTailer.h:112
float m_pedestal
Definition: SampleTailer.h:111
int SampleTailer::setPedestalVector ( const FloatVector pval)

Definition at line 100 of file SampleTailer.cxx.

100  {
101  clear();
102  m_pedestal = 0.0;
103  m_ppedvec = ppeds;
104  return 0;
105 }
const FloatVector * m_ppedvec
Definition: SampleTailer.h:112
float m_pedestal
Definition: SampleTailer.h:111
int SampleTailer::setSignal ( const FloatVector inSignal)

Definition at line 148 of file SampleTailer.cxx.

148  {
149  clear();
150  if ( ! isValid() ) return 1;
151  m_s = inSignal;
152  Index nsam = m_s.size();
153  bool havePedVector = m_ppedvec != nullptr;
154  if ( havePedVector && m_ppedvec->size() < nsam ) return 2;
155  m_d.resize(nsam, 0.0);
156  m_t.resize(nsam, 0.0);
157  double t = m_tail0;
158  double s = 0.0;
159  double ped = m_pedestal;
160  for ( Index isam=0; isam<nsam; ++isam ) {
161  if ( isam > 0 ) t = m_beta*t - m_alpha*s;
162  s = m_s[isam];
163  m_t[isam] = t;
164  if ( havePedVector ) ped = (*m_ppedvec)[isam];
165  m_d[isam] = s + t + ped;
166  }
167  return 0;
168 }
bool isValid() const
Definition: SampleTailer.h:80
const FloatVector * m_ppedvec
Definition: SampleTailer.h:112
unsigned int Index
float m_pedestal
Definition: SampleTailer.h:111
FloatVector m_t
Definition: SampleTailer.h:117
FloatVector m_d
Definition: SampleTailer.h:115
FloatVector m_s
Definition: SampleTailer.h:116
static QCString * s
Definition: config.cpp:1042
int SampleTailer::setTail0 ( float  val)

Definition at line 109 of file SampleTailer.cxx.

109  {
110  clear();
111  m_tail0 = val;
112  return 0;
113 }
int SampleTailer::setUnit ( Name  val)
inline

Definition at line 68 of file SampleTailer.h.

68 { m_unit = val; return 0; }
const FloatVector& SampleTailer::signal ( ) const
inline

Definition at line 90 of file SampleTailer.h.

90 { return m_s; }
FloatVector m_s
Definition: SampleTailer.h:116
float SampleTailer::signal ( Index  isam) const
inline

Definition at line 91 of file SampleTailer.h.

91 { return isam < m_s.size() ? m_s[isam] : 0.0; }
FloatVector m_s
Definition: SampleTailer.h:116
TH1* SampleTailer::signalHist ( ) const
inline

Definition at line 97 of file SampleTailer.h.

97 { return m_phs; }
TH1 * SampleTailer::signalHist ( )

Definition at line 191 of file SampleTailer.cxx.

191  {
192  if ( m_phs != nullptr ) return m_phs;
193  Index nsam = m_s.size();
194  if ( nsam == 0 ) return nullptr;
195  Name hnam = "hst_signal";
196  Name httl = "Sample signal; Tick;" + unit();
197  TH1* ph = new TH1F(hnam.c_str(), httl.c_str(), nsam, 0, nsam);
198  ph->SetDirectory(nullptr);
199  ph->SetLineWidth(2);
200  ph->SetStats(0);
201  for ( Index isam=0; isam<nsam; ++isam ) {
202  ph->SetBinContent(isam+1, m_s[isam]);
203  }
204  m_phs = ph;
205  return ph;
206 }
ChannelGroupService::Name Name
unsigned int Index
Name unit() const
Definition: SampleTailer.h:95
FloatVector m_s
Definition: SampleTailer.h:116
Index SampleTailer::size ( ) const
inline

Definition at line 94 of file SampleTailer.h.

94 { return m_d.size(); }
FloatVector m_d
Definition: SampleTailer.h:115
const FloatVector& SampleTailer::tail ( ) const
inline

Definition at line 92 of file SampleTailer.h.

92 { return m_t; }
FloatVector m_t
Definition: SampleTailer.h:117
float SampleTailer::tail ( Index  isam) const
inline

Definition at line 93 of file SampleTailer.h.

93 { return isam < m_t.size() ? m_t[isam] : 0.0; }
FloatVector m_t
Definition: SampleTailer.h:117
float SampleTailer::tail0 ( ) const
inline

Definition at line 87 of file SampleTailer.h.

87 { return m_tail0; }
TH1* SampleTailer::tailHist ( ) const
inline

Definition at line 98 of file SampleTailer.h.

98 { return m_pht; }
TH1 * SampleTailer::tailHist ( )

Definition at line 210 of file SampleTailer.cxx.

210  {
211  if ( m_pht != nullptr ) return m_pht;
212  Index nsam = m_t.size();
213  if ( nsam == 0 ) return nullptr;
214  Name hnam = "hst_tail";
215  Name httl = "Sample tail; Tick;" + unit();
216  TH1* ph = new TH1F(hnam.c_str(), httl.c_str(), nsam, 0, nsam);
217  ph->SetDirectory(nullptr);
218  ph->SetLineWidth(2);
219  ph->SetStats(0);
220  for ( Index isam=0; isam<nsam; ++isam ) {
221  ph->SetBinContent(isam+1, m_t[isam]);
222  }
223  m_pht = ph;
224  return ph;
225 }
ChannelGroupService::Name Name
unsigned int Index
Name unit() const
Definition: SampleTailer.h:95
FloatVector m_t
Definition: SampleTailer.h:117
Name SampleTailer::unit ( ) const
inline

Definition at line 95 of file SampleTailer.h.

95 { return m_unit; }

Member Data Documentation

float SampleTailer::m_alpha
private

Definition at line 110 of file SampleTailer.h.

float SampleTailer::m_beta
private

Definition at line 109 of file SampleTailer.h.

FloatVector SampleTailer::m_d
private

Definition at line 115 of file SampleTailer.h.

float SampleTailer::m_decayTime
private

Definition at line 108 of file SampleTailer.h.

float SampleTailer::m_pedestal
private

Definition at line 111 of file SampleTailer.h.

TH1* SampleTailer::m_phd =nullptr
private

Definition at line 118 of file SampleTailer.h.

TH1* SampleTailer::m_phs =nullptr
private

Definition at line 119 of file SampleTailer.h.

TH1* SampleTailer::m_pht =nullptr
private

Definition at line 120 of file SampleTailer.h.

const FloatVector* SampleTailer::m_ppedvec
private

Definition at line 112 of file SampleTailer.h.

FloatVector SampleTailer::m_s
private

Definition at line 116 of file SampleTailer.h.

FloatVector SampleTailer::m_t
private

Definition at line 117 of file SampleTailer.h.

float SampleTailer::m_tail0
private

Definition at line 113 of file SampleTailer.h.

Name SampleTailer::m_unit
private

Definition at line 114 of file SampleTailer.h.


The documentation for this class was generated from the following files: