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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/parameterisations/Par01/src/Par01PionShowerModel.cc (Version 11.3.0) and /examples/extended/parameterisations/Par01/src/Par01PionShowerModel.cc (Version 10.0.p3)


  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 Par01/src/Par01PionShowerModel.cc    << 
 27 /// \brief Implementation of the Par01PionShow << 
 28 //                                             << 
 29 //                                                 26 //
                                                   >>  27 // $Id: Par01PionShowerModel.cc 66241 2012-12-13 18:34:42Z gunter $
 30 //                                                 28 //
 31 #include "Par01PionShowerModel.hh"                 29 #include "Par01PionShowerModel.hh"
 32                                                << 
 33 #include "Par01EnergySpot.hh"                      30 #include "Par01EnergySpot.hh"
 34                                                    31 
 35 #include "G4Colour.hh"                         <<  32 #include "Randomize.hh"
 36 #include "G4PhysicalConstants.hh"              <<  33 
 37 #include "G4PionMinus.hh"                          34 #include "G4PionMinus.hh"
 38 #include "G4PionPlus.hh"                           35 #include "G4PionPlus.hh"
 39 #include "G4SystemOfUnits.hh"                  << 
 40 #include "G4TouchableHistory.hh"               << 
 41 #include "G4TransportationManager.hh"              36 #include "G4TransportationManager.hh"
 42 #include "G4VSensitiveDetector.hh"                 37 #include "G4VSensitiveDetector.hh"
 43 #include "Randomize.hh"                        <<  38 #include "G4TouchableHistory.hh"
 44                                                    39 
 45 //....oooOO0OOooo........oooOO0OOooo........oo <<  40 #include "G4Colour.hh"
                                                   >>  41 #include "G4PhysicalConstants.hh"
                                                   >>  42 #include "G4SystemOfUnits.hh"
 46                                                    43 
 47 Par01PionShowerModel::Par01PionShowerModel(G4S     44 Par01PionShowerModel::Par01PionShowerModel(G4String modelName, G4Region* envelope)
 48   : G4VFastSimulationModel(modelName, envelope <<  45 : G4VFastSimulationModel(modelName, envelope)
 49 {                                                  46 {
 50   fFakeStep = new G4Step();                    <<  47   fFakeStep          = new G4Step();
 51   fFakePreStepPoint = fFakeStep->GetPreStepPoi <<  48   fFakePreStepPoint  = fFakeStep->GetPreStepPoint();
 52   fFakePostStepPoint = fFakeStep->GetPostStepP     49   fFakePostStepPoint = fFakeStep->GetPostStepPoint();
 53   fTouchableHandle = new G4TouchableHistory(); <<  50   fTouchableHandle   = new G4TouchableHistory();
 54   fpNavigator = new G4Navigator();             <<  51   fpNavigator        = new G4Navigator();
 55   fNaviSetup = false;                          <<  52   fNaviSetup         = false;
 56 }                                                  53 }
 57                                                    54 
 58 //....oooOO0OOooo........oooOO0OOooo........oo <<  55 Par01PionShowerModel::Par01PionShowerModel(G4String modelName)
 59                                                <<  56 : G4VFastSimulationModel(modelName)
 60 Par01PionShowerModel::Par01PionShowerModel(G4S << 
 61 {                                                  57 {
 62   fFakeStep = new G4Step();                    <<  58   fFakeStep          = new G4Step();
 63   fFakePreStepPoint = fFakeStep->GetPreStepPoi <<  59   fFakePreStepPoint  = fFakeStep->GetPreStepPoint();
 64   fFakePostStepPoint = fFakeStep->GetPostStepP     60   fFakePostStepPoint = fFakeStep->GetPostStepPoint();
 65   fTouchableHandle = new G4TouchableHistory(); <<  61   fTouchableHandle   = new G4TouchableHistory();
 66   fpNavigator = new G4Navigator();             <<  62   fpNavigator        = new G4Navigator();
 67   fNaviSetup = false;                          <<  63   fNaviSetup         = false;
 68 }                                                  64 }
 69                                                    65 
 70 //....oooOO0OOooo........oooOO0OOooo........oo << 
 71                                                << 
 72 Par01PionShowerModel::~Par01PionShowerModel()      66 Par01PionShowerModel::~Par01PionShowerModel()
 73 {                                                  67 {
 74   delete fFakeStep;                                68   delete fFakeStep;
 75   delete fpNavigator;                              69   delete fpNavigator;
 76 }                                                  70 }
 77                                                    71 
 78 //....oooOO0OOooo........oooOO0OOooo........oo << 
 79                                                << 
 80 G4bool Par01PionShowerModel::IsApplicable(cons     72 G4bool Par01PionShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
 81 {                                                  73 {
 82   return &particleType == G4PionMinus::PionMin <<  74   return 
 83          || &particleType == G4PionPlus::PionP <<  75     &particleType == G4PionMinus::PionMinusDefinition() ||
                                                   >>  76     &particleType == G4PionPlus::PionPlusDefinition();
 84 }                                                  77 }
 85                                                    78 
 86 //....oooOO0OOooo........oooOO0OOooo........oo << 
 87                                                << 
 88 G4bool Par01PionShowerModel::ModelTrigger(cons     79 G4bool Par01PionShowerModel::ModelTrigger(const G4FastTrack&)
 89 {                                                  80 {
 90   // Applies the parameterisation always:          81   // Applies the parameterisation always:
 91   // ie as soon as the pion enters the envelop     82   // ie as soon as the pion enters the envelope
 92   return true;                                     83   return true;
 93 }                                                  84 }
 94                                                    85 
 95 //....oooOO0OOooo........oooOO0OOooo........oo <<  86 void Par01PionShowerModel::DoIt(const G4FastTrack& fastTrack, 
 96                                                <<  87                      G4FastStep& fastStep)
 97 void Par01PionShowerModel::DoIt(const G4FastTr << 
 98 {                                                  88 {
 99   //  G4cout << "Par01PionShowerModel::DoIt" <     89   //  G4cout << "Par01PionShowerModel::DoIt" << G4endl;
100                                                    90 
101   // Kill the parameterised particle:              91   // Kill the parameterised particle:
102   fastStep.KillPrimaryTrack();                     92   fastStep.KillPrimaryTrack();
103   fastStep.ProposePrimaryTrackPathLength(0.0);     93   fastStep.ProposePrimaryTrackPathLength(0.0);
104   fastStep.ProposeTotalEnergyDeposited(fastTra     94   fastStep.ProposeTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetKineticEnergy());
105                                                    95 
106   // split into "energy spots" energy accordin     96   // split into "energy spots" energy according to the shower shape:
107   Explode(fastTrack);                              97   Explode(fastTrack);
108                                                <<  98   
109   // and put those energy spots into the cryst     99   // and put those energy spots into the crystals:
110   BuildDetectorResponse();                        100   BuildDetectorResponse();
111 }                                                 101 }
112                                                   102 
113 //....oooOO0OOooo........oooOO0OOooo........oo << 
114                                                << 
115 void Par01PionShowerModel::Explode(const G4Fas    103 void Par01PionShowerModel::Explode(const G4FastTrack& fastTrack)
116 {                                                 104 {
117   //------------------------------------------    105   //-----------------------------------------------------
118   // Non-physical shower generated: exp along     106   // Non-physical shower generated: exp along z and
119   // transverse.                                  107   // transverse.
120   //------------------------------------------    108   //-----------------------------------------------------
121                                                   109 
122   // center of the shower, we put at the middl    110   // center of the shower, we put at the middle of the ghost:
123   G4ThreeVector showerCenter;                     111   G4ThreeVector showerCenter;
124   G4double distOut;                               112   G4double distOut;
125   distOut = fastTrack.GetEnvelopeSolid()->Dist << 113   distOut = fastTrack.GetEnvelopeSolid()->
126                                                << 114     DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
127   showerCenter = fastTrack.GetPrimaryTrackLoca << 115                   fastTrack.GetPrimaryTrackLocalDirection());
128                  + (distOut / 2.) * fastTrack. << 116   showerCenter = fastTrack.GetPrimaryTrackLocalPosition() + 
                                                   >> 117     (distOut/2.)*fastTrack.GetPrimaryTrackLocalDirection();
129                                                   118 
130   showerCenter = fastTrack.GetInverseAffineTra << 119   showerCenter = fastTrack.GetInverseAffineTransformation()->
                                                   >> 120     TransformPoint(showerCenter);
131                                                   121 
132   // axis of the shower, in global reference f    122   // axis of the shower, in global reference frame:
133   G4ThreeVector xShower, yShower, zShower;        123   G4ThreeVector xShower, yShower, zShower;
134   zShower = fastTrack.GetPrimaryTrack()->GetMo    124   zShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
135   xShower = zShower.orthogonal();                 125   xShower = zShower.orthogonal();
136   yShower = zShower.cross(xShower);               126   yShower = zShower.cross(xShower);
137                                                << 127   
138   // shoot the energy spots:                      128   // shoot the energy spots:
139   G4double Energy = fastTrack.GetPrimaryTrack(    129   G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
140   G4int nSpot = 50;                               130   G4int nSpot = 50;
141   G4double deposit = Energy / double(nSpot);   << 131   G4double deposit = Energy/double(nSpot);
142   Par01EnergySpot eSpot;                          132   Par01EnergySpot eSpot;
143   eSpot.SetEnergy(deposit);                       133   eSpot.SetEnergy(deposit);
144   G4ThreeVector ePoint;                           134   G4ThreeVector ePoint;
145                                                   135 
146   // clear the spot list before use               136   // clear the spot list before use
147   feSpotList.clear();                             137   feSpotList.clear();
148                                                   138 
149   G4double z, r, phi;                             139   G4double z, r, phi;
150   for (int i = 0; i < nSpot; i++) {            << 140   for (int i = 0; i < nSpot; i++)
151     z = G4RandGauss::shoot(0, 20 * cm);        << 141     {
152     r = G4RandGauss::shoot(0, 10 * cm);        << 142       z   = G4RandGauss::shoot(0,20*cm);
153     phi = G4UniformRand() * twopi;             << 143       r   = G4RandGauss::shoot(0,10*cm);
154     ePoint = showerCenter + z * zShower + r *  << 144       phi = G4UniformRand()*twopi;
155     eSpot.SetPosition(ePoint);                 << 145       ePoint = showerCenter +
156     feSpotList.push_back(eSpot);               << 146         z*zShower +
157   }                                            << 147         r*std::cos(phi)*xShower + r*std::sin(phi)*yShower;
                                                   >> 148       eSpot.SetPosition(ePoint);
                                                   >> 149       feSpotList.push_back(eSpot);
                                                   >> 150     }
158 }                                                 151 }
159                                                   152 
160 //....oooOO0OOooo........oooOO0OOooo........oo << 
161                                                   153 
162 void Par01PionShowerModel::BuildDetectorRespon    154 void Par01PionShowerModel::BuildDetectorResponse()
163 {                                                 155 {
164   // Does the assignation of the energy spots     156   // Does the assignation of the energy spots to the sensitive volumes:
165   for (size_t i = 0; i < feSpotList.size(); i+ << 157   for (size_t i = 0; i < feSpotList.size(); i++)
166     // Draw the energy spot:                   << 158     {
167     //      G4Colour red(1.,0.,0.);            << 159       // Draw the energy spot:
168     //      feSpotList[i].Draw(&red);          << 160       G4Colour red(1.,0.,0.);
169     //      feSpotList[i].Print();             << 161       feSpotList[i].Draw(&red);
170                                                << 162       //      feSpotList[i].Print();
171     // "converts" the energy spot into the fak << 163       
172     // G4Step to pass to sensitive detector:   << 164       // "converts" the energy spot into the fake
173     AssignSpotAndCallHit(feSpotList[i]);       << 165       // G4Step to pass to sensitive detector:
174   }                                            << 166       AssignSpotAndCallHit(feSpotList[i]);
                                                   >> 167     }
175 }                                                 168 }
176                                                   169 
177 //....oooOO0OOooo........oooOO0OOooo........oo << 
178                                                   170 
179 void Par01PionShowerModel::AssignSpotAndCallHi << 171 void Par01PionShowerModel::AssignSpotAndCallHit(const Par01EnergySpot &eSpot)
180 {                                                 172 {
181   //                                              173   //
182   // "converts" the energy spot into the fake     174   // "converts" the energy spot into the fake
183   // G4Step to pass to sensitive detector:        175   // G4Step to pass to sensitive detector:
184   //                                              176   //
185   FillFakeStep(eSpot);                            177   FillFakeStep(eSpot);
186                                                   178 
187   //                                              179   //
188   // call sensitive part: taken/adapted from t    180   // call sensitive part: taken/adapted from the stepping:
189   // Send G4Step information to Hit/Dig if the    181   // Send G4Step information to Hit/Dig if the volume is sensitive
190   //                                              182   //
191   G4VPhysicalVolume* pCurrentVolume = fFakeSte << 183   G4VPhysicalVolume* pCurrentVolume = 
                                                   >> 184     fFakeStep->GetPreStepPoint()->GetPhysicalVolume();
192   G4VSensitiveDetector* pSensitive;               185   G4VSensitiveDetector* pSensitive;
193                                                << 186   
194   if (pCurrentVolume != nullptr) {             << 187   if( pCurrentVolume != 0 )
195     pSensitive = pCurrentVolume->GetLogicalVol << 188     {
196     if (pSensitive != nullptr) {               << 189       pSensitive = pCurrentVolume->GetLogicalVolume()->
197       pSensitive->Hit(fFakeStep);              << 190         GetSensitiveDetector();
                                                   >> 191       if( pSensitive != 0 )
                                                   >> 192         {
                                                   >> 193           pSensitive->Hit(fFakeStep);
                                                   >> 194         }
198     }                                             195     }
199   }                                            << 
200 }                                                 196 }
201                                                   197 
202 //....oooOO0OOooo........oooOO0OOooo........oo << 
203                                                   198 
204 void Par01PionShowerModel::FillFakeStep(const  << 199 void Par01PionShowerModel::FillFakeStep(const Par01EnergySpot &eSpot)
205 {                                                 200 {
206   //------------------------------------------    201   //-----------------------------------------------------------
207   // find in which volume the spot is.            202   // find in which volume the spot is.
208   //------------------------------------------    203   //-----------------------------------------------------------
209   if (!fNaviSetup) {                           << 204   if (!fNaviSetup)
210     fpNavigator->SetWorldVolume(G4Transportati << 205     {
211                                   ->GetNavigat << 206       fpNavigator->
212                                   ->GetWorldVo << 207         SetWorldVolume(G4TransportationManager::GetTransportationManager()->
213     fpNavigator->LocateGlobalPointAndUpdateTou << 208                        GetNavigatorForTracking()->GetWorldVolume());
214       eSpot.GetPosition(), G4ThreeVector(0., 0 << 209       fpNavigator->
215     fNaviSetup = true;                         << 210         LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
216   }                                            << 211                                             G4ThreeVector(0.,0.,0.),
217   else {                                       << 212                                             fTouchableHandle,
218     fpNavigator->LocateGlobalPointAndUpdateTou << 213                                             false);
219       eSpot.GetPosition(), G4ThreeVector(0., 0 << 214       fNaviSetup = true;
220   }                                            << 215     }
                                                   >> 216   else
                                                   >> 217     {
                                                   >> 218       fpNavigator->
                                                   >> 219         LocateGlobalPointAndUpdateTouchableHandle(eSpot.GetPosition(),
                                                   >> 220                                             G4ThreeVector(0.,0.,0.),
                                                   >> 221                                             fTouchableHandle);
                                                   >> 222      }
221   //--------------------------------------        223   //--------------------------------------
222   // Fills attribute of the G4Step needed         224   // Fills attribute of the G4Step needed
223   // by our sensitive detector:                   225   // by our sensitive detector:
224   //-------------------------------------         226   //-------------------------------------
225   // set touchable volume at PreStepPoint:        227   // set touchable volume at PreStepPoint:
226   fFakePreStepPoint->SetTouchableHandle(fTouch    228   fFakePreStepPoint->SetTouchableHandle(fTouchableHandle);
227   // set total energy deposit:                    229   // set total energy deposit:
228   fFakeStep->SetTotalEnergyDeposit(eSpot.GetEn    230   fFakeStep->SetTotalEnergyDeposit(eSpot.GetEnergy());
229 }                                                 231 }
230                                                   232