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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 11.1)


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