Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:14

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file SAXSSensitiveDetector.cc
0027 /// \brief Implementation of the SAXSSensitiveDetector class
0028 //
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0030 
0031 #include "SAXSSensitiveDetector.hh"
0032 
0033 #include "SAXSSensitiveDetectorHit.hh"
0034 
0035 #include "G4HCofThisEvent.hh"
0036 #include "G4Navigator.hh"
0037 #include "G4SDManager.hh"
0038 #include "G4Step.hh"
0039 #include "G4TouchableHistory.hh"
0040 #include "G4Track.hh"
0041 #include "G4ios.hh"
0042 
0043 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0044 
0045 SAXSSensitiveDetector::SAXSSensitiveDetector(G4String name) : G4VSensitiveDetector(name)
0046 {
0047   G4String HCname;
0048   collectionName.insert(HCname = "collection");
0049   fHCID = -1;
0050 
0051   fVarStopAndKill = true;
0052 
0053   fSDMessenger = new SAXSSensitiveDetectorMessenger(this);
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0057 
0058 SAXSSensitiveDetector::~SAXSSensitiveDetector() {}
0059 
0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0061 
0062 void SAXSSensitiveDetector::Initialize(G4HCofThisEvent* HCE)
0063 {
0064   fHitsCollection = new SensitiveDetectorHitsCollection(SensitiveDetectorName, collectionName[0]);
0065   if (fHCID < 0) fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
0066   HCE->AddHitsCollection(fHCID, fHitsCollection);
0067 }
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0070 
0071 bool SAXSSensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0072 {
0073   G4Track* vTrack = aStep->GetTrack();
0074 
0075   G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
0076 
0077   G4ThreeVector worldPosition = preStepPoint->GetPosition();
0078   G4ThreeVector localPosition =
0079     preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
0080       worldPosition);
0081 
0082   G4ThreeVector mom = preStepPoint->GetMomentumDirection();
0083 
0084   // if the partcile is not on the boundary of the sensitive detector, return
0085   if (!(preStepPoint->GetStepStatus() == fGeomBoundary)) {
0086     return false;
0087   }
0088 
0089   G4int vType = -1;
0090   if (preStepPoint->GetMass() == 0 && preStepPoint->GetCharge() == 0) {
0091     vType = 0;
0092   }
0093   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() == 0) {
0094     vType = 1;
0095   }
0096   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() > 0) {
0097     vType = 2;
0098   }
0099   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() < 0) {
0100     vType = 3;
0101   }
0102 
0103   // insert a hit
0104   SAXSSensitiveDetectorHit* aHit = new SAXSSensitiveDetectorHit();
0105   aHit->SetPos(localPosition);
0106   aHit->SetMom(mom);
0107   aHit->SetType(vType);
0108   aHit->SetEnergy(preStepPoint->GetKineticEnergy());
0109   aHit->SetTime(preStepPoint->GetGlobalTime());
0110   aHit->SetTrackID(vTrack->GetTrackID());
0111   aHit->SetWeight(vTrack->GetWeight());
0112   fHitsCollection->insert(aHit);
0113 
0114   if (fVarStopAndKill) {
0115     vTrack->SetTrackStatus(fStopAndKill);
0116   }
0117 
0118   return true;
0119 }
0120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0121 
0122 void SAXSSensitiveDetector::EndOfEvent(G4HCofThisEvent*) {}
0123 
0124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....