13 #include "CLHEP/Units/PhysicalConstants.h" 14 using namespace CLHEP;
19 if(detectorFactoryMap->find(fname) == detectorFactoryMap->end())
21 cout <<
" *** WARNING: " << fname <<
" NOT FOUND IN Detector Factory Map." << endl;
25 return (*detectorFactoryMap)[fname]();
33 map<string, detectorFactoryInMap> dFactoryMap;
54 map<string, detector> hallMap;
57 for(map<string, detectorFactoryInMap>::iterator it = detectorFactoryMap.begin(); it != detectorFactoryMap.end(); it++)
66 map<string, detector> thisDMap = thisFactory->
loadDetectors();
69 for(map<string, detector>::iterator idet = thisDMap.begin(); idet != thisDMap.end(); idet++)
73 if(hallMap.find(idet->first) != hallMap.end())
75 cout <<
" *** WARNING! A detector >" << idet->first <<
"< in factory " << it->first <<
" exists already " << endl;
81 hallMap[idet->first] = idet->second;
90 string hall_mat = go.
optMap[
"HALL_MATERIAL"].args;
91 string hall_field = go.
optMap[
"HALL_FIELD"].args;
93 if(hall_dims.size() != 3)
94 cout <<
" !!! Error: Hall dimensions is not a vector of 3 numbers. Example of dimensions: \"20*m, 20*m, 20*m\"" << endl;
100 queen.
pos = G4ThreeVector(0, 0, 0);
101 queen.
rot = G4RotationMatrix(G4ThreeVector(1, 0, 0),
102 G4ThreeVector(0, 1, 0),
103 G4ThreeVector(0, 0, 1));
114 hallMap[queen.
name] = queen;
118 string nofield = go.
optMap[
"NO_FIELD"].args;
121 for( map<string, detector>::iterator it = hallMap.begin(); it!=hallMap.end() && nofield !=
"all" ; it++)
124 if(it->first == nofield)
127 if(it->second.magfield ==
"no")
130 string mother = it->second.mother;
131 string firstAncestorFieldFound =
"no";
132 while(mother !=
"akasha" && firstAncestorFieldFound ==
"no")
134 if(hallMap[mother].magfield !=
"no")
136 firstAncestorFieldFound = hallMap[mother].magfield;
137 it->second.magfield = hallMap[mother].magfield;
140 mother = hallMap[mother].mother;
152 set<string> requested;
161 requested.insert(it->second.get_factory());
165 for(map<string, detectorFactoryInMap>::iterator it = detectorFactoryMap.begin(); it != detectorFactoryMap.end(); it++)
166 present.insert(it->first);
169 for(set<string>::iterator it = requested.begin(); it != requested.end(); it++ )
171 frequested.append(*it +
" ");
172 if(present.find(*it) == present.end())
175 fnotfound.append(*it +
" ");
181 return string(
" *** WARNING: These detector factories were requested but not found: " + fnotfound);
183 return string(
" >> All detector factories requested are found: " + frequested);
189 if(gemcOpt.optMap[
"LOG_VERBOSITY"].arg > 0)
190 cout <<
" > " << ft <<
" Detector Factory is Initialized " << endl;
203 if(gt.
data.size() < 18)
205 cout <<
" !!! ERROR: Detector data size should be at least 18. There are " << gt.
data.size() <<
" items on the line for " << gt.
data[0] << endl;
208 string hd_msg =
" >> TEXT Factory: ";
211 string catch_v = go.
optMap[
"CATCH"].args;
232 if(shiftp.mag2() != 0)
234 if(verbosity > 3 || det.
name.find(catch_v))
235 cout << hd_msg <<
" Detector " << det.
name <<
" is displaced by: " << shiftp/cm <<
" cm" << endl;
242 if(more_rot.mag2() != 0)
244 if(verbosity > 3 || det.
name.find(catch_v))
245 cout << hd_msg <<
" Detector " << det.
name <<
" is rotated by: " << more_rot/deg <<
" deg" << endl;
247 det.
rot.rotateX(more_rot.x());
248 det.
rot.rotateY(more_rot.y());
249 det.
rot.rotateZ(more_rot.z());
255 if(gt.
data[5].size() != 6 && gt.
data[5].size() != 7)
257 cout << hd_msg <<
" Color Attributes for " << det.
name <<
"<" << gt.
data[5] <<
"> have wrong size: " << gt.
data[5].size()
258 <<
". It should be 6 or 7 digits rrggbb[t] (red, green, blue hexadecimals + optional transparency)." << endl;
262 G4Colour thisCol =
gcol(gt.
data[5]);
268 stringstream vars(gt.
data[7]);
295 if(verbosity > 3 || det.
name.find(catch_v))
296 cout << hd_msg <<
" Detector " << det.
name <<
" has existance set to: " << det.
exist << endl;
306 det.
VAtts = G4VisAttributes(thisCol);
309 det.
style ? det.
VAtts.SetForceSolid(
true) : det.
VAtts.SetForceWireframe(
true);
331 if(gt.
data.size() > 20)
334 if(gt.
data.size() > 21)
335 det.
run = atoi(gt.
data[21].c_str());
map< string, detector > buildDetector(map< string, detectorFactoryInMap > detectorFactoryMap, goptions go, runConditions rc)
vector< string > get_strings(string input)
returns a vector of strings from a stringstream, space is delimiter
string check_factory_existance(map< string, detectorFactoryInMap > detectorFactoryMap, runConditions rc)
string sensitivity
Defines the Sensitive Detector. possible choices: "no" "hits collection name".
string mother
Mother Volume name.
static detectorFactory * createFactory()
vector< identifier > get_identifiers(string var)
int run
run number that generated the detector
G4ThreeVector pos
Position relative to the mother volume, as G4ThreeVector.
static detectorFactory * createFactory()
string system
detector system
map< string, detectorCondition > detectorConditionsMap
G4VisAttributes VAtts
Visual Attributes: color, transparency, style (wireframe, solid), visibility.
double get_number(string v, int warn_no_unit)
Returns number with dimension from string, i.e. 100*cm.
static detectorFactory * createFactory()
virtual map< string, detector > loadDetectors()=0
G4ThreeVector calc_position(string v)
bool pMany
Needed by geant4 at G4PVPlacement time.
string factory
factory that generated the detector
G4RotationMatrix calc_rotation(string r, string dname)
static detectorFactory * createFactory()
string name
Name of the volume. Since this is the key of the STL map, it has to be unique.
map< string, aopt > optMap
Options map.
string material
Volume Material name.
G4Colour gcol(string cvar)
void initFactory(goptions, runConditions, string)
int visible
visibility of the detector: 0=invisible 1=visible
int style
Visual style: 0=wireframe 1=solid.
string hitType
Hit Process routine name. A Hit Process HitProcess derived class must exists with this name...
vector< identifier > identity
Vector of identifiers. Example: superlayer manual 1 type manual 2 segment manual 3 strip manual 4...
string magfield
Magnetic Field. The string "no" means that the field is inherited from the mother volume...
G4RotationMatrix rot
Rotation Matrix, defined by rotations along x,y,z axis relative to the mother volume.
int exist
detector ON/OFF switch
string type
solid type. This follows the GEANT4 definitions
vector< double > dimensions
vector of dimensions. Size, units depends on solid type
int scanned
for use during construction
detector get_detector(gtable gt, goptions go, runConditions RC)
string variation
variation that generated the detector
detectorFactory * getDetectorFactory(map< string, detectorFactoryInMap > *detectorFactoryMap, string fname)
map< string, detectorFactoryInMap > registerDetectorFactory()
string description
Volume Description for documentation.