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