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 auto& suppressedHits = static_cast<TLaBr&>(rhs).fSuppressedHits;
87 if(suppressedHits.size() > fSuppressedHits.size()) {
88 for(size_t i = fSuppressedHits.size(); i < suppressedHits.size(); ++i) {
89 delete suppressedHits[i];
90 }
91 suppressedHits.resize(fSuppressedHits.size());
92 } else if(suppressedHits.size() < fSuppressedHits.size()) {
93 // right-hand side has less hits, that means there is at least one we can use to determine the type
94 // we need to use IsA()->New() to make a new hit of whatever derived type this actually is
95 suppressedHits.resize(fSuppressedHits.size(), static_cast<TDetectorHit*>(fSuppressedHits[0]->IsA()->New()));
96 }
97 // we have now ensured that the size of the two vectors is the same, so we can copy the contents of the hits
98 for(size_t i = 0; i < fSuppressedHits.size(); ++i) {
99 fSuppressedHits[i]->Copy(*(suppressedHits[i]), true);
100 }
101 static_cast<TLaBr&>(rhs).fLaBrBits = 0;
102}
103
105{
106 rhs.Copy(*this);
107 return *this;
108}
109
110void TLaBr::Print(Option_t*) const
111{
112 /// Prints out TLaBr Multiplicity, currently does little.
113 Print(std::cout);
114}
115
116void TLaBr::Print(std::ostream& out) const
117{
118 std::ostringstream str;
119 str << GetMultiplicity() << " hits" << std::endl;
120 out << str.str();
121}
122
127
128void TLaBr::SetSuppressed(const bool flag)
129{
131}
132
134{
135 SetSuppressed(false);
136 for(auto& hit : fSuppressedHits) {
137 delete hit;
138 }
139 fSuppressedHits.clear();
140}
141
143{
144 /// Automatically builds the suppressed hits using the fSuppressionCriterion and returns the number of suppressed hits
145 if(NoHits()) {
146 return 0;
147 }
148 // if the suppressed has been reset, clear the suppressed hits
149 if(!IsSuppressed()) {
150 for(auto& hit : fSuppressedHits) {
151 delete hit;
152 }
153 fSuppressedHits.clear();
154 }
155 if(fSuppressedHits.empty()) {
157 SetSuppressed(true);
158 }
159
160 return fSuppressedHits.size();
161}
162
164{
165 try {
166 return static_cast<TLaBrHit*>(fSuppressedHits.at(i));
167 } catch(const std::out_of_range& oor) {
168 std::cerr << ClassName() << " is out of range: " << oor.what() << std::endl;
169 throw grsi::exit_exception(1);
170 }
171 return nullptr;
172}
173
174void TLaBr::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel*)
175{
176 auto* hit = new TLaBrHit(*frag); // Building is controlled in the constructor of the hit
177 AddHit(hit);
178}
bool DefaultLaBrSuppression(const TDetectorHit *hit, const TDetectorHit *bgoHit)
Definition TLaBr.cxx:8
double SuppressionWindow() const
double SuppressionEnergy() const
Definition TBgo.h:16
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:72
virtual Short_t GetMultiplicity() const
Definition TDetector.h:70
std::vector< TDetectorHit * > & Hits()
Definition TDetector.h:74
virtual void AddHit(TDetectorHit *hit)
Definition TDetector.h:60
static TAnalysisOptions * AnalysisOptions()
Definition TLaBr.h:28
void Print(Option_t *opt="") const override
!
Definition TLaBr.cxx:110
TLaBr & operator=(const TLaBr &)
!
Definition TLaBr.cxx:104
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:142
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:123
void SetSuppressed(bool flag)
Definition TLaBr.cxx:128
void Clear(Option_t *opt="") override
!
Definition TLaBr.cxx:70
TLaBrHit * GetSuppressedHit(const int &i)
!
Definition TLaBr.cxx:163
std::vector< TDetectorHit * > fSuppressedHits
Definition TLaBr.h:78
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Definition TLaBr.cxx:174
static std::function< bool(const TDetectorHit *, const TDetectorHit *)> fSuppressionCriterion
Definition TLaBr.h:76
~TLaBr() override
Definition TLaBr.cxx:56
void ResetSuppressed()
Definition TLaBr.cxx:133
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