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