CMS 3D CMS Logo

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

#include <TPNPulse.h>

Inheritance diagram for TPNPulse:

Public Member Functions

double * getAdcWithoutPedestal ()
 
double getMax ()
 
int getMaxSample ()
 
double getPedestal ()
 
void setPresamples (int)
 
bool setPulse (double *)
 
 TPNPulse ()
 
 TPNPulse (int, int)
 
 ~TPNPulse () override
 

Private Member Functions

void init (int, int)
 

Private Attributes

int _nsamples
 
int _presample
 
double * adc_
 
double adcMax_
 
int iadcMax_
 
bool isMaxFound_
 
bool isPedCalc_
 
double pedestal_
 

Detailed Description

Definition at line 7 of file TPNPulse.h.

Constructor & Destructor Documentation

◆ TPNPulse() [1/2]

TPNPulse::TPNPulse ( )

Definition at line 17 of file TPNPulse.cc.

17 { init(50, 6); }

References init.

◆ TPNPulse() [2/2]

TPNPulse::TPNPulse ( int  nsamples,
int  presample 
)

Definition at line 20 of file TPNPulse.cc.

20 { init(nsamples, presample); }

References init.

◆ ~TPNPulse()

TPNPulse::~TPNPulse ( )
override

Definition at line 23 of file TPNPulse.cc.

23 {}

Member Function Documentation

◆ getAdcWithoutPedestal()

double * TPNPulse::getAdcWithoutPedestal ( )

Definition at line 89 of file TPNPulse.cc.

89  {
90  double ped;
91  if (!isPedCalc_)
92  ped = getPedestal();
93  else
94  ped = pedestal_;
95 
96  double *adcNoPed = new double[50];
97  for (int i = 0; i < _nsamples; i++) {
98  adcNoPed[i] = adc_[i] - ped;
99  }
100  return adcNoPed;
101 }

References mps_fire::i.

Referenced by EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::analyze().

◆ getMax()

double TPNPulse::getMax ( )

Definition at line 53 of file TPNPulse.cc.

53  {
54  if (isMaxFound_)
55  return adcMax_;
56 
57  int iadcmax = 0;
58  double adcmax = 0.0;
59  for (int i = 0; i < _nsamples; i++) {
60  if (adc_[i] > adcmax) {
61  iadcmax = i;
62  adcmax = adc_[i];
63  }
64  }
65  iadcMax_ = iadcmax;
66  adcMax_ = adcmax;
67  return adcMax_;
68 }

References mps_fire::i.

◆ getMaxSample()

int TPNPulse::getMaxSample ( )

Definition at line 70 of file TPNPulse.cc.

70  {
71  if (!isMaxFound_)
72  getMax();
73  return iadcMax_;
74 }

Referenced by EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::analyze().

◆ getPedestal()

double TPNPulse::getPedestal ( )

Definition at line 76 of file TPNPulse.cc.

76  {
77  if (isPedCalc_)
78  return pedestal_;
79  double ped = 0;
80  for (int i = 0; i < _presample; i++) {
81  ped += adc_[i];
82  }
83  ped /= double(_presample);
84  pedestal_ = ped;
85  isPedCalc_ = true;
86  return pedestal_;
87 }

References mps_fire::i.

◆ init()

void TPNPulse::init ( int  nsamples,
int  presample 
)
private

Definition at line 25 of file TPNPulse.cc.

25  {
26  _nsamples = 50;
27  assert(nsamples == _nsamples);
28  assert(presample != 0);
29  adc_ = new double[50];
30 
31  _presample = presample;
32 
33  for (int i = 0; i < _nsamples; i++) {
34  adc_[i] = 0.0;
35  }
36 
37  adcMax_ = 0;
38  iadcMax_ = 0;
39  pedestal_ = 0;
40 
41  isMaxFound_ = false;
42  isPedCalc_ = false;
43 }

References cms::cuda::assert(), and mps_fire::i.

◆ setPresamples()

void TPNPulse::setPresamples ( int  presample)

Definition at line 103 of file TPNPulse.cc.

103  {
104  isPedCalc_ = false;
105  _presample = presample;
106 }

◆ setPulse()

bool TPNPulse::setPulse ( double *  adc)

Definition at line 45 of file TPNPulse.cc.

45  {
46  bool done = false;
47  adc_ = adc;
48  done = true;
49  isMaxFound_ = false;
50  isPedCalc_ = false;
51  return done;
52 }

References ecalLiteDTU::adc(), and fileCollector::done.

Referenced by EcalLaserAnalyzer2::analyze(), and EcalLaserAnalyzer::analyze().

Member Data Documentation

◆ _nsamples

int TPNPulse::_nsamples
private

Definition at line 9 of file TPNPulse.h.

◆ _presample

int TPNPulse::_presample
private

Definition at line 10 of file TPNPulse.h.

◆ adc_

double* TPNPulse::adc_
private

Definition at line 12 of file TPNPulse.h.

◆ adcMax_

double TPNPulse::adcMax_
private

Definition at line 15 of file TPNPulse.h.

◆ iadcMax_

int TPNPulse::iadcMax_
private

Definition at line 16 of file TPNPulse.h.

◆ isMaxFound_

bool TPNPulse::isMaxFound_
private

Definition at line 13 of file TPNPulse.h.

◆ isPedCalc_

bool TPNPulse::isPedCalc_
private

Definition at line 14 of file TPNPulse.h.

◆ pedestal_

double TPNPulse::pedestal_
private

Definition at line 17 of file TPNPulse.h.

TPNPulse::_presample
int _presample
Definition: TPNPulse.h:10
TPNPulse::getMax
double getMax()
Definition: TPNPulse.cc:53
mps_fire.i
i
Definition: mps_fire.py:428
TPNPulse::_nsamples
int _nsamples
Definition: TPNPulse.h:9
cms::cuda::assert
assert(be >=bs)
TPNPulse::adc_
double * adc_
Definition: TPNPulse.h:12
ecalLiteDTU::adc
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
Definition: EcalLiteDTUSample.h:12
fileCollector.done
done
Definition: fileCollector.py:123
TPNPulse::isMaxFound_
bool isMaxFound_
Definition: TPNPulse.h:13
TPNPulse::adcMax_
double adcMax_
Definition: TPNPulse.h:15
TPNPulse::getPedestal
double getPedestal()
Definition: TPNPulse.cc:76
TPNPulse::iadcMax_
int iadcMax_
Definition: TPNPulse.h:16
TPNPulse::init
void init(int, int)
Definition: TPNPulse.cc:25
TPNPulse::isPedCalc_
bool isPedCalc_
Definition: TPNPulse.h:14
TPNPulse::pedestal_
double pedestal_
Definition: TPNPulse.h:17