]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Initial version
authorivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Oct 2000 10:46:36 +0000 (10:46 +0000)
committerivana <ivana@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 9 Oct 2000 10:46:36 +0000 (10:46 +0000)
TGeant4/TG4StepStatus.h [new file with mode: 0644]
TGeant4/TG4SteppingAction.cxx [new file with mode: 0644]
TGeant4/TG4SteppingAction.h [new file with mode: 0644]
TGeant4/TG4TrackingAction.cxx [new file with mode: 0644]
TGeant4/TG4TrackingAction.h [new file with mode: 0644]

diff --git a/TGeant4/TG4StepStatus.h b/TGeant4/TG4StepStatus.h
new file mode 100644 (file)
index 0000000..4a18f9c
--- /dev/null
@@ -0,0 +1,26 @@
+// $Id$
+// Category: event
+//
+// In orded to take into account different stepping 
+// mechanism in G3 and G4 three states of 
+// TG4StepManager are defined:
+//  kVertex     - returns track properties in the vertex
+//                position before particle started stepping
+//  kBoundary   - returns track properties when particle
+//                is crossing geometrical boundary
+//                (the volume that preceeds the boundary is returned
+//                 as current volume)
+//  kNormalStep - returns track properties in a post step
+//                point              
+
+#ifndef TG4_STEP_STATUS_H
+#define TG4_STEP_STATUS_H
+
+enum TG4StepStatus { 
+  kVertex,     // in track vertex
+  kBoundary,   // when crossing geometrical boundary
+  kNormalStep  // in post step point
+};
+
+#endif //TG4_STEP_STATUS_H
+
diff --git a/TGeant4/TG4SteppingAction.cxx b/TGeant4/TG4SteppingAction.cxx
new file mode 100644 (file)
index 0000000..9912250
--- /dev/null
@@ -0,0 +1,71 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "TG4SteppingAction.h"
+#include "TG4StepManager.h"
+#include "TG4VSensitiveDetector.h"
+#include "TG4Globals.h"
+
+TG4SteppingAction::TG4SteppingAction() {
+//
+}
+
+TG4SteppingAction::TG4SteppingAction(const TG4SteppingAction& right) {
+//
+  TG4Globals::Exception("TG4SteppingAction is protected from copying.");
+}
+
+TG4SteppingAction::~TG4SteppingAction() {
+//
+}
+
+// operators
+
+TG4SteppingAction& 
+TG4SteppingAction::operator=(const TG4SteppingAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  TG4Globals::Exception("TG4SteppingAction is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void TG4SteppingAction::UserSteppingAction(const G4Step* step)
+{
+// Called by G4 kernel at the end of each step.
+// ---
+
+  // call stepping action of derived class
+  SteppingAction(step);
+
+  // let sensitive detector process boundary step
+  // if crossing geometry border
+  // (this ensures compatibility with G3 that
+  // makes boundary step of zero length)
+
+  if (step->GetPostStepPoint()->GetStepStatus() == fGeomBoundary &&
+      step->GetTrack()->GetNextVolume() != 0) {
+
+    G4VSensitiveDetector* sd
+      = step->GetPostStepPoint()->GetPhysicalVolume()
+          ->GetLogicalVolume()->GetSensitiveDetector();
+
+    if (sd) {
+      TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd);
+      if (tsd) 
+        tsd->ProcessHitsOnBoundary((G4Step*)step);
+      else {
+        G4String text = "TG4SteppingAction:::UserSteppingAction: \n";
+        text = text + "   Unknown sensitive detector type"; 
+        TG4Globals::Exception(text);
+      }        
+    } 
+  }  
+}
+
diff --git a/TGeant4/TG4SteppingAction.h b/TGeant4/TG4SteppingAction.h
new file mode 100644 (file)
index 0000000..b2d2ed1
--- /dev/null
@@ -0,0 +1,37 @@
+// $Id$
+// Category: event
+//
+// Class that ensures additional call to sensitive detector
+// when track crosses geometrical boundary.
+
+#ifndef TG4_STEPPING_ACTION_H
+#define TG4_STEPPING_ACTION_H
+
+#include <G4UserSteppingAction.hh>
+#include <globals.hh>
+
+class G4Step;
+
+class TG4SteppingAction : public G4UserSteppingAction 
+{
+  public:
+    TG4SteppingAction();
+    // --> protected
+    // TG4SteppingAction(const TG4SteppingAction& right);
+    virtual ~TG4SteppingAction();
+   
+    // methods
+    virtual void SteppingAction(const G4Step* step) {;}
+                  // the following method should not
+                 // be overwritten in a derived class
+    virtual void UserSteppingAction(const G4Step* step);
+
+
+  protected:
+    TG4SteppingAction(const TG4SteppingAction& right);
+
+    // operators
+    TG4SteppingAction& operator=(const TG4SteppingAction& right);
+};
+
+#endif //TG4_STEPPING_ACTION_H
diff --git a/TGeant4/TG4TrackingAction.cxx b/TGeant4/TG4TrackingAction.cxx
new file mode 100644 (file)
index 0000000..64cf696
--- /dev/null
@@ -0,0 +1,85 @@
+// $Id$
+// Category: event
+//
+// See the class description in the header file.
+
+#include "TG4TrackingAction.h"
+#include "TG4StepManager.h"
+#include "TG4VSensitiveDetector.h"
+#include "TG4Globals.h"
+
+TG4TrackingAction::TG4TrackingAction() {
+//
+}
+
+TG4TrackingAction::TG4TrackingAction(const TG4TrackingAction& right) {
+//
+  TG4Globals::Exception("TG4TrackingAction is protected from copying.");
+}
+
+TG4TrackingAction::~TG4TrackingAction() {
+//
+}
+
+// operators
+
+TG4TrackingAction& 
+TG4TrackingAction::operator=(const TG4TrackingAction &right)
+{
+  // check assignement to self
+  if (this == &right) return *this;
+  
+  TG4Globals::Exception("TG4TrackingAction is protected from assigning.");
+
+  return *this;
+}
+
+// public methods
+
+void TG4TrackingAction::PreUserTrackingAction(const G4Track* track)
+{
+// Called by G4 kernel before starting tracking.
+// ---
+
+  // call pre-tracking action of derived class
+  PreTrackingAction(track);
+
+  // let sensitive detector process vertex step
+  // (this ensures compatibility with G3 that
+  // makes first step of zero length)
+   
+  TG4StepManager* stepManager = TG4StepManager::Instance();
+  stepManager->SetStep((G4Track*)track, kVertex);
+  
+  G4VPhysicalVolume* pv = stepManager->GetCurrentPhysicalVolume();
+  
+  if (!pv) {
+    G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
+    text = text + "   Cannot locate track vertex."; 
+    TG4Globals::Exception(text);
+  }  
+  
+  G4VSensitiveDetector* sd
+    = pv->GetLogicalVolume()->GetSensitiveDetector();
+
+  if (sd) {
+    TG4VSensitiveDetector* tsd = dynamic_cast<TG4VSensitiveDetector*>(sd);
+    if (tsd) 
+      tsd->UserProcessHits((G4Track*)track, 0);
+    else {
+      G4String text = "TG4TrackingAction::PreUserTrackingAction: \n";
+      text = text + "   Unknown sensitive detector type"; 
+      TG4Globals::Exception(text);
+    }          
+  } 
+}
+
+void TG4TrackingAction::PostUserTrackingAction(const G4Track* track)
+{
+// Called by G4 kernel after finishing tracking.
+// ---
+
+  // call post-tracking action of derived class
+  PostTrackingAction(track);
+}
+
diff --git a/TGeant4/TG4TrackingAction.h b/TGeant4/TG4TrackingAction.h
new file mode 100644 (file)
index 0000000..ad4ab48
--- /dev/null
@@ -0,0 +1,41 @@
+// $Id$
+// Category: event
+//
+// Class that ensures calling sensitive detector
+// before track starts stepping.
+// It also takes care of setting step status (kVertex)
+// and passing G4Track to TG4StepManager.
+
+#ifndef TG4_TRACKING_ACTION_H
+#define TG4_TRACKING_ACTION_H
+
+#include <G4UserTrackingAction.hh>
+#include <globals.hh>
+
+class G4Track;
+
+class TG4TrackingAction : public G4UserTrackingAction 
+{
+  public:
+    TG4TrackingAction();
+    // --> protected
+    // TG4TrackingAction(const TG4TrackingAction& right);
+    virtual ~TG4TrackingAction();
+   
+    // methods
+    virtual void PreTrackingAction(const G4Track* aTrack) {;}
+    virtual void PostTrackingAction(const G4Track* aTrack) {;}
+                  // the following methods should not
+                 // be overwritten in a derived class
+    virtual void PreUserTrackingAction(const G4Track* aTrack);
+    virtual void PostUserTrackingAction(const G4Track* aTrack);
+
+
+  protected:
+    TG4TrackingAction(const TG4TrackingAction& right);
+
+    // operators
+    TG4TrackingAction& operator=(const TG4TrackingAction& right);
+};
+
+#endif //TG4_TRACKING_ACTION_H