GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TLaBr.cxx
Go to the documentation of this file.
1#include <iostream>
2#include "TLaBr.h"
3#include <TRandom.h>
4#include <TMath.h>
5
6#include "TGRSIOptions.h"
7
8bool DefaultLaBrSuppression(const TDetectorHit* hit, const TDetectorHit* bgoHit)
9{
10 return ((hit->GetDetector() == bgoHit->GetDetector()) &&
11 (std::fabs(hit->GetTime() - bgoHit->GetTime()) < TGRSIOptions::AnalysisOptions()->SuppressionWindow()) &&
13}
14
16
17std::array<TVector3, 9> TLaBr::fPosition = {
18 // Ancillary detector locations from Evan.
19 TVector3(TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Cos(TMath::DegToRad() * (0.0)),
20 TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Sin(TMath::DegToRad() * (0.0)),
21 TMath::Cos(TMath::DegToRad() * (0.0))),
22 // Downstream detectors
23 TVector3(TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Cos(TMath::DegToRad() * (22.5)),
24 TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Sin(TMath::DegToRad() * (22.5)),
25 TMath::Cos(TMath::DegToRad() * (54.73561))),
26 TVector3(TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Cos(TMath::DegToRad() * (112.5)),
27 TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Sin(TMath::DegToRad() * (112.5)),
28 TMath::Cos(TMath::DegToRad() * (54.73561))),
29 TVector3(TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Cos(TMath::DegToRad() * (202.5)),
30 TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Sin(TMath::DegToRad() * (202.5)),
31 TMath::Cos(TMath::DegToRad() * (54.73561))),
32 TVector3(TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Cos(TMath::DegToRad() * (292.5)),
33 TMath::Sin(TMath::DegToRad() * (54.73561)) * TMath::Sin(TMath::DegToRad() * (292.5)),
34 TMath::Cos(TMath::DegToRad() * (54.73561))),
35
36 // Upstream detectors
37 TVector3(TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Cos(TMath::DegToRad() * (22.5)),
38 TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Sin(TMath::DegToRad() * (22.5)),
39 TMath::Cos(TMath::DegToRad() * (125.2644))),
40 TVector3(TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Cos(TMath::DegToRad() * (112.5)),
41 TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Sin(TMath::DegToRad() * (112.5)),
42 TMath::Cos(TMath::DegToRad() * (125.2644))),
43 TVector3(TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Cos(TMath::DegToRad() * (202.5)),
44 TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Sin(TMath::DegToRad() * (202.5)),
45 TMath::Cos(TMath::DegToRad() * (125.2644))),
46 TVector3(TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Cos(TMath::DegToRad() * (292.5)),
47 TMath::Sin(TMath::DegToRad() * (125.2644)) * TMath::Sin(TMath::DegToRad() * (292.5)),
48 TMath::Cos(TMath::DegToRad() * (125.2644)))};
49
51{
52 // Default Constructor
53 Clear();
54}
55
57{
58 // Default Destructor
59 for(auto& hit : fSuppressedHits) {
60 delete hit;
61 }
62}
63
64TLaBr::TLaBr(const TLaBr& rhs) : TSuppressed(rhs)
65{
66 // Copy Contructor
67 rhs.Copy(*this);
68}
69
70void TLaBr::Clear(Option_t* opt)
71{
72 // Clears all of the hits
74 for(auto& hit : fSuppressedHits) {
75 delete hit;
76 }
77 fSuppressedHits.clear();
78 fLaBrBits = 0;
79}
80
81void TLaBr::Copy(TObject& rhs) const
82{
83 // Copies a TLaBr
85
86 static_cast<TLaBr&>(rhs).fSuppressedHits.resize(fSuppressedHits.size());
87 for(size_t i = 0; i < fSuppressedHits.size(); ++i) {
88 static_cast<TLaBr&>(rhs).fSuppressedHits[i] = new TLaBrHit(*static_cast<TLaBrHit*>(fSuppressedHits[i]));
89 }
90 static_cast<TLaBr&>(rhs).fLaBrBits = 0;
91}
92
94{
95 rhs.Copy(*this);
96 return *this;
97}
98
99void TLaBr::Print(Option_t*) const
100{
101 /// Prints out TLaBr Multiplicity, currently does little.
102 Print(std::cout);
103}
104
105void TLaBr::Print(std::ostream& out) const
106{
107 std::ostringstream str;
108 str << GetMultiplicity() << " hits" << std::endl;
109 out << str.str();
110}
111
116
117void TLaBr::SetSuppressed(const bool flag)
118{
120}
121
123{
124 SetSuppressed(false);
125 for(auto& hit : fSuppressedHits) {
126 delete hit;
127 }
128 fSuppressedHits.clear();
129}
130
132{
133 /// Automatically builds the suppressed hits using the fSuppressionCriterion and returns the number of suppressed hits
134 if(NoHits()) {
135 return 0;
136 }
137 // if the suppressed has been reset, clear the suppressed hits
138 if(!IsSuppressed()) {
139 for(auto& hit : fSuppressedHits) {
140 delete hit;
141 }
142 fSuppressedHits.clear();
143 }
144 if(fSuppressedHits.empty()) {
146 SetSuppressed(true);
147 }
148
149 return fSuppressedHits.size();
150}
151
153{
154 try {
155 return static_cast<TLaBrHit*>(fSuppressedHits.at(i));
156 } catch(const std::out_of_range& oor) {
157 std::cerr << ClassName() << " is out of range: " << oor.what() << std::endl;
158 throw grsi::exit_exception(1);
159 }
160 return nullptr;
161}
162
163void TLaBr::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel*)
164{
165 auto* hit = new TLaBrHit(*frag); // Building is controlled in the constructor of the hit
166 AddHit(hit);
167}
bool DefaultLaBrSuppression(const TDetectorHit *hit, const TDetectorHit *bgoHit)
Definition TLaBr.cxx:8
double SuppressionWindow() const
double SuppressionEnergy() const
Definition TBgo.h:22
virtual double GetEnergy(Option_t *opt="") const
virtual Int_t GetDetector() const
!
virtual Double_t GetTime(const ETimeFlag &correct_flag=ETimeFlag::kAll, Option_t *opt="") const
Returns a time value to the nearest nanosecond!
virtual bool NoHits() const
Definition TDetector.h:76
virtual Short_t GetMultiplicity() const
Definition TDetector.h:73
std::vector< TDetectorHit * > & Hits()
Definition TDetector.h:78
virtual void AddHit(TDetectorHit *hit)
Definition TDetector.h:63
static TAnalysisOptions * AnalysisOptions()
Definition TLaBr.h:28
void Print(Option_t *opt="") const override
!
Definition TLaBr.cxx:99
TLaBr & operator=(const TLaBr &)
!
Definition TLaBr.cxx:93
TTransientBits< UChar_t > fLaBrBits
Definition TLaBr.h:82
TLaBr()
Definition TLaBr.cxx:50
void SetBitNumber(const ELaBrBits bit, const bool set) const
Definition TLaBr.h:85
Short_t GetSuppressedMultiplicity(const TBgo *fBgo)
Definition TLaBr.cxx:131
Bool_t TestBitNumber(const ELaBrBits bit) const
Definition TLaBr.h:86
static std::array< TVector3, 9 > fPosition
! Position of each detectir
Definition TLaBr.h:17
void Copy(TObject &rhs) const override
Definition TLaBr.cxx:81
bool IsSuppressed() const
Definition TLaBr.cxx:112
void SetSuppressed(bool flag)
Definition TLaBr.cxx:117
void Clear(Option_t *opt="") override
!
Definition TLaBr.cxx:70
TLaBrHit * GetSuppressedHit(const int &i)
!
Definition TLaBr.cxx:152
std::vector< TDetectorHit * > fSuppressedHits
Definition TLaBr.h:78
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Definition TLaBr.cxx:163
static std::function< bool(const TDetectorHit *, const TDetectorHit *)> fSuppressionCriterion
Definition TLaBr.h:76
~TLaBr() override
Definition TLaBr.cxx:56
void ResetSuppressed()
Definition TLaBr.cxx:122
void Clear(Option_t *opt="all") override
!
void Copy(TObject &) const override
!
void CreateSuppressed(const TBgo *bgo, const std::vector< T * > &hits, std::vector< T * > &suppressedHits)
Definition TSuppressed.h:69