1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
/*
* \class TPNPulse
*
* \author: Julie Malcles - CEA/Saclay
*/
#include <CalibCalorimetry/EcalLaserAnalyzer/interface/TPNPulse.h>
#include <TMath.h>
#include <iostream>
#include <cassert>
using namespace std;
//ClassImp(TPNPulse)
// Default Constructor...
TPNPulse::TPNPulse() { init(50, 6); }
// Constructor...
TPNPulse::TPNPulse(int nsamples, int presample) { init(nsamples, presample); }
// Destructor
TPNPulse::~TPNPulse() {}
void TPNPulse::init(int nsamples, int presample) {
_nsamples = 50;
assert(nsamples == _nsamples);
assert(presample != 0);
adc_ = new double[50];
_presample = presample;
for (int i = 0; i < _nsamples; i++) {
adc_[i] = 0.0;
}
adcMax_ = 0;
iadcMax_ = 0;
pedestal_ = 0;
isMaxFound_ = false;
isPedCalc_ = false;
}
bool TPNPulse::setPulse(double *adc) {
bool done = false;
adc_ = adc;
done = true;
isMaxFound_ = false;
isPedCalc_ = false;
return done;
}
double TPNPulse::getMax() {
if (isMaxFound_)
return adcMax_;
int iadcmax = 0;
double adcmax = 0.0;
for (int i = 0; i < _nsamples; i++) {
if (adc_[i] > adcmax) {
iadcmax = i;
adcmax = adc_[i];
}
}
iadcMax_ = iadcmax;
adcMax_ = adcmax;
return adcMax_;
}
int TPNPulse::getMaxSample() {
if (!isMaxFound_)
getMax();
return iadcMax_;
}
double TPNPulse::getPedestal() {
if (isPedCalc_)
return pedestal_;
double ped = 0;
for (int i = 0; i < _presample; i++) {
ped += adc_[i];
}
ped /= double(_presample);
pedestal_ = ped;
isPedCalc_ = true;
return pedestal_;
}
double *TPNPulse::getAdcWithoutPedestal() {
double ped;
if (!isPedCalc_)
ped = getPedestal();
else
ped = pedestal_;
double *adcNoPed = new double[50];
for (int i = 0; i < _nsamples; i++) {
adcNoPed[i] = adc_[i] - ped;
}
return adcNoPed;
}
void TPNPulse::setPresamples(int presample) {
isPedCalc_ = false;
_presample = presample;
}
|