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}) diff --git a/g4irt/include/g4dRIChOptics.hh b/g4irt/include/g4dRIChOptics.hh index 7678db0..dbefeef 100644 --- a/g4irt/include/g4dRIChOptics.hh +++ b/g4irt/include/g4dRIChOptics.hh @@ -14,9 +14,14 @@ #include "G4LogicalSkinSurface.hh" #include "G4tgbMaterialMgr.hh" #include "G4tgbVolumeMgr.hh" +#include "G4Version.hh" #include +using std::cout; +using std::cerr; +using std::endl; + /* * Service Classes */ @@ -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 @@@ diff --git a/source/Materials.cc b/source/Materials.cc index 2be7e2c..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 @@ -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_) @@ -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 energy; + std::vector 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); } @@ -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_]; @@ -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; { @@ -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); @@ -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 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;