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
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 TTdrCloverHit::Copy(TObject& rhs) const
33{
35 static_cast<TTdrCloverHit&>(rhs).fFilter = fFilter;
36 static_cast<TTdrCloverHit&>(rhs).fCrystal = fCrystal;
38}
39
40void TTdrCloverHit::Copy(TObject& obj, bool waveform) const
41{
42 Copy(obj);
43 if(waveform) {
44 CopyWave(obj);
45 }
46}
47
49{
50 // check if the desired filter is in wanted filter;
51 // return the answer;
52 return true;
53}
54
55void TTdrCloverHit::Clear(Option_t* opt)
56{
57 // Clears the information stored in the TTdrCloverHit.
58 TDetectorHit::Clear(opt); // clears the base (address, position and waveform)
59 fFilter = 0;
60 fCrystal = 0xFFFF;
62}
63
64void TTdrCloverHit::Print(Option_t*) const
65{
66 // Prints the Detector Number, Crystal Number, Energy, Time and Angle.
67 Print(std::cout);
68}
69
70void TTdrCloverHit::Print(std::ostream& out) const
71{
72 std::ostringstream str;
73 str << "TdrClover Detector: " << GetDetector() << std::endl;
74 str << "TdrClover Crystal: " << GetCrystal() << std::endl;
75 str << "TdrClover Energy: " << GetEnergy() << std::endl;
76 str << "TdrClover hit time: " << GetTime() << std::endl;
77 str << "TdrClover hit TV3 theta: " << GetPosition().Theta() * 180. / 3.141597 << "\tphi" << GetPosition().Phi() * 180. / 3.141597 << std::endl;
78 out << str.str();
79}
80
81TVector3 TTdrCloverHit::GetPosition(double dist) const
82{
84}
85
87{
89}
90
92{
93 return (lhs->GetEnergy() > rhs->GetEnergy());
94}
95
97{
98 // add another TDR clover hit to this one (for addback),
99 // using the time and position information of the one with the higher energy
100 const TTdrCloverHit* cloverHit = dynamic_cast<const TTdrCloverHit*>(hit);
101 if(cloverHit == nullptr) {
102 throw std::runtime_error("trying to add non-clover hit to clover hit!");
103 }
104
105 if(!CompareEnergy(this, cloverHit)) {
106 SetCfd(cloverHit->GetCfd());
107 SetTime(cloverHit->GetTime());
108 // SetPosition(cloverHit->GetPosition());
109 SetAddress(cloverHit->GetAddress());
110 } else {
111 SetTime(GetTime());
112 }
113 SetEnergy(GetEnergy() + cloverHit->GetEnergy());
114 // this has to be done at the very end, otherwise GetEnergy() might not work
115 SetCharge(0);
116 // Add all of the pileups.This should be changed when the max number of pileups changes
117 if((NPileUps() + cloverHit->NPileUps()) < 4) {
118 SetNPileUps(NPileUps() + cloverHit->NPileUps());
119 } else {
120 SetNPileUps(3);
121 }
122 if((PUHit() + cloverHit->PUHit()) < 4) {
123 SetPUHit(PUHit() + cloverHit->PUHit());
124 } else {
125 SetPUHit(3);
126 }
127 // KValue is somewhate meaningless in addback, so I am using it as an indicator that a piledup hit was added-back RD
128 if(GetKValue() > cloverHit->GetKValue()) {
129 SetKValue(cloverHit->GetKValue());
130 }
131}
132
134{
135 SetHitBit(static_cast<TDetectorHit::EBitFlag>(flag), set);
136}
137
139{
140 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
141 return static_cast<UShort_t>(TestHitBit(static_cast<TDetectorHit::EBitFlag>(ETdrCloverHitBits::kTotalPU1)) +
143}
144
145UShort_t TTdrCloverHit::PUHit() const
146{
147 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
148 return static_cast<UShort_t>(TestHitBit(static_cast<TDetectorHit::EBitFlag>(ETdrCloverHitBits::kPUHit1)) +
149 (TestHitBit(static_cast<TDetectorHit::EBitFlag>(ETdrCloverHitBits::kPUHit2)) >> static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kPUHitOffset)));
150}
151
152void TTdrCloverHit::SetNPileUps(UChar_t npileups)
153{
154 SetTdrCloverFlag(ETdrCloverHitBits::kTotalPU1, (npileups & static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kTotalPU1)) != 0);
155 SetTdrCloverFlag(ETdrCloverHitBits::kTotalPU2, (npileups & static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kTotalPU2)) != 0);
156}
157
158void TTdrCloverHit::SetPUHit(UChar_t puhit)
159{
160 if(puhit > 2) {
161 puhit = 3;
162 }
163 // The pluralized test bits returns the actual value of the fBits masked. Not just a bool.
164
165 SetTdrCloverFlag(ETdrCloverHitBits::kPUHit1, ((puhit << static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kPUHitOffset)) & static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kPUHit1)) != 0);
166 SetTdrCloverFlag(ETdrCloverHitBits::kPUHit2, ((puhit << static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kPUHitOffset)) & static_cast<std::underlying_type<ETdrCloverHitBits>::type>(ETdrCloverHitBits::kPUHit2)) != 0);
167}
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)
!
bool TestHitBit(EBitFlag flag) const
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 SetHitBit(EBitFlag, Bool_t set=true) const
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)
!