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 // These positions should be updated (they are currently SCEPTAR-ish)
19 TVector3(0, 0, 1),
20 TVector3(14.3025, 4.6472, 22.8096),
21 TVector3(0, 15.0386, 22.8096),
22 TVector3(-14.3025, 4.6472, 22.8096),
23 TVector3(-8.8395, -12.1665, 22.8096),
24 TVector3(8.8395, -12.1665, 22.8096),
25 TVector3(19.7051, 6.4026, 6.2123),
26 TVector3(0, 20.7192, 6.2123),
27 TVector3(-19.7051, 6.4026, 6.2123),
28};
29
31{
32 // Default Constructor
33 Clear();
34}
35
37{
38 // Default Destructor
39 for(auto& hit : fSuppressedHits) {
40 delete hit;
41 }
42}
43
44TLaBr::TLaBr(const TLaBr& rhs) : TSuppressed(rhs)
45{
46 // Copy Contructor
47 rhs.Copy(*this);
48}
49
50void TLaBr::Clear(Option_t* opt)
51{
52 // Clears all of the hits
54 for(auto& hit : fSuppressedHits) {
55 delete hit;
56 }
57 fSuppressedHits.clear();
58 fLaBrBits = 0;
59}
60
61void TLaBr::Copy(TObject& rhs) const
62{
63 // Copies a TLaBr
65
66 static_cast<TLaBr&>(rhs).fSuppressedHits.resize(fSuppressedHits.size());
67 for(size_t i = 0; i < fSuppressedHits.size(); ++i) {
68 static_cast<TLaBr&>(rhs).fSuppressedHits[i] = new TLaBrHit(*static_cast<TLaBrHit*>(fSuppressedHits[i]));
69 }
70 static_cast<TLaBr&>(rhs).fLaBrBits = 0;
71}
72
74{
75 rhs.Copy(*this);
76 return *this;
77}
78
79void TLaBr::Print(Option_t*) const
80{
81 /// Prints out TLaBr Multiplicity, currently does little.
82 Print(std::cout);
83}
84
85void TLaBr::Print(std::ostream& out) const
86{
87 std::ostringstream str;
88 str << GetMultiplicity() << " hits" << std::endl;
89 out << str.str();
90}
91
96
97void TLaBr::SetSuppressed(const bool flag)
98{
100}
101
103{
104 SetSuppressed(false);
105 for(auto& hit : fSuppressedHits) {
106 delete hit;
107 }
108 fSuppressedHits.clear();
109}
110
112{
113 /// Automatically builds the suppressed hits using the fSuppressionCriterion and returns the number of suppressed hits
114 if(NoHits()) {
115 return 0;
116 }
117 // if the suppressed has been reset, clear the suppressed hits
118 if(!IsSuppressed()) {
119 for(auto& hit : fSuppressedHits) {
120 delete hit;
121 }
122 fSuppressedHits.clear();
123 }
124 if(fSuppressedHits.empty()) {
126 SetSuppressed(true);
127 }
128
129 return fSuppressedHits.size();
130}
131
133{
134 try {
135 return static_cast<TLaBrHit*>(fSuppressedHits.at(i));
136 } catch(const std::out_of_range& oor) {
137 std::cerr << ClassName() << " is out of range: " << oor.what() << std::endl;
138 throw grsi::exit_exception(1);
139 }
140 return nullptr;
141}
142
143void TLaBr::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel*)
144{
145 auto* hit = new TLaBrHit(*frag); // Building is controlled in the constructor of the hit
146 AddHit(hit);
147}
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:79
TLaBr & operator=(const TLaBr &)
!
Definition TLaBr.cxx:73
TTransientBits< UChar_t > fLaBrBits
Definition TLaBr.h:82
TLaBr()
Definition TLaBr.cxx:30
void SetBitNumber(const ELaBrBits bit, const bool set) const
Definition TLaBr.h:85
Short_t GetSuppressedMultiplicity(const TBgo *fBgo)
Definition TLaBr.cxx:111
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:61
bool IsSuppressed() const
Definition TLaBr.cxx:92
void SetSuppressed(bool flag)
Definition TLaBr.cxx:97
void Clear(Option_t *opt="") override
!
Definition TLaBr.cxx:50
TLaBrHit * GetSuppressedHit(const int &i)
!
Definition TLaBr.cxx:132
std::vector< TDetectorHit * > fSuppressedHits
Definition TLaBr.h:78
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Definition TLaBr.cxx:143
static std::function< bool(const TDetectorHit *, const TDetectorHit *)> fSuppressionCriterion
Definition TLaBr.h:76
~TLaBr() override
Definition TLaBr.cxx:36
void ResetSuppressed()
Definition TLaBr.cxx:102
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