Commit a8df1e23 authored by J.Dudouet [IPNL/CSNSM]'s avatar J.Dudouet [IPNL/CSNSM]
Browse files

Adding developments on Peak1D etc...

Adding the Nuclear database class


git-svn-id: svn+ssh://anonsvn.in2p3.fr/agata/gammaware/trunk@2096 c3abf467-7ff2-0310-b516-c5fb849bdde0
parent de794b90
/***************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2014] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#if defined(__ROOTCLING__) || defined(__CINT__)
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ namespace Gw;
#endif
......@@ -93,18 +93,21 @@ void BashColor::ResetColor()
void BashColor::SetErrorOut()
{
ResetColor();
SetColor(kRed);
SetType(kBoldHighIntensity);
}
void BashColor::SetWarningOut()
{
ResetColor();
SetColor(kYellow);
SetType(kBoldUnderline);
}
void BashColor::SetInfoOut()
{
ResetColor();
SetColor(kBlue);
SetType(kBoldHighIntensity);
}
......@@ -38,8 +38,8 @@
#define GW_LibraryPath "@GW_LIB_DIR@";
#define GW_BinaryPath "@GW_BIN_DIR@";
#define GW_IncludePath "@GW_INCLUDE_DIR@";
#define GW_IconsPath "@GW_DATA_DIR@/gw/icons";
#define GW_NdbPath "@GW_DATA_DIR@/gw/ndb";
#define GW_MacrosPath "@GW_DATA_DIR@/gw/macros";
#define GW_IconsPath "@GW_DATA_DIR@/icons";
#define GW_NdbPath "@GW_DATA_DIR@/ndb";
#define GW_MacrosPath "@GW_DATA_DIR@/macros";
#endif
......@@ -37,8 +37,8 @@
#define GW_LibraryPath "@libdir@";
#define GW_BinaryPath "@bindir@";
#define GW_IncludePath "@includedir@";
#define GW_IconsPath "@datadir@/gw/icons";
#define GW_NdbPath "@datadir@/gw/ndb";
#define GW_MacrosPath "@datadir@/gw/macros";
#define GW_IconsPath "@datadir@/icons";
#define GW_NdbPath "@datadir@/ndb";
#define GW_MacrosPath "@datadir@/macros";
#endif
......@@ -41,6 +41,8 @@
#include "TPolyLine.h"
#endif
#include "TGraph.h"
using namespace Gw;
//
......@@ -85,9 +87,44 @@ TH1* PadManager::GetHisto(TVirtualPad *pad, Option_t * /*opt*/ )
break;
}
}
if(h == 0x0)
{
TGraph *g = GetGraph(pad);
if(g != 0x0) h = g->GetHistogram();
}
return h;
}
//__________________________________________________________
TGraph* PadManager::GetGraph(TVirtualPad *pad, Option_t * /*opt*/ )
{
// histograms to be returned
TGraph* h = 0x0;
// to get the pad on which the creator is added
TVirtualPad *locpad = 0x0;
if ( pad == 0x0 )
if ( TVirtualPad::Pad() == 0x0 )
return h;
else
locpad = TVirtualPad::Pad();
else
locpad = pad;
TObject* obj = 0x0;
TIter next(locpad->GetListOfPrimitives());
while ( (obj = next()) ) { // iterator skips empty slots
if ( obj->InheritsFrom("TGraph") ) {
h = dynamic_cast<TGraph*> ( obj );
break;
}
}
return h;
}
TPolyLine *PadManager::ShowDiff(const TH1 *h, const TF1 *f, Double_t xmin, Double_t xmax)
{
TPolyLine *result = new TPolyLine();
......
......@@ -36,6 +36,7 @@
#include "TRegexp.h"
class TF1;
class TGraph;
class TPolyLine;
namespace Gw {
......@@ -66,6 +67,8 @@ public:
//! look for an histogram into the pad
static TH1 * GetHisto(TVirtualPad *pad = 0x0 , Option_t *op = "");
static TGraph * GetGraph(TVirtualPad *pad = 0x0, Option_t *op = "" );
//! check if the action is
// static Bool_t IsActionOn(TVirtualPad *pad, EActionMode);
......
......@@ -79,7 +79,6 @@
using namespace Gw;
//
ClassImp(BaseSpectrumPlayer)
//__________________________________________________________
BaseSpectrumPlayer::BaseSpectrumPlayer()
......@@ -89,6 +88,7 @@ BaseSpectrumPlayer::BaseSpectrumPlayer()
fInnerPeakList(0x0),
fLastX(0),
fLastY(0),
fIsHelpsPrintActive(true),
fContextMenu(0x0),
fLog("BaseSpectrumPlayer")
{
......@@ -167,12 +167,18 @@ Bool_t BaseSpectrumPlayer::Connect(TCanvas *canvas)
fContextMenu = localCanvas->GetContextMenu();
// add a peak creator to the canvas if it does not exists
if ( ! PeakCreator::IsPeakCreator(localCanvas) ) {
if ( ! PeakCreator::IsPeakCreator(localCanvas) ) {
// change the characteristics ?
// PeakCreator *p = PeakCreator::AddPeakCreator(localCanvas);
PeakCreator::AddPeakCreator(localCanvas);
fCreator->AddCreatorToList();
fCreator->Connect();
}
else PeakCreator::IsPeakCreator(localCanvas)->Collect();
else
{
fCreator->Connect();
}
fCreator->Collect();
}
return localCanvas != 0x0;
}
......@@ -203,13 +209,16 @@ Bool_t BaseSpectrumPlayer::Disconnect(TCanvas *canvas)
}
fContextMenu = 0x0;
PeakCreator *PC = PeakCreator::IsPeakCreator(localCanvas);
if(PC) PC->Disconnect();
fLog << dolog;
return localCanvas != 0x0;
}
//__________________________________________________________
void BaseSpectrumPlayer::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* select)
void BaseSpectrumPlayer::HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* /*select*/)
{
// handle cursor mouvement
TVirtualPad *pad = gROOT->GetSelectedPad(), *cpad = TVirtualPad::Pad();
......@@ -217,24 +226,47 @@ void BaseSpectrumPlayer::HandleMovement(Int_t eventType, Int_t eventX, Int_t eve
if ( pad != cpad )
pad->cd();
TString name(select->ClassName());
if (eventType == kMouseMotion) {
// to keep track of the last mouse position
fLastX = eventX; fLastY = eventY;
}
if( eventType == kKeyPress) {
Int_t keysym = eventY;
if ( (EKeySym)keysym == kKey_f)
if((EKeySym)eventY == kKey_a && (EKeySym)eventX == kKey_a && (EKeySym)fLastY == kKey_f && (EKeySym)fLastX == kKey_f)
PopupFitMenu();
if ( (EKeySym)keysym == kKey_h) {
fLog << info;
fLog << "\tf: pop up fit panel menu" << nline;
fLog << dolog;
}
if((EKeySym)eventY == kKey_m && (EKeySym)eventX == kKey_m && (((EKeySym)fLastY == kKey_s && (EKeySym)fLastX == kKey_s) || ((EKeySym)fLastY == kKey_h && (EKeySym)fLastX == kKey_h)))
{
if(TVirtualPad::Pad() == 0x0) return;
TList *list = TVirtualPad::Pad()->GetListOfPrimitives();
if(list==0x0) return;
for(int i=0 ; i<list->GetSize() ; i++)
{
TObject *o = list->At(i);
if(o->InheritsFrom("Gw::Peak1D"))
{
Peak1D *peak = (Peak1D*)o;
if(peak->IsDrawAs(Peak1D::kGate)) continue;
else
{
if((EKeySym)fLastY == kKey_s) peak->SetDrawOption("ml");
else peak->SetDrawOption("!m!l");
}
}
}
gPad->Modified();
gPad->Update();
}
if ( (EKeySym)keysym == kKey_h && fIsHelpsPrintActive) {
fLog << info;
fLog << "\tf + a: pop up fit panel menu" << nline;
fLog << dolog;
}
}
fLastX = eventX; fLastY = eventY;
cpad->cd();
}
......@@ -307,12 +339,12 @@ void BaseSpectrumPlayer::FitAll(const char* nameFunc, Option_t* optFit, Option_t
}
if (peaks.GetEntries() != 0) {
peak->SetSignalFunction(nameFunc);
peak->FitCombined(h, &peaks, optFit, optBkg);
peaks.Clear("nodelete");
} else {
peak->SetSignalFunction(nameFunc);
peak->Fit(h,optFit, optBkg);
}
......@@ -322,6 +354,9 @@ void BaseSpectrumPlayer::FitAll(const char* nameFunc, Option_t* optFit, Option_t
while ( (obj = next()) ) {
peaks.Remove(obj);
}
gPad->Modified();
gPad->Update();
}
......@@ -518,8 +553,8 @@ Int_t BaseSpectrumPlayer::CollectPeaks(Option_t* o)
while ( (obj = next()) ) { // iterator skips empty slots
if ( obj->InheritsFrom("Gw::BasePeak") ) {
if (!fPeakList->FindObject(obj)) {
obj->SetBit(TObject::kCanDelete, false);
obj->SetBit(TObject::kMustCleanup, false);
// obj->SetBit(TObject::kCanDelete, false);
// obj->SetBit(TObject::kMustCleanup, false);
fPeakList->Add(obj); i++;
}
}
......@@ -534,3 +569,6 @@ void BaseSpectrumPlayer::Print(Option_t* opt) const
// print peak info
fPeakList->Print(opt);
}
ClassImp(BaseSpectrumPlayer)
......@@ -78,6 +78,11 @@ private:
private:
Int_t fLastX; // last x event position
Int_t fLastY; // last y event position
private:
bool fIsHelpsPrintActive;
public:
virtual void SetHelpsPrintActive(bool on) {fIsHelpsPrintActive = on;}
protected:
//! set/get fLastX/fLastY
......@@ -117,6 +122,8 @@ public:
*/
Bool_t Disconnect(TCanvas *c = 0x0);
virtual PeakCreator *GetPeakCreator() {return fCreator;}
//! Get formula that gives the with as a function of energy
virtual const TF1* GetDefaultPeakWidth() const
{ return fCreator->GetDefaultPeakFWHM(); }
......@@ -147,7 +154,7 @@ public:
virtual Bool_t RenamePeak(const Char_t* baseName = "Peak", Bool_t force = false);
//! Fit all peaks using the spectrum in the current pad
virtual void FitAll(const char* nameFunc = "gaus", Option_t* optFit = "RN", Option_t* optBkg = "lin"); //*MENU*
virtual void FitAll(const char* nameFunc = "gaus", Option_t* optFit = "RNE", Option_t* optBkg = "lin"); //*MENU*
//! Popup AddLink menu
virtual void PopupFitMenu();
......@@ -178,6 +185,10 @@ public:
virtual Bool_t SetParameter(const char* /*name*/, Double_t /*value*/) { return false; }
virtual Bool_t SetParameter(const char* /*name*/, Int_t /*value*/) { return false; }
virtual Bool_t SetParameter(const char* name, const TObject* value);
//! To get the parameters
virtual TParameter<Int_t> GetIntParameter(TString /*Name*/) { return TParameter<Int_t>(); }
virtual TParameter<Double_t> GetDoubleParameter(TString /*Name*/){ return TParameter<Double_t>(); }
//! Collect the peaks from the current pad
/*!
......@@ -189,9 +200,9 @@ public:
virtual void Print(Option_t* opt = "") const;
//! Handle Movement
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject* select);
void HandleMovement(Int_t eventType, Int_t eventX, Int_t eventY, TObject*);
ClassDef(BaseSpectrumPlayer, 0); // Base class for facilities to play with spectra
ClassDef(BaseSpectrumPlayer, 1); // Base class for facilities to play with spectra
};
} // end namespace
......
......@@ -52,6 +52,8 @@ set( with_dictionnaries
SymCorrelatedSpace
XGammaLink
GCondition
NDB
InnerNDB
)
set( without_dictionnaries
BaseENSDF
......
/***************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Jeremie Dudouet dudouet(AT)ipnl.in2p3.fr [2014] *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2014] *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
/** \file GWNuclearDataBase.cpp compiled in libGWPHYSICS.so */
#include "TSystem.h"
#include "TString.h"
#include "TSystemDirectory.h"
#include "TList.h"
#include "TObjArray.h"
#include "TObjString.h"
#include "Env.h"
#include "BashColor.h"
#include "InnerNDB.h"
using namespace Gw;
using namespace std;
InnerNDB::InnerNDB() :
ConcreteNDB(),
fInnerDataBaseName("Inner"),
fGammaSourcesName("GammaSources"),
fListOfGammaSourceFiles(0x0)
{
Init();
}
InnerNDB::InnerNDB(const char * name, const char * title) :
ConcreteNDB(name,title),
fInnerDataBaseName("Inner"),
fGammaSourcesName("GammaSources"),
fListOfGammaSourceFiles(0x0)
{
Init();
}
InnerNDB::~InnerNDB()
{
}
void InnerNDB::Init()
{
if(!gSystem->OpenDirectory(fDataBasePath))
{
fBashColor->SetErrorOut();
cout<<"[DataBaseError] Error ! DataBase path: "<<fDataBasePath<<" not found; ==> Default one \""<<Gw::Env::GetPath("NdbPath")<<"\" is taken !"<<endl;
fDataBasePath = Gw::Env::GetPath("NdbPath");
}
else
{
fBashColor->SetInfoOut();
cout<<"[DataBaseInfo] DataBase: "<<fDataBasePath<<" will be used !"<<endl;
fBashColor->ResetColor();
}
fInnerDataBasePath = fDataBasePath + "/" + fInnerDataBaseName;
if(!gSystem->OpenDirectory(fInnerDataBasePath))
{
fBashColor->SetErrorOut();
cout<<"[DataBaseError] Inner DataBase path: "<<fInnerDataBaseName<<" not found in "<<fDataBasePath<<"; ==> Default one \"Inner\" is taken !"<<endl;
fInnerDataBaseName = "Inner";
fInnerDataBasePath = fDataBasePath + "/" + fInnerDataBaseName;
fBashColor->ResetColor();
}
else
{
fBashColor->SetInfoOut();
cout<<"[DataBaseInfo] "<<fInnerDataBaseName<<" DataBase: loaded !"<<endl;
fBashColor->ResetColor();
}
fGammaSourcesPath = fInnerDataBasePath + "/" + fGammaSourcesName;
if(!gSystem->OpenDirectory(fGammaSourcesPath))
{
fBashColor->SetWarningOut();
cout<<"[DataBaseError] No Gamma sources directory named: "<<fGammaSourcesName<<"; ==> Default one \"GammaSources\" is taken !"<<endl;
fGammaSourcesName = "GammaSources";
fGammaSourcesPath = fInnerDataBasePath + "/" + fGammaSourcesName;
fBashColor->ResetColor();
}
else
{
fBashColor->SetInfoOut();
cout<<"[DataBaseInfo] Gamma source files are located in ${DataBase}/"<<fInnerDataBaseName<<"/"<<fGammaSourcesName<<endl;
GetListOfSourceFiles();
fBashColor->ResetColor();
}
fBashColor->ResetColor();
}
void InnerNDB::SetInnerDataBase(TString name)
{
fInnerDataBaseName = name;
Init();
}
void InnerNDB::GetListOfSourceFiles()
{
TSystemDirectory Dir;
Dir.SetDirectory(fGammaSourcesPath);
fListOfGammaSourceFiles = Dir.GetListOfFiles();
fListOfGammaSourceFiles->SetName("ListOfGammaSourceFiles");
fListOfGammaSourceFiles->Remove(fListOfGammaSourceFiles->FindObject(".")); // Pour supprimer /.
fListOfGammaSourceFiles->Remove(fListOfGammaSourceFiles->FindObject("..")); // Pour supprimer /.
fListOfGammaSourceFiles->Sort();
}
void InnerNDB::Print(const char *option) const
{
TString StrOpt = option;
if(StrOpt =="*" || StrOpt.Contains("GammaSources"))
{
fBashColor->SetInfoOut();
cout<<"List of available Sources:"<<endl;
fListOfGammaSourceFiles->Print();
fBashColor->ResetColor();
}
}
std::vector<GammaSourceRay *> InnerNDB::GetGammaSource(TString SourceName, double EMin, double IMin, TString Opt)
{
TString SourceFilePath = fGammaSourcesPath + "/" + SourceName + ".sou";
if(!gSystem->IsFileInIncludePath(SourceFilePath))
{
fBashColor->SetWarningOut();
cout<<"No source file in "<<fGammaSourcesPath<<" for "<<SourceName<<" source !"<<endl;
Print("GammaSources");
return std::vector < Gw::GammaSourceRay* >();
fBashColor->ResetColor();
}
std::ifstream FileIn;
FileIn.open (SourceFilePath.Data(), std::ifstream::in);
string line;
TString Buffer;
const char* tab = "\t";
std::vector < Gw::GammaSourceRay* > ListOfGammas;
while(FileIn)
{
getline(FileIn,line);
Buffer = line;
if(Buffer=="")break;
if(Buffer.BeginsWith("#") || Buffer.BeginsWith("A")) continue;
Int_t i=0;
TString toto[20];
TObjArray *loa=Buffer.Tokenize(tab);
TIter next(loa);
TObjString *os=0;
while((os=(TObjString *)next()))
{
toto[i] = os->GetString();
i++;
}
TString DecayMode = toto[4].ReplaceAll(" ","").ReplaceAll(tab,"");
TString Daughter = toto[7].ReplaceAll(" ","").ReplaceAll(tab,"");
TString RadSubType = toto[9].ReplaceAll(" ","").ReplaceAll(tab,"");
double LifeTime = toto[6].ReplaceAll(" ","").ReplaceAll(tab,"").Atof();
double E = toto[10].ReplaceAll(" ","").ReplaceAll(tab,"").Atof();
double dE = toto[11].ReplaceAll(" ","").ReplaceAll(tab,"").Atof();
double I = toto[14].ReplaceAll(" ","").ReplaceAll(tab,"").Atof();
double dI = toto[15].ReplaceAll(" ","").ReplaceAll(tab,"").Atof();
if(E<EMin) continue;
if(I<IMin) continue;
if(Opt.Contains("NoXR") && RadSubType.Contains("XR")) continue;
cout<<DecayMode<<tab<<Daughter<<tab<<RadSubType<<tab<<LifeTime<<tab<<E<<tab<<dE<<tab<<I<<tab<<dI<<endl;
GammaSourceRay *Gamma = new GammaSourceRay(Form("%s_%.0lf",SourceName.Data(),E),Form("%s_%.0lf",SourceName.Data(),E));
Gamma->Emmiter = SourceName;
Gamma->Daughter = Daughter;
Gamma->DecayMode = DecayMode;
Gamma->RadSubType = RadSubType;
Gw::Measure<Double_t> *LifeTimeMeas;
LifeTimeMeas = new Gw::Measure<Double_t>();
LifeTimeMeas->SetValue(LifeTime);
LifeTimeMeas->SetError(0.);
Gamma->LifeTime = LifeTimeMeas;
Gw::Measure<Double_t> *IntensityMeas;
IntensityMeas = new Gw::Measure<Double_t>();
IntensityMeas->SetValue(I);
IntensityMeas->SetError(dI);
Gamma->Intensity = IntensityMeas;
Gw::Measure<Double_t> *EnerMeas;
EnerMeas = new Gw::Measure<Double_t>();
EnerMeas->SetValue(E);
EnerMeas->SetError(dE);
Gamma->Energy = EnerMeas;
ListOfGammas.push_back(Gamma);
}
return ListOfGammas;
}
ClassImp(InnerNDB);
/***************************************************************************
* Copyright (c) IPNL, IN2P3, CNRS *
* Contibutor(s) : *
* Jeremie Dudouet dudouet(AT)ipnl.in2p3.fr [2014] *
* Olivier Stezowski stezow(AT)ipnl.in2p3.fr [2014] *