Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake for root and Geant4 version changes #1

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
51 changes: 45 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,48 @@ endif()

#----------------------------------------------------------------------------

## Some dependency above clearly pulls in a ressult of
## find_package (XerxesC)
# message ("XercesC_FOUND = ${XercesC_FOUND}")
# message ("XercesC_INCLUDE_DIR = ${XercesC_INCLUDE_DIR}")
# message ("XercesC_LIBRARIES = ${XercesC_LIBRARIES}")

include_directories(
${Geant4_INCLUDE_DIR}
${ROOT_INCLUDE_DIRS}

${IRT}/include/IRT
${BMF}/include
${HEPMC3}/include
${XERCES}/include

${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/g4irt/include
)

file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h )
if(DEFINED XERCES)
include_directories(
${XERCES}/include
)
elseif(${XercesC_FOUND})
include_directories(
XercesC_INCLUDE_DIR
)
endif()

# file(GLOB headers ${PROJECT_SOURCE_DIR}/include/*.h )
SET( headers
include/tuning.cc.h
include/fixed.h
include/tuning.ak.h
include/Materials.h
include/RunAction.h
include/MagneticField.h
include/tuning.xx.h
include/DetectorConstruction.h
include/PrimaryGeneratorAction.h
include/tuning.h
include/TofPetMultiColumn.h
)

SET(G4IRT_LIB g4irt)
SET(PFRICH_EXE pfrich)
Expand Down Expand Up @@ -79,10 +107,16 @@ SET( sources
${PROJECT_SOURCE_DIR}/source/DetectorConstruction.cc
)

SET( XML_SRC
${PROJECT_SOURCE_DIR}/source/XmlReader.cc
)

if(DEFINED XERCES OR XercesC_FOUND )
SET( XML_SRC
${PROJECT_SOURCE_DIR}/source/XmlReader.cc
)
SET( headers
${headers}
include/XmlTree.h
)
endif()

ADD_LIBRARY( ${G4IRT_LIB} SHARED ${G4IRT_SRC} )
TARGET_LINK_LIBRARIES(${G4IRT_LIB} ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} -L${IRT}/lib IRT)

Expand All @@ -98,11 +132,16 @@ if(DEFINED HEPMC3)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHEPMC3")
target_link_libraries(${PFRICH_EXE} -L${HEPMC3}/lib -L${HEPMC3}/lib64 HepMC3)
endif()

if(DEFINED XERCES)
SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DXERCES")
target_link_libraries(${PFRICH_EXE} -L${XERCES}/lib -L${XERCES}/lib64 xerces-c)
elseif(${XercesC_FOUND})
add_compile_definitions ( XERCES )
target_link_libraries(${PFRICH_EXE} ${XercesC_LIBRARIES} )
endif()


#----------------------------------------------------------------------------

#add_executable( xmlreader ${XML_SRC})
Expand Down
18 changes: 17 additions & 1 deletion g4irt/include/g4dRIChOptics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
#include "G4LogicalSkinSurface.hh"
#include "G4tgbMaterialMgr.hh"
#include "G4tgbVolumeMgr.hh"
#include "G4Version.hh"

#include <tuning.h>

using std::cout;
using std::cerr;
using std::endl;

/*
* Service Classes
*/
Expand Down Expand Up @@ -153,13 +158,24 @@ protected:

// add properties to the MaterialPropertiesTable and link to material
void setMatPropTable(int nEntries) {
#if G4VERSION_NUMBER < 1070
if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries)->SetSpline(true);
#else
if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries, false, true);
#endif // version < 10.7
#ifndef _DISABLE_ABSORPTION_
#if G4VERSION_NUMBER < 1070
if (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries)->SetSpline(true);
#else
if (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries, false, true);
#endif // version < 10.7
#endif
#ifndef _DISABLE_RAYLEIGH_SCATTERING_
#if G4VERSION_NUMBER < 1070
if (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries)->SetSpline(true);
#else
if (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries, false, true);
#endif // version < 10.7
#endif
// pTable->AddConstProperty("SCINTILLATIONYIELD", 0. / MeV); // @@@ TBC @@@
// pTable->AddConstProperty("RESOLUTIONSCALE", 1.0); // @@@ TBC @@@
Expand Down
44 changes: 34 additions & 10 deletions source/Materials.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "G4Element.hh"
#include "G4Material.hh"
#include "G4NistManager.hh"
#include "G4Version.hh"

#include <TString.h>

Expand All @@ -22,6 +23,10 @@
// Does not make sense to spoil tuning.h with this number;
#define _ACRYLIC_DENSITY_ (1.18*g/cm3)

using std::cout;
using std::cerr;
using std::endl;

// -------------------------------------------------------------------------------------

Materials::Materials( void ): CherenkovWaveLengthRange(_WLDIM_, _NU_MIN_, _NU_STEP_)
Expand Down Expand Up @@ -152,15 +157,23 @@ void Materials::DefineMaterials( void )
unsigned riDim = wl.size();

// FIXME: use constant for now;
#if G4VERSION_NUMBER < 1070
G4double energy[riDim], refractiveIndex[riDim];
for(int iq=riDim-1; iq>=0; iq--) {
energy [iq] = (1240.0/wl[iq])*eV;
refractiveIndex[iq] = ri[iq];
} //for iq
#else
std::vector<G4double> energy;
std::vector<G4double> refractiveIndex;
for(int iq=riDim-1; iq>=0; iq--) {
energy.push_back( (1240.0/wl[iq])*eV );
refractiveIndex.push_back( ri[iq] );
} //for iq
#endif // version < 10.7

G4MaterialPropertiesTable* fsMPT = new G4MaterialPropertiesTable();
fsMPT->AddProperty("RINDEX", energy, refractiveIndex, riDim);

fsMPT->AddProperty("RINDEX", energy, refractiveIndex, riDim );
m_FusedSilica->SetMaterialPropertiesTable(fsMPT);
}

Expand All @@ -183,7 +196,6 @@ void Materials::DefineMaterials( void )

aerogel->AddElement(m_Si, 1);
aerogel->AddElement(m_O, 2);

#ifdef _AEROGEL_REFRACTIVE_INDEX_
// FIXME: use constant for now;
G4double refractiveIndex[_WLDIM_];
Expand All @@ -199,13 +211,11 @@ void Materials::DefineMaterials( void )
aerogel->SetRIChOptics(new g4dRIChAerogel(aerogel));
// FIXME: tuned model#3 to n ~ 1.02 @ 400ns (which corresponds to 110 mg/cm^3 density);
aerogel->GetRIChOptics()->setOpticalParams(3);
aerogel->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);
// kk aerogel->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);
#endif

_m_Aerogel[density[il]] = aerogel;
} //for il
}

#ifdef XERCES
// Belle II aerogel, two types;
{
Expand Down Expand Up @@ -379,11 +389,11 @@ void Materials::DefineMaterials( void )
#else
m_Acrylic->SetRIChOptics(new g4dRIChFilter(m_Acrylic));
m_Acrylic->GetRIChOptics()->setOpticalParams(_ACRYLIC_WL_CUTOFF_);
m_Acrylic->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);
// kk m_Acrylic->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);
#endif
}
#endif

// C2F6 as a gas radiator option;
{
m_C2F6 = new G4RadiatorMaterial("C2F6", 5.7*mg/cm3, 2);
Expand All @@ -393,9 +403,23 @@ void Materials::DefineMaterials( void )

m_C2F6->SetRIChOptics(new g4dRIChGas(m_C2F6));
m_C2F6->GetRIChOptics()->setOpticalParams();
m_C2F6->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);
}

// kk: We hope that the following is simply not needed
// Note that the version number can be checked with #if G4VERSION_NUMBER < 1070
// // m_C2F6->GetRIChOptics()->pTable->GetProperty("RINDEX")->SetSpline(true);

// If it is, the following should be a hacky solution
// auto mpv = m_C2F6->GetRIChOptics()->pTable->GetProperty("RINDEX");
// auto nEntries= mpv->GetVectorLength();
// std::vector<G4double> scaledE;
// std::vector<G4double> scaledN;
// for (std::size_t i=0; i<nEntries; ++i){
// scaledE[i] = mpv->Energy(i);
// scaledN[i] = (*mpv)[i];
// }
// (*mpv) = *(new G4MaterialPropertyVector(scaledE, scaledN, true));
}

// Bialkali photocathode;
{
// Well, the only part what matters here is the refractive index; density is fake;
Expand Down