Commit da780327 authored by Jérémie Dudouet's avatar Jérémie Dudouet
Browse files

Merge branch 'Cubix' into 'Cubix'

Cubix

See merge request !36
parents cce7b049 9869999c
Pipeline #28161 passed with stage
in 4 minutes and 2 seconds
......@@ -18,6 +18,7 @@
#include "TGListTree.h"
#include "TClass.h"
#include "TCanvas.h"
#include "TCutG.h"
using namespace std;
......@@ -59,7 +60,7 @@ CXFileList::CXFileList(const TGCompositeFrame *MotherFrame, UInt_t w, UInt_t h)
fMenu->AddEntry("Lar&ge Icons",kLVLargeIcons);
fMenu->AddEntry("S&mall Icons",kLVSmallIcons);
fMenu->AddEntry("&List", kLVList);
// fMenu->AddEntry("&Details", kLVDetails);
// fMenu->AddEntry("&Details", kLVDetails);
fMenu->Connect("Activated(Int_t)","CXFileList",this,"DoMenu(Int_t)");
TGHorizontalFrame *h3 = new TGHorizontalFrame(fv2,10,10);
......@@ -91,7 +92,7 @@ CXFileList::CXFileList(const TGCompositeFrame *MotherFrame, UInt_t w, UInt_t h)
Resize();
DoMenu(kLVSmallIcons);
DoMenu(kLVList);
}
void CXFileList::DoubleClicked(TGListTreeItem *item, Int_t a_int)
......@@ -99,20 +100,15 @@ void CXFileList::DoubleClicked(TGListTreeItem *item, Int_t a_int)
TGListTree *sender = (TGListTree *)gTQSender;
const TGWindow *parent = sender->GetParent()->GetParent()->GetParent();
if(parent == fBrowser)
{
if(parent == fBrowser){
TObject *obj = (TObject *) item->GetUserData();
if(obj)
{
if(obj){
obj->IsA()->SetName("");
TString filename = fBrowser->FullPathName(item);
if(gSystem->IsFileInIncludePath(filename) && filename.EndsWith(".root"))
{
DisplayFile(filename);
}
}
}
}
......@@ -120,7 +116,6 @@ void CXFileList::DoubleClicked(TGListTreeItem *item, Int_t a_int)
CXFileList::~CXFileList()
{
// Cleanup.
delete fContents;
fMain->DeleteWindow(); // deletes fMain
......@@ -130,15 +125,21 @@ CXFileList::~CXFileList()
void CXFileList::DoMenu(Int_t mode)
{
// Switch view mode.
if (mode<10) {
if (mode<10)
fContents->SetViewMode((EListViewMode)mode);
} else {
else
delete this;
}
}
void CXFileList::DisplayFile(const TString &fname)
{
//Close the last opened file
if(fCurrentFile){
fCurrentFile->Close();
fCurrentFile = nullptr;
fFolders.clear();
}
// Display content of ROOT file.
TFile *file = TFile::Open(fname);
fContents->RemoveAll();
......@@ -155,7 +156,7 @@ void CXFileList::DisplayFile(const TString &fname)
TGLVEntry *entry = new TGLVEntry(fContents,name,cname);
entry->SetSubnames(key->GetTitle());
if(cname=="TList")
if(cname=="TList" || cname=="TDirectoryFile")
entry->SetPictures(gClient->GetPicture("folder_s.xpm"),gClient->GetPicture("folder_t.xpm"));
if(cname=="TCutG")
entry->SetPictures(gClient->GetPicture("bld_cut.png"),gClient->GetPicture("bld_cut.png"));
......@@ -168,49 +169,53 @@ void CXFileList::DisplayFile(const TString &fname)
entry->SetUserData((void*)StrDup(fname));
}
fMain->Resize();
fParent = file;
if(fParentFile && file!=fParentFile){
fParentFile->Close();
}
fParentFile = file;
fCurrentFile = file;
fFolders.push_back(file);
}
void CXFileList::DisplayList(TList *list)
{
// Display content of ROOT file.
TString Name = fParentFile->GetName();
TString Name = fCurrentFile->GetName();
TObjArray *arr = Name.Tokenize("/");
Name = arr->Last()->GetName();
delete arr;
TGLVEntry *entry = new TGLVEntry(fContents,Name,fParentFile->ClassName());
entry->SetUserData((void*)StrDup(fParentFile->GetName()));
fContents->RemoveAll();
// fContents->AddFile(gSystem->WorkingDirectory());
fContents->AddItem(entry);
fContents->SetPagePosition(0,0);
// fContents->SetColHeaders("Name","Title");
// fContents->SetColHeaders("Name","Title");
TObject *Folder = fFolders.back();
TGLVEntry *entry = nullptr;
if(fFolders.size()>1){
entry = new TGLVEntry(fContents,"..",Folder->ClassName());
entry->SetUserData((void*)StrDup(Folder->GetName()));
entry->SetPictures(gClient->GetPicture("folder_s.xpm"),gClient->GetPicture("folder_t.xpm"));
fContents->AddItem(entry);
}
TIter next(list);
TObject *key;
while ((key=(TObject*)next())) {
if(Folder->InheritsFrom(TDirectoryFile::Class_Name())){
key = ((TDirectoryFile*)Folder)->Get(key->GetName());
}
TString cname = key->ClassName();
TString name = key->GetName();
TGLVEntry *entry = new TGLVEntry(fContents,name,cname);
entry->SetSubnames(key->GetTitle());
fContents->AddItem(entry);
if(cname=="TList")
if(cname==TList::Class_Name() || cname==TDirectoryFile::Class_Name())
entry->SetPictures(gClient->GetPicture("folder_s.xpm"),gClient->GetPicture("folder_t.xpm"));
if(cname=="TCutG")
if(cname==TCutG::Class_Name())
entry->SetPictures(gClient->GetPicture("bld_cut.png"),gClient->GetPicture("bld_cut.png"));
if(cname.BeginsWith("TGraph"))
if(cname.BeginsWith(TGraph::Class_Name()))
entry->SetPictures(gClient->GetPicture("graph.xpm"),gClient->GetPicture("graph.xpm"));
// user data is a filename
......@@ -219,44 +224,34 @@ void CXFileList::DisplayList(TList *list)
fMain->Resize();
}
void CXFileList::DisplayDirectory(const TString &fname)
{
// Display content of directory.
fContents->SetDefaultHeaders();
gSystem->ChangeDirectory(fname);
fContents->ChangeDirectory(fname);
fContents->DisplayDirectory();
fContents->AddFile(".."); // up level directory
fContents->Sort(EFSSortMode::kSortByName);
fMain->Resize();
}
void CXFileList::DisplayObject(const TString& fname,const TString& name)
{
// Browse object located in file.
TDirectory *sav = gDirectory;
TObject* obj = nullptr;
TObject *CurrentFolder = fFolders.back();
if(fParent->InheritsFrom("TFile"))
obj = fParentFile->Get(name);
else if(fParent->InheritsFrom("TList"))
obj = fParent->FindObject(name);
if(name==".."){
fFolders.pop_back();
obj=fFolders.back();
fFolders.pop_back();
}
else if(CurrentFolder->InheritsFrom(TList::Class_Name()))
obj = ((TList*)CurrentFolder)->FindObject(name);
else if(CurrentFolder->InheritsFrom(TDirectoryFile::Class_Name()))
obj = ((TDirectoryFile*)CurrentFolder)->Get(name);
if(obj == nullptr){
DisplayFile(fParentFile->GetName());
DisplayFile(fCurrentFile->GetName());
return;
}
if (obj)
{
if (!obj->IsFolder())
{
if (!obj->IsFolder()){
TString CanvasName = fMainWindow->GetCanvas()->GetName();
if(CanvasName.BeginsWith("GxG"))
{
if(CanvasName.BeginsWith("GxG")){
cout<<" cannot plot in a Tab dedicated to Gamma Gamma projections" << endl;
return;
}
......@@ -268,12 +263,10 @@ void CXFileList::DisplayObject(const TString& fname,const TString& name)
if(gPad && (obj->InheritsFrom("TH1")
|| obj->InheritsFrom("TGraph")
|| obj->InheritsFrom("TF1")))
{
|| obj->InheritsFrom("TF1"))){
obj->Draw(fBrowser->GetDrawOption());
if(obj->InheritsFrom("TH1"))
{
if(obj->InheritsFrom("TH1")){
TH1 *hist = (TH1*)obj;
hist->SetDirectory(nullptr);
}
......@@ -281,8 +274,7 @@ void CXFileList::DisplayObject(const TString& fname,const TString& name)
gPad->Update();
gPad->GetFrame()->SetBit(TObject::kCannotPick);
}
else if(gPad && obj->InheritsFrom("TCanvas"))
{
else if(gPad && obj->InheritsFrom("TCanvas")){
TCanvas *canvas_in = (TCanvas*)obj;
CXCanvas *canvas_out = fMainWindow->GetCanvas();
canvas_out->cd();
......@@ -290,47 +282,46 @@ void CXFileList::DisplayObject(const TString& fname,const TString& name)
Int_t idraw = 0;
for(int i=0 ; i<canvas_in->GetListOfPrimitives()->GetEntries() ; i++)
{
for(int i=0 ; i<canvas_in->GetListOfPrimitives()->GetEntries() ; i++){
TObject *o = canvas_in->GetListOfPrimitives()->At(i);
if(idraw==0)
{
if(idraw==0){
idraw++;
if(o->InheritsFrom("TH2"))
if(o->InheritsFrom(TH2::Class_Name()))
o->Draw("col");
else if(o->InheritsFrom("TH1"))
else if(o->InheritsFrom(TH1::Class_Name()))
o->Draw("hist");
else if(o->InheritsFrom("TGraph"))
else if(o->InheritsFrom(TGraph::Class_Name()))
o->Draw("APL");
else
idraw--;
}
else
{
if(o->InheritsFrom("TH2"))
else{
if(o->InheritsFrom(TH2::Class_Name()))
o->Draw("col same");
else if(o->InheritsFrom("TH1"))
else if(o->InheritsFrom(TH1::Class_Name()))
o->Draw("hist same");
else if(o->InheritsFrom("TGraph"))
else if(o->InheritsFrom(TGraph::Class_Name()))
o->Draw("PL");
}
}
canvas_out->ls();
gPad->Modified();
gPad->Update();
gPad->GetFrame()->SetBit(TObject::kCannotPick);
}
fMainWindow->RefreshPad();
}
else
{
cout<<"No possibility to drawn "<<obj->ClassName()<<" objects"<<endl;
}
}
else if(obj->InheritsFrom("TList"))
{
fParent = obj;
DisplayList(((TList*)obj));
else if(obj->InheritsFrom(TList::Class_Name()) || obj->InheritsFrom(TDirectoryFile::Class_Name())){
fFolders.push_back(obj);
if(obj->InheritsFrom(TList::Class_Name()))
DisplayList((TList*)obj);
if(obj->InheritsFrom(TDirectoryFile::Class_Name()))
DisplayList(((TDirectoryFile*)obj)->GetListOfKeys());
}
}
......@@ -341,14 +332,16 @@ void CXFileList::OnClick(TGLVEntry *f, Int_t btn, Int_t x, Int_t y)
{
if (btn == kButton3)
{
TObject *CurrentFolder = fFolders.back();
TString name(f->GetTitle());
TObject* obj = nullptr;
if(fParent->InheritsFrom("TFile"))
obj = fParentFile->Get(name);
else if(fParent->InheritsFrom("TList"))
obj = fParent->FindObject(name);
if(CurrentFolder->InheritsFrom(TDirectoryFile::Class_Name()))
obj = ((TDirectoryFile*)CurrentFolder)->Get(name);
else if(CurrentFolder->InheritsFrom(TList::Class_Name()))
obj = CurrentFolder->FindObject(name);
if(obj == nullptr)
return;
......@@ -370,13 +363,8 @@ void CXFileList::OnDoubleClick(TGLVEntry *f, Int_t btn)
TString name(f->GetTitle());
const char* fname = (const char*)f->GetUserData();
if (fname) {
DisplayObject(fname, name);
} else if (name.EndsWith(".root")) {
DisplayFile(name);
} else {
DisplayDirectory(name);
}
DisplayObject(fname, name);
// set kPointer cursor
cur = gVirtualX->CreateCursor(kPointer);
gVirtualX->SetCursor(fContents->GetId(), cur);
......
......@@ -14,6 +14,7 @@ class TList;
class TFile;
class TGListTreeItem;
class CXGFileBrowser;
class TDirectoryFile;
class CXFileList : public TGVerticalFrame
{
......@@ -33,8 +34,11 @@ protected:
TGPopupMenu *fMenu;
TGTextEntry *fDrawOption;
std::vector<TObject*> fFolders;
TObject *fCurrent = nullptr;
TObject *fParent = nullptr;
TFile *fParentFile = nullptr;
TFile *fCurrentFile = nullptr;
CXGFileBrowser *fBrowser = nullptr;
......@@ -57,7 +61,6 @@ public:
private:
void DisplayFile(const TString &fname);
void DisplayDirectory(const TString &fname);
void DisplayObject(const TString& fname,const TString& name);
void DisplayList(TList *list);
......
......@@ -15,7 +15,9 @@
#include "TGLabel.h"
#include "TGButton.h"
#include "TList.h"
#include "TGResourcePool.h"
#include "GwConfig.h"
#include "LevelScheme.h"
#include "GammaLink.h"
......@@ -159,7 +161,7 @@ void CXGammaSearch::SetCalMode()
{
if(fNGammas<=1)
cout<<"Soory, I cannot determine coincidence between one or less gamma ray..."<<endl;
else if(fNGammas==1)
else if(fNGammas==2)
{
FindGammaRays(true);
FindInDoubleCoincidence();
......@@ -245,10 +247,11 @@ void CXGammaSearch::FindGammaRays(Bool_t Bash)
{
gatetrig[ig] = true;
GoodGammas.push_back(Link);
goto cnt;
}
if(gatetrig[ig])
continue;
}
cnt:;
}
Int_t NGatesTrig=0;
......@@ -257,6 +260,10 @@ cnt:;
if(NGatesTrig>=fNGammas)
{
// cout<<NGatesTrig<<" "<<fNGammas<<endl;
// cout<<GoodGammas.size()<<endl;
// cout<<Form("%s (Z=%d, A=%d, N=%d)",Nuc.GetSymbol().Data(),Nuc.GetZ(),Nuc.GetA(),Nuc.GetN())<<endl;
if(!Bash)
PrintInListBox(Form("%s (Z=%d, A=%d, N=%d)",Nuc.GetSymbol().Data(),Nuc.GetZ(),Nuc.GetA(),Nuc.GetN()),kInfo);
......@@ -277,20 +284,35 @@ cnt:;
Float_t ELevF = NucLevF->GetEnergy().GetValue();
TString spinF = GetSpinFromLev(NucLevF);
Float_t LifeTime = NucLevI->GetT().GetValue();
TString LifeTimeText="";
if(LifeTime != 0) {
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);
}
agammatrans.NucName = Nuc.GetSymbol();
agammatrans.EGamma = Energy;
agammatrans.EI = ELevI;
agammatrans.EF = ELevF;
agammatrans.SpinI = spinI;
agammatrans.SpinF = spinF;
agammatrans.LifeTime = LifeTimeText;
avect.push_back(agammatrans);
if(!Bash)
{
TString GammaTitle = Form(" => %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV)",Energy,spinI.Data(),ELevI,spinF.Data(),ELevF);
PrintInListBox(GammaTitle.Data(),kPrint);
}
TString GammaTitle = Form(" => %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV)%s",Energy,spinI.Data(),ELevI,spinF.Data(),ELevF, LifeTimeText.Data());
if(!Bash) PrintInListBox(GammaTitle.Data(),kPrint);
}
fListOfGoodGammas.push_back(avect);
......@@ -306,7 +328,6 @@ cnt:;
MapSubwindows();
MapWindow();
Layout();
}
void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
......@@ -318,6 +339,7 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
std::vector<int> Index_Nuclei;
std::vector<string> Nuclei_ID;
std::vector<Float_t> DeltaE;
Int_t Number_Analysed_Gammas=0;
Int_t Count=0;
......@@ -330,7 +352,7 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
vector < GammaTransition > avec = fListOfGoodGammas[inuc];
if(avec.size()<3)
if(avec.size()<2)
continue;
CXNucleus Nuc(((GammaTransition)avec[0]).NucName.Data());
......@@ -354,6 +376,9 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
Bool_t Det = fSp->IsDet(Mat_LS,Dim_LS);
TString TransitionName[Dim_LS];
Float_t ETrans[Dim_LS];
Float_t EI[Dim_LS];
Float_t EF[Dim_LS];
//get the coordinates of the gammas
for(Int_t ig=0 ; ig<Dim_LS ; ig++)
......@@ -365,15 +390,43 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
if(GT.EGamma == Mat_E[ig][0])
{
Flag[ig] = Mat_E[ig][0];
TransitionName[ig] = Form(" %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV) ",GT.EGamma,GT.SpinI.Data(),GT.EI,GT.SpinF.Data(),GT.EF);
TransitionName[ig] = Form(" %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV)%s ",GT.EGamma,GT.SpinI.Data(),GT.EI,GT.SpinF.Data(),GT.EF,GT.LifeTime.Data());
ETrans[ig] = GT.EGamma;
EI[ig] = GT.EI;
EF[ig] = GT.EF;
}
}
}
Bool_t gatetrig[fNGammas];
Float_t Gates[fNGammas];
Float_t Width[fNGammas];
for(int ig=0 ; ig<fNGammas ; ig++) {
Gates[ig] = fEnergies[ig]->GetNumber();
Width[ig] = fWidths[ig]->GetNumber();
}
for(Int_t j=0 ; j<Dim_LS ; j++)
{
for(Int_t m=0 ; m<j ; m++)
{
memset(gatetrig,0,sizeof(fNGammas));
Int_t NGatesTrig=0;
for(int ig=0 ; ig<fNGammas ; ig++) {
if(TMath::Abs(ETrans[j]-Gates[ig])<Width[ig])
gatetrig[ig] = true;
if(TMath::Abs(ETrans[m]-Gates[ig])<Width[ig])
gatetrig[ig] = true;
}
for(int ii=0 ; ii<fNGammas ; ii++)
NGatesTrig += gatetrig[ii];
if(NGatesTrig != 2)
continue;
Float_t Prob = TMath::Abs(Mat_P[j][m]);
if(Flag[j]>0 && Flag[m]>0 && Prob>0.01)
{
......@@ -381,6 +434,11 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
Tab_P.push_back(Prob);
Index_Nuclei.push_back(Count);
if(EI[j]>EI[m])
DeltaE.push_back(EF[j]-EI[m]);
else
DeltaE.push_back(EF[m]-EI[j]);
TString Name_Output = Form("%s# --> %s# --> %s, Prob = %1.3f", Nuc.GetSymbol().Data(),TransitionName[j].Data(),TransitionName[m].Data(),Prob);
if (Det==false)
......@@ -397,7 +455,7 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
}
std::vector<int> Index_Sorted;
Index_Sorted = Sort_Index(Index_Nuclei,Tab_P);
Index_Sorted = Sort_Index(Index_Nuclei,Tab_P, DeltaE);
if(!Bash)
{
......@@ -405,7 +463,7 @@ void CXGammaSearch::FindInDoubleCoincidence(Bool_t Bash)
{
TString Name = Nuclei_ID.at(Index_Sorted[j]);
TObjArray *arr = Name.Tokenize("#");
TString NucName = arr->First()->GetName();
TString NucName = Form("%s : Energy Diff = %1.3f",arr->First()->GetName(),DeltaE[Index_Sorted[j]]);
TString Transition1 = arr->At(1)->GetName();
TString Transition2 = arr->At(2)->GetName();
......@@ -427,6 +485,7 @@ void CXGammaSearch::FindInTripleCoincidence()
std::vector<int> Index_Nuclei;
std::vector<string> Nuclei_ID;
std::vector<Float_t> DeltaE;
Int_t Number_Analysed_Gammas=0;
Int_t Count=0;
......@@ -463,6 +522,9 @@ void CXGammaSearch::FindInTripleCoincidence()
Bool_t Det = fSp->IsDet(Mat_LS,Dim_LS);
TString TransitionName[Dim_LS];
Float_t ETrans[Dim_LS];
Float_t EI[Dim_LS];
Float_t EF[Dim_LS];
//get the coordinates of the gammas
for(Int_t ig=0 ; ig<Dim_LS ; ig++)
......@@ -474,17 +536,47 @@ void CXGammaSearch::FindInTripleCoincidence()
if(GT.EGamma == Mat_E[ig][0])
{
Flag[ig] = Mat_E[ig][0];
TransitionName[ig] = Form(" %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV) ",GT.EGamma,GT.SpinI.Data(),GT.EI,GT.SpinF.Data(),GT.EF);
TransitionName[ig] = Form(" %6.1f keV : %5s (%6.1f keV) --> %5s (%6.1f keV)%s ",GT.EGamma,GT.SpinI.Data(),GT.EI,GT.SpinF.Data(),GT.EF,GT.LifeTime.Data());
ETrans[ig] = GT.EGamma;
EI[ig] = GT.EI;
EF[ig] = GT.EF;
}
}
}
Bool_t gatetrig[fNGammas];
Float_t Gates[fNGammas];
Float_t Width[fNGammas];
for(int ig=0 ; ig<fNGammas ; ig++) {