4#if __cplusplus >= 201703L
13#include "TPaveLabel.h"
34class TGamma :
public TArrow {
36 explicit TGamma(TLevelScheme* levelScheme =
nullptr, std::string label =
"",
const double& br = 100.,
const double& ts = 1.);
37 TGamma(
const TGamma& rhs);
38 TGamma(TGamma&& rhs)
noexcept =
default;
39 TGamma& operator=(
const TGamma& rhs);
40 TGamma& operator=(TGamma&& rhs)
noexcept =
default;
44 void Energy(
const double val) { fEnergy = val; }
45 void EnergyUncertainty(
const double val) { fEnergyUncertainty = val; }
46 void UseTransitionStrength(
const bool val)
48 fUseTransitionStrength = val;
51 void Scaling(
const double offset,
const double gain)
53 fScalingOffset = offset;
57 void BranchingRatio(
const double val)
59 fBranchingRatio = val;
62 void BranchingRatioUncertainty(
const double val) { fBranchingRatioUncertainty = val; }
63 void BranchingRatioPercent(
const double val) { fBranchingRatioPercent = val; }
64 void BranchingRatioPercentUncertainty(
const double val) { fBranchingRatioPercentUncertainty = val; }
65 void TransitionStrength(
const double val)
67 fTransitionStrength = val;
70 void TransitionStrengthUncertainty(
const double val) { fTransitionStrengthUncertainty = val; }
71 void LabelText(
const char* val)
76 void InitialEnergy(
const double val) { fInitialEnergy = val; }
77 void FinalEnergy(
const double val) { fFinalEnergy = val; }
80 double Energy()
const {
return fEnergy; }
81 double EnergyUncertainty()
const {
return fEnergyUncertainty; }
82 bool UseTransitionStrength()
const {
return fUseTransitionStrength; }
83 double ScalingGain()
const {
return fScalingGain; }
84 double ScalingOffset()
const {
return fScalingOffset; }
85 double BranchingRatio()
const {
return fBranchingRatio; }
86 double BranchingRatioUncertainty()
const {
return fBranchingRatioUncertainty; }
87 double BranchingRatioPercent()
const {
return fBranchingRatioPercent; }
88 double BranchingRatioPercentUncertainty()
const {
return fBranchingRatioPercentUncertainty; }
89 double TransitionStrength()
const {
return fTransitionStrength; }
90 double TransitionStrengthUncertainty()
const {
return fTransitionStrengthUncertainty; }
91 double InitialEnergy()
const {
return fInitialEnergy; }
92 double FinalEnergy()
const {
return fFinalEnergy; }
93 double Width()
const {
return (fUseTransitionStrength ? fTransitionStrength : fBranchingRatio); }
94 std::string LabelText()
const {
return fLabelText; }
95 TLatex* Label()
const {
return fLabel; }
97 std::map<double, double> CoincidentGammas();
98 void PrintCoincidentGammas();
100 std::vector<std::tuple<double, std::vector<double>>> ParallelGammas();
101 void PrintParallelGammas();
103 void Print(Option_t* option =
"")
const override;
109 void Draw(
const double& x1,
const double& y1,
const double& x2,
const double& y2);
111 void Debug(
bool val) { fDebug = val; }
113 static void TextSize(
float val) { fTextSize = val; }
114 static float TextSize() {
return fTextSize; }
118 bool fUseTransitionStrength{
false};
120 double fEnergyUncertainty{0.};
121 double fScalingGain{1.};
122 double fScalingOffset{1.};
123 double fBranchingRatio{100.};
124 double fBranchingRatioUncertainty{0.};
125 double fBranchingRatioPercent{100.};
126 double fBranchingRatioPercentUncertainty{0.};
127 double fTransitionStrength{1.};
128 double fTransitionStrengthUncertainty{0.};
129 std::string fLabelText;
130 TLatex* fLabel{
nullptr};
131 TLevelScheme* fLevelScheme{
nullptr};
132 double fInitialEnergy{0.};
133 double fFinalEnergy{0.};
135 static float fTextSize;
138 ClassDefOverride(TGamma, 2)
142class TLevel :
public TPolyLine {
144 explicit TLevel(TLevelScheme* levelScheme =
nullptr,
const double& energy = -1.,
const std::string& label =
"");
145 TLevel(
const TLevel& rhs);
146 TLevel(TLevel&& rhs)
noexcept =
default;
147 TLevel& operator=(
const TLevel& rhs);
148 TLevel& operator=(TLevel&& rhs)
noexcept =
default;
151 TGamma* AddGamma(
double levelEnergy,
const char* label =
"",
double br = 100.,
double ts = 1.);
152 TGamma* AddGamma(
double levelEnergy,
double energyUncertainty,
const char* label =
"",
double br = 100.,
double ts = 1.);
154 void Energy(
const double val) { fEnergy = val; }
155 void EnergyUncertainty(
const double val) { fEnergyUncertainty = val; }
156 void Label(
const char* val) { fLabel = val; }
157 void AddFeeding() { ++fNofFeeding; }
158 void Offset(
const double& val) { fOffset = val; }
160 void MoveToBand(
const char* val);
162 double Energy()
const {
return fEnergy; }
163 double EnergyUncertainty()
const {
return fEnergyUncertainty; }
164 std::string Label()
const {
return fLabel; }
165 double Offset()
const {
return fOffset; }
167 std::pair<double, double> GetMinMaxGamma()
const;
168 size_t NofDrainingGammas()
const {
return fGammas.size(); }
169 size_t NofFeedingGammas()
const {
return fNofFeeding; }
171 using TPolyLine::Draw;
172 void Draw(
const double& left,
const double& right);
173 double DrawLabel(
const double& pos);
174 double DrawEnergy(
const double& pos);
176 std::map<double, TGamma>::iterator begin() {
return fGammas.begin(); }
177 std::map<double, TGamma>::iterator end() {
return fGammas.end(); }
178 std::map<double, TGamma>::const_iterator begin()
const {
return fGammas.begin(); }
179 std::map<double, TGamma>::const_iterator end()
const {
return fGammas.end(); }
182 friend bool operator<(
const TLevel& lhs,
const TLevel& rhs) {
return lhs.fEnergy < rhs.fEnergy; }
183 friend bool operator>(
const TLevel& lhs,
const TLevel& rhs) {
return rhs < lhs; }
184 friend bool operator<=(
const TLevel& lhs,
const TLevel& rhs) {
return !(rhs < lhs); }
185 friend bool operator>=(
const TLevel& lhs,
const TLevel& rhs) {
return !(lhs < rhs); }
187 friend bool operator<(
const TLevel& lhs,
const double& rhs) {
return lhs.fEnergy < rhs; }
188 friend bool operator>(
const TLevel& lhs,
const double& rhs) {
return rhs < lhs; }
189 friend bool operator<=(
const TLevel& lhs,
const double& rhs) {
return !(rhs < lhs); }
190 friend bool operator>=(
const TLevel& lhs,
const double& rhs) {
return !(lhs < rhs); }
192 friend bool operator<(
const double& lhs,
const TLevel& rhs) {
return lhs < rhs.fEnergy; }
193 friend bool operator>(
const double& lhs,
const TLevel& rhs) {
return rhs < lhs; }
194 friend bool operator<=(
const double& lhs,
const TLevel& rhs) {
return !(rhs < lhs); }
195 friend bool operator>=(
const double& lhs,
const TLevel& rhs) {
return !(lhs < rhs); }
197 void Print(Option_t* option =
"")
const override;
202 for(
auto& [level, gamma] : fGammas) { gamma.Debug(val); }
205 static void TextSize(
float val) { fTextSize = val; }
206 static float TextSize() {
return fTextSize; }
211 double fEnergyUncertainty{0.};
213 std::map<double, TGamma> fGammas;
214 size_t fNofFeeding{0};
215 TLevelScheme* fLevelScheme{
nullptr};
218 TLatex* fLevelLabel{
nullptr};
219 TLatex* fEnergyLabel{
nullptr};
223 static float fTextSize;
226 ClassDefOverride(TLevel, 1)
230class TBand :
public TPaveLabel {
232 explicit TBand(TLevelScheme* levelScheme =
nullptr,
const std::string& label =
"");
233 TBand(
const TBand& rhs);
234 TBand(TBand&& rhs)
noexcept =
default;
235 TBand& operator=(
const TBand& rhs);
236 TBand& operator=(TBand&& rhs)
noexcept =
default;
239 TLevel* AddLevel(
double energy,
const std::string& label);
240 TLevel* AddLevel(
const double energy,
const char* label)
242 std::string tmp(label);
243 return AddLevel(energy, tmp);
245 void AddLevel(TLevel* level);
246 void RemoveLevel(TLevel* level);
248 size_t NofLevels()
const {
return fLevels.size(); }
249 TLevel* GetLevel(
double energy);
250 TLevel* FindLevel(
double energy,
double energyUncertainty);
251 std::pair<double, double> GetMinMaxLevelEnergy()
const {
return std::make_pair(fLevels.begin()->second.Energy(), fLevels.rbegin()->second.Energy()); }
252 std::pair<double, double> GetMinMaxGamma()
const;
253 double Width(
double distance)
const;
255 std::map<double, TLevel>::iterator begin() {
return fLevels.begin(); }
256 std::map<double, TLevel>::iterator end() {
return fLevels.end(); }
257 std::map<double, TLevel>::const_iterator begin()
const {
return fLevels.begin(); }
258 std::map<double, TLevel>::const_iterator end()
const {
return fLevels.end(); }
260 void Print(Option_t* option =
"")
const override;
265 for(
auto& [energy, level] : fLevels) { level.Debug(val); }
270 std::map<double, TLevel> fLevels;
271 TLevelScheme* fLevelScheme{
nullptr};
274 ClassDefOverride(TBand, 1)
278class TLevelScheme :
public TPaveLabel {
280 enum class EGammaWidth :
char { kNoWidth,
284 explicit TLevelScheme(
const std::string& filename =
"",
bool debug =
false);
285 explicit TLevelScheme(
const char* filename,
bool debug =
false) : TLevelScheme(std::string(filename), debug) {}
286 TLevelScheme(
const TLevelScheme& rhs);
287 TLevelScheme(TLevelScheme&& rhs)
noexcept =
default;
288 TLevelScheme& operator=(
const TLevelScheme& rhs) =
default;
289 TLevelScheme& operator=(TLevelScheme&& rhs)
noexcept =
default;
290 ~TLevelScheme() =
default;
292 static void ListLevelSchemes();
293 static TLevelScheme* GetLevelScheme(
const char* name);
295 TLevel* AddLevel(
double energy,
const std::string& bandName,
const std::string& label);
296 TLevel* AddLevel(
const double energy,
const char* bandName,
const char* label) {
return AddLevel(energy, std::string(bandName), std::string(label)); }
297 TLevel* GetLevel(
double energy);
298 TLevel* FindLevel(
double energy,
double energyUncertainty);
300 TGamma* FindGamma(
double energy,
double energyUncertainty = 0.);
301 std::vector<TGamma*> FindGammas(
double lowEnergy,
double highEnergy);
303 std::map<double, double> FeedingGammas(
double levelEnergy,
double factor = 1.);
304 std::map<double, double> DrainingGammas(
double levelEnergy,
double factor = 1.);
305 void ResetGammaMap() { fGammaMap.clear(); }
306 std::vector<std::tuple<double, std::vector<double>>> ParallelGammas(
double initialEnergy,
double finalEnergy,
double factor = 1.);
308 void MoveToBand(
const char* bandName, TLevel* level);
310 void UseGlobalGammaWidth(
const int val)
312 fGammaWidth =
static_cast<EGammaWidth
>(val);
315 void RadwareStyle(
const bool val)
320 void GammaDistance(
const double val)
322 fGammaDistance = val;
325 void BandGap(
const double val)
330 void LeftMargin(
const double val)
335 void RightMargin(
const double val)
340 void BottomMargin(
const double val)
345 void TopMargin(
const double val)
353 void Draw(Option_t* option =
"")
override;
355 void Print(Option_t* option =
"")
const override;
360 for(
auto& band : fBands) { band.Debug(val); }
364 void ParseENSDF(
const std::string& filename);
365 void DrawAuxillaryLevel(
const double& energy,
const double& left,
const double& right);
366 void BuildGammaMap(
double levelEnergy);
369 static std::vector<TLevelScheme*> fLevelSchemes;
371 std::vector<TBand> fBands;
372 std::multimap<double, TLine> fAuxillaryLevels;
373 std::multimap<double, TGamma*> fGammaMap;
377 double fQValueUncertainty{0.};
378 double fNeutronSeparation{0.};
379 double fNeutronSeparationUncertainty{0.};
382 EGammaWidth fGammaWidth{EGammaWidth::kNoWidth};
383 bool fRadwareStyle{
true};
384 double fGammaDistance{50.};
385 double fBandGap{200.};
386 double fLeftMargin{-1.};
387 double fRightMargin{-1.};
388 double fBottomMargin{-1.};
389 double fTopMargin{-1.};
390 double fMinWidth{1.};
391 double fMaxWidth{10.};
400 ClassDefOverride(TLevelScheme, 1)