diff --git a/CMakeLists.txt b/CMakeLists.txt index cc74e088527db68ce006fe3fd4884ea890756292..f159227a8b73138f0d5698859e698d4382354ba9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,14 +14,13 @@ endif() #---Packages------------------------------------------------------------------------ add_subdirectory(DDCore) +add_subdirectory(DDGeant4) add_subdirectory(DDExamples/ILDExDet) add_subdirectory(DDExamples/CLICSiD) add_subdirectory(DDExamples/ILDExDisplay) add_subdirectory(DDExamples/ILDExReco) - -add_subdirectory(VGM/packages) add_subdirectory(DDExamples/ILDExSimu) diff --git a/DDCore/python/SystemOfUnits.py b/DDCore/python/SystemOfUnits.py index 95f6954733b0e81ccacadea61eace6f6a6c234bb..8657d5c7a6362d8131e3e2418a53f5b69d8e9e30 100644 --- a/DDCore/python/SystemOfUnits.py +++ b/DDCore/python/SystemOfUnits.py @@ -48,7 +48,7 @@ # # Length [L] # -millimeter = 1. +millimeter = 0.1 millimeter2 = millimeter*millimeter millimeter3 = millimeter*millimeter*millimeter diff --git a/DDCore/python/lcdd.py b/DDCore/python/lcdd.py index 6ff8805a845e97de8e8c3570f2a8ffd6e025f5fa..cb417f9e6fb5288317cdd24af76ae65a57f15480 100644 --- a/DDCore/python/lcdd.py +++ b/DDCore/python/lcdd.py @@ -145,7 +145,7 @@ def process_includes(lcdd, elem): #--------------------------------------------------------------------------------- def process_define(lcdd, elem): for c in elem.findall('constant'): - print 'Adding constant ...', c.get('name') + #print 'Adding constant ...', c.get('name') lcdd.addConstant(Constant(lcdd, c.get('name'),c.get('value'))) _toDictionary(c.get('name'),c.get('value')) #-- Make it known to the evaluator constants[c.get('name')] = c.getF('value') @@ -181,7 +181,7 @@ def process_materials(lcdd, elem): def process_material(lcdd, m): - print 'Adding material ...', m.get('name') + #print 'Adding material ...', m.get('name') density = m.find('D') radlen = m.find('RL') intlen = m.find('NIL') @@ -194,7 +194,6 @@ def process_material(lcdd, m): rl = (radlen is not None) and eval(radlen.get('value')+'*'+radlen.get('unit'),constants) or 0.0 il = (intlen is not None) and eval(intlen.get('value')+'*'+intlen.get('unit'),constants) or 0.0 #mat.SetRadLen(-rl, -il) - mat.Print() elts = [mat.GetElement(i).GetName() for i in range(mat.GetNelements())] for c in composites: nam = c.ref @@ -221,7 +220,7 @@ def process_material(lcdd, m): #---------------------------------------------------------------------------------- def process_display(lcdd, elem): for v in elem.findall('vis'): - print 'Adding vis ...', v.name + #print 'Adding vis ...', v.name visattr = VisAttr(lcdd,v.name) r = 'r' in v.keys() and v.getF('r') or 1.0 g = 'g' in v.keys() and v.getF('g') or 1.0 @@ -239,7 +238,7 @@ def process_display(lcdd, elem): if 'drawingStyle' in v.keys() : ds = v.get('drawingStyle') if ds == 'wireframe' : visattr.setDrawingStyle(VisAttr.WIREFRAME) - print visattr.toString() + #print visattr.toString() lcdd.addVisAttribute(visattr) def process_limits(lcdd, elem): diff --git a/DDCore/src/LCDDImp.cpp b/DDCore/src/LCDDImp.cpp index 2411ba0410a561a4473c27208143510bd5fe4e71..a3cc354417e8a96cdfb87d4a3a0867030395f4d8 100644 --- a/DDCore/src/LCDDImp.cpp +++ b/DDCore/src/LCDDImp.cpp @@ -110,21 +110,21 @@ void LCDDImp::create() { void LCDDImp::init() { LCDD& lcdd = *this; Box worldSolid(lcdd,"world_box","world_x","world_y","world_z"); - Material air = material("Air"); - Volume world(lcdd,"world_volume",worldSolid,air); + Material vacuum = material("Vacuum"); + Volume world(lcdd,"world_volume",worldSolid,vacuum); Tube trackingSolid(lcdd,"tracking_cylinder", 0., _toDouble("tracking_region_radius"), _toDouble("2*tracking_region_zmax"),2*M_PI); - Volume tracking(lcdd,"tracking_volume",trackingSolid, air); - world.placeVolume(tracking); + Volume tracking(lcdd,"tracking_volume",trackingSolid, vacuum); + //-->world.placeVolume(tracking); //Ref_t ref_world(lcdd,"world",world.refName()); //m_setup.append(ref_world); m_worldVol = world; m_trackingVol = tracking; - m_materialAir = air; + m_materialAir = material("Air"); m_materialVacuum = material("Vacuum"); gGeoManager->SetTopVolume(m_worldVol); } diff --git a/DDExamples/ILDExDet/compact/ILDEx.xml b/DDExamples/ILDExDet/compact/ILDEx.xml index 5678f8e0488f90e97f56671bfe63e38f41396636..dc571e63b46c0ef242c9551dcc52909276b881ae 100644 --- a/DDExamples/ILDExDet/compact/ILDEx.xml +++ b/DDExamples/ILDExDet/compact/ILDEx.xml @@ -18,10 +18,10 @@ </includes> <define> - <constant name="world_side" value="30000"/> - <constant name="world_x" value="world_side"/> - <constant name="world_y" value="world_side"/> - <constant name="world_z" value="world_side"/> + <constant name="world_side" value="1*m"/> + <constant name="world_x" value="world_side/2"/> + <constant name="world_y" value="world_side/2"/> + <constant name="world_z" value="world_side/2"/> <constant name="CrossingAngle" value="0.020"/> <constant name="TPC_zhalf" value="2500*mm"/> @@ -151,7 +151,7 @@ </readouts> <fields> <field type="Solenoid" name="GlobalSolenoid" inner_field="5.0" - outer_field="-1.5" zmax="SolenoidCoilOuterZ" - outer_radius="SolenoidalFieldRadius" /> + outer_field="-1.5" zmax="SolenoidCoilOuterZ" + outer_radius="SolenoidalFieldRadius" /> </fields> </lccdd> diff --git a/DDExamples/ILDExDet/drivers/ILDExSIT.py b/DDExamples/ILDExDet/drivers/ILDExSIT.py index ff84dc1aa9fa13c9cc207660e82d16bddcfe26a3..4267fd11c3a4b6c91e5d33ab8748a57051530ef3 100644 --- a/DDExamples/ILDExDet/drivers/ILDExSIT.py +++ b/DDExamples/ILDExDet/drivers/ILDExSIT.py @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------------- def detector_ILDExSIT(lcdd, det): sit = DetElement(lcdd, det.name, det.type, det.id) - mother = lcdd.trackingVolume() + mother = lcdd.worldVolume() for layer in det.findall('layer'): support = layer.find('support') ladder = layer.find('ladder') diff --git a/DDExamples/ILDExDet/drivers/ILDExTPC.py b/DDExamples/ILDExDet/drivers/ILDExTPC.py index af6ef9c151e59d84a903123b25ca7b4a1446e5bc..be82a247966b21ac5f957f92c7202b155915c5be 100644 --- a/DDExamples/ILDExDet/drivers/ILDExTPC.py +++ b/DDExamples/ILDExDet/drivers/ILDExTPC.py @@ -16,16 +16,14 @@ def detector_ILDExTPC(lcdd, det): part_det = DetElement(lcdd, px.name, px.type, px.id) part_tube = Tube(lcdd,px.name+'_tube',px_tube.rmin, px_tube.rmax, px_tube.zhalf) part_vol = Volume(lcdd, px.name, part_tube, lcdd.material(px_mat.name)) - print 'Vis for %s ' %det.name, px.vis part_vol.setVisAttributes(lcdd.visAttributes(px.vis)) part_det.addPlacement(tpc_vol.placeVolume(part_vol, getPosition(px_pos), getRotation(px_rot))) if px.id == 0 : tpc_de.setInnerWall(part_det) elif px.id == 1 : tpc_de.setOuterWall(part_det) elif px.id == 5 : tpc_de.setGasVolume(part_det) tpc_de.add(part_det) - print 'vis = ', det.vis tpc_vol.setVisAttributes(lcdd.visAttributes(det.vis)) - lcdd.pickMotherVolume(tpc_de).placeVolume(tpc_vol) + lcdd.worldVolume().placeVolume(tpc_vol) #--additonal TPC data----------------------------- mod = det.find('module') tpc_de.setNModules(mod.getI('number')) diff --git a/DDExamples/ILDExDet/drivers/ILDExVXD.py b/DDExamples/ILDExDet/drivers/ILDExVXD.py index c062d5d7843fda35bf6d61e1bb13f4afd3fd2b86..e585c5c5d80a9796d92417dc217906d102b8aef8 100644 --- a/DDExamples/ILDExDet/drivers/ILDExVXD.py +++ b/DDExamples/ILDExDet/drivers/ILDExVXD.py @@ -1,7 +1,7 @@ #------------------------------------------------------------------------------------- def detector_ILDExVXD(lcdd, det): vdx = DetElement(lcdd, det.name, det.type, det.id) - mother = lcdd.trackingVolume() + mother = lcdd.worldVolume() for layer in det.findall('layer'): support = layer.find('support') ladder = layer.find('ladder') diff --git a/DDExamples/ILDExSimu/CMakeLists.txt b/DDExamples/ILDExSimu/CMakeLists.txt index a0f2eab34b252e83ccee750e2f5080f25e8f31e5..d5944a7ef6becddf281d7dda9cd0a691b2e6607b 100644 --- a/DDExamples/ILDExSimu/CMakeLists.txt +++ b/DDExamples/ILDExSimu/CMakeLists.txt @@ -3,15 +3,13 @@ cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) find_package(Geant4 REQUIRED) include_directories( ${CMAKE_SOURCE_DIR}/DDCore/include - ${CMAKE_SOURCE_DIR}/VGM/packages/RootGM/include - ${CMAKE_SOURCE_DIR}/VGM/packages/Geant4GM/include - ${CMAKE_SOURCE_DIR}/VGM/packages/BaseVGM/include - ${CMAKE_SOURCE_DIR}/VGM/packages/VGM/include + ${CMAKE_SOURCE_DIR}/DDGeant4/include ${CMAKE_CURRENT_SOURCE_DIR}/include ${ROOT_INCLUDE_DIR} - ${Geant4_INCLUDE_DIR}) + ${Geant4_INCLUDE_DIR} + ${VGM_INCLUDE_DIR}) file(GLOB sources src/*.cpp) add_executable(ILDExSimu ILDExSimu.cpp ${sources}) -target_link_libraries(ILDExSimu DD4hepCore ILDEx Geant4GM RootGM ${Geant4_LIBRARIES}) +target_link_libraries(ILDExSimu DD4hepCore DD4hepGeant4 ILDEx ${Geant4_LIBRARIES}) diff --git a/DDExamples/ILDExSimu/run1.mac b/DDExamples/ILDExSimu/run1.mac index 5d1ef3ec4b43a09ebb160dc5c795517a7440afb2..ce78258d7839ac619eb7ba3d36616f85e8964f9e 100644 --- a/DDExamples/ILDExSimu/run1.mac +++ b/DDExamples/ILDExSimu/run1.mac @@ -5,7 +5,7 @@ # can be run in batch, without graphic # or interactively: Idle> /control/execute run1.mac # -/control/verbose 2 +/control/verbose 1 /control/saveHistory # /run/verbose 2 diff --git a/DDExamples/ILDExSimu/src/ILDExPhysicsList.cpp b/DDExamples/ILDExSimu/src/ILDExPhysicsList.cpp index ab829f406dd94fd39a4462cd0e1cc8d462fc55fe..3f7ec58e8637ce3a966341e8001bca196f6d96a9 100644 --- a/DDExamples/ILDExSimu/src/ILDExPhysicsList.cpp +++ b/DDExamples/ILDExSimu/src/ILDExPhysicsList.cpp @@ -101,13 +101,13 @@ void ILDExPhysicsList::ConstructEM() } else if (particleName == "e-") { //electron pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1); -// pmanager->AddProcess(new G4eIonisation, -1, 2, 2); + pmanager->AddProcess(new G4eIonisation, -1, 2, 2); // pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); } else if (particleName == "e+") { //positron -// pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1) -// pmanager->AddProcess(new G4eIonisation, -1, 2, 2); + pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1); + pmanager->AddProcess(new G4eIonisation, -1, 2, 2); // pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); // pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4); @@ -115,7 +115,7 @@ void ILDExPhysicsList::ConstructEM() particleName == "mu-" ) { //muon pmanager->AddProcess(new G4MuMultipleScattering,-1, 1, 1); - //pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); + pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); // pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3); // pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4); diff --git a/DDExamples/ILDExSimu/src/ILDExSteppingAction.cpp b/DDExamples/ILDExSimu/src/ILDExSteppingAction.cpp index b716e83538b2e1bd456cfd9e6636f39c7d26c1b6..c9d097e0e5eb5db6e21523daea742a5432196273 100644 --- a/DDExamples/ILDExSimu/src/ILDExSteppingAction.cpp +++ b/DDExamples/ILDExSimu/src/ILDExSteppingAction.cpp @@ -25,8 +25,28 @@ ILDExSteppingAction::~ILDExSteppingAction() void ILDExSteppingAction::UserSteppingAction(const G4Step* aStep) { - assert(aStep); + static G4Material* SiMaterial = G4Material::GetMaterial("Silicon"); + static G4Material* TPCGasMaterial = G4Material::GetMaterial("Argon"); + + // get volume of the current step + G4VPhysicalVolume* volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume(); + G4Material* material = volume->GetLogicalVolume()->GetMaterial(); + + // collect energy and track length step by step + G4double edep = aStep->GetTotalEnergyDeposit(); + G4double stepl = 0.; + if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) stepl = aStep->GetStepLength(); + + if (material == SiMaterial || material == TPCGasMaterial) { + eventaction->SumSensitive(edep, stepl, 0.0); + } + else { + eventaction->SumSupport(edep, stepl, 0.0); + } + + //example of saving random number seed of this event, under condition + //// if (condition) G4RunManager::GetRunManager()->rndmSaveThisEvent(); } //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... diff --git a/DDGeant4/AddCMakeFiles.patch b/DDGeant4/AddCMakeFiles.patch new file mode 100644 index 0000000000000000000000000000000000000000..c2c4ceaf8ed2758b53d0dc889806e1f46e7670cc --- /dev/null +++ b/DDGeant4/AddCMakeFiles.patch @@ -0,0 +1,327 @@ +Index: cmake/FindROOT.cmake +=================================================================== +--- cmake/FindROOT.cmake (revision 0) ++++ cmake/FindROOT.cmake (revision 0) +@@ -0,0 +1,101 @@ ++# - Finds ROOT instalation ++# This module sets up ROOT information ++# It defines: ++# ROOT_FOUND If the ROOT is found ++# ROOT_INCLUDE_DIR PATH to the include directory ++# ROOT_LIBRARIES Most common libraries ++# ROOT_LIBRARY_DIR PATH to the library directory ++ ++ ++find_program(ROOT_CONFIG_EXECUTABLE root-config ++ PATHS $ENV{ROOTSYS}/bin) ++ ++if(ROOT_CONFIG_EXECUTABLE) ++ execute_process( ++ COMMAND ${ROOT_CONFIG_EXECUTABLE} --prefix ++ OUTPUT_VARIABLE ROOTSYS ++ OUTPUT_STRIP_TRAILING_WHITESPACE) ++ ++ execute_process( ++ COMMAND ${ROOT_CONFIG_EXECUTABLE} --version ++ OUTPUT_VARIABLE ROOT_VERSION ++ OUTPUT_STRIP_TRAILING_WHITESPACE) ++ ++ execute_process( ++ COMMAND ${ROOT_CONFIG_EXECUTABLE} --incdir ++ OUTPUT_VARIABLE ROOT_INCLUDE_DIR ++ OUTPUT_STRIP_TRAILING_WHITESPACE) ++ ++ execute_process( ++ COMMAND ${ROOT_CONFIG_EXECUTABLE} --libs ++ OUTPUT_VARIABLE ROOT_LIBRARIES ++ OUTPUT_STRIP_TRAILING_WHITESPACE) ++ ++endif() ++ ++#set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lThread -lMinuit -lHtml -lVMC -lEG -lGeom -lTreePlayer -lXMLIO -lProof) ++#set(ROOT_LIBRARIES ${ROOT_LIBRARIES} -lProofPlayer -lMLP -lSpectrum -lEve -lRGL -lGed -lXMLParser -lPhysics) ++set(ROOT_LIBRARY_DIR ${ROOTSYS}/lib) ++set(ROOT_LIBRARIES -L${ROOT_LIBRARY_DIR} Core Cint) ++ ++include(FindPackageHandleStandardArgs) ++find_package_handle_standard_args(ROOT DEFAULT_MSG ROOT_CONFIG_EXECUTABLE) ++ ++# Make variables changeble to the advanced user ++mark_as_advanced(ROOT_CONFIG_EXECUTABLE) ++ ++if(ROOT_FOUND AND NOT ROOT_FIND_QUIETLY) ++ message(STATUS "Found ROOT ${ROOT_VERSION} in ${ROOTSYS}") ++endif() ++ ++ ++ ++include(CMakeParseArguments) ++find_program(ROOTCINT_EXECUTABLE rootcint PATHS $ENV{ROOTSYS}/bin) ++ ++#---------------------------------------------------------------------------- ++# function ROOT_GENERATE_DICTIONARY( dictionary ++# header1 header2 ... ++# LINKDEF linkdef1 ... ++# OPTIONS opt1...) ++function(ROOT_GENERATE_DICTIONARY dictionary) ++ CMAKE_PARSE_ARGUMENTS(ARG "" "" "LINKDEF;OPTIONS" "" ${ARGN}) ++ #---Get the list of header files------------------------- ++ set(headerfiles) ++ foreach(fp ${ARG_UNPARSED_ARGUMENTS}) ++ file(GLOB files ${fp}) ++ if(files) ++ foreach(f ${files}) ++ if(NOT f MATCHES LinkDef) ++ set(headerfiles ${headerfiles} ${f}) ++ endif() ++ endforeach() ++ else() ++ set(headerfiles ${headerfiles} ${fp}) ++ endif() ++ endforeach() ++ #---Get the list of include directories------------------ ++ get_directory_property(incdirs INCLUDE_DIRECTORIES) ++ set(includedirs) ++ foreach( d ${incdirs}) ++ set(includedirs ${includedirs} -I${d}) ++ endforeach() ++ #---Get LinkDef.h file------------------------------------ ++ set(linkdefs) ++ foreach( f ${ARG_LINKDEF}) ++ if( IS_ABSOLUTE ${f}) ++ set(linkdefs ${linkdefs} ${f}) ++ else() ++ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) ++ set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/inc/${f}) ++ else() ++ set(linkdefs ${linkdefs} ${CMAKE_CURRENT_SOURCE_DIR}/${f}) ++ endif() ++ endif() ++ endforeach() ++ #---call rootcint------------------------------------------ ++ add_custom_command(OUTPUT ${dictionary}.cxx ${dictionary}.h ++ COMMAND ${ROOTCINT_EXECUTABLE} -cint -f ${dictionary}.cxx ++ -c ${ARG_OPTIONS} ${includedirs} ${headerfiles} ${linkdefs} ++ DEPENDS ${headerfiles} ${linkdefs}) ++endfunction() +Index: cmake/FindXercesC.cmake +=================================================================== +--- cmake/FindXercesC.cmake (revision 0) ++++ cmake/FindXercesC.cmake (revision 0) +@@ -0,0 +1,79 @@ ++# - Find Xerces-C ++# This module tries to find the Xerces-C library and headers. ++# Once done this will define ++# ++# XERCESC_FOUND - system has Xerces-C headers and libraries ++# XERCESC_INCLUDE_DIRS - the include directories needed for Xerces-C ++# XERCESC_LIBRARIES - the libraries needed to use Xerces-C ++# ++# Variables used by this module, which can change the default behaviour and ++# need to be set before calling find_package: ++# ++# XERCESC_ROOT_DIR Root directory to Xerces-C installation. Will ++# be used ahead of CMake default path. ++# ++# The following advanced variables may be used if the module has difficulty ++# locating Xerces-C or you need fine control over what is used. ++# ++# XERCESC_INCLUDE_DIR ++# ++# XERCESC_LIBRARY ++# ++# Copyright (c) 2009, Ben Morgan, <Ben.Morgan@warwick.ac.uk> ++# ++# Redistribution and use is allowed according to the terms of the BSD license. ++# For details see the accompanying COPYING-CMAKE-SCRIPTS file. ++ ++ ++ ++# Look for the header - preferentially searching below XERCESC_ROOT_DIR ++find_path( ++ XERCESC_INCLUDE_DIR ++ NAMES xercesc/util/XercesVersion.hpp ++ PATHS ${XERCESC_ROOT_DIR} ++ PATH_SUFFIXES include ++ NO_DEFAULT_PATH ++) ++ ++# If we didn't find it there, fall back to some standard search paths ++find_path( ++ XERCESC_INCLUDE_DIR ++ NAMES xercesc/util/XercesVersion.hpp ++) ++ ++# Look for the library, preferentially searching below XERCESC_ROOT_DIR ++find_library( ++ XERCESC_LIBRARY ++ NAMES xerces-c xerces-c_3 ++ PATHS ${XERCESC_ROOT_DIR} ++ PATH_SUFFIXES lib64 lib32 lib ++ NO_DEFAULT_PATH ++) ++ ++find_library( ++ XERCESC_LIBRARY ++ NAMES xerces-c xerces-c_3 ++) ++ ++ ++include(FindPackageHandleStandardArgs) ++find_package_handle_standard_args( ++ XercesC ++ DEFAULT_MSG ++ XERCESC_LIBRARY ++ XERCESC_INCLUDE_DIR ++) ++ ++if (XERCESC_FOUND) ++ set(XERCESC_LIBRARIES ${XERCESC_LIBRARY}) ++ set(XERCESC_INCLUDE_DIRS ${XERCESC_INCLUDE_DIR}) ++else (XERCESC_FOUND) ++ set(XERCESC_LIBRARIES) ++ set(XERCESC_INCLUDE_DIRS) ++endif (XERCESC_FOUND) ++ ++ ++mark_as_advanced( ++ XERCESC_LIBRARY ++ XERCESC_INCLUDE_DIR ++) +Index: CMakeLists.txt +=================================================================== +--- CMakeLists.txt (revision 0) ++++ CMakeLists.txt (revision 0) +@@ -0,0 +1,28 @@ ++cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR) ++ ++project(VGM) ++ ++#---Options------------------------------------------------------------------------- ++option(VGM_WITH_Geant4GM "Build Geant4GM subpackage" ON) ++option(VGM_WITH_RootGM "Build RootGM subpackage" ON) ++option(VGM_WITH_XmlVGM "Build XmlVGM subpackage" ON) ++ ++#---CMake Module Path--------------------------------------------------------------- ++set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) ++ ++#---Find required packages---------------------------------------------------------- ++if(VGM_WITH_Geant4GM) ++ find_package(Geant4 REQUIRED) ++endif() ++if(VGM_WITH_RootGM) ++ find_package(ROOT REQUIRED) ++endif() ++if(VGM_WITH_XmlVGM) ++ find_package(XercesC REQUIRED) ++endif() ++ ++#---Add required packages---------------------------------------------------------- ++add_subdirectory(packages) ++ ++ ++ +Index: packages/BaseVGM/CMakeLists.txt +=================================================================== +--- packages/BaseVGM/CMakeLists.txt (revision 0) ++++ packages/BaseVGM/CMakeLists.txt (revision 0) +@@ -0,0 +1,9 @@ ++include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) ++ ++#---Add library--------------------------------------------------------------------- ++file(GLOB sources source/*/*.cxx) ++add_library(BaseVGM SHARED ${sources}) ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++install(TARGETS BaseVGM DESTINATION lib) +Index: packages/ClhepVGM/CMakeLists.txt +=================================================================== +--- packages/ClhepVGM/CMakeLists.txt (revision 0) ++++ packages/ClhepVGM/CMakeLists.txt (revision 0) +@@ -0,0 +1,10 @@ ++include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) ++ ++#---Add Library------------------------------------------------------------------- ++file(GLOB sources source/*.cxx) ++add_library(ClhepVGM SHARED ${sources}) ++target_link_libraries(ClhepVGM ${Geant4_LIBRARIES}) ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++install(TARGETS ClhepVGM DESTINATION lib) +Index: packages/Geant4GM/CMakeLists.txt +=================================================================== +--- packages/Geant4GM/CMakeLists.txt (revision 0) ++++ packages/Geant4GM/CMakeLists.txt (revision 0) +@@ -0,0 +1,10 @@ ++include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) ++ ++#---Add library------------------------------------------------------------------- ++file(GLOB sources source/*/*.cxx) ++add_library(Geant4GM SHARED ${sources}) ++target_link_libraries(Geant4GM BaseVGM ClhepVGM) ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++install(TARGETS Geant4GM DESTINATION lib) +Index: packages/RootGM/CMakeLists.txt +=================================================================== +--- packages/RootGM/CMakeLists.txt (revision 0) ++++ packages/RootGM/CMakeLists.txt (revision 0) +@@ -0,0 +1,10 @@ ++include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) ++ ++#---Add library------------------------------------------------------------------- ++file(GLOB sources source/*/*.cxx) ++add_library(RootGM SHARED ${sources}) ++target_link_libraries(RootGM BaseVGM ${ROOT_LIBRARIES} Geom) ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++install(TARGETS RootGM DESTINATION lib) +Index: packages/XmlVGM/CMakeLists.txt +=================================================================== +--- packages/XmlVGM/CMakeLists.txt (revision 0) ++++ packages/XmlVGM/CMakeLists.txt (revision 0) +@@ -0,0 +1,10 @@ ++include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) ++ ++#---Add library------------------------------------------------------------------- ++file(GLOB sources source/*.cxx) ++add_library(XmlVGM SHARED ${sources}) ++target_link_libraries(XmlVGM BaseVGM ClhepVGM ${XERCESC_LIBRARIES} ) ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++install(TARGETS XmlVGM DESTINATION lib) +Index: packages/CMakeLists.txt +=================================================================== +--- packages/CMakeLists.txt (revision 0) ++++ packages/CMakeLists.txt (revision 0) +@@ -0,0 +1,25 @@ ++#---Common environment------------------------------------------------------------- ++include_directories( VGM/include ++ ClhepVGM/include ++ BaseVGM/include ++ ${ROOT_INCLUDE_DIR} ++ ${Geant4_INCLUDE_DIR} ++ ${XERCESC_INCLUDE_DIR}) ++ ++#---Add required packages---------------------------------------------------------- ++add_subdirectory(ClhepVGM) ++add_subdirectory(BaseVGM) ++if(VGM_WITH_Geant4GM) ++ add_subdirectory(Geant4GM) ++endif() ++if(VGM_WITH_RootGM) ++ add_subdirectory(RootGM) ++endif() ++if(VGM_WITH_XmlVGM) ++ add_subdirectory(XmlVGM) ++endif() ++ ++#----Installation----------------------------------------------------------------- ++install(DIRECTORY VGM/include/ DESTINATION include PATTERN ".svn" EXCLUDE) ++ ++ diff --git a/DDGeant4/CMakeLists.txt b/DDGeant4/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..0d00dabe3f8e7548bddb3345a278a7d77d265a18 --- /dev/null +++ b/DDGeant4/CMakeLists.txt @@ -0,0 +1,32 @@ + +#---Build the VGM Libraries------------------------------------------------------- +include(ExternalProject) +ExternalProject_Add( + VGM + PREFIX VGM + SVN_REPOSITORY https://vgm.svn.sourceforge.net/svnroot/vgm/tags/v3-05/vgm + UPDATE_COMMAND "" + PATCH_COMMAND patch -p0 -i ${CMAKE_CURRENT_SOURCE_DIR}/AddCMakeFiles.patch + INSTALL_DIR ${CMAKE_BINARY_DIR} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> -DVGM_WITH_XmlVGM:BOOL=OFF -DGeant4_DIR=${Geant4_DIR}) + +set(VGM_LIBRARIES -L${CMAKE_BINARY_DIR}/lib -lRootGM -lGeant4GM -lBaseVGM) +set(VGM_INCLUDE_DIR ${CMAKE_BINARY_DIR}/include) + +#---Find Geant4------------------------------------------------------------------- +find_package(Geant4 REQUIRED) + +#---Includedirs------------------------------------------------------------------- +include_directories(${CMAKE_SOURCE_DIR}/DDCore/include + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${ROOT_INCLUDE_DIR} + ${Geant4_INCLUDE_DIR} + ${VGM_INCLUDE_DIR}) + +#---Add Library------------------------------------------------------------------- +file(GLOB sources src/*.cpp) +add_library(DD4hepGeant4 SHARED ${sources}) +target_link_libraries(DD4hepGeant4 DD4hepCore ${ROOT_LIBRARIES} ${Geant4_LIBRARIES} ${VGM_LIBRARIES}) +add_dependencies(DD4hepGeant4 VGM) + + diff --git a/DDExamples/ILDExSimu/include/G4DetectorConstruction.h b/DDGeant4/include/G4DetectorConstruction.h similarity index 100% rename from DDExamples/ILDExSimu/include/G4DetectorConstruction.h rename to DDGeant4/include/G4DetectorConstruction.h diff --git a/DDExamples/ILDExSimu/src/G4DetectorConstruction.cpp b/DDGeant4/src/G4DetectorConstruction.cpp similarity index 86% rename from DDExamples/ILDExSimu/src/G4DetectorConstruction.cpp rename to DDGeant4/src/G4DetectorConstruction.cpp index b4095fd35f59c3f9074def8e40f4a44d3cf097c0..96c1fa783ac867cbed95bb0ea953740c24f01732 100644 --- a/DDExamples/ILDExSimu/src/G4DetectorConstruction.cpp +++ b/DDGeant4/src/G4DetectorConstruction.cpp @@ -5,6 +5,7 @@ #include "Geant4GM/volumes/Factory.h" #include "RootGM/volumes/Factory.h" #include "TGeoManager.h" +#include "G4Material.hh" using namespace DD4hep; @@ -21,14 +22,17 @@ G4VPhysicalVolume* G4DetectorConstruction::Construct() { // Import geometry from Root to VGM RootGM::Factory rtFactory; - rtFactory.SetDebug(1); + rtFactory.SetDebug(0); rtFactory.Import(gGeoManager->GetTopNode()); // Export VGM geometry to Geant4 // Geant4GM::Factory g4Factory; - g4Factory.SetDebug(1); + g4Factory.SetDebug(0); rtFactory.Export(&g4Factory); G4VPhysicalVolume* world = g4Factory.World(); + + G4cout << *(G4Material::GetMaterialTable()) << G4endl; + return world; } diff --git a/FixMe.txt b/FixMe.txt new file mode 100644 index 0000000000000000000000000000000000000000..f218cfb908eb72a520c246cb5b0b64c4536d7d0b --- /dev/null +++ b/FixMe.txt @@ -0,0 +1,6 @@ +- Length units are different between TGeo and G4. + The conversion VGM takes care of it but the detector constructor drivers should create the TGeo geometry in unit of cm which is not the case today. +- DetectorElement should be associated to one and only one volume placement +- Overlap problems between 'tracking_volume' and TPC. We need to rethink the need for the tracking volume +- Workout sensitive volumes +- DetectorElement sould associated to assembies if they do not provide an emvelop shape. diff --git a/ILDEx/src/ILDExDetectorConstruction.cc b/ILDEx/src/ILDExDetectorConstruction.cc index ee2cd7c0dd7cf4316cf98879cf6a8c8439fdbcda..a2fe22c450d4345be99692d10cdd669f5f198f20 100644 --- a/ILDEx/src/ILDExDetectorConstruction.cc +++ b/ILDEx/src/ILDExDetectorConstruction.cc @@ -237,8 +237,8 @@ G4VPhysicalVolume* ILDExDetectorConstruction::ConstructDetector() exit(1); } - G4GDMLParser parser; - parser.Write("World.gdml", physiWorld) ; + //G4GDMLParser parser; + //parser.Write("World.gdml", physiWorld) ; // //always return the physical World diff --git a/ILDEx/src/ILDExPhysicsList.cc b/ILDEx/src/ILDExPhysicsList.cc index 5dae9863d72a146bd05e2c32fccb83288ade182e..dfeea175a43b023a4467098ca2ac2f5eefc1603d 100644 --- a/ILDEx/src/ILDExPhysicsList.cc +++ b/ILDEx/src/ILDExPhysicsList.cc @@ -102,13 +102,13 @@ void ILDExPhysicsList::ConstructEM() } else if (particleName == "e-") { //electron pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1); -// pmanager->AddProcess(new G4eIonisation, -1, 2, 2); + pmanager->AddProcess(new G4eIonisation, -1, 2, 2); // pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); } else if (particleName == "e+") { //positron -// pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1) -// pmanager->AddProcess(new G4eIonisation, -1, 2, 2); + pmanager->AddProcess(new G4eMultipleScattering,-1, 1, 1); + pmanager->AddProcess(new G4eIonisation, -1, 2, 2); // pmanager->AddProcess(new G4eBremsstrahlung, -1, 3, 3); // pmanager->AddProcess(new G4eplusAnnihilation, 0,-1, 4); @@ -116,7 +116,7 @@ void ILDExPhysicsList::ConstructEM() particleName == "mu-" ) { //muon pmanager->AddProcess(new G4MuMultipleScattering,-1, 1, 1); - //pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); + pmanager->AddProcess(new G4MuIonisation, -1, 2, 2); // pmanager->AddProcess(new G4MuBremsstrahlung, -1, 3, 3); // pmanager->AddProcess(new G4MuPairProduction, -1, 4, 4); diff --git a/ILDEx/src/ILDExSteppingAction.cc b/ILDEx/src/ILDExSteppingAction.cc index d1c554be8fc59ef7e13def83518f2215bfff4ddd..48f45c3188655aa28a2574ba1997c429a36511a3 100644 --- a/ILDEx/src/ILDExSteppingAction.cc +++ b/ILDEx/src/ILDExSteppingAction.cc @@ -28,7 +28,25 @@ ILDExSteppingAction::~ILDExSteppingAction() void ILDExSteppingAction::UserSteppingAction(const G4Step* aStep) { - assert(aStep); + static G4Material* SiMaterial = G4Material::GetMaterial("Silicon"); + static G4Material* TPCGasMaterial = G4Material::GetMaterial("Argon"); + + // get volume of the current step + G4VPhysicalVolume* volume = aStep->GetPreStepPoint()->GetTouchableHandle()->GetVolume(); + G4Material* material = volume->GetLogicalVolume()->GetMaterial(); + + // collect energy and track length step by step + G4double edep = aStep->GetTotalEnergyDeposit(); + + G4double stepl = 0.; + if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.) stepl = aStep->GetStepLength(); + + if (material == SiMaterial || material == TPCGasMaterial) { + eventaction->SumSensitive(edep, stepl, 0.0); + } + else { + eventaction->SumSupport(edep, stepl, 0.0); + } } diff --git a/ILDEx/src/ILDExTPC.cc b/ILDEx/src/ILDExTPC.cc index 79353d958c00ff8f415c47a5f84f1906d3644835..f2a13bc4e5759f4fa2f5375f90f0a0bb4fbf2201 100644 --- a/ILDEx/src/ILDExTPC.cc +++ b/ILDEx/src/ILDExTPC.cc @@ -156,7 +156,7 @@ void ILDExTPC::build() { G4Tubs* tpcSensitiveGasSolid = new G4Tubs(name_base.str()+"_SensitiveGasSolid", _rmin+_inner_wall_thickness, _rmax-_outer_wall_thickness, _halfz-_endcap_thickness, 0.0*rad, twopi*rad); - G4LogicalVolume* tpcSensitiveGasLogical = new G4LogicalVolume(tpcSensitiveGasSolid, _wall_material, name_base.str()+"_SensitiveGasLogical"); + G4LogicalVolume* tpcSensitiveGasLogical = new G4LogicalVolume(tpcSensitiveGasSolid, _sensitive_gas_material, name_base.str()+"_SensitiveGasLogical"); VisAtt = new G4VisAttributes(sensitive_colour); diff --git a/ILDEx/src/ILDExVXD.cc b/ILDEx/src/ILDExVXD.cc index fb033171594565da373a6db00198acc5457cf5d0..ec01169f576a69cf8f0c064a6f51ad099ed44cf4 100644 --- a/ILDEx/src/ILDExVXD.cc +++ b/ILDEx/src/ILDExVXD.cc @@ -109,7 +109,7 @@ void ILDExVXD::build(){ std::stringstream name_base; - name_base << "SIT"; + name_base << "VDX"; std::stringstream name_enum; name_enum << i;