Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:30:48

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 RMC01SD.cc
0027 /// \brief Implementation of the RMC01SD class
0028 
0029 //      Class Name:        RMC01SD
0030 //        Author:               L. Desorgher
0031 //         Organisation:         SpaceIT GmbH
0032 //        Contract:        ESA contract 21435/08/NL/AT
0033 //         Customer:             ESA/ESTEC
0034 //////////////////////////////////////////////////////////////
0035 
0036 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 #include "RMC01SD.hh"
0040 
0041 #include "G4HCofThisEvent.hh"
0042 #include "G4LogicalVolume.hh"
0043 #include "G4LogicalVolumeStore.hh"
0044 #include "G4ParticleDefinition.hh"
0045 #include "G4PhysicalVolumeStore.hh"
0046 #include "G4SDManager.hh"
0047 #include "G4Step.hh"
0048 #include "G4Track.hh"
0049 #include "G4VPhysicalVolume.hh"
0050 #include "G4VProcess.hh"
0051 #include "G4ios.hh"
0052 
0053 // #include "G4AdjointAnalysisManager.hh"
0054 #include "G4Electron.hh"
0055 #include "G4Gamma.hh"
0056 #include "G4Proton.hh"
0057 #include "G4RunManager.hh"
0058 #include "G4THitsCollection.hh"
0059 
0060 class G4Step;
0061 
0062 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0063 
0064 RMC01SD::RMC01SD(G4String name)
0065   : G4VSensitiveDetector(name),
0066     fTotalEventEdep(0.),
0067     fEventEdepCollection(0),
0068     fProtonCurrentCollection(0),
0069     fGammaCurrentCollection(0),
0070     fElectronCurrentCollection(0)
0071 {
0072   collectionName.insert("edep");
0073   collectionName.insert("current_electron");
0074   collectionName.insert("current_proton");
0075   collectionName.insert("current_gamma");
0076 }
0077 
0078 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0079 
0080 RMC01SD::~RMC01SD()
0081 {
0082   ;
0083 }
0084 
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0086 
0087 void RMC01SD::Initialize(G4HCofThisEvent* HCE)
0088 {
0089   fTotalEventEdep = 0.;
0090   static G4int HCID = -1;
0091 
0092   fEventEdepCollection =
0093     new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[0]);
0094   HCID = GetCollectionID(0);
0095   HCE->AddHitsCollection(HCID, fEventEdepCollection);
0096 
0097   fElectronCurrentCollection =
0098     new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[1]);
0099   HCID = GetCollectionID(1);
0100   HCE->AddHitsCollection(HCID, fElectronCurrentCollection);
0101 
0102   fProtonCurrentCollection =
0103     new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[2]);
0104   HCID = GetCollectionID(2);
0105   HCE->AddHitsCollection(HCID, fProtonCurrentCollection);
0106 
0107   fGammaCurrentCollection =
0108     new G4THitsCollection<RMC01DoubleWithWeightHit>(SensitiveDetectorName, collectionName[3]);
0109   HCID = GetCollectionID(3);
0110   HCE->AddHitsCollection(HCID, fGammaCurrentCollection);
0111 }
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 
0115 G4bool RMC01SD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0116 {
0117   G4double weight = aStep->GetTrack()->GetWeight();
0118   G4double edep = aStep->GetTotalEnergyDeposit();
0119   if (edep > 0) fEventEdepCollection->insert(new RMC01DoubleWithWeightHit(edep, weight));
0120 
0121   G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
0122 
0123   if (preStepPoint->GetStepStatus() == fGeomBoundary) {
0124     // Entering the sensitive volume
0125     weight = preStepPoint->GetWeight();
0126     G4double eKin = preStepPoint->GetKineticEnergy();
0127     G4ParticleDefinition* thePartDef = aStep->GetTrack()->GetDefinition();
0128     if (thePartDef == G4Electron::Electron())
0129       fElectronCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0130     else if (thePartDef == G4Gamma::Gamma())
0131       fGammaCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0132     else if (thePartDef == G4Proton::Proton())
0133       fProtonCurrentCollection->insert(new RMC01DoubleWithWeightHit(eKin, weight));
0134   }
0135   return true;
0136 }
0137 
0138 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0139 
0140 void RMC01SD::EndOfEvent(G4HCofThisEvent*)
0141 {
0142   fEventEdepCollection->insert(new RMC01DoubleWithWeightHit(fTotalEventEdep, 1.));
0143 }
0144 
0145 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0146 
0147 void RMC01SD::Clear()
0148 {
0149   ;
0150 }
0151 
0152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0153 
0154 void RMC01SD::DrawAll()
0155 {
0156   ;
0157 }
0158 
0159 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0160 
0161 void RMC01SD::PrintAll()
0162 {
0163   ;
0164 }
0165 
0166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......