-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathSBSAdcHit.cxx
79 lines (64 loc) · 2.38 KB
/
SBSAdcHit.cxx
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
///////////////////////////////////////////////////////////////////////////////
// //
// SBSAdcHit //
// //
// //
///////////////////////////////////////////////////////////////////////////////
#include "SBSAdcHit.h"
#include "SBSScintPMT.h"
using namespace std;
//_____________________________________________________________________________
SBSAdcHit::SBSAdcHit(SBSScintPMT* pmt, Int_t rawampl):fPMT(pmt),
fRawAmpl(rawampl)
{
// Construct and correct the Adc hit for calibrations.
if (pmt) {
fBarNum = pmt->GetBarNum();
fSide = pmt->GetSide();
} else {
fBarNum = 0;
fSide = 0;
}
CorrectHit();
}
//_____________________________________________________________________________
void SBSAdcHit::CorrectHit() {
// Apply the associated PMT's pedestal and gain correction factors.
SBSScintPMT* pmt = GetPMT();
if (pmt) {
fAmplPedCor = fRawAmpl - pmt->GetPed();
fAmpl = fAmplPedCor * pmt->GetGain();
} else {
fAmplPedCor = 0;
fAmpl = 0;
}
}
//_____________________________________________________________________________
Int_t SBSAdcHit::Compare(const TObject *obj) const {
// sort SBSAdcHits according to side and bar number.
// obj should be a SBSAdcHit, and we will assume as much
//
// Returns -1 if this < obj, 0 if this==obj, and 1 if this>obj
const SBSAdcHit *h = static_cast<const SBSAdcHit*>(obj);
// Side (Left-right) comparison
if (fSide < h->fSide) return -1;
if (fSide > h->fSide) return 1;
// Bar-number comparison
if (fBarNum < h->fBarNum) return -1;
if (fBarNum > h->fBarNum) return 1;
// finally, Amplitude comparison, highest Amplitude "wins" (first)
if (fAmpl < h->fAmpl) return 1;
if (fAmpl > h->fAmpl) return -1;
return 0;
}
//_____________________________________________________________________________
void SBSAdcHit::Clear(Option_t *) {
// clear the data inside SBSAdcHit, so it does not have to be deleted each
// time
fPMT = nullptr;
fRawAmpl = fAmplPedCor = fSide = 0;
fBarNum = -1;
fAmpl = 0;
}
///////////////////////////////////////////////////////////////////////////////
ClassImp(SBSAdcHit)