Newer
Older
// $Id:$
//====================================================================
//  AIDA Detector description implementation for LCD
//--------------------------------------------------------------------
//
//  Author     : M.Frank
//
//====================================================================
// Framework include files
#include "DDG4/Geant4SensitiveDetector_inline.h"
#include "DDG4/Factories.h"
/*
 *   DD4hep::Simulation namespace declaration
 */
namespace DD4hep {  namespace Simulation {
Markus Frank
committed
  /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  ///               Geant4GenericSD<Tracker>
  /// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  struct Tracker {};
  /// Method for generating hit(s) using the information of G4Step object.
  template <> bool Geant4GenericSD<Tracker>::buildHits(G4Step* step,G4TouchableHistory* ) {
    StepHandler h(step);
    Position prePos    = h.prePos();
    Position postPos   = h.postPos();
Markus Frank
committed
    Position direction = postPos - prePos;
Markus Frank
committed
    double   hit_len   = direction.R();
Markus Frank
committed
      double new_len = mean_length(h.preMom(),h.postMom())/hit_len;
      direction *= new_len/hit_len;
    }
    Geant4TrackerHit* hit = 
      new Geant4TrackerHit(h.track->GetTrackID(),
			   h.track->GetDefinition()->GetPDGEncoding(),
			   step->GetTotalEnergyDeposit(),
			   h.track->GetGlobalTime());
    hit->position = position;
    hit->momentum = direction;
    hit->length   = hit_len;
}}    // End namespace DD4hep::Simulation