VMC Version 2.0
Loading...
Searching...
No Matches
TVirtualMCApplication.cxx
Go to the documentation of this file.
1// -----------------------------------------------------------------------
2// Copyright (C) 2019 CERN and copyright holders of VMC Project.
3// This software is distributed under the terms of the GNU General Public
4// License v3 (GPL Version 3), copied verbatim in the file "LICENSE".
5//
6// See https://github.com/vmc-project/vmc for full licensing information.
7// -----------------------------------------------------------------------
8
9// Author: Ivana Hrivnacova, 27/03/2002
10
11/*************************************************************************
12 * Copyright (C) 2006, Rene Brun and Fons Rademakers. *
13 * Copyright (C) 2002, ALICE Experiment at CERN. *
14 * All rights reserved. *
15 * *
16 * For the licensing terms see $ROOTSYS/LICENSE. *
17 * For the list of contributors see $ROOTSYS/README/CREDITS. *
18 *************************************************************************/
19
21#include "TError.h"
22#include "TVirtualMC.h"
23#include "TMCManager.h"
24
34
39
40TVirtualMCApplication::TVirtualMCApplication(const char *name, const char *title) : TNamed(name, title)
41{
42 if (fgInstance) {
43 ::Fatal("TVirtualMCApplication::TVirtualMCApplication", "Attempt to create two instances of singleton.");
44 }
45
46 // This is set to true if a TMCManager was reuqested.
48 ::Fatal("TVirtualMCApplication::TVirtualMCApplication", "In multi-engine run ==> multithreading is disabled.");
49 }
50
51 fgInstance = this;
52 // There cannot be a TVirtualMC since it must have registered to this
53 // TVirtualMCApplication
54 fMC = nullptr;
55 fMCManager = nullptr;
56}
57
62
64{
65 fgInstance = this;
66 fMC = nullptr;
67 fMCManager = nullptr;
68}
69
74
76{
77 fgInstance = nullptr;
78 if (fMCManager) {
79 delete fMCManager;
80 }
81}
82
87
89{
90 return fgInstance;
91}
92
97
99{
100 fMCManager = new TMCManager();
101 fMCManager->Register(this);
103 fLockMultiThreading = kTRUE;
104}
105
110
112{
113 // If there is already a transport engine, fail since only one is allowed.
114 if (fMC && !fMCManager) {
115 Fatal("Register", "Attempt to register a second TVirtualMC which "
116 "is not allowed");
117 }
118 fMC = mc;
119 if (fMCManager) {
120 fMCManager->Register(mc);
121 }
122}
123
128
130{
131 return fMC;
132}
Singleton manager class for handling and steering a run with multiple TVirtualMC engines sharing even...
Definition: TMCManager.h:43
void ConnectEnginePointer(TVirtualMC **mc)
Connect a pointer which is updated whenever the engine is changed.
Definition: TMCManager.cxx:209
void Register(TVirtualMC *engine)
A TVirtualMC will register itself via this method during construction if a TMCManager was instanciate...
Definition: TMCManager.cxx:93
Interface to a user Monte Carlo application.
TVirtualMCApplication()
Default constructor.
virtual ~TVirtualMCApplication()
Destructor.
TMCManager * fMCManager
Pointer to requested TMCManager which will only be instantiated by a call to RequestMCManager()
void Register(TVirtualMC *mc)
Register the an engine.
TVirtualMC * GetMC() const
Return the transport engine registered to this application.
static TMCThreadLocal TVirtualMCApplication * fgInstance
Singleton instance.
void RequestMCManager()
Request a TMCManager which is required if multiple engines should be run.
static Bool_t fLockMultiThreading
Forbid multithreading mode if multi run via global static flag.
static TVirtualMCApplication * Instance()
Static access method.
TVirtualMC * fMC
The current transport engine in use.
Abstract Monte Carlo interface.
Definition: TVirtualMC.h:49