39 #include <Inventor/nodes/SoSeparator.h>
40 #include <Inventor/nodes/SoSwitch.h>
41 #include <Inventor/events/SoKeyboardEvent.h>
42 #include <Inventor/nodes/SoPickStyle.h>
43 #include <Inventor/nodes/SoEventCallback.h>
44 #include <Inventor/nodes/SoCamera.h>
45 #include <Inventor/nodes/SoCylinder.h>
46 #include <Inventor/nodes/SoFont.h>
48 #include "GeoModelKernel/GeoVolumeCursor.h"
49 #include "GeoModelKernel/GeoPrintGraphAction.h"
67 #include "GeoModelKernel/GeoBox.h"
68 #include "GeoModelKernel/GeoCountVolAction.h"
69 #include "GeoModelKernel/GeoAccessVolumeAction.h"
70 #include "GeoModelDBManager/GMDBManager.h"
71 #include "GeoRead/GReadIn.h"
79 #endif // BUILDVP1LIGHT
86 #include <QHeaderView>
87 #include <QApplication>
89 #include <QMessageBox>
102 #ifndef BUILDVP1LIGHT
106 const unsigned n_chamber_t0_sources=2;
107 for (
unsigned i=0;
i<n_chamber_t0_sources;++
i)
129 SubSystemInfo( QCheckBox* cb,
const QRegExp& the_geomodeltreetopregexp,
bool the_negatetreetopregexp,
131 const std::string& the_matname,
132 const QRegExp& the_geomodelgrandchildrenregexp,
bool the_negategrandchildrenregexp=
false)
210 std::cout<<
" SubSystemInfo @ "<<
this<<
"\n"
211 <<(
isbuilt?
"Is built.\n":
"Is not built.\n")
212 <<(
muonchambers?
"Has muon chambers.\n":
"No muon chambers.\n");
213 std::cout<<
"Contains following volhandles: [";
214 for (
auto vol :
vollist) std::cout<<&vol<<
",";
215 std::cout<<
"]"<<std::endl;
216 std::cout<<
"Matname = "<<
matname<<std::endl;
217 std::cout<<
"Contains following TreetopInfo: [";
219 std::cout<<
"]"<<std::endl;
227 const QString& treetopregexp,
const QString& childrenregexp=
"",
228 const std::string& matname=
"",
bool negatetreetopregexp =
false,
bool negatechildrenregexp =
false,
229 const QString& grandchildrenregexp=
"",
bool negategrandchildrenregexp =
false);
251 static double volume(
const PVConstLink&
pv);
276 #ifndef BUILDVP1LIGHT
292 void applyTopVolStates(
const QMap<quint32,QByteArray>&,
bool disablenotif =
false);
305 "This system displays the geometry as defined in the GeoModel tree.",
306 "Riccardo.Maria.Bianchi@cern.ch"),
307 m_d(
new Imp(this,SubSystemsTurnedOn))
366 const QString& treetopregexp,
const QString& childrenregexp,
367 const std::string& matname,
bool negatetreetopregexp,
bool negatechildrenregexp,
368 const QString& grandchildrenregexp,
bool negategrandchildrenregexp)
370 theclass->
messageDebug(
"VP1GeometrySystem::Imp::addSubSystem - flag: '" + QString(
f) +
"' - matName: '" +
str(matname.c_str()) +
"'." );
378 QRegExp(childrenregexp),negatechildrenregexp,
f,matname,
379 QRegExp(grandchildrenregexp), negategrandchildrenregexp);
386 message(
"VP1GeometrySystem::buildController");
404 connect(
m_d->
controller,SIGNAL(muonChamberAdaptionStyleChanged(VP1GeoFlags::MuonChamberAdaptionStyleFlags)),
409 connect(
m_d->
controller,SIGNAL(
autoAdaptPixelsOrSCT(
bool,
bool,
bool,
bool,
bool,
bool)),
this,SLOT(
autoAdaptPixelsOrSCT(
bool,
bool,
bool,
bool,
bool,
bool)));
410 connect(
m_d->
controller,SIGNAL(
autoAdaptMuonNSW(
bool,
bool,
bool,
bool,
bool,
bool)),
this,SLOT(
autoAdaptMuonNSW(
bool,
bool,
bool,
bool,
bool,
bool)));
508 This->
kbEvent =
static_cast<const SoKeyboardEvent *
>(
CB->getEvent());
516 #ifndef BUILDVP1LIGHT
518 message(
"Error: GeoModel not configured properly in job.");
525 message(
"Error: Could not retrieve the ATLAS GeoModelExperiment from detector store");
545 SoFont *myFont =
new SoFont;
546 myFont->name.setValue(
"Arial");
547 myFont->size.setValue(12.0);
550 bool save =
root->enableNotify(
false);
553 SoEventCallback *catchEvents =
new SoEventCallback();
555 root->addChild(catchEvents);
569 subsys->
checkbox->setEnabled(
false);
570 subsys->
checkbox->setToolTip(
"This sub-system is not available");
579 qDebug() <<
"Looping on volumes from the input GeoModel...";
581 GeoVolumeCursor av(world);
582 while (!av.atEnd()) {
584 std::string
name = av.getName();
586 qDebug() <<
"volume name:" << QString::fromStdString(
name);
613 SoSwitch * sw =
new SoSwitch();
616 if (sw->whichChild.getValue() != SO_SWITCH_NONE)
617 sw->whichChild = SO_SWITCH_NONE;
618 SoSeparator *
sep =
new SoSeparator;
623 subsys->
checkbox->setToolTip(
"Toggle the display of the "+subsys->
checkbox->text()+
" sub system");
629 message(
"Warning: Found unexpected GeoModel treetop: "+QString(
name.c_str()));
636 if (!checkBoxOther->isEnabled())
637 checkBoxOther->setVisible(
false);
645 if (subsys->
soswitch->whichChild.getValue() != SO_SWITCH_ALL)
646 subsys->
soswitch->whichChild = SO_SWITCH_ALL;
673 return getGeometryFromLocalDB();
681 if (world ==
nullptr)
684 double densityOfAir=0.1;
685 const GeoMaterial* worldMat =
new GeoMaterial(
"std::Air", densityOfAir);
687 const GeoLogVol* worldLog =
new GeoLogVol(
"WorldLog", worldBox, worldMat);
689 world =
new GeoPhysVol(worldLog);
693 return theExperiment;
709 VP1Msg::messageDebug(
"Method VP1GeometrySystem::Imp::getDummyGeometry() has to be ported to the new standalone GeoModel.");
711 return theExperiment;
722 QSettings settings(
"ATLAS",
"VP1Light");
723 QString
path = settings.value(
"db/path").toString();
725 qDebug() <<
"Using this DB file:" <<
path;
731 qWarning() <<
"ERROR!! DB '" <<
path <<
"' does not exist!!";
732 qWarning() <<
"Returning..." <<
"\n";
737 GMDBManager*
db =
new GMDBManager(
path);
741 qDebug() <<
"OK! Database is open!";
746 qDebug() <<
"Database is not open!";
753 GeoModelPers::GReadIn readInGeo = GeoModelPers::GReadIn(
db);
755 qDebug() <<
"GReadIn set.";
759 GeoPhysVol* dbPhys = readInGeo.buildGeoModel();
762 qDebug() <<
"GReadIn::buildGeoModel() done.";
768 return theExperiment;
776 QCheckBox * cb =
static_cast<QCheckBox*
>(sender());
779 if (cb==
ss->checkbox) {
785 message(
"ERROR: Unknown checkbox");
791 if (cb->isChecked()) {
792 SbBool
save = sw->enableNotify(
false);
793 if (sw->getNumChildren()==0) {
797 if (sw->whichChild.getValue() != SO_SWITCH_ALL)
798 sw->whichChild = SO_SWITCH_ALL;
799 sw->enableNotify(
save);
806 if (sw->whichChild.getValue() != SO_SWITCH_NONE)
807 sw->whichChild = SO_SWITCH_NONE;
841 if (pickedPath->getNodeFromTail(0)->getTypeId()==SoCylinder::getClassTypeId())
844 if (pickedPath->getLength()<5) {
849 SoSeparator * nodesep(0);
851 if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSeparator::getClassTypeId()
852 && pickedPath->getNodeFromTail(2)->getTypeId()==SoSwitch::getClassTypeId()
853 && pickedPath->getNodeFromTail(3)->getTypeId()==SoSeparator::getClassTypeId())
856 nodesep =
static_cast<SoSeparator*
>(pickedPath->getNodeFromTail(3));
859 else if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSwitch::getClassTypeId()
860 && pickedPath->getNodeFromTail(2)->getTypeId()==SoSeparator::getClassTypeId())
863 nodesep =
static_cast<SoSeparator*
>(pickedPath->getNodeFromTail(2));
865 else if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSeparator::getClassTypeId()) {
867 nodesep =
static_cast<SoSeparator*
>(pickedPath->getNodeFromTail(1));
870 message(
"Unexpected picked path");
874 message(
"Problems finding volume handle");
879 message(
"Found NULL volume handle");
893 bool shift_isdown = (Qt::ShiftModifier & QApplication::keyboardModifiers());
906 bool ctrl_isdown = (Qt::ControlModifier & QApplication::keyboardModifiers());
935 bool orientedView(
false);
945 message(
"Warning: Failed to relocate picked node.");
991 message(
"===> CopyNo : "+(cn>=0?
QString::number(cn):QString(cn==-1?
"Invalid":
"Error reconstructing copynumber")));
996 float translation_x, translation_y, translation_z, rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians;
998 translation_x, translation_y, translation_z,
999 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
1000 message(
"===> Local Translation:");
1004 message(
"===> Local Rotation:");
1010 translation_x, translation_y, translation_z,
1011 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
1012 message(
"===> Global Translation:");
1016 message(
"===> Global Rotation:");
1024 std::ostringstream
str;
1025 GeoPrintGraphAction
pg(
str);
1028 for (
const QString&
line : QString(
str.str().c_str()).split(
"\n"))
1036 message(
"===> Total Mass <===");
1044 #ifndef BUILDVP1LIGHT
1047 std::map<GeoPVConstLink,const MuonGM::MuonStation*>::const_iterator itStation(
m_d->
pv2MuonStation.find(pvlink));
1049 message(
"===> Muon station <===");
1059 QStack<QString> partspectPath, extras;
1060 QString detFactoryName;
1062 VolumeHandle *parentVH(volhandle), *childVH(volhandle);
1066 parentVH = parentVH->parent();
1067 PVConstLink parentPVLink = parentVH ? parentVH->geoPVConstLink() : childVH->
geoPVConstLink()->getParent();
1071 std::string childPVName = parentPVLink->getNameOfChildVol(indexOfChild);
1072 QString pathEntry = childPVName==
"ANON" ? detFactoryName+childVH->
getName() : QString(childPVName.c_str());
1074 Query<int> childCopyNo = parentPVLink->getIdOfChildVol(indexOfChild);
1075 if(childCopyNo.isValid()) {
1077 strCopyNo.setNum(childCopyNo);
1078 pathEntry += (
"::"+strCopyNo);
1080 partspectPath.push(pathEntry);
1085 while(!extras.isEmpty())
1086 partspectPath.push(extras.pop());
1088 partspectPath.push(
"Atlas::Atlas");
1107 ensureInitVisAttributes();
1108 #ifndef BUILDVP1LIGHT
1109 ensureInitPV2MuonStationMap();
1118 SoSeparator * subsystemsep =
new SoSeparator;
1119 phisectormanager->registerSubSystemSeparator(si->
flag,subsystemsep);
1120 phisectormanager->largeChangesBegin();
1126 std::vector<SubSystemInfo::TreetopInfo>::const_iterator
it,
itE = si->
treetopinfo.end();
1132 SoMaterial*
m = detVisAttributes->get(
it->volname);
1134 theclass->message(
"Warning: Did not find a predefined material for volume: "+QString(
it->volname.c_str()));
1137 m,matVisAttributes,volVisAttributes,
1138 controller->zappedVolumeListModel(),controller->volumeTreeBrowser(), m_textSep);
1147 std::vector<SubSystemInfo::TreetopInfo>::const_iterator
it,
itE = si->
treetopinfo.end();
1155 SoMaterial*mat_top(0);
1157 mat_top = detVisAttributes->get(si->
matname);
1160 mat_top,matVisAttributes,volVisAttributes,
1161 controller->zappedVolumeListModel(),controller->volumeTreeBrowser(),m_textSep);
1162 volhandle_subsysdata->
ref();
1166 GeoVolumeCursor av(
it->pV);
1168 while (!av.atEnd()) {
1175 PVConstLink pVD = av.getVolume();
1182 if (hasMuonChambers){
1183 #ifndef BUILDVP1LIGHT
1186 #ifdef BUILDVP1LIGHT
1189 muonchambers_pv2handles[pVD] = vh;
1191 std::cout<<
"Has muon chamber VH="<<vh<<std::endl;
1196 vh =
new VolumeHandle(volhandle_subsysdata,0,pVD,ichild++,
1216 theclass->message(
"Zapping this volumehandle because it's probably junk."+vh->
getDescriptiveName() +
" - " + vh->
getName());
1225 volhandle_subsysdata->
unref();
1232 volumetreemodel->addSubSystem( si->
flag, si->
vollist );
1240 VP1Msg::messageDebug(
"Perform auto expansion of all ether volumes (needed for muon dead material)");
1245 (*it)->expandMothersRecursivelyToNonEther();
1251 phisectormanager->updateRepresentationsOfVolsAroundZAxis();
1252 phisectormanager->largeChangesEnd();
1253 si->
soswitch->addChild(subsystemsep);
1262 const GeoLogVol* lv =
pv->getLogVol();
1263 const GeoMaterial *material = lv->getMaterial();
1264 double density = material->getDensity();
1265 return density*volume(
pv);
1271 const GeoLogVol * lv =
pv->getLogVol();
1272 const GeoShape *shape = lv->getShape();
1273 return shape->volume();
1280 const GeoLogVol* lv =
pv->getLogVol();
1281 const GeoMaterial *material = lv->getMaterial();
1282 double density = material->getDensity();
1284 double mass = exclusiveMass(
pv);
1286 GeoVolumeCursor av(
pv);
1287 while (!av.atEnd()) {
1288 mass += inclusiveMass(av.getVolume());
1289 mass -= volume(av.getVolume())*density;
1308 QMap<QString,bool> subsysstate;
1311 subsysstate.insert(subsys->
checkbox->text(),subsys->
checkbox->isChecked());
1316 QMap<quint32,QByteArray> topvolstates;
1322 topvolstates.insert((*it)->hashID(),(*it)->getPersistifiableState());
1339 message(
"Warning: State data in .vp1 file is in wrong format - ignoring!");
1342 if (
state.version()<=5) {
1343 message(
"Warning: State data in .vp1 file is in obsolete format - ignoring!");
1354 VP1GeoFlags::SubSystemFlags
flags;
1355 QMap<QString,bool> subsysstate =
state.restore<QMap<QString,bool> >();
1358 if (subsysstate.contains(subsys->
checkbox->text())&&subsysstate[subsys->
checkbox->text()])
1364 QMap<quint32,QByteArray> topvolstates;
1365 topvolstates =
state.restore<QMap<quint32,QByteArray> >();
1371 if (
state.version()>=7) {
1378 state.disableUnrestoredChecks();
1389 phisectormanager->largeChangesBegin();
1390 QMap<quint32,QByteArray>::const_iterator topvolstatesItr;
1394 topvolstatesItr = topvolstates.find((*it)->hashID());
1395 if (topvolstatesItr!=topvolstates.end())
1396 (*it)->applyPersistifiableState(topvolstatesItr.value());
1400 phisectormanager->updateRepresentationsOfVolsAroundZAxis();
1401 phisectormanager->largeChangesEnd();
1410 prefix = QString(
"Pixel::");
1413 entries.push(
"ITkPixel::ITkPixel");
1419 prefix = QString(
"SCT::");
1422 entries.push(
"ITkStrip::ITkStrip");
1428 prefix = QString(
"TRT::");
1434 prefix = QString(
"InDetServMat::");
1439 prefix = QString(
"LArMgr::");
1441 entries.push(
"LArMgr::LArMgr");
1445 prefix = QString(
"Tile::");
1463 prefix = QString(
"Muon::");
1464 entries.push(
"MUONQ02::MUONQ02");
1465 entries.push(
"Muon::MuonSys");
1469 prefix = QString(
"BeamPipe::");
1470 entries.push(
"BeamPipe::BeamPipe");
1491 if (val<0||val>100) {
1492 message(
"setCurvedSurfaceRealism Error: Value "+
str(
val)+
"out of range!");
1531 messageDebug(
"resetting volume --> " + (*it)->getName() );
1544 std::set<GeoPVConstLink> allchambers;
1549 allchambers.insert(itLists->second.begin(),itLists->second.end());
1561 if (allchambers.find(
it->first)==itchambersE)
1564 if (
it->second->muonChamberDirty())
1582 it->second->setMuonChamberDirty(
true);
1594 message(
"emit_appropriateMDTProjectionsChanged called before controller built.");
1600 int i (option_openmdtchambers?(option_hidetubes?0:1):2);
1624 if (stationname.empty()) {
1625 theclass->message(
"Warning: Asked to handle muon chamber (station) with empty name!");
1633 VP1GeoFlags::MuonChamberAdaptionStyleFlags
f(controller->muonChamberAdaptionStyle());
1640 char firstletter = stationname[0];
1641 std::string
name1,name2;
1642 if (firstletter==
'E' || firstletter ==
'B') {
1646 if (option_openmdtchambers) {
1651 for (;itch!=itchE;++itch) {
1655 name1 = (*itch)->getNameStdString();
1659 (*itch)->initialiseChildren();
1661 for (;itch2!=itch2E;++itch2) {
1665 name2 = (*itch2)->getNameStdString();
1667 if (option_hidetubes&&name2==
"MDTDriftWall") {
1669 }
else if (name2.size()>2&&name2[0]==
'R'&&((name2[1]==
'p'&&name2[2]==
'c')||(name2[1]==
'P'&&name2[2]==
'C'))) {
1670 zap = (option_hiderpcvolumes||name2!=
"Rpclayer");
1671 }
else if (name2.size()>2&&name2[0]==
'D'&&name2[1]==
'e'&&name2[2]==
'd') {
1680 chamberhandle->
reset();
1683 if (firstletter==
'C') {
1687 if (option_opencscchambers) {
1691 for (;itch!=itchE;++itch) {
1692 if ((*itch)->hasName(
"CSCspacer")) {
1696 if ((*itch)->nChildren()<1)
1698 (*itch)->initialiseChildren();
1700 for (;itch2!=itch2E;++itch2) {
1701 if ((*itch2)->nChildren()<1)
1703 (*itch2)->initialiseChildren();
1705 for (;itch3!=itch3E;++itch3) {
1706 if ((*itch3)->getNameStdString()==
"CscArCO2")
1721 if (option_opentgcchambers) {
1725 for (;itch!=itchE;++itch) {
1726 if ((*itch)->nChildren()<1)
1728 (*itch)->initialiseChildren();
1730 for (;itch2!=itch2E;++itch2) {
1731 if ((*itch2)->getNameStdString()==
"muo::TGCGas")
1750 std::string
name = chamberPV->getLogVol()->getName();
1755 if (!subsys->hasMuonChambers())
1757 if (subsys->childrenRegExpNameCompatible(
name)) {
1775 message(
"Error: Asked to orient view to chamber volume '"
1776 +QString(chamberPV->getLogVol()->getName().c_str())
1777 +
"', which doesn't fit the known format of any chamber!");
1783 message(
"Warning: Asked to orient view to muon chamber volume which is not available. Perhaps muon geometry was not built?");
1794 message(
"Error: Asked to orient view to chamber volume '"
1795 +QString(chamberPV->getLogVol()->getName().c_str())
1796 +
"', but could not find chamber handle!");
1806 bool isCSCOrTGC =
name.size()>=2 && ( (
name[0]==
'C' &&
name[1]==
'S') || (
name[0]==
'T') );
1807 if (!isCSCOrTGC&&!(
name.size()>=1&&(
name[0]==
'E'||
name[0]==
'B'))) {
1809 message(
"orientViewToMuonChamber Warning: Not CSC, TGC or MDT station!");
1816 int32_t soswitch_val = subsys->
soswitch->whichChild.getValue();
1817 if (soswitch_val!=SO_SWITCH_ALL)
1818 subsys->
soswitch->whichChild = SO_SWITCH_ALL;
1833 SbRotation camrot = (*it)->orientation.getValue();
1834 SbVec3f cameraDir(0, 0, -1);
1835 camrot.multVec(cameraDir, cameraDir);
1836 SbVec3f cameraUpVec(0, 1, 0);
1837 camrot.multVec(cameraUpVec, cameraUpVec);
1839 std::pair<SbVec3f,SbVec3f> chamberdirections;
1847 SbVec3f newdirection = - chamberdirections.first;
1848 SbVec3f newup(cameraUpVec);
1849 const float epsilon(0.00001
f);
1854 SbRotation rot(cameraDir,0.5*
M_PI);
1855 SbVec3f chambdir1 = chamberdirections.second;
1856 SbVec3f chambdir2,chambdir3,chambdir4;
1857 rot.multVec(chambdir1,chambdir2);
1858 rot.multVec(chambdir2,chambdir3);
1859 rot.multVec(chambdir3,chambdir4);
1860 if (cameraUpVec.equals(chambdir1,epsilon)) {
1862 }
else if (cameraUpVec.equals(chambdir2,epsilon)) {
1864 }
else if (cameraUpVec.equals(chambdir3,epsilon)) {
1866 }
else if (cameraUpVec.equals(chambdir4,epsilon)) {
1870 float cos1 = chambdir1.dot(cameraUpVec);
1871 float cos2 = chambdir2.dot(cameraUpVec);
1872 float cos3 = chambdir3.dot(cameraUpVec);
1873 float cos4 = chambdir4.dot(cameraUpVec);
1877 else if (cos2==maxcos)
1879 else if (cos3==maxcos)
1893 chamberHandle->
setState(oldChamberState);
1894 if (soswitch_val!=SO_SWITCH_ALL)
1895 subsys->
soswitch->whichChild.setValue(soswitch_val);
1897 subsys->
soswitch->enableNotify(
true);
1907 const SbVec3f& cameraUpDirection,
1911 SbVec3f closesttubedir(cameraDirection);
1912 SbVec3f closesttubeupvec(cameraUpDirection);
1913 float smallestcosangle(1.1);
1918 for (;itch!=itchE;++itch) {
1920 std::string
name1 = (*itch)->getNameStdString();
1924 (*itch)->initialiseChildren();
1927 const SbVec3f unitz(0.0
f,0.0
f,1.0
f);
1928 const SbVec3f unity(0.0
f,1.0
f,0.0
f);
1930 SbVec3f translation,
scale;
1931 SbRotation
rotation, scalerotation;
1933 for (;itch2!=itch2E;++itch2) {
1934 if ((*itch2)->getNameStdString()==
"MDTDriftWall") {
1938 (*itch2)->getGlobalTransformToVolume().getTransform(translation,
rotation,
scale,scalerotation);
1939 rotation.multVec (unitz, tubeglob);
1940 if (tubeglob.dot(cameraDirection)<smallestcosangle) {
1941 smallestcosangle = tubeglob.dot(cameraDirection);
1942 closesttubedir = tubeglob;
1943 rotation.multVec(unity, closesttubeupvec);
1945 if (tubeglob.dot(-cameraDirection)<smallestcosangle) {
1946 smallestcosangle = tubeglob.dot(-cameraDirection);
1947 closesttubedir = -tubeglob;
1948 rotation.multVec(unity, closesttubeupvec);
1953 return std::pair<SbVec3f,SbVec3f>(closesttubedir,closesttubeupvec);
1961 std::vector<SbVec3f> directions;
1962 directions.push_back(SbVec3f(0.0
f,1.0
f,0.0
f));
1963 directions.push_back(SbVec3f(0.0
f,-1.0
f,0.0
f));
1964 directions.push_back(SbVec3f(0.0
f,0.0
f,1.0
f));
1965 directions.push_back(SbVec3f(0.0
f,0.0
f,-1.0
f));
1967 directions.push_back(SbVec3f(1.0
f,0.0
f,0.0
f));
1968 directions.push_back(SbVec3f(-1.0
f,0.0
f,0.0
f));
1971 SbVec3f translation,
scale;
1972 SbRotation
rotation, scalerotation;
1976 for (
unsigned i = 0;
i<directions.size();++
i)
1977 rotation.multVec(directions[
i],directions[
i]);
1980 SbVec3f chamberDir(-cameraDirection);
1981 float smallestcosangle(1.1);
1982 for (
unsigned i = 0;
i<directions.size();++
i) {
1983 if (directions.at(
i).dot(cameraDirection)<smallestcosangle) {
1984 smallestcosangle = directions.at(
i).dot(cameraDirection);
1985 chamberDir = directions.at(
i);
1993 chamberDir.getValue(
x,
y,
z);
1995 rotation.multVec(SbVec3f(0.0
f,1.0
f,0.0
f),chamberUp);
1997 rotation.multVec(SbVec3f(1.0
f,0.0
f,0.0
f),chamberUp);
2001 return std::pair<SbVec3f,SbVec3f>(chamberDir,chamberUp);
2022 changeStateOfVisibleNonStandardVolumesRecursively(*
it,
target);
2032 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2041 for (
unsigned i = 0;
i<roothandles.size();++
i) {
2042 it = roothandles.at(
i).first;
2043 itE = roothandles.at(
i).second;
2060 if (targetname.isEmpty()) {
2065 messageVerbose(
"Auto expansions of visible volumes requested. Target all volumes with "
2066 +
str(bymatname?
"material name":
"name")+
" matching "+targetname);
2068 QRegExp selregexp(targetname,Qt::CaseSensitive,QRegExp::Wildcard);
2070 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2079 for (
unsigned i = 0;
i<roothandles.size();++
i) {
2080 it = roothandles.at(
i).first;
2081 itE = roothandles.at(
i).second;
2102 && selregexp.exactMatch(bymatname?QString(handle->
geoMaterial()->getName().c_str()):handle->
getName())) {
2112 expandVisibleVolumesRecursively(*
it,selregexp,bymatname);
2123 if( selregexp.exactMatch(bymatname?QString(handle->
geoMaterial()->getName().c_str()):handle->
getName())) {
2133 iconifyVisibleVolumesRecursively(*
it,selregexp,bymatname);
2140 if (targetname.isEmpty()) {
2145 messageVerbose(
"Auto iconification/zapping of visible volumes requested. Target all volumes with "
2146 +
str(bymatname?
"material name":
"name")+
" matching "+targetname);
2148 QRegExp selregexp(targetname,Qt::CaseSensitive,QRegExp::Wildcard);
2150 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2159 for (
unsigned i = 0;
i<roothandles.size();++
i) {
2160 it = roothandles.at(
i).first;
2161 itE = roothandles.at(
i).second;
2173 #ifndef BUILDVP1LIGHT
2182 theclass->message(
"WARNING: Ignored null station pointer");
2185 pv2MuonStation[pvlink] = station;
2191 if (pv2MuonStationInit) {
2195 pv2MuonStationInit =
true;
2196 theclass->messageVerbose(
"Initializing physical volume link -> MuonStation map.");
2200 VP1Msg::message(
"WARNING: Could not get muon detector manager to construct volume -> muon station map!");
2203 if (
mgr->nMdtRE()) {
2204 for (
auto det_el =
mgr->mdtIdHelper()->detectorElement_begin();
2205 det_el !=
mgr->mdtIdHelper()->detectorElement_end(); ++det_el) {
2206 updatePV2MuonStationMap(
mgr->getMdtReadoutElement(*det_el));
2209 if (
mgr->nRpcRE()) {
2210 for (
auto det_el =
mgr->rpcIdHelper()->detectorElement_begin();
2211 det_el !=
mgr->rpcIdHelper()->detectorElement_end(); ++det_el) {
2212 updatePV2MuonStationMap(
mgr->getRpcReadoutElement(*det_el));
2215 if (
mgr->nCscRE()) {
2216 for (
auto det_el =
mgr->cscIdHelper()->detectorElement_begin();
2217 det_el !=
mgr->cscIdHelper()->detectorElement_end(); ++det_el) {
2218 updatePV2MuonStationMap(
mgr->getCscReadoutElement(*det_el));
2221 if (
mgr->nTgcRE()) {
2222 for (
auto det_el =
mgr->tgcIdHelper()->detectorElement_begin();
2223 det_el !=
mgr->tgcIdHelper()->detectorElement_end(); ++det_el) {
2224 updatePV2MuonStationMap(
mgr->getTgcReadoutElement(*det_el));
2228 VP1Msg::messageDebug(
"Initialised physical volume link -> MuonStation map. Found "+
str(pv2MuonStation.size())+
" stations.");
2249 #ifndef BUILDVP1LIGHT
2255 bool bcm(bcmA||bcmC);
2262 if (si->
flag == subSysFlag) {
2268 message(
"AutoAdaptPixelsOrSCT Error: Could not find subsystem");
2286 (*it)->initialiseChildren();
2289 for (;itChl!=itChlE;++itChl) {
2293 if (brl&&(*itChl)->hasName(
"barrelLog")) {
2296 }
else if ((ec)&&(*itChl)->hasName(
"EndCapLog")) {
2297 if (((*itChl)->isPositiveZ()?ecA:ecC)) {
2301 }
else if (bcm&&(*itChl)->hasName(
"bcmModLog")) {
2302 if (((*itChl)->isPositiveZ()?bcmA:bcmC)) {
2308 if ((*itChl)->hasName(
"ITkPixelDetector")) {
2321 (*it)->initialiseChildren();
2326 if (brl&&(*it)->hasName(
"SCT_Barrel")) {
2329 }
else if (ecA&&(*it)->hasName(
"SCT_ForwardA")) {
2332 }
else if (ecC&&(*it)->hasName(
"SCT_ForwardC")) {
2358 #ifndef BUILDVP1LIGHT
2373 if (si->
flag == subSysFlag) {
2379 message(
"autoAdaptMuonNSW Error: Could not find subsystem");
2398 (*it)->initialiseChildren();
2403 for (;itChl!=itChlE;++itChl) {
2405 bool unzap(
reset?
true :
false );
2409 if ( (stgc) && (*itChl)->hasName(
"NSW_sTGC") ) {
2412 }
else if ( (
mm) && (*itChl)->hasName(
"NSW_MM") ) {
2415 }
else if ( (passiveSpacer) && (*itChl)->hasName(
"NSW_Spacer") ) {
2417 }
else if ( (passiveStructure) && (*itChl)->hasName(
"NSW_Aluminum_Structure_and_HUB") ) {
2419 }
else if ( (passiveAPlate) && (*itChl)->hasName(
"A_Plate") ) {
2446 h->initialiseChildren();
2449 if ((*it)->hasName(
"moduleLog")) {
2451 (*it)->contractDaughtersRecursively();
2452 (*it)->initialiseChildren();
2454 for (;itMod!=itModE;++itMod) {
2455 if ((*itMod)->getName().startsWith(
"si"))
2463 if ((*it)->hasName(
"pigtailLog")||(*it)->hasName(
"omegaLog")) {
2465 (*it)->contractDaughtersRecursively();
2468 if ((*it)->nChildren()<1) {
2473 showPixelModules(*
it);
2480 if (
h->nChildren()==0) {
2481 if (isPixel and (ecA or ecC)) {
2482 float translation_x, translation_y, translation_z, rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians;
2484 translation_x, translation_y, translation_z,
2485 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
2486 if ((!ecA || !ecC) && ((ecA and (translation_z<0.)) or (ecC and (translation_z>0.) ))) {
2493 std::vector< std::string > selected_volumes = {};
2496 selected_volumes.push_back(
"InnerBarrelSingleMod_Sensor");
2497 selected_volumes.push_back(
"InnerBarrelQuadMod_Sensor");
2498 selected_volumes.push_back(
"OuterBarrelQuadMod_Sensor");
2499 selected_volumes.push_back(
"LongeronCoolingTube");
2500 selected_volumes.push_back(
"InnerPixBarrelSupport_Stave");
2501 selected_volumes.push_back(
"InnerPixBarrelSupport_Stave1");
2502 selected_volumes.push_back(
"LongeronCornerBase");
2503 selected_volumes.push_back(
"LongeronCornerEnd");
2504 selected_volumes.push_back(
"LongeronTrussWall");
2505 selected_volumes.push_back(
"LongeronCapBase");
2506 selected_volumes.push_back(
"LongeronTopCap");
2509 selected_volumes.push_back(
"BRLSensorSS");
2510 selected_volumes.push_back(
"BRLSensorMS");
2511 selected_volumes.push_back(
"B_HybridPCB");
2512 selected_volumes.push_back(
"DCDC_PCB");
2513 selected_volumes.push_back(
"DCDC_Box");
2514 selected_volumes.push_back(
"Bex_HybridPCB_near");
2515 selected_volumes.push_back(
"Bex_HybridPCB_far");
2520 selected_volumes.push_back(
"InclinedQuadMod_Sensor");
2521 selected_volumes.push_back(
"InnerRingSingleMod_Sensor");
2522 selected_volumes.push_back(
"InnerEndcapQuadMod_Sensor");
2523 selected_volumes.push_back(
"OuterEndcapQuadMod_Sensor");
2524 selected_volumes.push_back(
"L2HalfRingCoolingPipe");
2525 selected_volumes.push_back(
"L3HalfRingCoolingPipe");
2526 selected_volumes.push_back(
"L4endcapcoolingpipe");
2527 selected_volumes.push_back(
"InclL2HalfShell");
2528 selected_volumes.push_back(
"InclL2Support");
2529 selected_volumes.push_back(
"InclL3HalfShell");
2530 selected_volumes.push_back(
"InclL3Support");
2531 selected_volumes.push_back(
"InclL4HalfShell");
2532 selected_volumes.push_back(
"InclL4Support");
2533 selected_volumes.push_back(
"InnerPixEndcap_CoupledRingSupport");
2534 selected_volumes.push_back(
"InnerPixEndcap_IntermediateRingSupport");
2535 selected_volumes.push_back(
"InnerPixEndcap_L1RingSupport");
2536 selected_volumes.push_back(
"L2HalfRingCarbonFoamInner");
2537 selected_volumes.push_back(
"L2HalfRingCarbonFoamOuter");
2538 selected_volumes.push_back(
"L2HalfRingFaceSheet");
2539 selected_volumes.push_back(
"L3HalfRingCarbonFoamInner");
2540 selected_volumes.push_back(
"L3HalfRingCarbonFoamOuter");
2541 selected_volumes.push_back(
"L3HalfRingFaceSheet");
2542 selected_volumes.push_back(
"L4endcapinnerCarbonFoam");
2543 selected_volumes.push_back(
"L4endcapouterCarbonFoam");
2544 selected_volumes.push_back(
"L4endcapFaceSheet");
2545 selected_volumes.push_back(
"L2HalfShell");
2546 selected_volumes.push_back(
"L3HalfShell");
2547 selected_volumes.push_back(
"L4HalfShell");
2549 selected_volumes.push_back(
"ECSensor0");
2550 selected_volumes.push_back(
"ECSensor1");
2551 selected_volumes.push_back(
"ECSensor2");
2552 selected_volumes.push_back(
"ECSensor3");
2553 selected_volumes.push_back(
"ECSensor4");
2554 selected_volumes.push_back(
"ECSensor5");
2555 selected_volumes.push_back(
"ECSensorBack0");
2556 selected_volumes.push_back(
"ECSensorBack1");
2557 selected_volumes.push_back(
"ECSensorBack2");
2558 selected_volumes.push_back(
"ECSensorBack3");
2559 selected_volumes.push_back(
"ECSensorBack4");
2560 selected_volumes.push_back(
"ECSensorBack5");
2564 std::string
name =
h->getName().toStdString();
2566 if (not isPixel and (ecA or ecC)) {
2568 if (
name.starts_with(
"ECHybrid") or
name.starts_with(
"DCDC_EC"))
2572 if (
std::find(selected_volumes.begin(), selected_volumes.end(),
name) == selected_volumes.end()) {
2577 }
else if (not isPixel and (
h->getName().toStdString()==
"PetalCore" or
2578 h->getName().toStdString()==
"StaveCoreSS" or
2579 h->getName().toStdString() ==
"StaveCoreMS")) {
2582 h->initialiseChildren();
2587 expandAllChildren(*
it, isPixel, brl, ecA, ecC);
2594 h->initialiseChildren();
2598 expandAllChildren(*
it,
true, brl, ecA, ecC);
2606 h->initialiseChildren();
2610 if (brl and (*it)->hasName(
"ITkStrip_Barrel")) {
2611 expandAllChildren(*
it,
false, brl, ecA, ecC);
2613 else if (ecA and (*it)->hasName(
"ITkStrip_ForwardPlus")) {
2614 expandAllChildren(*
it,
false, brl, ecA, ecC);
2616 else if (ecC and (*it)->hasName(
"ITkStrip_ForwardMinus")) {
2617 expandAllChildren(*
it,
false, brl, ecA, ecC);
2627 h->initialiseChildren();
2630 if ((*it)->getName().startsWith(
"Layer")) {
2632 (*it)->initialiseChildren();
2634 for (;itLay!=itLayE;++itLay) {
2635 if ((*itLay)->getName().endsWith(
"Active")&&(*itLay)->getName().startsWith(
"Layer")) {
2637 (*itLay)->initialiseChildren();
2639 for (;itActLay!=itActLayE;++itActLay) {
2640 if ((*itActLay)->getName().startsWith(
"Ski")) {
2642 (*itActLay)->initialiseChildren();
2644 for (;itSki!=itSkiE;++itSki) {
2646 if ((*itSki)->hasName(
"Module")) {
2649 (*itSki)->initialiseChildren();
2651 for (;itMod!=itModE;++itMod) {
2652 if ((*itMod)->getName().contains(
"Envelope")) {
2654 (*itMod)->initialiseChildren();
2656 for(;itEnv!=itEnvE;++itEnv) {
2657 if ((*itEnv)->getName().contains(
"Sensor"))
2680 (*itLay)->contractDaughtersRecursively();
2686 (*it)->contractDaughtersRecursively();
2695 h->initialiseChildren();
2698 if ((*it)->getName().startsWith(
"Wheel")) {
2700 (*it)->initialiseChildren();
2702 for (;itWhl!=itWhlE;++itWhl) {
2703 if ((*itWhl)->getName().startsWith(
"Ring")) {
2705 (*itWhl)->initialiseChildren();
2707 for (;itRng!=itRngE;++itRng) {
2708 if ((*itRng)->getName().startsWith(
"FwdModule")) {
2710 (*itRng)->initialiseChildren();
2712 for(;itMod!=itModE;++itMod) {
2713 if ((*itMod)->getName().startsWith(
"ECSensor")) {
2727 (*itWhl)->contractDaughtersRecursively();
2733 (*it)->contractDaughtersRecursively();
2777 if (!
fi.isWritable()) {
2778 QMessageBox::critical(0,
"Error - could not save to file "+
filename,
2779 "Could not save to file: <i>"+
filename+
"</i>"
2780 +
"<br/><br/>Reason: File exists already and is write protected",QMessageBox::Ok,QMessageBox::Ok);
2786 if (!
file.open(QIODevice::WriteOnly)) {
2787 QMessageBox::critical(0,
"Error - problems writing to file "+
filename,
2788 "Problems writing to file: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2795 s.save(QString(
"VP1GeoMaterialsBegin"));
2799 s.save(QString(
"VP1GeoMaterialsEnd"));
2800 s.disableUnsavedChecks();
2803 outfile<<qCompress(
s.result()).toBase64();
2814 QMessageBox::critical(0,
"Error - file does not exists: "+
filename,
2815 "File does not exists: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2818 if (!
fi.isReadable()) {
2819 QMessageBox::critical(0,
"Error - file is not readable: "+
filename,
2820 "File is not readable: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2825 if (!
file.open(QIODevice::ReadOnly)) {
2826 QMessageBox::critical(0,
"Error - problems opening file "+
filename,
2827 "Problems opening file: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2830 QByteArray byteArray64;
2833 QByteArray byteArray = qUncompress(QByteArray::fromBase64(byteArray64));
2836 if (
s.version()!=0) {
2837 QMessageBox::critical(0,
"Error - File in wrong format "+
filename,
2838 "File in wrong format: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2841 QString txtbegin, txtend;
2842 QByteArray baDet, baMat, baVol;
2843 txtbegin =
s.restoreString();
2844 baDet =
s.restoreByteArray();
2845 baMat =
s.restoreByteArray();
2846 baVol =
s.restoreByteArray();
2847 txtend =
s.restoreString();
2848 s.disableUnrestoredChecks();
2849 if (txtbegin!=
"VP1GeoMaterialsBegin"||txtend!=
"VP1GeoMaterialsEnd") {
2850 QMessageBox::critical(0,
"Error - File in wrong format "+
filename,
2851 "File in wrong format: <i>"+
filename+
"</i>",QMessageBox::Ok,QMessageBox::Ok);
2877 for (;
it!=itEnd ; ++
it){
2878 if (
it->second->isInMuonChamber())
it->second->updateLabels();
2889 message(
"ERROR: chamber t0 index out of bounds!");