diff --git a/DDCore/include/XML/UnicodeValues.h b/DDCore/include/XML/UnicodeValues.h index f3b8d4acb36a970c7f88bf212f13e8b45137dac6..078f64d13237e9d67497d87b712622543ffb098f 100644 --- a/DDCore/include/XML/UnicodeValues.h +++ b/DDCore/include/XML/UnicodeValues.h @@ -363,6 +363,7 @@ UNICODE (rmin); UNICODE (rmin1); UNICODE (rmin2); UNICODE (RL); +UNICODE (rootFile); UNICODE (row); UNICODE (rpc); UNICODE (RowID); diff --git a/examples/DDCodex/CMakeLists.txt b/examples/DDCodex/CMakeLists.txt index 07f92ccc4408694a7f37b9cf9e043c358dd712b0..b24ab73127a0c985e0e42742837ac6a848cbc245 100644 --- a/examples/DDCodex/CMakeLists.txt +++ b/examples/DDCodex/CMakeLists.txt @@ -25,7 +25,7 @@ dd4hep_add_plugin(DDCodexPlugins ) # # -dd4hep_install_dir( compact python DESTINATION ${CMAKE_INSTALL_PREFIX}/examples/DDCodex ) +dd4hep_install_dir( compact python eve DESTINATION ${CMAKE_INSTALL_PREFIX}/examples/DDCodex ) dd4hep_install_files(FILES Upgrade.root DESTINATION ${CMAKE_INSTALL_PREFIX}/examples/DDCodex ) #-------------------------------------------------------------------------- # diff --git a/examples/DDCodex/CodexB_2018-06-29_22-48.root b/examples/DDCodex/CodexB_2018-06-29_22-48.root new file mode 100644 index 0000000000000000000000000000000000000000..1b1cfeb361a5792b1de9dff3597bff68670720bf Binary files /dev/null and b/examples/DDCodex/CodexB_2018-06-29_22-48.root differ diff --git a/examples/DDCodex/compact/CODEX-b-alone.xml b/examples/DDCodex/compact/CODEX-b-alone.xml new file mode 100644 index 0000000000000000000000000000000000000000..21bb24ab0e35605a058199016d9b68353d0853a6 --- /dev/null +++ b/examples/DDCodex/compact/CODEX-b-alone.xml @@ -0,0 +1,44 @@ +<lccdd xmlns:compact="http://www.lcsim.org/schemas/compact/1.0" + xmlns:xs="http://www.w3.org/2001/XMLSchema" + xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> + + <!-- Have the materials --> + <includes> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> + <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/materials.xml"/> + </includes> + + <define> + <!-- Define the world box --> + <constant name="world_side" value="50000*mm"/> + <constant name="world_x" value="world_side"/> + <constant name="world_y" value="world_side"/> + <constant name="world_z" value="world_side"/> + </define> + <display> + <vis name="BeamPipeVis" r="0.0" g="0.99" b="0.0" showDaughters="false" visible="true"/> + <vis name="WALL_vis" alpha="0.6" r="0.5" g="0.5" b="0.5" showDaughters="true" visible="true"/> + <vis name="B2_vis" alpha="0.6" r="0" g="0.5" b="0.5" showDaughters="true" visible="true"/> + </display> + <detectors> + <include ref="CODEX-b.xml" type="xml"/> + <detector id="3" name="LHCb" type="DD4hep_BoxSegment" vis="B2_vis"> + <material name="Air"/> + <box x="1000*cm" y="1000*cm" z="2500*cm"/> + <position x="0" y="0" z="1000*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + <detector id="4" name="WALL" type="DD4hep_BoxSegment" vis="WALL_vis"> + <material name="Air"/> + <box x="200*cm" y="1000*cm" z="2500*cm"/> + <position x="1210*cm" y="0" z="1000*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + <detector name="Beampipe" type="DD4hep_TubeSegment" vis="BeamPipeVis"> + <material name="Be" /> + <tubs rmin="5*cm" rmax="5.1*cm" zhalf="2600*cm" /> + <position x="0" y="0" z="1000*cm"/> + <rotation x="0" y="0" z="0"/> + </detector> + </detectors> +</lccdd> diff --git a/examples/DDCodex/compact/CODEX-b.xml b/examples/DDCodex/compact/CODEX-b.xml index 4a97c7da08b990776594e7333ff896706252dbcc..01447458fc5e19d0f087cc06844c96bf1d4adc0d 100644 --- a/examples/DDCodex/compact/CODEX-b.xml +++ b/examples/DDCodex/compact/CODEX-b.xml @@ -9,7 +9,7 @@ --> <define> <constant name="COBEX_beam_angle" value="60*degree"/> - <constant name="COBEX_cone_len" value="40*m"/> + <constant name="COBEX_cone_len" value="50*m"/> </define> <comment>Common Generic visualization attributes</comment> @@ -28,11 +28,13 @@ <!-- Includes for sensitives and support --> <detectors> - <detector name="COBEXb" type="DD4hep_CODEXb" vis="Codex_Envelope_Vis"> - <envelope angle="COBEX_beam_angle" dz="COBEX_cone_len" rmax="4*m"/> - <shield name="Pb-shield-1" z="7*m" dz="1.5*m" material="Lead" sensitive="false" vis="Codex_Shield_Pb_Vis"/> + <detector id="1" name="CODEXb" type="DD4hep_CODEXb" vis="Codex_Envelope_Vis" readout="CodexHits"> +<!-- limits="codex_limits" --> + + <envelope angle="COBEX_beam_angle" dz="COBEX_cone_len" rmax="8*m"/> + <shield name="Pb-shield-1" z="7*m" dz="1.5*m" material="Lead" sensitive="true" vis="Codex_Shield_Pb_Vis"/> <shield name="Shield-veto" z="8.5*m" dz="0.1*m" material="Si" sensitive="true" vis="Codex_Shield_Veto_Vis"/> - <shield name="Pb-shield-2" z="8.6*m" dz="0.5*m" material="Lead" sensitive="false" vis="Codex_Shield_Pb_Vis"/> + <shield name="Pb-shield-2" z="8.6*m" dz="0.5*m" material="Lead" sensitive="true" vis="Codex_Shield_Pb_Vis"/> <station z="12*m" width="10*m" height="10*m" thickness="2*cm" material="Si" sensitive="true" vis="Codex_Module1_Vis" @@ -49,5 +51,19 @@ </detector> </detectors> + <limits> + <limitset name="codex_limits"> + <limit name="step_length_max" particles="*" value="5.0" unit="mm" /> + </limitset> + </limits> + <readouts> + <readout name="CodexHits"> + <segmentation type="CartesianGridXY" grid_size_x="1*cm" grid_size_y="1*cm" /> + <id>system:8,type:3,station:10,x:32:-16,y:-16</id> + </readout> + </readouts> + + <fields> + </fields> </lccdd> diff --git a/examples/DDG4_MySensDet/scripts/MyTrackerSD.py b/examples/DDCodex/python/CODEX-b-alone.py similarity index 51% rename from examples/DDG4_MySensDet/scripts/MyTrackerSD.py rename to examples/DDCodex/python/CODEX-b-alone.py index a8db6afda49033a637c0690fb717b66f51a736e6..c15e530e6d652e5a659158a11f493f21da1fa673 100644 --- a/examples/DDG4_MySensDet/scripts/MyTrackerSD.py +++ b/examples/DDCodex/python/CODEX-b-alone.py @@ -16,15 +16,10 @@ from SystemOfUnits import * def run(): kernel = DDG4.Kernel() install_dir = os.environ['DD4hepExamplesINSTALL'] - kernel.loadGeometry("file:"+install_dir+"/examples/ClientTests/compact/SiliconBlock.xml") + kernel.loadGeometry("file:"+install_dir+"/examples/DDCodex/compact/CODEX-b-alone.xml") DDG4.importConstants(kernel.detectorDescription(),debug=False) - - # ======================================================================================= - # ===> This is actually the ONLY difference to ClientTests/scripts/SiliconBlock.py - # ======================================================================================= - geant4 = DDG4.Geant4(kernel,tracker='MyTrackerSDAction') - + geant4 = DDG4.Geant4(kernel,tracker='Geant4TrackerAction') geant4.printDetectors() # Configure UI if len(sys.argv)>1: @@ -36,52 +31,57 @@ def run(): field = geant4.setupTrackingField(prt=True) # Configure Event actions prt = DDG4.EventAction(kernel,'Geant4ParticlePrint/ParticlePrint') - prt.OutputLevel = Output.DEBUG + prt.OutputLevel = Output.WARNING prt.OutputType = 3 # Print both: table and tree kernel.eventAction().adopt(prt) - generator_output_level = Output.INFO - - # Configure G4 geometry setup - seq,act = geant4.addDetectorConstruction("Geant4DetectorGeometryConstruction/ConstructGeo") - act.DebugMaterials = True - act.DebugElements = False - act.DebugVolumes = True - act.DebugShapes = True - # Configure I/O - evt_root = geant4.setupROOTOutput('RootOutput','SiliconBlock_'+time.strftime('%Y-%m-%d_%H-%M')) + evt_root = geant4.setupROOTOutput('RootOutput','CodexB_'+time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun - gun = geant4.setupGun("Gun",particle='mu-',energy=20*GeV,multiplicity=1) - gun.OutputLevel = generator_output_level + gun = geant4.setupGun("Gun",particle='pi+', + energy=50*GeV, + multiplicity=1, + isotrop=False,Standalone=True, + direction=(0.866025,0,0.5), + position='(0,0,0)') + setattr(gun,'print',True) + #seq,action = geant4.setupTracker('CODEXb') + seq,action = geant4.setupCalorimeter('CODEXb') + action.OutputLevel = Output.ERROR + #geant4.setupTracker('CODEX-b-Shield') + #geant4.setupTracker('CODEX-b-Stations') # And handle the simulation particles. part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") kernel.generatorAction().adopt(part) - part.SaveProcesses = ['Decay'] - part.MinimalKineticEnergy = 100*MeV - part.OutputLevel = Output.INFO #generator_output_level + part.OutputLevel = Output.INFO part.enableUI() user = DDG4.Action(kernel,"Geant4TCUserParticleHandler/UserParticleHandler") - user.TrackingVolume_Zmax = 3.0*m - user.TrackingVolume_Rmax = 3.0*m + user.TrackingVolume_Zmax = 999999.*m # Something big. All is a tracker + user.TrackingVolume_Rmax = 999999.*m user.enableUI() part.adopt(user) - geant4.setupTracker('SiliconBlockUpper') - geant4.setupTracker('SiliconBlockDown') # Now build the physics list: + ##phys = kernel.physicsList() phys = geant4.setupPhysics('QGSP_BERT') ph = DDG4.PhysicsList(kernel,'Geant4PhysicsList/Myphysics') - ph.addParticleConstructor('G4Geantino') + ph.addParticleConstructor('G4LeptonConstructor') + ph.addParticleConstructor('G4BaryonConstructor') + ph.addParticleConstructor('G4MesonConstructor') ph.addParticleConstructor('G4BosonConstructor') ph.enableUI() phys.adopt(ph) + ##phys.extends = 'QGSP_BERT' + phys.enableUI() phys.dump() - - geant4.execute() + # run + kernel.configure() + kernel.initialize() + kernel.run() + kernel.terminate() if __name__ == "__main__": run() diff --git a/examples/DDCodex/src/CODEXb_geo.cpp b/examples/DDCodex/src/CODEXb_geo.cpp index 6c0cb0c303c0d92b93d48944000a4131e84d37a7..77a93bfb882e87e73f2fe4de4b96afbe276adb30 100644 --- a/examples/DDCodex/src/CODEXb_geo.cpp +++ b/examples/DDCodex/src/CODEXb_geo.cpp @@ -34,19 +34,34 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { double sin_cone = std::sin(std::atan(x_envelope.rmax()/env_dz/2.0)); double cos_beam = std::cos(env_angle); double sin_beam = std::sin(env_angle); - Cone env_cone(env_dz,0,0.0001,x_envelope.rmax(),x_envelope.rmax()+0.0001); - Volume env_vol (det_name,env_cone,description.air()); + //Cone env_cone(env_dz,0,0.0001,x_envelope.rmax(),x_envelope.rmax()+0.0001); + //Volume env_vol (det_name,env_cone,description.air()); + // If the cone should be removed and replaced by an assembly, + // comment the upper to and enable the lower line + Assembly env_vol(det_name); PlacedVolume pv; + SensitiveDetector sd = sens; + sd.setType("tracker"); + +#if 0 + Box b(2000,2000,2000); + Volume vb(det_name+"_bbb",b,description.material("Si")); + pv = env_vol.placeVolume(vb, Position(0,0,0)); + vb.setSensitiveDetector(sd); + pv.addPhysVolID("type", 0); + pv.addPhysVolID("station", 20); +#endif + + // Set visualization, limits and region (if present) env_vol.setRegion(description, x_det.regionStr()); env_vol.setLimitSet(description, x_det.limitsStr()); env_vol.setVisAttributes(description, x_det.visStr()); - printout(INFO,"CODEX-b","%s Envelope: dz=%g r1=%g r2=%g beam-angle=%g atan(cone)=%g", - det_name.c_str(), env_cone->GetDz(), env_cone->GetRmin1(), env_cone->GetRmax2(), - env_angle, std::atan(x_envelope.rmax()/env_dz/2.0)); + printout(INFO,"CODEX-b","%s beam-angle=%g atan(cone)=%g", + det_name.c_str(), env_angle, std::atan(x_envelope.rmax()/env_dz/2.0)); Tube tub(0, 3, x_envelope.dz()+500); - Volume tub_vol("Tube", tub, description.air()); + Volume tub_vol(det_name+"_Tube", tub, description.air()); tub_vol.setVisAttributes(description, "BlackVis"); pv = env_vol.placeVolume(tub_vol, Position(0,0,0)); @@ -55,7 +70,7 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { xml_comp_t shield = i; double z = shield.z(), dz = shield.dz(); double r1 = sin_cone*z, r2 = sin_cone*(z+dz); - string nam = shield.nameStr(); + string nam = det_name+"_"+shield.nameStr(); Cone con(dz/2., 0., r1, 0., r2); Material mat(description.material(shield.attr<string>(_U(material)))); Volume vol(nam,con,mat); @@ -66,8 +81,9 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { pv = env_vol.placeVolume(vol, Position(0,0,-env_dz+z+dz/2.0)); if ( shield.isSensitive() ) { DetElement det(sdet, "shield_"+nam, x_det.id()); + vol.setSensitiveDetector(sd); pv.addPhysVolID("type", 0); - pv.addPhysVolID("module", num_sensitive); + pv.addPhysVolID("station", num_sensitive); det.setPlacement(pv); ++num_sensitive; } @@ -93,13 +109,19 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { if ( station.hasAttr(_U(z)) ) { z0 = station.z()+x_tot/2.0/cos_beam; x0 = -x_tot/2.0/sin_beam; - } + } + // Set visualization, limits and region (if present) vol.setVisAttributes(description, station.visStr()); + vol.setLimitSet(description, station.limitsStr()); + vol.setRegion(description, station.regionStr()); + if ( station.isSensitive() ) { + vol.setSensitiveDetector(sd); + } for(int j=0; j < repeat; ++j) { DetElement det(sdet, _toString(station_number,"module%d"), station_number); pv = env_vol.placeVolume(vol, Transform3D(RotationZYX(0,M_PI/2.0-env_angle,0), Position(x0,0,z0))); pv.addPhysVolID("type", 1); - pv.addPhysVolID("module", station_number); + pv.addPhysVolID("station", station_number); printout(INFO,"CODEX-b","%s Module: %2d %-12s x=%g y=%g z=%7g Dist:%g dx:%g dz:%g", det_name.c_str(), station_number, ('['+string(mat.name())+']').c_str(), x0, 0.0, z0, dist, dx, dz); @@ -110,18 +132,14 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { } } - if ( x_det.isSensitive() ) { - SensitiveDetector sd = sens; - xml_dim_t sd_typ = x_det.child(_U(sensitive)); - env_vol.setSensitiveDetector(sens); - sd.setType(sd_typ.typeStr()); - } - Volume mother = description.pickMotherVolume(sdet); - pv = mother.placeVolume(env_vol,Transform3D(RotationZYX(rot.z(),rot.y(),rot.x()),Position(-pos.x(),-pos.y(),pos.z()))); + Transform3D trafo(RotationZYX(rot.z(),rot.y(),rot.x()),Position(-pos.x(),-pos.y(),pos.z())); + Direction dir = trafo*Direction(0,0,1.); + pv = mother.placeVolume(env_vol,trafo); if ( x_det.hasAttr(_U(id)) ) { pv.addPhysVolID("system",x_det.id()); } + printout(INFO,det_name,"+++ Need to shot in direction: (x,y,z) = (%g,%g,%g)",dir.X(),dir.Y(),dir.Z()); sdet.setPlacement(pv); return sdet; }