Newer
Older
Markus Frank
committed
//==========================================================================
// AIDA Detector description implementation for LCD
Markus Frank
committed
//--------------------------------------------------------------------------
// Copyright (C) Organisation europeenne pour la Recherche nucleaire (CERN)
Markus Frank
committed
// All rights reserved.
Markus Frank
committed
// For the licensing terms see $DD4hepINSTALL/LICENSE.
// For the list of contributors see $DD4hepINSTALL/doc/CREDITS.
Markus Frank
committed
// Author : M.Frank
//
//==========================================================================
// Framework include files
#include "DDG4/Geant4SensitiveDetector_inline.h"
#include "DDG4/Factories.h"
#include "DDG4/Geant4StepHandler.h"
#include "DDG4/Geant4Mapping.h"
Markus Frank
committed
#include <stdexcept>
/*
* DD4hep::Simulation namespace declaration
*/
namespace DD4hep { namespace Simulation {
Markus Frank
committed
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* /*hist*/ ) {
Position prePos = h.prePos();
Position postPos = h.postPos();
Position direction = postPos - prePos;
Position position = mean_direction(prePos,postPos);
double hit_len = direction.R();
if (hit_len > 0) {
Markus Frank
committed
double new_len = mean_length(h.preMom(),h.postMom())/hit_len;
direction *= new_len/hit_len;
Markus Frank
committed
// G4cout << "----------- Geant4GenericSD<Tracker>::buildHits : position : " << prePos << G4endl ;
Markus Frank
committed
Geant4TrackerHit* hit =
new Geant4TrackerHit(h.track->GetTrackID(),
h.track->GetDefinition()->GetPDGEncoding(),
step->GetTotalEnergyDeposit(),
h.track->GetGlobalTime());
Markus Frank
committed
HitContribution contrib = Geant4Hit::extractContribution(step);
hit->cellID = getCellID( step ) ;
Markus Frank
committed
hit->energyDeposit = contrib.deposit ;
hit->position = position;
hit->momentum = direction;
hit->length = hit_len;
collection(0)->insert(hit);
return 1;
}
throw std::runtime_error("new() failed: Cannot allocate hit object");
typedef Geant4GenericSD<Tracker> Geant4Tracker;
}} // End namespace DD4hep::Simulation
Markus Frank
committed
DECLARE_GEANT4SENSITIVEDETECTOR_NS(DD4hep::Simulation,Geant4Tracker)