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 "TClass.h"
4
5#include "TTigress.h"
6
11
13{
14 rhs.Copy(*this);
15}
16
18{
19 frag.Copy(*this);
20}
21
23{
24 frag.Copy(*this);
25}
26
27void TTigressHit::Clear(Option_t* opt)
28{
30 fTimeFit = 0.0;
31 fSig2Noise = 0.0;
32
33 fCoreSet = false;
34 fBgoFired = false;
35 fSegments.clear();
36}
37
38void TTigressHit::Copy(TObject& rhs) const
39{
41 static_cast<TTigressHit&>(rhs).fTimeFit = fTimeFit;
42 static_cast<TTigressHit&>(rhs).fSegments = fSegments;
43 static_cast<TTigressHit&>(rhs).fCoreSet = fCoreSet;
44 static_cast<TTigressHit&>(rhs).fBgoFired = fBgoFired;
45}
46
47void TTigressHit::Copy(TObject& rhs, bool waveform) const
48{
49 Copy(rhs);
50 if(waveform) {
51 CopyWave(rhs);
52 }
53}
54
55TVector3 TTigressHit::GetPosition(Double_t dist) const
56{
57 return TTigress::GetPosition(*this, dist);
58}
59
60TVector3 TTigressHit::GetLastPosition(Double_t dist) const
61{
62 const TDetectorHit* seg = nullptr;
63 if(GetNSegments() > 0) {
64 seg = &GetSegmentHit(GetNSegments() - 1); // returns the last segment in the segment vector.
65 } else {
66 seg = this; // if no segments, use the core. pcb.
67 }
68
69 return TTigress::GetPosition(seg->GetDetector(), seg->GetCrystal(), seg->GetSegment(), dist);
70}
71
72void TTigressHit::Print(Option_t*) const
73{
74 Print(std::cout);
75}
76
77void TTigressHit::Print(std::ostream& out) const
78{
79 std::ostringstream str;
80 //TString sopt(opt);
81 str << "==== TigressHit @ " << this << " ====" << std::endl;
82 str << "\t" << GetName() << std::endl;
83 str << "\tCharge: " << GetCharge() << std::endl;
84 str << "\tEnergy: " << GetEnergy() << std::endl;
85 str << "\tTime: " << GetTime() << std::endl;
86 str << "\tCore set: " << (CoreSet() ? "true" : "false") << std::endl;
87 str << "\tBGO Fired: " << (BGOFired() ? "true" : "false") << std::endl;
88 str << "\tTime: " << GetTimeStamp() << std::endl;
89 str << "\thit contains " << GetNSegments() << " segments." << std::endl;
90 //if(sopt.Contains("all")) {
91 str << "Name Charge" << std::endl;
92 for(int x = 0; x < GetNSegments(); x++) {
93 str << "\t\t" << GetSegmentHit(x).GetName() << " | " << GetSegmentHit(x).GetCharge() << std::endl;
94 }
95 auto p = GetPosition();
96 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;
97 //}
98 str << "============================" << std::endl;
99 out << str.str();
100}
101
102bool TTigressHit::Compare(const TTigressHit& lhs, const TTigressHit& rhs)
103{
104 if(lhs.GetDetector() == rhs.GetDetector()) {
105 return (lhs.GetCrystal() < rhs.GetCrystal());
106 }
107 return (lhs.GetDetector() < rhs.GetDetector());
108}
109
111{
112 return (lhs.GetEnergy()) > rhs.GetEnergy();
113}
114
116{
117 if(this != hit) {
118
119 // Should always be true when called by addback construction due to energy ordering during detector construction
120 if(GetEnergy() > hit->GetEnergy()) {
121 SetTime(GetTime()); // Needs to be call before energy sum to ensure and kIsTimeSet using original energy
122 // for any adjustment
123 for(int x = 0; x < hit->GetNSegments(); x++) {
124 AddSegment((hit->fSegments[x]));
125 }
126 } else {
127 SetTime(hit->GetTime());
128 SetAddress(hit->GetAddress());
129 SetCfd(hit->GetCfd());
130
131 // Maybe overkill, but consistent
132 std::vector<TDetectorHit> fSegmentHold = hit->fSegments;
133 for(int x = 0; x < GetNSegments(); x++) {
134 fSegmentHold.push_back(fSegments[x]);
135 }
136 fSegments = fSegmentHold;
137 }
138
139 SetEnergy(GetEnergy() + hit->GetEnergy());
140
141 if(hit->BGOFired()) {
142 SetBGOFired(true);
143 }
144 }
145}
146
148{
149 TPulseAnalyzer pulse(frag);
150 if(pulse.IsSet()) {
151 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
152 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
153 }
154}
155
157{
158 TPulseAnalyzer pulse(*GetWaveform(), 0, GetName());
159 if(pulse.IsSet()) {
160 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
161 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
162 }
163}
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:326