Commit 7621e8b0 authored by Anmol Arora's avatar Anmol Arora

Add the Necessary Files for Nudy and Modify the Top-Level CMake File to include…

Add the Necessary Files for Nudy and Modify the Top-Level CMake File to include the subdirectory Nudy
parent 28b1c0b3
......@@ -258,6 +258,7 @@ add_subdirectory (micromc)
#add_subdirectory (test-small)
add_subdirectory (cmstrack)
add_subdirectory (test-complex)
#add_subdirectory (Nudy)
if (CUDA)
add_subdirectory (vecprot_v2/cuda)
# Enable the Language Fortran
# Locate Sources and Headers for this project
# NB : Headers are also included
file(GLOB sources src/*.cxx src/*.f)
file(GLOB headers inc/T*.h)
# Generate the Dictionary
ROOT_GENERATE_DICTIONARY(NudyDict ${headers} MODULE libNudy LINKDEF inc/LinkDef.h)
# Add the executable, and link it to the Geant4 libraries
add_library(Nudy SHARED ${sources} NudyDict.cxx)
target_link_libraries(Nudy ${ROOT_LIBRARIES} Geom EG MathMore Graf)
# for some reason the installation process alters the libraries on Mac, and the program fails
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class TNudyCore+;
#pragma link C++ class TNudyENDF+;
#pragma link C++ class TNudyEndfTape+;
#pragma link C++ class TNudyEndfMat+;
#pragma link C++ class TNudyEndfFile+;
#pragma link C++ class TNudyEndfSec+;
#pragma link C++ class TNudyEndfCont+;
#pragma link C++ class TNudyEndfRecord+;
#pragma link C++ class TNudyEndfList+;
#pragma link C++ class TNudyEndfTab1+;
#pragma link C++ class TNudyEndfTab2+;
#pragma link C++ class TNudyEndfINTG+;
#pragma link C++ class TNudyElementTable+;
#pragma link C++ class TNudyElementRN+;
#pragma link C++ class TNudyManager+;
#pragma link C++ class TNudyDB+;
#pragma link C++ class TNudyLibrary+;
#pragma link C++ class TNudySubLibrary+;
#pragma link C++ class TVNudyModel+;
#pragma link C++ class TNudyAlias+;
#pragma link C++ class TNudyAliasCont+;
#ifndef ROOT_TNudyAlias
#define ROOT_TNudyAlias
#include <TObject.h>
#include <TRandom.h>
#include "TNudyCore.h"
// Provides random number generation using a discrete
// probability distribution using the Alias Method
class TNudyAlias : public TObject {
Int_t fLen; //Length of data
//Alias table
Double_t *fP; //[fLen]
Double_t *fX; //[fLen]
Double_t *fA; //[fLen]
Double_t *fR; //[fLen]
TRandom *fRnd; //Uniform random number generation
virtual ~TNudyAlias();
TNudyAlias(Double_t *p,Double_t *x,const Int_t len,UInt_t seed=65539);
void DumpTable();
Double_t Random();
Double_t GetP(Int_t i) {if(i<fLen) return fP[i]; else return -1;};
Double_t GetX(Int_t i) {if(i<fLen) return fX[i]; else return -1;};
Int_t GetLen() {return fLen;}
class TNudyComStruct {
//Class to communicate between thread handler and objects
TNudyAlias *fAl;
Int_t fI;
TNudyComStruct(TNudyAlias *a,Int_t j) {fAl=a;fI=j;}
virtual ~TNudyComStruct() {}
static void* ThreadHandle(void *ptr);
Double_t *fMult; //! When generating using a multithreaded approach
Int_t fMultLen;//! Number of random values to be generated using the multi threaded approach
Double_t* Randoms(Int_t n);
#ifndef ROOT_TNudyAliasCont
#define ROOT_TNudyAliasCont
#include <TObject.h>
#include <TRandom.h>
#include <TArrayD.h>
#include "TNudyAlias.h"
#include "TNudyCore.h"
// This class takes a continuous piecewise linear probability
// distribution and generates a random number according to that
// probability distributions using the Alias method
class TNudyAliasCont : public TObject {
Int_t fLen; // Length of data
TNudyAlias *fChooseBin; // Use alias method to choose bin
//Probability distribution
TArrayD *fP; // Probability distribution
TArrayD *fX; // Energy distribution
TArrayD *fInterX; // Built Energy distribution
TArrayD *fInterP; // Built Probability distribution
TArrayD *fTx; //! Temporary Energy distribution
TArrayD *fTp; //! Temporary Probability distribution
Double_t fTa; //! Temporary Alpha value
Double_t fInterAlpha; // Alpha for the next distribution
TRandom *fRan; // To generate unifrom random numbers
TRandom *fRnd; // To generate unifrom random numbers
Double_t fAlpha;// Stores the number which identifies the distribution
TNudyAliasCont(Double_t *p,Double_t *x,const Int_t len,Double_t alpha,UInt_t seed=65539);
TNudyAliasCont(TArrayD *data,Double_t alpha,UInt_t seed);
void Initialize(Double_t *p,Double_t *x,const Int_t len,Double_t alpha,UInt_t seed=65539);
virtual ~TNudyAliasCont();
void DumpTable();
Double_t GetP(Int_t i) {if(i>=0 && i<fLen) return fP->GetAt(i); else return -1;}
Double_t GetX(Int_t i) {if(i>=0 && i<fLen) return fX->GetAt(i); else return -1;}
Double_t GetAlpha() {return fAlpha;}
Double_t Uniform(Double_t x=1) {if(fRnd) return fRnd->Uniform(x); else return -1;}
Double_t RandomBin() {if(fChooseBin) return fChooseBin->Random(); else return -1;}
Double_t Random(IntScheme_t iScheme=kLinear,Int_t binNo=-1,AliasDist_t arr=kOriginal,Double_t r1 = -1,Double_t r2 = -1);
Double_t ImprovedInterpolation(Double_t alpha);
Double_t SelectBin(Double_t ein, AliasDist_t distribution=kOriginal);
static void BuildIntermediate(TNudyAliasCont *x,const Int_t len);
static Double_t StatisticalInterpolation(TNudyAliasCont *dist1, TNudyAliasCont *dist2,Double_t alpha);
Double_t *fMult; //! Random numbers to be generated in parallel
Int_t fMultLen; //! Number if random numbres to be generated in parallel
Double_t* Randoms(Int_t n,IntScheme_t iScheme=kLinear);
#ifndef ROOT_TNudyCore
#define ROOT_TNudyCore
#include <TObject.h>
#include <TGeoElement.h>
#include <TGeoManager.h>
#include <TPDGCode.h>
#include <TParticlePDG.h>
#include <TDatabasePDG.h>
#include <TParticle.h>
#include <TList.h>
#include <TSystem.h>
#include "TNudyTypes.h"
//Set to turn on multi threaded generation of random numbers
class TNudyCore : public TNamed {
static TNudyCore* fgInstance;
TGeoManager *fGeom;
TGeoElementTable *fTable;
TDatabasePDG *fPdgDB;
TList *fListOfObjects;
TNudyCore(const TNudyCore& core): TNamed(core){}
TNudyCore& operator=(const TNudyCore& core)
{if(this!=&core){TNamed::operator=(core);}return *this;}
virtual ~TNudyCore();//Public Destructor
static TNudyCore* Instance();//Returns Instance of TNudyManager
//Calculation functions
Double_t LinearInterpolation(Double_t x1,Double_t y1,Double_t x2,Double_t y2,Double_t x);//Linear Interpolation
Double_t BilinearInterploation(Double_t x1,Double_t y1,Double_t x2,Double_t y2,Double_t z11,Double_t z12,Double_t z21,Double_t z22,Double_t x,Double_t y);//Biliniear Interpolation
void TrapezoidalIntegral(Double_t *xpts, Double_t *ypts,const Int_t npts,Double_t *out);//Calculates integral of discrete points
void CumulativeIntegral(Double_t *x, Double_t *y, Double_t *q, Int_t len);
Int_t BinarySearch(Double_t *array,Int_t len, Double_t val);
Double_t InterpolateScale(Double_t x[2],Double_t y[2],Int_t law, Double_t xx);
Double_t Interpolate(Int_t *nbt, Int_t *interp, Int_t nr, Double_t *x, Double_t*y, Int_t np, Double_t xx);
char * ExpandReaction(Reaction_t reac);
//Model Key checking/generation functions
Int_t IsMaterial(const TGeoElementRN* endf, const char* key);
Int_t IsTemperature(const ULong_t temp,const char *key);
Int_t IsReaction(const Reaction_t r, const char *key);
char * GetKey(const TGeoElementRN *mat,Reaction_t reac,ULong_t temp);
//Uniform access functions
TGeoElementTable* GetElementTable(){return fTable;}
TDatabasePDG* GetDatabasePDG(){return fPdgDB;}
TGeoElementRN* GetMaterial(Int_t ENDFcode) { return fTable->GetElementRN(ENDFcode);}
TGeoElementRN* GetMaterial(Int_t a, Int_t z, Int_t iso = 0) { return fTable->GetElementRN(a,z,iso);}
const THashList* GetParticleList(){return fPdgDB->ParticleList();}
TParticlePDG* GetParticlePDG(Int_t pdgCode);
TParticlePDG* GetParticlePDG(const char* name);
TParticle* GetParticle(Int_t pdgCode);
TParticle* GetParticle(const char* name);
void MemProfile();
#ifndef ROOT_TNudyDB
#define ROOT_TNudyDB
#include <THashTable.h>
#include <TFile.h>
#include <TList.h>
#include "TNudyCore.h"
#include "TNudyLibrary.h"
class TNudyDB : public TNamed {
TNudyDB(const char *name, const char *title, const char *file);
virtual ~TNudyDB();
void AddLibrary(const char *name, const char* file); //Add a Library to a Nudy Database from a RENDF file
void RemoveLibrary(const char *name); //Remove a Library from a Nudy Databse
TList* GetEntries(); //Get a List of Libraries in the Nudy Database
TFile* GetDBFile() {return fDB;} //Get a pointer to the database file
TFile *fDB; //! Database data file
#ifndef ROOT_TNudyENDF
#define ROOT_TNudyENDF
// @(#)root/meta:$Id: TNuEndf.h 29000 2009-06-15 13:53:52Z rdm $
// Author: F.Carminati 02/05/09
This is the main class to read a file in ENDF format and write a file
in R-ENDF format
class TFile;
class TNudyEndfTape;
class TNudyEndfMat;
class TNudyEndfFile;
class TNudyEndfSec;
class TNudyEndfCont;
class TNudyEndfList;
class TNudyEndfTab1;
class TNudyEndfTab2;
class TNudyEndfINTG;
#include <TObject.h>
#include <TList.h>
#include <Riostream.h>
#include <RConfig.h>
#ifndef WIN32
# define type_of_call
# define DEFCHARD const char*
# define DEFCHARL , const int
# define PASSCHARD(string) string
# define PASSCHARL(string) , strlen(string)
# define type_of_call _stdcall
# define DEFCHARD const char* , const int
# define DEFCHARL
# define PASSCHARD(string) string, strlen(string)
# define PASSCHARL(string)
/* FORTRAN Reading Routines */
#ifndef WIN32
#define FGetMTF fgetmtf_
#define FGetCONT fgetcont_
#define FGetFloat fgetfloat_
#define FGetInt fgetint_
#define FGetINTG fgetintg_
#define FGetFloat FGETFLOAT
#define FGetInt FGETINT
extern "C" type_of_call {
void FGetMTF(DEFCHARD str, Int_t mtf[4] DEFCHARL);
void FGetCONT(DEFCHARD str, Double_t c[2], Int_t nl[4], Int_t mtf[4] DEFCHARL);
void FGetFloat(DEFCHARD str, Double_t arr[6] DEFCHARL);
void FGetInt(DEFCHARD str, Int_t iarr[6] DEFCHARL);
void FGetINTG(DEFCHARD str, Int_t &ndigit,Int_t ij[2], Int_t kij[18], Int_t mtf[4] DEFCHARL);
#define LINLEN 256
class TNudyENDF: public TObject {
TNudyENDF(const Char_t *nFileENDF, const Char_t *nFileRENDF, Option_t *opt="new",UChar_t loglev=0);
virtual ~TNudyENDF();
void SetLogLev(UChar_t loglev) {fLogLev=loglev;}
UChar_t GetLogLev() const {return fLogLev;}
void Process();
void Process(TNudyEndfMat *mat);
void Process(TNudyEndfFile *file);
void Process(TNudyEndfSec* sec);
void Process(TNudyEndfCont *secCont);
void Process(TNudyEndfList *secList);
void Process(TNudyEndfTab1 *secTab1);
void Process(TNudyEndfTab2 *secTab2);
void Process(TNudyEndfINTG *secINTG);
void ProcessF1(TNudyEndfSec* sec);
void ProcessF2(TNudyEndfSec* sec);
void ProcessF3(TNudyEndfSec* sec);
void ProcessF4(TNudyEndfSec* sec);
void ProcessF5(TNudyEndfSec* sec);
void ProcessF6(TNudyEndfSec* sec);
void ProcessF7(TNudyEndfSec* sec);
void ProcessF8(TNudyEndfSec* sec);
void ProcessF9(TNudyEndfSec* sec);
void ProcessF10(TNudyEndfSec* sec);
void ProcessF12(TNudyEndfSec* sec);
void ProcessF13(TNudyEndfSec* sec);
void ProcessF14(TNudyEndfSec* sec);
void ProcessF15(TNudyEndfSec* sec);
void ProcessF23(TNudyEndfSec* sec);
void ProcessF26(TNudyEndfSec* sec);
void ProcessF27(TNudyEndfSec* sec);
void ProcessF28(TNudyEndfSec* sec);
void ProcessF30(TNudyEndfSec* sec);
void ProcessF31(TNudyEndfSec* sec);
void ProcessF32(TNudyEndfSec* sec);
void ProcessF33(TNudyEndfSec* sec);
void ProcessF34(TNudyEndfSec* sec);
void ProcessF35(TNudyEndfSec* sec);
void ProcessF40(TNudyEndfSec* sec);
void GetSEND(const Int_t pmtf[3]);
void GetFEND(const Int_t pmtf[3]);
void GetMEND(const Int_t pmtf[3]);
void GetTEND();
void ToEndSec();
TNudyEndfTape* GetTape(){return this->fTape;}
void CheckSEND(const Int_t pmtf[3]) const;
void CheckFEND(const Int_t pmtf[3]) const;
void CheckMEND(const Int_t pmtf[3]) const;
void CheckTEND() const;
void GetMTF(Int_t mtf[4]) const {
void GetCONT(Double_t c[2], Int_t nl[4], Int_t mtf[4]) const {
FGetCONT(PASSCHARD(fLine), c, nl, mtf PASSCHARL(fLine));
void GetFloat(Double_t c[6]) const {
FGetFloat(PASSCHARD(fLine), c PASSCHARL(fLine));
void GetInt(Int_t n[6]) const {
FGetInt(PASSCHARD(fLine), n PASSCHARL(fLine));
void GetINTG(Int_t ndigit, Int_t ij[2] ,Int_t kij[18], Int_t mtf[4] )const{
FGetINTG(PASSCHARD(fLine), ndigit, ij, kij, mtf PASSCHARL(fLine));
void DumpENDF(Int_t flags);
static const char fkElNam[119][4];
static const char fkElIso[4][2];
UChar_t fLogLev; // Log Level Flag
std::ifstream fENDF; //! Input fENDF tape
TFile *fRENDF; //! Output fRENDF file
Char_t fLine[LINLEN]; //! Buffer to read the line
TNudyEndfTape *fTape; //! Support link for the tape structure
TNudyEndfMat *fMat; //! Support link for the current material
ClassDef(TNudyENDF, 1) // class for an ENDF data file
#ifndef ROOT_TNudyElementRN
#define ROOT_TNudyElementRN
#include "RConfigure.h"
#include "Riostream.h"
#include "TGeoElement.h"
#include "TBox.h"
#include "TObject.h"
#include "TPaveText.h"
#include "TList.h"
#include "TColor.h"
#include "Rtypes.h"
#include "TColor.h"
#include "TRint.h"
#include <string.h>
#include "TStyle.h"
#include "TROOT.h"
class TNudyElementRN: public TObject{
int fCoSize;
Float_t fX,fY;
TGeoElementRN* fEle;
TBox* fBox;
TPaveText fInfo;
Color_t GetColor(Double_t halfLife);
static Double_t fCCodeRange[26];
static Int_t fCCodeColor[26][3];
Float_t fSize;
Float_t fScale;
Float_t fPadding;
TColor fColors[26];
TNudyElementRN(TGeoElementRN* elem,Float_t fX, Float_t fY);
virtual ~TNudyElementRN() {};
void Draw(Option_t* option="");
void Move(Float_t x, Float_t y);
void SetColorCode(TList* cCodeRange, TList* cCodeColor);
Int_t GetA() {return fEle->AtomicNo();}
Int_t GetZ() {return fEle->MassNo();}
ClassDef(TNudyElementRN,1) //Radio Nucleide Element
#ifndef ROOT_TNudyElementTable
#define ROOT_TNudyElementTable
#include "RConfigure.h"
#include "Riostream.h"
#include "TGeoElement.h"
#include "TGeoManager.h"
#include "TNudyElementRN.h"
#include "TCanvas.h"
#include "TObject.h"
#include "TBox.h"
#include "TList.h"
#include "TButton.h"
const Int_t kENABLED = 1;
const Int_t kDISABLED = 0;
class TNudyElementTable: public TObject{
Int_t fState;
Float_t fOx,fOy;
TGeoElementTable* fTable;
TBox fWindow;
TList fEleBox;
Float_t fLOD;
TCanvas* fRNTable;
TGeoManager* fGeom;
void DrawUI();
TList fControls;
void InitializeControls();
virtual ~TNudyElementTable();
void Draw(Option_t *option="");
void ZoomIn();
void ZoomOut();
void MoveUp();
void MoveDown();
void MoveLeft();
void MoveRight();
void Update();
ClassDef(TNudyElementTable,1) //Table of RadioNucleides
#ifndef ROOT_TNudyEndfCont
#define ROOT_TNudyEndfCont
// @(#)root/meta:$Id: TNuEndf.h 29000 2009-06-15 13:53:52Z rdm $
// Author: F.Carminati 02/05/09
This is the main class supporting an ENDF material in R-ENDF format
Units used
Quantity Units
energies electron-volts (eV)
angles dimensionless cosines of the angle
cross sections barns
temperatures Kelvin
mass units of the neutron mass
angular distrib probability per unit-cosine
energy distrib probability per eV
energy-angle dist probability per unit-cosine per eV
half life seconds
#include <Riostream.h>
#include <TObject.h>
//class TNudyEndfSec;
#include "TNudyEndfRecord.h"
class TNudyEndfCont: public TNudyEndfRecord {
TNudyEndfCont(Double_t c1, Double_t c2,
Int_t l1, Int_t l2, Int_t n1, Int_t n2);
virtual void SetCont(Double_t c1, Double_t c2,
Int_t l1, Int_t l2, Int_t n1, Int_t n2);
virtual Double_t GetC1() const {return fC1;}
virtual Double_t GetC2() const {return fC2;}
virtual Int_t GetL1() const {return fL1;}
virtual Int_t GetL2() const {return fL2;}
virtual Int_t GetN1() const {return fN1;}
virtual Int_t GetN2() const {return fN2;}
void DumpENDF(Int_t mat, Int_t mf, Int_t mt, Int_t& ns,Int_t flags);
static Char_t * F2F(Double_t f, char s[]);
Double_t fC1; // C1 of the CONT record
Double_t fC2; // C2 of the CONT record
Int_t fL1; // L1 of the CONT record
Int_t fL2; // L2 of the CONT record
Int_t fN1; // N1 of the CONT record
Int_t fN2; // N2 of the CONT record
#ifndef ROOT_TNudyEndfFile
#define ROOT_TNudyEndfFile
// @(#)root/meta:$Id: TNuEndf.h 29000 2009-06-15 13:53:52Z rdm $
// Author: F.Carminati 02/05/09
This is the main class supporting an ENDF File in R-ENDF format
Units used
Quantity Units
energies electron-volts (eV)
angles dimensionless cosines of the angle
cross sections barns
temperatures Kelvin
mass units of the neutron mass
angular distrib probability per unit-cosine
energy distrib probability per eV
energy-angle dist probability per unit-cosine per eV
half life seconds
//class TString;
//class TNudyEndfSec;
#include "TNudyEndfSec.h"
#include <Riostream.h>
#include <TObject.h>
#include <TList.h>
#include <RConfig.h>
class TNudyEndfFile: public TObject {
TNudyEndfFile(Int_t mat, Int_t mf);
virtual ~TNudyEndfFile();
const Char_t* GetName() const {return fName;}
Int_t GetMAT() const {return fMAT;}
Int_t GetMF() const {return fMF;}
void Add(TNudyEndfSec *sec) {fSecs->Add(sec);}
//TList fMF; //! List of the files of this material
void DumpENDF(Int_t flags);
TNudyEndfSec* GetSec(Int_t MT);
TList* GetSections(){return fSecs;}
Char_t fName[9]; // File Name
Int_t fMAT; // MAT number
Int_t fMF; // MF number
TList *fSecs; // List of the sections of this file
#ifndef ROOT_TNudyEndfINTG
#define ROOT_TNudyEndfINTG
#include <Riostream.h>
#include "TNudyEndfCont.h"
class TNudyEndfINTG: public TNudyEndfCont {
TNudyEndfINTG(Int_t nrow, Int_t ndigit);
Int_t* GetKIJ() {return fKIJ;}
Int_t GetNdigit(){return fNdigit;}
void SetIJ(Int_t ij[2]){fII = ij[0]; fJJ = ij[1];}
void SetNrow(Int_t nrow) { fNrow = nrow;}
void SetNdigit(Int_t ndigit){ fNdigit = ndigit;}
void SetKIJ(Int_t kij[18]);
void DumpENDF(Int_t mat, Int_t mf, Int_t mt, Int_t& ns, Int_t flags);
Int_t fKIJ[18];
Int_t fNrow;
Int_t fNdigit;
Int_t fII;
Int_t fJJ;
#ifndef ROOT_TNudyEndfList
#define ROOT_TNudyEndfList
// @(#)root/meta:$Id: TNuEndf.h 29000 2009-06-15 13:53:52Z rdm $
// Author: F.Carminati 02/05/09
This is the main class supporting an ENDF material in R-ENDF format
Units used
Quantity Units
energies electron-volts (eV)
angles dimensionless cosines of the angle
cross sections barns
temperatures Kelvin
mass units of the neutron mass