LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
SimEnergyDepositSD.cc
Go to the documentation of this file.
1 //
2 // __ __ __ __ __
3 // ____ ______/ /_____ _/ // / / /_/ /__
4 // / __ `/ ___/ __/ __ `/ // /_/ __/ //_/
5 // / /_/ / / / /_/ /_/ /__ __/ /_/ ,<
6 // \__,_/_/ \__/\__, / /_/ \__/_/|_|
7 // /____/
8 //
9 // artg4tk: art based Geant 4 Toolkit
10 //
11 //=============================================================================
12 // SimEnergyDeposit.cc: Class representing a sensitive tracking detector
13 // Author: Hans Wenzel (Fermilab)
14 //=============================================================================
16 #include "Geant4/G4Cerenkov.hh"
17 #include "Geant4/G4Event.hh"
18 #include "Geant4/G4EventManager.hh"
19 #include "Geant4/G4HCofThisEvent.hh"
20 #include "Geant4/G4SDManager.hh"
21 #include "Geant4/G4Scintillation.hh"
22 #include "Geant4/G4Step.hh"
23 #include "Geant4/G4SteppingManager.hh"
24 #include "Geant4/G4ThreeVector.hh"
25 #include "Geant4/G4VSolid.hh"
26 #include "Geant4/G4VVisManager.hh"
27 #include "Geant4/G4ios.hh"
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 namespace larg4 {
31 
32  SimEnergyDepositSD::SimEnergyDepositSD(G4String name) : G4VSensitiveDetector(name)
33  {
34  hitCollection.clear();
35  }
36 
37  //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
38 
40 
41  //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  {
45  hitCollection.clear();
46  }
47  //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
49  G4bool SimEnergyDepositSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
50  {
51  G4double edep = aStep->GetTotalEnergyDeposit() / CLHEP::MeV;
52 
53  if (edep == 0.) return false;
54  //std::cout << "7777777777777777: "<< aStep->GetTotalEnergyDeposit()/CLHEP::MeV << " " << aStep->GetTotalEnergyDeposit() <<std::endl;
55  const int electronsperMeV = 10000;
56  int nrelec = (int)round(edep * electronsperMeV);
57  if (aStep->GetTrack()->GetDynamicParticle()->GetCharge() == 0) return false;
58  G4int photons = 0;
59  G4SteppingManager* fpSteppingManager =
60  G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager();
61  G4StepStatus stepStatus = fpSteppingManager->GetfStepStatus();
62  if (stepStatus != fAtRestDoItProc) {
63  G4ProcessVector* procPost = fpSteppingManager->GetfPostStepDoItVector();
64  size_t MAXofPostStepLoops = fpSteppingManager->GetMAXofPostStepLoops();
65  for (size_t i3 = 0; i3 < MAXofPostStepLoops; i3++) {
66  if (!(*procPost)[i3]) continue;
67  /*
68  if ((*procPost)[i3]->GetProcessName() == "Cerenkov") {
69  G4Cerenkov* proc =(G4Cerenkov*) (*procPost)[i3];
70  photons+=proc->GetNumPhotons();
71  }
72  */
73  if ((*procPost)[i3]->GetProcessName() == "Scintillation") {
74  G4Scintillation* proc1 = (G4Scintillation*)(*procPost)[i3];
75  photons += proc1->GetNumPhotons();
76  }
77  }
78  }
79  geo::Point_t start = geo::Point_t(aStep->GetPreStepPoint()->GetPosition().x() / CLHEP::cm,
80  aStep->GetPreStepPoint()->GetPosition().y() / CLHEP::cm,
81  aStep->GetPreStepPoint()->GetPosition().z() / CLHEP::cm);
82  geo::Point_t end = geo::Point_t(aStep->GetPostStepPoint()->GetPosition().x() / CLHEP::cm,
83  aStep->GetPostStepPoint()->GetPosition().y() / CLHEP::cm,
84  aStep->GetPostStepPoint()->GetPosition().z() / CLHEP::cm);
85  sim::SimEnergyDeposit newHit =
86  sim::SimEnergyDeposit(photons,
87  nrelec,
88  1.0,
89  edep,
90  start,
91  end,
92  aStep->GetPreStepPoint()->GetGlobalTime() / CLHEP::ns,
93  aStep->GetPostStepPoint()->GetGlobalTime() / CLHEP::ns,
94  aStep->GetTrack()->GetTrackID(),
95  aStep->GetTrack()->GetParticleDefinition()->GetPDGEncoding(),
96  aStep->GetTrack()->GetTrackID() //original track id
97  );
98  hitCollection.push_back(newHit);
99  return true;
100  } // end ProcessHits
101 } // end namespace larg4
sim::SimEnergyDepositCollection hitCollection
Geant4 interface.
void Initialize(G4HCofThisEvent *)
decltype(auto) constexpr end(T &&obj)
ADL-aware version of std::end.
Definition: StdUtils.h:77
Double_t edep
Definition: macro.C:13
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
Definition: geo_vectors.h:180
Energy deposition in the active material.
G4bool ProcessHits(G4Step *, G4TouchableHistory *)