diff --git a/DDCore/include/Parsers/Primitives.h b/DDCore/include/Parsers/Primitives.h index c4c3b41a6852b71a0e15810662922a5ae809be04..ab64b2b430a65cd42a117da490e7d98f5f273801 100644 --- a/DDCore/include/Parsers/Primitives.h +++ b/DDCore/include/Parsers/Primitives.h @@ -30,6 +30,8 @@ /// Namespace for the AIDA detector description toolkit namespace dd4hep { + class DetElement; + /// Namespace describing generic detector segmentations namespace DDSegmentation { class BitFieldCoder; @@ -438,7 +440,25 @@ namespace dd4hep { template <typename M> ReferenceObjects<typename M::value_type> reference2nd(M&) { return ReferenceObjects<typename M::value_type>(); } - + /// Helper to pass reference counted objects + template <typename T> class RefCountHandle { + public: + T* ptr; + RefCountHandle() : ptr(0) {} + RefCountHandle(T* p) : ptr(p) { if ( ptr ) ptr->addRef(); } + RefCountHandle(const RefCountHandle& c) : ptr(c.ptr) { if ( ptr ) ptr->addRef(); } + RefCountHandle(const RefCountHandle& c, const DetElement& ) : ptr(c.ptr) { if ( ptr ) ptr->addRef(); } + virtual ~RefCountHandle() { if ( ptr ) ptr->release(); } + RefCountHandle& operator=(const RefCountHandle& c) { + if ( &c != this ) { + if ( ptr ) ptr->release(); + ptr = c.ptr; + if ( ptr ) ptr->addRef(); + } + return *this; + } + }; + /// Member function call-functor with no arguments template <typename R, typename T> struct ApplyMemFunc { typedef R (T::*memfunc_t)(); diff --git a/DDCore/src/XML/VolumeBuilder.cpp b/DDCore/src/XML/VolumeBuilder.cpp index 838529ea7f68b36d665cec5ebeb0f7165160609d..e5df89abe4c02dc9e7a0a1c579c183a06343e4da 100644 --- a/DDCore/src/XML/VolumeBuilder.cpp +++ b/DDCore/src/XML/VolumeBuilder.cpp @@ -68,6 +68,12 @@ void VolumeBuilder::registerShape(const std::string& nam, Solid shape) { void VolumeBuilder::registerVolume(const std::string& nam, Volume volume) { auto is = volumes.find(nam); if ( is == volumes.end() ) { + printout(debug ? ALWAYS : DEBUG,"VolumeBuilder", + "+++ Register volume: %-20s shape:%-24s vis:%s sensitive:%s", + nam.c_str(), + volume.solid()->IsA()->GetName(), + volume.visAttributes().name(), + yes_no(volume.isSensitive())); volumes[nam] = make_pair(xml_h(0), volume); return; } @@ -213,6 +219,7 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { continue; } } + bool is_sensitive = c.attr_nothrow(_U(sensitive)); /// Check if the volume is implemented by a factory if ( (attr=c.attr_nothrow(_U(type))) ) { string typ = c.attr<string>(attr); @@ -220,13 +227,14 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); volumes.insert(make_pair(nam,make_pair(c,vol))); /// Check if the volume is sensitive - if ( c.attr_nothrow(_U(sensitive)) ) { + if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); } solid = vol.solid(); printout(debug ? ALWAYS : DEBUG,"VolumeBuilder", - "+++ Building volume from XML: %-20s shape:%-24s vis:%s", - nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str()); + "+++ Building volume from XML: %-20s shape:%-24s vis:%s sensitive:%s", + nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str(), + yes_no(is_sensitive)); buildVolumes(c); continue; } @@ -249,12 +257,13 @@ size_t VolumeBuilder::buildVolumes(xml_h handle) { vol.setAttributes(description,x.regionStr(),x.limitsStr(),x.visStr()); volumes.insert(make_pair(nam,make_pair(c,vol))); /// Check if the volume is sensitive - if ( c.attr_nothrow(_U(sensitive)) ) { + if ( is_sensitive ) { vol.setSensitiveDetector(sensitive); } printout(debug ? ALWAYS : DEBUG,"VolumeBuilder", - "+++ Building volume from XML: %-20s shape:%-24s vis:%s", - nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str()); + "+++ Building volume from XML: %-20s shape:%-24s vis:%s sensitive:%s", + nam.c_str(), solid->IsA()->GetName(), x.visStr().c_str(), + yes_no(is_sensitive)); buildVolumes(c); continue; } diff --git a/DDCore/src/plugins/StandardPlugins.cpp b/DDCore/src/plugins/StandardPlugins.cpp index 3ac559c1714f2cac9ea4a82ee5df05ee7f3fcbe3..db8c6f12cd3be8c7c3d4126bd8da60eeb47a6fea 100644 --- a/DDCore/src/plugins/StandardPlugins.cpp +++ b/DDCore/src/plugins/StandardPlugins.cpp @@ -875,6 +875,7 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { long dump(string prefix, TGeoNode* ideal, TGeoNode* aligned, int level, PlacedVolume::VolIDs volids) { char fmt[128]; + stringstream log; PlacedVolume pv(ideal); bool sensitive = false; string opt_info, pref = prefix; @@ -898,7 +899,6 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { pref += aligned->GetName(); } if ( m_printPositions || m_printVolIDs ) { - stringstream log; if ( m_printPointers ) { if ( ideal != aligned ) ::snprintf(fmt,sizeof(fmt),"Ideal:%p Aligned:%p ",(void*)ideal,(void*)aligned); @@ -930,16 +930,6 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { } } } - if ( m_printPositions ) { - if ( ideal ) { - const double* trans = ideal->GetMatrix()->GetTranslation(); - ::snprintf(fmt, sizeof(fmt), "Pos: (%f,%f,%f) ",trans[0],trans[1],trans[2]); - } - else { - ::snprintf(fmt, sizeof(fmt), " <ERROR: INVALID Translation matrix> "); - } - log << fmt; - } opt_info = log.str(); } TGeoVolume* volume = ideal ? ideal->GetVolume() : 0; @@ -983,12 +973,23 @@ static long dump_volume_tree(Detector& description, int argc, char** argv) { printout(ok ? INFO : ERROR, "VolumeDump", fmt, " ->", "", mat.name(), mat.A(), mptr->GetA(), mat.Z(), mptr->GetZ()); } + log.str(""); if ( m_printShapes ) { - Volume vol = pv.volume(); - TGeoShape* sh = vol->GetShape(); - ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds Shape: %%s",level+1,2*level+1); - printout(INFO, "VolumeDump", fmt, " ->", "", toStringSolid(sh).c_str()); - ++m_numShapes; + log << "Shape: " << toStringSolid(pv.volume().solid()) << " \t"; + } + if ( m_printPositions ) { + if ( ideal ) { + const double* trans = ideal->GetMatrix()->GetTranslation(); + ::snprintf(fmt, sizeof(fmt), "Pos: (%f,%f,%f) ",trans[0],trans[1],trans[2]); + } + else { + ::snprintf(fmt, sizeof(fmt), " <ERROR: INVALID Translation matrix> "); + } + log << fmt << " \t"; + } + if ( !log.str().empty() ) { + ::snprintf(fmt,sizeof(fmt),"%03d %%s %%-%ds %%s",level+1,2*level+1); + printout(INFO, "VolumeDump", fmt, " ->", "", log.str().c_str()); } for (Int_t idau = 0, ndau = aligned->GetNdaughters(); idau < ndau; ++idau) { if ( ideal ) { @@ -1201,11 +1202,16 @@ template <int flag> long dump_detelement_tree(Detector& description, int argc, c } if ( dump_positions && place.isValid() ) { Position pos = place.position(); - Box box = place.volume().solid(); + Box box = place.volume().solid(); + double loc[3] = {0,0,0}, world[3] = {0,0,0}; + TGeoHMatrix tr = de.nominal().worldTransformation(); + tr.LocalToMaster(loc, world); ::snprintf(fmt,sizeof(fmt), "%03d %%-%ds BBox: (%%9.4f,%%9.4f,%%9.4f) [cm]", level+1,2*level+3); printout(INFO,"DetectorDump",fmt,"", box.x(), box.y(), box.z()); - ::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm]", level+1,2*level+3); + ::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm] w/r to mother", level+1,2*level+3); printout(INFO,"DetectorDump",fmt,"", pos.X(), pos.Y(), pos.Z()); + ::snprintf(fmt,sizeof(fmt), "%03d %%-%ds Position: (%%9.4f,%%9.4f,%%9.4f) [cm] w/r to world", level+1,2*level+3); + printout(INFO,"DetectorDump",fmt,"", world[0], world[1], world[2]); } } } diff --git a/DDDetectors/src/VolumeAssembly_geo.cpp b/DDDetectors/src/VolumeAssembly_geo.cpp index 4f2c2a59e8558d46df139334c1b2c5ae660c7c3d..ddae386b92fca7ce34ccf948196c5a772c2537d5 100644 --- a/DDDetectors/src/VolumeAssembly_geo.cpp +++ b/DDDetectors/src/VolumeAssembly_geo.cpp @@ -35,7 +35,7 @@ static Ref_t create_element(Detector& description, xml_h e, SensitiveDetector se Volume assembly; xml::tools::VolumeBuilder builder(description, e, sens); - builder.debug = x_dbg != 0 || true; + builder.debug = x_dbg != 0; builder.load(x_det, "include"); builder.buildShapes(x_det); builder.buildShapes(x_env); diff --git a/examples/DDCodex/CMakeLists.txt b/examples/DDCodex/CMakeLists.txt old mode 100644 new mode 100755 diff --git a/examples/DDCodex/CODEX-b.jpg b/examples/DDCodex/CODEX-b.jpg old mode 100644 new mode 100755 diff --git a/examples/DDCodex/CodexB_2018-07-18_20-34.root b/examples/DDCodex/CodexB_2018-07-18_20-34.root deleted file mode 100644 index 7ecacdb791e013c47ee7baeb4e5f5b07fd236120..0000000000000000000000000000000000000000 Binary files a/examples/DDCodex/CodexB_2018-07-18_20-34.root and /dev/null differ diff --git a/examples/DDCodex/README.txt b/examples/DDCodex/README.txt old mode 100644 new mode 100755 diff --git a/examples/DDCodex/compact/CODEX-b-alone.xml b/examples/DDCodex/compact/CODEX-b-alone.xml old mode 100644 new mode 100755 index 23fdb7ca5ce8cf65c0eacdb84dc3fd552cfc16ca..be83e8e3b79270bd3d97aa87280c2f5c0b30cd7a --- a/examples/DDCodex/compact/CODEX-b-alone.xml +++ b/examples/DDCodex/compact/CODEX-b-alone.xml @@ -2,18 +2,6 @@ xmlns:xs="http://www.w3.org/2001/XMLSchema" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/compact/1.0/compact.xsd"> -<!-- #========================================================================== - # AIDA Detector description implementation - #========================================================================== - # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) - # All rights reserved. - # - # For the licensing terms see $DD4hepINSTALL/LICENSE. - # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. - # - #========================================================================== ---> - <!-- Have the materials --> <includes> <gdmlFile ref="${DD4hepINSTALL}/DDDetectors/compact/elements.xml"/> @@ -49,23 +37,23 @@ </display> <detectors> <include ref="CODEX-b.xml" type="xml"/> - <detector id="3" name="LHCb" type="DD4hep_BoxSegment" vis="B2_vis"> + <!--detector id="3" name="LHCb" type="DD4hep_BoxSegment" vis="B2_vis"> <material name="Air"/> <box x="500*cm" y="500*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"> + </detector--> + <!--detector id="4" name="WALL" type="DD4hep_BoxSegment" vis="WALL_vis"> <material name="Concrete"/> - <box x="200*cm" y="500*cm" z="2500*cm"/> - <position x="2250*cm*sin(60*degree)" y="0" z="2500*cm*cos(60*degree)"/> + <box x="160*cm" y="600*cm" z="1265*cm"/> + <position x="2500*cm" y="0" z="1265*cm"/> <rotation x="0" y="0" z="0"/> - </detector> - <detector name="Beampipe" type="DD4hep_TubeSegment" vis="BeamPipeVis"> + </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> + </detector--> </detectors> </lccdd> diff --git a/examples/DDCodex/compact/CODEX-b.xml b/examples/DDCodex/compact/CODEX-b.xml old mode 100644 new mode 100755 index 365e63234b8045afd28c5e418e5c48fbb7ec41cc..31d849d30964d5cf68e44afadbb0feb92ce87a95 --- a/examples/DDCodex/compact/CODEX-b.xml +++ b/examples/DDCodex/compact/CODEX-b.xml @@ -1,19 +1,6 @@ <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"> - -<!-- #========================================================================== - # AIDA Detector description implementation - #========================================================================== - # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) - # All rights reserved. - # - # For the licensing terms see $DD4hepINSTALL/LICENSE. - # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. - # - #========================================================================== ---> - <!-- <includes> <gdmlFile ref="elements.xml"/> @@ -24,7 +11,7 @@ <constant name="COBEX_beam_angle" value="60*degree"/> <constant name="COBEX_cone_len" value="50*m"/> <constant name="Global_gap" value="3*cm" /> - <constant name="Layer_thickness" value="1*cm" /> + <constant name="Layer_thickness" value="0.5*cm" /> <constant name="Layer_pitch" value="4*cm" /> </define> @@ -32,12 +19,11 @@ <display> <vis name="BlackVis" alpha="1" r="0.1" g="0.1" b="0.1" showDaughters="false" visible="true"/> <vis name="Codex_Envelope_Vis" alpha="0.7" r="0.2" g="0.2" b="0.7" showDaughters="true" visible="true"/> + <vis name="Codex_Box_Vis" alpha="0.1" r="0.8" g="0.8" b="0.8" showDaughters="true" visible="true"/> <vis name="Codex_Module_center_Vis" alpha="0.4" r="0.2" g="0.2" b="0.8" showDaughters="true" visible="true"/> <vis name="Codex_Module_front_Vis" alpha="0.4" r="0.8" g="0.2" b="0.2" showDaughters="true" visible="true"/> - <vis name="Codex_Module_back_Vis" alpha="0.4" r="0.8" g="0.2" b="0.2" showDaughters="true" visible="true"/> - <vis name="Codex_Module1_Vis" alpha="0.4" r="0.8" g="0.2" b="0.2" showDaughters="true" visible="true"/> - <vis name="Codex_Module2_Vis" alpha="0.4" r="0.2" g="0.8" b="0.2" showDaughters="true" visible="true"/> - <vis name="Codex_Module3_Vis" alpha="1" r="0.2" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="Codex_Layer1_Vis" alpha="0.4" r="0.2" g="0.2" b="0.8" showDaughters="true" visible="true"/> + <vis name="Codex_Layer2_Vis" alpha="0.4" r="0.2" g="0.8" b="0.2" showDaughters="true" visible="true"/> <vis name="Codex_Shield_Pb_Vis" alpha="1" r="0.4" g="0.4" b="0.4" showDaughters="false" visible="true"/> <vis name="Codex_Shield_Veto_Vis" alpha="1" r="0.9" g="0.9" b="0.0" showDaughters="true" visible="true"/> </display> @@ -47,7 +33,7 @@ <!-- Includes for sensitives and support --> <detectors> - <detector id="1" name="Shield" type="DD4hep_CODEXb_shield" vis="Codex_Envelope_Vis" readout="ShieldHits"> + <!--detector id="1" name="Shield" type="DD4hep_CODEXb_shield" vis="Codex_Envelope_Vis" readout="ShieldHits"> <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="false" vis="Codex_Shield_Pb_Vis"/> @@ -56,7 +42,7 @@ <position x="-sin(COBEX_beam_angle)*COBEX_cone_len/2" y="0" z="cos(COBEX_beam_angle)*COBEX_cone_len/2"/> <rotation x="0" y="COBEX_beam_angle" z="0"/> - </detector> + </detector--> <!-- <detector id="2" name="CODEXb" type="DD4hep_CODEXb_layer" vis="Codex_Envelope_Vis" readout="CodexHits" > @@ -70,27 +56,22 @@ </detector> --> - <detector id="13" name="CODEXb" type="DD4hep_CODEXb_detector" vis="Codex_Envelope_Vis" readout="CodexHits" > - <envelope thickness="23*m" length="6*m" height="6*m" vis="Codex_Module1_Vis"> + <detector id="13" name="CODEXb" type="DD4hep_CODEXb_detector" vis="Codex_Box_Vis" readout="CodexHits" > + <envelope thickness="16*m" length="8*m" height="8*m" vis="Codex_Box_Vis"> </envelope> - <layer material="Si" width="5*m" thickness="Layer_thickness" height="5*m" sensitive="true" - x="0" y="0" z="0" vis="Codex_Module2_Vis" /> - <station name="front_station" material="Al" width="5*m" thickness="40*cm" height="5*m" - repeat="6" distance="15*cm" vis="Codex_Module_front_Vis"> - <layers number="6" gap="Layer_pitch" /> - <position x="1*m" y="0" z="0" /> - </station> - <station name="center_station" material="Al" width="5*m" thickness="40*cm" height="5*m" - repeat="5" distance="15*cm" vis="Codex_Module_center_Vis"> - <layers number="5" gap="Layer_pitch" /> - <position x="8*m" y="0" z="0" /> + <station name="inner_station" material="Air" width="5*m" thickness="40*cm" height="5*m" + repeat="5" distance="1.67*m" angle="0" vis="Codex_Module_front_Vis"> + <layers name="CODEX_layer_type_0" material="Si" width="5*m" thickness="Layer_thickness" height="5*m" sensitive="true" + vis="Codex_Layer1_Vis" number="3" gap="Layer_pitch" /> + <position x="0" y="0" z="0" /> </station> - <station name="back_station" material="Al" width="5*m" thickness="60*cm" height="5*m" - repeat="6" distance="15*cm" vis="Codex_Module_back_Vis"> - <layers number="5" gap="Layer_pitch" /> - <position x="15*m" y="0" z="0" /> + <station name="face_station" material="Air" width="6.2*m" thickness="40*cm" height="6.2*m" + repeat="6" distance="1.3*m" angle="90*degree" vis="Codex_Module_center_Vis"> + <layers name="CODEX_layer_type_1" material="Si" width="5*m" thickness="Layer_thickness" height="5*m" sensitive="true" + vis="Codex_Layer2_Vis" number="6" gap="Layer_pitch" /> + <position x="0" y="0" z="0" /> </station> - <position x="3300*cm*sin(60*degree)+500*cm" y="0" z="2500*cm*cos(60*degree)" /> + <position x="2872.5*cm+500*cm" y="0" z="1265*cm" /> </detector> </detectors> diff --git a/examples/DDCodex/eve/DDEve.xml b/examples/DDCodex/eve/DDEve.xml old mode 100644 new mode 100755 index 260cbd67699982013ebad7d1e686c1af7edcc5b3..03fa5095a73c36488f1e61593097eedefb5c17a9 --- a/examples/DDCodex/eve/DDEve.xml +++ b/examples/DDCodex/eve/DDEve.xml @@ -1,22 +1,12 @@ <ddeve> -<!-- #========================================================================== - # AIDA Detector description implementation - #========================================================================== - # Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN) - # All rights reserved. - # - # For the licensing terms see $DD4hepINSTALL/LICENSE. - # For the list of contributors see $DD4hepINSTALL/doc/CREDITS. - # - #========================================================================== ---> <display visLevel="12" loadLevel="12"/> <collection name="CodexHits" hits="PointSet" color="kRed" size="1.4" type="20"/> + <collection name="ShieldHits" hits="PointSet" color="kBlack" size="1.4" type="20"/> <collection name="MC_Particles" hits="Particles" size="0.6" width="1" type="kCircle"/> <view name="3D Trackers" type="View3D"> - <detelement name="Codex-B" load_geo="5" alpha="0.55"/> + <detelement name="CODEXb" load_geo="5" alpha="0.55"/> </view> <view name="Multi (Global)" type="MultiView"> diff --git a/examples/DDCodex/python/CODEX-b-alone.py b/examples/DDCodex/python/CODEX-b-alone.py old mode 100644 new mode 100755 index 40e05eeecfef052c02e43772c1b5d741884c4721..9b45611de8e9665a787037a190518b7afd59b5b1 --- a/examples/DDCodex/python/CODEX-b-alone.py +++ b/examples/DDCodex/python/CODEX-b-alone.py @@ -19,7 +19,7 @@ def run(): kernel.loadGeometry("file:"+install_dir+"/examples/DDCodex/compact/CODEX-b-alone.xml") DDG4.importConstants(kernel.detectorDescription(),debug=False) - geant4 = DDG4.Geant4(kernel,tracker='Geant4TrackerAction') + geant4 = DDG4.Geant4(kernel,tracker='Geant4TrackerCombineAction') geant4.printDetectors() # Configure UI if len(sys.argv)>1: @@ -31,7 +31,7 @@ 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) @@ -39,26 +39,30 @@ def run(): evt_root = geant4.setupROOTOutput('RootOutput','CodexB_'+time.strftime('%Y-%m-%d_%H-%M')) # Setup particle gun - """ + + #gun = geant4.setupGun("Gun",particle='pi+', gun = geant4.setupGun("Gun",particle='mu-', energy=1000*GeV, multiplicity=1, isotrop=False,Standalone=True, - direction=(0.866025,0,0.5), - position='(0,0,0)') + direction=(1,0,0), + #direction=(0.866025,0,0.5), + position='(0,0,12650)') + #position='(0,0,0)') setattr(gun,'print',True) """ - gen = DDG4.GeneratorAction(kernel,"Geant4InputAction/InputO1"); - gen.Input = "Geant4EventReaderHepMC|../DD4hep/examples/DDG4/data/LHCb_MinBias_HepMC.txt" + gen = DDG4.GeneratorAction(kernel,"Geant4InputAction/Input") + ##gen.Input = "Geant4EventReaderHepMC|"+ "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/examples/DDG4/data/hepmc_geant4.dat" + gen.Input = "Geant4EventReaderHepMC|"+ "/afs/cern.ch/work/j/jongho/Project_DD4hep/Test/DD4hep/DDG4/examples/MinBias_HepMC.txt" gen.MomentumScale = 1.0 gen.Mask = 1 geant4.buildInputStage([gen],output_level=Output.DEBUG) - - #seq,action = geant4.setupTracker('CODEXb') + """ + seq,action = geant4.setupTracker('CODEXb') - action.OutputLevel = Output.DEBUG - seq,action = geant4.setupTracker('Shield') - action.OutputLevel = Output.DEBUG + #action.OutputLevel = Output.ERROR + #seq,action = geant4.setupTracker('Shield') + #action.OutputLevel = Output.ERROR # And handle the simulation particles. part = DDG4.GeneratorAction(kernel,"Geant4ParticleHandler/ParticleHandler") @@ -70,8 +74,7 @@ def run(): user.TrackingVolume_Rmax = 999999.*m user.enableUI() part.adopt(user) - """ - """ + # Now build the physics list: ##phys = kernel.physicsList() @@ -83,7 +86,6 @@ def run(): ph.addParticleConstructor('G4BosonConstructor') ph.enableUI() phys.adopt(ph) - ##phys.extends = 'QGSP_BERT' phys.enableUI() phys.dump() # run diff --git a/examples/DDCodex/python/GeoExtract.py b/examples/DDCodex/python/GeoExtract.py old mode 100644 new mode 100755 diff --git a/examples/DDCodex/scripts/display.C b/examples/DDCodex/scripts/display.C old mode 100644 new mode 100755 diff --git a/examples/DDCodex/src/CODEXb_box.cpp b/examples/DDCodex/src/CODEXb_box.cpp old mode 100644 new mode 100755 diff --git a/examples/DDCodex/src/CODEXb_det.cpp b/examples/DDCodex/src/CODEXb_det.cpp old mode 100644 new mode 100755 index a152b9a7af0d23727cd559d6e368e82c696d6a1a..dbc3403bc0e487f01aa281bf26496d3d9156a990 --- a/examples/DDCodex/src/CODEXb_det.cpp +++ b/examples/DDCodex/src/CODEXb_det.cpp @@ -45,45 +45,65 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { det_name.c_str(), env_thick, env_length, env_height ); /// Build the single layer volume: - int type_la_num = 0; - xml_comp_t layer = x_det.child(_U(layer)); - double la_width = layer.width(); - double la_thick = layer.thickness(); - double la_height = layer.height(); - //double la_gap = layer.gap(); - double la_x = 0; - double la_y = 0; - double la_z = 0; - string la_nam = _toString(type_la_num, "CODEX_layer_type_%d"); - Box la_box(la_thick, la_height, la_width); - Material la_mat(description.material(layer.attr<string>(_U(material)))); - Volume la_vol(la_nam, la_box, la_mat); + //int type_la_num = 0; + //xml_comp_t layer = x_det.child(_U(layer)); + //double la_width = layer.width(); + //double la_thick = layer.thickness(); + //double la_height = layer.height(); + ////double la_gap = layer.gap(); + //double la_x = 0; + //double la_y = 0; + //double la_z = 0; + //string la_nam = _toString(type_la_num, "CODEX_layer_type_%d"); + //Box la_box(la_thick, la_height, la_width); + //Material la_mat(description.material(layer.attr<string>(_U(material)))); + //Volume la_vol(la_nam, la_box, la_mat); - la_vol.setVisAttributes(description, layer.visStr()); + //la_vol.setVisAttributes(description, layer.visStr()); - if( layer.isSensitive() ) { - la_vol.setSensitiveDetector(sd); - } + //if( layer.isSensitive() ) { + // la_vol.setSensitiveDetector(sd); + //} /// Now we build the staions int type_st_num = 0; + int type_la_num = 0; typedef std::map<Volume,std::vector<PlacedVolume> > Stations; Stations station_layers; vector<Volume> station_vols; for(xml_coll_t i(x_det, _U(station)); i; ++i) { xml_comp_t station = i; - xml_dim_t st_layers = station.child(_U(layers)); - int st_N_lay = st_layers.number(); - double layer_gap = st_layers.gap(); - string st_name = station.nameStr(); - double st_width = station.width(); - double layer_dist= layer_gap + 2.0*la_thick; - double st_thick = (st_N_lay-1)*layer_dist/2.0 + layer_gap; - double st_height = station.height(); - string st_nam = _toString(type_st_num, "CODEX_sub_station_%d"); - Box st_box(st_thick, st_height, st_width); - Material st_mat(description.material(station.attr<string>(_U(material)))); - Volume st_vol(st_nam,st_box,st_mat); + //xml_dim_t st_layers = station.child(_U(layers)); + xml_comp_t st_layers = station.child(_U(layers)); + int st_N_lay = st_layers.number(); + double layer_gap = st_layers.gap(); + double la_width = st_layers.width(); + double la_thick = st_layers.thickness(); + double la_height = st_layers.height(); + double la_x = 0; + double la_y = 0; + double la_z = 0; + string la_nam = st_layers.nameStr(); + Box la_box(la_thick, la_height, la_width); + Material la_mat(description.material(st_layers.attr<string>(_U(material)))); + Volume la_vol(la_nam, la_box, la_mat); + + string st_name = station.nameStr(); + double st_width = station.width(); + double layer_dist= layer_gap; + double st_thick = (st_N_lay-1)*layer_dist/2.0 + layer_gap; + double st_height = station.height(); + string st_nam = _toString(type_st_num, "CODEX_sub_station_%d"); + Box st_box(st_thick, st_height, st_width); + Material st_mat(description.material(station.attr<string>(_U(material)))); + Volume st_vol(st_name,st_box,description.air()); + + la_vol.setVisAttributes(description, st_layers.visStr()); + if( st_layers.isSensitive() ) { + cout << "Station:" << st_name << " layer:" << la_nam << endl; + la_vol.setSensitiveDetector(sd); + } + printout(INFO, "CODEX-b station size"," Thick: % g, width: % g, height: % g", st_thick, st_width, st_height); st_vol.setVisAttributes(description, station.visStr()); station_vols.push_back(st_vol); @@ -111,21 +131,45 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { double super_height = station.height(); double super_width = station.width(); int super_repeat = station.repeat(); + double super_angle = station.angle(); double super_thick = st_dist/2.0*(super_repeat-1) + st_thick*super_repeat; - Box super_box(super_thick,super_width+30.0,super_height+30.0); - Material super_mat(description.material(station.attr<string>(_U(material)))); - Volume super_vol(_toString(num_super,"Super%d"),super_box,super_mat); + string super_name = station.nameStr(); + //Box super_box(super_width+50.0,super_width+50.0,super_height+50.0); + //Volume super_vol(_toString(num_super,"Super%d"),super_box,description.air()); + Assembly super_vol(_toString(num_super,"Super%d")); + printout(INFO, "CODEX-b super station size"," Thick: % g, width: % g, height: % g", super_thick, super_width+30.0, super_height+30.0); + double face_x = -super_height; double super_x = -super_thick + st_thick; + double inner_x = -st_dist*((super_repeat-1)/2.0); for (int j=0; j < super_repeat; ++j ) { - pv = super_vol.placeVolume(st_vol, Position(super_x, 0, 0)); + if( super_name.compare("face_station") == 0 && j < 2 ) { + Transform3D trafo(RotationZYX(0,0,0),Position(face_x, 0, 0)); + pv = super_vol.placeVolume(st_vol,trafo); + } + if( super_name.compare("face_station") == 0 && j >=2 && j < 4 ) { + if( j == 2 ) face_x = -super_height; + Transform3D trafo(RotationZYX(0,super_angle,0),Position(0, 0, face_x)); + pv = super_vol.placeVolume(st_vol,trafo); + } + if( super_name.compare("face_station") == 0 && j >=4 && j < 6 ) { + if( j == 4 ) face_x = -super_height; + Transform3D trafo(RotationZYX(super_angle,0,0),Position(0, face_x, 0)); + pv = super_vol.placeVolume(st_vol,trafo); + } + if( super_name.compare("inner_station") == 0 ) { + pv = super_vol.placeVolume(st_vol, Position(inner_x, 0, 0)); + } + //pv = super_vol.placeVolume(st_vol, Position(super_x, 0, 0)); pv.addPhysVolID("station", j+1); - printout(INFO, "CODEX-b-station"," Station: %d x=%g y=%g z=%g", j+1, super_x); + printout(INFO, "CODEX-b-station"," Station: %d x=%g y=%g z=%g", j+1, inner_x); super_stations[st_vol].push_back(pv); super_x += st_dist + 2.0*st_thick; + //inner_x += st_dist + 2.0*st_thick; + inner_x += st_dist; + face_x += 2.0*super_height + st_thick/10.; } - if ( !first_box.isValid() ) first_box = super_box; - pv = env_vol.placeVolume(super_vol,Position(super_pos.x()+first_box.x()-env_thick/2.0,super_pos.y(),super_pos.z())); + pv = env_vol.placeVolume(super_vol,Position(super_pos.x(),super_pos.y(),super_pos.z())); pv.addPhysVolID("super", num_super+1); super_places.push_back(pv); } @@ -153,7 +197,7 @@ static Ref_t create_element(Detector& description, xml_h e, Ref_t sens) { } Volume mother = description.pickMotherVolume(det); - xml_dim_t pos = x_det.position(); + xml_dim_t pos = x_det.position(); Transform3D trafo(Position(pos.x(),pos.y(),pos.z())); //Direction dir = trafo*Direction(0,0,1.); pv = mother.placeVolume(env_vol, trafo); diff --git a/examples/DDCodex/src/CODEXb_geo.cpp b/examples/DDCodex/src/CODEXb_geo.cpp old mode 100644 new mode 100755