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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/medical/dna/microprox/src/TrackerSD.cc (Version 11.3.0) and /examples/extended/medical/dna/microprox/src/TrackerSD.cc (Version 9.3)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 // This example is provided by the Geant4-DNA     
 27 // Any report or published results obtained us    
 28 // shall cite the following Geant4-DNA collabo    
 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)    
 33 //                                                
 34 // The Geant4-DNA web site is available at htt    
 35 //                                                
 36 /// \file TrackerSD.cc                            
 37 /// \brief Implementation of the TrackerSD cla    
 38                                                   
 39 #include "TrackerSD.hh"                           
 40                                                   
 41 #include "G4AnalysisManager.hh"                   
 42 #include "G4SDManager.hh"                         
 43 #include "G4SystemOfUnits.hh"                     
 44 #include "Randomize.hh"                           
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 TrackerSD::TrackerSD(const G4String& name, con    
 49   : G4VSensitiveDetector(name), fHitsCollectio    
 50 {                                                 
 51   collectionName.insert(hitsCollectionName);      
 52 }                                                 
 53                                                   
 54 //....oooOO0OOooo........oooOO0OOooo........oo    
 55                                                   
 56 TrackerSD::~TrackerSD() {}                        
 57                                                   
 58 //....oooOO0OOooo........oooOO0OOooo........oo    
 59                                                   
 60 void TrackerSD::Initialize(G4HCofThisEvent* hc    
 61 {                                                 
 62   // Create hits collection                       
 63   fHitsCollection = new TrackerHitsCollection(    
 64                                                   
 65   // Add this collection in hce                   
 66   G4int hcID = G4SDManager::GetSDMpointer()->G    
 67                                                   
 68   hce->AddHitsCollection(hcID, fHitsCollection    
 69 }                                                 
 70                                                   
 71 //....oooOO0OOooo........oooOO0OOooo........oo    
 72                                                   
 73 G4bool TrackerSD::ProcessHits(G4Step* aStep, G    
 74 {                                                 
 75   // Energy deposit                               
 76   G4double edep = aStep->GetTotalEnergyDeposit    
 77                                                   
 78   if (edep == 0.) return false;                   
 79                                                   
 80   TrackerHit* newHit = new TrackerHit();          
 81                                                   
 82   newHit->SetTrackID(aStep->GetTrack()->GetTra    
 83   newHit->SetEdep(edep);                          
 84   newHit->SetPos(aStep->GetPostStepPoint()->Ge    
 85                                                   
 86   if (aStep->GetTrack()->GetTrackID() == 1 &&     
 87     newHit->SetIncidentEnergy(aStep->GetTrack(    
 88                                                   
 89   fHitsCollection->insert(newHit);                
 90                                                   
 91   // Print                                        
 92   // newHit->Print();                             
 93                                                   
 94   return true;                                    
 95 }                                                 
 96                                                   
 97 //....oooOO0OOooo........oooOO0OOooo........oo    
 98 void TrackerSD::EndOfEvent(G4HCofThisEvent*)      
 99 {                                                 
100   G4int nofHits = fHitsCollection->entries();     
101                                                   
102   G4double Einc = 0;                              
103                                                   
104   /*                                              
105   G4cout << G4endl                                
106   << "-------->Hits Collection: in this event     
107   << nofHits                                      
108   << " hits in the target volume " << G4endl;     
109   */                                              
110                                                   
111   // PROCESSING OF PROXIMITY FUNCTION t(x)        
112                                                   
113   // *************************************        
114   // Please select herebelow :                    
115   // - the minimum value of x radius              
116   // - the maximum value of x radius              
117   // - the number of steps in radius              
118                                                   
119   G4double minRadius = 0.1 * nm;                  
120                                                   
121   G4double maxRadius = 10000 * nm;                
122   G4int nRadiusSteps = 101;                       
123                                                   
124   //                                              
125                                                   
126   auto analysisManager = G4AnalysisManager::In    
127                                                   
128   G4double radius(minRadius);                     
129   G4double stpRadius(std::pow(maxRadius / radi    
130   G4int step(nRadiusSteps);                       
131   G4int noRadius(0);                              
132                                                   
133   // 1) loop on radius                            
134                                                   
135   while (step > 0) {                              
136     step--;                                       
137     noRadius = nRadiusSteps - step;               
138                                                   
139     // G4cout << "---radius/nm=" << radius/nm     
140                                                   
141     // Computation of t(x)                        
142                                                   
143     G4double tNum = 0.;                           
144     G4double tDenom = 0.;                         
145     G4int nbEdep = 0;                             
146                                                   
147     // 2) loop on hits                            
148                                                   
149     for (G4int k = 0; k < nofHits; k++) {         
150       G4ThreeVector hitPos = (*fHitsCollection    
151       G4double hitNrj = (*fHitsCollection)[k]-    
152                                                   
153       // G4cout << "======> hit position x/nm     
154       // G4cout << "======> hit position y/nm     
155       // G4cout << "======> hit position z/nm     
156                                                   
157       // 3) loop on all other hits located wit    
158                                                   
159       G4double localSum = 0.;                     
160                                                   
161       for (G4int i = 0; i < nofHits; i++) {       
162         if ((*fHitsCollection)[i]->GetIncident    
163           Einc = (*fHitsCollection)[i]->GetInc    
164                                                   
165         G4ThreeVector localPosi = (*fHitsColle    
166                                                   
167         if (((localPosi.x() - hitPos.x()) * (l    
168                + (localPosi.y() - hitPos.y())     
169                + (localPosi.z() - hitPos.z())     
170              < radius * stpRadius * radius * s    
171             && ((localPosi.x() - hitPos.x()) *    
172                   + (localPosi.y() - hitPos.y(    
173                   + (localPosi.z() - hitPos.z(    
174                 >= radius * radius))              
175                                                   
176         {                                         
177           localSum = localSum + (*fHitsCollect    
178           nbEdep = nbEdep + 1;                    
179         }                                         
180       }                                           
181                                                   
182       tNum = tNum + localSum * hitNrj;            
183       tDenom = tDenom + hitNrj;                   
184                                                   
185     }  // loop on hits                            
186                                                   
187     // fill ntuple including weighting            
188     // does not work with ntuple merging...       
189                                                   
190     analysisManager->FillNtupleDColumn(0, 0, r    
191     analysisManager->FillNtupleIColumn(0, 1, n    
192     analysisManager->FillNtupleDColumn(0, 2, n    
193     analysisManager->FillNtupleDColumn(0, 3, n    
194     analysisManager->FillNtupleDColumn(0, 4, (    
195     analysisManager->FillNtupleDColumn(0, 5, (    
196     analysisManager->FillNtupleDColumn(0, 6, E    
197     analysisManager->AddNtupleRow();              
198                                                   
199     // G4cout << "---radius/nm=" << radius/nm     
200     // G4cout << "----end of radius--- " << ra    
201                                                   
202     radius *= stpRadius;                          
203                                                   
204   }  // loop on radii                             
205 }                                                 
206                                                   
207 //....oooOO0OOooo........oooOO0OOooo........oo    
208