From 2caa688963b9828b3cb293bf53420c89ff79bfa7 Mon Sep 17 00:00:00 2001
From: Markus Frank <markus.frank@cern.ch>
Date: Thu, 2 Aug 2012 09:44:33 +0000
Subject: [PATCH] First version of running Geant$ converter from ROOT geometry

---
 DDG4/include/{ => DDG4}/Geant4Converter.h   |   5 +-
 DDG4/include/DDG4/Geant4SensitiveDetector.h |  73 ++++++++++++++++++++
 DDG4/src/Geant4Converter.cpp                | Bin 11869 -> 13364 bytes
 DDG4/src/Geant4SensitiveDetector.cpp        |  43 ++++++++++++
 4 files changed, 119 insertions(+), 2 deletions(-)
 rename DDG4/include/{ => DDG4}/Geant4Converter.h (97%)
 create mode 100644 DDG4/include/DDG4/Geant4SensitiveDetector.h
 create mode 100644 DDG4/src/Geant4SensitiveDetector.cpp

diff --git a/DDG4/include/Geant4Converter.h b/DDG4/include/DDG4/Geant4Converter.h
similarity index 97%
rename from DDG4/include/Geant4Converter.h
rename to DDG4/include/DDG4/Geant4Converter.h
index 4279a51e9..8f0cfadba 100644
--- a/DDG4/include/Geant4Converter.h
+++ b/DDG4/include/DDG4/Geant4Converter.h
@@ -48,6 +48,7 @@ typedef G4AnyThing<G4VSolid> G4Tubs;
 typedef G4AnyThing<G4VSolid> G4Trd;
 typedef G4AnyThing<G4VSolid> G4Paraboloid;
 typedef G4AnyThing<G4VSolid> G4Polycone;
+typedef G4AnyThing<G4VSolid> G4Polyhedra;
 typedef G4AnyThing<G4VSolid> G4Sphere;
 typedef G4AnyThing<G4VSolid> G4Torus;
 typedef G4AnyThing<G4VSolid> G4UnionSolid;
@@ -70,6 +71,7 @@ typedef G4AnyThing<G4VAny>   G4PVPlacement;
 #include "G4Trd.hh"
 #include "G4Paraboloid.hh"
 #include "G4Polycone.hh"
+#include "G4Polyhedra.hh"
 #include "G4Sphere.hh"
 #include "G4Torus.hh"
 #include "G4UnionSolid.hh"
@@ -97,7 +99,7 @@ namespace DD4hep {
 	std::map<const TGeoVolume*, G4LogicalVolume*> g4Volumes;
 	std::map<const TGeoNode*,   G4PVPlacement*>   g4Placements;
       };
-      G4GeometryInfo*   m_dataPtr;
+      G4GeometryInfo* m_dataPtr;
       G4GeometryInfo& data() const { return *m_dataPtr; }
 
       /// Constructor
@@ -122,4 +124,3 @@ namespace DD4hep {
 }      // End namespace DD4hep
 
 #endif // DD4HEP_GEANT4CONVERTER_H
-
diff --git a/DDG4/include/DDG4/Geant4SensitiveDetector.h b/DDG4/include/DDG4/Geant4SensitiveDetector.h
new file mode 100644
index 000000000..81eb77be5
--- /dev/null
+++ b/DDG4/include/DDG4/Geant4SensitiveDetector.h
@@ -0,0 +1,73 @@
+// $Id:$
+//====================================================================
+//  AIDA Detector description implementation
+//--------------------------------------------------------------------
+//
+//  Author     : M.Frank
+//
+//====================================================================
+#ifndef DD4HEP_GEANT4SENSITIVEDETECTOR_H
+#define DD4HEP_GEANT4SENSITIVEDETECTOR_H
+
+// Framework include files
+#include "DD4hep/Readout.h"
+#include "DD4hep/Detector.h"
+
+// Geant 4 include files
+#include "G4Step.hh"
+#include "G4HCofThisEvent.hh"
+#include "G4TouchableHistory.hh"
+#include "G4VSensitiveDetector.hh"
+
+/*
+ *   DD4hep namespace declaration
+ */
+namespace DD4hep {
+
+  namespace Geometry {
+    struct LCDD;
+  };
+
+  /*
+   *   Simulation namespace declaration
+   */
+  namespace Simulation {
+
+    struct Geant4SensitiveDetector : public G4VSensitiveDetector  {
+      
+      typedef Geometry::LCDD       LCDD;
+      typedef Geometry::Readout    Readout;
+      typedef Geometry::DetElement DetElement;
+
+      /// Reference to the detector description object
+      LCDD&      m_lcdd;
+      /// Reference to the detector element describing this sensitive element
+      DetElement m_detector;
+      /// Reference to the readout structure
+      Readout    m_readout;
+
+      public:
+      /// Constructor
+      Geant4SensitiveDetector(const std::string& name, DetElement detector, LCDD& lcdd);
+
+      /// Standard destructor
+      virtual ~Geant4SensitiveDetector();
+
+      /** Method invoked at the begining of each event. 
+       *  The hits collection(s) created by this sensitive detector must
+       *  be set to the G4HCofThisEvent object at one of these two methods.
+       */
+      virtual void Initialize(G4HCofThisEvent* HCE);
+      /// Method invoked at the end of each event. 
+      virtual void EndOfEvent(G4HCofThisEvent* HCE);
+
+      /// Method for generating hit(s) using the information of G4Step object.
+      virtual G4bool ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist) = 0;
+
+      /// Method is invoked if the event abortion is occured.
+      virtual void clear();
+    };
+  }    // End namespace Simulation
+}      // End namespace DD4hep
+
+#endif // DD4HEP_GEANT4SENSITIVEDETECTOR_H
diff --git a/DDG4/src/Geant4Converter.cpp b/DDG4/src/Geant4Converter.cpp
index ada85eb5d99b384c70ca0884d2dabf36b6a1e487..5b8ab0482f3b224f91bf35ab317aaab8b8c670a4 100644
GIT binary patch
delta 2079
zcmb7F&2QsG6sKV;8V8}K+ielmZeLwUZO2L4B?2jF!iKgRRqDqoTZ*)$id=h=c=1PN
zJN?Ki$^~)a#0dTZB#s~j&T!<4khmeZfH+oM5GQ!!u|p~(R%^)`d)~}@zu$YmdGphI
zUv<7boS59)tQQNz!->zHPY6K&loh(Dyh>~MehV|StE8s^{J=AvHaMDH769nS%CaaV
zVSOFM6*zRQ(u&A_&T`c{3HCIbNHPdX`n>`P9Ilk5`FM4>jyQ(J{Pcz4UpIbF4C+P0
z?VeZ!dQbsk5t}$cuKGxl%R+Kw(@3i|ZmvnPBDD*)YZ10ice??@fDlOt48l-+!Pvye
zJ?@XD-(n+kUx@u7TJ|u0!2L+q?2v<AxI1J*e|}+ZapV^>a9{=&ra)y_)Sk+=(nqN~
z^z+H|@NnwQiMyr~fV0Jk`bcV(WrIDs>-Yia9nDj~Jq^$#=I{~A^uy%-ttd;iX5a>z
z#rEY_%k+oj$~9-UdBN)tLGm$=bRl({-V)M-QB;<*mg`9jidk7LgSkGkl_8roWtN0E
zRJH<A?6-y=fh5aE=J8W~z!T=>piW%QmiC0^z-)m8OYI^7ncEp}UOjQE(b#X4VAu40
zCOF--PhAJ)z^g#63ydoekOtUVKs*zZ5>`Ei8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t1d@<(1-?r@-N2~b;fX6$4^P8p!l4wIF+q$jKJJ50W+Y_)klzcwqYa%P%>!Q_)7
zCakG>DVb@L8AXjJZxVgNnVg@Os*#tNn>x8(NP2RIsK(^CQtT>zRY1pcadL7hfPh+2
zZf0JzL97mll~@5`RZV^`p+8wf+;j2{(R&mav-!P5GWX=^DvFbXR5T|ysEBXgrJ}&J
z*-X8jiH!?v{pS5zTUnI#(lU#ROLP=8v@$jIic^8^P5}m#f<i4<Ef-gDNn%N6@?=I<
zt;xEqN|OVDxRh0qr?{jjGcR2M=sjz$$;()kC!b-Jo&1JXelj1M0>6!of|9zD0+0fR
zNRIX74t-|{h4j>XkfFKpDTyVC0VPEWwhC%MvCW_KeVHaV8~HFPC``U+q%D(?2-K76
R2Mjk2tt_xRKrVr}1^~yqp<Ms~

diff --git a/DDG4/src/Geant4SensitiveDetector.cpp b/DDG4/src/Geant4SensitiveDetector.cpp
new file mode 100644
index 000000000..3791bb978
--- /dev/null
+++ b/DDG4/src/Geant4SensitiveDetector.cpp
@@ -0,0 +1,43 @@
+// $Id:$
+//====================================================================
+//  AIDA Detector description implementation for LCD
+//--------------------------------------------------------------------
+//
+//  Author     : M.Frank
+//
+//====================================================================
+
+#include "DDG4/Geant4SensitiveDetector.h"
+
+using namespace DD4hep;
+using namespace DD4hep::Simulation;
+
+/// Constructor
+Geant4SensitiveDetector::Geant4SensitiveDetector(const std::string& name, DetElement detector, LCDD& lcdd)
+  : G4VSensitiveDetector(name), m_detector(detector), m_lcdd(lcdd)
+{
+  m_readout = detector.readout();
+  collectionName.insert("trackerCollection");
+}
+
+/// Standard destructor
+Geant4SensitiveDetector::~Geant4SensitiveDetector() {
+}
+
+/// Method invoked at the begining of each event. 
+void Geant4SensitiveDetector::Initialize(G4HCofThisEvent* HCE) {
+}
+
+/// Method invoked at the end of each event. 
+void Geant4SensitiveDetector::EndOfEvent(G4HCofThisEvent* HCE) {
+}
+
+/// Method for generating hit(s) using the information of G4Step object.
+G4bool Geant4SensitiveDetector::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist) {
+}
+
+/// Method is invoked if the event abortion is occured.
+void Geant4SensitiveDetector::clear() {
+}
+
+//DECLARE_TRANSLATION(LCDD2Geant4,create_g4);
-- 
GitLab