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