GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TTigressHit.cxx
Go to the documentation of this file.
1#include "TTigressHit.h"
2
3#include "TTigress.h"
4
9
11{
12 rhs.Copy(*this);
13}
14
16{
17 frag.Copy(*this);
18}
19
21{
22 frag.Copy(*this);
23}
24
25void TTigressHit::Clear(Option_t* opt)
26{
28 fTimeFit = 0.0;
29 fSig2Noise = 0.0;
30
31 fCoreSet = false;
32 fBgoFired = false;
33 fSegments.clear();
34}
35
36void TTigressHit::Copy(TObject& rhs) const
37{
39 static_cast<TTigressHit&>(rhs).fTimeFit = fTimeFit;
40 static_cast<TTigressHit&>(rhs).fSegments = fSegments;
41 static_cast<TTigressHit&>(rhs).fCoreSet = fCoreSet;
42 static_cast<TTigressHit&>(rhs).fBgoFired = fBgoFired;
43}
44
45void TTigressHit::Copy(TObject& rhs, bool waveform) const
46{
47 Copy(rhs);
48 if(waveform) {
49 CopyWave(rhs);
50 }
51}
52
53TVector3 TTigressHit::GetPosition(Double_t dist) const
54{
55 return TTigress::GetPosition(*this, dist);
56}
57
58TVector3 TTigressHit::GetLastPosition(Double_t dist) const
59{
60 const TDetectorHit* seg = nullptr;
61 if(GetNSegments() > 0) {
62 seg = &GetSegmentHit(GetNSegments() - 1); // returns the last segment in the segment vector.
63 } else {
64 seg = this; // if no segments, use the core. pcb.
65 }
66
67 return TTigress::GetPosition(seg->GetDetector(), seg->GetCrystal(), seg->GetSegment(), dist);
68}
69
70void TTigressHit::Print(Option_t*) const
71{
72 Print(std::cout);
73}
74
75void TTigressHit::Print(std::ostream& out) const
76{
77 std::ostringstream str;
78 //TString sopt(opt);
79 str << "==== TigressHit @ " << this << " ====" << std::endl;
80 str << "\t" << GetName() << std::endl;
81 str << "\tCharge: " << GetCharge() << std::endl;
82 str << "\tEnergy: " << GetEnergy() << std::endl;
83 str << "\tTime: " << GetTime() << std::endl;
84 str << "\tCore set: " << (CoreSet() ? "true" : "false") << std::endl;
85 str << "\tBGO Fired: " << (BGOFired() ? "true" : "false") << std::endl;
86 str << "\tTime: " << GetTimeStamp() << std::endl;
87 str << "\thit contains " << GetNSegments() << " segments." << std::endl;
88 //if(sopt.Contains("all")) {
89 str << "Name Charge" << std::endl;
90 for(int x = 0; x < GetNSegments(); x++) {
91 str << "\t\t" << GetSegmentHit(x).GetName() << " | " << GetSegmentHit(x).GetCharge() << std::endl;
92 }
93 auto p = GetPosition();
94 str << p.GetName() << " " << p.GetTitle() << " (x,y,z)=(" << p.X() << "," << p.Y() << "," << p.Z() << ") (rho,theta,phi)=(" << p.Mag() << "," << p.Theta() << "," << p.Phi() << ")" << std::endl;
95 //}
96 str << "============================" << std::endl;
97 out << str.str();
98}
99
100bool TTigressHit::Compare(const TTigressHit& lhs, const TTigressHit& rhs)
101{
102 if(lhs.GetDetector() == rhs.GetDetector()) {
103 return (lhs.GetCrystal() < rhs.GetCrystal());
104 }
105 return (lhs.GetDetector() < rhs.GetDetector());
106}
107
109{
110 return (lhs.GetEnergy()) > rhs.GetEnergy();
111}
112
114{
115 if(this != hit) {
116
117 // Should always be true when called by addback construction due to energy ordering during detector construction
118 if(GetEnergy() > hit->GetEnergy()) {
119 SetTime(GetTime()); // Needs to be call before energy sum to ensure and kIsTimeSet using original energy
120 // for any adjustment
121 for(int x = 0; x < hit->GetNSegments(); x++) {
122 AddSegment((hit->fSegments[x]));
123 }
124 } else {
125 SetTime(hit->GetTime());
126 SetAddress(hit->GetAddress());
127 SetCfd(hit->GetCfd());
128
129 // Maybe overkill, but consistent
130 std::vector<TDetectorHit> fSegmentHold = hit->fSegments;
131 for(int x = 0; x < GetNSegments(); x++) {
132 fSegmentHold.push_back(fSegments[x]);
133 }
134 fSegments = fSegmentHold;
135 }
136
137 SetEnergy(GetEnergy() + hit->GetEnergy());
138
139 if(hit->BGOFired()) {
140 SetBGOFired(true);
141 }
142 }
143}
144
146{
147 TPulseAnalyzer pulse(frag);
148 if(pulse.IsSet()) {
149 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
150 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
151 }
152}
153
155{
156 TPulseAnalyzer pulse(*GetWaveform(), 0, GetName());
157 if(pulse.IsSet()) {
158 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
159 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
160 }
161}
virtual Float_t GetCharge() const
!
Double_t SetEnergy(const double &energy) const
virtual UInt_t GetAddress() const
!
virtual void SetCfd(const Float_t &val)
!
virtual Long64_t GetTimeStamp(Option_t *="") const
virtual TVector3 GetPosition() const
!
virtual double GetEnergy(Option_t *opt="") const
const char * GetName() const override
!
const std::vector< Short_t > * GetWaveform() const
!
virtual Int_t GetCrystal() const
!
void Clear(Option_t *opt="") override
!
virtual Int_t GetDetector() const
!
virtual Float_t GetCfd() const
!
virtual Int_t GetSegment() const
!
void Copy(TObject &) const override
!
virtual Double_t GetTime(const ETimeFlag &correct_flag=ETimeFlag::kAll, Option_t *opt="") const
Returns a time value to the nearest nanosecond!
void SetAddress(const UInt_t &temp_address)
!
Double_t SetTime(const Double_t &time) const
virtual void CopyWave(TObject &) const
!
bool IsSet() const
int GetNSegments() const
!
Definition TTigressHit.h:90
void Print(Option_t *opt="") const override
!
static bool CompareEnergy(const TTigressHit &lhs, const TTigressHit &rhs)
!
void SetBGOFired(bool fired)
Definition TTigressHit.h:85
TVector3 GetLastPosition(Double_t dist=0.) const
void Clear(Option_t *opt="") override
!
void SumHit(TTigressHit *)
!
bool BGOFired() const
Definition TTigressHit.h:84
Float_t fSig2Noise
Definition TTigressHit.h:43
std::vector< TDetectorHit > fSegments
Definition TTigressHit.h:38
void SetWavefit()
static bool Compare(const TTigressHit &lhs, const TTigressHit &rhs)
!
const TDetectorHit & GetSegmentHit(int i) const
!
Definition TTigressHit.h:94
Float_t fTimeFit
Definition TTigressHit.h:42
bool CoreSet() const
Definition TTigressHit.h:82
void AddSegment(const TDetectorHit &seg)
!
Definition TTigressHit.h:56
void Copy(TObject &) const override
!
void CopyFragment(const TFragment &frag)
static TVector3 GetPosition(int DetNbr, int CryNbr, int SegNbr, double dist=0., bool smear=false)
!
Definition TTigress.cxx:340