GRSISort "v4.1.1.0"
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 <cmath>
4#include <iostream>
5
6#include "TTigress.h"
7#include "TPulseAnalyzer.h"
8
10{
11 /// Default Ctor. Ignores TObject Streamer in ROOT < 6.
12 Clear();
13}
14
16{
17 /// Copy Ctor. Ignores TObject Streamer in ROOT < 6.
18 Clear();
19 rhs.Copy(*this);
20}
21
23{
24 frag.Copy(*this);
26}
27
29{
30 frag.Copy(*this);
32}
33
34void TTigressHit::Copy(TObject& rhs) const
35{
37 static_cast<TTigressHit&>(rhs).fFilter = fFilter;
38 // We should copy over a 0 and let the hit recalculate, this is safest
39 static_cast<TTigressHit&>(rhs).fTigressHitBits = 0;
40 static_cast<TTigressHit&>(rhs).fTimeFit = fTimeFit;
41 static_cast<TTigressHit&>(rhs).fSegments = fSegments;
42 static_cast<TTigressHit&>(rhs).fCoreSet = fCoreSet;
43 static_cast<TTigressHit&>(rhs).fBgoFired = fBgoFired;
44}
45
46void TTigressHit::Copy(TObject& obj, bool waveform) const
47{
48 Copy(obj);
49 if(waveform) {
50 CopyWave(obj);
51 }
52}
53
55{
56 // check if the desired filter is in wanted filter;
57 // return the answer;
58 return true;
59}
60
61void TTigressHit::Clear(Option_t* opt)
62{
63 // Clears the information stored in the TTigressHit.
64 TDetectorHit::Clear(opt); // clears the base (address, position and waveform)
65 fFilter = 0;
67
68 fTimeFit = 0.0;
69 fSig2Noise = 0.0;
70
71 fCoreSet = false;
72 fBgoFired = false;
73 fSegments.clear();
74}
75
76void TTigressHit::Print(Option_t*) const
77{
78 // Prints the Detector Number, Crystal Number, Energy, Time and Angle.
79 Print(std::cout);
80}
81
82void TTigressHit::Print(std::ostream& out) const
83{
84 std::ostringstream str;
85 str << "==== TigressHit @ " << this << " ====" << std::endl
86 << "\t" << GetName() << std::endl
87 << "\tCharge: " << GetCharge() << std::endl
88 << "\tEnergy: " << GetEnergy() << std::endl
89 << "\tTime: " << GetTime() << std::endl
90 << "\tCore set: " << (CoreSet() ? "true" : "false") << std::endl
91 << "\tBGO Fired: " << (BGOFired() ? "true" : "false") << std::endl
92 << "\tTime: " << GetTimeStamp() << std::endl
93 << "\thit contains " << GetNSegments() << " segments:" << std::endl;
94 str << "Name Charge" << std::endl;
95 for(int x = 0; x < GetNSegments(); x++) {
96 str << "\t\t" << GetSegmentHit(x).GetName() << " | " << GetSegmentHit(x).GetCharge() << std::endl;
97 }
98 auto p = GetPosition();
99 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;
100 str << "============================" << std::endl;
101
102 out << str.str();
103}
104
105TVector3 TTigressHit::GetPosition(double dist) const
106{
108}
109
110TVector3 TTigressHit::GetLastPosition(double dist) const
111{
112 const TDetectorHit* seg = nullptr;
113 if(GetNSegments() > 0) {
114 seg = &fSegments.back(); // last segment in the segment vector.
115 } else {
116 seg = this; // if no segments, use the core.
117 }
118
119 return TTigress::GetPosition(seg->GetDetector(), seg->GetCrystal(), seg->GetSegment(), dist);
120}
121
123{
125}
126
128{
129 return lhs->GetEnergy() > rhs->GetEnergy();
130}
131
132bool TTigressHit::Compare(const TTigressHit* lhs, const TTigressHit* rhs)
133{
134 if(lhs->GetDetector() == rhs->GetDetector()) {
135 return lhs->GetCrystal() < rhs->GetCrystal();
136 }
137 return lhs->GetDetector() < rhs->GetDetector();
138}
139
141{
142 if(hit == this) { return; }
143
144 const auto* tigressHit = dynamic_cast<const TTigressHit*>(hit);
145 if(tigressHit == nullptr) {
146 throw std::runtime_error("trying to add non-griffin hit to griffin hit!");
147 }
148 // add another griffin hit to this one (for addback),
149 // using the time and position information of the one with the higher energy
150 if(!CompareEnergy(this, tigressHit)) {
151 SetCfd(tigressHit->GetCfd());
152 SetTime(tigressHit->GetTime());
153 SetAddress(tigressHit->GetAddress());
154 } else {
155 SetTime(GetTime());
156 }
157 SetEnergy(GetEnergy() + tigressHit->GetEnergy());
158 // this has to be done at the very end, otherwise GetEnergy() might not work
159 SetCharge(0);
160 // Add all of the pileups.This should be changed when the max number of pileups changes
161 if((NPileUps() + tigressHit->NPileUps()) < 4) {
162 SetNPileUps(NPileUps() + tigressHit->NPileUps());
163 } else {
164 SetNPileUps(3);
165 }
166 if((PUHit() + tigressHit->PUHit()) < 4) {
167 SetPUHit(PUHit() + tigressHit->PUHit());
168 } else {
169 SetPUHit(3);
170 }
171 // KValue is somewhat meaningless in addback, so I am using it as an indicator that a piledup griffinHit was added-back RD
172 if(GetKValue() > tigressHit->GetKValue()) {
173 SetKValue(tigressHit->GetKValue());
174 }
175}
176
178{
179 fTigressHitBits.SetBit(flag, set);
180}
181
182UShort_t TTigressHit::NPileUps() const
183{
184 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
186}
187
188UShort_t TTigressHit::PUHit() const
189{
190 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
191 return static_cast<UShort_t>(fTigressHitBits.TestBits(ETigressHitBits::kPUHit1) +
192 (fTigressHitBits.TestBits(ETigressHitBits::kPUHit2) >> static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kPUHitOffset)));
193}
194
195void TTigressHit::SetNPileUps(UChar_t npileups)
196{
197 SetTigressFlag(ETigressHitBits::kTotalPU1, (npileups & static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kTotalPU1)) != 0);
198 SetTigressFlag(ETigressHitBits::kTotalPU2, (npileups & static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kTotalPU2)) != 0);
199}
200
201void TTigressHit::SetPUHit(UChar_t puhit)
202{
203 if(puhit > 2) {
204 puhit = 3;
205 }
206 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
207
208 SetTigressFlag(ETigressHitBits::kPUHit1, ((puhit << static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kPUHitOffset)) & static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kPUHit1)) != 0);
209 SetTigressFlag(ETigressHitBits::kPUHit2, ((puhit << static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kPUHitOffset)) & static_cast<std::underlying_type<ETigressHitBits>::type>(ETigressHitBits::kPUHit2)) != 0);
210}
211
212Double_t TTigressHit::GetNoCTEnergy(Option_t*) const
213{
214 TChannel* chan = GetChannel();
215 if(chan == nullptr) {
216 Error("GetEnergy", "No TChannel exists for address 0x%08x", GetAddress());
217 return 0.;
218 }
219 return chan->CalibrateENG(Charge(), GetKValue());
220}
221
223{
224 TPulseAnalyzer pulse(frag);
225 if(pulse.IsSet()) {
226 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
227 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
228 }
229}
230
232{
233 TPulseAnalyzer pulse(*GetWaveform(), 0, GetName());
234 if(pulse.IsSet()) {
235 fTimeFit = static_cast<Float_t>(pulse.fit_newT0());
236 fSig2Noise = static_cast<Float_t>(pulse.get_sig2noise());
237 }
238}
double CalibrateENG(double) const
Definition TChannel.cxx:668
void SetKValue(const Short_t &temp_kval)
!
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 double GetEnergy(Option_t *opt="") const
virtual Short_t GetKValue() const
!
const char * GetName() const override
!
const std::vector< Short_t > * GetWaveform() const
!
virtual Int_t GetCrystal() const
!
virtual Float_t Charge() const
!
TChannel * GetChannel() const
!
void SetCharge(const Float_t &temp_charge)
!
void Clear(Option_t *opt="") override
!
virtual Int_t GetDetector() 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
!
Short_t GetNumberOfPileups() const
Definition TFragment.h:77
bool IsSet() const
int GetNSegments() const
!
Definition TTigressHit.h:85
Double_t GetNoCTEnergy(Option_t *opt="") const
TTransientBits< UChar_t > fTigressHitBits
Transient Member Flags.
Definition TTigressHit.h:43
void Print(Option_t *opt="") const override
!
void Clear(Option_t *opt="") override
!
void SetPUHit(UChar_t puhit)
UShort_t NPileUps() const
Double_t GetDefaultDistance() const
bool BGOFired() const
Definition TTigressHit.h:79
TVector3 GetPosition() const override
!
void CopyFragment(const TFragment &)
Float_t fSig2Noise
Definition TTigressHit.h:51
void Add(const TDetectorHit *) override
!
Int_t fFilter
The Filter Word.
Definition TTigressHit.h:42
static bool Compare(const TTigressHit *, const TTigressHit *)
!
std::vector< TDetectorHit > fSegments
Definition TTigressHit.h:46
void SetWavefit()
const TDetectorHit & GetSegmentHit(int i) const
!
Definition TTigressHit.h:87
void SetNPileUps(UChar_t npileups)
bool InFilter(Int_t)
!
static bool CompareEnergy(const TTigressHit *, const TTigressHit *)
!
Float_t fTimeFit
Definition TTigressHit.h:50
UShort_t PUHit() const
TVector3 GetLastPosition(double dist) const
!
bool CoreSet() const
Definition TTigressHit.h:77
void Copy(TObject &) const override
!
void SetTigressFlag(ETigressHitBits, Bool_t set)
static TVector3 GetPosition(int DetNbr, int CryNbr, int SegNbr, double dist=110.0, bool smear=false)
!
Definition TTigress.cxx:562
void SetBit(T bit, Bool_t flag)
T TestBits(T bit) const