Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:20:47

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