From 5ab9a10b5f864e29398add3f9ee3257f166c3b91 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 17 Aug 2023 15:27:28 -0400 Subject: [PATCH 1/7] Spline boolean fix --- g4irt/include/g4dRIChOptics.hh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/g4irt/include/g4dRIChOptics.hh b/g4irt/include/g4dRIChOptics.hh index 7678db0..2690243 100644 --- a/g4irt/include/g4dRIChOptics.hh +++ b/g4irt/include/g4dRIChOptics.hh @@ -17,6 +17,10 @@ #include +using std::cout; +using std::cerr; +using std::endl; + /* * Service Classes */ @@ -153,13 +157,15 @@ protected: // add properties to the MaterialPropertiesTable and link to material void setMatPropTable(int nEntries) { - - if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries)->SetSpline(true); + // if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries)->SetSpline(true); + if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries, false, true); #ifndef _DISABLE_ABSORPTION_ - if (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries)->SetSpline(true); + // if (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries)->SetSpline(true); + if (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries, false, true); #endif #ifndef _DISABLE_RAYLEIGH_SCATTERING_ - if (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries)->SetSpline(true); + // if (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries)->SetSpline(true); + if (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries, false, true); #endif // pTable->AddConstProperty("SCINTILLATIONYIELD", 0. / MeV); // @@@ TBC @@@ // pTable->AddConstProperty("RESOLUTIONSCALE", 1.0); // @@@ TBC @@@ From f55e2a6ae2a4948595a269e97bde67ca33387dcb Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 17 Aug 2023 15:32:39 -0400 Subject: [PATCH 2/7] Changed to vector signature of AddProperty for a strange bug; removed unnecessary (?) spline bool --- source/Materials.cc | 46 ++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/source/Materials.cc b/source/Materials.cc index dfee1ce..bf740fc 100644 --- a/source/Materials.cc +++ b/source/Materials.cc @@ -22,6 +22,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_) @@ -115,15 +119,20 @@ void Materials::DefineMaterials( void ) unsigned riDim = wl.size(); // FIXME: use constant for now; - G4double energy[riDim], refractiveIndex[riDim]; + // G4double energy[riDim], refractiveIndex[riDim]; + std::vector energy; + std::vector refractiveIndex; + for(int iq=riDim-1; iq>=0; iq--) { - energy [iq] = (1240.0/wl[iq])*eV; - refractiveIndex[iq] = ri[iq]; + // for(int iq=0; iqAddProperty("RINDEX", energy, refractiveIndex, riDim); - + fsMPT->AddProperty("RINDEX", energy, refractiveIndex, riDim ); m_FusedSilica->SetMaterialPropertiesTable(fsMPT); } @@ -146,7 +155,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_]; @@ -162,13 +170,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; { @@ -303,11 +309,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); @@ -317,9 +323,22 @@ 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 + // // 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 scaledE; + // std::vector scaledN; + // for (std::size_t i=0; iEnergy(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; @@ -334,6 +353,7 @@ void Materials::DefineMaterials( void ) refractiveIndex[iq] = _BIALKALI_REFRACTIVE_INDEX_; G4MaterialPropertiesTable* bialkaliMPT = new G4MaterialPropertiesTable(); + cout << "hello bia" << endl; bialkaliMPT->AddProperty("RINDEX", GetPhotonEnergies(), refractiveIndex, _WLDIM_); m_Bialkali->SetMaterialPropertiesTable(bialkaliMPT); From a30de0a20cf66073aecde88ddfe1dfb7db6d9e85 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 17 Aug 2023 15:33:31 -0400 Subject: [PATCH 3/7] Changed to vector signature of AddProperty for a strange bug; removed unnecessary (?) spline bool --- source/Materials.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Materials.cc b/source/Materials.cc index bf740fc..7e8a04d 100644 --- a/source/Materials.cc +++ b/source/Materials.cc @@ -353,7 +353,6 @@ void Materials::DefineMaterials( void ) refractiveIndex[iq] = _BIALKALI_REFRACTIVE_INDEX_; G4MaterialPropertiesTable* bialkaliMPT = new G4MaterialPropertiesTable(); - cout << "hello bia" << endl; bialkaliMPT->AddProperty("RINDEX", GetPhotonEnergies(), refractiveIndex, _WLDIM_); m_Bialkali->SetMaterialPropertiesTable(bialkaliMPT); From 1f5733d7395d44b9d90f64e558fd12c172aae495 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 17 Aug 2023 15:35:45 -0400 Subject: [PATCH 4/7] Fixed optionality and usage of XercesC --- CMakeLists.txt | 51 ++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bfe87ac..7509c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,12 @@ 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} @@ -44,13 +50,35 @@ include_directories( ${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) @@ -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) @@ -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}) From 9ad856c445916cb7b7b46ab16bf8c0a6b85415a8 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Mon, 21 Aug 2023 11:55:34 -0400 Subject: [PATCH 5/7] testing write privileges --- delme | 1 + 1 file changed, 1 insertion(+) create mode 100644 delme diff --git a/delme b/delme new file mode 100644 index 0000000..6c78478 --- /dev/null +++ b/delme @@ -0,0 +1 @@ +delme From b6a7b8bbf82797e2fae148b763def935e8ceec61 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Tue, 5 Dec 2023 12:09:45 -0500 Subject: [PATCH 6/7] cleanup --- delme | 1 - 1 file changed, 1 deletion(-) delete mode 100644 delme diff --git a/delme b/delme deleted file mode 100644 index 6c78478..0000000 --- a/delme +++ /dev/null @@ -1 +0,0 @@ -delme From ae6df36a04d2db9ee79a55e52bc6fbf72a84ae27 Mon Sep 17 00:00:00 2001 From: Kolja Kauder Date: Thu, 7 Dec 2023 10:33:07 -0500 Subject: [PATCH 7/7] Support older and newer Geant4 API for G4MaterialPropertiesTable --- g4irt/include/g4dRIChOptics.hh | 16 +++++++++++++--- source/Materials.cc | 17 +++++++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/g4irt/include/g4dRIChOptics.hh b/g4irt/include/g4dRIChOptics.hh index 2690243..dbefeef 100644 --- a/g4irt/include/g4dRIChOptics.hh +++ b/g4irt/include/g4dRIChOptics.hh @@ -14,6 +14,7 @@ #include "G4LogicalSkinSurface.hh" #include "G4tgbMaterialMgr.hh" #include "G4tgbVolumeMgr.hh" +#include "G4Version.hh" #include @@ -157,15 +158,24 @@ protected: // add properties to the MaterialPropertiesTable and link to material void setMatPropTable(int nEntries) { - // if (scaledN!=NULL) pTable->AddProperty("RINDEX", scaledE, scaledN, nEntries)->SetSpline(true); +#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 (scaledA!=NULL) pTable->AddProperty("ABSLENGTH", scaledE, scaledA, nEntries)->SetSpline(true); +#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 (scaledS!=NULL) pTable->AddProperty("RAYLEIGH", scaledE, scaledS, nEntries)->SetSpline(true); +#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 @@@ diff --git a/source/Materials.cc b/source/Materials.cc index 3875ab5..43c5d83 100644 --- a/source/Materials.cc +++ b/source/Materials.cc @@ -2,6 +2,7 @@ #include "G4Element.hh" #include "G4Material.hh" #include "G4NistManager.hh" +#include "G4Version.hh" #include @@ -156,17 +157,20 @@ void Materials::DefineMaterials( void ) unsigned riDim = wl.size(); // FIXME: use constant for now; - // G4double energy[riDim], refractiveIndex[riDim]; +#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 energy; - std::vector refractiveIndex; - + std::vector refractiveIndex; for(int iq=riDim-1; iq>=0; iq--) { - // for(int iq=0; iqAddProperty("RINDEX", energy, refractiveIndex, riDim ); @@ -401,6 +405,7 @@ void Materials::DefineMaterials( void ) m_C2F6->GetRIChOptics()->setOpticalParams(); // 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