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p3 ] [ 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/advanced/xray_TESdetector/src/XrayTESdetSteppingAction.cc (Version 11.3.0) and /examples/advanced/xray_TESdetector/src/XrayTESdetSteppingAction.cc (Version 11.2.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 //                                                 26 //
 27 /// \file XrayTESdetSteppingAction.cc              27 /// \file XrayTESdetSteppingAction.cc
 28 /// \brief Implementation of the SteppingActio     28 /// \brief Implementation of the SteppingAction class
 29 //                                                 29 //
 30 // Authors: P.Dondero (paolo.dondero@cern.ch),     30 // Authors: P.Dondero (paolo.dondero@cern.ch), R.Stanzani (ronny.stanzani@cern.ch)
 31 //                                                 31 //
 32 //....oooOO0OOooo........oooOO0OOooo........oo     32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 33 //....oooOO0OOooo........oooOO0OOooo........oo     33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 34                                                    34 
 35                                                    35 
 36 #include "XrayTESdetSteppingAction.hh"             36 #include "XrayTESdetSteppingAction.hh"
 37 #include "G4AnalysisManager.hh"                    37 #include "G4AnalysisManager.hh"
 38                                                    38 
 39 #include "G4SteppingManager.hh"                    39 #include "G4SteppingManager.hh"
 40 #include "G4RunManager.hh"                         40 #include "G4RunManager.hh"
 41 #include "G4SystemOfUnits.hh"                      41 #include "G4SystemOfUnits.hh"
 42 #include "G4PhysicalConstants.hh"                  42 #include "G4PhysicalConstants.hh"
 43                                                    43 
 44 //....oooOO0OOooo........oooOO0OOooo........oo     44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 45                                                    45 
 46 G4String clean_name (const G4String& vol_name)     46 G4String clean_name (const G4String& vol_name)
 47 {                                                  47 {
 48   G4String cleaned_name = "";                      48   G4String cleaned_name = "";
 49                                                    49 
 50   // Search if the vol_name contains one of th     50   // Search if the vol_name contains one of the following part
 51   if (((std::string)vol_name).find("Bipxl") !=     51   if (((std::string)vol_name).find("Bipxl") != std::string::npos)
 52     cleaned_name = "Bipxl";                        52     cleaned_name = "Bipxl";
 53   if (((std::string)vol_name).find("membrane")     53   if (((std::string)vol_name).find("membrane") != std::string::npos)
 54     cleaned_name = "membrane";                     54     cleaned_name = "membrane";
 55   if (((std::string)vol_name).find("gridpiece"     55   if (((std::string)vol_name).find("gridpiece") != std::string::npos)
 56     cleaned_name = "gridpiece";                    56     cleaned_name = "gridpiece";
 57   if (((std::string)vol_name).find("trapezoid"     57   if (((std::string)vol_name).find("trapezoid") != std::string::npos)
 58     cleaned_name = "Mesh";                         58     cleaned_name = "Mesh";
 59   if (cleaned_name == "") cleaned_name = vol_n     59   if (cleaned_name == "") cleaned_name = vol_name;
 60   return cleaned_name;                             60   return cleaned_name;
 61 }                                                  61 }
 62                                                    62 
 63 //....oooOO0OOooo........oooOO0OOooo........oo     63 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 64                                                    64 
 65 void XrayTESdetSteppingAction::UserSteppingAct     65 void XrayTESdetSteppingAction::UserSteppingAction(const G4Step* step)
 66 {                                                  66 {
 67   // Define quantities to use in the               67   // Define quantities to use in the
 68   G4RunManager *rm = G4RunManager::GetRunManag     68   G4RunManager *rm = G4RunManager::GetRunManager();
 69   auto analysisManager = G4AnalysisManager::In     69   auto analysisManager = G4AnalysisManager::Instance();
 70                                                    70 
 71   G4int eventID = rm->GetCurrentEvent()->GetEv     71   G4int eventID = rm->GetCurrentEvent()->GetEventID();
 72   G4Track* track = step->GetTrack();               72   G4Track* track = step->GetTrack();
 73   G4StepPoint* pre_step_point = step->GetPreSt     73   G4StepPoint* pre_step_point = step->GetPreStepPoint();
 74   G4int parentID = track->GetParentID();           74   G4int parentID = track->GetParentID();
 75   G4int trackID = track->GetTrackID();             75   G4int trackID = track->GetTrackID();
 76   const G4String& vol_name = track->GetVolume(     76   const G4String& vol_name = track->GetVolume()->GetName();
 77   G4String mother_name = "";                       77   G4String mother_name = "";
 78   G4double init_kinetic_energy = 0;                78   G4double init_kinetic_energy = 0;
 79   G4double kinetic_energy = track->GetKineticE     79   G4double kinetic_energy = track->GetKineticEnergy();
 80   G4double pre_kinetic_energy = pre_step_point     80   G4double pre_kinetic_energy = pre_step_point->GetKineticEnergy();
 81   const G4String& particle_name = track->GetPa     81   const G4String& particle_name = track->GetParticleDefinition()->GetParticleName();
 82   const G4VProcess* pre_step_proc = pre_step_p     82   const G4VProcess* pre_step_proc = pre_step_point->GetProcessDefinedStep();
 83   const G4VProcess* post_step_proc = pre_step_     83   const G4VProcess* post_step_proc = pre_step_point->GetProcessDefinedStep();
 84                                                    84 
 85   bool proceed = false;                            85   bool proceed = false;
 86   G4String pre_step_name_s = "Undefined";          86   G4String pre_step_name_s = "Undefined";
 87   G4String post_step_name_s = "Undefined";         87   G4String post_step_name_s = "Undefined";
 88   G4String creator_process_name = "Undefined";     88   G4String creator_process_name = "Undefined";
 89   G4String init_creator_process = "Undefined";     89   G4String init_creator_process = "Undefined";
 90   const G4String& pre_step_name = pre_step_nam     90   const G4String& pre_step_name = pre_step_name_s;
 91   const G4String& post_step_name = post_step_n     91   const G4String& post_step_name = post_step_name_s;
 92                                                    92 
 93   if (track->GetCreatorProcess() != nullptr)       93   if (track->GetCreatorProcess() != nullptr)
 94   {                                                94   {
 95     creator_process_name = track->GetCreatorPr     95     creator_process_name = track->GetCreatorProcess()->GetProcessName();
 96   }                                                96   }
 97                                                    97 
 98   if (pre_step_proc != nullptr)                    98   if (pre_step_proc != nullptr)
 99   {                                                99   {
100     pre_step_name_s = pre_step_proc->GetProces    100     pre_step_name_s = pre_step_proc->GetProcessName();
101   }                                               101   }
102                                                   102 
103   if (post_step_proc != nullptr)                  103   if (post_step_proc != nullptr)
104   {                                               104   {
105     post_step_name_s = post_step_proc->GetProc    105     post_step_name_s = post_step_proc->GetProcessName();
106   }                                               106   }
107                                                   107 
108   // Saves the first energy of the secondaries    108   // Saves the first energy of the secondaries
109   if (eventID != fPrev_eventID)                   109   if (eventID != fPrev_eventID)
110   {                                               110   {
111     fInit_energy.clear();                         111     fInit_energy.clear();
112     fCreator_proc.clear();                        112     fCreator_proc.clear();
113   }                                               113   }
114                                                   114 
115   G4int current_step_number = -1;                 115   G4int current_step_number = -1;
116   current_step_number = track->GetCurrentStepN    116   current_step_number = track->GetCurrentStepNumber();
117   if (current_step_number != -1)                  117   if (current_step_number != -1)
118   {                                               118   {
119     if (current_step_number == 1 && parentID =    119     if (current_step_number == 1 && parentID == 0)
120     {                                             120     {
121       proceed = true;                             121       proceed = true;
122       fInit_energy.insert(std::pair<G4int, G4d    122       fInit_energy.insert(std::pair<G4int, G4double>(trackID, pre_kinetic_energy));
123       fCreator_proc.insert(std::pair<G4int, G4    123       fCreator_proc.insert(std::pair<G4int, G4String>(trackID, creator_process_name));
124       pre_step_name_s = "InitStep";               124       pre_step_name_s = "InitStep";
125     }                                             125     }
126   }                                               126   }
127                                                   127 
128   // Fill the map for the secondaries             128   // Fill the map for the secondaries
129   if (trackID > 1)                                129   if (trackID > 1)
130   {                                               130   {
131     // First value for each trackIDs; this ser    131     // First value for each trackIDs; this serves to keep it untile the eventID changes.
132     if (fInit_energy.count((int)trackID) == 0)    132     if (fInit_energy.count((int)trackID) == 0)
133     {                                             133     {
134       fInit_energy.insert(std::pair<G4int, G4d    134       fInit_energy.insert(std::pair<G4int, G4double>(trackID, pre_kinetic_energy));
135       fCreator_proc.insert(std::pair<G4int, G4    135       fCreator_proc.insert(std::pair<G4int, G4String>(trackID, creator_process_name));
136     }                                             136     }
137   }                                               137   }
138                                                   138 
139   // Exclude the world volume, which has no mo    139   // Exclude the world volume, which has no mother volume
140   if (((std::string)vol_name).find("expHall")     140   if (((std::string)vol_name).find("expHall") == std::string::npos)
141   {                                               141   {
142     if (track->GetVolume() != nullptr)            142     if (track->GetVolume() != nullptr)
143     {                                             143     {
144       if (track->GetVolume()->GetMotherLogical    144       if (track->GetVolume()->GetMotherLogical() != nullptr)
145       {                                           145       {
146         mother_name = track->GetVolume()->GetM    146         mother_name = track->GetVolume()->GetMotherLogical()->GetName();
147       }                                           147       }
148     }                                             148     }
149     if (((std::string)mother_name).find("Detec    149     if (((std::string)mother_name).find("Detector_log") != std::string::npos || ((std::string)mother_name).find("element_log") != std::string::npos)
150     {                                             150     {
151       proceed = true;                             151       proceed = true;
152     }                                             152     }
153   }                                               153   }
154                                                   154 
155   init_kinetic_energy = fInit_energy[(int)trac    155   init_kinetic_energy = fInit_energy[(int)trackID];
156   init_creator_process = fCreator_proc[trackID    156   init_creator_process = fCreator_proc[trackID];
157                                                   157 
158   G4String cleaned_name = "";                     158   G4String cleaned_name = "";
159   cleaned_name = clean_name(vol_name);            159   cleaned_name = clean_name(vol_name);
160                                                   160 
161   // Saves on tuple                               161   // Saves on tuple
162   if (proceed)                                    162   if (proceed)
163   {                                               163   {
164     G4double x = pre_step_point->GetPosition()    164     G4double x = pre_step_point->GetPosition().x();
165     G4double y = pre_step_point->GetPosition()    165     G4double y = pre_step_point->GetPosition().y();
166     G4double z = pre_step_point->GetPosition()    166     G4double z = pre_step_point->GetPosition().z();
167     G4ThreeVector direction = pre_step_point->    167     G4ThreeVector direction = pre_step_point->GetMomentum();
168     G4double theta = direction.theta();           168     G4double theta = direction.theta();
169     G4double phi = direction.phi();               169     G4double phi = direction.phi();
170     G4int pixel_number = track->GetVolume()->G    170     G4int pixel_number = track->GetVolume()->GetCopyNo();
171     G4int def_replica_number = -999;              171     G4int def_replica_number = -999;                        // default value, to be discarded during the analysis
172     G4int step_number = track->GetCurrentStepN    172     G4int step_number = track->GetCurrentStepNumber();
173     G4double step_energy_dep = step->GetTotalE    173     G4double step_energy_dep = step->GetTotalEnergyDeposit();
174                                                   174 
175     // Fill tuple                                 175     // Fill tuple
176     analysisManager->FillNtupleIColumn(0, even    176     analysisManager->FillNtupleIColumn(0, eventID);
177     analysisManager->FillNtupleSColumn(1, clea    177     analysisManager->FillNtupleSColumn(1, cleaned_name);
178     analysisManager->FillNtupleIColumn(2, trac    178     analysisManager->FillNtupleIColumn(2, trackID);
179     analysisManager->FillNtupleDColumn(3, x);     179     analysisManager->FillNtupleDColumn(3, x);
180     analysisManager->FillNtupleDColumn(4, y);     180     analysisManager->FillNtupleDColumn(4, y);
181     analysisManager->FillNtupleDColumn(5, z);     181     analysisManager->FillNtupleDColumn(5, z);
182     analysisManager->FillNtupleDColumn(6, thet    182     analysisManager->FillNtupleDColumn(6, theta);
183     analysisManager->FillNtupleDColumn(7, phi)    183     analysisManager->FillNtupleDColumn(7, phi);
184     analysisManager->FillNtupleIColumn(8, pare    184     analysisManager->FillNtupleIColumn(8, parentID);
185     if (((std::string)vol_name).find("Bipxl")     185     if (((std::string)vol_name).find("Bipxl") != std::string::npos)
186     {                                             186     {
187       analysisManager->FillNtupleIColumn(9, pi    187       analysisManager->FillNtupleIColumn(9, pixel_number);
188     }                                             188     }
189     else                                          189     else
190     {                                             190     {
191       analysisManager->FillNtupleIColumn(9, de    191       analysisManager->FillNtupleIColumn(9, def_replica_number);
192     }                                             192     }
193     analysisManager->FillNtupleDColumn(10, ste    193     analysisManager->FillNtupleDColumn(10, step_energy_dep);
194     analysisManager->FillNtupleIColumn(11, ste    194     analysisManager->FillNtupleIColumn(11, step_number);
195     analysisManager->FillNtupleDColumn(12, ini    195     analysisManager->FillNtupleDColumn(12, init_kinetic_energy);
196     analysisManager->FillNtupleDColumn(13, kin    196     analysisManager->FillNtupleDColumn(13, kinetic_energy);
197     analysisManager->FillNtupleSColumn(14, par    197     analysisManager->FillNtupleSColumn(14, particle_name);
198     analysisManager->FillNtupleSColumn(15, pre    198     analysisManager->FillNtupleSColumn(15, pre_step_name);
199     analysisManager->FillNtupleSColumn(16, pos    199     analysisManager->FillNtupleSColumn(16, post_step_name);
200     analysisManager->FillNtupleSColumn(17, ini    200     analysisManager->FillNtupleSColumn(17, init_creator_process);
201     analysisManager->AddNtupleRow(0);             201     analysisManager->AddNtupleRow(0);
202   }                                               202   }
203   fPrev_eventID = eventID;                        203   fPrev_eventID = eventID;
204   fPrev_trackID = trackID;                        204   fPrev_trackID = trackID;
205 }                                                 205 }
206                                                   206 
207 //....oooOO0OOooo........oooOO0OOooo........oo    207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
208                                                   208