00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include "G4Electron.hh"
00038 #include "G4Positron.hh"
00039 #include "G4NeutrinoE.hh"
00040 #include "G4NeutrinoMu.hh"
00041 #include "G4NeutrinoTau.hh"
00042 #include "G4AntiNeutrinoE.hh"
00043 #include "G4AntiNeutrinoMu.hh"
00044 #include "G4AntiNeutrinoTau.hh"
00045 #include "G4PionZero.hh"
00046 #include "G4VProcess.hh"
00047 #include "G4ios.hh"
00048 #include "G4LogicalVolume.hh"
00049 #include "geomdefs.hh"
00050
00051 #include "GFlashShowerModel.hh"
00052 #include "GFlashHomoShowerParameterisation.hh"
00053 #include "GFlashSamplingShowerParameterisation.hh"
00054 #include "GFlashEnergySpot.hh"
00055
00056
00057 GFlashShowerModel::GFlashShowerModel(G4String modelName,
00058 G4Envelope* envelope)
00059 : G4VFastSimulationModel(modelName, envelope),
00060 PBound(0), Parameterisation(0), HMaker(0)
00061 {
00062 FlagParamType = 0;
00063 FlagParticleContainment = 1;
00064 StepInX0 = 0.1;
00065 Messenger = new GFlashShowerModelMessenger(this);
00066 }
00067
00068 GFlashShowerModel::GFlashShowerModel(G4String modelName)
00069 : G4VFastSimulationModel(modelName),
00070 PBound(0), Parameterisation(0), HMaker(0)
00071 {
00072 FlagParamType =1;
00073 FlagParticleContainment = 1;
00074 StepInX0 = 0.1;
00075 Messenger = new GFlashShowerModelMessenger(this);
00076 }
00077
00078 GFlashShowerModel::~GFlashShowerModel()
00079 {
00080 delete Messenger;
00081 }
00082
00083 G4bool
00084 GFlashShowerModel::IsApplicable(const G4ParticleDefinition& particleType)
00085 {
00086 return
00087 &particleType == G4Electron::ElectronDefinition() ||
00088 &particleType == G4Positron::PositronDefinition();
00089 }
00090
00091
00092
00093
00094
00095 G4bool GFlashShowerModel::ModelTrigger(const G4FastTrack & fastTrack )
00096
00097 {
00098 G4bool select = false;
00099 if(FlagParamType != 0)
00100 {
00101 G4double ParticleEnergy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
00102 G4ParticleDefinition &ParticleType =
00103 *(fastTrack.GetPrimaryTrack()->GetDefinition());
00104 if(ParticleEnergy > PBound->GetMinEneToParametrise(ParticleType) &&
00105 ParticleEnergy < PBound->GetMaxEneToParametrise(ParticleType) )
00106 {
00107
00108
00109 Parameterisation->GenerateLongitudinalProfile(ParticleEnergy);
00110 select = CheckParticleDefAndContainment(fastTrack);
00111 if (select) EnergyStop= PBound->GetEneToKill(ParticleType);
00112 }
00113 }
00114
00115 return select;
00116 }
00117
00118
00119 G4bool
00120 GFlashShowerModel::CheckParticleDefAndContainment(const G4FastTrack& fastTrack)
00121 {
00122 G4bool filter=false;
00123 G4ParticleDefinition * ParticleType =
00124 fastTrack.GetPrimaryTrack()->GetDefinition();
00125
00126 if( ParticleType == G4Electron::ElectronDefinition() ||
00127 ParticleType == G4Positron::PositronDefinition() )
00128 {
00129 filter=true;
00130 if(FlagParticleContainment == 1)
00131 {
00132 filter=CheckContainment(fastTrack);
00133 }
00134 }
00135 return filter;
00136 }
00137
00138 G4bool GFlashShowerModel::CheckContainment(const G4FastTrack& fastTrack)
00139 {
00140 G4bool filter=false;
00141
00142 G4ThreeVector DirectionShower=fastTrack.GetPrimaryTrackLocalDirection();
00143 G4ThreeVector InitialPositionShower=fastTrack.GetPrimaryTrackLocalPosition();
00144
00145 G4ThreeVector OrthoShower, CrossShower;
00146
00147 OrthoShower = DirectionShower.orthogonal();
00148
00149 CrossShower = DirectionShower.cross(OrthoShower);
00150
00151 G4double R = Parameterisation->GetAveR90();
00152 G4double Z = Parameterisation->GetAveT90();
00153 G4int CosPhi[4] = {1,0,-1,0};
00154 G4int SinPhi[4] = {0,1,0,-1};
00155
00156 G4ThreeVector Position;
00157 G4int NlateralInside=0;
00158
00159 G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
00160 for(int i=0; i<4 ;i++)
00161 {
00162
00163 Position = InitialPositionShower +
00164 Z*DirectionShower +
00165 R*CosPhi[i]*OrthoShower +
00166 R*SinPhi[i]*CrossShower ;
00167
00168 if(SolidCalo->Inside(Position) != kOutside)
00169 NlateralInside++;
00170 }
00171
00172
00173 if(NlateralInside==4) filter=true;
00174
00175 return filter;
00176 }
00177
00178
00179 void
00180 GFlashShowerModel::DoIt(const G4FastTrack& fastTrack, G4FastStep& fastStep)
00181 {
00182
00183 if(fastTrack.GetPrimaryTrack()->GetDefinition()
00184 == G4Electron::ElectronDefinition() ||
00185 fastTrack.GetPrimaryTrack()->GetDefinition()
00186 == G4Positron::PositronDefinition() )
00187 ElectronDoIt(fastTrack,fastStep);
00188 }
00189
00190 void
00191 GFlashShowerModel::ElectronDoIt(const G4FastTrack& fastTrack,
00192 G4FastStep& fastStep)
00193 {
00194
00195
00196 fastStep.KillPrimaryTrack();
00197 fastStep.SetPrimaryTrackPathLength(0.0);
00198 fastStep.SetTotalEnergyDeposited(fastTrack.GetPrimaryTrack()->
00199 GetKineticEnergy());
00200
00201
00202
00203
00204
00205 G4double Energy = fastTrack.GetPrimaryTrack()->GetKineticEnergy();
00206
00207
00208 G4ThreeVector DirectionShower =
00209 fastTrack.GetPrimaryTrack()->GetMomentumDirection();
00210 G4ThreeVector OrthoShower, CrossShower;
00211 OrthoShower = DirectionShower.orthogonal();
00212 CrossShower = DirectionShower.cross(OrthoShower);
00213
00214
00216
00217 Parameterisation->GenerateLongitudinalProfile(Energy);
00218
00219
00221 G4VSolid *SolidCalo = fastTrack.GetEnvelopeSolid();
00222 G4ThreeVector pos = fastTrack.GetPrimaryTrackLocalPosition();
00223 G4ThreeVector dir = fastTrack.GetPrimaryTrackLocalDirection();
00224 G4double Bound = SolidCalo->DistanceToOut(pos,dir);
00225
00226 G4double Dz = 0.00;
00227 G4double ZEndStep = 0.00;
00228
00229 G4double EnergyNow = Energy;
00230 G4double EneIntegral = 0.00;
00231 G4double LastEneIntegral = 0.00;
00232 G4double DEne = 0.00;
00233
00234 G4double NspIntegral = 0.00;
00235 G4double LastNspIntegral = 0.00;
00236 G4double DNsp = 0.00;
00237
00238
00239 G4ThreeVector PositionShower = fastTrack.GetPrimaryTrack()->GetPosition();
00240 G4ThreeVector NewPositionShower = PositionShower;
00241 G4double StepLenght = 0.00;
00242
00243 G4int NSpotDeposited =0;
00244
00245
00247
00248
00249 do
00250 {
00251
00252 G4double stepLength = StepInX0*Parameterisation->GetX0();
00253 if(Bound < stepLength)
00254 {
00255 Dz = Bound;
00256 Bound = 0.00;
00257 }
00258 else
00259 {
00260 Dz = stepLength;
00261 Bound = Bound-Dz;
00262 }
00263 ZEndStep=ZEndStep+Dz;
00264
00265
00266 if(EnergyNow > EnergyStop)
00267 {
00268 LastEneIntegral = EneIntegral;
00269 EneIntegral = Parameterisation->IntegrateEneLongitudinal(ZEndStep);
00270 DEne = std::min( EnergyNow,
00271 (EneIntegral-LastEneIntegral)*Energy);
00272 LastNspIntegral = NspIntegral;
00273 NspIntegral = Parameterisation->IntegrateNspLongitudinal(ZEndStep);
00274 DNsp = std::max(1., std::floor( (NspIntegral-LastNspIntegral)
00275 *Parameterisation->GetNspot() ));
00276 }
00277
00278 else
00279 {
00280 DEne = EnergyNow;
00281 DNsp = std::max(1., std::floor( (1.- NspIntegral)
00282 *Parameterisation->GetNspot() ));
00283 }
00284 EnergyNow = EnergyNow - DEne;
00285
00286
00287
00288 GFlashSamplingShowerParameterisation* sp =
00289 dynamic_cast<GFlashSamplingShowerParameterisation*>(Parameterisation);
00290 if (sp)
00291 {
00292 G4double DEneSampling = sp->ApplySampling(DEne,Energy);
00293 DEne = DEneSampling;
00294 }
00295
00296
00297 StepLenght = StepLenght + Dz/2.00;
00298 NewPositionShower = NewPositionShower +
00299 StepLenght*DirectionShower;
00300 StepLenght = Dz/2.00;
00301
00302
00303 for (int i = 0; i < DNsp; i++)
00304 {
00305 NSpotDeposited++;
00306 GFlashEnergySpot Spot;
00307
00308
00309 Spot.SetEnergy( DEne / DNsp );
00310 G4double PhiSpot = Parameterisation->GeneratePhi();
00311 G4double RSpot = Parameterisation
00312 ->GenerateRadius(i,Energy,ZEndStep-Dz/2.);
00313
00314
00315
00316
00317 G4ThreeVector SpotPosition = NewPositionShower +
00318 Dz/DNsp*DirectionShower*(i+1/2.-DNsp/2.) +
00319 RSpot*std::cos(PhiSpot)*OrthoShower +
00320 RSpot*std::sin(PhiSpot)*CrossShower;
00321 Spot.SetPosition(SpotPosition);
00322
00323
00324 HMaker->make(&Spot, &fastTrack);
00325 }
00326 }
00327 while(EnergyNow > 0.0 && Bound> 0.0);
00328
00329
00331
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389