Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-01 07:50:36

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 #include "SAXSSensitiveDetector.hh"
0030 
0031 #include "SAXSSensitiveDetectorHit.hh"
0032 
0033 #include "G4HCofThisEvent.hh"
0034 #include "G4Navigator.hh"
0035 #include "G4SDManager.hh"
0036 #include "G4Step.hh"
0037 #include "G4TouchableHistory.hh"
0038 #include "G4Track.hh"
0039 #include "G4ios.hh"
0040 
0041 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0042 
0043 SAXSSensitiveDetector::SAXSSensitiveDetector(G4String name) : G4VSensitiveDetector(name)
0044 {
0045   G4String HCname;
0046   collectionName.insert(HCname = "collection");
0047   fHCID = -1;
0048 
0049   fVarStopAndKill = true;
0050 
0051   fSDMessenger = new SAXSSensitiveDetectorMessenger(this);
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0055 
0056 SAXSSensitiveDetector::~SAXSSensitiveDetector() {}
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0059 
0060 void SAXSSensitiveDetector::Initialize(G4HCofThisEvent* HCE)
0061 {
0062   fHitsCollection = new SensitiveDetectorHitsCollection(SensitiveDetectorName, collectionName[0]);
0063   if (fHCID < 0) fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(fHitsCollection);
0064   HCE->AddHitsCollection(fHCID, fHitsCollection);
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0068 
0069 bool SAXSSensitiveDetector::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0070 {
0071   G4Track* vTrack = aStep->GetTrack();
0072 
0073   G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
0074 
0075   G4ThreeVector worldPosition = preStepPoint->GetPosition();
0076   G4ThreeVector localPosition =
0077     preStepPoint->GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(
0078       worldPosition);
0079 
0080   G4ThreeVector mom = preStepPoint->GetMomentumDirection();
0081 
0082   // if the partcile is not on the boundary of the sensitive detector, return
0083   if (!(preStepPoint->GetStepStatus() == fGeomBoundary)) {
0084     return false;
0085   }
0086 
0087   G4int vType = -1;
0088   if (preStepPoint->GetMass() == 0 && preStepPoint->GetCharge() == 0) {
0089     vType = 0;
0090   }
0091   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() == 0) {
0092     vType = 1;
0093   }
0094   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() > 0) {
0095     vType = 2;
0096   }
0097   else if (preStepPoint->GetMass() != 0 && preStepPoint->GetCharge() < 0) {
0098     vType = 3;
0099   }
0100 
0101   // insert a hit
0102   SAXSSensitiveDetectorHit* aHit = new SAXSSensitiveDetectorHit();
0103   aHit->SetPos(localPosition);
0104   aHit->SetMom(mom);
0105   aHit->SetType(vType);
0106   aHit->SetEnergy(preStepPoint->GetKineticEnergy());
0107   aHit->SetTime(preStepPoint->GetGlobalTime());
0108   aHit->SetTrackID(vTrack->GetTrackID());
0109   aHit->SetWeight(vTrack->GetWeight());
0110   fHitsCollection->insert(aHit);
0111 
0112   if (fVarStopAndKill) {
0113     vTrack->SetTrackStatus(fStopAndKill);
0114   }
0115 
0116   return true;
0117 }
0118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0119 
0120 void SAXSSensitiveDetector::EndOfEvent(G4HCofThisEvent*) {}
0121 
0122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....