00001 //<<<<<< INCLUDES >>>>>> 00002 00003 #include "VisExamples/VisG4ExN02/src/VisG4ExampleSD.h" 00004 #include "VisExamples/VisG4ExN02/src/VisG4ExampleHit.h" 00005 #include <G4HCofThisEvent.hh> 00006 #include <G4Step.hh> 00007 #include <G4ThreeVector.hh> 00008 #include <G4SDManager.hh> 00009 00010 //<<<<<< PRIVATE DEFINES >>>>>> 00011 //<<<<<< PRIVATE CONSTANTS >>>>>> 00012 //<<<<<< PRIVATE TYPES >>>>>> 00013 //<<<<<< PRIVATE VARIABLE DEFINITIONS >>>>>> 00014 //<<<<<< PUBLIC VARIABLE DEFINITIONS >>>>>> 00015 //<<<<<< CLASS STRUCTURE INITIALIZATION >>>>>> 00016 //<<<<<< PRIVATE FUNCTION DEFINITIONS >>>>>> 00017 //<<<<<< PUBLIC FUNCTION DEFINITIONS >>>>>> 00018 //<<<<<< MEMBER FUNCTION DEFINITIONS >>>>>> 00019 00020 VisG4ExampleSD::VisG4ExampleSD (const std::string &name) 00021 : G4VSensitiveDetector (name) 00022 { collectionName.insert ("trackerCollection"); } 00023 00024 void 00025 VisG4ExampleSD::Initialize (G4HCofThisEvent *HCE) 00026 { 00027 static int HCID = G4SDManager::GetSDMpointer ()->GetCollectionID (collectionName [0]); 00028 m_hits = new VisG4ExampleHitsCollection (SensitiveDetectorName, collectionName [0]); 00029 HCE->AddHitsCollection (HCID, m_hits); 00030 } 00031 00032 bool 00033 VisG4ExampleSD::ProcessHits (G4Step *step, G4TouchableHistory *) 00034 { 00035 if (! step->GetTotalEnergyDeposit ()) 00036 return false; 00037 00038 VisG4ExampleHit *hit = new VisG4ExampleHit; 00039 hit->setTrackId (step->GetTrack ()->GetTrackID ()); 00040 hit->setChamber (step->GetPreStepPoint ()->GetTouchable () 00041 ->GetReplicaNumber ()); 00042 hit->setEnergy (step->GetTotalEnergyDeposit ()); 00043 hit->setPosition (step->GetPostStepPoint ()->GetPosition ()); 00044 00045 m_hits->insert (hit); 00046 return true; 00047 }