GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TTdrClover.cxx
Go to the documentation of this file.
1#include "TTdrClover.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/// TTdrClover
17///
18/// The TTdrClover 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 return ((clo->GetDetector() == bgo->GetDetector()) &&
35 (std::fabs(clo->GetTime() - bgo->GetTime()) < TGRSIOptions::AnalysisOptions()->SuppressionWindow()) &&
37}
38
40
41bool TTdrClover::fSetCoreWave = false;
42
43// This seems unnecessary, and why 17?;// they are static members, and need
44// to be defined outside the header
45// 17 is to have the detectors go from 1-16
46// plus we can use position zero
47// when the detector winds up back in
48// one of the stands like Alex used in the
49// gps run. pcb.
50// Initiallizes the HPGe Clover positions as per the wiki
51// <https://www.triumf.info/wiki/tigwiki/index.php/HPGe_Coordinate_Table>
52// theta phi
53// theta phi
54// theta
55TVector3 TTdrClover::gCloverPosition[17] = {
56 TVector3(TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Cos(TMath::DegToRad() * (0.0)),
57 TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Sin(TMath::DegToRad() * (0.0)),
58 TMath::Cos(TMath::DegToRad() * (0.0))),
59 // Downstream lampshade
60 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
61 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
62 TMath::Cos(TMath::DegToRad() * (45.0))),
63 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
64 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
65 TMath::Cos(TMath::DegToRad() * (45.0))),
66 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
67 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
68 TMath::Cos(TMath::DegToRad() * (45.0))),
69 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
70 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
71 TMath::Cos(TMath::DegToRad() * (45.0))),
72 // Corona
73 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (22.5)),
74 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (22.5)),
75 TMath::Cos(TMath::DegToRad() * (90.0))),
76 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
77 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
78 TMath::Cos(TMath::DegToRad() * (90.0))),
79 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (112.5)),
80 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (112.5)),
81 TMath::Cos(TMath::DegToRad() * (90.0))),
82 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
83 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
84 TMath::Cos(TMath::DegToRad() * (90.0))),
85 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (202.5)),
86 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (202.5)),
87 TMath::Cos(TMath::DegToRad() * (90.0))),
88 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
89 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
90 TMath::Cos(TMath::DegToRad() * (90.0))),
91 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (292.5)),
92 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (292.5)),
93 TMath::Cos(TMath::DegToRad() * (90.0))),
94 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
95 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
96 TMath::Cos(TMath::DegToRad() * (90.0))),
97 // Upstream lampshade
98 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
99 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
100 TMath::Cos(TMath::DegToRad() * (135.0))),
101 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
102 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
103 TMath::Cos(TMath::DegToRad() * (135.0))),
104 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
105 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
106 TMath::Cos(TMath::DegToRad() * (135.0))),
107 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
108 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
109 TMath::Cos(TMath::DegToRad() * (135.0)))};
110
111std::map<int, TSpline*> TTdrClover::fEnergyResiduals;
112
114{
115// Default ctor. Ignores TObjectStreamer in ROOT < 6
116#if ROOT_VERSION_CODE < ROOT_VERSION(6, 0, 0)
117 Class()->IgnoreTObjectStreamer(kTRUE);
118#endif
119 Clear();
120}
121
123{
124// Copy ctor. Ignores TObjectStreamer in ROOT < 6
125#if ROOT_VERSION_CODE < ROOT_VERSION(6, 0, 0)
126 Class()->IgnoreTObjectStreamer(kTRUE);
127#endif
128 rhs.Copy(*this);
129}
130
131void TTdrClover::Copy(TObject& rhs) const
132{
133 // Copy function.
135
136 static_cast<TTdrClover&>(rhs).fAddbackHits = fAddbackHits;
137 static_cast<TTdrClover&>(rhs).fAddbackFrags = fAddbackFrags;
138 static_cast<TTdrClover&>(rhs).fSuppressedHits = fSuppressedHits;
141 static_cast<TTdrClover&>(rhs).fSetCoreWave = fSetCoreWave;
142 static_cast<TTdrClover&>(rhs).fCycleStart = fCycleStart;
143 static_cast<TTdrClover&>(rhs).fTdrCloverBits = 0;
144}
145
147{
148 // Default Destructor
149}
150
151void TTdrClover::Clear(Option_t* opt)
152{
153 // Clears the mother, and all of the hits
154 ClearStatus();
156 // need to delete or change to unique_ptr!!!
157 fAddbackHits.clear();
158 fAddbackFrags.clear();
159 fSuppressedHits.clear();
162 fCycleStart = 0;
163}
164
165void TTdrClover::Print(Option_t*) const
166{
167 Print(std::cout);
168}
169
170void TTdrClover::Print(std::ostream& out) const
171{
172 std::ostringstream str;
173 str << "TdrClover 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*>& TTdrClover::GetAddbackVector()
208{
209 return fAddbackHits;
210}
211
212std::vector<UShort_t>& TTdrClover::GetAddbackFragVector()
213{
214 return fAddbackFrags;
215}
216
221
222void TTdrClover::SetAddback(const Bool_t flag) const
223{
225}
226
227std::vector<TDetectorHit*>& TTdrClover::GetSuppressedVector()
228{
229 return fSuppressedHits;
230}
231
236
237void TTdrClover::SetSuppressed(const Bool_t flag) const
238{
240}
241
242std::vector<TDetectorHit*>& TTdrClover::GetSuppressedAddbackVector()
243{
245}
246
248{
250}
251
256
257void TTdrClover::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 returns 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 suppressed addback hits using the fAddbackCriterion and fSuppressionriterion
330 /// (if the size of the fSuppressedAddbackHits vector is zero)
331 /// and returns the number of suppressed 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 TTdrClover::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel* chan)
365{
366 // Builds the TdrClover 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 TTdrCloverHit(*frag);
373 Hits().push_back(hit);
374}
375
376TVector3 TTdrClover::GetPosition(int DetNbr, int CryNbr, double dist)
377{
378 // Gets the position vector for a crystal specified by CryNbr within Clover 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(gCloverPosition[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 fTdrCloverBits = 0;
411}
412
414{
415 SetAddback(false);
416 GetAddbackVector().clear();
417 GetAddbackFragVector().clear();
418}
419
420UShort_t TTdrClover::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
443UShort_t TTdrClover::GetNSuppressedAddbackFrags(const size_t& idx)
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 TTdrClover::SetBitNumber(enum ETdrCloverBits bit, Bool_t set) const
454{
455 // Used to set the flags that are stored in TTdrClover.
456 fTdrCloverBits.SetBit(bit, set);
457 /* if(set)
458 fTdrCloverBits |= bit;
459 else
460 fTdrCloverBits &= (~bit);*/
461}
462
463const char* TTdrClover::GetColorFromNumber(Int_t number)
464{
465 switch(number) {
466 case(0): return "B";
467 case(1): return "G";
468 case(2): return "R";
469 case(3): return "W";
470 };
471 return "X";
472}
bool DefaultSuppression(TTdrCloverHit *clo, TBgoHit *bgo)
bool DefaultAddback(TTdrCloverHit *one, TTdrCloverHit *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
UShort_t GetNAddbackFrags(const size_t &idx)
void Clear(Option_t *opt="all") override
!
Int_t GetAddbackMultiplicity()
std::vector< UShort_t > fAddbackFrags
! Number of crystals involved in creating in the addback hit
Definition TTdrClover.h:96
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
static bool fSetCoreWave
! Flag for Waveforms ON/OFF
Definition TTdrClover.h:90
void Copy(TObject &) const override
!
std::vector< UShort_t > & GetAddbackFragVector()
!
std::vector< UShort_t > fSuppressedAddbackFrags
! Number of crystals involved in creating in the suppressed addback hit
Definition TTdrClover.h:100
void ClearStatus() const
!
Definition TTdrClover.h:106
UShort_t GetNSuppressedAddbackFrags(const size_t &idx)
std::vector< TDetectorHit * > & GetAddbackVector()
!
static std::function< bool(TTdrCloverHit *, TBgoHit *)> fSuppressionCriterion
Definition TTdrClover.h:88
Bool_t TestBitNumber(ETdrCloverBits bit) const
Definition TTdrClover.h:108
void SetSuppressed(bool flag=true) const
void ResetFlags() const
bool IsSuppressedSet() const
void SetAddback(bool flag=true) const
std::vector< TDetectorHit * > fAddbackHits
! Used to create addback hits on the fly
Definition TTdrClover.h:95
~TTdrClover() override
TTransientBits< UChar_t > fTdrCloverBits
Definition TTdrClover.h:93
std::vector< TDetectorHit * > fSuppressedAddbackHits
! Used to create suppressed addback hits on the fly
Definition TTdrClover.h:99
bool IsSuppressedAddbackSet() const
static std::map< int, TSpline * > fEnergyResiduals
!
Definition TTdrClover.h:110
std::vector< UShort_t > & GetSuppressedAddbackFragVector()
!
Int_t GetSuppressedMultiplicity(TBgo *)
TTdrClover & operator=(const TTdrClover &)
!
void ResetAddback()
static TVector3 gCloverPosition[17]
! Position of each HPGe Clover
Definition TTdrClover.h:55
long fCycleStart
! The start of the cycle
Definition TTdrClover.h:92
void ResetSuppressed()
static const char * GetColorFromNumber(Int_t number)
static TVector3 GetPosition(int DetNbr, int CryNbr=5, double dist=110.0)
!
std::vector< TDetectorHit * > & GetSuppressedAddbackVector()
!
TDetectorHit * GetAddbackHit(const int &i)
std::vector< TDetectorHit * > fSuppressedHits
! Used to create suppressed hits on the fly
Definition TTdrClover.h:98
TDetectorHit * GetSuppressedHit(const int &i)
void SetBitNumber(ETdrCloverBits bit, Bool_t set) const
std::vector< TDetectorHit * > & GetSuppressedVector()
!
void ResetSuppressedAddback()
bool IsAddbackSet() const
static std::function< bool(TTdrCloverHit *, TTdrCloverHit *)> fAddbackCriterion
Definition TTdrClover.h:87
void Print(Option_t *opt="") const override
!
TDetectorHit * GetSuppressedAddbackHit(const int &i)
void SetSuppressedAddback(bool flag=true) const
Int_t GetSuppressedAddbackMultiplicity(TBgo *)
void SetBit(T bit, Bool_t flag)