All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PhysicsList.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 /// \file PhysicsList.h
3 /// \brief Create the physics lists to be used by Geant4.
4 ///
5 /// \author seligman@nevis.columbia.edu
6 ////////////////////////////////////////////////////////////////////////
7 //
8 // Don't be too confused by the names. PhysicsList.h and
9 // PhysicsList.cxx define what the name "LArG4::PhysicList" means.
10 // However, that definition is mainly in terms of
11 // LArG4::ModularPhysicsList, a class that inherits from
12 // G4VModularPhysicsList.
13 
15 
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 
18 #include "Geant4/G4ParallelWorldScoringProcess.hh"
19 #include "Geant4/G4ParticleDefinition.hh"
20 #include "Geant4/G4ParticleTable.hh"
21 #include "Geant4/G4VModularPhysicsList.hh"
22 
23 #include "Geant4/G4ChargeExchange.hh"
24 #include "Geant4/G4ChargeExchangeProcess.hh"
25 #include "Geant4/G4ProcessManager.hh"
26 
27 ///#include "nug4/G4Base/G4PhysListFactorySingleton.hh"
28 ///PHYSLISTREG3(larg4, PhysicsList, larg4::PhysicsList)
29 #include "Geant4/G4PhysListStamper.hh"
31 
32 #define G4MT_physicsVector ((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)
33 
34 namespace larg4 {
35 
36  // This is the method we have to modify to use the Geant4 parallel geometries.
37  void
39  {
40  // We don't need to modify G4VModularPhysicsList's
41  // AddTransportation method. Just invoke it directly.
42  G4VModularPhysicsList::AddTransportation();
43 
44  ////////////////////////////////////////////////////////////////////////////////////////
45  // This is the "new" code that has to be added to
46  // G4VModularPhysicsList::ConstructProcess() to handle the
47  // parallel geometry.
48 
49  art::ServiceHandle<sim::LArG4Parameters const> lgp;
50  bool DisableWireplanes = lgp->DisableWireplanes();
51 
52  G4ParallelWorldScoringProcess* LArVoxelParallelWorldScoringProcess =
53  new G4ParallelWorldScoringProcess("LArVoxelReadoutScoringProcess");
54 
55  G4ParallelWorldScoringProcess* OpDetParallelWorldScoringProcess =
56  new G4ParallelWorldScoringProcess("OpDetReadoutScoringProcess");
57 
58  // Note that the name below MUST match the name used in the
59  // LArVoxelReadoutGeometry or OpDetReadoutGeometry constructor.
60  LArVoxelParallelWorldScoringProcess->SetParallelWorld("LArVoxelReadoutGeometry");
61  OpDetParallelWorldScoringProcess->SetParallelWorld("OpDetReadoutGeometry");
62 
63  // Tell all the particles in the physics list to recognize the
64  // LAr voxel parallel world. "theParticleIterator" is defined in
65  // G4VUserPhysicsList.hh. Only photons recognise the OpDet parallel
66  // world.
67  static G4ParticleTable* fParticleTable = G4ParticleTable::GetParticleTable();
68  G4ParticleTable::G4PTblDicIterator* theParticleIterator;
69  theParticleIterator = fParticleTable->GetIterator();
70  theParticleIterator->reset();
71  while ((*theParticleIterator)()) {
72  G4ParticleDefinition* particle = theParticleIterator->value();
73 
74  if (particle->GetParticleType() == "opticalphoton") {
75  G4ProcessManager* pmanager = particle->GetProcessManager();
76  pmanager->AddProcess(OpDetParallelWorldScoringProcess);
77  pmanager->SetProcessOrderingToLast(OpDetParallelWorldScoringProcess, idxAtRest);
78  pmanager->SetProcessOrdering(OpDetParallelWorldScoringProcess, idxAlongStep, 1);
79  pmanager->SetProcessOrderingToLast(OpDetParallelWorldScoringProcess, idxPostStep);
80  }
81 
82  // Only apply voxel processing in the LAr TPC if the particles are
83  // charged and they have a significant life-time.
84  else if (particle->GetPDGCharge() != 0 && !particle->IsShortLived()) {
85  G4ProcessManager* pmanager = particle->GetProcessManager();
86  if (!DisableWireplanes) {
87  pmanager->AddProcess(LArVoxelParallelWorldScoringProcess);
88  pmanager->SetProcessOrderingToLast(LArVoxelParallelWorldScoringProcess, idxAtRest);
89  pmanager->SetProcessOrdering(LArVoxelParallelWorldScoringProcess, idxAlongStep, 1);
90  pmanager->SetProcessOrderingToLast(LArVoxelParallelWorldScoringProcess, idxPostStep);
91  }
92 
93  // Do secondary biasing under control of K0Bias switch.
94  G4bool genSecondaries(false);
95  G4bool cE(false);
96  if (((particle->GetParticleName() == G4MuonPlus::MuonPlus()->GetParticleName() ||
97  particle->GetParticleName() == G4MuonMinus::MuonMinus()->GetParticleName()) &&
98  lgp->UseCustomPhysics()) ||
99  ((particle->GetParticleName() == G4Proton::Proton()->GetParticleName() ||
100  particle->GetParticleName() == G4Neutron::Neutron()->GetParticleName() ||
101  particle->GetParticleName() == G4KaonZeroShort::KaonZeroShort()->GetParticleName() ||
102  particle->GetParticleName() == G4KaonZeroLong::KaonZeroLong()->GetParticleName() ||
103  particle->GetParticleName() == G4Lambda::Lambda()->GetParticleName()) &&
104  lgp->UseCustomPhysics())) {
105  std::vector<std::string> EnabledPhysics = lgp->EnabledPhysics();
106  for (std::vector<std::string>::const_iterator it = EnabledPhysics.begin();
107  it != EnabledPhysics.end();
108  it++) {
109  std::string PhysicsName = (*it);
110  if (!PhysicsName.compare("SynchrotronAndGN") && lgp->K0Bias()) {
111  genSecondaries = true;
112  }
113  if (!PhysicsName.compare("ChargeExchange")) { cE = true; }
114  } // end loop over enabled physics
115  } // end if using custom physics
116 
117  if (genSecondaries) {
118  G4int nSecondaries(lgp->K0Bias());
119  G4int fXSBias(lgp->MNXSBias());
120  G4int xSBias(lgp->MNXBias());
121  mf::LogInfo("PhysicsList: ")
122  << "Turning on WrappedMuNuclear for " << particle->GetParticleName() << "s with "
123  << nSecondaries << " appropriately weighted secondaries."
124  << " XSBias is set to " << xSBias
125  << " and the cross-section is increased by a factor of " << fXSBias << ".";
126  G4MuonNuclearProcess* g4MNI = new G4MuonNuclearProcess();
127  MuNuclearSplittingProcessXSecBias* munuclSplitting =
129  G4bool active(true);
130 
131  munuclSplitting->SetNSplit(nSecondaries, xSBias, fXSBias);
132  munuclSplitting->SetIsActive(active);
133  munuclSplitting->RegisterProcess(g4MNI);
134  // Middle -1 with no biasing.
135  // The middle +1 enforces AlongStepDoIt active for MuNuclear, I claim.
136  if (xSBias && (fXSBias > 1))
137  pmanager->AddProcess(munuclSplitting, -1, 1, 1);
138  else
139  pmanager->AddProcess(munuclSplitting, -1, -1, 1);
140  } // end if generating secondaries
141 
142  if (cE) {
143  mf::LogInfo("PhysicsList: ")
144  << "Turning on ChargeExchange for " << particle->GetParticleName() << "s.";
145  G4ChargeExchange* model = new G4ChargeExchange();
146  G4ChargeExchangeProcess* p = new G4ChargeExchangeProcess();
147 
148  p->RegisterMe(model);
149  pmanager->AddDiscreteProcess(p);
150 
151  } // end if doing charge exchange
152  } // end if short lived particle
153  } // end loop over particles
154 
155  // End of code "added" to G4VModularPhysicsList::ConstructProcess()
156  ////////////////////////////////////////////////////////////////////////////////////////
157 
158  // This code is also unchanged from
159  // G4VModularPhysicsList::ConstructProcess(); it means "activate
160  // the physics processes and particle combinations we've specified
161  // in physicsVector." The physicsVector is built up by the
162  // pre-supplied Geant4 physics list; see PhysicsList.h for the
163  // name of that list. "physicsVector" is defined in
164  // G4VModularPhysicsList.hh.
165  G4PhysConstVector::iterator itr;
166  for (itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end(); ++itr) {
167  (*itr)->ConstructProcess();
168  }
169  } // end ConstructProcess
170 
171 } // namespace LArG4
Create the physics lists to be used by Geant4.
void SetNSplit(G4int nTrx, G4int xB=0, G4double xFac=1)
pdgs p
Definition: selectors.fcl:22
#define G4MT_physicsVector
Definition: PhysicsList.cxx:32
TConfigurablePhysicsList< ModularPhysicsList > PhysicsList
Definition: PhysicsList.h:89
G4_DECLARE_PHYSLIST_FACTORY_NS(larg4::PhysicsList, larg4, PhysicsList)
virtual void ConstructProcess()
Definition: PhysicsList.cxx:38
process_name largeant stream1 can override from command line with o or output physics producers generator physics producers generator services LArG4Parameters EnabledPhysics