Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions
G4VUserDetectorConstruction Class Referenceabstract

#include <G4VUserDetectorConstruction.hh>

Inheritance diagram for G4VUserDetectorConstruction:
B01DetectorConstruction B02DetectorConstruction B03DetectorConstruction B1DetectorConstruction B1DetectorConstruction B1DetectorConstruction B2aDetectorConstruction B2bDetectorConstruction B2bDetectorConstruction B3DetectorConstruction B4cDetectorConstruction B4dDetectorConstruction B4DetectorConstruction B4DetectorConstruction B5DetectorConstruction BrachyDetectorConstruction CCalDetectorConstruction CexmcSetup CML2WorldConstruction Collimator100BeamLine Collimator40BeamLine Collimator50BeamLine Collimator60BeamLine Collimator70BeamLine Collimator80BeamLine DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DetectorConstruction DicomDetectorConstruction DMXDetectorConstruction ElectronBenchmarkDetector Em10DetectorConstruction eRositaDetectorConstruction ExErrorDetectorConstruction ExG4DetectorConstruction01 ExG4DetectorConstruction02 ExGflashDetectorConstruction exGPSGeometryConstruction ExN01DetectorConstruction ExN02DetectorConstruction ExN03DetectorConstruction ExN04DetectorConstruction ExN04DetectorConstruction ExP01DetectorConstruction ExP02DetConstrReader ExP02DetectorConstruction exrdmDetectorConstruction ExTGDetectorConstruction ExTGDetectorConstructionWithCpp ExTGDetectorConstructionWithCuts ExTGDetectorConstructionWithSD EzDetectorConstruction F01DetectorConstruction F02DetectorConstruction F03DetectorConstruction F04DetectorConstruction F05DetectorConstruction F06DetectorConstruction FCALTestbeamSetup G01DetectorConstruction G02DetectorConstruction G03DetectorConstruction G04DetectorConstruction G3toG4DetectorConstruction G4HumanPhantomConstruction GammaKnifeDetectorConstruction GammaRayTelDetectorConstruction GB01DetectorConstruction GB02DetectorConstruction H02DetectorConstruction LXeDetectorConstruction MyDetectorConstruction OpNoviceDetectorConstruction Par01DetectorConstruction PassiveCarbonBeamLine PassiveProtonBeamLine PurgMagDetectorConstruction pyG4VUserDetectorConstruction::CB_G4VUserDetectorConstruction QDetectorConstruction QDetectorConstruction RE01DetectorConstruction RE02DetectorConstruction RE03DetectorConstruction RE04DetectorConstruction RE05DetectorConstruction RE06DetectorConstruction read_gdml.MyDetectorConstruction read_gdml.MyDetectorConstruction RMC01DetectorConstruction test.MyDetectorConstruction test.MyDetectorConstruction test.MyDetectorConstruction test.MyDetectorConstruction test.MyDetectorConstruction test.MyDetectorConstruction TRTDetectorConstruction UltraDetectorConstruction WLSDetectorConstruction XDetectorConstruction XrayFluoDetectorConstruction XrayFluoGeometry XrayFluoMercuryDetectorConstruction XrayFluoPlaneDetectorConstruction XrayTelDetectorConstruction

Public Member Functions

 G4VUserDetectorConstruction ()
 
virtual ~G4VUserDetectorConstruction ()
 
virtual G4VPhysicalVolumeConstruct ()=0
 
virtual void ConstructSDandField ()
 
virtual void CloneSD ()
 
virtual void CloneF ()
 
void RegisterParallelWorld (G4VUserParallelWorld *)
 
G4int ConstructParallelGeometries ()
 
void ConstructParallelSD ()
 
G4int GetNumberOfParallelWorld () const
 
G4VUserParallelWorldGetParallelWorld (G4int i) const
 

Protected Member Functions

void SetSensitiveDetector (const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
 
void SetSensitiveDetector (G4LogicalVolume *logVol, G4VSensitiveDetector *aSD)
 

Detailed Description

Definition at line 50 of file G4VUserDetectorConstruction.hh.

Constructor & Destructor Documentation

G4VUserDetectorConstruction::G4VUserDetectorConstruction ( )

Definition at line 40 of file G4VUserDetectorConstruction.cc.

41 {;}
G4VUserDetectorConstruction::~G4VUserDetectorConstruction ( )
virtual

Definition at line 43 of file G4VUserDetectorConstruction.cc.

44 {;}

Member Function Documentation

void G4VUserDetectorConstruction::CloneF ( )
virtual

Definition at line 107 of file G4VUserDetectorConstruction.cc.

References assert, G4FieldManager::Clone(), FatalException, G4Exception(), G4LogicalVolumeStore::GetInstance(), python.hepunit::second, and G4LogicalVolume::SetFieldManager().

108 {
109  typedef std::map<G4FieldManager*,G4FieldManager*> FMtoFMmap;
110  typedef std::pair<G4FieldManager*,G4FieldManager*> FMpair;
111  FMtoFMmap masterToWorker;
113  assert( logVolStore != NULL );
114  for ( G4LogicalVolumeStore::const_iterator it = logVolStore->begin() ; it != logVolStore->end() ; ++it )
115  {
116  G4LogicalVolume *g4LogicalVolume = *it;
117  //Use shadow of master to get instance of FM
118  G4FieldManager* masterFM = 0;//g4LogicalVolume->fFieldManager;
119  G4FieldManager* clonedFM = 0;
120  if ( masterFM )
121  {
122  FMtoFMmap::iterator fmFound = masterToWorker.find(masterFM);
123  if ( fmFound == masterToWorker.end() )
124  {
125  //First time we see this SD, let's clone and remember...
126  try {
127  std::pair<FMtoFMmap::iterator,bool> insertedEl = masterToWorker.insert( FMpair(masterFM, masterFM->Clone()) );
128  clonedFM = (insertedEl.first)->second;
129  }
130  catch (...)
131  {
133  msg << "Cloning of G4FieldManager failed."
134  << " But derived class does not implement cloning. Cannot continue.";
135  G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053", FatalException,msg);
136 
137  }
138  }
139  else
140  {
141  // We have already seen this SD attached to a fifferent LogicalVolume, let's re-use previous clone
142  clonedFM = (*fmFound).second;
143  }
144  }// masterFM != 0
145  //Note that we do not push FM to doughters (false argument), however, since we area looping on all
146  //logical volumes and we implemented the "trick" of the map master<->cloned the final
147  //effect is the same as using here the correct boolean flag: log-volumes that originally were sharing
148  //the same FM they will have cloned ones
149  g4LogicalVolume->SetFieldManager(clonedFM, false);
150  }
151 }
virtual G4FieldManager * Clone() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
#define assert(x)
Definition: mymalloc.cc:1309
void SetFieldManager(G4FieldManager *pFieldMgr, G4bool forceToAllDaughters)
static G4LogicalVolumeStore * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4VUserDetectorConstruction::CloneSD ( )
virtual

Definition at line 153 of file G4VUserDetectorConstruction.cc.

References assert, G4VSensitiveDetector::Clone(), FatalException, G4Exception(), G4VSensitiveDetector::GetFullPathName(), G4LogicalVolumeStore::GetInstance(), G4VSensitiveDetector::GetName(), python.hepunit::second, and G4LogicalVolume::SetSensitiveDetector().

154 {
155  //Loop on ALL logial volumes to search for attached SD
157  assert( logVolStore != NULL );
158 
159  typedef std::map<G4VSensitiveDetector*,G4VSensitiveDetector*> SDtoSDmap;
160  typedef std::pair<G4VSensitiveDetector*,G4VSensitiveDetector*> SDpair;
161  SDtoSDmap masterToWorker;
162 
163  for ( G4LogicalVolumeStore::const_iterator it = logVolStore->begin() ; it != logVolStore->end() ; ++it )
164  {
165  G4LogicalVolume *g4LogicalVolume = *it;
166  //Use shadow of master to get the instance of SD
167  G4VSensitiveDetector* masterSD = 0;//g4LogicalVolume->fSensitiveDetector;
168  G4VSensitiveDetector* clonedSD = 0;
169  if ( masterSD )
170  {
171  SDtoSDmap::iterator sdFound = masterToWorker.find(masterSD);
172  if ( sdFound == masterToWorker.end() )
173  {
174  //First time we see this SD, let's clone and remember...
175  try {
176  std::pair<SDtoSDmap::iterator,bool> insertedEl = masterToWorker.insert( SDpair(masterSD,masterSD->Clone()) );
177  clonedSD = (insertedEl.first)->second;
178  }
179  catch (...)
180  {
182  msg << "Cloning of G4VSensitiveDetector requested for:" << masterSD->GetName() << "\n"
183 #ifndef WIN32
184  << " (full path name: " << masterSD->GetFullPathName() << ").\n"
185 #endif
186  << " But derived class does not implement cloning. Cannot continue.";
187  G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053", FatalException,msg);
188  }
189 
190  }
191  else
192  {
193  // We have already seen this SD attached to a fifferent LogicalVolume, let's re-use previous clone
194  clonedSD = (*sdFound).second;
195 
196  }
197  }// masterSD!=0
198  g4LogicalVolume->SetSensitiveDetector(clonedSD);
199 
200  }
201 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
#define assert(x)
Definition: mymalloc.cc:1309
virtual G4VSensitiveDetector * Clone() const
static G4LogicalVolumeStore * GetInstance()
G4String GetFullPathName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)
virtual G4VPhysicalVolume* G4VUserDetectorConstruction::Construct ( )
pure virtual

Implemented in RE02DetectorConstruction, CexmcSetup, GammaRayTelDetectorConstruction, Em10DetectorConstruction, XrayFluoDetectorConstruction, CML2WorldConstruction, DetectorConstruction, F01DetectorConstruction, F02DetectorConstruction, XrayFluoMercuryDetectorConstruction, F03DetectorConstruction, DetectorConstruction, DetectorConstruction, XrayFluoPlaneDetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, ExN03DetectorConstruction, DetectorConstruction, UltraDetectorConstruction, DMXDetectorConstruction, PurgMagDetectorConstruction, DetectorConstruction, ExErrorDetectorConstruction, DetectorConstruction, WLSDetectorConstruction, DetectorConstruction, Collimator100BeamLine, Collimator40BeamLine, Collimator50BeamLine, Collimator60BeamLine, Collimator70BeamLine, Collimator80BeamLine, XrayTelDetectorConstruction, G02DetectorConstruction, RMC01DetectorConstruction, DetectorConstruction, DicomDetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, B4cDetectorConstruction, B4dDetectorConstruction, FCALTestbeamSetup, ExG4DetectorConstruction02, DetectorConstruction, DetectorConstruction, B4DetectorConstruction, B4DetectorConstruction, DetectorConstruction, F04DetectorConstruction, F06DetectorConstruction, DetectorConstruction, DetectorConstruction, DicomPartialDetectorConstruction, ExN02DetectorConstruction, G03DetectorConstruction, ExP01DetectorConstruction, ExG4DetectorConstruction01, DetectorConstruction, F05DetectorConstruction, LXeDetectorConstruction, PassiveProtonBeamLine, DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, XrayFluoGeometry, B5DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, exrdmDetectorConstruction, RE04DetectorConstruction, BrachyDetectorConstruction, eRositaDetectorConstruction, B2aDetectorConstruction, B2bDetectorConstruction, DetectorConstruction, DetectorConstruction, B2bDetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, DetectorConstruction, ElectronBenchmarkDetector, DetectorConstruction, ExN01DetectorConstruction, DetectorConstruction, MyDetectorConstruction, DetectorConstruction, DetectorConstruction, G3toG4DetectorConstruction, ExGflashDetectorConstruction, PassiveCarbonBeamLine, B3DetectorConstruction, TRTDetectorConstruction, DetectorConstruction, ExP02DetConstrReader, DetectorConstruction, RE06DetectorConstruction, GammaKnifeDetectorConstruction, G4HumanPhantomConstruction, B01DetectorConstruction, B02DetectorConstruction, GB01DetectorConstruction, GB02DetectorConstruction, DetectorConstruction, G01DetectorConstruction, G04DetectorConstruction, EzDetectorConstruction, QDetectorConstruction, QDetectorConstruction, ExN04DetectorConstruction, ExP02DetectorConstruction, RE01DetectorConstruction, RE05DetectorConstruction, B1DetectorConstruction, B1DetectorConstruction, B03DetectorConstruction, ExTGDetectorConstruction, ExTGDetectorConstructionWithCpp, ExTGDetectorConstructionWithCuts, ExTGDetectorConstructionWithSD, RE03DetectorConstruction, B1DetectorConstruction, exGPSGeometryConstruction, XDetectorConstruction, pyG4VUserDetectorConstruction::CB_G4VUserDetectorConstruction, DetectorConstruction, ExN04DetectorConstruction, OpNoviceDetectorConstruction, Par01DetectorConstruction, CCalDetectorConstruction, H02DetectorConstruction, DetectorConstruction, and DetectorConstruction.

Referenced by read_gdml.MyDetectorConstruction::Construct(), test.MyDetectorConstruction::Construct(), export_G4VUserDetectorConstruction(), G4RunManager::InitializeGeometry(), and G4ErrorRunManagerHelper::SetUserInitialization().

G4int G4VUserDetectorConstruction::ConstructParallelGeometries ( )

Definition at line 63 of file G4VUserDetectorConstruction.cc.

Referenced by G4RunManager::InitializeGeometry().

64 {
65  G4int nP = 0;
66  std::vector<G4VUserParallelWorld*>::iterator pwItr;
67  for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
68  {
69  (*pwItr)->Construct();
70  nP++;
71  }
72  return nP;
73 }
int G4int
Definition: G4Types.hh:78
void G4VUserDetectorConstruction::ConstructParallelSD ( )

Definition at line 75 of file G4VUserDetectorConstruction.cc.

Referenced by G4WorkerRunManager::InitializeGeometry(), and G4RunManager::InitializeGeometry().

76 {
77  std::vector<G4VUserParallelWorld*>::iterator pwItr;
78  for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
79  { (*pwItr)->ConstructSD(); }
80 }
void G4VUserDetectorConstruction::ConstructSDandField ( )
virtual

Reimplemented in RE02DetectorConstruction, DicomDetectorConstruction, F01DetectorConstruction, F02DetectorConstruction, F03DetectorConstruction, DetectorConstruction, DetectorConstruction, WLSDetectorConstruction, UltraDetectorConstruction, DetectorConstruction, DetectorConstruction, B01DetectorConstruction, DetectorConstruction, B4cDetectorConstruction, B4dDetectorConstruction, F04DetectorConstruction, B4DetectorConstruction, B4DetectorConstruction, F06DetectorConstruction, DetectorConstruction, F05DetectorConstruction, LXeDetectorConstruction, B5DetectorConstruction, ElectronBenchmarkDetector, B2aDetectorConstruction, B2bDetectorConstruction, B2bDetectorConstruction, G4HumanPhantomConstruction, DetectorConstruction, ExGflashDetectorConstruction, B3DetectorConstruction, RE06DetectorConstruction, GB02DetectorConstruction, RE01DetectorConstruction, RE05DetectorConstruction, ExTGDetectorConstructionWithSD, RE03DetectorConstruction, DetectorConstruction, Par01DetectorConstruction, DetectorConstruction, and DetectorConstruction.

Definition at line 93 of file G4VUserDetectorConstruction.cc.

Referenced by G4WorkerRunManager::InitializeGeometry(), and G4RunManager::InitializeGeometry().

94 {
95 // G4RunManager::RMType rmtype = G4RunManager::GetRunManager()->GetRunManagerType();
96 // if(rmtype != G4RunManager::sequentialRM)
97 // {
98 // G4cout
99 // << "User-derived detector construction class does not implement \n"
100 // << "ConstructSDandFiled method: i.e. workers will not have SD and fields!\n"
101 // << "The user can safely ignore this message if (s)he has no sensitive\n"
102 // << "detector or field in her/his application." << G4endl;
103 // }
104 }
G4int G4VUserDetectorConstruction::GetNumberOfParallelWorld ( ) const

Definition at line 82 of file G4VUserDetectorConstruction.cc.

Referenced by GetParallelWorld().

83 { return parallelWorld.size(); }
G4VUserParallelWorld * G4VUserDetectorConstruction::GetParallelWorld ( G4int  i) const

Definition at line 85 of file G4VUserDetectorConstruction.cc.

References GetNumberOfParallelWorld().

Referenced by RE06DetectorConstruction::SetSerialGeometry(), and HadrontherapyDetectorConstruction::UpdateGeometry().

86 {
87  if(i<0||i>=GetNumberOfParallelWorld()) return 0;
88  return parallelWorld[i];
89 }
void G4VUserDetectorConstruction::RegisterParallelWorld ( G4VUserParallelWorld aPW)

Definition at line 46 of file G4VUserDetectorConstruction.cc.

References FatalErrorInArgument, G4Exception(), and G4VUserParallelWorld::GetName().

Referenced by main(), PassiveCarbonBeamLine::PassiveCarbonBeamLine(), and PassiveProtonBeamLine::PassiveProtonBeamLine().

47 {
48  std::vector<G4VUserParallelWorld*>::iterator pwItr;
49  for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
50  {
51  if((*pwItr)->GetName()==aPW->GetName())
52  {
53  G4String eM = "A parallel world <";
54  eM += aPW->GetName();
55  eM += "> is already registered to the user detector construction.";
56  G4Exception("G4VUserDetectorConstruction::RegisterParallelWorld",
57  "Run0051",FatalErrorInArgument,eM);
58  }
59  }
60  parallelWorld.push_back(aPW);
61 }
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4VUserDetectorConstruction::SetSensitiveDetector ( const G4String logVolName,
G4VSensitiveDetector aSD,
G4bool  multi = false 
)
protected

Definition at line 204 of file G4VUserDetectorConstruction.cc.

References FatalErrorInArgument, G4Exception(), G4LogicalVolumeStore::GetInstance(), and G4VSensitiveDetector::GetName().

Referenced by H02DetectorConstruction::Construct(), ExTGDetectorConstructionWithSD::ConstructSDandField(), RE01DetectorConstruction::ConstructSDandField(), RE05DetectorConstruction::ConstructSDandField(), B3DetectorConstruction::ConstructSDandField(), G4HumanPhantomConstruction::ConstructSDandField(), B2aDetectorConstruction::ConstructSDandField(), B2bDetectorConstruction::ConstructSDandField(), ElectronBenchmarkDetector::ConstructSDandField(), LXeDetectorConstruction::ConstructSDandField(), B4cDetectorConstruction::ConstructSDandField(), B4dDetectorConstruction::ConstructSDandField(), B01DetectorConstruction::ConstructSDandField(), UltraDetectorConstruction::ConstructSDandField(), WLSDetectorConstruction::ConstructSDandField(), F03DetectorConstruction::ConstructSDandField(), F01DetectorConstruction::ConstructSDandField(), F02DetectorConstruction::ConstructSDandField(), DicomDetectorConstruction::ConstructSDandField(), and MyDetectorConstruction::SetSDtoScoreVoxel().

205 {
206  G4bool found = false;
208  for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
209  {
210  if((*pos)->GetName()==logVolName)
211  {
212  if(found && !multi)
213  {
214  G4String eM = "More than one logical volumes of the name <";
215  eM += (*pos)->GetName();
216  eM += "> are found and thus the sensitive detector <";
217  eM += aSD->GetName();
218  eM += "> cannot be uniquely assigned.";
219  G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector",
220  "Run0052",FatalErrorInArgument,eM);
221  }
222  found = true;
223  SetSensitiveDetector(*pos,aSD);
224  }
225  }
226  if(!found)
227  {
228  G4String eM2 = "No logical volume of the name <";
229  eM2 += logVolName;
230  eM2 += "> is found. The specified sensitive detector <";
231  eM2 += aSD->GetName();
232  eM2 += "> couldn't be assigned to any volume.";
233  G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector",
234  "Run0053",FatalErrorInArgument,eM2);
235  }
236 }
bool G4bool
Definition: G4Types.hh:79
static G4LogicalVolumeStore * GetInstance()
void SetSensitiveDetector(const G4String &logVolName, G4VSensitiveDetector *aSD, G4bool multi=false)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4VUserDetectorConstruction::SetSensitiveDetector ( G4LogicalVolume logVol,
G4VSensitiveDetector aSD 
)
protected

Definition at line 239 of file G4VUserDetectorConstruction.cc.

References G4SDManager::AddNewDetector(), G4SDManager::GetSDMpointer(), and G4LogicalVolume::SetSensitiveDetector().

240 {
242  logVol->SetSensitiveDetector(aSD);
243 }
void AddNewDetector(G4VSensitiveDetector *aSD)
Definition: G4SDManager.cc:67
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
void SetSensitiveDetector(G4VSensitiveDetector *pSDetector)

The documentation for this class was generated from the following files: