26 #include "TObjArray.h"
27 #include "TGeoVolume.h"
31 #include "TGeoManager.h"
32 #include "TGeoVoxelFinder.h"
33 #include "TGeoMatrix.h"
68 fMotherVolumeName(
""),
69 fgeoVer(
"Not defined"),
70 fgeoName(
"Not defined"),
77 fRootMaterialImportFlag(kFALSE),
89 fMotherVolumeName(
""),
90 fgeoVer(
"Not defined"),
91 fgeoName(
"Not defined"),
98 fRootMaterialImportFlag(kFALSE),
105 void FairModule::Streamer(TBuffer& b)
127 TString FileName = fname;
128 TString work = getenv(
"VMCWORKDIR");
129 TString userwork = getenv(
"GEOMPATH");
134 if (TString(gSystem->FindFile(
fgeoName.Data(),fname)) != TString(
"")) {
141 if (TString(gSystem->FindFile(
fgeoName.Data(),FileName)) != TString(
"")) {
157 TListIter iter(aList);
185 fNodes->AddLast( aVol );
236 TGeoManager* OldGeo=gGeoManager;
237 TGeoManager* NewGeo=0;
240 TList* l= f->GetListOfKeys();
245 while ((key = (TKey*)next())) {
250 if (strcmp(key->GetClassName(),
"TGeoManager") != 0) {
continue; }
252 NewGeo = (TGeoManager*)key->ReadObj();
260 volume=(TGeoVolume*)NewGeo->GetNode(0)->GetDaughter(0)->GetVolume();
261 v1=volume->MakeCopyVolume(volume->GetShape());
285 while ((qkey = (TKey*)qnext())) {
286 volume=
dynamic_cast<TGeoVolume*
> (qkey->ReadObj());
287 if (!volume)
continue;
289 n = volume->GetNode(0);
294 if (TString(n->GetName()).BeginsWith(GetName()))
298 std::cout << n->GetName() <<
" " << GetName() << std::endl;
312 TGeoVolume* Cave=NULL;
314 Cave= gGeoManager->GetTopVolume();
320 gGeoManager->AddVolume(v1);
322 TGeoVoxelFinder* voxels = v1->GetVoxels();
323 if (voxels) { voxels->SetNeedRebuild(); }
330 TGeoMatrix*
M = n->GetMatrix();
334 gGeoManager->GetListOfMatrices()->Remove(M);
335 TGeoHMatrix* global = gGeoManager->GetHMatrix();
336 gGeoManager->GetListOfMatrices()->Remove(global);
338 Cave->AddNode(v1,0, M);
345 if(NewGeo!=0) {
delete NewGeo; }
348 fLogger->
Fatal(
MESSAGE_ORIGIN,
"\033[5m\033[31mFairModule::ConstructRootGeometry(): could not find the given mother volume \033[0m %s \033[5m\033[31m where the geomanger should be added. \033[0m",
fMotherVolumeName.Data());
367 TGeoMatrix* Matrix =fN->GetMatrix();
368 if(gGeoManager->GetListOfMatrices()->FindObject(Matrix)) { gGeoManager->GetListOfMatrices()->Remove(Matrix); }
369 TGeoVolume*
v1=fN->GetVolume();
371 for (Int_t Nod=0; Nod<NodeList->GetEntriesFast(); Nod++) {
372 TGeoNode* fNode =(TGeoNode*)NodeList->At(Nod);
373 TGeoMatrix*
M =fNode->GetMatrix();
376 TGeoVolume*
v= fNode->GetVolume();
392 if(fNode->GetNdaughters()>0) {
ExpandNode(fNode); }
394 if (!gGeoManager->FindVolumeFast(v->GetName())) {
396 v->RegisterYourself();
417 if (!gGeoManager) {
return; }
418 if (strlen(matrix->GetName())) {
return; }
420 if (matrix->IsTranslation()) { type =
't'; }
421 if (matrix->IsRotation()) { type =
'r'; }
422 if (matrix->IsScale()) { type =
's'; }
423 if (matrix->IsCombi()) { type =
'c'; }
424 if (matrix->IsGeneral()) { type =
'g'; }
425 TObjArray* matrices = gGeoManager->GetListOfMatrices();
427 if (matrices) { index =matrices->GetEntriesFast() - 1; }
428 matrix->SetName(Form(
"%c%i", type, index));
443 TGeoMedium* med1=v->GetMedium();
444 if(med1 && strcmp(med1->GetName(),
"dummy")) {
445 TGeoMaterial* mat1=v->GetMaterial();
450 TGeoMaterial* newMat = gGeoManager->GetMaterial(mat1->GetName());
452 TGeoMaterial* newMat = gGeoManager->GetMaterial(med1->GetName());
471 for(
unsigned iq=0; iq<mat1->GetNelements(); iq++) {
474 mat1->GetElementProp(a, z, w, iq);
486 for(
unsigned iq=0; iq<8; iq++)
487 params[iq] = med1->GetParam(iq);
489 FairMedium->
fldFlag = params[1];
490 FairMedium->
fld = params[2];
491 FairMedium->
madfld = params[3];
492 FairMedium->
maxstep = params[4];
493 FairMedium->
maxde = params[5];
494 FairMedium->
epsil = params[6];
495 FairMedium->
minstep = params[7];
506 v->SetMedium(gGeoManager->GetMedium(nmed));
507 gGeoManager->SetAllIndex();
511 TGeoMedium* med2= gGeoManager->GetMedium(mat1->GetName());
513 TGeoMedium* med2= gGeoManager->GetMedium(med1->GetName());
518 if (strcmp(v->ClassName(),
"TGeoVolumeAssembly") != 0) {
520 fLogger->
Fatal(
MESSAGE_ORIGIN,
"The volume %s Has no medium information and not an Assembly so we have to quit", v->GetName());