ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
STCyclotronSensitiveTarget.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file STCyclotronSensitiveTarget.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // Author: F. Poignant, floriane.poignant@gmail.com
27 //
28 // file STCyclotronSensitiveTarget.cc
29 //
30 #include "STCyclotronAnalysis.hh"
31 #include "STCyclotronRun.hh"
33 
34 #include "G4RunManager.hh"
35 #include "G4HCofThisEvent.hh"
36 #include "G4UnitsTable.hh"
37 #include "G4Step.hh"
38 #include "G4SteppingManager.hh"
39 #include "G4ThreeVector.hh"
40 #include "G4SDManager.hh"
41 #include "G4ios.hh"
42 #include "G4SystemOfUnits.hh"
43 #include "G4ThreeVector.hh"
44 #include "G4Track.hh"
45 #include "G4ParticleDefinition.hh"
46 #include "G4DecayTable.hh"
47 #include "G4VDecayChannel.hh"
48 #include "G4RadioactiveDecay.hh"
49 #include "G4TrackVector.hh"
50 #include "G4VProcess.hh"
51 #include "G4Tubs.hh"
52 #include <map>
53 
56  : G4VSensitiveDetector(name),
57  fDet(det)
58 {
59  fTempTrack = 0;
60  fTempTrack1 = 0;
61  fTempEnergy = 0.;
62  fTempVector = G4ThreeVector(0.,0.,0.);
63  fTrack=0;
64 }
65 
67 {
68  delete fTrack;
69  }
70 
72 {
73 
75  fTrack = aStep->GetTrack();
76 
77  auto analysisManager = G4AnalysisManager::Instance();
78 
79  //----------------------------------------------
80  // Volume info
81  //----------------------------------------------
82  G4double targetHalfDiameter= (fDet->GetTargetDiameter())/2.;
83 
84  //----------------------------------------------
85  // Step information
86  //----------------------------------------------
87 
90  G4ThreeVector momentumDirection = aStep->GetPreStepPoint()->GetMomentumDirection();
91  G4ThreeVector vectorPosition = aStep->GetPreStepPoint()->GetPosition();
92 
93  //----------------------------------------------
94  // Track
95  //----------------------------------------------
96 
97  G4ParticleDefinition* thePartDef = fTrack->GetDefinition();
100  G4double timeLife = fTrack->GetDefinition()->GetPDGLifeTime(); //<---
101  const G4VProcess* process = fTrack->GetCreatorProcess();
102 
103  //----------------------------------------------
104  // Collect general information concerning all of the particles
105  // Collect energy deposition ; separe decay case to beam case
106  //----------------------------------------------
107 
108  fRun->EnergyDepositionTarget(edep);
109 
110 
111  //----------------------------------------------
112  //Collect information about protons and deuterons
113  //----------------------------------------------
114 
115  if(name == "proton" || name == "deuteron")
116  {
117 
118  if(fTrack->GetTrackID()!=fTempTrack && (momentumDirection.getZ()>0.) &&
119  vectorPosition.getX()<targetHalfDiameter &&
120  vectorPosition.getX()>-targetHalfDiameter &&
121  vectorPosition.getY()<targetHalfDiameter &&
122  vectorPosition.getY()>-targetHalfDiameter)
123  {
124  analysisManager->FillH2(0,vectorPosition.getX(),vectorPosition.getY());
125  analysisManager->FillH1(0,energy);
126  fRun->CountParticlesTarget();
128  }
129 
130  if(fTempTrack1 == 0)
131  {
133  }
134 
135  if(fTrack->GetTrackID()!=fTempTrack1 && (momentumDirection.getZ()>0.) &&
136  fTempVector.getX()<targetHalfDiameter &&
137  fTempVector.getX()>-targetHalfDiameter &&
138  fTempVector.getY()<targetHalfDiameter &&
139  fTempVector.getY()>-targetHalfDiameter )
140  {
141 
142  analysisManager->FillH2(4,fTempVector.getX(),fTempVector.getY());
143  analysisManager->FillH1(2,fTempEnergy);
145  }
146 
147  fTempVector = aStep->GetPostStepPoint()->GetPosition(); //vectorPosition;
148  fTempEnergy = aStep->GetPostStepPoint()->GetKineticEnergy(); //energy;
149 
150  analysisManager->FillH2(3,vectorPosition.getZ(),energy);
151 
152  }
153 
154  //----------------------------------------------
155  // Store ID for particles that are
156  // not protons/electrons or deuterons
157  //----------------------------------------------
158 
159  if((name != "proton") && (name != "e-") && (name != "deuteron"))
160  {
162  }
163 
164  //----------------------------------------------
165  // Collect of information for unstable isotopes
166  // generated from an interaction with the target
167  //----------------------------------------------
168 
169  if (name!="deuteron")
170  {
171  if (( partType == "nucleus") && !(thePartDef->GetPDGStable()) && (fTrack->GetCurrentStepNumber()==1) && timeLife!=0.)
172  {
173  //G4cout << "Saving unstable particles ..." << G4endl;
174  G4int Z=thePartDef->GetAtomicNumber();
175  G4int A=thePartDef->GetAtomicMass();
176  analysisManager->FillH2(2,Z,A);
177 
178  //----------------------------------------------
179  // isotopes count
180  //----------------------------------------------
181 
182  fRun->PrimaryIsotopeCountTarget(name,timeLife);
183  analysisManager->FillH1(4,fTrack->GetPosition().getZ());
184  //particle that created the nucleus
185  std::map<G4int,G4String> parentID = fRun->GetIsotopeID();
186  G4String nameParent = parentID[fTrack->GetParentID()];
187  fRun->ParticleParent(name, process->GetProcessName());
188 
189  //G4cout << name << " : " << process->GetProcessName() << " with track ID " << fTrack->GetTrackID() << " and step ID " << fTrack->GetCurrentStepNumber() << G4endl;
190 
191  }
192  }
193 
194  //----------------------------------------------
195  // Collect of information for stable isotopes
196  // generated from an interaction with the target
197  //----------------------------------------------
198 
199  if (name!="deuteron")
200  {
201  if (( partType == "nucleus") && (thePartDef->GetPDGStable()) && (process->GetProcessName() != "RadioactiveDecay") && (fTrack->GetCurrentStepNumber()==1) )
202  {
203  //----------------------------------------------
204  // isotopes count
205  //----------------------------------------------
206  fRun->CountStableIsotopes(name);
207  }
208  }
209 
210 
211  //----------------------------------------------
212  // Collect unstable isotopes from decay
213  //----------------------------------------------
214 
215  if (( partType == "nucleus") && !(thePartDef->GetPDGStable()) && (process->GetProcessName() == "RadioactiveDecay") && (fTrack->GetCurrentStepNumber()==1) && timeLife!=0)
216  {
217  std::map<G4int,G4String>::iterator itbis;
218  std::map<G4int,G4String> parentID = fRun->GetIsotopeID();
219  G4String nameParent = parentID[fTrack->GetParentID()];
220  fRun->DecayIsotopeCountTarget(name,nameParent,timeLife);
221  }
222 
223  //----------------------------------------------
224  // Collect any other particles emitted
225  //----------------------------------------------
226 
227  if((partType!="nucleus")&&(name!="proton")&&(name!="deuteron"))
228  {
229  fRun->ParticleCountTarget(name);
230  //Condition so the particle will be counted for only one step
231  if((fTrack->GetCurrentStepNumber()==1))
232  {
233  if(process->GetProcessName() != "RadioactiveDecay")
234  {
235  if(name=="e+"){
236  analysisManager->FillH1(5,energy);
237  }
238  if(name=="e-"){
239  analysisManager->FillH1(6,energy);
240  }
241  if(name=="gamma"){
242  analysisManager->FillH1(7,energy);
243  }
244  if(name=="neutron"){
245  analysisManager->FillH1(8,energy);
246  }
247  }
248 
249  if(process->GetProcessName() == "RadioactiveDecay")
250  {
251  if(name=="e+"){
252  analysisManager->FillH1(9,energy);
253  }
254  if(name=="e-"){
255  analysisManager->FillH1(10,energy);
256  }
257  if(name=="gamma"){
258  analysisManager->FillH1(11,energy);
259  }
260  if(name=="neutron"){
261  analysisManager->FillH1(12,energy);
262  }
263  if(name=="nu_e"){
264  analysisManager->FillH1(13,energy);
265  }
266  if(name=="anti_nu_e"){
267  analysisManager->FillH1(14,energy);
268  }
269  }
270  }
271  }
272 
273 
277 
278  return true;
279 
280 }
281 
282