ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4ImportanceConfigurator.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4ImportanceConfigurator.cc
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 //
27 //
28 // ----------------------------------------------------------------------
29 // Class G4ImportanceConfigurator
30 //
31 // Author: Michael Dressel (Michael.Dressel@cern.ch)
32 // ----------------------------------------------------------------------
33 
35 
36 #include "G4ImportanceProcess.hh"
37 #include "G4ProcessPlacer.hh"
38 #include "G4ImportanceAlgorithm.hh"
39 
41 #include "G4AutoLock.hh"
42 
43 #ifdef G4MULTITHREADED
44 namespace {
45  G4Mutex BiasConfigMutex = G4MUTEX_INITIALIZER;
46 }
47 #endif
48 
51  const G4String &particlename,
52  G4VIStore &istore,
53  const G4VImportanceAlgorithm *ialg, G4bool para)
54  : fWorld(worldvolume),
55  fWorldName(worldvolume->GetName()),
56  fPlacer(particlename),
57  fIStore(istore),
58  fDeleteIalg( ( ! ialg) ),
59  fIalgorithm(( (fDeleteIalg) ?
60  new G4ImportanceAlgorithm : ialg)),
61  fImportanceProcess(0),
62  paraflag(para)
63 {;}
64 
66 G4ImportanceConfigurator(const G4String &worldvolumeName,
67  const G4String &particlename,
68  G4VIStore &istore,
69  const G4VImportanceAlgorithm *ialg, G4bool para)
70 : fWorldName(worldvolumeName),
71  fPlacer(particlename),
72  fIStore(istore),
73  fDeleteIalg( ( ! ialg) ),
74  fIalgorithm(( (fDeleteIalg) ?
75  new G4ImportanceAlgorithm : ialg)),
76  fImportanceProcess(0),
77  paraflag(para)
78 {
81 }
82 
84 {
86  {
88  delete fImportanceProcess;
89  }
90  if (fDeleteIalg)
91  {
92  delete fIalgorithm;
93  }
94 }
95 
96 void
98 {
99  G4cout << "G4ImportanceConfigurator:: entering importance configure, paraflag " << paraflag << G4endl;
100  const G4VTrackTerminator *terminator = 0;
101  if (preConf)
102  {
103  terminator = preConf->GetTrackTerminator();
104  };
105 
106 
107 #ifdef G4MULTITHREADED
108  G4AutoLock l(&BiasConfigMutex);
109 #endif
112  fIStore,
113  terminator,"ImportanceProcess",paraflag);
114 
115  if (!fImportanceProcess)
116  {
117  G4Exception("G4ImportanceConfigurator::Configure()",
118  "FatalError", FatalException,
119  "Failed allocation of G4ImportanceProcess !");
120  }
121 
122  // G4cout << "G4ImportanceConfigurator:: setting parallel World " << paraflag << G4endl;
124 #ifdef G4MULTITHREADED
125  l.unlock();
126 // G4MUTEXUNLOCK(&G4ImportanceConfigurator::BiasConfigMutex);
127 #endif
128  // if(paraflag) fImportanceProcess->SetParallelWorld(fWorldName);
129  // G4cout << "G4ImportanceConfigurator:: set " << paraflag << " name: " << fWorld->GetName() << G4endl;
130  // getchar();
132 }
133 
136 {
137  return fImportanceProcess;
138 }
139 
141 {
142  G4cout << " G4ImportanceConfigurator:: setting world name: " << name << G4endl;
143  fWorldName = name;
144 }