CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DummyChargeFlipProcess.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include "G4ParticleTable.hh"
3 #include "Randomize.hh"
4 
6 
8 DummyChargeFlipProcess(const G4String& processName) :
9  G4HadronicProcess(processName)
10 {
11  AddDataSet(new G4HadronElasticDataSet);
12 }
13 
15 {
16 }
17 
18 
20 BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
21 {
22  if (!G4HadronicProcess::GetCrossSectionDataStore()) {
23  return;
24  }
25  G4HadronicProcess::GetCrossSectionDataStore()->BuildPhysicsTable(aParticleType);
26 }
27 
28 
31  const G4DynamicParticle* /*aParticle*/, const G4Element* element, G4double /*aTemp*/)
32 {
33 
34  return 30*millibarn*element->GetN();
35 }
36 
37 
38 G4bool
40 IsApplicable(const G4ParticleDefinition& aParticleType)
41 {
42  if(aParticleType.GetParticleType() == "rhadron")
43  return true;
44  else
45  return false;
46 }
47 
48 
49 void
51 DumpPhysicsTable(const G4ParticleDefinition& /*aParticleType*/)
52 {
53 
54 }
55 
56 
58  const G4Track &aTrack, const G4Step &/*aStep*/)
59 {
60  G4ParticleChange * pc = new G4ParticleChange();
61  pc->Initialize(aTrack);
62  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
63  G4ParticleDefinition* aParticleDef = aParticle->GetDefinition();
64 
65  G4double ParentEnergy = aParticle->GetTotalEnergy();
66  G4ThreeVector ParentDirection(aParticle->GetMomentumDirection());
67 
68  G4double energyDeposit = 0.0;
69  G4double finalGlobalTime = aTrack.GetGlobalTime();
70 
71  G4int numberOfSecondaries = 1;
72  pc->SetNumberOfSecondaries(numberOfSecondaries);
73  const G4TouchableHandle thand = aTrack.GetTouchableHandle();
74 
75  // get current position of the track
76  aTrack.GetPosition();
77  // create a new track object
78  G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
79  float randomParticle = G4UniformRand();
80  G4ParticleDefinition * newType = aParticleDef;
81  if(randomParticle < 0.333)
82  newType=particleTable->FindParticle(1009213);
83  else if(randomParticle > 0.667)
84  newType=particleTable->FindParticle(-1009213);
85  else
86  newType=particleTable->FindParticle(1009113);
87 
88  std::cout << "RHADRON: New charge = " << newType->GetPDGCharge() << std::endl;
89 
90  G4DynamicParticle * newP = new G4DynamicParticle(newType,ParentDirection,ParentEnergy);
91  G4Track* secondary = new G4Track( newP ,
92  finalGlobalTime ,
93  aTrack.GetPosition()
94  );
95  // switch on good for tracking flag
96  secondary->SetGoodForTrackingFlag();
97  secondary->SetTouchableHandle(thand);
98  // add the secondary track in the List
99  pc->AddSecondary(secondary);
100 
101  // Kill the parent particle
102  pc->ProposeTrackStatus( fStopAndKill ) ;
103  pc->ProposeLocalEnergyDeposit(energyDeposit);
104  pc->ProposeGlobalTime( finalGlobalTime );
105  // Clear NumberOfInteractionLengthLeft
106  ClearNumberOfInteractionLengthLeft();
107 
108 
109 
110  return pc;
111 
112 }
113 
void DumpPhysicsTable(const G4ParticleDefinition &aParticleType)
G4double GetMicroscopicCrossSection(const G4DynamicParticle *aParticle, const G4Element *anElement, G4double aTemp)
DummyChargeFlipProcess(const G4String &processName="Dummy")
void BuildPhysicsTable(const G4ParticleDefinition &aParticleType)
tuple cout
Definition: gather_cfg.py:121
G4bool IsApplicable(const G4ParticleDefinition &aParticleType)
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)