GEMC  2.3
Geant4 Monte-Carlo Framework
MDetectorConstruction.cc
Go to the documentation of this file.
1 // G4 headers
2 #include "G4Box.hh"
3 #include "G4GeometryManager.hh"
4 #include "G4LogicalVolumeStore.hh"
5 #include "G4LogicalVolume.hh"
6 #include "G4PhysicalVolumeStore.hh"
7 #include "G4ProductionCuts.hh"
8 #include "G4PVPlacement.hh"
9 #include "G4RunManager.hh"
10 #include "G4SolidStore.hh"
11 #include "G4VisAttributes.hh"
12 #include "G4SDManager.hh"
13 #include "G4OpBoundaryProcess.hh"
14 #include "G4RegionStore.hh"
15 
16 // gemc headers
17 #include "MDetectorConstruction.h"
18 #include "MDetectorMessenger.h"
19 
20 // C++ headers
21 #include <sstream>
22 using namespace std;
23 
25 {
26  gemcOpt = Opts;
27 }
28 
30 {
31  ;
32 }
33 
34 
36 {
37  string hd_msg = gemcOpt.optMap["LOG_MSG"].args + " >> Construction:";
38  double VERB = gemcOpt.optMap["G4P_VERBOSITY"].arg ;
39  string catch_v = gemcOpt.optMap["CATCH"].args;
40  string hall_mat = gemcOpt.optMap["HALL_MATERIAL"].args;
41  string hall_field = gemcOpt.optMap["HALL_FIELD"].args;
42 
43  // Clean old geometry, if any
44  G4GeometryManager::GetInstance()->OpenGeometry();
45  G4PhysicalVolumeStore::GetInstance()->Clean();
46  G4LogicalVolumeStore::GetInstance()->Clean();
47  G4SolidStore::GetInstance()->Clean();
48 
49  // Experimental hall is a 20mx2 = 40 meters box
50  // dimensions coming from HALL_DIMENSIONS options
51  (*hallMap)["root"].create_solid(gemcOpt, hallMap);
52  (*hallMap)["root"].create_logical_volume(mats, gemcOpt);
53  (*hallMap)["root"].create_physical_volumes(gemcOpt, NULL);
54  hasMagfield((*hallMap)["root"]);
55 
56  if(VERB > 3 || catch_v == "root") cout << hd_msg << " " << (*hallMap)["root"] ;
57 
58 
59  cout << hd_msg << " Building Detector from Geometry STL Map..." << endl;
60 
61 
62  // ########################################################################
63  // Resetting Detector Map "scanned". Propagating "exist" to all generations
64  // ########################################################################
65  if(VERB > 2) cout << hd_msg << " Mapping Physical Detector..." << endl << endl;
66 
67  for(map<string, detector>::iterator i = hallMap->begin(); i!=hallMap->end(); i++)
68  {
69  if(VERB > 3) cout << hd_msg << " Scanning Detector " << i->first << " - existance: " << i->second.exist << endl;
70 
71  // Find the mother up to "root" - disable kid if ancestor does not exist
72  detector mother = findDetector(i->second.mother);
73 
74  while(mother.name != "akasha" && mother.name != "notfound")
75  {
76  if(mother.exist == 0)
77  {
78  if(VERB > 2) cout << hd_msg << "\t" << i->second.mother << " is not activated. Its child " << i->second.name
79  << " will be disactivated as well." << endl;
80  i->second.exist = 0;
81  }
82  mother = findDetector(mother.mother);
83  }
84  if(i->first != "root") i->second.scanned = 0;
85 
86  // scanning for replica, replicants physical volumes are not built
87  if(i->second.type.find("ReplicaOf:") != string::npos)
88  {
89  stringstream ops;
90  string operands(i->second.type, 10, i->second.type.size());
91  ops << operands;
92  string original;
93  ops >> original;
94 
95  replicants.insert(original);
96  }
97 
98  }
99 
100 
101  // ########################################################################
102  // Building Solids, Logical Volumes, Physical Volumes from the detector Map
103  // ########################################################################
104  vector<string> relatives;
105  string mom, kid;
106 
107  vector<string> regions; // all volumes for which mom is "root"
108 
109  for( map<string, detector>::iterator i = hallMap->begin(); i!=hallMap->end(); i++)
110  {
111  // don't build anything if the exist flag is not set
112  if(i->second.exist == 0) continue;
113 
114  // put the first volume in relatives
115  // typically it's the first in alphabetical order
116  if(i->first != "root") relatives.push_back(i->second.name);
117 
118  while(relatives.size() > 0)
119  {
120  detector kid = findDetector(relatives.back());
121  detector mom = findDetector(kid.mother);
122 
123  // if the mother system is different than the kid system
124  // then the kid will define a new region
125  if(mom.system != kid.system && kid.material != "Component")
126  regions.push_back(kid.name);
127 
128 
129  // Mom doesn't exists in the hallMap. Stopping everything.
130  if(mom.name != "akasha" && mom.name == "notfound")
131  {
132  cout << hd_msg << " Mom was not found for <" << relatives.back() << ">. "
133  << " We have a No Child Left Behind policy. Exiting. " << endl << endl;
134  exit(0);
135  }
136 
137  // output the Geneaology
138  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
139  {
140  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
141  cout << hd_msg << " Checking " << kid.name << ", child of " << mom.name
142  << ", for a living ancestor. "
143  << " This Geneaology Depth is " << relatives.size() << "." << endl;
144  }
145 
146  // Mom is built, kid not built yet.
147  if(kid.scanned == 0 && mom.scanned == 1)
148  {
149  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
150  {
151  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
152  cout << hd_msg << " Found: " << kid.name
153  << " is not built yet but its mommie " << mom.name << " is."
154  << " Building " << kid.name << " of type: " << kid.type << "..." << endl;
155  }
156 
157  // Check kid dependency on copies
158  if(kid.type.find("CopyOf") == 0)
159  {
160 
161  stringstream ops;
162  string operands(kid.type, 6, kid.type.size());
163  ops << operands;
164  string original;
165  ops >> original;
166 
167  detector dorig = findDetector(original);
168  // if dependency is not built yet, then
169  // add it to the relative list
170  if(dorig.scanned == 0)
171  {
172  relatives.push_back(original);
173  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
174  {
175  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
176  cout << hd_msg << kid.name << " is copied volume. "
177  << " Must build: " << original << " first " << endl;
178  }
179  }
180  // otherwise can build the kid
181  else
182  {
183  buildDetector(kid.name);
184  kid.scanned = 1;
185  }
186  }
187 
188  // Check kid dependency on replicas
189  if(kid.type.find("ReplicaOf:") == 0)
190  {
191 
192  stringstream ops;
193  string operands(kid.type, 10, kid.type.size());
194  ops << operands;
195  string original;
196  ops >> original;
197 
198  detector dorig = findDetector(original);
199  // if dependency is not built yet, then
200  // add it to the relative list
201  if(dorig.scanned == 0)
202  {
203  relatives.push_back(TrimSpaces(original));
204 
205  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
206  {
207  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
208  cout << hd_msg << kid.name << " is a replica volume of " << original
209  << ". Must build: " << original << " first " << endl;
210  }
211  }
212  // otherwise can build the kid
213  else
214  {
215  buildDetector(kid.name);
216  kid.scanned = 1;
217  }
218  }
219 
220 
221 
222  // Check kid dependency on operations
223  else if(kid.type.find("Operation:") == 0)
224  {
225  int sstart = 10;
226  if(kid.type.find("Operation:~") == 0 || kid.type.find("Operation:@") == 0 ) sstart = 11;
227 
228  string operation(kid.type, sstart, kid.type.size());
229  vector<string> operands = get_strings(replaceCharWithChars(operation, "-+*/", " "));
230  string firstop = operands[0];
231  string secondop = operands[1];
232 
233  // if dependency is not built yet, then
234  // add it to the relative list
235  detector dsecondop = findDetector(secondop);
236  if(dsecondop.scanned == 0)
237  {
238  relatives.push_back(secondop);
239  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
240  {
241  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
242  cout << hd_msg << kid.name << " is the result of an operation. "
243  << " Must build: " << secondop << " first " << endl;
244  }
245  }
246  detector dfirstop = findDetector(firstop);
247  if(dfirstop.scanned == 0)
248  {
249  relatives.push_back(firstop);
250  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
251  {
252  for(unsigned int ir=0; ir<relatives.size()-1; ir++) cout << "\t";
253  cout << hd_msg << kid.name << " is the result of an operation. "
254  << " Must build: " << firstop << " first " << endl;
255  }
256  }
257  // otherwise can build the kid
258  else if(dsecondop.scanned == 1 && dfirstop.scanned == 1)
259  {
260  buildDetector(kid.name);
261  kid.scanned = 1;
262  }
263  }
264  // no dependencies found, build the kid
265  else
266  {
267  buildDetector(kid.name);
268  kid.scanned = 1;
269  }
270  }
271 
272  // if the kid still doesn't exists and its mom doesn't exist.
273  // adding mom to the relatives list
274  if(kid.scanned == 0 && mom.scanned == 0)
275  {
276  relatives.push_back(kid.mother);
277  }
278 
279  // the kid has been built. Can go down one step in geneaology
280  if(kid.scanned == 1 && relatives.size())
281  {
282  if(VERB > 3 || kid.name.find(catch_v) != string::npos)
283  cout << hd_msg << " " << kid << " is built." << endl << endl;
284 
285  relatives.pop_back();
286  }
287  }
288  }
289 
290  // build mirrors
291  buildMirrors();
292 
293 
294  // assign regions
295  // includes root
296  regions.push_back("root");
297  assignRegions(regions);
298 
299 
300  return (*hallMap)["root"].GetPhysical();
301 }
302 
303 #include "G4UserLimits.hh"
304 
306 {
307  string hd_msg = gemcOpt.optMap["LOG_MSG"].args + " Sensitivity: >> ";
308  double VERB = gemcOpt.optMap["HIT_VERBOSITY"].arg ;
309  string catch_v = gemcOpt.optMap["CATCH"].args;
310 
311  string sensi = detect.sensitivity;
312 
313  if(sensi != "no" && sensi.find("mirror:") == string::npos)
314  {
315  G4SDManager* SDman = G4SDManager::GetSDMpointer();
316  if (!SDman) throw "Can't get G4SDManager";
317 
318  if(VERB > 5 || detect.name.find(catch_v) != string::npos)
319  cout << hd_msg << " " << detect.name << " has assigned sensitivity: " << sensi << endl;
320 
321  // The key for the SD, Region, PC maps is the same so we can only check SD
322  map<string, sensitiveDetector*>::iterator itr = SeDe_Map.find(sensi);
323  // if not found, add new sensitive detector
324  if(itr == SeDe_Map.end())
325  {
326  if(VERB > 3 || detect.name.find(catch_v) != string::npos)
327  cout << endl << hd_msg << " Sensitive detector <" << sensi
328  << "> doesn't exist yet. Adding <" << sensi << ">. " << endl;
329 
330  // passing detector infos to access factory, runMin, runMax and variation
331  SeDe_Map[sensi] = new sensitiveDetector(sensi, gemcOpt, detect.factory, detect.run, detect.variation, detect.system);
332 
333  // Pass Detector Map Pointer to Sensitive Detector
334  SeDe_Map[sensi]->hallMap = hallMap;
335 
336  SDman->AddNewDetector( SeDe_Map[sensi]);
337  }
338  detect.setSensitivity(SeDe_Map[sensi]);
339 
340  // Setting Max Acceptable Step for this SD
341  detect.SetUserLimits(new G4UserLimits(SeDe_Map[sensi]->SDID.maxStep, SeDe_Map[sensi]->SDID.maxStep));
342  }
343 }
344 
345 
347 {
348  string hd_msg = gemcOpt.optMap["LOG_MSG"].args + " Magnetic Field: >> ";
349  double verbosity = gemcOpt.optMap["FIELD_VERBOSITY"].arg ;
350  string catch_v = gemcOpt.optMap["CATCH"].args;
351  string field = gemcOpt.optMap["NO_FIELD"].args;
352 
353  if(field == "all" || detect.name.find(field) != string::npos)
354  return;
355 
356  string magf = detect.magfield;
357 
358  if(magf != "no")
359  {
360  map<string, gfield>::iterator itr = fieldsMap->find(magf);
361 
362  if(itr == fieldsMap->end())
363  {
364  cout << hd_msg << " Electro-Magnetic Field <" << magf
365  << "> is not defined. Exiting." << endl;
366  exit(0);
367  }
368 
369  activeFields.insert(magf);
370  detect.AssignMFM(itr->second.get_MFM());
371 
372  if(verbosity > 1 || detect.name.find(catch_v) != string::npos)
373  cout << hd_msg << " Field <" << magf << "> is built and assigned to " << detect.name << "." << endl;
374  }
375 }
376 
377 
379 {
380  cout << "Updating geometry... " << endl;
381  G4RunManager::GetRunManager()->GeometryHasBeenModified();
382 }
383 
384 detector MDetectorConstruction::findDetector(string name)
385 {
386  map<string, detector>::iterator it = hallMap->find(name);
387  if(it != hallMap->end())
388  return it->second;
389 
390  detector notfound;
391  notfound.name = "notfound";
392 
393  return notfound;
394 }
395 
396 void MDetectorConstruction::buildDetector(string name)
397 {
398  detector kid = findDetector(name);
399  detector mom = findDetector(kid.mother);
400 
401  if(kid.name != "notfound" || mom.name != "notfound")
402  {
403 
404  // handling replicas
405  if(kid.type.find("ReplicaOf:") == 0)
406  {
407  // get the replicant detector
408  stringstream ops;
409  string operands(kid.type, 10, kid.type.size());
410  ops << operands;
411  string repName;
412  ops >> repName;
413 
414  detector rep = findDetector(repName);
415 
416  if(rep.name != "notfound" )
417  {
418  // creating the replicas volume
419  (*hallMap)[kid.name].create_replicas(gemcOpt, mom.GetLogical(), rep);
420  }
421  else
422  {
423  cout << " Attention: " << kid.name << " not found. " << endl;
424  }
425  }
426  else
427  {
428  (*hallMap)[kid.name].create_solid(gemcOpt, hallMap);
429 
430  // creating logical volume
431  if((*hallMap)[kid.name].create_logical_volume(mats, gemcOpt))
432  {
433 
434  // creating physical volume unless it is in the replicant set
435  if(replicants.find(kid.name) == replicants.end())
436  (*hallMap)[kid.name].create_physical_volumes(gemcOpt, mom.GetLogical());
437 
438 
439  isSensitive((*hallMap)[kid.name]); // if sensitive, associate sensitive detector
440  hasMagfield((*hallMap)[kid.name]); // if it has magnetic field, create or use MFM
441  }
442  (*hallMap)[kid.name].scanned = 1;
443  }
444  }
445 
446  if(kid.name == "notfound")
447  cout << " Attention: " << kid.name << " not found. " << endl;
448  if(mom.name == "notfound" )
449  cout << " Attention: " << mom.name << " not found. " << endl;
450 }
451 
452 
454 {
455  string hd_msg = gemcOpt.optMap["LOG_MSG"].args + " Mirrors: >> ";
456  double VERB = gemcOpt.optMap["MIRROR_VERBOSITY"].arg ;
457  string catch_v = gemcOpt.optMap["CATCH"].args;
458 
459  vector<G4OpticalSurface*> mirrorSurfaces;
460  vector<G4MaterialPropertiesTable*> mirrorsMPT;
461  vector<G4LogicalBorderSurface*> mirrorLBorderSurf;
462  vector<G4LogicalSkinSurface*> mirrorLSkinSurf;
463 
464  for( map<string, detector>::iterator it = hallMap->begin(); it != hallMap->end(); it++)
465  {
466  string name = it->first;
467 
468  string mirrorString = "no";
469  if(it->second.sensitivity.find("mirror:") != string::npos)
470  {
471  vector<string> mmirror = get_strings(it->second.sensitivity);
472  if(mmirror.size() == 2)
473  mirrorString = mmirror[1];
474  }
475 
476  if(mirrorString != "no")
477  {
478  if(VERB > 5 || name.find(catch_v) != string::npos)
479  cout << hd_msg << " " << name << " has assigned mirror: " << mirrorString << endl;
480 
481  map<string, mirror*>::iterator itr = mirs->find(mirrorString);
482 
483  // must find the mirror in the mirror map
484  if(itr != mirs->end())
485  {
486  if(VERB > 3 || name.find(catch_v) != string::npos)
487  cout << endl << hd_msg << " Mirror <" << mirrorString << "> found for " << name << "." << endl;
488 
489  // checking that the border volume exist
490  // for non SkinSurface types
491  string borderv = itr->second->border;
492  string mirrorSurf = "mirrorBorderSurface_for_" + name + "_and_" + borderv;
493 
494  if(!(*hallMap)[borderv].GetPhysical() && borderv != "SkinSurface")
495  {
496  cout << hd_msg << " !! Error: border volume " << borderv << " is not found for volume " << name << ". Exiting." << endl;
497  exit(0);
498  }
499 
500  else if(borderv == "SkinSurface")
501  {
502  mirrorSurf = "mirrorSkinSurface_for_" + name;
503  }
504 
505  mirrorSurfaces.push_back(new G4OpticalSurface(mirrorSurf));
506 
507  // If a material was given for this interface,
508  // AND a material properties table has been defined for said mirror,
509  // use this instead of a new table!
510 
511  string maptOptProps = itr->second->maptOptProps;
512  if( maptOptProps != "notDefined" && ( (*mats)[maptOptProps] )->GetMaterialPropertiesTable() )
513  {
514  mirrorsMPT.push_back( ( (*mats)[maptOptProps] )->GetMaterialPropertiesTable() );
515  }
516  else
517  {
518  mirrorsMPT.push_back(new G4MaterialPropertiesTable());
519 
520  vector<double> photonEnergy = itr->second->photonEnergy;
521  if(photonEnergy.size())
522  {
523  vector<double> indexOfRefraction = itr->second->indexOfRefraction;
524  vector<double> reflectivity = itr->second->reflectivity;
525  vector<double> efficiency = itr->second->efficiency;
526  vector<double> specularlobe = itr->second->specularlobe;
527  vector<double> specularspike = itr->second->specularspike;
528  vector<double> backscatter = itr->second->backscatter;
529 
530  // array size must be the same for all
531  // properties by construction, assured by the API
532  unsigned peneSize = photonEnergy.size();
533 
534  G4double pene[peneSize];
535  G4double var[peneSize];
536 
537  for(unsigned i=0; i<peneSize; i++)
538  pene[i] = photonEnergy[i];
539 
540  if(indexOfRefraction.size())
541  {
542  for(unsigned i=0; i<peneSize; i++) var[i] = indexOfRefraction[i];
543  mirrorsMPT.back()->AddProperty("RINDEX", pene, var, peneSize);
544  }
545  if(reflectivity.size())
546  {
547  for(unsigned i=0; i<peneSize; i++) var[i] = reflectivity[i];
548  mirrorsMPT.back()->AddProperty("REFLECTIVITY", pene, var, peneSize);
549  }
550  if(efficiency.size())
551  {
552  for(unsigned i=0; i<peneSize; i++) var[i] = efficiency[i];
553  mirrorsMPT.back()->AddProperty("EFFICIENCY", pene, var, peneSize);
554  }
555  if(specularlobe.size())
556  {
557  for(unsigned i=0; i<peneSize; i++)var[i] = specularlobe[i];
558  mirrorsMPT.back()->AddProperty("SPECULARLOBECONSTANT", pene, var, peneSize);
559  }
560  if(specularspike.size())
561  {
562  for(unsigned i=0; i<peneSize; i++)var[i] = specularspike[i];
563  mirrorsMPT.back()->AddProperty("SPECULARSPIKECONSTANT", pene, var, peneSize);
564  }
565  if(backscatter.size())
566  {
567  for(unsigned i=0; i<peneSize; i++)var[i] = backscatter[i];
568  mirrorsMPT.back()->AddProperty("BACKSCATTERCONSTANT", pene, var, peneSize);
569  }
570  }
571  else
572  {
573  cout << " !! Fatal error: no optical property material, and no optical properties for mirror "
574  << itr->second->name << endl;
575  exit(0);
576  }
577  }
578  mirrorSurfaces.back()->SetMaterialPropertiesTable(mirrorsMPT.back());
579 
580  // surface type
581  string surfaceType = itr->second->type;
582  if(surfaceType == "dielectric_metal") mirrorSurfaces.back()->SetType(dielectric_metal);
583  if(surfaceType == "dielectric_dielectric") mirrorSurfaces.back()->SetType(dielectric_dielectric);
584  if(surfaceType == "dielectric_LUT") mirrorSurfaces.back()->SetType(dielectric_LUT);
585 
586  // surface finish
587  string surfaceFinish = itr->second->finish;
588  if(surfaceFinish == "polished") mirrorSurfaces.back()->SetFinish(polished); // smooth perfectly polished surface
589  if(surfaceFinish == "polishedfrontpainted") mirrorSurfaces.back()->SetFinish(polishedfrontpainted); // smooth top-layer (front) paint
590  if(surfaceFinish == "polishedbackpainted") mirrorSurfaces.back()->SetFinish(polishedbackpainted); // same is 'polished' but with a back-paint
591 
592  if(surfaceFinish == "ground") mirrorSurfaces.back()->SetFinish(ground); // rough surface
593  if(surfaceFinish == "groundfrontpainted") mirrorSurfaces.back()->SetFinish(groundfrontpainted); // rough top-layer (front) paint
594  if(surfaceFinish == "groundbackpainted") mirrorSurfaces.back()->SetFinish(groundbackpainted); // same as 'ground' but with a back-paint
595 
596 
597  if(surfaceFinish == "polishedlumirrorair") mirrorSurfaces.back()->SetFinish(polishedlumirrorair); // mechanically polished surface, with lumirror
598  if(surfaceFinish == "polishedlumirrorglue") mirrorSurfaces.back()->SetFinish(polishedlumirrorglue); // mechanically polished surface, with lumirror & meltmount
599 
600 
601  // surface model
602  string surfaceModel = itr->second->model;
603  if(surfaceModel == "glisur") mirrorSurfaces.back()->SetModel(glisur); // original GEANT3 model
604  if(surfaceModel == "unified") mirrorSurfaces.back()->SetModel(unified); // UNIFIED model
605  if(surfaceModel == "LUT") mirrorSurfaces.back()->SetModel(LUT); // Look-Up-Table model
606 
607 
608  if(borderv=="SkinSurface")
609  {
610  mirrorLSkinSurf.push_back(new G4LogicalSkinSurface(name,
611  (*hallMap)[name].GetLogical(), mirrorSurfaces.back()));
612  }
613  else
614  {
615 
616  mirrorLBorderSurf.push_back(new G4LogicalBorderSurface(name,
617  (*hallMap)[borderv].GetPhysical(),
618  (*hallMap)[name].GetPhysical(), mirrorSurfaces.back()));
619  }
620 
621 
622  if(VERB > 3 || name.find(catch_v) != string::npos)
623  {
624  cout << hd_msg << " " << name << " is a mirror:" << endl;
625  cout << " > Border Volume: " << borderv << endl;
626  cout << " > Surface Type: " << surfaceType << endl;
627  cout << " > Finish: " << surfaceFinish << endl;
628  cout << " > Model: " << surfaceModel << endl;
629 
630  // why it's not dumping all properties?
631  mirrorsMPT.back()->DumpTable();
632  }
633  }
634  else
635  {
636  cout << " !! Fatal error: mirror <" << mirrorString << "> not found for " << it->second.name << "." << endl;
637  exit(0);
638 
639  }
640  }
641  }
642 }
643 
644 void MDetectorConstruction::assignRegions(vector<string> volumes)
645 {
646  double VERB = gemcOpt.optMap["HIT_VERBOSITY"].arg ;
647 
648  for(unsigned int i=0; i<volumes.size(); i++)
649  {
650  // looking in the sensitive detector map for the SD with matching system
651  for(map<string, sensitiveDetector*>::iterator itr = SeDe_Map.begin(); itr != SeDe_Map.end(); itr++)
652  {
653  detector regionDet = findDetector(volumes[i]);
654 
655  if(regionDet.system == itr->second->SDID.system)
656  {
657 
658  // region name is volume + system
659  string regionName = volumes[i] + "_" + get_info(regionDet.system, "/").back();
660 
661 
662  map<string, G4Region*>::iterator itrr = SeRe_Map.find(regionName);
663 
664  // if not found, add new region. Otherwise it's already there.
665  if(itrr == SeRe_Map.end())
666  {
667  // Creating G4 Region, assigning Production Cut to it.
668  // assigning the logical volume to the region (this will apply the region to all daughters)
669  SeRe_Map[regionName] = new G4Region(regionName);
670  SeRe_Map[regionName]->AddRootLogicalVolume(regionDet.GetLogical());
671 
672  SePC_Map[regionName] = new G4ProductionCuts;
673  SePC_Map[regionName] ->SetProductionCut(itr->second->SDID.prodThreshold);
674 
675  if(VERB > 3)
676  cout << " Region " << regionName << " activated for volume " << regionDet.name << " with range: " << itr->second->SDID.prodThreshold << endl;
677 
678  SeRe_Map[regionName]->SetProductionCuts(SePC_Map[regionName]);
679 
680  }
681  }
682  }
683  }
684 }
685 
686 
687 
688 
689 
690 
691 
692 
693 
694 
map< string, detector > buildDetector(map< string, detectorFactoryInMap > detectorFactoryMap, goptions go, runConditions rc)
G4VPhysicalVolume * Construct()
vector< string > get_strings(string input)
returns a vector of strings from a stringstream, space is delimiter
G4LogicalVolume * GetLogical()
Returns Logical Volume pointer.
Definition: detector.h:113
string sensitivity
Defines the Sensitive Detector. possible choices: "no" "hits collection name".
Definition: detector.h:89
string mother
Mother Volume name.
Definition: detector.h:68
void AssignMFM(G4FieldManager *MFM)
Assigns Magnetic Field Manager to LogicV.
Definition: detector.h:118
int run
run number that generated the detector
Definition: detector.h:98
double verbosity
STL namespace.
vector< string > get_info(string input, string chars)
get information from strings such as "5*GeV, 2*deg, 10*deg", parses out strings in second argument ...
map< string, mirror * > buildMirrors(map< string, mirrorFactory > mirrorFactoryMap, goptions go, runConditions rc)
string system
detector system
Definition: detector.h:95
string replaceCharWithChars(string input, string x, string y)
string factory
factory that generated the detector
Definition: detector.h:96
string name
Name of the volume. Since this is the key of the STL map, it has to be unique.
Definition: detector.h:67
string material
Volume Material name.
Definition: detector.h:79
void SetUserLimits(G4UserLimits *L)
Definition: detector.h:120
string magfield
Magnetic Field. The string "no" means that the field is inherited from the mother volume...
Definition: detector.h:80
int exist
detector ON/OFF switch
Definition: detector.h:85
string type
solid type. This follows the GEANT4 definitions
Definition: detector.h:76
string TrimSpaces(string in)
Removes leading and trailing spaces.
int scanned
for use during construction
Definition: detector.h:93
string variation
variation that generated the detector
Definition: detector.h:97
MDetectorConstruction(goptions Opts)
void setSensitivity(G4VSensitiveDetector *SD)
Assign the sensitive detector to the Logical Volume.
Definition: detector.h:110