4#if __cplusplus >= 201703L
14#include "TPaveLabel.h"
35class TGamma :
public TArrow {
37 explicit TGamma(TLevelScheme* levelScheme =
nullptr, std::string label =
"",
const double& br = 100.,
const double& ts = 1.);
38 TGamma(
const TGamma& rhs);
39 TGamma(TGamma&& rhs)
noexcept =
default;
40 TGamma& operator=(
const TGamma& rhs);
41 TGamma& operator=(TGamma&& rhs)
noexcept =
default;
45 void Energy(
const double val) { fEnergy = val; }
46 void EnergyUncertainty(
const double val) { fEnergyUncertainty = val; }
47 void UseTransitionStrength(
const bool val)
49 fUseTransitionStrength = val;
52 void Scaling(
const double offset,
const double gain)
54 fScalingOffset = offset;
58 void BranchingRatio(
const double val)
60 fBranchingRatio = val;
63 void BranchingRatioUncertainty(
const double val) { fBranchingRatioUncertainty = val; }
64 void BranchingRatioPercent(
const double val) { fBranchingRatioPercent = val; }
65 void BranchingRatioPercentUncertainty(
const double val) { fBranchingRatioPercentUncertainty = val; }
66 void TransitionStrength(
const double val)
68 fTransitionStrength = val;
71 void TransitionStrengthUncertainty(
const double val) { fTransitionStrengthUncertainty = val; }
72 void LabelText(
const char* val)
77 void InitialEnergy(
const double val) { fInitialEnergy = val; }
78 void FinalEnergy(
const double val) { fFinalEnergy = val; }
81 double Energy()
const {
return fEnergy; }
82 double EnergyUncertainty()
const {
return fEnergyUncertainty; }
83 bool UseTransitionStrength()
const {
return fUseTransitionStrength; }
84 double ScalingGain()
const {
return fScalingGain; }
85 double ScalingOffset()
const {
return fScalingOffset; }
86 double BranchingRatio()
const {
return fBranchingRatio; }
87 double BranchingRatioUncertainty()
const {
return fBranchingRatioUncertainty; }
88 double BranchingRatioPercent()
const {
return fBranchingRatioPercent; }
89 double BranchingRatioPercentUncertainty()
const {
return fBranchingRatioPercentUncertainty; }
90 double TransitionStrength()
const {
return fTransitionStrength; }
91 double TransitionStrengthUncertainty()
const {
return fTransitionStrengthUncertainty; }
92 double InitialEnergy()
const {
return fInitialEnergy; }
93 double FinalEnergy()
const {
return fFinalEnergy; }
94 double Width()
const {
return (fUseTransitionStrength ? fTransitionStrength : fBranchingRatio); }
95 std::string LabelText()
const {
return fLabelText; }
96 TLatex* Label()
const {
return fLabel; }
98 std::map<double, double> CoincidentGammas();
99 void PrintCoincidentGammas();
101 std::vector<std::tuple<double, std::vector<double>>> ParallelGammas();
102 void PrintParallelGammas();
104 void Print(Option_t* option =
"")
const override;
110 void Draw(
const double& x1,
const double& y1,
const double& x2,
const double& y2);
112 void Debug(
bool val) { fDebug = val; }
114 static void TextSize(
float val) { fTextSize = val; }
115 static float TextSize() {
return fTextSize; }
119 bool fUseTransitionStrength{
false};
121 double fEnergyUncertainty{0.};
122 double fScalingGain{1.};
123 double fScalingOffset{1.};
124 double fBranchingRatio{100.};
125 double fBranchingRatioUncertainty{0.};
126 double fBranchingRatioPercent{100.};
127 double fBranchingRatioPercentUncertainty{0.};
128 double fTransitionStrength{1.};
129 double fTransitionStrengthUncertainty{0.};
130 std::string fLabelText;
131 TLatex* fLabel{
nullptr};
132 TLevelScheme* fLevelScheme{
nullptr};
133 double fInitialEnergy{0.};
134 double fFinalEnergy{0.};
136 static float fTextSize;
139 ClassDefOverride(TGamma, 1)
143class TLevel :
public TPolyLine {
145 explicit TLevel(TLevelScheme* levelScheme =
nullptr,
const double& energy = -1.,
const std::string& label =
"");
146 TLevel(
const TLevel& rhs);
147 TLevel(TLevel&& rhs)
noexcept =
default;
148 TLevel& operator=(
const TLevel& rhs);
149 TLevel& operator=(TLevel&& rhs)
noexcept =
default;
152 TGamma* AddGamma(
double levelEnergy,
const char* label =
"",
double br = 100.,
double ts = 1.);
153 TGamma* AddGamma(
double levelEnergy,
double energyUncertainty,
const char* label =
"",
double br = 100.,
double ts = 1.);
155 void Energy(
const double val) { fEnergy = val; }
156 void EnergyUncertainty(
const double val) { fEnergyUncertainty = val; }
157 void Label(
const char* val) { fLabel = val; }
158 void AddFeeding() { ++fNofFeeding; }
159 void Offset(
const double& val) { fOffset = val; }
161 void MoveToBand(
const char* val);
163 double Energy()
const {
return fEnergy; }
164 double EnergyUncertainty()
const {
return fEnergyUncertainty; }
165 std::string Label()
const {
return fLabel; }
166 double Offset()
const {
return fOffset; }
168 std::pair<double, double> GetMinMaxGamma()
const;
169 size_t NofDrainingGammas()
const {
return fGammas.size(); }
170 size_t NofFeedingGammas()
const {
return fNofFeeding; }
172 using TPolyLine::Draw;
173 void Draw(
const double& left,
const double& right);
174 double DrawLabel(
const double& pos);
175 double DrawEnergy(
const double& pos);
177 std::map<double, TGamma>::iterator begin() {
return fGammas.begin(); }
178 std::map<double, TGamma>::iterator end() {
return fGammas.end(); }
179 std::map<double, TGamma>::const_iterator begin()
const {
return fGammas.begin(); }
180 std::map<double, TGamma>::const_iterator end()
const {
return fGammas.end(); }
183 friend bool operator<(
const TLevel& lhs,
const TLevel& rhs) {
return lhs.fEnergy < rhs.fEnergy; }
184 friend bool operator>(
const TLevel& lhs,
const TLevel& rhs) {
return rhs < lhs; }
185 friend bool operator<=(
const TLevel& lhs,
const TLevel& rhs) {
return !(rhs < lhs); }
186 friend bool operator>=(
const TLevel& lhs,
const TLevel& rhs) {
return !(lhs < rhs); }
188 friend bool operator<(
const TLevel& lhs,
const double& rhs) {
return lhs.fEnergy < rhs; }
189 friend bool operator>(
const TLevel& lhs,
const double& rhs) {
return rhs < lhs; }
190 friend bool operator<=(
const TLevel& lhs,
const double& rhs) {
return !(rhs < lhs); }
191 friend bool operator>=(
const TLevel& lhs,
const double& rhs) {
return !(lhs < rhs); }
193 friend bool operator<(
const double& lhs,
const TLevel& rhs) {
return lhs < rhs.fEnergy; }
194 friend bool operator>(
const double& lhs,
const TLevel& rhs) {
return rhs < lhs; }
195 friend bool operator<=(
const double& lhs,
const TLevel& rhs) {
return !(rhs < lhs); }
196 friend bool operator>=(
const double& lhs,
const TLevel& rhs) {
return !(lhs < rhs); }
198 void Print(Option_t* option =
"")
const override;
203 for(
auto& [level, gamma] : fGammas) { gamma.Debug(val); }
206 static void TextSize(
float val) { fTextSize = val; }
207 static float TextSize() {
return fTextSize; }
212 double fEnergyUncertainty{0.};
214 std::map<double, TGamma> fGammas;
215 size_t fNofFeeding{0};
216 TLevelScheme* fLevelScheme{
nullptr};
219 TLatex* fLevelLabel{
nullptr};
220 TLatex* fEnergyLabel{
nullptr};
224 static float fTextSize;
227 ClassDefOverride(TLevel, 1)
231class TBand :
public TPaveLabel {
233 explicit TBand(TLevelScheme* levelScheme =
nullptr,
const std::string& label =
"");
234 TBand(
const TBand& rhs);
235 TBand(TBand&& rhs)
noexcept =
default;
236 TBand& operator=(
const TBand& rhs);
237 TBand& operator=(TBand&& rhs)
noexcept =
default;
240 TLevel* AddLevel(
double energy,
const std::string& label);
241 TLevel* AddLevel(
const double energy,
const char* label)
243 std::string tmp(label);
244 return AddLevel(energy, tmp);
246 void AddLevel(TLevel* level);
247 void RemoveLevel(TLevel* level);
249 size_t NofLevels()
const {
return fLevels.size(); }
250 TLevel* GetLevel(
double energy);
251 TLevel* FindLevel(
double energy,
double energyUncertainty);
252 std::pair<double, double> GetMinMaxLevelEnergy()
const {
return std::make_pair(fLevels.begin()->second.Energy(), fLevels.rbegin()->second.Energy()); }
253 std::pair<double, double> GetMinMaxGamma()
const;
254 double Width(
double distance)
const;
256 std::map<double, TLevel>::iterator begin() {
return fLevels.begin(); }
257 std::map<double, TLevel>::iterator end() {
return fLevels.end(); }
258 std::map<double, TLevel>::const_iterator begin()
const {
return fLevels.begin(); }
259 std::map<double, TLevel>::const_iterator end()
const {
return fLevels.end(); }
261 void Print(Option_t* option =
"")
const override;
266 for(
auto& [energy, level] : fLevels) { level.Debug(val); }
271 std::map<double, TLevel> fLevels;
272 TLevelScheme* fLevelScheme{
nullptr};
275 ClassDefOverride(TBand, 1)
279class TLevelScheme :
public TPaveLabel {
281 enum class EGammaWidth { kNoWidth,
285 explicit TLevelScheme(
const std::string& filename =
"",
bool debug =
false);
286 explicit TLevelScheme(
const char* filename,
bool debug =
false) : TLevelScheme(std::string(filename), debug) {}
287 TLevelScheme(
const TLevelScheme& rhs);
288 TLevelScheme(TLevelScheme&& rhs)
noexcept =
default;
289 TLevelScheme& operator=(
const TLevelScheme& rhs) =
default;
290 TLevelScheme& operator=(TLevelScheme&& rhs)
noexcept =
default;
291 ~TLevelScheme() =
default;
293 static void ListLevelSchemes();
294 static TLevelScheme* GetLevelScheme(
const char* name);
296 TLevel* AddLevel(
double energy,
const std::string& bandName,
const std::string& label);
297 TLevel* AddLevel(
const double energy,
const char* bandName,
const char* label) {
return AddLevel(energy, std::string(bandName), std::string(label)); }
298 TLevel* GetLevel(
double energy);
299 TLevel* FindLevel(
double energy,
double energyUncertainty);
301 TGamma* FindGamma(
double energy,
double energyUncertainty = 0.);
302 std::vector<TGamma*> FindGammas(
double lowEnergy,
double highEnergy);
304 std::map<double, double> FeedingGammas(
double levelEnergy,
double factor = 1.);
305 std::map<double, double> DrainingGammas(
double levelEnergy,
double factor = 1.);
306 void ResetGammaMap() { fGammaMap.clear(); }
307 std::vector<std::tuple<double, std::vector<double>>> ParallelGammas(
double initialEnergy,
double finalEnergy,
double factor = 1.);
309 void MoveToBand(
const char* bandName, TLevel* level);
311 void UseGlobalGammaWidth(
const int val)
313 fGammaWidth =
static_cast<EGammaWidth
>(val);
316 void RadwareStyle(
const bool val)
321 void GammaDistance(
const double val)
323 fGammaDistance = val;
326 void BandGap(
const double val)
331 void LeftMargin(
const double val)
336 void RightMargin(
const double val)
341 void BottomMargin(
const double val)
346 void TopMargin(
const double val)
354 void Draw(Option_t* option =
"")
override;
356 void Print(Option_t* option =
"")
const override;
361 for(
auto& band : fBands) { band.Debug(val); }
365 void ParseENSDF(
const std::string& filename);
366 void DrawAuxillaryLevel(
const double& energy,
const double& left,
const double& right);
367 void BuildGammaMap(
double levelEnergy);
370 static std::vector<TLevelScheme*> fLevelSchemes;
372 std::vector<TBand> fBands;
373 std::multimap<double, TLine> fAuxillaryLevels;
374 std::multimap<double, TGamma*> fGammaMap;
378 double fQValueUncertainty{0.};
379 double fNeutronSeparation{0.};
380 double fNeutronSeparationUncertainty{0.};
383 EGammaWidth fGammaWidth{EGammaWidth::kNoWidth};
384 bool fRadwareStyle{
true};
385 double fGammaDistance{50.};
386 double fBandGap{200.};
387 double fLeftMargin{-1.};
388 double fRightMargin{-1.};
389 double fBottomMargin{-1.};
390 double fTopMargin{-1.};
391 double fMinWidth{1.};
392 double fMaxWidth{10.};
401 ClassDefOverride(TLevelScheme, 1)