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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/exoticphysics/saxs/src/SAXSSteppingAction.cc (Version 11.3.0) and /examples/extended/exoticphysics/saxs/src/SAXSSteppingAction.cc (Version 11.2.2)


  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 /// \file SAXSSteppingAction.cc                    26 /// \file SAXSSteppingAction.cc
 27 /// \brief Definition of the SAXSSteppingActio     27 /// \brief Definition of the SAXSSteppingAction class
 28 //                                                 28 //
 29 //....oooOO0OOooo........oooOO0OOooo........oo     29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 30                                                    30 
 31 #ifdef G4MULTITHREADED                             31 #ifdef G4MULTITHREADED
 32 #  include "G4MTRunManager.hh"                 <<  32 #include "G4MTRunManager.hh"
 33 #else                                              33 #else
 34 #  include "G4RunManager.hh"                   <<  34 #include "G4RunManager.hh"
 35 #endif                                             35 #endif
 36                                                    36 
 37 #include "SAXSDetectorConstruction.hh"         << 
 38 #include "SAXSEventAction.hh"                  << 
 39 #include "SAXSSteppingAction.hh"               << 
 40                                                << 
 41 #include "G4AnalysisManager.hh"                << 
 42 #include "G4Event.hh"                              37 #include "G4Event.hh"
 43 #include "G4EventManager.hh"                       38 #include "G4EventManager.hh"
 44 #include "G4HCofThisEvent.hh"                      39 #include "G4HCofThisEvent.hh"
 45 #include "G4OpticalPhoton.hh"                  << 
 46 #include "G4SDManager.hh"                      << 
 47 #include "G4Step.hh"                           << 
 48 #include "G4SystemOfUnits.hh"                  << 
 49 #include "G4Track.hh"                          << 
 50 #include "G4Trajectory.hh"                     << 
 51 #include "G4TrajectoryContainer.hh"            << 
 52 #include "G4UImanager.hh"                      << 
 53 #include "G4VHitsCollection.hh"                    40 #include "G4VHitsCollection.hh"
                                                   >>  41 #include "G4TrajectoryContainer.hh"
                                                   >>  42 #include "G4Trajectory.hh"
 54 #include "G4VVisManager.hh"                        43 #include "G4VVisManager.hh"
                                                   >>  44 #include "G4SDManager.hh"
                                                   >>  45 #include "G4UImanager.hh"
 55 #include "G4ios.hh"                                46 #include "G4ios.hh"
                                                   >>  47 #include "G4SystemOfUnits.hh"
                                                   >>  48 #include "G4AnalysisManager.hh"
                                                   >>  49 
                                                   >>  50 #include "SAXSSteppingAction.hh"
                                                   >>  51 #include "SAXSEventAction.hh"
                                                   >>  52 #include "SAXSDetectorConstruction.hh"
                                                   >>  53 
                                                   >>  54 #include "G4Step.hh"
                                                   >>  55 #include "G4Track.hh"
                                                   >>  56 #include "G4OpticalPhoton.hh"
 56                                                    57 
 57 #include <cmath>                                   58 #include <cmath>
 58                                                    59 
 59 //....oooOO0OOooo........oooOO0OOooo........oo     60 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 60                                                    61 
 61 SAXSSteppingAction::SAXSSteppingAction(SAXSEve <<  62 SAXSSteppingAction::SAXSSteppingAction(SAXSEventAction* eventAction):
 62   : G4UserSteppingAction(), fEventAction(event <<  63   G4UserSteppingAction(),
                                                   >>  64   fEventAction(eventAction),
                                                   >>  65   fPhantom(0),
                                                   >>  66   fEventNumber(-1),
                                                   >>  67   fNSe(0)
 63 {}                                                 68 {}
 64                                                    69 
 65 //....oooOO0OOooo........oooOO0OOooo........oo     70 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 66                                                    71 
 67 SAXSSteppingAction::~SAXSSteppingAction() {}       72 SAXSSteppingAction::~SAXSSteppingAction() {}
 68                                                    73 
 69 //....oooOO0OOooo........oooOO0OOooo........oo     74 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 70                                                    75 
 71 void SAXSSteppingAction::UserSteppingAction(co     76 void SAXSSteppingAction::UserSteppingAction(const G4Step* step)
 72 {                                              <<  77 {        
 73   // DetectorConstruction instance             <<  78   //DetectorConstruction instance
 74   const SAXSDetectorConstruction* detectorCons <<  79   const SAXSDetectorConstruction* detectorConstruction = 
 75     static_cast<const SAXSDetectorConstruction <<  80     static_cast<const SAXSDetectorConstruction*>
 76       G4RunManager::GetRunManager()->GetUserDe <<  81     (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
 77                                                <<  82         
 78   // get Phantom volume                        <<  83   //get Phantom volume
 79   fPhantom = detectorConstruction->GetPhantom(     84   fPhantom = detectorConstruction->GetPhantom();
 80                                                    85 
 81   // get pre and post step points              <<  86   //get pre and post step points
 82   G4StepPoint* preStepPoint = step->GetPreStep     87   G4StepPoint* preStepPoint = step->GetPreStepPoint();
 83   G4StepPoint* postStepPoint = step->GetPostSt     88   G4StepPoint* postStepPoint = step->GetPostStepPoint();
 84                                                    89 
 85   // get the volume of the current step        <<  90   //get the volume of the current step
 86   G4LogicalVolume* volume = preStepPoint->GetT <<  91   G4LogicalVolume* volume = preStepPoint->GetTouchableHandle()
 87                                                <<  92     ->GetVolume()->GetLogicalVolume();
 88   // get track and particle name               <<  93           
                                                   >>  94   //get track and particle name
 89   G4Track* track = step->GetTrack();               95   G4Track* track = step->GetTrack();
 90   G4int ID = track->GetTrackID();                  96   G4int ID = track->GetTrackID();
 91   G4String partName = track->GetDefinition()->     97   G4String partName = track->GetDefinition()->GetParticleName();
 92                                                    98 
 93   // update the primary particle (event) weigh <<  99   //update the primary particle (event) weight
 94   G4double PrimaryWeight = 1.;                    100   G4double PrimaryWeight = 1.;
 95   if (partName == "gamma" && ID == 1) {        << 101   if (partName == "gamma" && ID==1) {
 96     PrimaryWeight = track->GetWeight();           102     PrimaryWeight = track->GetWeight();
 97     fEventAction->UpdateEventWeight(PrimaryWei    103     fEventAction->UpdateEventWeight(PrimaryWeight);
 98   }                                               104   }
 99                                                << 105                                          
100   // if the particle is not a primary photon s << 106   //if the particle is not a primary photon stepping in the phantom, exit!
101   if (volume != fPhantom || partName != "gamma << 107   if (volume != fPhantom || partName != "gamma" || ID!=1) return;
102                                                << 108                 
103   // if it is a new event, reset variable valu << 109   //if it is a new event, reset variable values to 0
104   G4int eventNumber = G4RunManager::GetRunMana << 110   G4int eventNumber = G4RunManager::GetRunManager()
                                                   >> 111     ->GetCurrentEvent()->GetEventID();
105   if (eventNumber != fEventNumber) {              112   if (eventNumber != fEventNumber) {
106     fEventNumber = eventNumber;                   113     fEventNumber = eventNumber;
107     fNSe = 0;                                     114     fNSe = 0;
108   }                                               115   }
109                                                   116 
110   // identify the process that occurred        << 117   //identify the process that occurred
111   G4String Process;                            << 118   G4String Process; 
112   if (postStepPoint->GetProcessDefinedStep() !    119   if (postStepPoint->GetProcessDefinedStep() != NULL) {
113     Process = postStepPoint->GetProcessDefined    120     Process = postStepPoint->GetProcessDefinedStep()->GetProcessName();
114   }                                            << 121   } else {
115   else {                                       << 
116     Process = "UserLimit";                        122     Process = "UserLimit";
117   }                                               123   }
118   // G4cout << "Process: " << Process << G4end << 124   //G4cout << "Process: " << Process << G4endl;
119   G4int ProcIndex = -1;                           125   G4int ProcIndex = -1;
120   if (Process == "Transportation" || Process = << 126   if (Process == "Transportation" || Process == "CoupledTransportation" 
                                                   >> 127       || Process == "UserLimit") {
121     ProcIndex = 0;                                128     ProcIndex = 0;
122   }                                               129   }
123   if (Process == "Rayl" || Process == "biasWra    130   if (Process == "Rayl" || Process == "biasWrapper(Rayl)") {
124     ProcIndex = 1;                                131     ProcIndex = 1;
125     fNSe++;                                       132     fNSe++;
126     fEventAction->AddNRi();                       133     fEventAction->AddNRi();
127   }                                               134   }
128   if (Process == "compt" || Process == "biasWr    135   if (Process == "compt" || Process == "biasWrapper(compt)") {
129     ProcIndex = 2;                                136     ProcIndex = 2;
130     fNSe++;                                       137     fNSe++;
131     fEventAction->AddNCi();                       138     fEventAction->AddNCi();
132   }                                               139   }
133   if (Process == "phot" || Process == "biasWra    140   if (Process == "phot" || Process == "biasWrapper(phot)") ProcIndex = 3;
134   if (Process == "conv" || Process == "biasWra << 141   if (Process == "conv" || Process == "biasWrapper(conv)") ProcIndex = 4;        
135   if (Process == "photonNuclear" || Process == << 142   if (Process == "photonNuclear" ||
                                                   >> 143       Process == "biasWrapper(photonNuclear)") {
136     ProcIndex = 5;                                144     ProcIndex = 5;
137   }                                               145   }
138   if (Process == "PowderDiffraction" || Proces << 146   if (Process == "PowderDiffraction" ||
                                                   >> 147       Process == "biasWrapper(PowderDiffraction)") {
139     ProcIndex = 6;                                148     ProcIndex = 6;
140     fNSe++;                                       149     fNSe++;
141     fEventAction->AddNDi();                       150     fEventAction->AddNDi();
142   }                                               151   }
143   // G4cout << "ProcIndex: " << ProcIndex << G << 152   //G4cout << "ProcIndex: " << ProcIndex << G4endl;
144                                                << 153         
145   // calculate the scattering angle            << 154   //calculate the scattering angle
146   G4ThreeVector mom1 = preStepPoint->GetMoment    155   G4ThreeVector mom1 = preStepPoint->GetMomentumDirection();
147   G4ThreeVector mom2 = postStepPoint->GetMomen << 156   G4ThreeVector mom2 = postStepPoint->GetMomentumDirection();        
148   G4double theta = mom1.angle(mom2);           << 157   G4double theta = mom1.angle(mom2); 
149                                                   158 
150   // fill the Scattering ntuple                << 159   //fill the Scattering ntuple 
151   G4AnalysisManager* analysisManager = G4Analy    160   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
152   if (theta > 1e-6) {  // record only if the a << 161   if (theta > 1e-6) { //record only if the angle is not 0
153     analysisManager->FillNtupleIColumn(1, 0, P << 162     analysisManager->FillNtupleIColumn(1,0,ProcIndex);
154     analysisManager->FillNtupleDColumn(1, 1, p << 163     analysisManager->FillNtupleDColumn(1,1,
155     analysisManager->FillNtupleDColumn(1, 2, t << 164         preStepPoint->GetKineticEnergy()/CLHEP::keV);
156     analysisManager->FillNtupleDColumn(1, 3, t << 165     analysisManager->FillNtupleDColumn(1,2,theta/CLHEP::deg); 
                                                   >> 166     analysisManager->FillNtupleDColumn(1,3,track->GetWeight());    
157     analysisManager->AddNtupleRow(1);             167     analysisManager->AddNtupleRow(1);
158   }                                            << 168   }        
159 }                                                 169 }
160                                                   170 
161 //....oooOO0OOooo........oooOO0OOooo........oo    171 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
                                                   >> 172 
162                                                   173