forked from JeffersonLab/SBS-offline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SBSScintHit.cxx
125 lines (105 loc) · 3.59 KB
/
SBSScintHit.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
///////////////////////////////////////////////////////////////////////////////
// //
// SBSScintHit //
// //
// Class representing a single hit for a scint //
// //
///////////////////////////////////////////////////////////////////////////////
#include "SBSScintHit.h"
//_______________________________________________________________________________
SBSScintHit::SBSScintHit( const SBSScintBar* bar,Int_t planenum, Int_t barnum,
Double_t ypos,
Double_t Tof, Double_t HitEnergy, Double_t Tdiff)
{
Clear();
fScBar = const_cast<SBSScintBar*>(bar);
fPlaneNum = planenum;
fBarNum = barnum;
fHitYPos = ypos;
fHitTOF = Tof;
fHitEdep = HitEnergy;
fTdiff = Tdiff;
if (bar) {
fHitXPos = bar->GetXPos();
fHitZPos = bar->GetZPos();
fBarNum_nd = bar->GetBarNum_nd();
} else {
fHitXPos = -1.e5;
fHitZPos = -1.e5;
}
}
//_______________________________________________________________________________
SBSScintHit::SBSScintHit(const SBSScintHit* pScHit)
{
Clear();
CopyScintHit(pScHit);
}
//_______________________________________________________________________________
SBSScintHit::SBSScintHit(const SBSScintHit* pScHit, Int_t clusternum)
{
Clear();
fClusterNum=clusternum;
CopyScintHit(pScHit);
}
//_______________________________________________________________________________
SBSScintHit::SBSScintHit(const SBSScintHit* pScHit, Int_t planenum, Int_t Bar_nd)
{
Clear();
fPlaneNum=planenum;
fBarNum_nd=Bar_nd;
CopyScintHit(pScHit);
}
//___________________________________________________________________________
void SBSScintHit::Clear(Option_t *) {
fScBar = nullptr;
fPlaneNum = -1;
fBarNum = 0;
fBarNum_nd = -1;
fOrder = 0;
fClusterNum = -1;
fHitXPos = fHitYPos = fHitZPos = fHitTOF = fHitEdep = fTdiff = 0;
}
//___________________________________________________________________________
SBSScintHit::~SBSScintHit()
{
fScBar = 0;
}
//_____________________________________________________________________________
Int_t SBSScintHit::CopyScintHit(const SBSScintHit* pScHit)
{
if(pScHit){
fScBar = pScHit->fScBar;
fBarNum = pScHit->fBarNum;
if(fBarNum_nd<0) fBarNum_nd = pScHit->fBarNum_nd;
fHitXPos = pScHit->fHitXPos;
fHitYPos = pScHit->fHitYPos;
fHitZPos = pScHit->fHitZPos;
fHitTOF = pScHit->fHitTOF;
fHitEdep = pScHit->fHitEdep;
fTdiff = pScHit->fTdiff;
fOrder = pScHit->fOrder;
if(fClusterNum<0) fClusterNum = pScHit->fClusterNum;
if(fPlaneNum<0) fPlaneNum = pScHit->fPlaneNum;
}
return 0;
}
//_____________________________________________________________________________
Int_t SBSScintHit::Compare(const TObject* obj) const
{
// Compare two hits via plane number, and then bar number,
// and finally time
// Returns -1 if this < obj, 0 if this==obj, and 1 if this>obj
const SBSScintHit *h = static_cast<const SBSScintHit*>(obj);
// Side (Left-right) comparison
if (fPlaneNum < h->fPlaneNum) return -1;
if (fPlaneNum > h->fPlaneNum) return 1;
// Bar-number comparison
if (fBarNum < h->fBarNum) return -1;
if (fBarNum > h->fBarNum) return 1;
// finally, time comparison, earlier wins
if (fHitTOF < h->fHitTOF) return -1;
if (fHitTOF > h->fHitTOF) return 1;
return 0;
}
//////////////////////////////////////////////////////////////////////////////
ClassImp(SBSScintHit)