BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSIMLink.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSIMLink.hh"
20
21#include <csignal>
22#include <cstdlib> // standard headers
23#include <cstdio>
24
25#include "G4EventManager.hh" // Geant4 includes
26#include "G4GeometryManager.hh"
27#include "G4GeometryTolerance.hh"
28#include "G4Version.hh"
29#include "G4VModularPhysicsList.hh"
30
31#include "BDSAcceleratorModel.hh"
32#include "BDSAperturePointsLoader.hh"
33#include "BDSBeamPipeFactory.hh"
34#include "BDSBunch.hh"
35#include "BDSBunchFactory.hh"
36#include "BDSLinkBunch.hh"
37#include "BDSBunchSixTrackLink.hh"
38#include "BDSCavityFactory.hh"
39#include "BDSColours.hh"
40#include "BDSComponentFactoryUser.hh"
41#include "BDSDebug.hh"
42#include "BDSException.hh"
43#include "BDSExecOptions.hh"
44#include "BDSFieldFactory.hh"
45#include "BDSFieldLoader.hh"
46#include "BDSGeometryFactory.hh"
47#include "BDSGeometryFactorySQL.hh"
48#include "BDSGeometryWriter.hh"
49#include "BDSGlobalConstants.hh"
50#include "BDSLinkComponent.hh"
51#include "BDSLinkDetectorConstruction.hh"
52#include "BDSLinkEventAction.hh"
53#include "BDSLinkPrimaryGeneratorAction.hh"
54#include "BDSLinkRunAction.hh"
55#include "BDSLinkRunManager.hh"
56#include "BDSLinkStackingAction.hh"
57#include "BDSLinkTrackingAction.hh"
58#include "BDSMaterials.hh"
59#include "BDSOutput.hh"
60#include "BDSOutputFactory.hh"
61#include "BDSParallelWorldUtilities.hh"
62#include "BDSParser.hh"
63#include "BDSParticleExternal.hh"
64#include "BDSParticleDefinition.hh"
65#include "BDSPhysicsUtilities.hh"
66#include "BDSRandom.hh"
67#include "BDSSamplerRegistry.hh"
68#include "BDSSDManager.hh"
69#include "BDSTemporaryFiles.hh"
70#include "BDSUtilities.hh"
71#include "BDSVisManager.hh"
72
73#include <map>
74#include <set>
75
76
78 ignoreSIGINT(false),
79 usualPrintOut(true),
80 initialised(false),
81 initialisationResult(1),
82 argcCache(0),
83 argvCache(nullptr),
84 parser(nullptr),
85 bdsOutput(nullptr),
86 bdsBunch(bunchIn),
87 internalBdsBunch(false),
88 runManager(nullptr),
89 construction(nullptr),
90 runAction(nullptr),
91 currentElementIndex(0),
92 userPhysicsList(nullptr)
93{
94 if(!bdsBunch) {
95 bdsBunch = new BDSLinkBunch();
96 internalBdsBunch = true;
97 }
98}
99
100BDSIMLink::BDSIMLink(int argc, char** argv, bool usualPrintOutIn):
101 ignoreSIGINT(false),
102 usualPrintOut(usualPrintOutIn),
103 initialised(false),
104 initialisationResult(1),
105 argcCache(argc),
106 argvCache(argv),
107 parser(nullptr),
108 bdsOutput(nullptr),
109 bdsBunch(nullptr),
110 runManager(nullptr),
111 construction(nullptr),
112 runAction(nullptr),
113 currentElementIndex(0),
114 userPhysicsList(nullptr)
115{
117}
118
120 char** argv,
121 bool usualPrintOutIn,
122 double minimumKineticEnergy,
123 bool protonsAndIonsOnly)
124{
125 argcCache = argc;
126 argvCache = new char*[argc + 1]; // +1 for null termination (optional)
127 for (int i = 0; i < argc; ++i) {
128 size_t len = std::strlen(argv[i]) + 1; // +1 for null terminator
129 argvCache[i] = new char[len];
130 std::strcpy(argvCache[i], argv[i]); // deep copy the string
131 }
132 argvCache[argc] = nullptr; // optional: null-terminate array like execv expects
133
134 usualPrintOut = usualPrintOutIn;
135 initialisationResult = Initialise(minimumKineticEnergy, protonsAndIonsOnly);
137}
138
139int BDSIMLink::Initialise(double minimumKineticEnergy,
140 bool protonsAndIonsOnly)
141{
142 minimumKineticEnergy *= CLHEP::GeV; // units
143 G4bool trackerDebug = false;
144
146 const BDSExecOptions* execOptions = new BDSExecOptions(argcCache,argvCache);
147 if (usualPrintOut)
148 {execOptions->Print();}
149 ignoreSIGINT = execOptions->IgnoreSIGINT(); // different sig catching for cmake
150 execOptions->PrintCopyright();
151#ifdef BDSDEBUG
152 G4cout << __METHOD_NAME__ << "DEBUG mode is on." << G4endl;
153#endif
154
156 parser = BDSParser::Instance(execOptions->InputFileName());
158 parser->AmalgamateOptions(execOptions->Options());
159 parser->AmalgamateBeam(execOptions->Beam(), execOptions->Options().recreate);
162
165
167 delete execOptions;
168
173
175 BDSRandom::CreateRandomNumberGenerator(globalConstants->RandomEngine());
176 BDSRandom::SetSeed(); // set the seed from options
177
179 bdsOutput = BDSOutputFactory::CreateOutput(globalConstants->OutputFormat(),
180 globalConstants->OutputFileName());
181
184 {
185 G4cerr << "No Geant4 environmental variables found - please source geant4.sh environment" << G4endl;
186 G4cout << "A common fault is the wrong Geant4 environment as compared to the one BDSIM was compiled with." << G4endl;
187 return 1;
188 }
189
193
196
198 auto parallelWorldsRequiringPhysics = BDS::ConstructAndRegisterParallelWorlds(construction, true, false);
199
200 runManager->SetUserInitialization(construction);
201
202 // Set filters used in sensitive detectors that transfer particles back
203 BDSSDManager::Instance()->SetLinkMinimumEK(minimumKineticEnergy);
204 BDSSDManager::Instance()->SetLinkProtonsAndIonsOnly(protonsAndIonsOnly);
205
206#ifdef BDSDEBUG
207 G4cout << __METHOD_NAME__ << "> Constructing physics processes" << G4endl;
208#endif
209 G4String physicsListName = parser->GetOptions().physicsList;
210
211#if G4VERSION_NUMBER > 1049
212 // from 10.5 onwards they have a looping particle killer that warnings and kills particles
213 // deemed to be looping that are <100 MeV. This is unrelated to the primary energy so troublesome.
214 // set to the 'low' limits here ~10keV. This must be done before any physics is created as the
215 // parameters are copied into the transportation physics process for each particle and it's very
216 // hard to sift through and fix afterwards
217 G4PhysicsListHelper::GetPhysicsListHelper()->UseLowLooperThresholds();
218#endif
219 auto parallelWorldPhysics = BDS::ConstructParallelWorldPhysics(parallelWorldsRequiringPhysics);
220 G4int physicsVerbosity = BDSGlobalConstants::Instance()->PhysicsVerbosity();
221 G4VModularPhysicsList* physList;
222 if (userPhysicsList)
223 {
224 G4cout << "Using externally registered user defined physics list" << G4endl;
225 physList = userPhysicsList;
226 }
227 else
228 {physList = BDS::BuildPhysics(physicsListName, physicsVerbosity);}
229
230 BDS::RegisterSamplerPhysics(parallelWorldPhysics, physList);
231 // Construction of the physics lists defines the necessary particles and therefore
232 // we can calculate the beam rigidity for the particle the beam is designed w.r.t. This
233 // must happen before the geometry is constructed (which is called by
234 // runManager->Initialize()).
235 BDSParticleDefinition* designParticle = nullptr;
236 BDSParticleDefinition* beamParticle = nullptr;
237 G4bool beamDifferentFromDesignParticle = false;
239 globalConstants->FFact(),
240 designParticle,
241 beamParticle,
242 beamDifferentFromDesignParticle);
243 if (usualPrintOut)
244 {
245 G4cout << "Design particle properties: " << G4endl << *designParticle;
246 if (beamDifferentFromDesignParticle)
247 {G4cout << "Beam particle properties: " << G4endl << *beamParticle;}
248 }
249 // update rigidity where needed
250 construction->SetDesignParticle(designParticle);
251 //BDSFieldFactory::SetDesignParticle(designParticle);
252
253 //auto biasPhysics = BDS::BuildAndAttachBiasWrapper(parser->GetBiasing());
254 //if (biasPhysics)//could be nullptr and can't be passed to geant4 like this
255 // {physList->RegisterPhysics(biasPhysics);}
256 runManager->SetUserInitialization(physList);
257
259 GMAD::Beam b;
260 b.distrType = "sixtracklink";
261 if (!bdsBunch)
262 {
264 parser->GetBeam(),
265 globalConstants->BeamlineTransform(),
266 globalConstants->BeamlineS(),
267 globalConstants->GeneratePrimariesOnly());
268 }
269 else
270 {
271 bdsBunch->SetOptions(beamParticle, b, BDSBunchType::reference); // update particle definition only
272 }
275 delete beamParticle;
276
278 G4GeometryTolerance* theGeometryTolerance = G4GeometryTolerance::GetInstance();
279 if (usualPrintOut)
280 {
281 G4cout << __METHOD_NAME__ << "Geometry Tolerances: " << G4endl;
282 G4cout << __METHOD_NAME__ << std::setw(12) << "Surface: " << std::setw(7) << theGeometryTolerance->GetSurfaceTolerance() << " mm" << G4endl;
283 G4cout << __METHOD_NAME__ << std::setw(12) << "Angular: " << std::setw(7) << theGeometryTolerance->GetAngularTolerance() << " rad" << G4endl;
284 G4cout << __METHOD_NAME__ << std::setw(12) << "Radial: " << std::setw(7) << theGeometryTolerance->GetRadialTolerance() << " mm" << G4endl;
285 }
288 BDSLinkEventAction* eventAction = new BDSLinkEventAction(bdsOutput, runAction, trackerDebug);
289 runManager->SetUserAction(eventAction);
290 runManager->SetUserAction(runAction);
291 G4int verboseSteppingEventStart = globalConstants->VerboseSteppingEventStart();
292 G4int verboseSteppingEventStop = BDS::VerboseEventStop(verboseSteppingEventStart,
293 globalConstants->VerboseSteppingEventContinueFor());
294 runManager->SetUserAction(new BDSLinkTrackingAction(globalConstants->Batch(),
295 eventAction,
296 verboseSteppingEventStart,
297 verboseSteppingEventStop,
298 globalConstants->VerboseSteppingPrimaryOnly(),
299 globalConstants->VerboseSteppingLevel()));
300 runManager->SetUserAction(new BDSLinkStackingAction(globalConstants, std::set<G4int>(), protonsAndIonsOnly, minimumKineticEnergy));
301
302 /*
303 // Only add steppingaction if it is actually used, so do check here (for performance reasons)
304 G4int verboseSteppingEventStart = globalConstants->VerboseSteppingEventStart();
305 G4int verboseSteppingEventStop = BDS::VerboseEventStop(verboseSteppingEventStart,
306 globalConstants->VerboseSteppingEventContinueFor());
307 if (globalConstants->VerboseSteppingBDSIM())
308 {
309 runManager->SetUserAction(new BDSSteppingAction(true,
310 verboseSteppingEventStart,
311 verboseSteppingEventStop));
312 }
313 */
314
315 auto primaryGeneratorAction = new BDSLinkPrimaryGeneratorAction(bdsBunch, &currentElementIndex, construction, trackerDebug);
316 construction->SetPrimaryGeneratorAction(primaryGeneratorAction);
317 runManager->SetUserAction(primaryGeneratorAction);
318 //BDSFieldFactory::SetPrimaryGeneratorAction(primaryGeneratorAction);
319
321 runManager->Initialize();
322
324 construction->BuildPhysicsBias();
325
326 if (usualPrintOut && BDSGlobalConstants::Instance()->PhysicsVerbose())
327 {
330 }
331
335 runManager->SetVerboseLevel(std::min(globalConstants->VerboseRunLevel(), globalConstants->PhysicsVerbosity()));
336 G4EventManager::GetEventManager()->SetVerboseLevel(globalConstants->VerboseEventLevel());
337 G4EventManager::GetEventManager()->GetTrackingManager()->SetVerboseLevel(globalConstants->VerboseTrackingLevel());
338
340 G4bool bCloseGeometry = G4GeometryManager::GetInstance()->CloseGeometry();
341 if (!bCloseGeometry)
342 {
343 G4cerr << __METHOD_NAME__ << "error - geometry not closed." << G4endl;
344 return 1;
345 }
346
347 if (globalConstants->ExportGeometry())
348 {
349 BDSGeometryWriter geometrywriter;
350 geometrywriter.ExportGeometry(globalConstants->ExportType(),
351 globalConstants->ExportFileName());
352 }
353
354 const auto& nameInds = construction->NameToElementIndex();
355 nameToElementIndex.insert(nameInds.begin(), nameInds.end());
356
357 if (bdsOutput)
358 {
361 }
362
363 initialised = true;
364 return 0;
365}
366
367void BDSIMLink::BeamOn(int nGenerate)
368{
370 {return;} // a mode where we don't do anything
371
372 G4cout.precision(10);
374 struct sigaction act;
375 act.sa_handler = &BDS::HandleAborts;
376 sigemptyset(&act.sa_mask);
377 act.sa_flags = 0;
378 if (!ignoreSIGINT)
379 {sigaction(SIGINT, &act, nullptr);}
380 sigaction(SIGABRT, &act, nullptr);
381 sigaction(SIGTERM, &act, nullptr);
382 sigaction(SIGSEGV, &act, nullptr);
383
385 try
386 {
387 if (!BDSGlobalConstants::Instance()->Batch()) // Interactive mode
388 {
389 BDSVisManager visManager = BDSVisManager(BDSGlobalConstants::Instance()->VisMacroFileName(),
390 BDSGlobalConstants::Instance()->Geant4MacroFileName());
391 visManager.StartSession(argcCache, argvCache);
392 }
393 else
394 {// batch mode
395 if (nGenerate < 0)
396 {runManager->BeamOn(BDSGlobalConstants::Instance()->NGenerate());}
397 else
398 {runManager->BeamOn(nGenerate);}
399 }
400 }
401 catch (const BDSException& exception)
402 {
403 // don't do this for now in case it's dangerous and we try tracking with open geometry
404 //G4GeometryManager::GetInstance()->OpenGeometry();
405 G4cout << exception.what() << G4endl;
406 exit(1);
407 }
408}
409
411{
413 G4GeometryManager::GetInstance()->OpenGeometry();
414
415#ifdef BDSDEBUG
416 G4cout << __METHOD_NAME__ << "deleting..." << G4endl;
417#endif
418 if (bdsOutput)
419 {bdsOutput->CloseFile();}
420 delete bdsOutput;
421
422 try
423 {
424 // order important here because of singletons relying on each other
428 delete BDSAcceleratorModel::Instance();
430 delete BDSFieldFactory::Instance(); // this uses BDSGlobalConstants which uses BDSMaterials
432 delete BDSMaterials::Instance();
433
434 // instances not used in this file, but no other good location for deletion
435 if (initialisationResult < 2)
436 {
437 delete BDSColours::Instance();
439 //delete BDSSDManager::Instance();
442 }
443 }
444 catch (...)
445 {;} // ignore any exception as this is a destructor
446
447 delete runManager;
448 delete parser;
449
450 if (argvCache) {
451 for (int i = 0; i < argcCache; ++i) {
452 delete[] argvCache[i];
453 }
454 delete[] argvCache;
455 }
456
457 if (usualPrintOut)
458 {G4cout << __METHOD_NAME__ << "End of Run. Thank you for using BDSIM!" << G4endl;}
459}
460
461int BDSIMLink::GetLinkIndex(const std::string& elementName) const
462{
463 int result = -1;
464 auto search = nameToElementIndex.find(elementName);
465 if (search != nameToElementIndex.end())
466 {result = search->second;}
467 return result;
468}
469
470const BDSLinkComponent* BDSIMLink::GetLinkComponent(int linkID) const
471{
472 const BDSBeamline* bl = construction->LinkBeamline();
473 if (!bl)
474 {return nullptr;}
475 if (linkID > (int)bl->size())
476 {return nullptr;}
477 const auto rawAccComponent = bl->at(linkID)->GetAcceleratorComponent();
478 const auto linkComponent = dynamic_cast<const BDSLinkComponent*>(rawAccComponent);
479 return linkComponent;
480}
481
482double BDSIMLink::GetChordLengthOfLinkElement(int beamlineIndex) const
483{
484 const BDSLinkComponent* component = GetLinkComponent(beamlineIndex);
485 if (!component)
486 {return -1.0;} // play it safe
487 return component->ComponentChordLength();
488}
489
490double BDSIMLink::GetChordLengthOfLinkElement(const std::string& elementName)
491{
492 int linkID = GetLinkIndex(elementName);
493 int beamlineIndex = linkIDToBeamlineIndex[linkID];
494 return GetChordLengthOfLinkElement(beamlineIndex);
495}
496
497double BDSIMLink::GetArcLengthOfLinkElement(int beamlineIndex) const
498{
499 const BDSLinkComponent* component = GetLinkComponent(beamlineIndex);
500 if (!component)
501 {return -1.0;} // play it safe
502 return component->ComponentArcLength();
503}
504
505double BDSIMLink::GetArcLengthOfLinkElement(const std::string& elementName)
506{
507 int linkID = GetLinkIndex(elementName);
508 int beamlineIndex = linkIDToBeamlineIndex[linkID];
509 return GetArcLengthOfLinkElement(beamlineIndex);
510}
511
512BDSBunch* BDSIMLink::GetBunch() const
513{
514 return bdsBunch;
515}
516
517void BDSIMLink::SelectLinkElement(const std::string& elementName, G4bool debug)
518{
519 if (debug)
520 {G4cout << "Searching for " << elementName;}
521 currentElementIndex = GetLinkIndex(elementName);
522 if (debug)
523 {G4cout << ", Index " << currentElementIndex << G4endl;}
524}
525
526void BDSIMLink::SelectLinkElement(int index, G4bool debug)
527{
528 if (debug)
529 {G4cout << "Searching for " << index << G4endl;}
530 currentElementIndex = index;
531}
532
533int BDSIMLink::AddLinkCollimatorJaw(const std::string& collimatorName,
534 const std::string& materialName,
535 double length,
536 double halfApertureLeft,
537 double halfApertureRight,
538 double rotation,
539 double xOffset,
540 double yOffset,
541 double jawTiltLeft,
542 double jawTiltRight,
543 bool buildLeftJaw,
544 bool buildRightJaw,
545 bool isACrystal,
546 double crystalAngle,
547 bool sampleIn)
548{
549 G4GeometryManager* gm = G4GeometryManager::GetInstance();
550 if (gm->IsGeometryClosed())
551 {gm->OpenGeometry();}
552
553 G4int linkID = construction->AddLinkCollimatorJaw(
554 collimatorName,
555 materialName,
556 length,
557 halfApertureLeft,
558 halfApertureRight,
559 rotation,
560 xOffset,
561 yOffset,
562 jawTiltLeft,
563 jawTiltRight,
564 buildLeftJaw,
565 buildRightJaw,
566 isACrystal,
567 crystalAngle,
568 sampleIn);
569 // update this class's nameToElementIndex map
570 nameToElementIndex = construction->NameToElementIndex();
571 linkIDToBeamlineIndex = construction->LinkIDToBeamlineIndex();
572
573 if (bdsOutput)
575
577 G4bool bCloseGeometry = gm->CloseGeometry();
578 if (!bCloseGeometry)
579 {throw BDSException(__METHOD_NAME__, "error - geometry not closed.");}
580 return (int)linkID;
581}
582
583int BDSIMLink::AddLinkCollimatorTipJaw(const std::string& collimatorName,
584 const std::string& materialName,
585 const std::string& tipMaterialName,
586 double tipThickness,
587 double length,
588 double halfApertureLeft,
589 double halfApertureRight,
590 double rotation,
591 double xOffset,
592 double yOffset,
593 double jawTiltLeft,
594 double jawTiltRight,
595 bool buildLeftJaw,
596 bool buildRightJaw)
597{
598 G4GeometryManager* gm = G4GeometryManager::GetInstance();
599 if (gm->IsGeometryClosed())
600 {gm->OpenGeometry();}
601
602 G4int linkID = construction->AddLinkCollimatorTipJaw(collimatorName,
603 materialName,
604 tipMaterialName,
605 tipThickness,
606 length,
607 halfApertureLeft,
608 halfApertureRight,
609 rotation,
610 xOffset,
611 yOffset,
612 jawTiltLeft,
613 jawTiltRight,
614 buildLeftJaw,
615 buildRightJaw);
616 // update this class's nameToElementIndex map
617 nameToElementIndex = construction->NameToElementIndex();
618 linkIDToBeamlineIndex = construction->LinkIDToBeamlineIndex();
619
620 if (bdsOutput)
622
624 G4bool bCloseGeometry = gm->CloseGeometry();
625 if (!bCloseGeometry)
626 {throw BDSException(__METHOD_NAME__, "error - geometry not closed.");}
627 return (int)linkID;
628}
629
630
632 G4GeometryManager* gm = G4GeometryManager::GetInstance();
633 if (gm->IsGeometryClosed())
634 {gm->OpenGeometry();}
635
636 G4int linkID = construction->AddLinkElement(el);
637 // update this class's nameToElementIndex map
638 nameToElementIndex = construction->NameToElementIndex();
639 linkIDToBeamlineIndex = construction->LinkIDToBeamlineIndex();
640
641 if (bdsOutput)
643
645 G4bool bCloseGeometry = gm->CloseGeometry();
646 if (!bCloseGeometry)
647 {throw BDSException(__METHOD_NAME__, "error - geometry not closed.");}
648 return (int)linkID;
649}
650
651
652BDSHitsCollectionSamplerLink* BDSIMLink::SamplerHits() const
653{
654 return runAction ? runAction->SamplerHits() : nullptr;
655}
656
657int BDSIMLink::GetCurrentMaximumSixTrackParticleID() const
658{
659 return runAction ? runAction->MaximumExternalParticleID() : 0;
660}
661
662void BDSIMLink::SetCurrentMaximumExternalParticleID(int currentMaximumExternalParticleID)
663{
664 if (runAction)
665 {runAction->SetMaximumExternalParticleID(currentMaximumExternalParticleID);}
666}
static BDSAperturePointsCache * Instance()
Access the singleton instance.
void ClearCachedFiles()
Delete all cached points from memory and clear the map of files loaded.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
BDSAcceleratorComponent * GetAcceleratorComponent() const
Accessor.
A vector of BDSBeamlineElement instances - a beamline.
const BDSBeamlineElement * at(int iElement) const
Return a reference to the element at i.
BeamlineVector::size_type size() const
Get the number of elements.
static BDSBunch * CreateBunch(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const G4Transform3D &beamlineTransform=G4Transform3D::Identity, G4double beamlineS=0, G4bool generatePrimariesOnlyIn=false)
factory method
The base class for bunch distribution generators.
Definition BDSBunch.hh:47
virtual const BDSParticleDefinition * ParticleDefinition() const
Access the beam particle definition.
Definition BDSBunch.hh:96
virtual void SetOptions(const BDSParticleDefinition *beamParticle, const GMAD::Beam &beam, const BDSBunchType &distrType, G4Transform3D beamlineTransformIn=G4Transform3D::Identity, const G4double beamlineS=0)
Definition BDSBunch.cc:82
static BDSCavityFactory * Instance()
Singleton accessor.
static BDSColours * Instance()
singleton pattern
Definition BDSColours.cc:33
General exception with possible name of object and message.
const char * what() const noexcept override
Override message in std::exception.
Executable option processing for BDSIM.
const GMAD::Options & Options() const
Accessor for options generated by command line parsing.
void Print() const
Print out the commands and their set values.
G4bool IgnoreSIGINT() const
Accessor.
const GMAD::Beam & Beam() const
Accessor for beam options generate by command line parsing.
void PrintCopyright() const
Print out the copyright information (no exit).
G4String InputFileName() const
Acessor for convenience for the one thing that's needed before the parser options.
static BDSFieldFactory * Instance()
Public accessor method for singleton pattern.
static BDSFieldLoader * Instance()
Singleton accessor.
static BDSGeometryFactory * Instance()
Singleton accessor.
A class for writing fully constructed geometry from BDSIM out to other formats.
void ExportGeometry(const G4String &geometryType, const G4String &geometryFileName)
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
A bunch distribution that holds a bunch from a Link.
A BDSAcceleratorComponent wrapper for BDSLinkOpaqueBox.
G4double ComponentChordLength() const
Accessor.
G4double ComponentArcLength() const
Accessor.
Construction of the geometry in the case of a link model.
G4int AddLinkCollimatorTipJaw(const std::string &collimatorName, const std::string &materialName, const std::string &tipMaterialName, G4double tipThickness, G4double length, G4double halfApertureLeft, G4double halfApertureRight, G4double rotation, G4double xOffset, G4double yOffset, G4double jawTiltLeft=0.0, G4double jawTiltRight=0.0, G4bool buildLeftJaw=true, G4bool buildRightJaw=true)
Interface to append a tip collimator jaw to the linking.
G4int AddLinkCollimatorJaw(const std::string &collimatorName, const std::string &materialName, G4double length, G4double halfApertureLeft, G4double halfApertureRight, G4double rotation, G4double xOffset, G4double yOffset, G4double jawTiltLeft=0.0, G4double jawTiltRight=0.0, G4bool buildLeftJaw=true, G4bool buildRightJaw=true, G4bool isACrystal=false, G4double crystalAngle=0, G4bool sampleIn=false)
Interface to append a collimator of jaw style to the linking.
G4int AddLinkElement(GMAD::Element el)
Interface to append an element.
void SetDesignParticle(const BDSParticleDefinition *defIn)
Set the design particle definition.
Process information at the event level for Link to trackers.
Generates primary particle vertices using BDSBunch.
Simplified run action to hold link hits.
Wrapper from G4RunManager that provides our exception handler.
BDSIM's Geant4 stacking action.
Action to decide whether or not to store trajectory information.
static BDSMaterials * Instance()
Singleton pattern access.
void PrepareRequiredMaterials(G4bool verbose=false)
converts parser material list
static BDSOutput * CreateOutput(BDSOutputType format, const G4String &fileName, G4int fileNumberOffset=-1, G4int compressionLevel=-1)
factory method
virtual void NewFile()=0
Open a new file. This should call WriteHeader() in it.
virtual void InitialiseGeometryDependent()
Definition BDSOutput.cc:171
virtual void UpdateSamplers()
Interface to allow updating samplers with dynamic construction. Only for link - not for regular use.
Definition BDSOutput.hh:96
virtual void CloseFile()=0
void AmalgamateBeam(const GMAD::Beam &beamIn, bool recreate)
Amalgamate the input beam definition with the ones stored in teh parser.
Definition BDSParser.cc:75
void CheckOptions()
Check options for consistency. This also checks the beam options.
Definition BDSParser.cc:94
static BDSParser * Instance()
Access method.
Definition BDSParser.cc:30
const GMAD::Beam & GetBeam() const
Return beam.
Definition BDSParser.hh:57
const GMAD::Options & GetOptions() const
Return options.
Definition BDSParser.hh:51
void AmalgamateOptions(const GMAD::Options &optionsIn)
Amalgamate the input options with the ones stored in the parser.
Definition BDSParser.cc:86
Wrapper for particle definition.
G4String Name() const
Accessor.
static BDSSamplerRegistry * Instance()
Accessor for registry.
static BDSTemporaryFiles * Instance()
Singleton accessor.
The BDS Visualisation Manager.
void StartSession(int argc, char **argv)
Start interactive mode.
std::string distrType
beam parameters
Definition beamBase.h:45
Beam class.
Definition beam.h:44
std::string physicsList
list of physics processes
bool verbose
General verbosity.
Definition optionsBase.h:65
bool recreate
Whether to recreate from a file or not.
Definition optionsBase.h:95
std::vector< G4ParallelWorldPhysics * > ConstructParallelWorldPhysics(const std::vector< G4VUserParallelWorld * > &worlds)
Construct the parallel physics process for each sampler world.
void PrintDefinedParticles()
void RegisterSamplerPhysics(const std::vector< G4ParallelWorldPhysics * > &processes, G4VModularPhysicsList *physicsList)
Register each parallel physics process to the main physics list.
std::vector< G4VUserParallelWorld * > ConstructAndRegisterParallelWorlds(G4VUserDetectorConstruction *massWorld, G4bool buildSamplerWorld, G4bool buildPlacementFieldsWorld)
void PrintPrimaryParticleProcesses(const G4String &primaryParticleName)
G4bool Geant4EnvironmentIsSet()
Check if the geant4 environmental variables necessary for a run are set.
void HandleAborts(int signal_number)
void ConstructDesignAndBeamParticle(const GMAD::Beam &beamDefinition, G4double ffact, BDSParticleDefinition *&designParticle, BDSParticleDefinition *&beamParticle, G4bool &beamDifferentFromDesignParticle)
G4int VerboseEventStop(G4int verboseEventStart, G4int verboseEventContinueFor)
G4VModularPhysicsList * BuildPhysics(const G4String &physicsList, G4int verbosity=1)
Element class.
Definition element.h:45