GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGriffinHit.cxx
Go to the documentation of this file.
1#include "TGriffin.h"
2#include "TGriffinHit.h"
3#include "Globals.h"
4#include <cmath>
5#include <iostream>
6
8{
9 /// Default Ctor. Ignores TObject Streamer in ROOT < 6.
10 Clear();
11}
12
14{
15 /// Copy Ctor. Ignores TObject Streamer in ROOT < 6.
16 Clear();
17 rhs.Copy(*this);
18}
19
21{
22 frag.Copy(*this);
24}
25
26void TGriffinHit::Copy(TObject& rhs) const
27{
29 static_cast<TGriffinHit&>(rhs).fFilter = fFilter;
30 // We should copy over a 0 and let the hit recalculate, this is safest
31 static_cast<TGriffinHit&>(rhs).fGriffinHitBits = 0;
33}
34
35void TGriffinHit::Copy(TObject& obj, bool waveform) const
36{
37 Copy(obj);
38 if(waveform) {
39 CopyWave(obj);
40 }
41}
42
44{
45 // check if the desired filter is in wanted filter;
46 // return the answer;
47 return true;
48}
49
50void TGriffinHit::Clear(Option_t* opt)
51{
52 // Clears the information stored in the TGriffinHit.
53 TDetectorHit::Clear(opt); // clears the base (address, position and waveform)
54 fFilter = 0;
57}
58
59void TGriffinHit::Print(Option_t*) const
60{
61 // Prints the Detector Number, Crystal Number, Energy, Time and Angle.
62 Print(std::cout);
63}
64
65void TGriffinHit::Print(std::ostream& out) const
66{
67 std::ostringstream str;
68 str << "Griffin Detector: " << GetDetector() << std::endl
69 << "Griffin Crystal: " << GetCrystal() << std::endl
70 << "Griffin Energy: " << GetEnergy() << std::endl
71 << "Griffin hit time: " << GetTime() << ", TS (in ns) " << GetTimeStampNs() << ", TS " << GetTimeStamp() << std::endl
72 << "Griffin hit TV3 theta: " << GetPosition().Theta() * 180 / (3.141597) << " \tphi: " << GetPosition().Phi() * 180 / (3.141597) << std::endl;
73 out << str.str();
74}
75
76TVector3 TGriffinHit::GetPosition(double dist) const
77{
79}
80
82{
84}
85
87{
88 return (lhs->GetEnergy() > rhs->GetEnergy());
89}
90
92{
93 const auto* griffinHit = dynamic_cast<const TGriffinHit*>(hit);
94 if(griffinHit == nullptr) {
95 throw std::runtime_error("trying to add non-griffin hit to griffin hit!");
96 }
97 // add another griffin hit to this one (for addback),
98 // using the time and position information of the one with the higher energy
99 if(!CompareEnergy(this, griffinHit)) {
100 SetCfd(griffinHit->GetCfd());
101 SetTime(griffinHit->GetTime());
102 // SetPosition(griffinHit->GetPosition());
103 SetAddress(griffinHit->GetAddress());
104 } else {
105 SetTime(GetTime());
106 }
107 SetEnergy(GetEnergy() + griffinHit->GetEnergy());
108 // this has to be done at the very end, otherwise GetEnergy() might not work
109 SetCharge(0);
110 // Add all of the pileups.This should be changed when the max number of pileups changes
111 if((NPileUps() + griffinHit->NPileUps()) < 4) {
112 SetNPileUps(NPileUps() + griffinHit->NPileUps());
113 } else {
114 SetNPileUps(3);
115 }
116 if((PUHit() + griffinHit->PUHit()) < 4) {
117 SetPUHit(PUHit() + griffinHit->PUHit());
118 } else {
119 SetPUHit(3);
120 }
121 // KValue is somewhate meaningless in addback, so I am using it as an indicator that a piledup griffinHit was added-back RD
122 if(GetKValue() > griffinHit->GetKValue()) {
123 SetKValue(griffinHit->GetKValue());
124 }
125}
126
128{
129 fGriffinHitBits.SetBit(flag, set);
130}
131
132UShort_t TGriffinHit::NPileUps() const
133{
134 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
136}
137
138UShort_t TGriffinHit::PUHit() const
139{
140 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
141 return static_cast<UShort_t>(fGriffinHitBits.TestBits(EGriffinHitBits::kPUHit1) +
142 (fGriffinHitBits.TestBits(EGriffinHitBits::kPUHit2) >> static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kPUHitOffset)));
143}
144
145void TGriffinHit::SetNPileUps(UChar_t npileups)
146{
147 SetGriffinFlag(EGriffinHitBits::kTotalPU1, (npileups & static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kTotalPU1)) != 0);
148 SetGriffinFlag(EGriffinHitBits::kTotalPU2, (npileups & static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kTotalPU2)) != 0);
149}
150
151void TGriffinHit::SetPUHit(UChar_t puhit)
152{
153 if(puhit > 2) {
154 puhit = 3;
155 }
156 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
157
158 SetGriffinFlag(EGriffinHitBits::kPUHit1, ((puhit << static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kPUHitOffset)) & static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kPUHit1)) != 0);
159 SetGriffinFlag(EGriffinHitBits::kPUHit2, ((puhit << static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kPUHitOffset)) & static_cast<std::underlying_type<EGriffinHitBits>::type>(EGriffinHitBits::kPUHit2)) != 0);
160}
161
162Double_t TGriffinHit::GetNoCTEnergy(Option_t*) const
163{
164 TChannel* chan = GetChannel();
165 if(chan == nullptr) {
166 Error("GetEnergy", "No TChannel exists for address 0x%08x", GetAddress());
167 return 0.;
168 }
169 return chan->CalibrateENG(Charge(), GetKValue());
170}
double CalibrateENG(double) const
Definition TChannel.cxx:646
void SetKValue(const Short_t &temp_kval)
!
Double_t SetEnergy(const double &energy) const
virtual UInt_t GetAddress() const
!
virtual void SetCfd(const Float_t &val)
!
virtual Long64_t GetTimeStampNs(Option_t *opt="") const
virtual Long64_t GetTimeStamp(Option_t *="") const
virtual double GetEnergy(Option_t *opt="") const
virtual Short_t GetKValue() 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
!
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:78
Double_t GetDefaultDistance() const
Definition TGriffinHit.h:85
TVector3 GetPosition() const override
!
void Print(Option_t *opt="") const override
!
TTransientBits< UChar_t > fGriffinHitBits
Transient Member Flags.
Definition TGriffinHit.h:42
Bool_t fBremSuppressed_flag
! Bremsstrahlung Suppression flag.
Definition TGriffinHit.h:43
void SetGriffinFlag(EGriffinHitBits, Bool_t set)
static bool CompareEnergy(const TGriffinHit *, const TGriffinHit *)
!
void SetPUHit(UChar_t puhit)
void SetNPileUps(UChar_t npileups)
Double_t GetNoCTEnergy(Option_t *opt="") const
Int_t fFilter
The Filter Word.
Definition TGriffinHit.h:41
UShort_t NPileUps() const
void Add(const TDetectorHit *) override
!
void Clear(Option_t *opt="") override
!
UShort_t PUHit() const
void Copy(TObject &) const override
!
bool InFilter(Int_t)
!
static TVector3 GetPosition(int DetNbr, int CryNbr=5, double dist=110.0)
!
Definition TGriffin.cxx:501
void SetBit(T bit, Bool_t flag)
T TestBits(T bit) const