|Message: Re: Integrating a class into a G4 MT enviorment||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
In the following I assume you have already evaluated that what you want to do cannot be obtained with built-in functionalities of Geant4 and thus an ad-hoc analysis type class is the best for your use case.
Said this consider that to make a new "piece of software" integrated with MT you need to identify if this element is shared among threads or is "thread-private" (e.g. each thread has its won copy). I suggest you to consider the seconda case (unless it is expected that this element will use a very large, O(100MB), fraction of the memory of your system). I will consider here the second case, because this is the typical one and the simpler. It is relatively simple to add it to a MT application: in principle no changes are needed to your class specific code. There is no need to add G4ThreadLocal anywhere, unless you have static or global variables in your code (in such a case consult http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForToolkitDeveloper/html/ch02s14.html ).
My suggestion is that you instantiate your sphereDetect object via run and run action. The idea is that you can sub-class from G4Run and create your specific type of run. This new class can have, as a data-member an instance of sphereDetect. Since each thread has an instance of G4Run (or inherited as in this case), each thread will have its own sphereDetect. You need also to implement a Merge(G4Run*) method that implements the logic of reduction of sphereDetect into a single object (the master one). See http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch03s04.html
Summarizing: 1- Create a Run class inheriting from G4Run that own sphereDetect instance 2- Implement the reduction in G4Run::Merge 3- Create a RunAction class that instantiate your run in GenerateRun() method 4- Remember to instantiate this RunAction class for both master and workers in Build() and BuildForMaster() methods of your ActionInitialization class
You can see an example of all these in action in basic example basic/B1 (B1Run, B1RunAction and B1ActionInitialization classes)
A tutorial/manual for MT describing all this can be found here: https://twiki.cern.ch/twiki/bin/view/Geant4/QuickMigrationGuideForGeant4V10
|Inline Depth:||Outline Depth:||Add message:|