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