9#include "TInterpreter.h"
58 TVector3(TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Cos(TMath::DegToRad() * (0.0)),
59 TMath::Sin(TMath::DegToRad() * (0.0)) * TMath::Sin(TMath::DegToRad() * (0.0)),
60 TMath::Cos(TMath::DegToRad() * (0.0))),
62 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
63 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
64 TMath::Cos(TMath::DegToRad() * (45.0))),
65 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
66 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
67 TMath::Cos(TMath::DegToRad() * (45.0))),
68 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
69 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
70 TMath::Cos(TMath::DegToRad() * (45.0))),
71 TVector3(TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
72 TMath::Sin(TMath::DegToRad() * (45.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
73 TMath::Cos(TMath::DegToRad() * (45.0))),
75 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (22.5)),
76 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (22.5)),
77 TMath::Cos(TMath::DegToRad() * (90.0))),
78 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
79 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
80 TMath::Cos(TMath::DegToRad() * (90.0))),
81 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (112.5)),
82 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (112.5)),
83 TMath::Cos(TMath::DegToRad() * (90.0))),
84 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
85 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
86 TMath::Cos(TMath::DegToRad() * (90.0))),
87 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (202.5)),
88 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (202.5)),
89 TMath::Cos(TMath::DegToRad() * (90.0))),
90 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
91 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
92 TMath::Cos(TMath::DegToRad() * (90.0))),
93 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (292.5)),
94 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (292.5)),
95 TMath::Cos(TMath::DegToRad() * (90.0))),
96 TVector3(TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
97 TMath::Sin(TMath::DegToRad() * (90.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
98 TMath::Cos(TMath::DegToRad() * (90.0))),
100 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (67.5)),
101 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (67.5)),
102 TMath::Cos(TMath::DegToRad() * (135.0))),
103 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (157.5)),
104 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (157.5)),
105 TMath::Cos(TMath::DegToRad() * (135.0))),
106 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (247.5)),
107 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (247.5)),
108 TMath::Cos(TMath::DegToRad() * (135.0))),
109 TVector3(TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Cos(TMath::DegToRad() * (337.5)),
110 TMath::Sin(TMath::DegToRad() * (135.0)) * TMath::Sin(TMath::DegToRad() * (337.5)),
111 TMath::Cos(TMath::DegToRad() * (135.0)))};
245 std::ostringstream str;
246 str <<
"Griffin Contains: " << std::endl;
249 for(
const auto& hit :
Hits()) {
261 str << std::setw(6) <<
fAddbackLowGainHits.size() <<
" Low gain addback hits" << std::endl;
263 str << std::setw(6) <<
" "
264 <<
" Low Gain Addback not set" << std::endl;
270 str << std::setw(6) <<
" "
271 <<
" High Gain Addback not set" << std::endl;
274 str << std::setw(6) <<
" "
277 str << std::setw(6) <<
fCycleStart <<
" cycle start" << std::endl;
292 std::cerr << static_cast<std::underlying_type<EGainBits>::type>(gain_type) <<
" is not a known gain type. Please use kLowGain or kHighGain" << std::endl;
397 }
catch(
const std::out_of_range& oor) {
398 std::cerr << ClassName() <<
" Hits are out of range: " << oor.what() << std::endl;
427 if(hit_vec.empty()) {
432 for(
auto& hit : ab_vec) {
443 return ab_vec.size();
461 std::cerr <<
"Addback hits are out of range" << std::endl;
471 if(frag ==
nullptr || chan ==
nullptr) {
475 if(mnemonic ==
nullptr) {
476 std::cerr <<
"Trying to add fragment to TGriffin w/o mnemonic in TChannel!" << std::endl;
481 std::cerr << __PRETTY_FUNCTION__ <<
": not a GRIFFIN detector: " <<
static_cast<std::underlying_type<TMnemonic::EMnemonic>::type
>(mnemonic->
SubSystem()) << std::endl;
496 std::cout <<
"output sensor " <<
static_cast<std::underlying_type<TMnemonic::EMnemonic>::type
>(mnemonic->
OutputSensor()) <<
", skipping it" << std::endl;
519 case 0: shift.SetXYZ(-cp, cp,
id);
break;
520 case 1: shift.SetXYZ(cp, cp,
id);
break;
521 case 2: shift.SetXYZ(cp, -cp,
id);
break;
522 case 3: shift.SetXYZ(-cp, -cp,
id);
break;
523 default: shift.SetXYZ(0, 0, 1);
break;
525 shift.RotateY(temp_pos.Theta());
526 shift.RotateZ(temp_pos.Phi());
528 temp_pos.SetMag(dist);
530 return (temp_pos + shift);
596 Bool_t time_constraint)
598 if((hit_to_correct ==
nullptr) || (other_hit ==
nullptr)) {
599 std::cerr <<
"One of the hits is invalid in TGriffin::CTCorrectedEnergy" << std::endl;
603 if(time_constraint) {
614 static std::array<bool, 256> been_warned = {
false};
615 double fixed_energy = hit_to_correct->
GetEnergy();
620 }
catch(
const std::out_of_range& oor) {
622 if(!been_warned[
id]) {
623 been_warned[id] =
true;
624 std::cerr <<
DRED <<
"Missing CT correction for Det: " << hit_to_correct->
GetDetector()
648 if(hit_vec.size() < 2) {
652 for(
auto& hit : hit_vec) {
656 for(
auto& one : hit_vec) {
657 for(
auto& two : hit_vec) {
797 }
catch(
const std::out_of_range& oor) {
798 std::cerr << ClassName() <<
" Suppressed hits are out of range: " << oor.what() << std::endl;
815 if(hit_vec.empty()) {
820 for(
auto& hit : sup_vec) {
825 if(sup_vec.empty()) {
830 return sup_vec.size();
858 }
catch(
const std::out_of_range& oor) {
859 std::cerr << ClassName() <<
" Suppressed addback hits are out of range: " << oor.what() << std::endl;
878 if(hit_vec.empty()) {
883 for(
auto& hit : ab_vec) {
894 return ab_vec.size();
920 }
catch(
const std::out_of_range& oor) {
921 std::cerr << ClassName() <<
" Suppressed addback frags are out of range: " << oor.what() << std::endl;
bool DefaultGriffinAddback(const TDetectorHit *one, const TDetectorHit *two)
bool DefaultGriffinSuppression(const TDetectorHit *hit, const TDetectorHit *bgoHit)
double SuppressionWindow() const
double AddbackWindow() const
double SuppressionEnergy() const
std::vector< double > GetCTCoeff() const
const TMnemonic * GetMnemonic() const
virtual double GetEnergy(Option_t *opt="") const
virtual Int_t GetCrystal() const
!
TChannel * GetChannel() 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
std::vector< TDetectorHit * > & Hits()
static TAnalysisOptions * AnalysisOptions()
Double_t GetNoCTEnergy(Option_t *opt="") const
void ResetHighGainAddback()
!
bool IsSuppressed(const EGainBits &gain_type) const
TGriffinHit * GetSuppressedHighGainHit(const int &i)
!
void ResetSuppressedAddback()
!
static const char * GetColorFromNumber(int number)
std::vector< TDetectorHit * > fSuppressedLowGainHits
! The set of suppressed crystal hits
Short_t GetSuppressedAddbackLowGainMultiplicity(const TBgo *bgo)
Short_t GetSuppressedHighGainMultiplicity(const TBgo *bgo)
std::vector< UShort_t > & GetAddbackFragVector(const EGainBits &gain_type)
!
UShort_t GetNHighGainSuppressedAddbackFrags(const size_t &idx)
void Clear(Option_t *opt="all") override
!
TGriffinHit * GetAddbackHit(const int &i)
Short_t GetAddbackMultiplicity()
static EGainBits fDefaultGainType
Short_t GetSuppressedAddbackHighGainMultiplicity(const TBgo *bgo)
void FixHighGainCrossTalk()
static std::function< bool(const TDetectorHit *, const TDetectorHit *)> fAddbackCriterion
Short_t GetAddbackLowGainMultiplicity()
void ResetHighGainSuppressed()
!
std::vector< TDetectorHit * > & GetSuppressedVector(const EGainBits &gain_type)
!
void Print(Option_t *opt="") const override
!
std::vector< UShort_t > fSuppressedAddbackLowGainFrags
! Number of crystals involved in creating in the suppressed addback hit
UShort_t GetNLowGainSuppressedAddbackFrags(const size_t &idx)
TDetectorHit * GetHit(const int &idx)
int64_t fCycleStart
! The start of the cycle
static std::array< TVector3, 17 > fCloverPosition
! Position of each HPGe Clover
static TVector3 GetPosition(int DetNbr, int CryNbr=5, double dist=110.0)
!
void ResetLowGainAddback()
!
TGriffinHit * GetAddbackHighGainHit(const int &i)
void ResetLowGainSuppressed()
!
TGriffinHit * GetGriffinLowGainHit(const int &i)
!
void ClearStatus() const
!
std::vector< TDetectorHit * > & GetSuppressedAddbackVector(const EGainBits &gain_type)
!
UShort_t GetNSuppressedAddbackFrags(const size_t &idx)
void FixLowGainCrossTalk()
UShort_t GetNLowGainAddbackFrags(const size_t &idx)
TGriffinHit * GetAddbackLowGainHit(const int &i)
void SetCrossTalk(const EGainBits &gain_type, bool flag=true) const
void FixCrossTalk(const EGainBits &gain_type)
std::vector< TDetectorHit * > fGriffinHighGainHits
UShort_t GetNAddbackFrags(const size_t &idx)
void SetSuppressed(const EGainBits &gain_type, bool flag=true) const
TGriffinHit * GetSuppressedAddbackHit(const int &i)
void ResetHighGainSuppressedAddback()
!
bool IsSuppressedAddbackSet(const EGainBits &gain_type) const
std::vector< UShort_t > fAddbackHighGainFrags
! Number of crystals involved in creating in the addback hit
bool IsAddbackSet(const EGainBits &gain_type) const
TGriffin & operator=(const TGriffin &)
!
std::vector< TDetectorHit * > fAddbackHighGainHits
! Used to create addback hits on the fly
TTransientBits< UChar_t > fGriffinBits
Short_t GetAddbackHighGainMultiplicity()
static std::function< bool(const TDetectorHit *, const TDetectorHit *)> fSuppressionCriterion
Short_t GetSuppressedMultiplicity(const TBgo *bgo)
Short_t GetSuppressedAddbackMultiplicity(const TBgo *bgo)
Short_t GetMultiplicity() const override
void SetSuppressedAddback(const EGainBits &gain_type, bool flag=true) const
TGriffinHit * GetSuppressedAddbackLowGainHit(const int &i)
Short_t GetSuppressedLowGainMultiplicity(const TBgo *bgo)
Short_t GetLowGainMultiplicity() const
std::vector< UShort_t > fSuppressedAddbackHighGainFrags
! Number of crystals involved in creating in the suppressed addback hit
std::vector< TDetectorHit * > fSuppressedAddbackLowGainHits
! Used to create suppressed addback hits on the fly
UShort_t GetNHighGainAddbackFrags(const size_t &idx)
Bool_t IsCrossTalkSet(const EGainBits &gain_type) const
@ kIsHighGainSuppressedAddbackSet
@ kIsHighGainCrossTalkSet
@ kIsLowGainSuppressedAddbackSet
TGriffinHit * GetSuppressedLowGainHit(const int &i)
!
void SetBitNumber(EGriffinBits bit, Bool_t set) const
std::vector< TDetectorHit * > & GetAddbackVector(const EGainBits &gain_type)
!
void AddFragment(const std::shared_ptr< const TFragment > &, TChannel *) override
!
std::vector< TDetectorHit * > fSuppressedAddbackHighGainHits
! Used to create suppressed addback hits on the fly
TGriffinHit * GetSuppressedHit(const int &i)
!
void SetAddback(const EGainBits &gain_type, bool flag=true) const
const std::vector< TDetectorHit * > & GetHitVector() const override
!
TGriffinHit * GetGriffinHit(const int &i)
!
std::vector< UShort_t > fAddbackLowGainFrags
! Number of crystals involved in creating in the addback hit
TGriffinHit * GetGriffinHighGainHit(const int &i)
!
std::vector< TDetectorHit * > fAddbackLowGainHits
! Used to create addback hits on the fly
static Double_t CTCorrectedEnergy(const TGriffinHit *hit_to_correct, const TGriffinHit *other_hit, bool time_constraint=true)
std::vector< TDetectorHit * > fSuppressedHighGainHits
! The set of suppressed crystal hits
static TVector3 GetDetectorPosition(int DetNbr)
!
Bool_t TestBitNumber(EGriffinBits bit) const
void ResetLowGainSuppressedAddback()
!
static bool fSetCoreWave
! Flag for Waveforms ON/OFF
void Copy(TObject &) const override
!
Short_t GetHighGainMultiplicity() const
static void SetDefaultGainType(const EGainBits &gain_type)
TGriffinHit * GetSuppressedAddbackHighGainHit(const int &i)
std::vector< UShort_t > & GetSuppressedAddbackFragVector(const EGainBits &gain_type)
!
virtual EMnemonic OutputSensor() const
virtual EMnemonic SubSystem() const
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)
void CreateSuppressed(const TBgo *bgo, const std::vector< T * > &hits, std::vector< T * > &suppressedHits)
void CreateSuppressedAddback(const TBgo *bgo, const std::vector< T * > &hits, std::vector< T * > &addbacks, std::vector< UShort_t > &nofFragments)
void SetBit(T bit, Bool_t flag)