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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/Par01PiModel.cc (Version 11.3.0) and /examples/extended/parameterisations/Par01/src/Par01PiModel.cc (Version 10.4.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/Par01PiModel.cc                26 /// \file Par01/src/Par01PiModel.cc
 27 /// \brief Implementation of the Par01PiModel      27 /// \brief Implementation of the Par01PiModel class
 28 //                                                 28 //
 29 //                                                 29 //
                                                   >>  30 // $Id$
 30 //                                                 31 //
 31 #include "Par01PiModel.hh"                         32 #include "Par01PiModel.hh"
 32                                                    33 
 33 #include "G4Gamma.hh"                          << 
 34 #include "G4PionMinus.hh"                          34 #include "G4PionMinus.hh"
 35 #include "G4PionPlus.hh"                           35 #include "G4PionPlus.hh"
                                                   >>  36 #include "G4Gamma.hh"
 36                                                    37 
 37 //....oooOO0OOooo........oooOO0OOooo........oo     38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 38                                                    39 
 39 Par01PiModel::Par01PiModel(G4Region* anEnvelop <<  40 Par01PiModel::Par01PiModel(G4Region *anEnvelope) :
 40   : G4VFastSimulationModel("Par01PiModel", anE <<  41   G4VFastSimulationModel("Par01PiModel",anEnvelope)
 41 {                                              <<  42 {;}
 42   ;                                            << 
 43 }                                              << 
 44                                                    43 
 45 //....oooOO0OOooo........oooOO0OOooo........oo     44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 46                                                    45 
 47 Par01PiModel::~Par01PiModel()                      46 Par01PiModel::~Par01PiModel()
 48 {                                              <<  47 {;}
 49   ;                                            << 
 50 }                                              << 
 51                                                    48 
 52 //....oooOO0OOooo........oooOO0OOooo........oo     49 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 53                                                    50 
 54 G4bool Par01PiModel::IsApplicable(const G4Part     51 G4bool Par01PiModel::IsApplicable(const G4ParticleDefinition& particleType)
 55 {                                                  52 {
 56   return &particleType == G4PionMinus::PionMin <<  53   return
 57          || &particleType == G4PionPlus::PionP <<  54     &particleType == G4PionMinus::PionMinusDefinition() ||
                                                   >>  55     &particleType == G4PionPlus::PionPlusDefinition();
 58 }                                                  56 }
 59                                                    57 
 60 //....oooOO0OOooo........oooOO0OOooo........oo     58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 61                                                    59 
 62 G4bool Par01PiModel::ModelTrigger(const G4Fast <<  60 G4bool Par01PiModel::ModelTrigger(const G4FastTrack& fastTrack) {
 63 {                                              << 
 64   //------------------------------------------     61   //-------------------------------------------------------------
 65   // UserTrigger() method: method which has to     62   // UserTrigger() method: method which has to decide if
 66   // the parameterisation has to be applied.       63   // the parameterisation has to be applied.
 67   // Here ModelTrigger() asks the user (ie you     64   // Here ModelTrigger() asks the user (ie you) a 0/1 answer.
 68   //                                               65   //
 69   // Note that quantities like the local/globa     66   // Note that quantities like the local/global position/direction etc..
 70   // are available at this level via the fastT <<  67   // are available at this level via the fastTrack parameter (allowing 
 71   // to check distance from boundaries, see be     68   // to check distance from boundaries, see below  to allow the decision)
 72   //------------------------------------------     69   //--------------------------------------------------------------
 73   G4cout << "\nPar01PiModel::ModelTrigger() ca     70   G4cout << "\nPar01PiModel::ModelTrigger() called:" << G4endl;
 74   G4cout << "--------------------------------" <<  71   G4cout <<   "--------------------------------" << G4endl;
 75   G4cout << "(particle is a " << fastTrack.Get <<  72   G4cout << "(particle is a " << fastTrack.GetPrimaryTrack()->
 76          << " )\n"                             <<  73     GetDefinition()->GetParticleName() << " )\n" << G4endl;
 77          << G4endl;                            << 
 78                                                    74 
 79   // -- Examples of available informations:        75   // -- Examples of available informations:
 80                                                    76 
 81   // -- position:                                  77   // -- position:
 82   G4cout << "         Track position: " << fas <<  78   G4cout << "         Track position: " <<
 83          << "(global coord.)" << fastTrack.Get <<  79     fastTrack.GetPrimaryTrack()->GetPosition()  << "(global coord.)"   <<
 84          << G4endl;                            <<  80     fastTrack.GetPrimaryTrackLocalPosition()  << "(in envelope coord.)" 
                                                   >>  81        << G4endl;
 85                                                    82 
 86   // -- direction:                                 83   // -- direction:
 87   G4cout << "         Track direction:" << fas <<  84   G4cout << "         Track direction:"       <<
 88          << "(global coord.)" << fastTrack.Get <<  85     fastTrack.GetPrimaryTrack()->GetMomentum().unit() << 
 89          << G4endl;                            <<  86     "(global coord.)"      <<
                                                   >>  87     fastTrack.GetPrimaryTrackLocalDirection() << "(in envelope coord.)" << 
                                                   >>  88     G4endl;
 90                                                    89 
 91   return true;                                     90   return true;
 92 }                                                  91 }
 93                                                    92 
 94 //....oooOO0OOooo........oooOO0OOooo........oo     93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
 95                                                    94 
 96 void Par01PiModel::DoIt(const G4FastTrack& fas <<  95 void Par01PiModel::DoIt(const G4FastTrack& fastTrack, 
 97 //-------------------------------------------- <<  96                         G4FastStep& fastStep)
 98 //                                             <<  97   //--------------------------------------------------------
 99 // User method to code the parameterisation pr <<  98   //
100 //                                             <<  99   // User method to code the parameterisation properly said.
101 //-------------------------------------------- << 100   //
                                                   >> 101   //--------------------------------------------------------
102 {                                                 102 {
                                                   >> 103 
103   //------------------------------------------    104   //------------------------------------------------
104   // The primary track continues along its dir    105   // The primary track continues along its direction.
105   // One secondary (a photon) is added:           106   // One secondary (a photon) is added:
106   //------------------------------------------    107   //------------------------------------------------
107   G4cout << "      Pion `model' applied\n" <<     108   G4cout << "      Pion `model' applied\n" << G4endl;
108                                                   109 
109   //------------------------------                110   //------------------------------
110   // Primary:                                     111   // Primary:
111   //    idem as in "DefaultModel":                112   //    idem as in "DefaultModel":
112   //                                              113   //
113   //------------------------------                114   //------------------------------
114   G4ThreeVector position;                         115   G4ThreeVector position;
115   G4double distance;                              116   G4double distance;
116   distance = fastTrack.GetEnvelopeSolid()->Dis << 117   distance = fastTrack.GetEnvelopeSolid()->
117                                                << 118     DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
118   position =                                   << 119                   fastTrack.GetPrimaryTrackLocalDirection());
119     fastTrack.GetPrimaryTrackLocalPosition() + << 120   position = fastTrack.GetPrimaryTrackLocalPosition() + 
120                                                << 121     distance*fastTrack.GetPrimaryTrackLocalDirection();
                                                   >> 122   
121   // -- set final position:                       123   // -- set final position:
122   fastStep.ProposePrimaryTrackFinalPosition(po    124   fastStep.ProposePrimaryTrackFinalPosition(position);
123                                                << 125   
124   //---------------------------                   126   //---------------------------
125   // Secondary:                                   127   // Secondary:
126   //   Adds one "secondary":                      128   //   Adds one "secondary":
127   //---------------------------                   129   //---------------------------
128   // -- First, user has to say how many second    130   // -- First, user has to say how many secondaries will be created:
129   fastStep.SetNumberOfSecondaryTracks(1);         131   fastStep.SetNumberOfSecondaryTracks(1);
130                                                << 132   
131   //------------------------                      133   //------------------------
132   // -- Build the secondary:                      134   // -- Build the secondary:
133   //------------------------                      135   //------------------------
134   // -- direction:                                136   // -- direction:
135   G4ParticleMomentum direction(fastTrack.GetPr    137   G4ParticleMomentum direction(fastTrack.GetPrimaryTrackLocalDirection());
136   direction.setZ(direction.z() * 0.5);         << 138   direction.setZ(direction.z()*0.5);
137   direction.setY(direction.y() + direction.z() << 139   direction.setY(direction.y()+direction.z()*0.1);
138   direction = direction.unit();  // necessary  << 140   direction = direction.unit(); // necessary ?
139                                                << 141   
140   // -- dynamics (Note that many constructors     142   // -- dynamics (Note that many constructors exists for G4DynamicParticle
141   // -- see prototype/particle+matter/particle    143   // -- see prototype/particle+matter/particles/management/include/G4DynamicParticle.hh)
142   G4DynamicParticle dynamique(G4Gamma::GammaDe << 144   G4DynamicParticle dynamique(G4Gamma::GammaDefinition(),
143                               fastTrack.GetPri << 145                               direction,
                                                   >> 146                               fastTrack.GetPrimaryTrack()->
                                                   >> 147                               GetKineticEnergy()/2.);
144   // -- position:                                 148   // -- position:
145   G4double Dist;                                  149   G4double Dist;
146   Dist = fastTrack.GetEnvelopeSolid()->Distanc << 150   Dist = fastTrack.GetEnvelopeSolid()->
147                                                << 151     DistanceToOut(fastTrack.GetPrimaryTrackLocalPosition(),
                                                   >> 152                   direction);
148   G4ThreeVector posi;                             153   G4ThreeVector posi;
149   posi = fastTrack.GetPrimaryTrackLocalPositio << 154   posi = fastTrack.GetPrimaryTrackLocalPosition() + Dist*direction;
150                                                << 155   
151   //------------------------------------          156   //------------------------------------
152   //-- Creation of the secondary Track:           157   //-- Creation of the secondary Track:
153   //------------------------------------          158   //------------------------------------
154   fastStep.CreateSecondaryTrack(dynamique, pos << 159   fastStep.CreateSecondaryTrack(dynamique, posi, 
                                                   >> 160                                 fastTrack.GetPrimaryTrack()->GetGlobalTime());  
155 }                                                 161 }
156                                                   162