GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TTdrTigress.cxx
Go to the documentation of this file.
1#include "TTdrTigress.h"
2
3#include <sstream>
4#include <iostream>
5#include <iomanip>
6
7#include "TRandom.h"
8#include "TMath.h"
9#include "TInterpreter.h"
10#include "TMnemonic.h"
11
12#include "TGRSIOptions.h"
13
14////////////////////////////////////////////////////////////
15//
16// TTdrTigress
17//
18// The TTdrTigress class defines the observables and algorithms used
19// when analyzing GRIFFIN data. It includes detector positions,
20// add-back methods, etc.
21//
22////////////////////////////////////////////////////////////
23
24/// \cond CLASSIMP
26/// \endcond
27
29{
30 return ((one->GetDetector() == two->GetDetector()) &&
31 (std::fabs(one->GetTime() - two->GetTime()) < TGRSIOptions::AnalysisOptions()->AddbackWindow()));
32}
33
35
37{
38 // the tigress detector is the 4th detector after the three clovers
39 return ((4 == bgo->GetDetector()) &&
40 (std::fabs(clo->GetTime() - bgo->GetTime()) < TGRSIOptions::AnalysisOptions()->SuppressionWindow()) &&
42}
43
45
46bool TTdrTigress::fSetCoreWave = false;
47
48// This seems unnecessary, and why 17?;// they are static members, and need
49// to be defined outside the header
50// 17 is to have the detectors go from 1-16
51// plus we can use position zero
52// when the detector winds up back in
53// one of the stands like Alex used in the
54// gps run. pcb.
55// Initiallizes the HPGe Tigress positions as per the wiki
56// <https://www.triumf.info/wiki/tigwiki/index.php/HPGe_Coordinate_Table>
57// theta phi
58// theta phi
59// theta
60TVector3 TTdrTigress::gTigressPosition[17] = {
61 TVector3(TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Cos(TMath::DegToRad() * (0.0)),
62 TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Sin(TMath::DegToRad() * (0.0)),
63 TMath::Cos(TMath::DegToRad() * (0.0))),
64 // Downstream lampshade
65 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
66 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
67 TMath::Cos(TMath::DegToRad() * (45.0))),
68 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
69 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
70 TMath::Cos(TMath::DegToRad() * (45.0))),
71 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
72 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
73 TMath::Cos(TMath::DegToRad() * (45.0))),
74 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
75 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
76 TMath::Cos(TMath::DegToRad() * (45.0))),
77 // Corona
78 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (22.5)),
79 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (22.5)),
80 TMath::Cos(TMath::DegToRad() * (90.0))),
81 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
82 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
83 TMath::Cos(TMath::DegToRad() * (90.0))),
84 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (112.5)),
85 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (112.5)),
86 TMath::Cos(TMath::DegToRad() * (90.0))),
87 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
88 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
89 TMath::Cos(TMath::DegToRad() * (90.0))),
90 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (202.5)),
91 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (202.5)),
92 TMath::Cos(TMath::DegToRad() * (90.0))),
93 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
94 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
95 TMath::Cos(TMath::DegToRad() * (90.0))),
96 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (292.5)),
97 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (292.5)),
98 TMath::Cos(TMath::DegToRad() * (90.0))),
99 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
100 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
101 TMath::Cos(TMath::DegToRad() * (90.0))),
102 // Upstream lampshade
103 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
104 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
105 TMath::Cos(TMath::DegToRad() * (135.0))),
106 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
107 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
108 TMath::Cos(TMath::DegToRad() * (135.0))),
109 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
110 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
111 TMath::Cos(TMath::DegToRad() * (135.0))),
112 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
113 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
114 TMath::Cos(TMath::DegToRad() * (135.0)))};
115
116std::map<int, TSpline*> TTdrTigress::fEnergyResiduals;
117
119{
120// Default ctor. Ignores TObjectStreamer in ROOT < 6
121#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
122 Class()->IgnoreTObjectStreamer(kTRUE);
123#endif
124 Clear();
125}
126
128{
129// Copy ctor. Ignores TObjectStreamer in ROOT < 6
130#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
131 Class()->IgnoreTObjectStreamer(kTRUE);
132#endif
133 rhs.Copy(*this);
134}
135
136void TTdrTigress::Copy(TObject& rhs) const
137{
138 // Copy function.
140
141 static_cast<TTdrTigress&>(rhs).fAddbackHits = fAddbackHits;
142 static_cast<TTdrTigress&>(rhs).fAddbackFrags = fAddbackFrags;
143 static_cast<TTdrTigress&>(rhs).fSuppressedHits = fSuppressedHits;
146 static_cast<TTdrTigress&>(rhs).fSetCoreWave = fSetCoreWave;
147 static_cast<TTdrTigress&>(rhs).fCycleStart = fCycleStart;
148 static_cast<TTdrTigress&>(rhs).fTdrTigressBits = 0;
149}
150
152{
153 // Default Destructor
154}
155
156void TTdrTigress::Clear(Option_t* opt)
157{
158 // Clears the mother, and all of the hits
159 ClearStatus();
161 fAddbackHits.clear();
162 fAddbackFrags.clear();
163 fSuppressedHits.clear();
166 fCycleStart = 0;
167}
168
169void TTdrTigress::Print(Option_t*) const
170{
171 Print(std::cout);
172}
173
174void TTdrTigress::Print(std::ostream& out) const
175{
176 std::ostringstream str;
177 str<<"TdrTigress Contains: "<<std::endl;
178 str<<std::setw(6)<<GetMultiplicity()<<" hits"<<std::endl;
179
180 if(IsAddbackSet()) {
181 str<<std::setw(6)<<fAddbackHits.size()<<" addback hits"<<std::endl;
182 } else {
183 str<<std::setw(6)<<" "<<" Addback not set"<<std::endl;
184 }
185
186 if(IsSuppressedSet()) {
187 str<<std::setw(6)<<fSuppressedHits.size()<<" suppressed hits"<<std::endl;
188 } else {
189 str<<std::setw(6)<<" "<<" suppressed not set"<<std::endl;
190 }
191
193 str<<std::setw(6)<<fSuppressedAddbackHits.size()<<" suppressed addback hits"<<std::endl;
194 } else {
195 str<<std::setw(6)<<" "<<" suppressed Addback not set"<<std::endl;
196 }
197
198 str<<std::setw(6)<<fCycleStart<<" cycle start"<<std::endl;
199 out<<str.str();
200}
201
203{
204 rhs.Copy(*this);
205 return *this;
206}
207
208std::vector<TDetectorHit*>& TTdrTigress::GetAddbackVector()
209{
210 return fAddbackHits;
211}
212
213std::vector<UShort_t>& TTdrTigress::GetAddbackFragVector()
214{
215 return fAddbackFrags;
216}
217
222
223void TTdrTigress::SetAddback(const Bool_t flag) const
224{
226}
227
228std::vector<TDetectorHit*>& TTdrTigress::GetSuppressedVector()
229{
230 return fSuppressedHits;
231}
232
237
238void TTdrTigress::SetSuppressed(const Bool_t flag) const
239{
241}
242
243std::vector<TDetectorHit*>& TTdrTigress::GetSuppressedAddbackVector()
244{
246}
247
249{
251}
252
257
258void TTdrTigress::SetSuppressedAddback(const Bool_t flag) const
259{
261}
262
264{
265 // Automatically builds the addback hits using the fAddbackCriterion (if the size of the fAddbackHits vector is zero)
266 // and return the number of addback hits.
267 auto& hit_vec = GetHitVector();
268 auto& ab_vec = GetAddbackVector();
269 auto& frag_vec = GetAddbackFragVector();
270 if(hit_vec.empty()) {
271 return 0;
272 }
273 // if the addback has been reset, clear the addback hits
274 if(!IsAddbackSet()) {
275 ab_vec.clear();
276 frag_vec.clear();
277 }
278 if(ab_vec.empty()) {
279 CreateAddback(hit_vec, ab_vec, frag_vec);
280 SetAddback(true);
281 }
282
283 return ab_vec.size();
284}
285
287{
288 if(i < GetAddbackMultiplicity()) {
289 return GetAddbackVector().at(i);
290 }
291 std::cerr<<"Addback hits are out of range"<<std::endl;
292 throw grsi::exit_exception(1);
293 return nullptr;
294}
295
297{
298 // Automatically builds the suppressed hits using the fSuppressedCriterion (if the size of the fSuppressedHits vector is zero)
299 // and return the number of suppressed hits.
300 if(fHits.empty()) {
301 return 0;
302 }
303 // if the addback has been reset, clear the addback hits
304 if(!IsSuppressedSet()) {
305 fSuppressedHits.clear();
306 }
307 if(fSuppressedHits.empty()) {
309 SetSuppressed(true);
310 }
311
312 return fSuppressedHits.size();
313}
314
316{
317 try {
318 return GetSuppressedVector().at(i);
319 } catch(const std::out_of_range& oor) {
320 std::cerr<<ClassName()<<" Suppressed hits are out of range: "<<oor.what()<<std::endl;
321 if(!gInterpreter) {
322 throw grsi::exit_exception(1);
323 }
324 }
325 return nullptr;
326}
327
329{
330 // Automatically builds the addback hits using the fAddbackCriterion (if the size of the fSuppressedAddbackHits vector is zero)
331 // and return the number of addback hits.
332 auto& hit_vec = GetHitVector();
333 auto& ab_vec = GetSuppressedAddbackVector();
334 auto& frag_vec = GetSuppressedAddbackFragVector();
335 if(hit_vec.empty()) {
336 return 0;
337 }
338 // if the addback has been reset, clear the addback hits
340 ab_vec.clear();
341 frag_vec.clear();
342 }
343 if(ab_vec.empty()) {
344 CreateSuppressedAddback(bgo, hit_vec, ab_vec, frag_vec);
346 }
347
348 return ab_vec.size();
349}
350
352{
353 try {
354 return GetSuppressedAddbackVector().at(i);
355 } catch(const std::out_of_range& oor) {
356 std::cerr<<ClassName()<<" Suppressed addback hits are out of range: "<<oor.what()<<std::endl;
357 if(!gInterpreter) {
358 throw grsi::exit_exception(1);
359 }
360 }
361 return nullptr;
362}
363
364void TTdrTigress::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel* chan)
365{
366 // Builds the TdrTigress Hits directly from the TFragment. Basically, loops through the hits for an event and sets
367 // observables.
368 if(frag == nullptr || chan == nullptr) {
369 return;
370 }
371
372 auto hit = new TTdrTigressHit(*frag);
373 fHits.push_back(hit);
374}
375
376TVector3 TTdrTigress::GetPosition(int DetNbr, int CryNbr, double dist)
377{
378 // Gets the position vector for a crystal specified by CryNbr within Tigress DetNbr at a distance of dist mm away.
379 // This is calculated to the most likely interaction point within the crystal.
380 if(DetNbr > 16) {
381 return TVector3(0, 0, 1);
382 }
383
384 TVector3 temp_pos(gTigressPosition[DetNbr]);
385
386 // Interaction points may eventually be set externally. May make these members of each crystal, or pass from
387 // waveforms.
388 Double_t cp = 26.0; // Crystal Center Point mm.
389 Double_t id = 45.0; // 45.0; //Crystal interaction depth mm.
390 // Set Theta's of the center of each DETECTOR face
391 ////Define one Detector position
392 TVector3 shift;
393 switch(CryNbr) {
394 case 0: shift.SetXYZ(-cp, cp, id); break;
395 case 1: shift.SetXYZ(cp, cp, id); break;
396 case 2: shift.SetXYZ(cp, -cp, id); break;
397 case 3: shift.SetXYZ(-cp, -cp, id); break;
398 default: shift.SetXYZ(0, 0, 1); break;
399 };
400 shift.RotateY(temp_pos.Theta());
401 shift.RotateZ(temp_pos.Phi());
402
403 temp_pos.SetMag(dist);
404
405 return (temp_pos + shift);
406}
407
409{
410 fTdrTigressBits = 0;
411}
412
414{
415 SetAddback(false);
416 GetAddbackVector().clear();
417 GetAddbackFragVector().clear();
418}
419
420UShort_t TTdrTigress::GetNAddbackFrags(const size_t& idx)
421{
422 // Get the number of addback "fragments" contributing to the total addback hit
423 // with index idx.
424 if(idx < GetAddbackFragVector().size()) {
425 return GetAddbackFragVector().at(idx);
426 }
427 return 0;
428}
429
431{
432 SetSuppressed(false);
433 GetSuppressedVector().clear();
434}
435
442
444{
445 // Get the number of addback "fragments" contributing to the total addback hit
446 // with index idx.
447 if(idx < GetSuppressedAddbackFragVector().size()) {
448 return GetSuppressedAddbackFragVector().at(idx);
449 }
450 return 0;
451}
452
453void TTdrTigress::SetBitNumber(enum ETdrTigressBits bit, Bool_t set) const
454{
455 // Used to set the flags that are stored in TTdrTigress.
456 fTdrTigressBits.SetBit(bit, set);
457}
458
459const char* TTdrTigress::GetColorFromNumber(Int_t number)
460{
461 switch(number) {
462 case(0): return "B";
463 case(1): return "G";
464 case(2): return "R";
465 case(3): return "W";
466 };
467 return "X";
468}
ClassImp(THILMnemonic) void THILMnemonic
bool DefaultSuppression(TTdrTigressHit *clo, TBgoHit *bgo)
bool DefaultAddback(TTdrTigressHit *one, TTdrTigressHit *two)
double SuppressionWindow() const
double AddbackWindow() 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!
std::vector< TDetectorHit * > fHits
Definition TDetector.h:88
virtual Short_t GetMultiplicity() const
Definition TDetector.h:73
virtual const std::vector< TDetectorHit * > & GetHitVector() const
Definition TDetector.h:75
static TAnalysisOptions * AnalysisOptions()
void Clear(Option_t *opt="all") override
!
void Copy(TObject &) const override
!
void CreateAddback(const std::vector< T * > &hits, std::vector< T * > &addbacks, std::vector< UShort_t > &nofFragments)
Definition TSuppressed.h:38
void CreateSuppressed(const TBgo *bgo, const std::vector< T * > &hits, std::vector< T * > &suppressedHits)
Definition TSuppressed.h:69
void CreateSuppressedAddback(const TBgo *bgo, const std::vector< T * > &hits, std::vector< T * > &addbacks, std::vector< UShort_t > &nofFragments)
Definition TSuppressed.h:94
bool IsAddbackSet() const
void SetSuppressed(bool flag=true) const
TDetectorHit * GetSuppressedHit(const int &i)
TTdrTigress & operator=(const TTdrTigress &)
!
void ClearStatus() const
!
std::vector< TDetectorHit * > & GetSuppressedAddbackVector()
!
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
Int_t GetSuppressedMultiplicity(TBgo *)
void SetBitNumber(ETdrTigressBits bit, Bool_t set) const
bool IsSuppressedAddbackSet() const
std::vector< TDetectorHit * > fSuppressedHits
! Used to create suppressed hits on the fly
Definition TTdrTigress.h:97
Int_t GetAddbackMultiplicity()
static TVector3 GetPosition(int DetNbr, int CryNbr=5, double dist=110.0)
!
UShort_t GetNAddbackFrags(const size_t &idx)
long fCycleStart
! The start of the cycle
Definition TTdrTigress.h:92
static const char * GetColorFromNumber(Int_t number)
void Clear(Option_t *opt="all") override
!
void ResetSuppressedAddback()
std::vector< TDetectorHit * > & GetSuppressedVector()
!
Int_t GetSuppressedAddbackMultiplicity(TBgo *)
void ResetFlags() const
static std::function< bool(TTdrTigressHit *, TBgoHit *)> fSuppressionCriterion
Definition TTdrTigress.h:88
std::vector< UShort_t > fSuppressedAddbackFrags
! Number of crystals involved in creating in the suppressed addback hit
Definition TTdrTigress.h:99
TTransientBits< UChar_t > fTdrTigressBits
static bool fSetCoreWave
! Flag for Waveforms ON/OFF
Definition TTdrTigress.h:90
bool IsSuppressedSet() const
std::vector< TDetectorHit * > & GetAddbackVector()
!
void ResetAddback()
void SetAddback(bool flag=true) const
TDetectorHit * GetAddbackHit(const int &i)
void Print(Option_t *opt="") const override
!
Bool_t TestBitNumber(ETdrTigressBits bit) const
UShort_t GetNSuppressedAddbackFrags(const size_t &idx)
static std::function< bool(TTdrTigressHit *, TTdrTigressHit *)> fAddbackCriterion
Definition TTdrTigress.h:87
std::vector< UShort_t > & GetAddbackFragVector()
!
std::vector< TDetectorHit * > fSuppressedAddbackHits
! Used to create suppressed addback hits on the fly
Definition TTdrTigress.h:98
static std::map< int, TSpline * > fEnergyResiduals
!
void ResetSuppressed()
~TTdrTigress() override
void Copy(TObject &) const override
!
TDetectorHit * GetSuppressedAddbackHit(const int &i)
void SetSuppressedAddback(bool flag=true) const
std::vector< UShort_t > & GetSuppressedAddbackFragVector()
!
std::vector< UShort_t > fAddbackFrags
! Number of crystals involved in creating in the addback hit
Definition TTdrTigress.h:95
static TVector3 gTigressPosition[17]
! Position of each HPGe Tigress
Definition TTdrTigress.h:60
std::vector< TDetectorHit * > fAddbackHits
! Used to create addback hits on the fly
Definition TTdrTigress.h:94
void SetBit(T bit, Bool_t flag)