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 10.6.p1)


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