27 #ifndef SToGS_DetectorFactory_h
28 #define SToGS_DetectorFactory_h 1
31 #include "G4VUserDetectorConstruction.hh"
32 #include "G4RotationMatrix.hh"
33 #include "G4Transform3D.hh"
42 class G4LogicalVolume;
43 class G4VPhysicalVolume;
45 class G4AssemblyVolume;
46 class G4VSensitiveDetector;
74 static std::vector < DetectorFactory * > fSubFactory;
99 fSubFactory.push_back(df);
105 fPath(
"DetectorFactory/"),
124 G4int val = gCopyNb++;
129 G4int current = gCopyNb;
138 static void ChangeCopyNb(G4VPhysicalVolume *top, G4String which_det, G4int which_nb);
147 static G4VPhysicalVolume *
MakeVCR(
149 G4double HalfX = 5.0*CLHEP::m, G4double HalfY = 5.0*CLHEP::m, G4double HalfZ = 5.0*CLHEP::m,
157 static void SetActive(G4LogicalVolume *pv,
const G4String &option =
"*|*|*|0.5;0.5;0.5;0.5");
163 static void ChangeSD(G4String opt, G4VPhysicalVolume *top = 0x0);
165 static G4VSensitiveDetector *
GetSD(G4String opt,
const char sd_type =
'S');
172 std::vector<G4LogicalVolume *> &logical_stored,
173 std::vector<G4VPhysicalVolume *> &physical_stored, std::vector<G4VPhysicalVolume *> &physical_active);
178 virtual G4VPhysicalVolume *
Make(G4String , G4String )
183 void StoreMap(std::ofstream &amap, std::ofstream &dmap,
184 std::vector<G4LogicalVolume *> &logical_stored,
185 std::vector<G4VPhysicalVolume *> &physical_stored,
186 std::vector<G4VPhysicalVolume *> &physical_active,
187 G4VPhysicalVolume *theDetector);
196 G4VPhysicalVolume *
Import(G4String gdmlfile, G4String detname,
const G4String &opt_amap,
const G4String &opt_dmap);
213 G4String
GetDetName(
const G4String &path)
const;
214 G4String
GetDetName(G4String name, G4String version)
const;
217 G4String
GetFileName(G4String detname, G4String extention);
228 virtual G4VPhysicalVolume *
Get(G4String basename);
231 virtual void GetAttributes(G4String basename, G4bool do_amap =
true, G4bool do_dmap =
false);
234 G4int
Set(G4String basename, G4VPhysicalVolume *world, G4int copy_number_offset,
235 const G4ThreeVector *T = 0x0,
const G4RotationMatrix *R = 0x0, G4int main_copy_number = 0);
236 G4int
Set(G4String basename, G4VPhysicalVolume *world, G4int copy_number_offset,
237 const G4Transform3D *Tr, G4int main_copy_number = 0);
247 void MakeInStore(G4String name, G4String version_string);
254 virtual void Store(G4VPhysicalVolume *);
257 void AssemblyRename(G4AssemblyVolume *assembly,
const G4String &volume_to_find)
const;
262 G4int
DoMap(G4AssemblyVolume *assembly, G4VPhysicalVolume *volume_used_to_built_assembly, G4int copy_number_offset = 0
268 virtual G4int
ReMap(G4VPhysicalVolume *adetector, G4int offset);
280 #include "G4UImessenger.hh"
283 class G4UIcmdWithAString;
300 G4UIdirectory *theDirectory;
303 G4UIcmdWithAString *cmdToChangeSD;
304 G4UIcmdWithAString *cmdToSaveInFactory;
G4int Set(G4String basename, G4VPhysicalVolume *world, G4int copy_number_offset, const G4ThreeVector *T=0x0, const G4RotationMatrix *R=0x0, G4int main_copy_number=0)
to be used once a detector is fully contructed to simply place it in the world
static G4VPhysicalVolume * MakeVCR(G4String name, G4double HalfX=5.0 *CLHEP::m, G4double HalfY=5.0 *CLHEP::m, G4double HalfZ=5.0 *CLHEP::m, G4int copy=-1)
make a cubic world
the Messenger for the Detector Factory
static void ChangeCopyNb(G4VPhysicalVolume *top, G4String which_det, G4int which_nb)
change copy number of the physical volume contained in the top volume
void StoreMap(std::ofstream &amap, std::ofstream &dmap, std::vector< G4LogicalVolume * > &logical_stored, std::vector< G4VPhysicalVolume * > &physical_stored, std::vector< G4VPhysicalVolume * > &physical_active, G4VPhysicalVolume *theDetector)
recursively called in the tree struture
static DetectorFactory * GetFactory(G4String fullname)
get the specific factory for a full name to a file
void Clean()
clear factory i.e. in memory collections of physicals and assemblies
G4String GetDetName(const G4String &path) const
Get detector name from full path to the gdml file.
void MakeInStore(G4String name, G4String version_string)
build in store a particular detector from its names and version. i.e. call th Make method of the sub ...
virtual void Store(G4VPhysicalVolume *)
Store in the sub-factory the given physical volume.
virtual G4VPhysicalVolume * Make(G4String, G4String)
Should be implemented in any sub factory. It built (C++) a detector and return it.
static G4int GetGCopyNb()
virtual G4VPhysicalVolume * Get(G4String basename)
search for a detector in DetectorFactory
static G4VSensitiveDetector * GetSD(G4String opt, const char sd_type= 'S')
Get a particular SD. S means a SD while s is for Scorers.
static G4int AddGCopyNb()
global copy number, used to set copy number once building detector. Not protected for MT since in pri...
static DetectorFactory * theMainFactory()
to get the main factory
void SetNewValue(G4UIcommand *, G4String)
virtual G4VPhysicalVolume * MakeAnArrayFromFactory(G4String input_file)
built an array from the factory using the given input file
G4String GetFileName(G4String detname, G4String extention)
compute name of the file to store/read information
virtual G4int ReMap(G4VPhysicalVolume *adetector, G4int offset)
for the given volume, it changes all copy number of active volumes by starting with offset ...
static G4int SetGCopyNb(G4int val)
virtual ~DetectorFactory()
static void CollectVolumes(G4VPhysicalVolume *theDetector, std::vector< G4LogicalVolume * > &logical_stored, std::vector< G4VPhysicalVolume * > &physical_stored, std::vector< G4VPhysicalVolume * > &physical_active)
From the given physical volume, it collects into collection all logical (sensitive) and physical volu...
virtual void GetAttributes(G4String basename, G4bool do_amap=true, G4bool do_dmap=false)
Read the amap file and apply atributes to the detector. if not found, it creates a deefault one from ...
G4String fPath
Name of the factory, also used for the name of the directory containing the detectors handled by the ...
std::vector< std::pair< G4String, G4AssemblyVolume * > > fLoadedAssembly
in case a gdml file has already by loaded, it allows to get the assembly quickly
Base Factory. This is a container of sub-factories.
void AssemblyRename(G4AssemblyVolume *assembly, const G4String &volume_to_find) const
rename physical volume produced by the assembly
G4String GetFactoryName() const
virtual void MakeStore()
build the default store i.e. all the detectors. Here It calls MakeStore for all registered sub factor...
DetectorFactory(G4String path)
used for inheriting classes, it registers this in the factory
G4int DoMap(G4AssemblyVolume *assembly, G4VPhysicalVolume *volume_used_to_built_assembly, G4int copy_number_offset=0) const
remap all the physical volumes produced by the Imprint method.
G4VPhysicalVolume * Import(G4String gdmlfile, G4String detname, const G4String &opt_amap, const G4String &opt_dmap)
import a gdml file (extention to ascii ?) into factory. See Active for opt_amap option ...
void StreamTouchable(std::ofstream &dmap, G4String)
extrac from the name of the detector the touchable part
static void SetActive(G4LogicalVolume *pv, const G4String &option="*|*|*|0.5;0.5;0.5;0.5")
Set to the given logical volume some attributs (sensitive, color) depending of the given option...
DetectorFactory()
used only for the main, does not register this in the factory
static void ChangeSD(G4String opt, G4VPhysicalVolume *top=0x0)
Change some SD detector into an other type of SD. Opt is used eventually to filter on the name of the...
std::vector< std::pair< G4String, G4VPhysicalVolume * > > fLoadedPhysical
in case it has been loaded, keep a trace
G4AssemblyVolume * GetAssembly(G4String basename)