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
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 return ((clo->GetDetector() == bgo->GetDetector()) &&
39 (std::fabs(clo->GetTime() - bgo->GetTime()) < TGRSIOptions::AnalysisOptions()->SuppressionWindow()) &&
41}
42
44
45bool TTdrClover::fSetCoreWave = false;
46
47// This seems unnecessary, and why 17?;// they are static members, and need
48// to be defined outside the header
49// 17 is to have the detectors go from 1-16
50// plus we can use position zero
51// when the detector winds up back in
52// one of the stands like Alex used in the
53// gps run. pcb.
54// Initiallizes the HPGe Clover positions as per the wiki
55// <https://www.triumf.info/wiki/tigwiki/index.php/HPGe_Coordinate_Table>
56// theta phi
57// theta phi
58// theta
59TVector3 TTdrClover::gCloverPosition[17] = {
60 TVector3(TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Cos(TMath::DegToRad() * (0.0)),
61 TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Sin(TMath::DegToRad() * (0.0)),
62 TMath::Cos(TMath::DegToRad() * (0.0))),
63 // Downstream lampshade
64 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
65 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
66 TMath::Cos(TMath::DegToRad() * (45.0))),
67 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
68 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
69 TMath::Cos(TMath::DegToRad() * (45.0))),
70 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
71 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
72 TMath::Cos(TMath::DegToRad() * (45.0))),
73 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
74 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
75 TMath::Cos(TMath::DegToRad() * (45.0))),
76 // Corona
77 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (22.5)),
78 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (22.5)),
79 TMath::Cos(TMath::DegToRad() * (90.0))),
80 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
81 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
82 TMath::Cos(TMath::DegToRad() * (90.0))),
83 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (112.5)),
84 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (112.5)),
85 TMath::Cos(TMath::DegToRad() * (90.0))),
86 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
87 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
88 TMath::Cos(TMath::DegToRad() * (90.0))),
89 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (202.5)),
90 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (202.5)),
91 TMath::Cos(TMath::DegToRad() * (90.0))),
92 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
93 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
94 TMath::Cos(TMath::DegToRad() * (90.0))),
95 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (292.5)),
96 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (292.5)),
97 TMath::Cos(TMath::DegToRad() * (90.0))),
98 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
99 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
100 TMath::Cos(TMath::DegToRad() * (90.0))),
101 // Upstream lampshade
102 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
103 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
104 TMath::Cos(TMath::DegToRad() * (135.0))),
105 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
106 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
107 TMath::Cos(TMath::DegToRad() * (135.0))),
108 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
109 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
110 TMath::Cos(TMath::DegToRad() * (135.0))),
111 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
112 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
113 TMath::Cos(TMath::DegToRad() * (135.0)))};
114
115std::map<int, TSpline*> TTdrClover::fEnergyResiduals;
116
118{
119// Default ctor. Ignores TObjectStreamer in ROOT < 6
120#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
121 Class()->IgnoreTObjectStreamer(kTRUE);
122#endif
123 Clear();
124}
125
127{
128// Copy ctor. Ignores TObjectStreamer in ROOT < 6
129#if ROOT_VERSION_CODE < ROOT_VERSION(6,0,0)
130 Class()->IgnoreTObjectStreamer(kTRUE);
131#endif
132 rhs.Copy(*this);
133}
134
135void TTdrClover::Copy(TObject& rhs) const
136{
137 // Copy function.
139
140 static_cast<TTdrClover&>(rhs).fAddbackHits = fAddbackHits;
141 static_cast<TTdrClover&>(rhs).fAddbackFrags = fAddbackFrags;
142 static_cast<TTdrClover&>(rhs).fSuppressedHits = fSuppressedHits;
145 static_cast<TTdrClover&>(rhs).fSetCoreWave = fSetCoreWave;
146 static_cast<TTdrClover&>(rhs).fCycleStart = fCycleStart;
147 static_cast<TTdrClover&>(rhs).fTdrCloverBits = 0;
148}
149
151{
152 // Default Destructor
153}
154
155void TTdrClover::Clear(Option_t* opt)
156{
157 // Clears the mother, and all of the hits
158 ClearStatus();
160 // need to delete or change to unique_ptr!!!
161 fAddbackHits.clear();
162 fAddbackFrags.clear();
163 fSuppressedHits.clear();
166 fCycleStart = 0;
167}
168
169void TTdrClover::Print(Option_t*) const
170{
171 Print(std::cout);
172}
173
174void TTdrClover::Print(std::ostream& out) const
175{
176 std::ostringstream str;
177 str<<"TdrClover 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*>& TTdrClover::GetAddbackVector()
209{
210 return fAddbackHits;
211}
212
213std::vector<UShort_t>& TTdrClover::GetAddbackFragVector()
214{
215 return fAddbackFrags;
216}
217
222
223void TTdrClover::SetAddback(const Bool_t flag) const
224{
226}
227
228std::vector<TDetectorHit*>& TTdrClover::GetSuppressedVector()
229{
230 return fSuppressedHits;
231}
232
237
238void TTdrClover::SetSuppressed(const Bool_t flag) const
239{
241}
242
243std::vector<TDetectorHit*>& TTdrClover::GetSuppressedAddbackVector()
244{
246}
247
249{
251}
252
257
258void TTdrClover::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 returns 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 suppressed addback hits using the fAddbackCriterion and fSuppressionriterion
331 /// (if the size of the fSuppressedAddbackHits vector is zero)
332 /// and returns the number of suppressed addback hits.
333 auto& hit_vec = GetHitVector();
334 auto& ab_vec = GetSuppressedAddbackVector();
335 auto& frag_vec = GetSuppressedAddbackFragVector();
336 if(hit_vec.empty()) {
337 return 0;
338 }
339 // if the addback has been reset, clear the addback hits
341 ab_vec.clear();
342 frag_vec.clear();
343 }
344 if(ab_vec.empty()) {
345 CreateSuppressedAddback(bgo, hit_vec, ab_vec, frag_vec);
347 }
348
349 return ab_vec.size();
350}
351
353{
354 try {
355 return GetSuppressedAddbackVector().at(i);
356 } catch(const std::out_of_range& oor) {
357 std::cerr<<ClassName()<<" Suppressed addback hits are out of range: "<<oor.what()<<std::endl;
358 if(!gInterpreter) {
359 throw grsi::exit_exception(1);
360 }
361 }
362 return nullptr;
363}
364
365void TTdrClover::AddFragment(const std::shared_ptr<const TFragment>& frag, TChannel* chan)
366{
367 // Builds the TdrClover Hits directly from the TFragment. Basically, loops through the hits for an event and sets
368 // observables.
369 if(frag == nullptr || chan == nullptr) {
370 return;
371 }
372
373 auto hit = new TTdrCloverHit(*frag);
374 fHits.push_back(hit);
375}
376
377TVector3 TTdrClover::GetPosition(int DetNbr, int CryNbr, double dist)
378{
379 // Gets the position vector for a crystal specified by CryNbr within Clover DetNbr at a distance of dist mm away.
380 // This is calculated to the most likely interaction point within the crystal.
381 if(DetNbr > 16) {
382 return TVector3(0, 0, 1);
383 }
384
385 TVector3 temp_pos(gCloverPosition[DetNbr]);
386
387 // Interaction points may eventually be set externally. May make these members of each crystal, or pass from
388 // waveforms.
389 Double_t cp = 26.0; // Crystal Center Point mm.
390 Double_t id = 45.0; // 45.0; //Crystal interaction depth mm.
391 // Set Theta's of the center of each DETECTOR face
392 ////Define one Detector position
393 TVector3 shift;
394 switch(CryNbr) {
395 case 0: shift.SetXYZ(-cp, cp, id); break;
396 case 1: shift.SetXYZ(cp, cp, id); break;
397 case 2: shift.SetXYZ(cp, -cp, id); break;
398 case 3: shift.SetXYZ(-cp, -cp, id); break;
399 default: shift.SetXYZ(0, 0, 1); break;
400 };
401 shift.RotateY(temp_pos.Theta());
402 shift.RotateZ(temp_pos.Phi());
403
404 temp_pos.SetMag(dist);
405
406 return (temp_pos + shift);
407}
408
410{
411 fTdrCloverBits = 0;
412}
413
415{
416 SetAddback(false);
417 GetAddbackVector().clear();
418 GetAddbackFragVector().clear();
419}
420
421UShort_t TTdrClover::GetNAddbackFrags(const size_t& idx)
422{
423 // Get the number of addback "fragments" contributing to the total addback hit
424 // with index idx.
425 if(idx < GetAddbackFragVector().size()) {
426 return GetAddbackFragVector().at(idx);
427 }
428 return 0;
429}
430
432{
433 SetSuppressed(false);
434 GetSuppressedVector().clear();
435}
436
443
444UShort_t TTdrClover::GetNSuppressedAddbackFrags(const size_t& idx)
445{
446 // Get the number of addback "fragments" contributing to the total addback hit
447 // with index idx.
448 if(idx < GetSuppressedAddbackFragVector().size()) {
449 return GetSuppressedAddbackFragVector().at(idx);
450 }
451 return 0;
452}
453
454void TTdrClover::SetBitNumber(enum ETdrCloverBits bit, Bool_t set) const
455{
456 // Used to set the flags that are stored in TTdrClover.
457 fTdrCloverBits.SetBit(bit, set);
458 /* if(set)
459 fTdrCloverBits |= bit;
460 else
461 fTdrCloverBits &= (~bit);*/
462}
463
464const char* TTdrClover::GetColorFromNumber(Int_t number)
465{
466 switch(number) {
467 case(0): return "B";
468 case(1): return "G";
469 case(2): return "R";
470 case(3): return "W";
471 };
472 return "X";
473}
ClassImp(THILMnemonic) void THILMnemonic
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!
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
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:59
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)