_Geant4 Version: 11.2.0
_Operating System: Almalinux 9.4
_Compiler/Version: g++ (GCC) 13.1.0
_CMake Version: cmake version 3.26.2
Dear experts,
I’m developing a personal class for storing information on a ROOT ntuple. To access variables during events I’m using an Instance() method. Below you can see a snippet of the header file containing the Instance method implementation
class CreateTree
{
private:
TTree* ftree ;
TString fname ;
public:
CreateTree (TString name);
~CreateTree () ;
static CreateTree* Instance() { return fInstance; } ;
static CreateTree* fInstance;
int aSimpleCounter;
Now the variable aSimpleCounter
is an optical photon counter that I implement in SteppingAction :
if(G4StrUtil::contains(thePrePVName, "Calorimeter") && G4StrUtil::contains(thePostPVName, "SiPM_C")){
if (processName == "Scintillation") {
CreateTree::Instance()->aSimpleCounter +=1;
fEventAction->anotherSimpleCounter +=1;
}
Here anotherSimpleCounter
is implemented in EventAction class and fills a ROOT ntuples created via AnalysisManager class.
So, I discovered that when using more threads the two variables are different. I just found out that there are methods to avoid this issue, but since I’m not an expert I’m asking for an help to use my class with multithreading.
Thanks for the attention.
Best regards,
Francesco