diff options
| author | shivesh <s.p.mandalia@qmul.ac.uk> | 2019-08-22 01:37:19 +0100 |
|---|---|---|
| committer | shivesh <s.p.mandalia@qmul.ac.uk> | 2019-08-22 01:37:19 +0100 |
| commit | e3079fb2367c26f767be41e6c313d960c517bbcd (patch) | |
| tree | 509f081184a4179894ab8370ea06425d46729e9a /src/G4BeamTestSC4SD.cxx | |
| parent | ba4dd395d1f163983f7102ff9a6c513cfe17912e (diff) | |
| download | G4BeamTest-e3079fb2367c26f767be41e6c313d960c517bbcd.tar.gz G4BeamTest-e3079fb2367c26f767be41e6c313d960c517bbcd.zip | |
Thu 22 Aug 01:37:19 BST 2019
Diffstat (limited to 'src/G4BeamTestSC4SD.cxx')
| -rw-r--r-- | src/G4BeamTestSC4SD.cxx | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/src/G4BeamTestSC4SD.cxx b/src/G4BeamTestSC4SD.cxx new file mode 100644 index 0000000..f9ef766 --- /dev/null +++ b/src/G4BeamTestSC4SD.cxx @@ -0,0 +1,90 @@ + +#include <sstream> + +#include "G4UnitsTable.hh" + +#include "G4BeamTestSC4SD.h" +#include "G4HCofThisEvent.hh" +#include "G4Step.hh" +#include "G4ThreeVector.hh" +#include "G4SDManager.hh" +#include "G4ios.hh" + + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4BeamTestSC4SD::G4BeamTestSC4SD(const G4String& name, const G4String& hitsCollectionName) + : G4VSensitiveDetector(name) + , fHitsCollection(NULL) +{ + collectionName.insert(hitsCollectionName); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4BeamTestSC4SD::~G4BeamTestSC4SD() +{ +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void G4BeamTestSC4SD::Initialize(G4HCofThisEvent* hce) +{ + // Create hits collection + + fHitsCollection + = new G4BeamTestSiHitsCollection(SensitiveDetectorName, collectionName[0]); + + // Add this collection in hce + + G4int hcID + = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); + hce->AddHitsCollection( hcID, fHitsCollection ); +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +G4bool G4BeamTestSC4SD::ProcessHits(G4Step* aStep, G4TouchableHistory*) +{ + // G4double stepl = 10; + // aStep->SetStepLength(stepl); + + G4String name=aStep->GetTrack()->GetDefinition()->GetParticleName(); + + + if (name == "pi-" || name == "e-") { + G4cout << " Particle_name hit SC4 = " << name << G4endl; + // total energy + G4double etot = aStep->GetTrack()->GetTotalEnergy(); + // energy deposit + G4double edep = aStep->GetTotalEnergyDeposit(); + + G4BeamTestSiHit* newHit = new G4BeamTestSiHit(); + // G4StepPoint* preStepPoint = aStep->GetPreStepPoint(); + + newHit->SetTrackID (aStep->GetTrack()->GetTrackID()); + newHit->SetEdep(edep); + newHit->SetPos (aStep->GetPostStepPoint()->GetPosition()); + newHit-> SetTime (aStep->GetPreStepPoint()->GetProperTime()); + fHitsCollection->insert( newHit ); + + return true; + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + +void G4BeamTestSC4SD::EndOfEvent(G4HCofThisEvent*) +{ + if ( verboseLevel>1 ) { + G4int nofHits = fHitsCollection->entries(); + G4cout << G4endl + << "-------->Hits Collection: in this event they are " << nofHits + << " hits in the tracker chambers: " << G4endl; + for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print(); + + } +} + +//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... + |
