ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TrackerSD.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file TrackerSD.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 // This example is provided by the Geant4-DNA collaboration
27 // Any report or published results obtained using the Geant4-DNA software
28 // shall cite the following Geant4-DNA collaboration publications:
29 // Med. Phys. 45 (2018) e722-e739
30 // Phys. Med. 31 (2015) 861-874
31 // Med. Phys. 37 (2010) 4692-4708
32 // Int. J. Model. Simul. Sci. Comput. 1 (2010) 157\u2013178
33 //
34 // The Geant4-DNA web site is available at http://geant4-dna.org
35 //
38 
39 #include "Analysis.hh"
40 #include "TrackerSD.hh"
41 #include "Randomize.hh"
42 #include "G4SDManager.hh"
43 
44 #include "G4RandomDirection.hh"
45 #include "G4SystemOfUnits.hh"
46 
47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
48 
50  const G4String& hitsCollectionName)
52 fHitsCollection(NULL)
53 {
54  collectionName.insert(hitsCollectionName);
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {}
61 
62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
63 
65 {
66  // Create hits collection
69 
70  // Add this collection in hce
71 
72  G4int hcID
74 
75  hce->AddHitsCollection( hcID, fHitsCollection );
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
79 
82 {
83  // energy deposit
85 
86  if (edep==0.) return false;
87 
88  TrackerHit* newHit = new TrackerHit();
89 
90  newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
91  newHit->SetEdep(edep);
92  newHit->SetPos (aStep->GetPostStepPoint()->GetPosition());
93 
94  if (aStep->GetTrack()->GetTrackID()==1&&aStep->GetTrack()->GetParentID()==0)
96 
97  fHitsCollection->insert( newHit );
98 
99  //newHit->Print();
100 
101  return true;
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 {
107  G4int nofHits = fHitsCollection->entries();
108 
109  G4double Einc=0;
110 
111  /*
112  G4cout << G4endl
113  << "-------->Hits Collection: in this event they are "
114  << nofHits
115  << " hits in the target volume " << G4endl;
116  */
117 
118  // PROCESSING OF PROXIMITY FUNCTION t(x)
119 
120  // *************************************
121  // Please select herebelow :
122  // - the minimum value of x radius
123  // - the maximum value of x radius
124  // - the number of steps in radius
125 
126  G4double minRadius = 0.1 * nm;
127 
128  G4double maxRadius = 10000 * nm;
129  G4int nRadiusSteps = 101;
130 
131  //
132 
133  auto analysisManager = G4AnalysisManager::Instance();
134 
135  G4double radius(minRadius);
136  G4double stpRadius(std::pow(maxRadius/radius, 1./static_cast<G4double>(nRadiusSteps-1)));
137  G4int step(nRadiusSteps);
138  G4int noRadius(0);
139 
140  // 1) loop on radius
141 
142  while (step>0)
143  {
144  step--;
145  noRadius=nRadiusSteps-step;
146 
147  //G4cout << "---radius/nm=" << radius/nm << G4endl;
148 
149  // Computation of t(x)
150 
151  G4double tNum = 0.;
152  G4double tDenom = 0.;
153  G4int nbEdep = 0;
154 
155  // 2) loop on hits
156 
157  for ( G4int k=0; k<nofHits; k++ )
158  {
159 
160  G4ThreeVector hitPos = (*fHitsCollection)[k]->GetPos();
161  G4double hitNrj = (*fHitsCollection)[k]->GetEdep();
162 
163  //G4cout << "======> hit position x/nm =" << hitPos.x()/nm << G4endl;
164  //G4cout << "======> hit position y/nm =" << hitPos.y()/nm << G4endl;
165  //G4cout << "======> hit position z/nm =" << hitPos.z()/nm << G4endl;
166 
167  // 3) loop on all other hits located within shell
168 
169  G4double localSum = 0.;
170 
171  for ( G4int i=0; i<nofHits; i++ )
172  {
173 
174  if ((*fHitsCollection)[i]->GetIncidentEnergy()>0)
175  Einc = (*fHitsCollection)[i]->GetIncidentEnergy();
176 
177  G4ThreeVector localPosi = (*fHitsCollection)[i]->GetPos();
178 
179  if
180  (
181  (
182  (localPosi.x()-hitPos.x()) * (localPosi.x()-hitPos.x()) +
183  (localPosi.y()-hitPos.y()) * (localPosi.y()-hitPos.y()) +
184  (localPosi.z()-hitPos.z()) * (localPosi.z()-hitPos.z())
185  < radius*stpRadius*radius*stpRadius
186  )
187  &&
188  (
189  (localPosi.x()-hitPos.x()) * (localPosi.x()-hitPos.x()) +
190  (localPosi.y()-hitPos.y()) * (localPosi.y()-hitPos.y()) +
191  (localPosi.z()-hitPos.z()) * (localPosi.z()-hitPos.z())
192  >= radius*radius
193  )
194  )
195 
196  {
197  localSum = localSum + (*fHitsCollection)[i]->GetEdep() ;
198  nbEdep = nbEdep + 1;
199  }
200  }
201 
202  tNum = tNum + localSum*hitNrj;
203  tDenom = tDenom + hitNrj;
204 
205 
206  } // loop on hits
207 
208  // fill ntuple including weighting
209  // does not work with ntuple merging...
210 
211  analysisManager->FillNtupleDColumn(0,0, radius/nm);
212  analysisManager->FillNtupleIColumn(0,1, noRadius);
213  analysisManager->FillNtupleDColumn(0,2, nofHits);
214  analysisManager->FillNtupleDColumn(0,3, nbEdep);
215  analysisManager->FillNtupleDColumn(0,4, (tNum/tDenom)/eV);
216  analysisManager->FillNtupleDColumn(0,5, (stpRadius*radius)/nm);
217  analysisManager->FillNtupleDColumn(0,6, Einc/eV);
218  analysisManager->AddNtupleRow();
219 
220  //G4cout << "---radius/nm=" << radius/nm << G4endl;
221  //G4cout << "----end of radius--- " << radius/nm << G4endl;
222 
223  radius*=stpRadius;
224 
225  } // loop on radii
226 
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......