aboutsummaryrefslogtreecommitdiffstats
path: root/src/G4BeamTestSiSD.cxx
diff options
context:
space:
mode:
authorshivesh <s.p.mandalia@qmul.ac.uk>2019-08-22 01:37:19 +0100
committershivesh <s.p.mandalia@qmul.ac.uk>2019-08-22 01:37:19 +0100
commite3079fb2367c26f767be41e6c313d960c517bbcd (patch)
tree509f081184a4179894ab8370ea06425d46729e9a /src/G4BeamTestSiSD.cxx
parentba4dd395d1f163983f7102ff9a6c513cfe17912e (diff)
downloadG4BeamTest-e3079fb2367c26f767be41e6c313d960c517bbcd.tar.gz
G4BeamTest-e3079fb2367c26f767be41e6c313d960c517bbcd.zip
Thu 22 Aug 01:37:19 BST 2019
Diffstat (limited to 'src/G4BeamTestSiSD.cxx')
-rw-r--r--src/G4BeamTestSiSD.cxx125
1 files changed, 58 insertions, 67 deletions
diff --git a/src/G4BeamTestSiSD.cxx b/src/G4BeamTestSiSD.cxx
index afa6bf8..194a0fc 100644
--- a/src/G4BeamTestSiSD.cxx
+++ b/src/G4BeamTestSiSD.cxx
@@ -15,8 +15,7 @@ std::ofstream testdata("EVENTDATA.txt");
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4BeamTestSiSD::G4BeamTestSiSD(const G4String& name,
- const G4String& hitsCollectionName)
+G4BeamTestSiSD::G4BeamTestSiSD(const G4String& name, const G4String& hitsCollectionName)
: G4VSensitiveDetector(name)
, fHitsCollection(NULL)
{
@@ -25,7 +24,7 @@ G4BeamTestSiSD::G4BeamTestSiSD(const G4String& name,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4BeamTestSiSD::~G4BeamTestSiSD()
+G4BeamTestSiSD::~G4BeamTestSiSD()
{ // testdata << "Arrival time" << " " << "Energy " << " " << "Distance" << std::endl;
}
@@ -38,100 +37,92 @@ void G4BeamTestSiSD::Initialize(G4HCofThisEvent* hce)
testdata << "*" << std::endl;
- fHitsCollection
- = new G4BeamTestSiHitsCollection(SensitiveDetectorName, collectionName[0]);
+ fHitsCollection
+ = new G4BeamTestSiHitsCollection(SensitiveDetectorName, collectionName[0]);
// Add this collection in hce
- G4int hcID
+ G4int hcID
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
- G4cout << "hcID " << hcID << G4endl;
- hce->AddHitsCollection( hcID, fHitsCollection );
+ hce->AddHitsCollection( hcID, fHitsCollection );
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
-G4bool G4BeamTestSiSD::ProcessHits(G4Step* aStep,
- G4TouchableHistory*)
-{
+G4bool G4BeamTestSiSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
+{
// G4double stepl = 10;
// aStep->SetStepLength(stepl);
G4String name=aStep->GetTrack()->GetDefinition()->GetParticleName();
- /* G4cout << " Particle_name = " << name << G4endl; */
+ // G4cout << " Particle_name = " << name << G4endl;
if (name == "opticalphoton" || name == "gamma") {
- // G4cout << " Particle_name = " << name << G4endl;
+ // G4cout << " Particle_name = " << name << G4endl;
-// total energy
- G4double etot = aStep->GetTrack()->GetTotalEnergy();
-// energy deposit
- G4double edep = aStep->GetTotalEnergyDeposit();
+ // total energy
+ G4double etot = aStep->GetTrack()->GetTotalEnergy();
+ // energy deposit
+ G4double edep = aStep->GetTotalEnergyDeposit();
- if (etot < 2.26 * CLHEP::eV) { // Lower threshold of PMT - 550nm
- // if (etot < 2.48 * CLHEP::eV) { // Lower threshold of PMT - 500nm
- // G4cout << "particle " << name << " under threshold with energy " << etot << G4endl;
- return true;
- }
- if (etot > 3.55 * CLHEP::eV) { // Upper threshold of PMT - 350nm
- // if (etot > 3.10 * CLHEP::eV) { // Upper threshold of PMT - 400nm
- // G4cout << "particle " << name << " over threshold with energy " << etot << G4endl;
- return true;
- }
- // G4cout << "inserting particle " << name << " with energy " << etot << " into record" << G4endl;
+ if (etot < 2.26 * CLHEP::eV) { // Lower threshold of PMT - 550nm
+ // if (etot < 2.48 * CLHEP::eV) { // Lower threshold of PMT - 500nm
+ // G4cout << "particle " << name << " under threshold with energy " << etot << G4endl;
+ return true;
+ }
+ if (etot > 3.55 * CLHEP::eV) { // Upper threshold of PMT - 350nm
+ // if (etot > 3.10 * CLHEP::eV) { // Upper threshold of PMT - 400nm
+ // G4cout << "particle " << name << " over threshold with energy " << etot << G4endl;
+ return true;
+ }
+ // G4cout << "inserting particle " << name << " with energy " << etot << " into record" << G4endl;
-// if (edep==0.) return false;
+ G4BeamTestSiHit* newHit = new G4BeamTestSiHit();
+ // G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
- /* G4cout << " Particle_name_after_edep = " << name << G4endl; */
+ newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
+ newHit->SetEdep(edep);
+ newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
+ newHit-> SetTime (aStep->GetPreStepPoint()->GetProperTime());
+ fHitsCollection->insert( newHit );
- 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 );
-
+ G4double zbef =aStep->GetPreStepPoint()->GetPosition().z();
+ G4double zaft =aStep->GetPostStepPoint()->GetPosition().z();
+ G4double zdelta = zaft-zbef;
+ //G4double zintial = aStep
- G4double zbef =aStep->GetPreStepPoint()->GetPosition().z();
- G4double zaft =aStep->GetPostStepPoint()->GetPosition().z();
- G4double zdelta = zaft-zbef;
- //G4double zintial = aStep
+ G4double zfix = (zdelta + (zbef- 4.7))*1000;
- G4double zfix = (zdelta + (zbef- 4.7))*1000;
+ // G4double zfix = (zdelta + (zbef- 375));
- // G4double zfix = (zdelta + (zbef- 375));
+ // G4cout << " Z VALUE = " << zfix << G4endl;
+ G4double time = aStep->GetPreStepPoint()->GetProperTime();
+ G4double gtime = aStep->GetPreStepPoint()->GetGlobalTime();
+ // G4cout << "Global Time " << gtime << G4endl;
+ G4double timefix = time - 0.288861775183071;
- // G4cout << " Z VALUE = " << zfix << G4endl;
- G4double time = aStep->GetPreStepPoint()->GetProperTime();
- G4double gtime = aStep->GetPreStepPoint()->GetGlobalTime();
- // G4cout << "Global Time " << gtime << G4endl;
- G4double timefix = time - 0.288861775183071;
+ /* G4cout << "TIME == " << time << G4endl; */
-/* G4cout << "TIME == " << time << G4endl; */
-
- G4double vel = aStep->GetPreStepPoint()->GetVelocity();
-
- G4double vel2 = zfix/time;
+ G4double vel = aStep->GetPreStepPoint()->GetVelocity();
- // G4cout << G4BestUnit(vel, "Speed")<< G4endl;
+ G4double vel2 = zfix/time;
-/*
+ // G4cout << G4BestUnit(vel, "Speed")<< G4endl;
- testdata << timefix << " " << edep << " " << zfix << std::endl;
-
- h_bragg9->Fill(zfix,edep);
- enetime->Fill(timefix, edep);
- // newHit->Print();
- sally->Fill(zfix,vel);
+ /*
- G4cout << "DISTANCE = " << zfix << " Velocity = " << vel2 << " Velocityold = " << vel <<G4endl;
+ testdata << timefix << " " << edep << " " << zfix << std::endl;
+ h_bragg9->Fill(zfix,edep);
+ enetime->Fill(timefix, edep);
+ // newHit->Print();
+ sally->Fill(zfix,vel);
-*/
- return true;
+ G4cout << "DISTANCE = " << zfix << " Velocity = " << vel2 << " Velocityold = " << vel <<G4endl;
+ */
+ return true;
}
}
@@ -139,10 +130,10 @@ G4bool G4BeamTestSiSD::ProcessHits(G4Step* aStep,
void G4BeamTestSiSD::EndOfEvent(G4HCofThisEvent*)
{
- if ( verboseLevel>1 ) {
+ if ( verboseLevel>1 ) {
G4int nofHits = fHitsCollection->entries();
G4cout << G4endl
- << "-------->Hits Collection: in this event they are " << nofHits
+ << "-------->Hits Collection: in this event they are " << nofHits
<< " hits in the tracker chambers: " << G4endl;
for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();