224
238
return _detector->GetField();
227
void MAUSGeant4Manager::SetAuxInformation(MiceModule& module) {
241
void MAUSGeant4Manager::SetVolumeInformation(MiceModule& module, G4LogicalVolume* base) {
243
// G4VPhysicalVolume* world = _parser.GetWorldVolume();
244
G4int nDaughters = base->GetNoDaughters();
245
for ( int i = 0; i < nDaughters; i++ ) {
246
G4VPhysicalVolume* daughter = base->GetDaughter(i);
247
G4LogicalVolume* myvol = daughter->GetLogicalVolume();
248
// first check if there are auxiliary objects
249
const G4GDMLAuxListType auxlist = _parser.GetVolumeAuxiliaryInformation(myvol);
251
// Squeak::mout(Squeak::info) << "Found volume " << myvol->GetName()
252
// << " with "<< auxlist.size() <<" auxiliary elements." << std::endl;
253
if (auxlist.size() > 0) {
254
// Set auxiliary information
255
SetAuxInformation(module, myvol, auxlist);
258
// _detector->GetUserLimits().push_back(new G4UserLimits(_stepMax, _trackMax,
259
// _timeMax, _keThreshold));
260
// myvol->SetUserLimits(_detector->GetUserLimits().back());
262
if ( myvol->GetNoDaughters() > 0 ) {
263
// Consider adding information to the daughter volumes
264
SetVolumeInformation(module, myvol);
269
void MAUSGeant4Manager::SetSteppingLimits(G4LogicalVolume* myvol) {
271
double stepMax = _stepMax;
272
double timeMax = _timeMax;
273
double trackMax = _trackMax;
274
double keThreshold = _keThreshold;
280
// Squeak::mout(Squeak::info) << "Defining user limits for " << myvol->GetName() << std::endl;
281
_detector->GetUserLimits().push_back(new G4UserLimits(stepMax, trackMax,
282
timeMax, keThreshold));
283
// Squeak::mout(Squeak::info) << "Setting user limits for " << myvol->GetName() << std::endl;
284
myvol->SetUserLimits(_detector->GetUserLimits().back());
286
_detector->GetVisAttributes().push_back(new G4VisAttributes(G4Color(red, green, blue)));
288
_detector->GetVisAttributes().push_back(new G4VisAttributes(false));
289
myvol->SetVisAttributes(_detector->GetVisAttributes().back());
290
// Squeak::mout(Squeak::info) << "Limits set for " << myvol->GetName() << std::endl;
293
void MAUSGeant4Manager::SetAuxInformation(MiceModule& module, G4LogicalVolume* myvol,
294
const G4GDMLAuxListType auxlist) {
228
295
// Establish sensitive detectors using the SDmanager
229
296
// Get the map of the auxiliary information from the parser
230
298
const G4GDMLAuxMapType* auxmap = _parser.GetAuxMap();
231
299
Squeak::mout(Squeak::info) << "Found " << auxmap->size()
232
300
<< " volume(s) with auxiliary information.\n\n";
302
double stepMax = _stepMax;
303
double timeMax = _timeMax;
304
double trackMax = _trackMax;
305
double keThreshold = _keThreshold;
234
311
for (G4GDMLAuxMapType::const_iterator iter = auxmap->begin();
235
312
iter != auxmap->end(); iter++) {
236
313
// Construct a mice module containing the auxilliary information
237
314
G4LogicalVolume* myvol = (*iter).first;
238
// Want to know, specifically if there is a sensitive detector in this object
239
for (G4GDMLAuxListType::const_iterator vit = (*iter).second.begin();
240
vit != (*iter).second.end(); vit++) {
315
Squeak::mout(Squeak::info) << "Checking aux map of volume "
316
<< myvol->GetName() << std::endl;
318
// Define sensitive detectors etc.
319
bool sensdet = false;
320
std::string sensdetname = "";
321
G4GDMLAuxListType::const_iterator vit = auxlist.begin();
322
// Want to know, specifically, if there is a sensitive detector in this object
323
// but there will be other information of interest
324
// for (int i=0; i < auxlist.size(); i++){
241
327
if ((*vit).type.contains("SensitiveDetector")) {
242
// Find the module corresponding to the volume name
243
std::vector<const MiceModule*> mods =
244
module.findModulesByPropertyString((*vit).type, (*vit).value);
245
// Squeak::mout(Squeak::info)<<"Search for detector "<<(*vit).value
246
// <<" with name "<<myvol->GetName()<<": "
247
// <<mods.size()<<" candidates\n";
248
for (unsigned i = 0; i < mods.size(); i++) {
249
// This is kind of a double check now to make
250
// sure that this is the same object.
252
if (mods.at(i)->name() == myvol->GetName()) {
253
// propertyExists("SensitiveDetector","PropertyString")){
254
// Make a copy of the module to remove the const cast
255
MiceModule* tempmod = MiceModule::deepCopy(*mods[i], false);
256
// tempmod->printThis(Squeak::mout(Squeak::info));
257
_detector->SetUserLimits(myvol, tempmod);
258
_detector->SetVisAttributes(myvol, tempmod);
259
_detector->BuildSensitiveDetector(myvol, tempmod);
260
_detector->AddToRegion(myvol, tempmod);
261
// Now loop over all daughters to add them to the sensitive volumes
262
if ((*vit).value == "SciFi" || (*vit).value == "KL") {
263
if (myvol->GetNoDaughters() > 0) {
264
SetDaughterSensitiveDetectors(myvol);
329
sensdetname = (*vit).value;
330
} else if ((*vit).type.contains("G4StepMax")) {
331
stepMax = atof((*vit).value.c_str());
333
} else if ((*vit).type.contains("G4TrackMax")) {
334
trackMax = atof((*vit).value.c_str());
335
} else if ((*vit).type.contains("G4TimeMax")) {
336
timeMax = atof((*vit).value.c_str());
337
} else if ((*vit).type.contains("G4KinMin")) {
338
keThreshold = atof((*vit).value.c_str());
339
} else if ((*vit).type.contains("Region")) {
340
std::string name = (*vit).value;
341
G4RegionStore* store = G4RegionStore::GetInstance();
342
if (store->GetRegion(name) == NULL) {
344
_detector->GetRegions().push_back(name);
346
G4Region* region = store->GetRegion(name);
347
if (region == NULL) {
348
throw MAUS::Exception(Exception::recoverable,
349
"Failed to make region",
350
"MAUSgeant4Manager::SetAuxInformation");
352
region->AddRootLogicalVolume(myvol);
353
} else if ((*vit).type.contains("Invisible")) {
355
} else if ((*vit).type.contains("RedColor")) {
356
red = atof((*vit).value.c_str());
357
} else if ((*vit).type.contains("GreenColor")) {
358
green = atof((*vit).value.c_str());
359
} else if ((*vit).type.contains("BlueColor")) {
360
blue = atof((*vit).value.c_str());
362
// Don't really know what to do with this.
363
// Do nothing if selection is not otherwise known.
368
// Squeak::mout(Squeak::info) << "Found " << (*vit).type << " with value "
369
// << (*vit).value << " in object "
370
// << myvol->GetName() << "\n";
372
} while (vit != auxlist.end());
375
DefineSensitiveDetector(module, myvol, sensdetname);
377
_detector->GetUserLimits().push_back(new G4UserLimits(stepMax, trackMax,
378
timeMax, keThreshold));
379
// Squeak::mout(Squeak::info) << "User limits set for " << myvol->GetName()
380
// << " with max step " << stepMax << std::endl;
381
myvol->SetUserLimits(_detector->GetUserLimits().back());
382
// if (myvol->GetNoDaughters() > 0) {
383
// SetDaughterUserLimits(myvol);
387
_detector->GetVisAttributes().push_back(new G4VisAttributes(G4Color(red, green, blue)));
389
_detector->GetVisAttributes().push_back(new G4VisAttributes(false));
391
myvol->SetVisAttributes(_detector->GetVisAttributes().back());
393
// Squeak::mout(Squeak::info) << "Attributes set for volume "
394
// << myvol->GetName() << std::endl;
398
void MAUSGeant4Manager::DefineSensitiveDetector(MiceModule& module, G4LogicalVolume* myvol,
399
std::string sensdetname) {
400
// Find the module corresponding to the volume name
401
std::vector<const MiceModule*> mods =
402
module.findModulesByPropertyString("SensitiveDetector", sensdetname);
403
// Squeak::mout(Squeak::info) << "Search for detector " << sensdetname
404
// << " with name " << myvol->GetName() << ": "
405
// << mods.size() << " candidates\n";
406
bool moduleFound = false;
407
for ( unsigned i = 0; i < mods.size(); i++ ) {
408
// This is kind of a double check now to make
409
// sure that this is the same object.
410
// Squeak::mout(Squeak::info) << "Check module " << i << " named "
411
// << mods.at(i)->name() << std::endl;
412
if (mods.at(i)->name() == myvol->GetName()) {
414
// propertyExists("SensitiveDetector","PropertyString")){
415
// Make a copy of the module to remove the const cast
416
MiceModule* tempmod = MiceModule::deepCopy(*mods[i], false);
417
// tempmod->printThis(Squeak::mout(Squeak::info));
418
_detector->SetUserLimits(myvol, tempmod);
419
_detector->SetVisAttributes(myvol, tempmod);
420
_detector->BuildSensitiveDetector(myvol, tempmod);
421
_detector->AddToRegion(myvol, tempmod);
422
// Now loop over all daughters to add them to the sensitive volumes
423
if (sensdetname == "SciFi" || sensdetname == "KL") {
424
if (myvol->GetNoDaughters() > 0) {
425
SetDaughterSensitiveDetectors(myvol);
430
// Squeak::mout(Squeak::info) << "Module for " << myvol->GetName()
431
// << " found." << std::endl;
274
434
void MAUSGeant4Manager::SetDaughterSensitiveDetectors(G4LogicalVolume* logic) {
275
435
// std::cout << "Adding " << logic->GetNoDaughters()
276
// << " to sensitive detector in " << logic->GetName() << std::endl;
436
// << " to sensitive detector in " << logic->GetName() << std::endl;
278
438
for (G4int i = 0; i < logic->GetNoDaughters(); i++) {
279
439
logic->GetDaughter(i)->GetLogicalVolume()->