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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/advanced/CaTS/src/RadiatorSD.cc (Version 11.3.0) and /examples/advanced/CaTS/src/RadiatorSD.cc (Version 1.1)


  1 // *******************************************      1 
  2 // * License and Disclaimer                       
  3 // *                                              
  4 // * The  Geant4 software  is  copyright of th    
  5 // * the Geant4 Collaboration.  It is provided    
  6 // * conditions of the Geant4 Software License    
  7 // * LICENSE and available at  http://cern.ch/    
  8 // * include a list of copyright holders.         
  9 // *                                              
 10 // * Neither the authors of this software syst    
 11 // * institutes,nor the agencies providing fin    
 12 // * work  make  any representation or  warran    
 13 // * regarding  this  software system or assum    
 14 // * use.  Please see the license in the file     
 15 // * for the full disclaimer and the limitatio    
 16 // *                                              
 17 // * This  code  implementation is the result     
 18 // * technical work of the GEANT4 collaboratio    
 19 // * By using,  copying,  modifying or  distri    
 20 // * any work based  on the software)  you  ag    
 21 // * use  in  resulting  scientific  publicati    
 22 // * acceptance of all terms of the Geant4 Sof    
 23 // *******************************************    
 24 //                                                
 25 // *******************************************    
 26 //                                                
 27 //  CaTS (Calorimetry and Tracking Simulation)    
 28 //                                                
 29 //  Authors : Hans Wenzel                         
 30 //            Soon Yung Jun                       
 31 //            (Fermi National Accelerator Labo    
 32 //                                                
 33 // History                                        
 34 //   October 18th, 2021 : first implementation    
 35 //                                                
 36 // *******************************************    
 37 //                                                
 38 /// \file RadiatorSD.cc                           
 39 /// \brief Implementation of the CaTS::Radiato    
 40                                                   
 41 // Geant4 headers                                 
 42 #include "G4Step.hh"                              
 43 #include "G4Track.hh"                             
 44 #ifdef WITH_G4OPTICKS                             
 45 #  include "G4ThreeVector.hh"                     
 46 #  include "G4ios.hh"                             
 47 #  include "G4UnitsTable.hh"                      
 48 #  include "G4SystemOfUnits.hh"                   
 49 #  include "G4VProcess.hh"                        
 50 #  include "G4VRestDiscreteProcess.hh"            
 51 #  include "G4SDManager.hh"                       
 52 #  include "G4HCofThisEvent.hh"                   
 53 #  include "G4Opticks.hh"                         
 54 #  include "TrackInfo.hh"                         
 55 #  include "OpticksGenstep.h"                     
 56 #  include "OpticksFlags.hh"                      
 57 #  include "G4OpticksHit.hh"                      
 58 #  include "G4EventManager.hh"                    
 59 #  include "G4Event.hh"                           
 60 #  include "G4RunManager.hh"                      
 61 #  include "G4Version.hh"                         
 62 #  include "PhotonSD.hh"                          
 63 #  include "G4Cerenkov.hh"                        
 64 #  include "G4Scintillation.hh"                   
 65 #  include <string>                               
 66 #endif                                            
 67 // project headers                                
 68 #include "RadiatorSD.hh"                          
 69 #include "ConfigurationManager.hh"                
 70                                                   
 71 RadiatorSD::RadiatorSD(G4String name)             
 72   : G4VSensitiveDetector(name)                    
 73 {                                                 
 74   verbose = ConfigurationManager::getInstance(    
 75 }                                                 
 76                                                   
 77 void RadiatorSD::Initialize(G4HCofThisEvent*)     
 78                                                   
 79 G4bool RadiatorSD::ProcessHits(G4Step* aStep,     
 80 {                                                 
 81   G4double edep = aStep->GetTotalEnergyDeposit    
 82   if(edep == 0.)                                  
 83     return false;                                 
 84   // only deal with charged particles             
 85   G4Track* aTrack = aStep->GetTrack();            
 86   G4double charge = aTrack->GetDynamicParticle    
 87   if(charge == 0)                                 
 88     return false;                                 
 89 #ifdef WITH_G4OPTICKS                             
 90   if(ConfigurationManager::getInstance()->isEn    
 91   {                                               
 92     G4int materialIndex = 0;                      
 93     if(first)                                     
 94     {                                             
 95       aMaterial     = aTrack->GetMaterial();      
 96       materialIndex = aMaterial->GetIndex();      
 97       if(verbose)                                 
 98       {                                           
 99         G4cout << "***************************    
100         G4cout << "RadiatorSD::ProcessHits ini    
101                << aMaterial->GetName() << " "     
102         G4cout << "RadiatorSD::ProcessHits: Na    
103                << aStep->GetPreStepPoint()        
104                     ->GetPhysicalVolume()         
105                     ->GetLogicalVolume()          
106                     ->GetName()                   
107                << G4endl;                         
108       }                                           
109       aMaterialPropertiesTable = aMaterial->Ge    
110       if(verbose)                                 
111       {                                           
112         aMaterialPropertiesTable->DumpTable();    
113       }                                           
114       //                                          
115       // properties related to Scintillation      
116       //                                          
117 #  if(G4VERSION_NUMBER > 1072)                    
118       YieldRatio =                                
119         aMaterialPropertiesTable->GetConstProp    
120         aMaterialPropertiesTable->GetConstProp    
121           kSCINTILLATIONYIELD2);  // slowerRat    
122       FastTimeConstant = aMaterialPropertiesTa    
123         kSCINTILLATIONTIMECONSTANT1);  // Time    
124       SlowTimeConstant = aMaterialPropertiesTa    
125         kSCINTILLATIONTIMECONSTANT2);  // slow    
126 #  else                                           
127       Fast_Intensity = aMaterialPropertiesTabl    
128       Slow_Intensity = aMaterialPropertiesTabl    
129       YieldRatio     = aMaterialPropertiesTabl    
130 #  endif                                          
131       ScintillationType = Slow;                   
132       //                                          
133       // properties related to Cerenkov           
134       //                                          
135       Rindex = aMaterialPropertiesTable->GetPr    
136 #  if(G4VERSION_NUMBER > 1072)                    
137       Pmin = Rindex->GetMinEnergy();              
138       Pmax = Rindex->GetMaxEnergy();              
139 #  else                                           
140       Pmin           = Rindex->GetMinLowEdgeEn    
141       Pmax           = Rindex->GetMaxLowEdgeEn    
142 #  endif                                          
143       dp   = Pmax - Pmin;                         
144       nMax = Rindex->GetMaxValue();               
145       if(verbose)                                 
146       {                                           
147         G4cout << "nMax: " << nMax << "  Pmin:    
148                << "  dp: " << dp << G4endl;       
149         Rindex->DumpValues();                     
150       }                                           
151       //                                          
152       first = false;                              
153     }                    // end if first          
154     G4int Sphotons = 0;  // number of scintill    
155     G4int Cphotons = 0;  // number of Cerenkov    
156     //                                            
157     // info needed for generating Cerenkov pho    
158     //                                            
159     G4double maxCos                      = 0.0    
160     G4double maxSin2                     = 0.0    
161     G4double beta                        = 0.0    
162     G4double beta1                       = 0.0    
163     G4double beta2                       = 0.0    
164     G4double BetaInverse                 = 0.0    
165     G4double MeanNumberOfPhotons1        = 0.0    
166     G4double MeanNumberOfPhotons2        = 0.0    
167     G4SteppingManager* fpSteppingManager = G4E    
168                                              -    
169                                              -    
170     G4StepStatus stepStatus = fpSteppingManage    
171     if(stepStatus != fAtRestDoItProc)             
172     {                                             
173       G4ProcessVector* procPost = fpSteppingMa    
174       size_t MAXofPostStepLoops = fpSteppingMa    
175       for(size_t i3 = 0; i3 < MAXofPostStepLoo    
176       {                                           
177         if((*procPost)[i3]->GetProcessName() =    
178         {                                         
179           G4Cerenkov* proc = (G4Cerenkov*) (*p    
180           thePhysicsTable  = proc->GetPhysicsT    
181           CerenkovAngleIntegrals =                
182             (G4PhysicsOrderedFreeVector*) ((*t    
183           Cphotons = proc->GetNumPhotons();       
184           if(Cphotons > 0)                        
185           {                                       
186             beta1       = aStep->GetPreStepPoi    
187             beta2       = aStep->GetPostStepPo    
188             beta        = (beta1 + beta2) * 0.    
189             BetaInverse = 1. / beta;              
190             maxCos      = BetaInverse / nMax;     
191             maxSin2     = (1.0 - maxCos) * (1.    
192             MeanNumberOfPhotons1 =                
193               proc->GetAverageNumberOfPhotons(    
194             MeanNumberOfPhotons2 =                
195               proc->GetAverageNumberOfPhotons(    
196           }                                       
197         }                                         
198         if((*procPost)[i3]->GetProcessName() =    
199         {                                         
200           G4Scintillation* proc1 = (G4Scintill    
201           Sphotons               = proc1->GetN    
202         }                                         
203       }                                           
204     }                                             
205     tSphotons += Sphotons;                        
206     tCphotons += Cphotons;                        
207     G4ThreeVector deltaPosition = aStep->GetDe    
208     G4double ScintillationTime  = 0. * ns;        
209     G4int scntId                = 1;              
210     G4StepPoint* pPreStepPoint  = aStep->GetPr    
211     G4ThreeVector x0            = pPreStepPoin    
212     G4ThreeVector p0            = aStep->GetDe    
213     //                                            
214     // harvest the Scintillation photon genste    
215     //                                            
216     if(Sphotons > 0)                              
217     {                                             
218       G4double ScintillationRiseTime = 0.0;       
219       G4Opticks::Get()->collectGenstep_G4Scint    
220         aTrack, aStep, Sphotons, scntId, Scint    
221         ScintillationRiseTime);                   
222     }                                             
223     //                                            
224     // harvest the Cerenkov photon gensteps:      
225     //                                            
226     if(Cphotons > 0)                              
227     {                                             
228       G4Opticks::Get()->collectGenstep_G4Ceren    
229         aTrack, aStep, Cphotons, BetaInverse,     
230         MeanNumberOfPhotons1, MeanNumberOfPhot    
231     }                                             
232     G4Opticks* g4ok      = G4Opticks::Get();      
233     G4RunManager* rm     = G4RunManager::GetRu    
234     const G4Event* event = rm->GetCurrentEvent    
235     G4int eventid        = event->GetEventID()    
236     G4OpticksHit hit;                             
237     unsigned num_photons = g4ok->getNumPhotons    
238     if(num_photons > ConfigurationManager::get    
239     {                                             
240       g4ok->propagateOpticalPhotons(eventid);     
241       G4HCtable* hctable = G4SDManager::GetSDM    
242       for(G4int i = 0; i < hctable->entries();    
243       {                                           
244         std::string sdn   = hctable->GetSDname    
245         std::size_t found = sdn.find("Photonde    
246         if(found != std::string::npos)            
247         {                                         
248           PhotonSD* aSD =                         
249             (PhotonSD*) G4SDManager::GetSDMpoi    
250               sdn);                               
251           aSD->AddOpticksHits();                  
252         }                                         
253       }                                           
254       g4ok->reset();                              
255     }                                             
256   }                                               
257 #endif                                            
258   return true;                                    
259 }                                                 
260                                                   
261 void RadiatorSD::EndOfEvent(G4HCofThisEvent*)     
262 {                                                 
263   tSphotons = 0;                                  
264   tCphotons = 0;                                  
265 }                                                 
266