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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/clustering/src/ClusterSBPoints.cc (Version 11.3.0) and /examples/extended/medical/dna/clustering/src/ClusterSBPoints.cc (Version 10.0)


  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. 37 (2010) 4692-4708                 
 30 // The Geant4-DNA web site is available at htt    
 31 //                                                
 32 // Authors: Henri Payno and Yann Perrot           
 33 //                                                
 34 //                                                
 35 /// \file ClusterSBPoints.cc                      
 36 /// \brief Implementation of the ClusterSBPoin    
 37                                                   
 38 #include "ClusterSBPoints.hh"                     
 39                                                   
 40 #include "G4SystemOfUnits.hh"                     
 41                                                   
 42 #include <iostream>                               
 43                                                   
 44 using namespace std;                              
 45                                                   
 46 //....oooOO0OOooo........oooOO0OOooo........oo    
 47                                                   
 48 ClusterSBPoints::ClusterSBPoints(std::set<SBPo    
 49 {                                                 
 50   UpdateDoubleStrand();                           
 51   std::set<SBPoint*>::iterator itPt;              
 52   for (itPt = pSBPoints.begin(); itPt != pSBPo    
 53     AddSBPoint(*itPt);                            
 54   }                                               
 55 }                                                 
 56                                                   
 57 //....oooOO0OOooo........oooOO0OOooo........oo    
 58                                                   
 59 ClusterSBPoints::~ClusterSBPoints()               
 60 {                                                 
 61   Clear();                                        
 62 }                                                 
 63                                                   
 64 void ClusterSBPoints::Clear()                     
 65 {                                                 
 66   std::set<SBPoint*>::iterator itPt;              
 67   for (itPt = fpRegisteredSBPoints.begin(); it    
 68     (*itPt)->CleanCluster();                      
 69   }                                               
 70   fpRegisteredSBPoints.clear();                   
 71 }                                                 
 72                                                   
 73 //....oooOO0OOooo........oooOO0OOooo........oo    
 74                                                   
 75 void ClusterSBPoints::AddSBPoint(SBPoint* pSBP    
 76 {                                                 
 77   assert(pSBPoint);                               
 78   fpRegisteredSBPoints.insert(pSBPoint);          
 79   pSBPoint->SetCluster(this);                     
 80                                                   
 81   UpdateDoubleStrand();                           
 82 }                                                 
 83                                                   
 84 //....oooOO0OOooo........oooOO0OOooo........oo    
 85                                                   
 86 G4ThreeVector ClusterSBPoints::GetBarycenter()    
 87 {                                                 
 88   G4double x = 0;                                 
 89   G4double y = 0;                                 
 90   G4double z = 0;                                 
 91                                                   
 92   std::set<SBPoint*>::iterator itSDSPt;           
 93   for (itSDSPt = fpRegisteredSBPoints.begin();    
 94     x += (*itSDSPt)->GetPosition().x();           
 95     y += (*itSDSPt)->GetPosition().y();           
 96     z += (*itSDSPt)->GetPosition().z();           
 97   }                                               
 98                                                   
 99   return G4ThreeVector(x / fpRegisteredSBPoint    
100                        z / fpRegisteredSBPoint    
101 }                                                 
102                                                   
103 //....oooOO0OOooo........oooOO0OOooo........oo    
104                                                   
105 G4double ClusterSBPoints::GetEdep() const         
106 {                                                 
107   G4double res = 0;                               
108   std::set<SBPoint*>::iterator itSDSPt;           
109   for (itSDSPt = fpRegisteredSBPoints.begin();    
110     res += (*itSDSPt)->GetEdep();                 
111   }                                               
112   return res;                                     
113 }                                                 
114                                                   
115 //....oooOO0OOooo........oooOO0OOooo........oo    
116                                                   
117 void ClusterSBPoints::UpdateDoubleStrand()        
118 {                                                 
119   fIsDoubleSB = false;                            
120   bool firstStrandTouch = false;                  
121   bool secondStrandTouch = false;                 
122                                                   
123   std::set<SBPoint*>::iterator itSDSPt;           
124   for (itSDSPt = fpRegisteredSBPoints.begin();    
125     // if the SDSPoint is localized on the fir    
126     if (((*itSDSPt)->GetTouchedStrand() == 0)     
127       firstStrandTouch = true;                    
128       if (secondStrandTouch) {                    
129         fIsDoubleSB = true;                       
130         return;                                   
131       }                                           
132     }                                             
133     // if the SDSPoint is localized on the sec    
134     if (((*itSDSPt)->GetTouchedStrand() == 1)     
135       secondStrandTouch = true;                   
136       if (firstStrandTouch) {                     
137         fIsDoubleSB = true;                       
138         return;                                   
139       }                                           
140     }                                             
141   }                                               
142 }                                                 
143                                                   
144 //....oooOO0OOooo........oooOO0OOooo........oo    
145                                                   
146 bool AreOnTheSameCluster(const SBPoint* pPt1,     
147 {                                                 
148   assert(pPt1);                                   
149   assert(pPt2);                                   
150                                                   
151   G4double x1 = pPt1->GetPosition().x() / nm;     
152   G4double y1 = pPt1->GetPosition().y() / nm;     
153   G4double z1 = pPt1->GetPosition().z() / nm;     
154                                                   
155   G4double x2 = pPt2->GetPosition().x() / nm;     
156   G4double y2 = pPt2->GetPosition().y() / nm;     
157   G4double z2 = pPt2->GetPosition().z() / nm;     
158                                                   
159   // if the two points are closed enough          
160   if (((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1    
161       <= (pMinDist / nm * pMinDist / nm))         
162   {                                               
163     return true;                                  
164   }                                               
165   else {                                          
166     return false;                                 
167   }                                               
168 }                                                 
169                                                   
170 //....oooOO0OOooo........oooOO0OOooo........oo    
171                                                   
172 void ClusterSBPoints::FindAllPointsPossible(st    
173                                             G4    
174 {                                                 
175   assert((unsigned int)pMinPts > this->GetSize    
176   std::vector<SBPoint*>::iterator itPt = pPtsT    
177   while (itPt != pPtsToCheck->end()) {            
178     // If 1- each SBpoint is part of only one     
179     //    2- the point isn't already in the cl    
180     //    3- the point is close enough of the     
181     if ((!(*itPt)->HasCluster()) && (fpRegiste    
182         && HasInBarycenter(*itPt, pMinDist))      
183     {                                             
184       // the point is added                       
185       this->AddSBPoint(*itPt);                    
186       if (this->GetSize() >= (unsigned int)pMi    
187         return;                                   
188       }                                           
189       // restart from scratch                     
190       itPt = pPtsToCheck->begin();                
191     }                                             
192     else {                                        
193       ++itPt;                                     
194     }                                             
195   }                                               
196 }                                                 
197                                                   
198 //....oooOO0OOooo........oooOO0OOooo........oo    
199                                                   
200 bool ClusterSBPoints::HasIn(const SBPoint* pPt    
201 {                                                 
202   // check if the given point is near one of t    
203   std::set<SBPoint*>::iterator itClusPt;          
204   for (itClusPt = fpRegisteredSBPoints.begin()    
205   {                                               
206     // if are two different pts                   
207     if ((*pPtToCheck != *(*itClusPt))) {          
208       // if close enought of an include point     
209       if (AreOnTheSameCluster(pPtToCheck, *itC    
210         return true;                              
211       }                                           
212     }                                             
213   }                                               
214   return false;                                   
215 }                                                 
216                                                   
217 //....oooOO0OOooo........oooOO0OOooo........oo    
218                                                   
219 bool ClusterSBPoints::HasInBarycenter(const SB    
220 {                                                 
221   G4double x1 = pPtToCheck->GetPosition().x()     
222   G4double y1 = pPtToCheck->GetPosition().y()     
223   G4double z1 = pPtToCheck->GetPosition().z()     
224                                                   
225   G4double x2 = this->GetBarycenter().x() / nm    
226   G4double y2 = this->GetBarycenter().y() / nm    
227   G4double z2 = this->GetBarycenter().z() / nm    
228                                                   
229   // if the two points are closed enough          
230   if (((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1    
231       <= (pMinDist / nm * pMinDist / nm))         
232   {                                               
233     return true;                                  
234   }                                               
235   else {                                          
236     return false;                                 
237   }                                               
238 }                                                 
239                                                   
240 //....oooOO0OOooo........oooOO0OOooo........oo    
241                                                   
242 /// this will insert all registredSBPoint         
243 /// from the given cluster to this cluster.       
244 void ClusterSBPoints::MergeWith(ClusterSBPoint    
245 {                                                 
246   std::set<SBPoint*> points = pCluster->GetReg    
247   pCluster->Clear();                              
248   std::set<SBPoint*>::iterator itPt;              
249   for (itPt = points.begin(); itPt != points.e    
250     this->AddSBPoint(*itPt);                      
251   }                                               
252 }                                                 
253