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);
296 static void DrawLevelEnergy(
bool val) { fDrawLevelEnergy = val; }
297 static void DrawLevelLabel(
bool val) { fDrawLevelLabel = val; }
298 static void DrawName(
bool val) { fDrawName = val; }
299 static void DrawBandLabel(
bool val) { fDrawBandLabel = val; }
300 static bool DrawLevelEnergy() {
return fDrawLevelEnergy; }
301 static bool DrawLevelLabel() {
return fDrawLevelLabel; }
302 static bool DrawName() {
return fDrawName; }
303 static bool DrawBandLabel() {
return fDrawBandLabel; }
305 TLevel* AddLevel(
double energy,
const std::string& bandName,
const std::string& label);
306 TLevel* AddLevel(
const double energy,
const char* bandName,
const char* label) {
return AddLevel(energy, std::string(bandName), std::string(label)); }
307 TLevel* GetLevel(
double energy);
308 TLevel* FindLevel(
double energy,
double energyUncertainty);
310 TGamma* FindGamma(
double energy,
double energyUncertainty = 0.);
311 std::vector<TGamma*> FindGammas(
double lowEnergy,
double highEnergy);
313 std::map<double, double> FeedingGammas(
double levelEnergy,
double factor = 1.);
314 std::map<double, double> DrainingGammas(
double levelEnergy,
double factor = 1.);
315 void ResetGammaMap() { fGammaMap.clear(); }
316 std::vector<std::tuple<double, std::vector<double>>> ParallelGammas(
double initialEnergy,
double finalEnergy,
double factor = 1.);
318 void MoveToBand(
const char* bandName, TLevel* level);
320 void UseGlobalGammaWidth(
const int val)
322 fGammaWidth =
static_cast<EGammaWidth
>(val);
325 void RadwareStyle(
const bool val)
330 void GammaDistance(
const double val)
332 fGammaDistance = val;
335 void BandGap(
const double val)
340 void LeftMargin(
const double val)
345 void RightMargin(
const double val)
350 void BottomMargin(
const double val)
355 void TopMargin(
const double val)
363 void Draw(Option_t* option =
"")
override;
365 void Print(Option_t* option =
"")
const override;
370 for(
auto& band : fBands) { band.Debug(val); }
374 bool ParseENSDF(
const std::string& filename);
375 void DrawAuxillaryLevel(
const double& energy,
const double& left,
const double& right);
376 void BuildGammaMap(
double levelEnergy);
379 static std::vector<TLevelScheme*> fLevelSchemes;
381 std::vector<TBand> fBands;
382 std::multimap<double, TLine> fAuxillaryLevels;
383 std::multimap<double, TGamma*> fGammaMap;
387 double fQValueUncertainty{0.};
388 double fNeutronSeparation{0.};
389 double fNeutronSeparationUncertainty{0.};
392 EGammaWidth fGammaWidth{EGammaWidth::kNoWidth};
393 bool fRadwareStyle{
true};
394 double fGammaDistance{50.};
395 double fBandGap{200.};
396 double fLeftMargin{-1.};
397 double fRightMargin{-1.};
398 double fBottomMargin{-1.};
399 double fTopMargin{-1.};
400 double fMinWidth{1.};
401 double fMaxWidth{10.};
404 static bool fDrawLevelEnergy;
405 static bool fDrawLevelLabel;
406 static bool fDrawName;
407 static bool fDrawBandLabel;
416 ClassDefOverride(TLevelScheme, 1)