Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/parameterisations/gflash/src/GFlashShowerModel.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.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 /parameterisations/gflash/src/GFlashShowerModel.cc (Version 11.3.0) and /parameterisations/gflash/src/GFlashShowerModel.cc (Version 7.0.p1)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                    <<   3 // * DISCLAIMER                                                       *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th <<   5 // * The following disclaimer summarizes all the specific disclaimers *
  6 // * the Geant4 Collaboration.  It is provided <<   6 // * of contributors to this software. The specific disclaimers,which *
  7 // * conditions of the Geant4 Software License <<   7 // * govern, are listed with their locations in:                      *
  8 // * LICENSE and available at  http://cern.ch/ <<   8 // *   http://cern.ch/geant4/license                                  *
  9 // * include a list of copyright holders.      << 
 10 // *                                                9 // *                                                                  *
 11 // * Neither the authors of this software syst     10 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     11 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     12 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     13 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file  <<  14 // * use.                                                             *
 16 // * for the full disclaimer and the limitatio << 
 17 // *                                               15 // *                                                                  *
 18 // * This  code  implementation is the result  <<  16 // * This  code  implementation is the  intellectual property  of the *
 19 // * technical work of the GEANT4 collaboratio <<  17 // * GEANT4 collaboration.                                            *
 20 // * By using,  copying,  modifying or  distri <<  18 // * By copying,  distributing  or modifying the Program (or any work *
 21 // * any work based  on the software)  you  ag <<  19 // * based  on  the Program)  you indicate  your  acceptance of  this *
 22 // * use  in  resulting  scientific  publicati <<  20 // * statement, and all its terms.                                    *
 23 // * acceptance of all terms of the Geant4 Sof << 
 24 // *******************************************     21 // ********************************************************************
 25 //                                                 22 //
 26 //                                             <<  23 //E.Barberio & Joanna Weng 
 27 //                                             << 
 28 // ------------------------------------------- << 
 29 // GEANT 4 class implementation                << 
 30 //                                             << 
 31 //      ---------------- GFlashShowerModel --- << 
 32 //                                             << 
 33 // Authors: E.Barberio & Joanna Weng - 9.11.20 << 
 34 // ------------------------------------------- << 
 35                                                    24 
 36 #include "G4Electron.hh"                           25 #include "G4Electron.hh"
 37 #include "G4Positron.hh"                           26 #include "G4Positron.hh"
                                                   >>  27 #include "G4Gamma.hh"
 38 #include "G4NeutrinoE.hh"                          28 #include "G4NeutrinoE.hh"
 39 #include "G4NeutrinoMu.hh"                         29 #include "G4NeutrinoMu.hh"
 40 #include "G4NeutrinoTau.hh"                        30 #include "G4NeutrinoTau.hh"
 41 #include "G4AntiNeutrinoE.hh"                      31 #include "G4AntiNeutrinoE.hh"
 42 #include "G4AntiNeutrinoMu.hh"                     32 #include "G4AntiNeutrinoMu.hh"
 43 #include "G4AntiNeutrinoTau.hh"                    33 #include "G4AntiNeutrinoTau.hh"
 44 #include "G4PionZero.hh"                           34 #include "G4PionZero.hh"
 45 #include "G4VProcess.hh"                           35 #include "G4VProcess.hh"
 46 #include "G4ios.hh"                                36 #include "G4ios.hh"
 47 #include "G4LogicalVolume.hh"                      37 #include "G4LogicalVolume.hh"
 48 #include "geomdefs.hh"                             38 #include "geomdefs.hh"
 49                                                    39 
 50 #include "GFlashShowerModel.hh"                    40 #include "GFlashShowerModel.hh"
 51 #include "GFlashHomoShowerParameterisation.hh" <<  41 #include "GFlashHomoShowerParamterisation.hh"
 52 #include "GFlashSamplingShowerParameterisation << 
 53 #include "GFlashEnergySpot.hh"                     42 #include "GFlashEnergySpot.hh"
 54                                                    43 
 55 GFlashShowerModel::GFlashShowerModel(G4String  <<  44 
 56   : G4VFastSimulationModel(modelName, envelope <<  45 GFlashShowerModel::GFlashShowerModel(G4String modelName, G4LogicalVolume* envelope)
                                                   >>  46 : G4VFastSimulationModel(modelName, envelope)
 57 {                                                  47 {
 58   FlagParamType = 0;                           <<  48   FlagParamType           = 0;
 59   FlagParticleContainment = 1;                 <<  49   FlagParticleContainment = 1;  
 60   StepInX0 = 0.1;                              <<  50   StepInX0 = 0.1;
 61   EnergyStop = 0.0;                            <<  51   Messenger       = new GFlashShowerModelMessenger(this);
 62   Messenger = new GFlashShowerModelMessenger(t << 
 63 }                                                  52 }
 64                                                    53 
 65 GFlashShowerModel::GFlashShowerModel(G4String      54 GFlashShowerModel::GFlashShowerModel(G4String modelName)
 66   : G4VFastSimulationModel(modelName), PBound( <<  55 : G4VFastSimulationModel(modelName)
 67 {                                                  56 {
 68   FlagParamType = 1;                           <<  57   FlagParamType           =1;
 69   FlagParticleContainment = 1;                 <<  58   FlagParticleContainment = 1;  
 70   StepInX0 = 0.1;                              <<  59   StepInX0 = 0.1; 
 71   EnergyStop = 0.0;                            <<  60   Messenger       = new GFlashShowerModelMessenger(this); 
 72   Messenger = new GFlashShowerModelMessenger(t << 
 73 }                                                  61 }
 74                                                    62 
                                                   >>  63 
 75 GFlashShowerModel::~GFlashShowerModel()            64 GFlashShowerModel::~GFlashShowerModel()
 76 {                                                  65 {
 77   delete Messenger;                            <<  66   Messenger       = new GFlashShowerModelMessenger(this);
 78 }                                                  67 }
 79                                                    68 
 80 G4bool GFlashShowerModel::IsApplicable(const G     69 G4bool GFlashShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
 81 {                                              <<  70 { 
 82   return &particleType == G4Electron::Electron <<  71   return 
 83          || &particleType == G4Positron::Posit <<  72   &particleType == G4Electron::ElectronDefinition() ||
                                                   >>  73   &particleType == G4Positron::PositronDefinition(); 
 84 }                                                  74 }
 85                                                    75 
 86 /********************************************* <<  76 /*********************************************************************/
 87 /* Checks whether conditions of fast parameter <<  77 /* Checks whether conditions of fast parametrisation  are fullfilled */
 88 /*********************************************     78 /**********************************************************************/
 89                                                    79 
 90 G4bool GFlashShowerModel::ModelTrigger(const G <<  80 G4bool GFlashShowerModel::ModelTrigger(const G4FastTrack & fastTrack )
 91                                                    81 
 92 {                                                  82 {
 93   G4bool select = false;                       <<  83   G4bool select = false;
 94   if (FlagParamType != 0) {                    <<  84   if(FlagParamType != 0)                  
 95     G4double ParticleEnergy = fastTrack.GetPri <<  85   {
 96     G4ParticleDefinition& ParticleType = *(fas <<  86     G4double  ParticleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy(); 
 97     if (ParticleEnergy > PBound->GetMinEneToPa <<  87     G4ParticleDefinition &ParticleType = *(fastTrack.GetPrimaryTrack()->GetDefinition()); 
 98         && ParticleEnergy < PBound->GetMaxEneT <<  88     if(ParticleEnergy > PBound->GetMinEneToParametrise(ParticleType) ||
 99     {                                          <<  89       ParticleEnergy < PBound->GetMaxEneToParametrise(ParticleType) )
100       // check conditions depending on particl <<  90     {
101       // performance to be optimized @@@@@@@   <<  91       ///check conditions depending on particle flavour
102       Parameterisation->GenerateLongitudinalPr <<  92       Parametrisation->GenerateLongitudinalProfile(ParticleEnergy); // performance to be optimized @@@@@@@
103       select = CheckParticleDefAndContainment( <<  93       select     = CheckParticleDefAndContainment(fastTrack); 
104       if (select) EnergyStop = PBound->GetEneT <<  94       if (select) EnergyStop= PBound->GetEneToKill(ParticleType);
105     }                                          <<  95     }
106   }                                            <<  96   }
107                                                <<  97   return select; 
108   return select;                               << 
109 }                                                  98 }
110                                                    99 
111 G4bool GFlashShowerModel::CheckParticleDefAndC << 
112 {                                              << 
113   G4bool filter = false;                       << 
114   G4ParticleDefinition* ParticleType = fastTra << 
115                                                   100 
116   if (ParticleType == G4Electron::ElectronDefi << 101 G4bool GFlashShowerModel::CheckParticleDefAndContainment(const G4FastTrack& fastTrack)
117       || ParticleType == G4Positron::PositronD << 102 {  
118   {                                            << 103   G4bool filter=false;
119     filter = true;                             << 104   G4ParticleDefinition * ParticleType = fastTrack.GetPrimaryTrack()->GetDefinition(); 
120     if (FlagParticleContainment == 1) {        << 105   
121       filter = CheckContainment(fastTrack);    << 106   if(  ParticleType == G4Electron::ElectronDefinition() || 
122     }                                          << 107     ParticleType == G4Positron::PositronDefinition() )
123   }                                            << 108   {
124   return filter;                               << 109     filter=true;
                                                   >> 110     if(FlagParticleContainment == 1)  
                                                   >> 111     {
                                                   >> 112       filter=CheckContainment(fastTrack); 
                                                   >> 113     }
                                                   >> 114   }
                                                   >> 115   return filter;  
125 }                                                 116 }
126                                                   117 
127 G4bool GFlashShowerModel::CheckContainment(con    118 G4bool GFlashShowerModel::CheckContainment(const G4FastTrack& fastTrack)
128 {                                                 119 {
129   G4bool filter = false;                       << 120   //Note: typedef Hep3Vector G4ThreeVector;
130   // track informations                        << 121   
131   G4ThreeVector DirectionShower = fastTrack.Ge << 122   G4bool filter=false;
132   G4ThreeVector InitialPositionShower = fastTr << 123   //track informations
133                                                << 124   G4ThreeVector DirectionShower = fastTrack.GetPrimaryTrackLocalDirection();
134   G4ThreeVector OrthoShower, CrossShower;      << 125   G4ThreeVector InitialPositionShower = fastTrack.GetPrimaryTrackLocalPosition();
135   // Returns orthogonal vector                 << 126   
136   OrthoShower = DirectionShower.orthogonal();  << 127   G4ThreeVector OrthoShower, CrossShower; 
137   // Shower in direction perpendicular to Orth << 128   //Returns orthogonal vector 
138   CrossShower = DirectionShower.cross(OrthoSho << 129   OrthoShower = DirectionShower.orthogonal();
139                                                << 130   // Shower in direction perpendicular to OrthoShower and DirectionShower
140   G4double R = Parameterisation->GetAveR90();  << 131   CrossShower = DirectionShower.cross(OrthoShower);
141   G4double Z = Parameterisation->GetAveT90();  << 132   
142   G4int CosPhi[4] = {1, 0, -1, 0};             << 133   G4double  R     = Parametrisation->GetAveR90();
143   G4int SinPhi[4] = {0, 1, 0, -1};             << 134   G4double  Z     = Parametrisation->GetAveT90();
144                                                << 135   G4int CosPhi[4] = {1,0,-1,0};
145   G4ThreeVector Position;                      << 136   G4int SinPhi[4] = {0,1,0,-1};
146   G4int NlateralInside = 0;                    << 137   
147   // pointer to solid we're in                 << 138   G4ThreeVector Position;
148   G4VSolid* SolidCalo = fastTrack.GetEnvelopeS << 139   G4int NlateralInside=0;
149   for (int i = 0; i < 4; i++) {                << 140   //pointer to soild we're in
150     // polar coordinates                       << 141   G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
151     Position = InitialPositionShower + Z * Dir << 142   for(int i=0; i<4 ;i++)
152                + R * SinPhi[i] * CrossShower;  << 143   {
153                                                << 144     // polar coordinates
154     if (SolidCalo->Inside(Position) != kOutsid << 145     Position = InitialPositionShower       + 
155   }                                            << 146     Z*DirectionShower           +
156                                                << 147     R*CosPhi[i]*OrthoShower     +
157   // choose to parameterise or flag when all i << 148     R*SinPhi[i]*CrossShower     ;
158   if (NlateralInside == 4) filter = true;      << 149     
159   // std::cout << " points =   " <<NlateralIns << 150     if(SolidCalo->Inside(Position) != kOutside) 
160   return filter;                               << 151       NlateralInside=NlateralInside++;
                                                   >> 152   }
                                                   >> 153   
                                                   >> 154   //chose to parametrise or flag when all inetc...
                                                   >> 155   if(NlateralInside==4) filter=true;
                                                   >> 156   // std::cout << " points =   " <<NlateralInside << std::endl;
                                                   >> 157   return filter;
161 }                                                 158 }
162                                                   159 
                                                   >> 160 
163 void GFlashShowerModel::DoIt(const G4FastTrack    161 void GFlashShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
164 {                                                 162 {
165   // parametrise electrons                     << 163   // parametrise electrons
166   if (fastTrack.GetPrimaryTrack()->GetDefiniti << 164   if(fastTrack.GetPrimaryTrack()->GetDefinition() == G4Electron::ElectronDefinition() || 
167       || fastTrack.GetPrimaryTrack()->GetDefin << 165     fastTrack.GetPrimaryTrack()->GetDefinition() == G4Positron::PositronDefinition() ) 
168     ElectronDoIt(fastTrack, fastStep);         << 166   ElectronDoIt(fastTrack,fastStep);
169 }                                                 167 }
170                                                   168 
171 void GFlashShowerModel::ElectronDoIt(const G4F << 169 void GFlashShowerModel::ElectronDoIt(const G4FastTrack& fastTrack,  G4FastStep& fastStep)
172 {                                                 170 {
173   // std::cout<<"--- ElectronDoit --- "<<std:: << 171   // std::cout<<"--- ElectronDoit --- "<<std::endl;
174                                                << 172   
175   fastStep.KillPrimaryTrack();                 << 173   fastStep.KillPrimaryTrack();
176   fastStep.ProposePrimaryTrackPathLength(0.0); << 174   fastStep.SetPrimaryTrackPathLength(0.0);
177   fastStep.ProposeTotalEnergyDeposited(fastTra << 175   fastStep.SetTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetKineticEnergy());
178                                                << 176   
179   //-----------------------------              << 177   //-----------------------------
180   // Get track parameters                      << 178   // Get track parameters 
181   //-----------------------------              << 179   //----------------------------- 
182   // E,vect{p} and t,vec(x)                    << 180   //E,vect{p} and t,vec(x)
183   G4double Energy = fastTrack.GetPrimaryTrack( << 181   G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
184                                                << 182   
185   // axis of the shower, in global reference f << 183   // axis of the shower, in global reference frame:
186   G4ThreeVector DirectionShower = fastTrack.Ge << 184   G4ThreeVector DirectionShower = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
187   G4ThreeVector OrthoShower, CrossShower;      << 185   G4ThreeVector OrthoShower, CrossShower;
188   OrthoShower = DirectionShower.orthogonal();  << 186   OrthoShower = DirectionShower.orthogonal();
189   CrossShower = DirectionShower.cross(OrthoSho << 187   CrossShower = DirectionShower.cross(OrthoShower);
190                                                << 188   
191   //--------------------------------           << 189   //--------------------------------
192   /// Generate longitudinal profile            << 190   ///Generate longitudinal profile
193   //--------------------------------           << 191   //--------------------------------
194   Parameterisation->GenerateLongitudinalProfil << 192   Parametrisation->GenerateLongitudinalProfile(Energy); // performane iteration @@@@@@@
195   // performance iteration @@@@@@@             << 193   
196                                                << 194   ///Initialisation of long. loop variables
197   /// Initialisation of long. loop variables   << 195   G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
198   G4VSolid* SolidCalo = fastTrack.GetEnvelopeS << 196   G4ThreeVector pos   = fastTrack.GetPrimaryTrackLocalPosition();
199   G4ThreeVector pos = fastTrack.GetPrimaryTrac << 197   G4ThreeVector dir   = fastTrack.GetPrimaryTrackLocalDirection();
200   G4ThreeVector dir = fastTrack.GetPrimaryTrac << 198   G4double Bound      = SolidCalo->DistanceToOut(pos,dir); 
201   G4double Bound = SolidCalo->DistanceToOut(po << 199   
202                                                << 200   G4double Dz       = 0.00;     
203   G4double Dz = 0.00;                          << 201   G4double ZEndStep = 0.00;
204   G4double ZEndStep = 0.00;                    << 202   
205                                                << 203   G4double EnergyNow        = Energy;
206   G4double EnergyNow = Energy;                 << 204   G4double EneIntegral      = 0.00;   
207   G4double EneIntegral = 0.00;                 << 205   G4double LastEneIntegral  = 0.00;   
208   G4double LastEneIntegral = 0.00;             << 206   G4double DEne             = 0.00;
209   G4double DEne = 0.00;                        << 207   
210                                                << 208   G4double NspIntegral      = 0.00;   
211   G4double NspIntegral = 0.00;                 << 209   G4double LastNspIntegral  = 0.00;   
212   G4double LastNspIntegral = 0.00;             << 210   G4double DNsp             = 0.00;
213   G4double DNsp = 0.00;                        << 211   
214                                                << 212   // starting point of the shower:
215   // starting point of the shower:             << 213   G4ThreeVector PositionShower  = fastTrack.GetPrimaryTrack()->GetPosition();
216   G4ThreeVector PositionShower = fastTrack.Get << 214   G4ThreeVector NewPositionShower    = PositionShower;   
217   G4ThreeVector NewPositionShower = PositionSh << 215   G4double      StepLenght           = 0.00;
218   G4double StepLenght = 0.00;                  << 216   
219                                                << 217   G4int NSpotDeposited =0;
220   //--------------------------                 << 218   
221   /// Begin Longitudinal Loop                  << 219   //--------------------------
222   //-------------------------                  << 220   /// Begin Longitudinal Loop
223                                                << 221   //-------------------------
224   do {                                         << 222   
225     // determine step size=min(1Xo,next bounda << 223   do
226     G4double stepLength = StepInX0 * Parameter << 224   {  
227     if (Bound < stepLength) {                  << 225     //determine step size=min(1Xo,next boundary)
228       Dz = Bound;                              << 226     G4double stepLength = StepInX0*Parametrisation->GetX0();
229       Bound = 0.00;                            << 227     if(Bound < stepLength)
230     }                                          << 228     { 
231     else {                                     << 229       Dz    = Bound;
232       Dz = stepLength;                         << 230       Bound = 0.00;
233       Bound = Bound - Dz;                      << 231     }
234     }                                          << 232     else
235     ZEndStep = ZEndStep + Dz;                  << 233     { 
236                                                << 234       Dz    = stepLength;
237     // Determine Energy Release in Step        << 235       Bound = Bound-Dz;
238     if (EnergyNow > EnergyStop) {              << 236     }
239       LastEneIntegral = EneIntegral;           << 237     ZEndStep=ZEndStep+Dz;
240       EneIntegral = Parameterisation->Integrat << 238     
241       DEne = std::min(EnergyNow, (EneIntegral  << 239     // Determine Energy Release in Step
242       LastNspIntegral = NspIntegral;           << 240     if(EnergyNow > EnergyStop)
243       NspIntegral = Parameterisation->Integrat << 241     {
244       DNsp =                                   << 242       LastEneIntegral  = EneIntegral;
245         std::max(1., std::floor((NspIntegral - << 243       EneIntegral      = Parametrisation->IntegrateEneLongitudinal(ZEndStep);
246     }                                          << 244       DEne             = std::min( EnergyNow, (EneIntegral-LastEneIntegral)*Energy);
247     // end of the shower                       << 245       LastNspIntegral  = NspIntegral;
248     else {                                     << 246       NspIntegral      = Parametrisation->IntegrateNspLongitudinal(ZEndStep);
249       DEne = EnergyNow;                        << 247       DNsp             = std::max(1., std::floor( (NspIntegral-LastNspIntegral)*Parametrisation->GetNspot() ) );
250       DNsp = std::max(1., std::floor((1. - Nsp << 248     }
251     }                                          << 249     // end of the shower
252     EnergyNow = EnergyNow - DEne;              << 250     else
253                                                << 251     {    
254     // Apply sampling fluctuation - only in sa << 252       DEne             = EnergyNow;
255     //                                         << 253       DNsp             = std::max(1., std::floor( (1.- NspIntegral)*Parametrisation->GetNspot() ));
256     GFlashSamplingShowerParameterisation* sp = << 254     } 
257       dynamic_cast<GFlashSamplingShowerParamet << 255     EnergyNow  = EnergyNow - DEne;
258     if (sp) {                                  << 256     
259       G4double DEneSampling = sp->ApplySamplin << 257     //  apply sampling fluctuation
260       DEne = DEneSampling;                     << 258     // G4double DEneSampling = Parametrisation->ApplySampling(DEne,Energy);
261     }                                          << 259     
262                                                << 260     //move particle in the middle of the step
263     // move particle in the middle of the step << 261     StepLenght        = StepLenght + Dz/2.00;  
264     StepLenght = StepLenght + Dz / 2.00;       << 262     NewPositionShower = NewPositionShower + 
265     NewPositionShower = NewPositionShower + St << 263     StepLenght*DirectionShower;
266     StepLenght = Dz / 2.00;                    << 264     StepLenght        = Dz/2.00;
267                                                << 265     
268     // generate spots & hits:                  << 266     //generate spots & hits:
269     for (G4int i = 0; i < DNsp; ++i) {         << 267     for (int i = 0; i < DNsp; i++)
270       GFlashEnergySpot Spot;                   << 268     { 
271                                                << 269       NSpotDeposited=NSpotDeposited++;
272       // Spot energy: the same for all spots   << 270       GFlashEnergySpot Spot;      
273       Spot.SetEnergy(DEne / DNsp);             << 271       
274       G4double PhiSpot = Parameterisation->Gen << 272       //Spot energy: the same for all spots
275       G4double RSpot = Parameterisation  // ra << 273       Spot.SetEnergy( DEne / DNsp );
276                          ->GenerateRadius(i, E << 274       G4double PhiSpot = Parametrisation->GeneratePhi(); // phi of spot
277                                                << 275       G4double RSpot   = Parametrisation->GenerateRadius(i,Energy,ZEndStep-Dz/2.); // radius of spot
278       // check reference-> may be need to intr << 276       ///check reference-> may be need to introduce rot matrix @@@
279       // Position: equally spaced in z         << 277       //Position: equally spaced in z
280                                                << 278       
281       G4ThreeVector SpotPosition =             << 279       G4ThreeVector SpotPosition = NewPositionShower                         +
282         NewPositionShower + Dz / DNsp * Direct << 280       Dz/DNsp*DirectionShower*(i+1/2.-DNsp/2.)  +
283         + RSpot * std::cos(PhiSpot) * OrthoSho << 281       RSpot*std::cos(PhiSpot)*OrthoShower            +  
284       Spot.SetPosition(SpotPosition);          << 282       RSpot*std::sin(PhiSpot)*CrossShower;      
285                                                << 283       Spot.SetPosition(SpotPosition);
286       // Generate Hits of this spot            << 284       
287       HMaker->make(&Spot, &fastTrack);         << 285       //Generate Hits of this spot      
288     }                                          << 286       HMaker->make(&Spot, &fastTrack);
289   } while (EnergyNow > 0.0 && Bound > 0.0);    << 287     }
290                                                << 288   }
291   //---------------                            << 289   while(EnergyNow > 0.0 && Bound> 0.0);     
292   /// End Loop                                 << 290   
293   //---------------                            << 291   //---------------
                                                   >> 292   /// End Loop
                                                   >> 293   //------------- 
                                                   >> 294   
294 }                                                 295 }
295                                                   296 
296 /*                                             << 297 /* void GFlashShowerModel::GammaDoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
297                                                << 298 { 
298 void                                           << 299   
299 GFlashShowerModel::GammaDoIt(const G4FastTrack << 300   if( fastTrack.GetPrimaryTrack()->GetKineticEnergy() > EnergyStop )
300                                    G4FastStep& << 301     return;
301 {                                              << 302   
302                                                << 303   //deposita in uno spot unico l'energia 
303   if( fastTrack.GetPrimaryTrack()->GetKineticE << 304   //con andamento exp decrescente. 
304     return;                                    << 305   
305                                                << 306   // Kill the particle to be parametrised
306   //deposita in uno spot unico l'energia       << 307   fastStep.KillPrimaryTrack();
307   //con andamento exp decrescente.             << 308   fastStep.SetPrimaryTrackPathLength(0.0);
308                                                << 309   fastStep.SetTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->GetKineticEnergy());
309   // Kill the particle to be parametrised      << 310   //other settings????
310   fastStep.KillPrimaryTrack();                 << 311   feSpotList.clear();   
311   fastStep.SetPrimaryTrackPathLength(0.0);     << 312   //-----------------------------
312   fastStep.SetTotalEnergyDeposited(fastTrack.G << 313   // Get track parameters 
313                                    ->GetKineti << 314   //-----------------------------
314   // other settings????                        << 315   //E,vect{p} and t,vec(x)
315   feSpotList.clear();                          << 316   G4double Energy = 
316                                                << 317   fastTrack.GetPrimaryTrack()->GetKineticEnergy();
317   //-----------------------------              << 318   // axis of the shower, in global reference frame:
318   // Get track parameters                      << 319   G4ThreeVector DirectionShower 
319   //-----------------------------              << 320   = fastTrack.GetPrimaryTrack()->GetMomentumDirection();
320                                                << 321   // starting point of the shower:
321   // E,vect{p} and t,vec(x)                    << 322   G4ThreeVector PositionShower 
322   G4double Energy =                            << 323   = fastTrack.GetPrimaryTrack()->GetPosition();
323     fastTrack.GetPrimaryTrack()->GetKineticEne << 324   
324   // axis of the shower, in global reference f << 325   //G4double DEneSampling = Parametrisation->ApplySampling(Energy,Energy);
325   G4ThreeVector DirectionShower =              << 326   //if(DEneSampling <= 0.00) DEneSampling=Energy;  
326     fastTrack.GetPrimaryTrack()->GetMomentumDi << 327   
327   // starting point of the shower:             << 328   if(Energy > 0.0)
328   G4ThreeVector PositionShower =               << 329   {
329     fastTrack.GetPrimaryTrack()->GetPosition() << 330     G4double dist = Parametrisation->GenerateExponential(Energy);      
330                                                << 331     
331   //G4double DEneSampling = Parameterisation-> << 332     GFlashEnergySpot Spot;
332   //if(DEneSampling <= 0.00) DEneSampling=Ener << 333     Spot.SetEnergy( Energy );
333                                                << 334     G4ThreeVector SpotPosition = PositionShower + dist*DirectionShower;  
334   if(Energy > 0.0)                             << 335     Spot.SetPosition(SpotPosition);
335   {                                            << 336     
336     G4double dist = Parameterisation->Generate << 337     // Record the Spot:
337                                                << 338     feSpotList.push_back(Spot);
338     GFlashEnergySpot Spot;                     << 339     
339     Spot.SetEnergy( Energy );                  << 340     //Generate Hits of this spot      
340     G4ThreeVector SpotPosition = PositionShowe << 341     HMaker->make(Spot);
341     Spot.SetPosition(SpotPosition);            << 342   }
342                                                << 343   
343     // Record the Spot:                        << 
344     feSpotList.push_back(Spot);                << 
345                                                << 
346     //Generate Hits of this spot               << 
347     HMaker->make(Spot);                        << 
348   }                                            << 
349 }                                                 344 }
350                                                   345 
351 */                                                346 */
352                                                   347