CXLevelSchemePlayer.cpp 30 KB
Newer Older
Jérémie Dudouet's avatar
Jérémie Dudouet committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include "CXLevelSchemePlayer.h"

#include <iostream>
#include <iomanip>
#include <vector>

#include "TH1F.h"
#include "TArrow.h"
#include "TLatex.h"
#include "TPad.h"
#include "TGToolTip.h"
#include "TBox.h"
#include "TROOT.h"
#include "KeySymbols.h"
#include "TFile.h"
#include "TObjArray.h"
#include "TMath.h"
#include "TCutG.h"

#include "GammaLink.h"
#include "Link.h"
#include "NuclearLevel.h"
#include "Spin.h"
#include "Measure.h"
#include "LevelScheme.h"
#include "BaseLSPlayer.h"
#include "GLSPlayer.h"
28
#include "TSystemDirectory.h"
Jérémie Dudouet's avatar
Jérémie Dudouet committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53

#include "CXCanvas.h"
#include "CXMainWindow.h"
#include "CXGuiLSPlayer.h"

using namespace std;

typedef std::vector<Float_t> Float_vec_t;

CXLevelSchemePlayer::CXLevelSchemePlayer(const char* name, const char *title) :
    TNamed(name,title),
    fCanReplot(true)
{
    Color_t c[12] = {kBlue-6, kCyan-6, kGreen-6, kYellow-6 , kRed-6, kMagenta-6, kAzure, kTeal, kSpring, kOrange, kPink, kViolet};
    for(int i=0 ; i<48 ; i++) fColorWheel[i] = c[i%12] - (int)i/12;
    fCurrentColor = fColorWheel[0];

    fBashColor = new CXBashColor;

    fListOfDatabase = new TList;
    fListOfDatabase->SetOwner();

    fExpDataDir = Form("%s/DataBase/LevelScheme/EXP_DATA/",getenv("GWSYS"));
    fENSDFDataDir = Form("%s/DataBase/LevelScheme/ENSDF/",getenv("GWSYS"));

54 55 56 57
    gSystem->mkdir(fExpDataDir.Data(),kTRUE);
    gSystem->mkdir(fENSDFDataDir.Data(),kTRUE);

    TSystemDirectory dir(fENSDFDataDir,fENSDFDataDir);
58
    if(dir.GetListOfFiles() == nullptr || dir.GetListOfFiles()->GetEntries()<=2 ){
59
        TString temp = Form("%s/DataBase/LevelScheme/README",getenv("GWSYS"));
60
        fBashColor->InfoMessage(Form("No ENSDF data found in %s, follow the procedure explained in %s to download the data from the ENSDF web site",fENSDFDataDir.Data(),temp.Data()));
61 62
    }

63 64 65 66 67 68 69 70
    fListOfArrows = new TList;
    fListOfArrows->SetOwner();

    fListOfLatex = new TList;
    fListOfLatex->SetOwner();

    fListOfBoxes = new TList;
    fListOfBoxes->SetOwner();
71 72 73

    fListOfCXArrows = new TList;
    fListOfCXArrows->SetOwner();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
74 75 76 77 78 79 80 81 82
}

CXLevelSchemePlayer::~CXLevelSchemePlayer()
{
    delete fListOfDatabase;
}

void CXLevelSchemePlayer::ConnectCanvas()
{
Jérémie Dudouet's avatar
Jérémie Dudouet committed
83 84
    //    TList *l = fMainWindow->GetCanvas()->GetListOfSignals();
    //    if(l==nullptr || l->FindObject("ProcessedEventLevelScheme(int,int,int,TObject*)") == nullptr)
85
    fMainWindow->GetCanvas()->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)","CXLevelSchemePlayer", this, "ProcessedEventLevelScheme(Int_t, Int_t, Int_t, TObject*)");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
86 87
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
88 89 90 91
void CXLevelSchemePlayer::CleanArrows()
{
    gPad = fMainWindow->GetSelectedPad();

92 93
    if(gPad == nullptr) return;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
94 95 96 97 98 99 100 101 102 103 104 105 106
    for(int i=0 ; i<fListOfArrows->GetEntries() ; i++) {
        if(gPad->GetListOfPrimitives()->FindObject(fListOfArrows->At(i))) {
            gPad->GetListOfPrimitives()->Remove(fListOfArrows->At(i));
            fListOfArrows->RemoveAt(i);
            gPad->GetListOfPrimitives()->Remove(fListOfLatex->At(i));
            fListOfLatex->RemoveAt(i);
            gPad->GetListOfPrimitives()->Remove(fListOfBoxes->At(i));
            fListOfBoxes->RemoveAt(i);
            i--;
        }
    }
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
107
LevelScheme *CXLevelSchemePlayer::DrawArrows(TString ListOfNuclei,TH1 *h, TString DataSet)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
108
{
Jérémie Dudouet's avatar
Jérémie Dudouet committed
109 110
    LevelScheme *RefLevel = nullptr;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
    if(fMainWindow->GetCanvas() == nullptr)
        fBashColor->InfoMessage("Oops, current canvas not found...");

    gPad = fMainWindow->GetSelectedPad();

    ConnectCanvas();

    fCanReplot = false;

    fGuiLSPlayer->GetBranchingRatio(fMinStrenght,fMaxStrenght);
    fGuiLSPlayer->GetELevels(fMinELevel,fMaxELevel);
    fGuiLSPlayer->GetSpins(fMinSpin,fMaxSpin);
    fGuiLSPlayer->GetLifeTime(fMinLifeTime,fMaxLifeTime);

    fCurrentHist = h;

    fCurrentHist->GetYaxis()->UnZoom();

    gPad->Update();
    gPad->Modified();

    Int_t IColor = 0;

    fCurrentColor = fColorWheel[IColor];

    fLevelDraw = false;

    TObjArray *arr = ListOfNuclei.Tokenize(" ");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
139
    for(int i=0 ; i<arr->GetEntries() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
140 141 142 143 144
        TString Nuc = arr->At(i)->GetName();

        fCurrentColor = fColorWheel[IColor];
        IColor++;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
145 146
        LevelScheme *levtest = DrawArrowsForNuc(Nuc,DataSet);
        if(RefLevel == nullptr) RefLevel = levtest;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
147 148 149
    }
    delete arr;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
150
    if(fLevelDraw) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
151 152 153 154 155 156 157 158 159 160 161 162 163 164
        if(fGuiLSPlayer->IsFullTitleMode())
            fCurrentHist->SetMaximum(fCurrentHist->GetMaximum()*1.45);
        else
            fCurrentHist->SetMaximum(fCurrentHist->GetMaximum()*1.25);

        gPad->Update();
        gPad->Modified();

        Float_t YMax = 0;

        Float_t PadMax = gPad->GetUymax();
        if(gPad->GetLogy())
            PadMax = TMath::Power(10,gPad->GetUymax());

Jérémie Dudouet's avatar
Jérémie Dudouet committed
165 166
        while(YMax>PadMax || YMax==0) {
            for(int i=0 ; i<fListOfLatex->GetEntries() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
167
                TLatex *l = (TLatex*)fListOfLatex->At(i);
168
                if(gPad->GetListOfPrimitives()->FindObject(l) == nullptr) continue;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
169 170 171 172 173 174 175 176 177 178 179 180 181
                Float_t Y = l->GetY()-(gPad->AbsPixeltoY(l->GetBBox().fY+l->GetBBox().fWidth)-gPad->AbsPixeltoY(l->GetBBox().fY));
                if(Y>YMax)
                    YMax = Y;
            }

            if(YMax>0.) fCurrentHist->SetMaximum(YMax*1.01);

            gPad->Update();
            gPad->Modified();

            for(int i=0 ; i<fListOfLatex->GetEntries() ; i++)
            {
                TLatex *l = (TLatex*)fListOfLatex->At(i);
182
                if(gPad->GetListOfPrimitives()->FindObject(l) == nullptr) continue;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
                Float_t Y = l->GetY()-(gPad->AbsPixeltoY(l->GetBBox().fY+l->GetBBox().fWidth)-gPad->AbsPixeltoY(l->GetBBox().fY));
                if(Y>YMax)
                    YMax = Y;
            }

            PadMax = gPad->GetUymax();
            if(gPad->GetLogy())
                PadMax = TMath::Power(10,gPad->GetUymax());
        }

        if(YMax<fCurrentHist->GetBinContent(fCurrentHist->GetMaximumBin()))
            fCurrentHist->GetYaxis()->UnZoom();

        gPad->Update();
        gPad->Modified();
    }

    fCanReplot = true;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
201 202

    return RefLevel;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
203 204
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
205
LevelScheme *CXLevelSchemePlayer::DrawArrowsForNuc(TString NucName, TString DataSet)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
206
{
Jérémie Dudouet's avatar
Jérémie Dudouet committed
207 208
    LevelScheme *RefLevel = nullptr;

Jérémie Dudouet's avatar
Jérémie Dudouet committed
209
    CXNucleus nuc(NucName);
210
    if(nuc.IsKnown() == false) return nullptr;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
211 212

    ///ENSDF data
Jérémie Dudouet's avatar
Jérémie Dudouet committed
213 214 215 216 217 218
    if(fGuiLSPlayer->GetDataType()==1 || fGuiLSPlayer->GetDataType()==3) {
        LevelScheme *lev = (LevelScheme*)fListOfDatabase->FindObject(Form("%s_ENSDF_%s",NucName.Data(),DataSet.Data()));
        if(lev==nullptr) {
            lev = ImportENSDFData(nuc.GetSymbol(),false,DataSet);
            if(lev == nullptr) lev = new LevelScheme;
            lev->SetName(Form("%s_ENSDF_%s",NucName.Data(),DataSet.Data()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
219 220
            fListOfDatabase->Add(lev);
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
221
        if(lev != nullptr && lev->GetLinks().GetEntries()>0) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
222 223
            if(fGuiLSPlayer->GetYrastMode())
                CalcYrast(lev);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
224
            for(Int_t i=0 ; i<lev->GetLinks().GetSize() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
225 226 227 228
                const GammaLink *gamma=(GammaLink*)lev->GetLinks().At(i);
                DrawArrow(fCurrentHist,gamma,nuc,"ENSDF");
            }
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
229 230

        RefLevel = lev;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
231 232 233
    }

    ///Experimental data
Jérémie Dudouet's avatar
Jérémie Dudouet committed
234
    if(fGuiLSPlayer->GetDataType()==2 || fGuiLSPlayer->GetDataType()==3) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
235
        LevelScheme *lev = (LevelScheme*)fListOfDatabase->FindObject(Form("%s",NucName.Data()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
236
        if(lev != nullptr) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
237 238 239 240 241 242
            fListOfDatabase->Remove(lev);
            delete lev;
        }

        lev = ImportExpData(nuc.GetSymbol());

Jérémie Dudouet's avatar
Jérémie Dudouet committed
243
        if(lev != nullptr) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
244 245 246 247 248 249
            lev->SetName(Form("%s",NucName.Data()));
            fListOfDatabase->Add(lev);

            if(fGuiLSPlayer->GetYrastMode())
                CalcYrast(lev);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
250
            for(Int_t i=0 ; i<lev->GetLinks().GetSize() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
251 252 253 254
                const GammaLink *gamma=(GammaLink*)lev->GetLinks().At(i);
                DrawArrow(fCurrentHist,gamma,nuc,"EXP");
            }
        }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
255
        RefLevel = lev;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
256
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
257 258

    return RefLevel;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385
}

void CXLevelSchemePlayer::CalcYrast(LevelScheme *lev)
{
    fYrastEnergies.clear();

    for(Int_t i=0 ; i<lev->GetLinks().GetSize() ; i++)
    {
        const GammaLink *gamma=(GammaLink*)lev->GetLinks().At(i);

        Float_t ELev = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL())->GetEnergy().GetValue();
        Float_t spin = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL())->GetSpin().Get();

        if(fYrastEnergies[2*spin]==0 || ELev<fYrastEnergies[2*spin])
            if(spin>0)
                fYrastEnergies[2*spin] = ELev;
    }
}

void CXLevelSchemePlayer::DrawArrow(TH1 *hist, const GammaLink *gamma, CXNucleus Nuc, TString DataType)
{
    if(hist == nullptr)
        return;

    Float_t Energy = ((GammaLink*)gamma)->GetEnergy().GetValue();

    if(Energy < fCurrentHist->GetBinLowEdge(fCurrentHist->GetXaxis()->GetFirst()) || Energy > fCurrentHist->GetBinLowEdge(fCurrentHist->GetXaxis()->GetLast()))
        return;

    Float_t Strengh = ((GammaLink*)gamma)->GetStrength().GetValue();

    if( fGuiLSPlayer->UseBranchingRatio() && (Strengh<fMinStrenght || Strengh>fMaxStrenght))
        return;

    Float_t ELevI = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL())->GetEnergy().GetValue();
    Float_t ELevF = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetFL())->GetEnergy().GetValue();

    if(fGuiLSPlayer->UseELevels() && (ELevI<fMinELevel || ELevI>fMaxELevel))
        return;

    Float_t spinI = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL())->GetSpin().Get();
    Float_t spinF = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetFL())->GetSpin().Get();

    if(fGuiLSPlayer->UseSpins() && (spinI<fMinSpin || spinI>fMaxSpin))
        return;

    if(fGuiLSPlayer->GetYrastMode() && ELevI>fYrastEnergies[2*spinI])
        return;

    //    if(fGuiLSPlayer->GetYrastMode() && ELevF>fYrastEnergies[2*spinF])
    //        return;

    Float_t LifeTime = ((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL())->GetT().GetValue();

    if(fGuiLSPlayer->UseLifeTime() && (LifeTime<fMinLifeTime || LifeTime>fMaxLifeTime))
        return;

    Float_t MaxGlob = hist->GetMaximum();

    Int_t XMinbin = hist->GetXaxis()->GetFirst();
    Int_t XMaxbin = hist->GetXaxis()->GetLast();

    Int_t XMin = hist->GetBinLowEdge(XMinbin);
    Int_t XMax = hist->GetBinLowEdge(XMaxbin);

    hist->GetXaxis()->SetRangeUser(Energy-3,Energy+3);
    Float_t MaxLoc = hist->GetMaximum();
    hist->GetXaxis()->SetRange(XMinbin, XMaxbin);

    Int_t A = Nuc.GetA();

    TArrow *GammaArrow = new TArrow(Energy,(MaxLoc + MaxGlob/100.) ,Energy,(MaxLoc +MaxGlob/10.),0.005,"<|");

    GammaArrow->SetAngle(40);
    GammaArrow->SetLineColor(fCurrentColor);
    GammaArrow->SetFillColor(fCurrentColor);
    GammaArrow->SetLineWidth(1);

    if(DataType=="EXP")
    {
        GammaArrow->SetAngle(45);
        GammaArrow->SetArrowSize(0.02);
        GammaArrow->SetLineWidth(2);
    }
    else
    {
        GammaArrow->SetAngle(40);
        GammaArrow->SetArrowSize(0.01);
        GammaArrow->SetLineWidth(1);
    }
    GammaArrow->Draw();
    GammaArrow->SetBit(TObject::kCannotPick);

    fListOfArrows->Add(GammaArrow);

    TBox *box; box = new TBox();
    box->SetX1(Energy-(XMax-XMin)/300.);
    box->SetX2(Energy+(XMax-XMin)/300.);
    box->SetY1(MaxLoc +1.2*MaxGlob/10.);
    box->SetY2(MaxLoc +2.6*MaxGlob/10.);
    if(fGuiLSPlayer->IsFullTitleMode())
        box->SetY2(MaxLoc +4.0*MaxGlob/10.);
    box->SetFillStyle(0);
    box->SetFillColor(0);
    box->SetLineWidth(0);
    box->SetLineColor(0);
    box->SetLineStyle(3);

    TString GammaTitle=Form("^{%d}%s : %0.1f",A,Nuc.GetSymbol("EL").Data(),Energy);
    if(DataType=="EXP") GammaTitle.Append(" => Exp data");

    TString ToolTip;

    ToolTip.Append(Form("%s : %0.1f keV",Nuc.GetSymbol().Data(),Energy));

    ///Bug sur la multipolarite pour le moment
    //    TString Multipolority = ((GammaLink*)gamma)->GetAttr1();

    //    if(Multipolority != "") ToolTip.Append(Form(" %s",Multipolority.Data()));

    //    Float_t Mixing = ((GammaLink*)gamma)->GetMixing().GetValue();
    //    if(Multipolority != "" && Mixing!=0) ToolTip.Append(Form("(%.1f)",Mixing));

    ToolTip.Append(" ==> ");

    Bool_t AdvancedTitle = fGuiLSPlayer->IsFullTitleMode();

Jérémie Dudouet's avatar
Jérémie Dudouet committed
386
    TString SIL = GetSpinFromLev(((Gw::NuclearLevel*)((GammaLink*)gamma)->GetIL()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
387 388
    TString ILE = Form("%.1f",ELevI);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
389 390
    ToolTip.Append(Form("%s (%s keV)",SIL.Data(),ILE.Data()));
    if(AdvancedTitle) GammaTitle.Append(Form(" : %s",SIL.Data()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
391 392 393 394

    ToolTip.Append(" --> ");
    if(AdvancedTitle) GammaTitle.Append(" --> ");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
395
    TString SFL = GetSpinFromLev(((Gw::NuclearLevel*)((GammaLink*)gamma)->GetFL()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
396 397
    TString FLE = Form("%.1f",ELevF);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
398 399
    ToolTip.Append(Form("%s (%s keV)",SFL.Data(),FLE.Data()));
    if(AdvancedTitle) GammaTitle.Append(Form(" : %s",SFL.Data()));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
400 401 402

    ToolTip.Append(Form(" ; I=%.1f",((GammaLink*)gamma)->GetStrength().GetValue()));

Jérémie Dudouet's avatar
Jérémie Dudouet committed
403
    if(LifeTime != 0) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
        TString LifeTimeText;

        if(LifeTime<1e-12)
            LifeTimeText = Form(" ; T1/2 = %.1f fs",LifeTime*1e15);
        if(LifeTime>1e-12 && LifeTime<1e-9)
            LifeTimeText = Form(" ; T1/2 = %.1f ps",LifeTime*1e12);
        if(LifeTime>1e-9 && LifeTime<1e-6)
            LifeTimeText = Form(" ; T1/2 = %.1f ns",LifeTime*1e9);
        if(LifeTime>1e-6 && LifeTime<1e-3)
            LifeTimeText = Form(" ; T1/2 = %.1f us",LifeTime*1e6);
        if(LifeTime>1e-3 && LifeTime<1e-0)
            LifeTimeText = Form(" ; T1/2 = %.1f ms",LifeTime*1e3);
        if(LifeTime>1e-0)
            LifeTimeText = Form(" ; T1/2 = %.1f s",LifeTime);

        ToolTip.Append(LifeTimeText);
        if(AdvancedTitle) GammaTitle.Append(LifeTimeText);
    }

    if(DataType=="EXP") ToolTip.Append(" ==> Exp data");

    TLatex *Latex = new TLatex(Energy,MaxLoc +1.2*MaxGlob/10.,GammaTitle);
    Latex->SetTextAngle(90);
    if(DataType=="EXP")
    {
        Latex->SetTextFont(22);
        Latex->SetTextSize(fGuiLSPlayer->GetTextSize());
    }
    else
    {
        Latex->SetTextFont(132);
        Latex->SetTextSize(fGuiLSPlayer->GetTextSize());
    }
    Latex->SetTextColor(fCurrentColor);
    Latex->SetBit(TObject::kCannotPick);
    Latex->Draw();
    fListOfLatex->Add(Latex);

    box->SetToolTipText(ToolTip.Data(),500);
    box->Draw();
    fListOfBoxes->Add(box);

    fLevelDraw = true;
}

LevelScheme *CXLevelSchemePlayer::ImportExpData(const char *NucSymbol)
{
    CXNucleus nuc(NucSymbol);

    TString FileName = Form("%s/%s.root",fExpDataDir.Data(),nuc.GetSymbol().Data());

    if(!gSystem->IsFileInIncludePath(FileName))
    {
        fBashColor->WarningMessage(Form("Experimental level Scheme for Nucleus %s not found in %s/",nuc.GetSymbol().Data(),fExpDataDir.Data()));
        return nullptr;
    }
    else
    {
        TFile *FileOut = new TFile(FileName);

        LevelScheme *lev = (LevelScheme*)FileOut->Get(nuc.GetSymbol().Data());
        return lev;
    }
}

469
LevelScheme *CXLevelSchemePlayer::ImportENSDFData(const char *NucSymbol, bool quietmode,TString dataset, bool graphical)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
470 471 472 473 474 475
{
    TVirtualPad *tempPad = gPad;

    CXNucleus nuc(NucSymbol);
    TString ZMaj = ((TString)nuc.GetSymbol());
    ZMaj.ToUpper();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
476 477 478
    if(dataset == "") dataset = "ADOPTED LEVELS, GAMMAS";
    ZMaj.Append(Form(" %s",dataset.Data()));

479 480
    if(quietmode) ZMaj.Append("NoVerbose");
    if(!graphical) ZMaj.Append("NoGraphical");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
481 482 483

    TString FileName = fENSDFDataDir + "/" + ((TString)nuc.GetSymbol()) + ".ens";

Jérémie Dudouet's avatar
Jérémie Dudouet committed
484
    if(!gSystem->IsFileInIncludePath(FileName) && !quietmode) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
485 486 487
        fBashColor->WarningMessage(Form("ENSDF level Scheme for Nucleus %s not found in %s/",nuc.GetSymbol().Data(),fENSDFDataDir.Data()));
        return nullptr;
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
488
    else {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
489 490 491 492 493 494 495 496
        LevelScheme *lev =  new LevelScheme;
        TPad *p = new TPad();
        p->cd();
        lev->Import(FileName.Data(),ZMaj.Data());
        delete p;

        gPad = tempPad;

497 498 499
        //        if(lev->GetLinks().GetSize() == 0)
        //            return nullptr;
        //        else
Jérémie Dudouet's avatar
Jérémie Dudouet committed
500
        return lev;
Jérémie Dudouet's avatar
Jérémie Dudouet committed
501 502 503
    }
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
504 505 506 507 508 509
TString CXLevelSchemePlayer::PrintNucleusGammas(LevelScheme *lev, TString NucName, bool print)
{
    if(lev == nullptr) return "";

    TString Text="";

510 511 512 513 514 515 516 517 518 519
    if(print) {
        TString text = Form("** Gamma-rays transitions for nucleus %s **",NucName.Data());
        TString stars; for (int i=0 ; i<text.Length() ; i++) stars.Append("*");
        cout<<endl<<endl<<stars<<endl<<text<<endl<<stars<<endl<<endl;

        cout<<Form("    E Gamma :      Ji (    Ei    ) -->      Jf (     Ef   ) ( I %% )")<<endl;
        cout<<     "-------------------------------------------------------------------"<<endl;

        cout<<endl;
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537

    for(Int_t i=0 ; i<lev->GetLinks().GetSize() ; i++) {

        Gw::GammaLink *Link= (Gw::GammaLink*)lev->GetLinks().At(i);

        Float_t Energy = Link->GetEnergy().GetValue();

        NuclearLevel *NucLevI = (NuclearLevel*)Link->GetIL();
        NuclearLevel *NucLevF = (NuclearLevel*)Link->GetFL();

        Float_t Strengh = Link->GetStrength().GetValue();

        Float_t ELevI   = NucLevI->GetEnergy().GetValue();
        TString spinI_s = GetSpinFromLev(NucLevI);

        Float_t ELevF   = NucLevF->GetEnergy().GetValue();
        TString spinF_s = GetSpinFromLev(NucLevF);

538
        TString TransitionName = Form(" %6.1f keV : %7s (%6.1f keV) --> %7s (%6.1f keV) (%3.f %%) ",Energy,spinI_s.Data(),ELevI,spinF_s.Data(),ELevF,Strengh);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571

        if(print) cout<<TransitionName<<endl;
        Text += Form("!%-7g %-7s->%-7s",Energy,spinI_s.Data(),spinF_s.Data());

    }
    return Text;
}

TString CXLevelSchemePlayer::PrintNucleusGammas(Int_t Z, Int_t N, bool print)
{
    CXNucleus nuc(Z,Z+N);
    LevelScheme *lev = ImportENSDFData(nuc.GetSymbol());

    if(lev == nullptr) {
        cout<<Form("%s Level scheme not found",nuc.GetSymbol().Data())<<endl;
        return Form("%s Level scheme not found",nuc.GetSymbol().Data());
    }

    return PrintNucleusGammas(lev,nuc.GetSymbol(),print);
}

LevelScheme *CXLevelSchemePlayer::GetLevelScheme(TString Symb, bool print, TString dataset)
{
    LevelScheme *lev = ImportENSDFData(Symb,!print,dataset);
    return lev;
}

TString CXLevelSchemePlayer::PrintNucleusLevels(LevelScheme *lev, TString NucName, bool print)
{
    if(lev == nullptr) return "";

    TString Text="";

572 573 574 575 576 577 578 579
    if(print) {
        TString text = Form("** Levels info for nucleus %s **",NucName.Data());
        TString stars; for (int i=0 ; i<text.Length() ; i++) stars.Append("*");
        cout<<endl<<endl<<stars<<endl<<text<<endl<<stars<<endl<<endl;

        cout<<left<<setw(15)<<"Energy"<<setw(6)<<"Spin"<<setw(8)<<"T 1/2"<<endl;
        cout<<"--------------------------"<<endl<<endl;
    }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629
    for(Int_t i=0 ; i<lev->GetLevels().GetSize() ; i++) {
        NuclearLevel *NucLev = (NuclearLevel*)lev->GetLevels().At(i);
        Float_t ELev   = NucLev->GetEnergy().GetValue();
        TString spin = GetSpinFromLev(NucLev);
        Float_t LifeTime = NucLev->GetT().GetValue();

        TString LifeTimeText="";
        if(LifeTime >0.) {
            if(LifeTime<1e-12)
                LifeTimeText = Form("%.1f fs",LifeTime*1e15);
            if(LifeTime>1e-12 && LifeTime<1e-9)
                LifeTimeText = Form("%.1f ps",LifeTime*1e12);
            if(LifeTime>1e-9 && LifeTime<1e-6)
                LifeTimeText = Form("%.1f ns",LifeTime*1e9);
            if(LifeTime>1e-6 && LifeTime<1e-3)
                LifeTimeText = Form("%.1f us",LifeTime*1e6);
            if(LifeTime>1e-3 && LifeTime<1e-0)
                LifeTimeText = Form("%.1f ms",LifeTime*1e3);
            if(LifeTime>1e-0)
                LifeTimeText = Form("%.1f s",LifeTime);
            if(LifeTime>60)
                LifeTimeText = Form("%.1f min",LifeTime/60.);
            if(LifeTime>3600)
                LifeTimeText = Form("%.1f h",LifeTime/3600.);
            if(LifeTime>3600*12)
                LifeTimeText = Form("%.1f d",LifeTime/(3600.*12));
            if(LifeTime>3600*12*365)
                LifeTimeText = Form("%.1f years",LifeTime/(3600.*12*365));
            if(LifeTime>1e15)
                LifeTimeText = Form("STABLE");
        }
        if(print) cout<<left<<setw(15)<<ELev<<setw(6)<<spin<<setw(8)<<LifeTimeText<<endl;
        Text += Form("!%-7g %-7s %-10s",ELev,spin.Data(),LifeTimeText.Data());
    }
    return Text;
}

TString CXLevelSchemePlayer::PrintNucleusLevels(Int_t Z, Int_t N, bool print)
{
    CXNucleus nuc(Z,Z+N);
    LevelScheme *lev = ImportENSDFData(nuc.GetSymbol());

    if(lev == nullptr) {
        cout<<Form("%s Level scheme not found",nuc.GetSymbol().Data())<<endl;
        return Form("%s Level scheme not found",nuc.GetSymbol().Data());
    }

    return PrintNucleusLevels(lev,nuc.GetSymbol(),print);
}

630
void CXLevelSchemePlayer::PlotLevelScheme(TString NucName, TString Type, TString DataSet)
Jérémie Dudouet's avatar
Jérémie Dudouet committed
631 632 633 634
{
    LevelScheme *lev = nullptr;

    if(Type=="ENSDF")
635
        lev = ImportENSDFData(NucName,true,DataSet,false);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
636 637 638
    else
        lev = ImportExpData(NucName);

Jérémie Dudouet's avatar
Jérémie Dudouet committed
639
    if(lev == nullptr) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
        cout<<Form("%s Level scheme for %s not found",Type.Data(), NucName.Data())<<endl;
        return;
    }

    fRangeXMin = 1e6;
    fRangeXMax = -1e6;

    if(fGuiLSPlayer->GetYrastMode())
        CalcYrast(lev);

    fGuiLSPlayer->GetBranchingRatio(fMinStrenght,fMaxStrenght);
    fGuiLSPlayer->GetELevels(fMinELevel,fMaxELevel);
    fGuiLSPlayer->GetSpins(fMinSpin,fMaxSpin);
    fGuiLSPlayer->GetLifeTime(fMinLifeTime,fMaxLifeTime);

    TCanvas *ctest = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("GLSPlayer");
    if(ctest != 0x0) ctest->Close();
    ctest = new TCanvas("GLSPlayer","GLSPlayer");
    ctest->cd();

    LevelScheme *LS_To_Plot = new LevelScheme;

    GLSPlayer *LSPlayer = (GLSPlayer*)LS_To_Plot->GetPlayer();

    CXNucleus Nuc(NucName);

666
    for(Int_t i=0 ; i<lev->GetLinks().GetSize() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
667 668 669 670 671 672 673 674 675 676 677
        Gw::GammaLink *Link= (Gw::GammaLink*)lev->GetLinks().At(i);

        NuclearLevel *NucLevI = (NuclearLevel*)Link->GetIL();
        NuclearLevel *NucLevF = (NuclearLevel*)Link->GetFL();

        Float_t Strengh = Link->GetStrength().GetValue();
        Float_t ELevI   = NucLevI->GetEnergy().GetValue();
        TString spinI_s = GetSpinFromLev(NucLevI);
        Float_t spinI   = NucLevI->GetSpin().Get();
        Float_t ELevF   = NucLevF->GetEnergy().GetValue();
        TString spinF_s = GetSpinFromLev(NucLevF);
678 679 680 681
        Float_t LifeTimeI = NucLevI->GetT().GetValue();
        Float_t LifeTimeF = NucLevF->GetT().GetValue();
        TString LifeTimestrI = GetLTString(LifeTimeI);
        TString LifeTimestrF = GetLTString(LifeTimeF);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697

        if( fGuiLSPlayer->UseBranchingRatio() && (Strengh<fMinStrenght || Strengh>fMaxStrenght))
            continue;

        if(fGuiLSPlayer->UseELevels() && (ELevI<fMinELevel || ELevI>fMaxELevel))
            continue;

        if(fGuiLSPlayer->UseSpins() && (spinI<fMinSpin || spinI>fMaxSpin))
            continue;

        if(fGuiLSPlayer->GetYrastMode() && ELevI>fYrastEnergies[2*spinI])
            continue;

        //        if(fGuiLSPlayer->GetYrastMode() && ELevF>fYrastEnergies[2*spinF])
        //            continue;

698
        if(fGuiLSPlayer->UseLifeTime() && (LifeTimeI<fMinLifeTime || LifeTimeI>fMaxLifeTime))
Jérémie Dudouet's avatar
Jérémie Dudouet committed
699 700 701
            continue;

        NuclearLevel *NucLevel_F = GetLevel(NucLevF,LS_To_Plot);
702 703 704 705 706 707 708 709 710 711
        if(NucLevel_F == nullptr) {
            cout<<"tot "<< ELevF<<" "<<(TMath::Abs(ELevF)<0.001)<<endl;
            if(TMath::Abs(ELevF)<0.001){
                NucLevel_F = LSPlayer->AddGroundLevel(Nuc.GetZ(),Nuc.GetA(),spinF_s.Data());
                NucLevel_F->SetLabels(spinF_s.Data(),"",LifeTimestrF.Data(),Form("%g",ELevF));
            }
            else {
                NucLevel_F = LSPlayer->AddLevel(ELevF,0,spinF_s.Data());
                NucLevel_F->SetLabels(spinF_s.Data(),"",LifeTimestrF.Data(),Form("%g",ELevF));
            }
Jérémie Dudouet's avatar
Jérémie Dudouet committed
712 713 714 715 716
        }

        LS_To_Plot->SetCLevel(NucLevel_F);

        NuclearLevel *NucLevel_I = GetLevel(NucLevI,LS_To_Plot);
717 718 719
        if(NucLevel_I == nullptr) {
            NucLevel_I = LSPlayer->AddLevel(ELevI,0,spinI_s.Data());
            NucLevel_I->SetLabels(spinI_s.Data(),"",LifeTimestrI.Data(),Form("%g",ELevI));
Jérémie Dudouet's avatar
Jérémie Dudouet committed
720 721 722 723
        }

        LSPlayer->HandleMovement(kKeyPress,-666,kKey_s,NucLevel_I);
        LSPlayer->HandleMovement(kKeyPress,-666,kKey_s,NucLevel_F);
724

Jérémie Dudouet's avatar
Jérémie Dudouet committed
725 726 727 728
        DrawLink(LS_To_Plot,Link);
    }

    Float_t YMax=0;
729
    for(int i=0 ; i<LS_To_Plot->GetLevels().GetEntries() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
730
        NuclearLevel *lev = (NuclearLevel*)LS_To_Plot->GetLevels().At(i);
731
        lev->SetVisLabel("1111");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
732 733 734 735 736 737

        if(lev->GetEnergy().Get()>YMax)
            YMax = lev->GetEnergy().Get();

        lev->SetX1(fRangeXMin);
        lev->SetX2(fRangeXMax);
738 739 740

        lev->SetLineColor(kBlack);
        lev->SetLineWidth(1);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
741 742
    }

743
    for(int i=0 ; i<LS_To_Plot->GetLinks().GetEntries() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
744 745 746 747 748 749
        Link* link = (Link*)LS_To_Plot->GetLinks().At(i);

        link->RefreshPoints();
        link->Paint();
    }

750
//    LS_To_Plot->SetName("");
Jérémie Dudouet's avatar
Jérémie Dudouet committed
751 752 753 754 755
    LS_To_Plot->Draw();
    LSPlayer->GetLSAxis()->SetRange(0,YMax,fRangeXMin,fRangeXMax);

    ctest->SetName(Form("ENSDFLS_%s",NucName.Data()));
    ctest->SetTitle(Form("ENSDF level Scheme for nuc %s",NucName.Data()));
756 757 758

    gSystem->ProcessEvents();
    LSPlayer->RefreshLinks();
Jérémie Dudouet's avatar
Jérémie Dudouet committed
759 760 761 762 763 764 765 766 767 768 769 770
}

void CXLevelSchemePlayer::DrawLink(LevelScheme *ls, GammaLink *gammalink)
{
    Float_t energy = gammalink->GetEnergy().Get();
    Float_t strenght = gammalink->GetStrength().Get();

    //    cout<<"DrawLink "<<energy<<" "<<strenght<<" "<<GetSpinFromLev((NuclearLevel*)gammalink->GetIL())<<" -> "<<GetSpinFromLev((NuclearLevel*)gammalink->GetFL())<< endl;
    GLSPlayer *LSPlayer = (GLSPlayer*)ls->GetPlayer();
    LSPlayer->AddLink(strenght,0,energy);

    GammaLink *NewLink = (GammaLink*) ls->GetLinks().Last();
771 772
    if(fGuiLSPlayer->GetColorMode()) NewLink->SetArrowStyle(2);
    else NewLink->SetArrowStyle(1);
Jérémie Dudouet's avatar
Jérémie Dudouet committed
773

774
    if(ls->GetLinks().GetEntries()==1) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
775 776 777 778 779 780
        NewLink->RefreshPoints();
        NewLink->Paint();
    }

    Bool_t ok = false;

781
    while(ok==false) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
782 783 784 785 786 787 788 789
        Float_t xmin_new,xmax_new,ymin_new,ymax_new;
        GetLimits(NewLink,xmin_new,xmax_new,ymin_new,ymax_new);

        if(xmin_new<fRangeXMin) fRangeXMin = xmin_new;
        if(xmax_new>fRangeXMax) fRangeXMax = xmax_new;

        ok = true;

790
        for(Int_t i=0 ; i<ls->GetLinks().GetSize()-1 ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
791 792 793 794 795 796 797 798
            GammaLink *Link= (Gw::GammaLink*)ls->GetLinks().At(i);
            Float_t xmin,xmax,ymin,ymax;
            GetLimits(Link,xmin,xmax,ymin,ymax);

            if((ymin+0.5>ymax_new) || (ymax-0.5<ymin_new))
                continue;
            else if((xmax<xmin_new) || (xmin>xmax_new))
                continue;
799
            else {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847
                ShiftLink(NewLink,60);
                ok = false;
                break;
            }
        }
    }
}

void CXLevelSchemePlayer::GetLimits(GammaLink *link, Float_t &xmin,Float_t &xmax,Float_t &ymin,Float_t &ymax)
{
    xmin = link->GetX()[0];
    xmax = link->GetX()[0];
    ymin = link->GetY()[0];
    ymax = link->GetY()[0];

    for(int i=0 ; i<8 ; i++)
    {
        if(link->GetX()[i]<xmin) xmin = link->GetX()[i];
        if(link->GetX()[i]>xmax) xmax = link->GetX()[i];
        if(link->GetY()[i]<ymin) ymin = link->GetY()[i];
        if(link->GetY()[i]>ymax) ymax = link->GetY()[i];
    }
}

void CXLevelSchemePlayer::ShiftLink(GammaLink *link, Float_t XShift)
{
    for(int i=0 ; i<8 ; i++)
    {
        link->SetPoint(i,link->GetX()[i]+XShift,link->GetY()[i]);
    }
}

void CXLevelSchemePlayer::ResizeNucLev(NuclearLevel *nuclev,Float_t width)
{
    Float_t Center = nuclev->GetX1() + (nuclev->GetX2()-nuclev->GetX1())/2.;

    nuclev->SetX1(Center-width/2);
    nuclev->SetX2(Center+width/2);
}

NuclearLevel *CXLevelSchemePlayer::GetLevel(NuclearLevel *nuclev, LevelScheme *ls)
{
    Float_t ELevel = nuclev->GetEnergy().GetValue();

    ELevel = TMath::Nint(ELevel*10.)/10.;

    NuclearLevel *level = nullptr;

848
    for(Int_t i=0 ; i<ls->GetLevels().GetSize() ; i++) {
Jérémie Dudouet's avatar
Jérémie Dudouet committed
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
        level = (NuclearLevel*)ls->GetLevels().At(i);

        Float_t ELevel2 = level->GetEnergy().GetValue();

        if(level && TMath::Abs(ELevel2 - ELevel)<0.1 && (GetSpinFromLev(nuclev) == GetSpinFromLev(level)) )
            return level;
    }

    return nullptr;
}

TString CXLevelSchemePlayer::GetSpinFromLev(NuclearLevel *nuclev)
{
    Float_t spin = nuclev->GetSpin().Get();

    TString  PL = "+";
    if(nuclev->GetParity().IsParity(Gw::Parity::kMinus))
        PL = "-";

    TString SL = Form("%.1f",spin);

    TString Lev;

    if(SL.EndsWith(".5"))
        Lev = Form("%d/2%s",TMath::Nint(2*SL.Atof()),PL.Data());
    else
        Lev = Form("%d%s",SL.Atoi(),PL.Data());

Jérémie Dudouet's avatar
Jérémie Dudouet committed
877 878 879 880 881
    if(nuclev->GetSpin().IsData(InfoData::kUnknown))
        Lev="?";
    else if(nuclev->GetSpin().IsData(InfoData::kTentative))
        Lev.Append(")").Prepend("(");

Jérémie Dudouet's avatar
Jérémie Dudouet committed
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
    return Lev;
}

void CXLevelSchemePlayer::ProcessedEventLevelScheme(Int_t eventType, Int_t eventX, Int_t eventY, TObject* obj)
{
    if( eventType == kKeyPress )
    {
        EKeySym keysym = (EKeySym)eventY;

        if ( keysym == kKey_r)
        {
            Int_t index = -1;
            if(fListOfBoxes->FindObject(obj))
                index = fListOfBoxes->IndexOf(obj);

            if(index != -1)
                RemoveArrow(index);
        }
    }
}

void CXLevelSchemePlayer::RemoveArrow(Int_t ArrowIndex)
{
    TList *l = fMainWindow->GetCanvas()->GetListOfPrimitives();

    l->Remove(fListOfBoxes->RemoveAt(ArrowIndex));
    l->Remove(fListOfArrows->RemoveAt(ArrowIndex));
    l->Remove(fListOfLatex->RemoveAt(ArrowIndex));

    fMainWindow->GetCanvas()->Modified();
    fMainWindow->GetCanvas()->Update();
}

915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947
TString CXLevelSchemePlayer::GetLTString(Float_t LifeTime)
{
    TString Value="";

    if(LifeTime >0.) {
        if(LifeTime<1e-12)
            Value = Form("%.3g fs",LifeTime*1e15);
        else if(LifeTime<1e-9)
            Value = Form("%.3g ps",LifeTime*1e12);
        else if(LifeTime<1e-6)
            Value = Form("%.3g ns",LifeTime*1e9);
        else if(LifeTime<1e-3)
            Value = Form("%.3g us",LifeTime*1e6);
        else if(LifeTime<1e-0)
            Value = Form("%.3g ms",LifeTime*1e3);
        else if(LifeTime<60)
            Value = Form("%.3g s",LifeTime);
        else if(LifeTime<3600)
            Value = Form("%.3g min",LifeTime/60.);
        else if(LifeTime<3600*12)
            Value = Form("%.3g h",LifeTime/3600.);
        else if(LifeTime<3600*24*365.242190517)
            Value = Form("%.3g d",LifeTime/(3600.*24));
        else if(!isinf(LifeTime))
            Value = Form("%.3g y",LifeTime/(3600.*24*365.242190517));
        else
            Value = Form("STABLE");
    }
    Value.Append(" ");

    return Value;
}

Jérémie Dudouet's avatar
Jérémie Dudouet committed
948 949 950 951 952
ClassImp(CXLevelSchemePlayer);