21 #include <TRealData.h>
22 #include <TDataMember.h>
25 #include "BaseVGM/volumes/VFactory.h"
26 #include "VGM/volumes/IPlacement.h"
27 #include "Geant4GM/volumes/Factory.h"
28 #include "RootGM/volumes/Factory.h"
33 #include <EicGeoParData.h>
36 #include "G4Material.hh"
37 #include "G4PVPlacement.hh"
38 #include "G4LogicalVolume.hh"
39 #include "G4ThreeVector.hh"
40 #include "G4VisAttributes.hh"
58 char user[128], host[128];
60 getlogin_r(user, 128-1);
61 gethostname(host, 128-1);
62 mAuthor = TString(user) +
"@" + host;
86 mVersion(version), mSubVersion(subVersion)
104 TString mediaFileName = TString(getenv(
"VMCWORKDIR")) +
"/geometry/media.geo";
111 mGeoFace->readMedia();
113 mFairMedia = mGeoFace->getMedia();
114 mGeobuild = mGeoLoad->getGeoBuilder();
122 mRootGeoManager =
new TGeoManager();
125 mWrapperVolume =
new TGeoVolumeAssembly(mDetName->Name() +
"GeantGeoWrapper");
126 mTopVolume =
new TGeoVolumeAssembly(mDetName->NAME());
128 mRootGeoManager->SetTopVolume(mWrapperVolume);
137 if (!fin.is_open()) {
138 printf(
"Media file '%s' does not exist!\n", fname);
187 void *pRot,
void *tlate)
196 #if defined(_ETM2GEANT_) && defined(_VGM_)
218 if (gGeoManager && gGeoManager->GetTopNode() && gGeoManager->GetTopNode()->GetVolume()->GetNode(0)) {
219 auto assembly = gGeoManager->GetTopNode()->GetVolume()->GetNode(0)->GetVolume();
221 for(
int iq=0; iq<assembly->GetNdaughters(); iq++) {
223 RootGM::Factory rtFactory;
224 Geant4GM::Factory g4Factory;
226 auto node = assembly->GetNode(iq);
229 rtFactory.Import(node);
230 rtFactory.Export(&g4Factory);
233 auto trans = rtFactory.Top()->Transformation();
236 G4ThreeVector
offset(trans[0], trans[1], trans[2]);
237 if (tlate) offset += *(G4ThreeVector*)tlate;
243 auto pvol =
new G4PVPlacement((G4RotationMatrix*)pRot, offset,
244 g4Factory.World()->GetLogicalVolume(),
245 node->GetName(), mother,
false, 0);
268 auto lvol = pvol->GetLogicalVolume();
280 G4VisAttributes* visAtt =
new G4VisAttributes();
285 auto rcolor = gROOT->GetColor(cpattern->second);
289 double transparency = tpattern ? (100-tpattern->second)/100. : 1.0;
290 visAtt->SetColor(rcolor->GetRed(), rcolor->GetGreen(), rcolor->GetBlue(), transparency);
291 visAtt->SetVisibility(
true);
292 visAtt->SetForceWireframe(
false);
293 visAtt->SetForceSolid(
true);
296 visAtt->SetVisibility(
false);
298 lvol->SetVisAttributes(visAtt);
301 for(
int iq=0; iq<lvol->GetNoDaughters(); iq++) {
302 auto daughter = lvol->GetDaughter(iq);
340 if (dim[iq])
max = iq;
345 for(
unsigned iq=0; iq<=
max; iq++)
375 const std::vector<LogicalVolumeGroupProjection*> &coords =
378 if (what >= coords.size() || !coords[what])
return -1;
380 coords[what]->mCircular =
true;
388 unsigned group,
unsigned logical[])
390 if (!map || !geo || !logical) {
391 printf(
"-E- EicGeoParData::SetMappingTableEntry(): zero pointer(s) used as arguments!\n");
396 printf(
"-E- EicGeoParData::SetMappingTableEntry(): group index '%d' exceeds '%d'!\n",
405 printf(
"-E- EicGeoParData::SetMappingTableEntry(): group index '%d' exceeds "
409 const std::vector<LogicalVolumeGroupProjection*> &coords =
412 for(
unsigned iq=0; iq<coords.size(); iq++) {
414 if (!logical[iq])
continue;
422 printf(
"-E- EicGeoParData::SetMappingTableEntry(): coordinate '%d' was not configured!\n", iq);
426 printf(
"-E- EicGeoParData::SetMappingTableEntry(): logical index #%d (%d) exceeds "
427 "max configured entry num (%d)!\n", iq, logical[iq], (
unsigned)coord->
mMaxEntryNum);
447 if (!fileName)
return;
449 FILE *fin = fopen(fileName,
"r");
451 printf(
"-E- SourceFile::SourceFile(): file '%s' does not exist!\n", fileName);
459 snprintf(buffer, 1024-1,
"%s", fileName);
465 fseek(fin, 0, SEEK_END);
466 mFileSize = ftell(fin);
468 mFileContent =
new UChar_t[mFileSize];
471 if (fread(mFileContent, 1, mFileSize, fin) == mFileSize)
474 delete [] mFileContent;
486 printf(
" --------------------");
487 for(
unsigned iq=0; iq<
mFileName.Length(); iq++)
507 printf(
"\n No file '%s' was attached!\n", fileName);
548 const char *suffix = root ?
".root" :
".gdml";
562 return TString(fileName);
572 char version[128] =
"";
588 assert(0);
return "";
605 while ((volume=(TGeoVolume*)next())) {
612 volume->SetLineColor(cpattern->second);
613 volume->SetFillColor(cpattern->second);
620 if (tpattern) volume->SetFillStyle(4000 + tpattern->second);
624 volume->SetVisibility(kFALSE);
663 const std::vector<LogicalVolumeGroupProjection*> &coords =
666 return (what < coords.size() && coords[what] ? coords[what]->mMaxEntryNum : 0);
673 unsigned group =
GetGroup(logicalID);
677 const std::vector<LogicalVolumeGroupProjection*> &coords =
680 if (what >= coords.size() || !coords[what])
return 0;
693 const std::vector<LogicalVolumeGroupProjection*> &coords =
696 if (what >= coords.size() || !coords[what])
return false;
698 return coords[what]->mCircular;
746 TString returnBackPath = gGeoManager->GetPath();
759 if (containerName.IsNull())
continue;
771 assert(cellLevel != -1);
774 if (cellLevel == -1)
continue;
796 snprintf(buffer, 128-1,
"%d", nID);
802 gGeoManager->cd(vPath);
803 TGeoNode *gNode = gGeoManager->GetCurrentNode();
811 node->
mGeoMtx =
new TGeoHMatrix(*gGeoManager->GetCurrentMatrix());
818 gGeoManager->cd(returnBackPath);
870 unsigned maxChebyshevDist)
const
884 if (!dim[iq])
continue;
886 UInt_t dist =
abs(x2[iq] - x1[iq]);
891 UInt_t cdist = dim[iq] - dist;
892 if (cdist < dist) dist = cdist;
898 if (dist > maxLinearDist)
return false;
901 if (maxChebyshevDist)
903 distChebyshev += dist;
908 if (distChebyshev > maxChebyshevDist)
return false;
921 printf(
"\nClass name: %s (v.%d); object name: %s\n\n",
922 ClassName(), Class()->GetClassVersion(), GetName());
937 TList *dataList = gROOT->GetClass(ClassName())->GetListOfRealData();
938 TIter next(dataList);
941 printf(
" Basic type variables:\n");
942 printf(
" ---------------------\n\n");
945 while ((data=(TRealData*)next())) {
946 TDataMember *member = data->GetDataMember();
949 if (!member->IsPersistent())
continue;
952 if (!member->IsBasic())
continue;
955 if (!strcmp(data->GetName(),
"fUniqueID") || !strcmp(data->GetName(),
"fBits"))
continue;
956 if (!strcmp(data->GetName(),
"mVersion") || !strcmp(data->GetName(),
"mSubVersion"))
continue;
957 if (!strcmp(data->GetName(),
"mTimeStamp.fSec") ||
958 !strcmp(data->GetName(),
"mTimeStamp.fNanoSec"))
961 printf(
"%-30s (%-10s):", data->GetName(), member->GetFullTypeName());
963 Long_t offset = member->GetOffset();
965 if (!strcmp(member->GetFullTypeName(),
"Double_t"))
966 printf(
" %f\n", *(Double_t*)((
char*)
this + offset));
967 else if (!strcmp(member->GetFullTypeName(),
"Int_t"))
968 printf(
" %d\n", *(Int_t*)((
char*)
this + offset));
969 else if (!strcmp(member->GetFullTypeName(),
"UInt_t"))
970 printf(
" %u\n", *(UInt_t*)((
char*)
this + offset));
971 else if (!strcmp(member->GetFullTypeName(),
"Bool_t"))
972 printf(
" %s\n", *(Bool_t*)((
char*)
this + offset) ?
"true" :
"false");
980 double xlocal[3] = {local.X(), local.Y(), local.Z()}, xmaster[3];
982 mtx->LocalToMaster(xlocal, xmaster);
984 return TVector3(xmaster[0], xmaster[1], xmaster[2]);
991 double xlocal[3] = {local.X(), local.Y(), local.Z()}, xmaster[3];
993 mtx->LocalToMasterVect(xlocal, xmaster);
995 return TVector3(xmaster[0], xmaster[1], xmaster[2]);
1002 double xmaster[3] = {master.X(), master.Y(), master.Z()}, xlocal[3];
1004 mtx->MasterToLocal(xmaster, xlocal);
1006 return TVector3(xlocal[0], xlocal[1], xlocal[2]);
1013 double xmaster[3] = {master.X(), master.Y(), master.Z()}, xlocal[3];
1015 mtx->MasterToLocalVect(xmaster, xlocal);
1017 return TVector3(xlocal[0], xlocal[1], xlocal[2]);