ATLAS Offline Software
Loading...
Searching...
No Matches
VP1GeometrySystem.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// Implementation of class VP1GeometrySystem //
8// //
9// Author: Thomas Kittelmann <Thomas.Kittelmann@cern.ch> //
10// //
11// Derived from V-atlas geometry system by Joe Boudreau. //
12// Origins of initial version dates back to ~1996, initial VP1 //
13// version by TK (May 2007) and almost entirely rewritten Oct 2007. //
14// Major refactoring october 2008. //
15// Updates: //
16// - Aug 2019, Riccardo.Maria.Bianchi@cern.ch //
17// //
19
22
31
33
38#include "VP1Base/VP1Msg.h"
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>
47
48#include "GeoModelKernel/GeoVolumeCursor.h"
49#include "GeoModelKernel/GeoPrintGraphAction.h"
51
52#ifndef BUILDVP1LIGHT
56#include "VP1Utils/VP1DetInfo.h"
64#endif
65
66#ifdef BUILDVP1LIGHT
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"
72
73// #include "GeoModelExamples/ToyDetectorFactory.h"
74//#include "GeoModelExamples/SimplestToyDetectorFactory.h"
75
76#include <QStack>
77#include <QString>
78#include <QSettings>
79#endif // BUILDVP1LIGHT
80
81
82#include <QDebug>
83#include <QRegExp>
84#include <QByteArray>
85#include <QTimer>
86#include <QHeaderView>
87#include <QApplication>
88#include <QCheckBox>
89#include <QMessageBox>
90#include <QFileInfo>
91
92#include <initializer_list>
93#include <map>
94#include <ranges>
95
97public:
98 Imp (VP1GeometrySystem*gs, const VP1GeoFlags::SubSystemFlags& ssf)
99 : theclass(gs), sceneroot(0),
104 #ifndef BUILDVP1LIGHT
105 ,pv2MuonStationInit(false)
106 #endif
107 {
108 const unsigned n_chamber_t0_sources=2;
109 for (unsigned i=0;i<n_chamber_t0_sources;++i)
110 chamberT0s.append(0);
111 }
112
114 SoSeparator * sceneroot;
115
116 std::map<SoSeparator*,VolumeHandle*> sonodesep2volhandle;
117 //Might be needed later: std::map<GeoPVConstLink,VolumeHandle*> pv2volhandle;
118
119 #ifdef BUILDVP1LIGHT
120 GeoModelExperiment* getGeometry();
121 GeoModelExperiment* createTheExperiment(GeoPhysVol* world = nullptr);
122 GeoModelExperiment* getGeometryFromLocalDB();
123 GeoModelExperiment* getDummyGeometry();
124 #endif
125
126
128 public:
129 // "geomodellocation" contains name of tree tops,
130 // or possible a bit more complex info in case of muons.
131 SubSystemInfo( QCheckBox* cb,const QRegExp& the_geomodeltreetopregexp, bool the_negatetreetopregexp,
132 const QRegExp& the_geomodelchildrenregexp, bool the_negatechildrenregexp, VP1GeoFlags::SubSystemFlag the_flag,
133 const std::string& the_matname,
134 const QRegExp& the_geomodelgrandchildrenregexp, bool the_negategrandchildrenregexp=false)
135 : isbuilt(false), checkbox(cb),
136 geomodeltreetopregexp(the_geomodeltreetopregexp),
137 geomodelchildrenregexp(the_geomodelchildrenregexp),
138 geomodelgrandchildrenregexp(the_geomodelgrandchildrenregexp),
139 negatetreetopregexp(the_negatetreetopregexp),
140 negatechildrenregexp(the_negatechildrenregexp),
141 negategrandchildrenregexp(the_negategrandchildrenregexp),
142 matname(the_matname), flag(the_flag), soswitch(0)
143 {
144
145 muonchambers=false;
146
147 // we set to True if the name contains any of the Muon flags here below
148 if (geomodeltreetopregexp.pattern()=="Muon") {
149 muonchambers = ( matname=="CSC"||matname=="TGC"||matname=="EndcapMdt"||matname=="MM"||matname=="sTGC"
150 ||matname=="BarrelInner"||matname=="BarrelMiddle"||matname=="BarrelOuter" );
151 }
152
153 }
154
155 //Info needed to define the system (along with the checkbox pointer in the map below):
158 QCheckBox* checkbox;
159
160 /* Regular Expressions for three levels of filtering: treetop, children, and grandchildren
161 *
162 * For example:
163 *
164 * - Muon --> treetop volume
165 * - ANON --> child volume
166 * - BAR_Toroid --> granchild volume
167 *
168 */
169 QRegExp geomodeltreetopregexp; //For picking the geomodel treetops
170 QRegExp geomodelchildrenregexp; //If instead of the treetops, this system consists of volumes below the treetop, this is non-empty.
171 QRegExp geomodelgrandchildrenregexp;//If instead of the treetops, this system consists of volumes below the child of a treetop, this is non-empty.
175
176
177 std::string matname; //if nonempty, use this from detvisattr instead of the top volname.
179
180
181 //Information needed to initialise the system:
182 class TreetopInfo { public:
184 PVConstLink pV;
185 HepGeom::Transform3D xf;// = av.getTransform();
186 std::string volname;
187 };
188 std::vector<TreetopInfo> treetopinfo;
189
190 //Switch associated with the system - it is initialised only if the system has info available:
191 SoSwitch * soswitch;
192
193 //For the use-case of automatically enabling/disabling specific muon chambers:
195 bool hasMuonChambers() const {
196 return muonchambers;
197 }
198
199 bool childrenRegExpNameCompatible(const std::string& volname) const {
200 return negatechildrenregexp!=geomodelchildrenregexp.exactMatch(volname.c_str());
201 }
202
203 bool grandchildrenRegExpNameCompatible(const std::string& volname) const {
204 if(VP1Msg::debug()){
205 std::cout << "volname: " << volname << " - regexpr: " << geomodelgrandchildrenregexp.pattern().toStdString() << std::endl;
206 std::cout << "negategrandchildrenregexp: " << negategrandchildrenregexp << std::endl;
207 }
208 return negategrandchildrenregexp!=geomodelgrandchildrenregexp.exactMatch(volname.c_str());
209 }
210
211 void dump() const {
212 std::cout<<" SubSystemInfo @ "<<this<<"\n"
213 <<(isbuilt?"Is built.\n":"Is not built.\n")
214 <<(muonchambers?"Has muon chambers.\n":"No muon chambers.\n");
215 std::cout<<"Contains following volhandles: [";
216 for (auto vol : vollist) std::cout<<&vol<<",";
217 std::cout<<"]"<<std::endl;
218 std::cout<<"Matname = "<<matname<<std::endl;
219 std::cout<<"Contains following TreetopInfo: [";
220 for (const auto& tt : treetopinfo) std::cout<<tt.volname<<",";
221 std::cout<<"]"<<std::endl;
222
223 }
224
225 };
226
227 QList<SubSystemInfo*> subsysInfoList;//We need to keep and ordered version also (since wildcards in regexp might match more than one subsystem info).
229 const QString& treetopregexp, const QString& childrenregexp="",
230 const std::string& matname="", bool negatetreetopregexp = false, bool negatechildrenregexp = false,
231 const QString& grandchildrenregexp="", bool negategrandchildrenregexp = false);
232
233 SubSystemInfo* chamberPVToMuonSubSystemInfo(const GeoPVConstLink& chamberPV);
234
243
244 VP1GeoFlags::SubSystemFlags initialSubSystemsTurnedOn;
249
250 //Helpers used for printouts://FIXME: To VolumeHandle!!
251 static double exclusiveMass(const PVConstLink& pv);
252 static double inclusiveMass(const PVConstLink& pv);
253 static double volume(const PVConstLink& pv);
254
255 //Basically for the zapping, and to ignore all clicks with ctrl/shift:
256 static void catchKbdState(void *userData, SoEventCallback *CB);
257 const SoKeyboardEvent *kbEvent;
258
259 //For automatic (de)iconisation of muon chambers:
260 std::map<PVConstLink,VolumeHandle*> muonchambers_pv2handles;
261 void updateTouchedMuonChamber(VolumeHandle * chamberhandle );
262 std::map<QObject*,std::set<GeoPVConstLink> > sender2ChamberList;
263
264 //Check all tubes in chamber and returns directions parallel with a tube which is closest to present camera direction (as well as the "up" directions of that tube):
265 std::pair<SbVec3f,SbVec3f> getClosestMuonDriftTubeDirections(const SbVec3f& cameraDirection, const SbVec3f& cameraUpDirection, VolumeHandle * chamberhandle );
266 std::pair<SbVec3f,SbVec3f> getClosestCSCOrTGCEdgeDirections(const SbVec3f& cameraDirection, VolumeHandle * chamberhandle );
268
269 //For letting other systems know what is the appropriate data projections:
271
273 void expandVisibleVolumesRecursively(VolumeHandle*,const QRegExp&,bool bymatname);
274 void iconifyVisibleVolumesRecursively(VolumeHandle*,const QRegExp&,bool bymatname);
275
276 SoSeparator* m_textSep;
277
278 #ifndef BUILDVP1LIGHT
279 std::map<GeoPVConstLink,const MuonGM::MuonStation*> pv2MuonStation;
283 QStringList stationInfo(const MuonGM::MuonStation*);
284 #endif
285
286 void expandAllChildren(VolumeHandle*, bool isPixel, bool brl, bool ecA, bool ecC);
288 void showITkPixelModules(VolumeHandle*, bool brl, bool ecA, bool ecC);
289 void showITkStripModules(VolumeHandle*, bool brl, bool ecA, bool ecC);
290 bool selectITkComponent(VolumeHandle*, bool isPixel, bool pixelModules, bool pixelServices, bool pixelSupports, bool stripSensors, bool stripElectronics, bool stripServices, bool stripSupports, unsigned inheritedCategory = 0);
293
294 QMap<quint32,QByteArray> restoredTopvolstates;
295 void applyTopVolStates(const QMap<quint32,QByteArray>&, bool disablenotif = false);
296
297 // Helper function for emiting a signal to the PartSpect system
298 // This function creates path entry prefixes (=Detector Factory name in G4) and extra
299 // path entries (top level volumes, python envelopes) depending on the subsystem of the selected volume
300 void createPathExtras(const VolumeHandle*, QString&, QStack<QString>&);
301
302 QList<const std::map<GeoPVConstLink, float>*> chamberT0s;
303};
304
305//_____________________________________________________________________________________
306VP1GeometrySystem::VP1GeometrySystem( const VP1GeoFlags::SubSystemFlags& SubSystemsTurnedOn, const QString& name )
308 "This system displays the geometry as defined in the GeoModel tree.",
309 "Riccardo.Maria.Bianchi@cern.ch"),
310 m_d(new Imp(this,SubSystemsTurnedOn))
311{
312}
313
314
315//_____________________________________________________________________________________
317{
318
319 m_d->volumetreemodel->cleanup();
320 delete m_d->matVisAttributes; m_d->matVisAttributes = 0;
321 delete m_d->detVisAttributes; m_d->detVisAttributes = 0;
322 delete m_d->volVisAttributes; m_d->volVisAttributes = 0;
323
324 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList)
325 delete subsys;
326 m_d->subsysInfoList.clear();
327
328}
329
330//_____________________________________________________________________________________
332{
333 delete m_d;
334 m_d = 0;
335}
336
337//_____________________________________________________________________________________
340 m_d->controller->setGeometrySelectable(b);
341}
342
343//_____________________________________________________________________________________
346 m_d->controller->setZoomToVolumeOnClick(b);
347}
348
349//_____________________________________________________________________________________
351{
353 m_d->controller->setOrientViewToMuonChambersOnClick(b);
354}
355
356//_____________________________________________________________________________________
358{
360 if (m_d->controller->autoAdaptMuonChambersToEventData()!=b) {
361 m_d->controller->setAutoAdaptMuonChambersToEventData(b);
362 if (b)
364 }
365}
366
367//_____________________________________________________________________________________
369 const QString& treetopregexp, const QString& childrenregexp,
370 const std::string& matname, bool negatetreetopregexp, bool negatechildrenregexp,
371 const QString& grandchildrenregexp, bool negategrandchildrenregexp)
372{
373 theclass->messageDebug("VP1GeometrySystem::Imp::addSubSystem - flag: '" + QString(f) + "' - matName: '" + str(matname.c_str()) + "'." );
374
375 QCheckBox * cb = controller->subSystemCheckBox(f);
376 if (!cb) {
377 theclass->message("Error: Problems retrieving checkbox for subsystem "+str(f));
378 return;
379 }
380 subsysInfoList << new SubSystemInfo(cb,QRegExp(treetopregexp),negatetreetopregexp,
381 QRegExp(childrenregexp),negatechildrenregexp,f,matname,
382 QRegExp(grandchildrenregexp), negategrandchildrenregexp);
383 //FIXME: DELETE!!!
384}
385
386//_____________________________________________________________________________________
388{
389 message("VP1GeometrySystem::buildController");
390
391 m_d->controller = new GeoSysController(this);
392
393 m_d->phisectormanager = new PhiSectorManager(m_d->controller->phiSectionWidget(),this,this);
394
395
396 connect(m_d->controller,SIGNAL(showVolumeOutLinesChanged(bool)),this,SLOT(setShowVolumeOutLines(bool)));
397 setShowVolumeOutLines(m_d->controller->showVolumeOutLines());
398 connect(m_d->controller,SIGNAL(saveMaterialsToFile(QString,bool)),this,SLOT(saveMaterialsToFile(QString,bool)));
399 connect(m_d->controller,SIGNAL(loadMaterialsFromFile(QString)),this,SLOT(loadMaterialsFromFile(QString)));
400
401 connect(m_d->controller,SIGNAL(transparencyChanged(float)),this,SLOT(updateTransparency()));
404 connect (m_d->controller,SIGNAL(volumeResetRequested(VolumeHandle*)),
406 connect(m_d->controller,SIGNAL(adaptMuonChambersToEventData()),this,SLOT(adaptMuonChambersToEventData()));
407 connect(m_d->controller,SIGNAL(muonChamberAdaptionStyleChanged(VP1GeoFlags::MuonChamberAdaptionStyleFlags)),
408 this,SLOT(adaptMuonChambersStyleChanged()));
409 connect(m_d->controller,SIGNAL(autoExpandByVolumeOrMaterialName(bool,QString)),this,SLOT(autoExpandByVolumeOrMaterialName(bool,QString)));
410 connect(m_d->controller,SIGNAL(autoIconifyByVolumeOrMaterialName(bool,QString)),this,SLOT(autoIconifyByVolumeOrMaterialName(bool,QString)));
411 connect(m_d->controller,SIGNAL(actionOnAllNonStandardVolumes(bool)),this,SLOT(actionOnAllNonStandardVolumes(bool)));
412 connect(m_d->controller,SIGNAL(autoAdaptPixelsOrSCT(bool,bool,bool,bool,bool,bool)),this,SLOT(autoAdaptPixelsOrSCT(bool,bool,bool,bool,bool,bool)));
413 connect(m_d->controller,SIGNAL(autoAdaptMuonNSW(bool,bool,bool,bool,bool,bool)),this,SLOT(autoAdaptMuonNSW(bool, bool,bool,bool,bool,bool)));
414 connect(m_d->controller,SIGNAL(autoAdaptHGTD(bool,bool,bool,bool,bool,bool,bool)),this,SLOT(autoAdaptHGTD(bool,bool,bool,bool,bool,bool,bool)));
415 connect(m_d->controller,SIGNAL(autoAdaptITk(bool,bool,bool,bool,bool,bool,bool,bool)),this,SLOT(autoAdaptITk(bool,bool,bool,bool,bool,bool,bool,bool)));
416 connect(m_d->controller,SIGNAL(resetSubSystems(VP1GeoFlags::SubSystemFlags)),this,SLOT(resetSubSystems(VP1GeoFlags::SubSystemFlags)));
417
418 connect(m_d->controller,SIGNAL(labelsChanged(int)),this,SLOT(setLabels(int)));
419 connect(m_d->controller,SIGNAL(labelPosOffsetChanged(QList<int>)),this,SLOT(setLabelPosOffsets(QList<int>)));
420 setLabels(m_d->controller->labels());
421
422
423 /* This is where we define the available different subsystems and their location in the geomodel tree.
424 *
425 * if the reg expr does not match any volume, the corresponding subsystem checkbox in the Geo GUI gets disabled.
426 *
427 * syntax: addSubSystem(VP1GeoFlags::SubSystemFlag&, // the associated system flag
428 QString& treetopregexp, // the regular expr for the top/root name of the main sub-detector system
429 QString& childrenregexp="", // the reg expr for the children of the main sub-detector
430 std::string& matname="", // a name we choose for displaying in VP1
431 bool negatetreetopregexp = false, // if we want to negate the top reg expr
432 bool negatechildrenregexp = false); // if we want to negate the children reg expr
433 const QString& grandchildrenregexp="", // the regex for granchildren of the main sub-detector
434 bool negategrandchildrenregexp = false // wheter we want to negate teh granchildren regex
435 */
436
438 m_d->addSubSystem( VP1GeoFlags::ITkPixel,"ITkPixel", "", "ITkPixel");
439 m_d->addSubSystem( VP1GeoFlags::ITkStrip,"ITkStrip", "", "ITkStrip");
440 } else {
441 m_d->addSubSystem( VP1GeoFlags::Pixel,"Pixel");
442 m_d->addSubSystem( VP1GeoFlags::SCT,"SCT");
443 m_d->addSubSystem( VP1GeoFlags::TRT,"TRT");
444 }
446 m_d->addSubSystem(VP1GeoFlags::HGTD, "HGTD", "", "HGTD");
447 }
448 m_d->addSubSystem( VP1GeoFlags::InDetServMat,"InDetServMat");
449 m_d->addSubSystem( VP1GeoFlags::LAr, ".*LAr.*");
450 m_d->addSubSystem( VP1GeoFlags::Tile,"Tile");
451 m_d->addSubSystem( VP1GeoFlags::CavernInfra,"CavernInfra");
452 m_d->addSubSystem( VP1GeoFlags::BeamPipe,"BeamPipe");
453 m_d->addSubSystem( VP1GeoFlags::LUCID,".*Lucid.*");
454 m_d->addSubSystem( VP1GeoFlags::ZDC,".*ZDC.*");
455 m_d->addSubSystem( VP1GeoFlags::ALFA,".*ALFA.*");
456 m_d->addSubSystem( VP1GeoFlags::AFP,".*AFP.*");
457 m_d->addSubSystem( VP1GeoFlags::ForwardRegion,".*ForwardRegion.*");
458
459 //The muon systems require special treatment, since we want to
460 //cherrypick below the treetop (this is the main reason for a lot
461 //of the ugly stuff in this class):
462 m_d->addSubSystem( VP1GeoFlags::MuonEndcapStationCSC,"Muon","CS.*","CSC");
463 m_d->addSubSystem( VP1GeoFlags::MuonEndcapStationTGC,"Muon","T(1|2|3|4).*","TGC");
464 m_d->addSubSystem( VP1GeoFlags::MuonEndcapStationMDT,"Muon","(EI|EM|EO|EE).*","EndcapMdt");
465 m_d->addSubSystem( VP1GeoFlags::MuonEndcapStationNSW,"Muon",".*ANON.*","MuonNSW",false, false, "NewSmallWheel.*");
466
467 m_d->addSubSystem( VP1GeoFlags::MuonBarrelStationInner,"Muon","(BI|BEE).*","BarrelInner");
468 m_d->addSubSystem( VP1GeoFlags::MuonBarrelStationMiddle,"Muon","BM.*","BarrelMiddle");
469 m_d->addSubSystem( VP1GeoFlags::MuonBarrelStationOuter,"Muon","BO.*","BarrelOuter");
470
471 //This last one is even more horrible. We want everything from the Muon treetop that is NOT included elsewhere:
472// m_d->addSubSystem( VP1GeoFlags::MuonToroidsEtc,"Muon","(CS|T1|T2|T3|T4|EI|EM|EO|EE|BI|BEE|BM|BO).*","Muon",false,true);
473
474 // Toroid
475 m_d->addSubSystem( VP1GeoFlags::BarrelToroid,"Muon",".*ANON.*","BarrelToroid", false, false, "BAR_Toroid.*");
476 m_d->addSubSystem( VP1GeoFlags::ToroidECA,"Muon",".*ANON.*","ToroidECA", false, false, "ECT_Toroids.*");
477// m_d->addSubSystem( VP1GeoFlags::ToroidECC,"Muon",".*ANON.*","ToroidECC", false, false, "ECT_Toroids");
478
479 // Muon Feet
480 m_d->addSubSystem( VP1GeoFlags::MuonFeet,"Muon",".*ANON.*","MuonFeet", false, false, "Feet.*");
481
482 // Muon shielding
483 m_d->addSubSystem( VP1GeoFlags::MuonShielding,"Muon",".*ANON.*","Shielding", false, false, "(JDSH|JTSH|JFSH).*");
484
485
486 // All muon stuff --> this will be linked to the "Services" checkbox in the GUI
487 // m_d->addSubSystem( VP1GeoFlags::MuonToroidsEtc,"Muon","(CS|T1|T2|T3|T4|EI|EM|EO|EE|BI|BEE|BM|BO).*","MuonEtc",false,true);
488 m_d->addSubSystem( VP1GeoFlags::MuonToroidsEtc,"Muon",".*(CS|T1|T2|T3|T4|EI|EM|EO|EE|BI|BEE|BM|BO).*","MuonEtc",false,true,"(ECT_Toroids|BAR_Toroid|Feet|NewSmallWheel|JDSH|JTSH|JFSH).*",true);
489
490 // m_d->addSubSystem( VP1GeoFlags::MuonToroidsEtc,"Muon","*.Feet.*","MuonEtc");
491
492 //This one MUST be added last. It will get slightly special treatment in various places!
493 m_d->addSubSystem( VP1GeoFlags::AllUnrecognisedVolumes,".*");
494
495
496 //Setup models/views for volume tree browser and zapped volumes list:
497 m_d->volumetreemodel = new VolumeTreeModel(m_d->controller->volumeTreeBrowser());
498 m_d->controller->volumeTreeBrowser()->header()->hide();
499 m_d->controller->volumeTreeBrowser()->uniformRowHeights();
500 m_d->controller->volumeTreeBrowser()->setModel(m_d->volumetreemodel);
501
502 return m_d->controller;
503}
504
505
506//_____________________________________________________________________________________
508{
509 m_d->ensureInitVisAttributes();
510}
511
512//_____________________________________________________________________________________
513void VP1GeometrySystem::Imp::catchKbdState(void *address, SoEventCallback *CB) {
514 VP1GeometrySystem::Imp *This=static_cast<VP1GeometrySystem::Imp*>(address);
515 if (This)
516 This->kbEvent = static_cast<const SoKeyboardEvent *>(CB->getEvent());
517}
518
519//_____________________________________________________________________________________
521{
522 m_d->sceneroot = root;
523
524 #ifndef BUILDVP1LIGHT
526 message("Error: GeoModel not configured properly in job.");
527 return;
528 }
529
530 //Get the world volume:
531 const GeoModelExperiment * theExpt;
532 if (!VP1SGAccessHelper(this,true).retrieve(theExpt,"ATLAS")) {
533 message("Error: Could not retrieve the ATLAS GeoModelExperiment from detector store");
534 return;
535 }
536 #endif
537
538 #ifdef BUILDVP1LIGHT
539 GeoModelExperiment* theExpt = m_d->getGeometry();
540 #endif
541 PVConstLink world(theExpt->getPhysVol());
542
543 if (!m_d->m_textSep) {
544 // FIXME!
545 // std::cout<<"Making new Text sep"<<std::endl;
546 m_d->m_textSep = new SoSeparator;
547 m_d->m_textSep->setName("TextSep");
548 m_d->m_textSep->ref();
549 }
550 m_d->sceneroot->addChild(m_d->m_textSep);
551
552 // FIXME - what if font is missing?
553 SoFont *myFont = new SoFont;
554 myFont->name.setValue("Arial");
555 myFont->size.setValue(12.0);
556 m_d->m_textSep->addChild(myFont);
557
558 bool save = root->enableNotify(false);
559
560 //Catch keyboard events:
561 SoEventCallback *catchEvents = new SoEventCallback();
562 catchEvents->addEventCallback(SoKeyboardEvent::getClassTypeId(),Imp::catchKbdState, m_d);
563 root->addChild(catchEvents);
564
565 root->addChild(m_d->controller->drawOptions());
566 root->addChild(m_d->controller->pickStyle());
567
568 if(VP1Msg::debug()){
569 qDebug() << "Configuring the default systems... - subsysInfoList len:" << (m_d->subsysInfoList).length();
570 }
571 // we switch on the systems flagged to be turned on at start
572 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList)
573 {
574 VP1Msg::messageDebug("Switching on this system: " + QString::fromStdString(subsys->matname) + " - " + subsys->flag);
575 bool on(m_d->initialSubSystemsTurnedOn & subsys->flag);
576 subsys->checkbox->setChecked( on );
577 subsys->checkbox->setEnabled(false);
578 subsys->checkbox->setToolTip("This sub-system is not available");
579 connect(subsys->checkbox,SIGNAL(toggled(bool)),this,SLOT(checkboxChanged()));
580 }
581
582 //Locate geometry info for the various subsystems, and add the info as appropriate:
583
584 QCheckBox * checkBoxOther = m_d->controller->subSystemCheckBox(VP1GeoFlags::AllUnrecognisedVolumes);
585
586 if(VP1Msg::debug()){
587 qDebug() << "Looping on volumes from the input GeoModel...";
588 }
589 GeoVolumeCursor av(world);
590 while (!av.atEnd()) {
591
592 std::string name = av.getName();
593 if(VP1Msg::debug()){
594 qDebug() << "volume name:" << QString::fromStdString(name);
595 }
596
597 // DEBUG
598 VP1Msg::messageDebug("DEBUG: Found GeoModel treetop: "+QString(name.c_str()));
599
600 //Let us see if we recognize this volume:
601 bool found = false;
602 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList) {
603 if (subsys->negatetreetopregexp!=subsys->geomodeltreetopregexp.exactMatch(name.c_str()))
604 {
605 if (subsys->checkbox==checkBoxOther&&found) {
606 continue;//The "other" subsystem has a wildcard which matches everything - but we only want stuff that is nowhere else.
607 }
608
609 if(VP1Msg::debug()){
610 qDebug() << (subsys->geomodeltreetopregexp).pattern() << subsys->geomodeltreetopregexp.exactMatch(name.c_str()) << subsys->negatetreetopregexp;
611 qDebug() << "setting 'found' to TRUE for pattern:" << (subsys->geomodeltreetopregexp).pattern();
612 }
613 found = true;
614 //We did... now, time to extract info:
615 subsys->treetopinfo.resize(subsys->treetopinfo.size()+1);
616 subsys->treetopinfo.back().pV = av.getVolume();
617 subsys->treetopinfo.back().xf = Amg::EigenTransformToCLHEP(av.getTransform());
618 subsys->treetopinfo.back().volname = av.getName();
619
620 //Add a switch for this system (turned off for now):
621 SoSwitch * sw = new SoSwitch();
622 //But add a separator on top of it (for caching):
623 subsys->soswitch = sw;
624 if (sw->whichChild.getValue() != SO_SWITCH_NONE)
625 sw->whichChild = SO_SWITCH_NONE;
626 SoSeparator * sep = new SoSeparator;
627 sep->addChild(sw);
628 root->addChild(sep);
629 //Enable the corresponding checkbox:
630 subsys->checkbox->setEnabled(true);
631 subsys->checkbox->setToolTip("Toggle the display of the "+subsys->checkbox->text()+" sub system");
632 //NB: Dont break here - several systems might share same treetop!
633 // break;
634 }
635 }
636 if (!found) {
637 message("Warning: Found unexpected GeoModel treetop: "+QString(name.c_str()));
638 }
639
640 av.next(); // increment volume cursor.
641 }
642
643 //Hide other cb if not needed:
644 if (!checkBoxOther->isEnabled())
645 checkBoxOther->setVisible(false);
646
647 //Build the geometry for those (available) subsystems that starts out being turned on:
648 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList) {
649 if (!subsys->soswitch||!subsys->checkbox->isChecked())
650 continue;
651 m_d->buildSystem(subsys);
652 //Enable in 3D view:
653 if (subsys->soswitch->whichChild.getValue() != SO_SWITCH_ALL)
654 subsys->soswitch->whichChild = SO_SWITCH_ALL;
655 //Enable in tree browser:
656 m_d->volumetreemodel->enableSubSystem(subsys->flag);
657 // new ModelTest(m_d->volumetreemodel, m_d->treeView_volumebrowser);
658 }
659 if (!m_d->restoredTopvolstates.isEmpty()) {
660 m_d->applyTopVolStates(m_d->restoredTopvolstates,false);
661 m_d->restoredTopvolstates.clear();
662 }
663 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
664 root->enableNotify(save);
665 if (save)
666 root->touch();
667
668
669 if (m_d->controller->autoAdaptMuonChambersToEventData())
671
672 //To ensure we emit it once upon startup:
673 QTimer::singleShot(0, this, SLOT(emit_appropriateMDTProjectionsChanged()));
674}
675
676#ifdef BUILDVP1LIGHT
677//_____________________________________________________________________________________
678GeoModelExperiment* VP1GeometrySystem::Imp::getGeometry()
679{
680 // return getDummyGeometry(); // for test
681 return getGeometryFromLocalDB(); // for production
682}
683#endif
684
685#ifdef BUILDVP1LIGHT
686//_____________________________________________________________________________________
687GeoModelExperiment* VP1GeometrySystem::Imp::createTheExperiment(GeoPhysVol* world)
688{
689 if (world == nullptr)
690 {
691 // Setup the 'World' volume from which everything else will be suspended
692 double densityOfAir=0.1;
693 const GeoMaterial* worldMat = new GeoMaterial("std::Air", densityOfAir);
694 const GeoBox* worldBox = new GeoBox(1000*CLHEP::cm, 1000*CLHEP::cm, 1000*CLHEP::cm);
695 const GeoLogVol* worldLog = new GeoLogVol("WorldLog", worldBox, worldMat);
696 // GeoPhysVol* worldPhys = new GeoPhysVol(worldLog);
697 world = new GeoPhysVol(worldLog);
698 }
699 // Setup the 'Experiment' manager
700 GeoModelExperiment* theExperiment = new GeoModelExperiment(world);
701 return theExperiment;
702}
703
704
705//_____________________________________________________________________________________
706GeoModelExperiment* VP1GeometrySystem::Imp::getDummyGeometry()
707{
708 // create the world volume container and its manager
709 GeoModelExperiment* theExperiment = createTheExperiment();
710 //GeoPhysVol* world = theExperiment->getPhysVol();
711
712// // we create the 'detector' geometry and we add it to the world volume
713// ToyDetectorFactory factory(NULL); // more complex geometry example
714// // SimplestToyDetectorFactory factory(NULL); // more complex geometry example
715// factory.create(world);
716// std::cout << "treetop numbers: " << factory.getDetectorManager()->getNumTreeTops() << std::endl;
717 VP1Msg::messageDebug("Method VP1GeometrySystem::Imp::getDummyGeometry() has to be ported to the new standalone GeoModel.");
718
719 return theExperiment;
720}
721
722
723//_____________________________________________________________________________________
724GeoModelExperiment* VP1GeometrySystem::Imp::getGeometryFromLocalDB()
725{
726
727 // GET GEOMETRY FROM LOCAL DB
728 // Set valid db path before first run
729 // static const QString path = "../../local/data/geometry.db";
730 QSettings settings("ATLAS", "VP1Light");
731 QString path = settings.value("db/path").toString();
732 if(VP1Msg::debug()){
733 qDebug() << "Using this DB file:" << path;
734 }
735
736
737 // check if DB file exists. If not, return
738 if (! QFileInfo(path).exists() ) {
739 qWarning() << "ERROR!! DB '" << path << "' does not exist!!";
740 qWarning() << "Returning..." << "\n";
741 // return;
742 throw;
743 }
744 // open the DB
745 GMDBManager* db = new GMDBManager(path);
746 /* Open database */
747 if (db->isOpen()) {
748 if(VP1Msg::debug()){
749 qDebug() << "OK! Database is open!";
750 }
751 }
752 else {
753 if(VP1Msg::debug()){
754 qDebug() << "Database is not open!";
755 }
756 // return;
757 throw;
758 }
759
760 /* setup the GeoModel reader */
761 GeoModelPers::GReadIn readInGeo = GeoModelPers::GReadIn(db);
762 if(VP1Msg::debug()){
763 qDebug() << "GReadIn set.";
764 }
765
766 /* build the GeoModel geometry */
767 GeoPhysVol* dbPhys = readInGeo.buildGeoModel(); // builds the whole GeoModel tree in memory
768 // GeoPhysVol* worldPhys = readInGeo.getGeoModelHandle(); // get only the root volume and its first-level children
769 if(VP1Msg::debug()){
770 qDebug() << "GReadIn::buildGeoModel() done.";
771 }
772 // create the world volume container and its manager
773 GeoModelExperiment* theExperiment = createTheExperiment(dbPhys);
774 // GeoPhysVol* world = theExperiment->getPhysVol();
775
776 return theExperiment;
777
778}
779#endif
780
781//_____________________________________________________________________________________
783{
784 QCheckBox * cb = static_cast<QCheckBox*>(sender());
785 Imp::SubSystemInfo * subsys(0);
786 for (Imp::SubSystemInfo * ss : m_d->subsysInfoList) {
787 if (cb==ss->checkbox) {
788 subsys=ss;
789 break;
790 }
791 }
792 if (!subsys) {
793 message("ERROR: Unknown checkbox");
794 return;
795 }
796
797 SoSwitch * sw = subsys->soswitch;
798 assert(sw);
799 if (cb->isChecked()) {
800 SbBool save = sw->enableNotify(false);
801 if (sw->getNumChildren()==0) {
802 m_d->buildSystem(subsys);
803 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();//
804 }
805 if (sw->whichChild.getValue() != SO_SWITCH_ALL)
806 sw->whichChild = SO_SWITCH_ALL;
807 sw->enableNotify(save);
808 //Enable in tree browser:
809 m_d->volumetreemodel->enableSubSystem(subsys->flag);
810 // new ModelTest(m_d->volumetreemodel, m_d->treeView_volumebrowser);
811 if (save)
812 sw->touch();
813 } else {
814 if (sw->whichChild.getValue() != SO_SWITCH_NONE)
815 sw->whichChild = SO_SWITCH_NONE;
816 m_d->volumetreemodel->disableSubSystem(subsys->flag);
817 }
818}
819
820//_____________________________________________________________________________________
821void VP1GeometrySystem::userPickedNode(SoNode* , SoPath *pickedPath)
822{
823
825 // We want to find the volumehandle for the volume. To do so, we look //
826 // for the SoSeparator identifying the actual picked shape node, and //
827 // use it to look up the handle: //
829
830 //Looking for the identifying "nodesep", there are three scenarios
831 //for the type signatures of the final part of the path:
832 //
833 // 1) Most shapes:
834 // nodesep -> pickedNode (but we must pop to a group node in case of SoCylinders)
835 //
836 // 2) Volumes Around Z (all phi sectors enabled):
837 // nodesep -> switch -> pickedNode
838 //
839 // 3) Volumes Around Z (only some phi sectors enabled):
840 // nodesep -> switch -> sep -> pickedNode
841 //
842 // In the third scenario we also have to pop the path, in order for
843 // all phi-slices of the part gets highlighted (since more than one
844 // soshape node represents the volume).
845
846
847 VP1Msg::messageDebug("VP1GeometrySystem::userPickedNode()");
848
849 if (pickedPath->getNodeFromTail(0)->getTypeId()==SoCylinder::getClassTypeId())
850 pickedPath->pop();
851
852 if (pickedPath->getLength()<5) {
853 message("Path too short");
854 return;
855 }
856
857 SoSeparator * nodesep(0);
858
859 if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSeparator::getClassTypeId()
860 && pickedPath->getNodeFromTail(2)->getTypeId()==SoSwitch::getClassTypeId()
861 && pickedPath->getNodeFromTail(3)->getTypeId()==SoSeparator::getClassTypeId())
862 {
863 //Scenario 3:
864 nodesep = static_cast<SoSeparator*>(pickedPath->getNodeFromTail(3));
865 pickedPath->pop();//To get highlighting of siblings also.
866 }
867 else if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSwitch::getClassTypeId()
868 && pickedPath->getNodeFromTail(2)->getTypeId()==SoSeparator::getClassTypeId())
869 {
870 //Scenario 2:
871 nodesep = static_cast<SoSeparator*>(pickedPath->getNodeFromTail(2));
872 }
873 else if (pickedPath->getNodeFromTail(1)->getTypeId()==SoSeparator::getClassTypeId()) {
874 //Scenario 1 (normal):
875 nodesep = static_cast<SoSeparator*>(pickedPath->getNodeFromTail(1));
876 }
877 if (!nodesep) {
878 message("Unexpected picked path");
879 return;
880 }
881 if ( (!(nodesep)) || (m_d->sonodesep2volhandle.find(nodesep) == m_d->sonodesep2volhandle.end()) ) {
882 message("Problems finding volume handle");
883 return;
884 }
885 VolumeHandle * volhandle = m_d->sonodesep2volhandle[nodesep];
886 if (!volhandle) {
887 message("Found NULL volume handle");
888 return;
889 }
890
892 // Next thing to do is to check whether volume was clicked on with a //
893 // modifier of SHIFT/CTRL/Z. If so, we have to change the state on //
894 // the volume handle. Otherwise, we need to print some information: //
896
897 //For focus reason, and since Qt doesn't allow standard keys such as
898 //'z' as modifiers, we check for keypress states using a combination
899 //of the inventor and Qt way
900
901 bool shift_isdown = (Qt::ShiftModifier & QApplication::keyboardModifiers());
902// || ( m_d->kbEvent && (SO_KEY_PRESS_EVENT(m_d->kbEvent, SoKeyboardEvent::LEFT_SHIFT)||
903// SO_KEY_PRESS_EVENT(m_d->kbEvent, SoKeyboardEvent::RIGHT_SHIFT)) ) );
904
905 if (shift_isdown) {
906 //Parent of volume should be put in CONTRACTED state.
907 deselectAll();
908 if (volhandle->parent())
910 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
911 return;
912 }
913
914 bool ctrl_isdown = (Qt::ControlModifier & QApplication::keyboardModifiers());
915// || ( m_d->kbEvent && (SO_KEY_PRESS_EVENT(m_d->kbEvent, SoKeyboardEvent::LEFT_CONTROL)||
916// SO_KEY_PRESS_EVENT(m_d->kbEvent, SoKeyboardEvent::RIGHT_CONTROL)) ) );
917
918 if (ctrl_isdown) {
919 //Volume should be put in EXPANDED state if it has children.
920 deselectAll();
921 if (volhandle->nChildren()>0) {
923 }
924 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
925 return;
926 }
927
928 bool z_isdown = m_d->kbEvent && SO_KEY_PRESS_EVENT(m_d->kbEvent,SoKeyboardEvent::Z);
929 if (z_isdown) {
930 //Volume should be put in ZAPPED state.
931 deselectAll();
932 volhandle->setState(VP1GeoFlags::ZAPPED);
933 message("===> Zapping Node: "+volhandle->getName());
934 // std::cout<<"Zapped VH="<<volhandle<<std::endl;
935 return;
936 }
937
939 // Depending on settings, we are to realign the camera if the //
940 // clicked volume is (daughter of) a muon chamber //
942
943 bool orientedView(false);
944 if (m_d->controller->orientViewToMuonChambersOnClick() && volhandle->isInMuonChamber()) {
945 //Volume is an, or is daughter of an, MDT, CSC or TGC chamber
947 orientedView = true;
948 //Now we must fix the tail of the pickedPath to ensure we
949 //select the correct node corresponding to the clicked volume
950 //again (it might have become attached/detached by the call to
951 //orientViewToMuonChamber):
952 if (!VP1QtInventorUtils::changePathTail(pickedPath,m_d->sceneroot,volhandle->nodeSoSeparator())) {
953 message("Warning: Failed to relocate picked node.");
954 deselectAll();
955 }
956 }
957
959 // Zoom to volume //
961
962 //Nb: We don't do this if we already oriented to the muon chamber above.
963 if (!orientedView&&m_d->controller->zoomToVolumeOnClick()) {
964 if (m_d->sceneroot&&volhandle->nodeSoSeparator()) {
965 std::set<SoCamera*> cameras = getCameraList();
966 std::set<SoCamera*>::iterator it,itE = cameras.end();
967 for (it=cameras.begin();it!=itE;++it) {
968 VP1CameraHelper::animatedZoomToSubTree(*it,m_d->sceneroot,volhandle->nodeSoSeparator(),2.0,1.0);
969 }
970 }
971 }
972
973
975 // Update last-select controls //
977
978 m_d->controller->setLastSelectedVolume(volhandle);
979
981 // OK, time to print some information for the volume //
983
984 message("===> Selected Node: "+volhandle->getName());
985 // std::cout<<"VolHandle = "<<volhandle<<std::endl;
986 if (m_d->controller->printInfoOnClick_Shape()) {
987 for (const QString& str : DumpShape::shapeToStringList(volhandle->geoPVConstLink()->getLogVol()->getShape()))
988 message(str);
989 }
990
991 if (m_d->controller->printInfoOnClick_Material()) {
992 message("===> Material:");
993 for (const QString& line : VP1GeomUtils::geoMaterialToStringList(volhandle->geoMaterial()))
994 message(" "+line);
995 }
996
997 if ( m_d->controller->printInfoOnClick_CopyNumber() ) {
998 int cn = volhandle->copyNumber();
999 message("===> CopyNo : "+(cn>=0?QString::number(cn):QString(cn==-1?"Invalid":"Error reconstructing copynumber")));
1000 }
1001
1002 if ( m_d->controller->printInfoOnClick_Transform() ) {
1003
1004 float translation_x, translation_y, translation_z, rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians;
1006 translation_x, translation_y, translation_z,
1007 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
1008 message("===> Local Translation:");
1009 message(" x = "+QString::number(translation_x/CLHEP::mm)+" mm");
1010 message(" y = "+QString::number(translation_y/CLHEP::mm)+" mm");
1011 message(" z = "+QString::number(translation_z/CLHEP::mm)+" mm");
1012 message("===> Local Rotation:");
1013 message(" axis x = "+QString::number(rotaxis_x));
1014 message(" axis y = "+QString::number(rotaxis_y));
1015 message(" axis z = "+QString::number(rotaxis_z));
1016 message(" angle = "+QString::number(rotangle_radians*180.0/M_PI)+" deg");
1018 translation_x, translation_y, translation_z,
1019 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
1020 message("===> Global Translation:");
1021 message(" x = "+QString::number(translation_x/CLHEP::mm)+" mm");
1022 message(" y = "+QString::number(translation_y/CLHEP::mm)+" mm");
1023 message(" z = "+QString::number(translation_z/CLHEP::mm)+" mm");
1024 message("===> Global Rotation:");
1025 message(" axis x = "+QString::number(rotaxis_x));
1026 message(" axis y = "+QString::number(rotaxis_y));
1027 message(" axis z = "+QString::number(rotaxis_z));
1028 message(" angle = "+QString::number(rotangle_radians*180.0/M_PI)+" deg");
1029 }
1030
1031 if (m_d->controller->printInfoOnClick_Tree()) {
1032 std::ostringstream str;
1033 GeoPrintGraphAction pg(str);
1034 volhandle->geoPVConstLink()->exec(&pg);
1035 message("===> Tree:");
1036 for (const QString& line : QString(str.str().c_str()).split("\n"))
1037 message(" "+line);
1038 }
1039
1040 if (m_d->controller->printInfoOnClick_Mass()) {
1041 //FIXME: Move the mass calculations to the volume handles, and let
1042 //the common data cache some of the volume information by
1043 //logVolume).
1044 message("===> Total Mass &lt;===");
1045 message("Inclusive "+QString::number(Imp::inclusiveMass(volhandle->geoPVConstLink())/CLHEP::kilogram)+" kg");
1046 message("Exclusive "+QString::number(Imp::exclusiveMass(volhandle->geoPVConstLink())/CLHEP::kilogram)+" kg");
1047 }
1048
1049 if (m_d->controller->printInfoOnClick_MuonStationInfo()&&volhandle->isInMuonChamber()) {
1050 PVConstLink pvlink = volhandle->topLevelParent()->geoPVConstLink();
1051 std::map<PVConstLink,VolumeHandle*>::const_iterator itChamber = m_d->muonchambers_pv2handles.find(pvlink);
1052 #ifndef BUILDVP1LIGHT
1053 if (itChamber!=m_d->muonchambers_pv2handles.end()) {
1054 m_d->ensureInitPV2MuonStationMap();
1055 std::map<GeoPVConstLink,const MuonGM::MuonStation*>::const_iterator itStation(m_d->pv2MuonStation.find(pvlink));
1056 if (itStation!=m_d->pv2MuonStation.end()) {
1057 message("===> Muon station &lt;===");
1058 message(" ",m_d->stationInfo(itStation->second));
1059 }
1060 }
1061 #endif
1062 }
1063
1065 // Emit a signal for the VP1UtilitySystems::PartSpect system //
1067 QStack<QString> partspectPath, extras;
1068 QString detFactoryName;
1069
1070 VolumeHandle *parentVH(volhandle), *childVH(volhandle);
1071 m_d->createPathExtras(volhandle,detFactoryName,extras);
1072
1073 do {
1074 parentVH = parentVH->parent();
1075 PVConstLink parentPVLink = parentVH ? parentVH->geoPVConstLink() : childVH->geoPVConstLink()->getParent();
1076 if (parentPVLink) {
1077 int indexOfChild = parentVH ? childVH->childNumber() : parentPVLink->indexOf(childVH->geoPVConstLink()).value();
1078
1079 std::string childPVName = parentPVLink->getNameOfChildVol(indexOfChild);
1080 QString pathEntry = childPVName=="ANON" ? detFactoryName+childVH->getName() : QString(childPVName.c_str());
1081
1082 std::optional<int> childCopyNo = parentPVLink->getIdOfChildVol(indexOfChild);
1083 if(childCopyNo) {
1084 QString strCopyNo;
1085 strCopyNo.setNum(*childCopyNo);
1086 pathEntry += ("::"+strCopyNo);
1087 }
1088 partspectPath.push(pathEntry);
1089 childVH = parentVH;
1090 }
1091 }while(parentVH);
1092
1093 while(!extras.isEmpty())
1094 partspectPath.push(extras.pop());
1095
1096 partspectPath.push("Atlas::Atlas");
1097
1098 // Emit the signal
1099 //volhandle cannot be NULL here (coverity 16287)
1100 //int cn=(!volhandle) ? -1 : volhandle->copyNumber();
1101 int cn=volhandle->copyNumber();
1102 plotSpectrum(partspectPath,cn);
1103}
1104
1105//_____________________________________________________________________________________
1107{
1108 VP1Msg::messageDebug("VP1GeometrySystem::Imp::buildSystem()" );
1109
1110 if (!si||si->isbuilt)
1111 return;
1112 si->isbuilt = true;
1113 int ichild(0);
1114
1116 #ifndef BUILDVP1LIGHT
1117 ensureInitPV2MuonStationMap(); // Needed for Muon Station names.
1118 #endif
1119
1120// // DEBUG
1121// for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
1122// VP1Msg::messageDebug("vol: " + QString((si->flag).str_c()) );
1123// }
1124
1125 assert(si->soswitch);
1126 SoSeparator * subsystemsep = new SoSeparator;
1127 phisectormanager->registerSubSystemSeparator(si->flag,subsystemsep);
1128 phisectormanager->largeChangesBegin();
1129
1130 SbBool save = si->soswitch->enableNotify(false);
1131
1132 if (si->geomodelchildrenregexp.isEmpty()) {
1133 //Loop over the treetop's that we previously selected:
1134 std::vector<SubSystemInfo::TreetopInfo>::const_iterator it, itE = si->treetopinfo.end();
1135 for (it=si->treetopinfo.begin();it!=itE;++it)
1136 {
1137 VP1Msg::messageDebug("toptree vol: " + QString(it->volname.c_str()) );
1138
1139 //Find material:
1140 SoMaterial*m = detVisAttributes->get(it->volname);
1141 if (!m) {
1142 theclass->message("Warning: Did not find a predefined material for volume: "+QString(it->volname.c_str()));
1143 }
1146 controller->zappedVolumeListModel(),controller->volumeTreeBrowser(), m_textSep,
1147 detVisAttributes->outlineColour(it->volname));
1148 SbMatrix matr;
1150 VolumeHandle * vh = new VolumeHandle(volhandle_subsysdata,0,it->pV,ichild++,VolumeHandle::NONMUONCHAMBER,matr);
1151 si->vollist.push_back(vh);
1152 // std::cout<<"Non muon chamber VH="<<vh<<std::endl;
1153 }
1154 } else {
1155 //Loop over the children of the physical volumes of the treetops that we previously selected:
1156 std::vector<SubSystemInfo::TreetopInfo>::const_iterator it, itE = si->treetopinfo.end();
1157 for (it=si->treetopinfo.begin();it!=itE;++it) {
1158
1159 VP1Msg::messageDebug("group name: " + QString(si->matname.c_str()) );
1160
1161 //NB: Here we use the si->matname. Above we use the si->volname. Historical reasons!
1162
1163 //Find material for top-nodes:
1164 SoMaterial*mat_top(0);
1165 if (si->matname!="")
1166 mat_top = detVisAttributes->get(si->matname);
1167
1170 controller->zappedVolumeListModel(),controller->volumeTreeBrowser(),m_textSep,
1171 detVisAttributes->outlineColour(si->matname));
1172 volhandle_subsysdata->ref();
1173
1174 const bool hasMuonChambers=si->hasMuonChambers();
1175
1176 GeoVolumeCursor av(it->pV);
1177 //unsigned int count=0;
1178 while (!av.atEnd()) {
1179
1180 // DEBUG
1181// VP1Msg::messageDebug("child vol: " + QString(av.getName().c_str()) );
1182
1183 //Use the childrenregexp to select the correct child volumes:
1184 if (si->childrenRegExpNameCompatible(av.getName().c_str())) {
1185 PVConstLink pVD = av.getVolume();
1186 SbMatrix matr;
1188 VolumeHandle * vh=0;
1189 // std::cout<<count++<<": dump SubSystemInfo\n"<<"---"<<std::endl;
1190 // si->dump();
1191 // std::cout<<"---"<<std::endl;
1192 if (hasMuonChambers){
1193 #ifndef BUILDVP1LIGHT
1194 vh = new MuonVolumeHandle(volhandle_subsysdata,0,pVD,ichild++,VolumeHandle::MUONCHAMBER_DIRTY,matr,pv2MuonStation[pVD],chamberT0s);
1195 #endif
1196 #ifdef BUILDVP1LIGHT
1197 vh = new VolumeHandle(volhandle_subsysdata,0,pVD,ichild++,VolumeHandle::MUONCHAMBER_DIRTY,matr);
1198 #endif
1199 muonchambers_pv2handles[pVD] = vh;
1200 if(VP1Msg::debug()){
1201 std::cout<<"Has muon chamber VH="<<vh<<std::endl;
1202 }
1203
1204 } else {
1205
1206 vh = new VolumeHandle(volhandle_subsysdata,0,pVD,ichild++,
1208 // std::cout<<"Does not have muon chamber (weird one) VH="<<vh<<std::endl;
1209 }
1210
1211 // DEBUG
1212// VP1Msg::messageDebug("granchild vol: " + vh->getName() + " - " + vh->getDescriptiveName() );
1213
1214 if (si->geomodelgrandchildrenregexp.isEmpty()) {
1215 // append the volume to the current list
1216 theclass->messageDebug("grandchild inserted : " + vh->getDescriptiveName() + " - " + vh->getName() );
1217 si->vollist.push_back(vh);
1218
1219 } else {
1220 VP1Msg::messageDebug("filtering at grandchild level...");
1221 if (si->grandchildrenRegExpNameCompatible(vh->getName().toStdString() ) ) {
1222 VP1Msg::messageDebug("filtered grandchild inserted : " + vh->getDescriptiveName() + " - " + vh->getName() );
1223 // append the volume to the current list
1224 si->vollist.push_back(vh);
1225 } else {
1226 theclass->message("Zapping this volumehandle because it's probably junk."+vh->getDescriptiveName() + " - " + vh->getName());
1227 vh->setState(VP1GeoFlags::ZAPPED); // FIXME - better solution for this? Maybe just don't create them?
1228
1229 // std::cout<<"Not adding "<<vh->getName().toStdString()<<"["<<vh<<"] to vollist"<<std::endl;
1230 }
1231 }
1232 }
1233 av.next(); // increment volume cursor.
1234 }
1235 volhandle_subsysdata->unref();//To ensure it is deleted if it was not used.
1236 }
1237 }
1238
1239 if (VP1Msg::debug()) si->dump();
1240
1241 VP1Msg::messageDebug("volumetreemodel->addSubSystem...");
1242 volumetreemodel->addSubSystem( si->flag, si->vollist );
1243
1244 //NB: We let the destructor of volumetreemodel take care of deleting
1245 //our (top) volume handles, since it has to keep a list of them
1246 //anyway.
1247
1248
1249 //Perform auto expansion of all ether volumes (needed for muon dead material):
1250 VP1Msg::messageDebug("Perform auto expansion of all ether volumes (needed for muon dead material)");
1251 VolumeHandle::VolumeHandleListItr it, itE(si->vollist.end());
1252 //int idx=0; // for debug
1253 for (it = si->vollist.begin(); it!=itE; ++it){
1254 //VP1Msg::messageDebug("\nexpanding idx: " + QString::number(++idx));
1255 (*it)->expandMothersRecursivelyToNonEther();
1256 //VP1Msg::messageDebug("expand DONE.");
1257 }
1258
1259
1260 VP1Msg::messageDebug("addChild...");
1261 phisectormanager->updateRepresentationsOfVolsAroundZAxis();
1262 phisectormanager->largeChangesEnd();
1263 si->soswitch->addChild(subsystemsep);
1264 si->soswitch->enableNotify(save);
1265 if (save)
1266 si->soswitch->touch();
1267 VP1Msg::messageDebug("END of VP1GeometrySystem::Imp::buildSystem() " );
1268}
1269
1270//_____________________________________________________________________________________
1271double VP1GeometrySystem::Imp::exclusiveMass(const PVConstLink& pv) {
1272 const GeoLogVol* lv = pv->getLogVol();
1273 const GeoMaterial *material = lv->getMaterial();
1274 double density = material->getDensity();
1275 return density*volume(pv);
1276}
1277
1278
1279//_____________________________________________________________________________________
1280double VP1GeometrySystem::Imp::volume(const PVConstLink& pv) {
1281 const GeoLogVol * lv = pv->getLogVol();
1282 const GeoShape *shape = lv->getShape();
1283 return shape->volume();
1284}
1285
1286
1287//_____________________________________________________________________________________
1288double VP1GeometrySystem::Imp::inclusiveMass(const PVConstLink& pv) {
1289
1290 const GeoLogVol* lv = pv->getLogVol();
1291 const GeoMaterial *material = lv->getMaterial();
1292 double density = material->getDensity();
1293
1294 double mass = exclusiveMass(pv);
1295
1296 GeoVolumeCursor av(pv);
1297 while (!av.atEnd()) {
1298 mass += inclusiveMass(av.getVolume());
1299 mass -= volume(av.getVolume())*density;
1300 av.next();
1301 }
1302
1303 return mass;
1304}
1305
1306//_____________________________________________________________________________________
1308
1310
1311 VP1Serialise serialise(7/*version*/,this);
1312 serialise.save(IVP13DSystemSimple::saveState());
1313
1314 //Controller:
1315 serialise.save(m_d->controller->saveSettings());
1316
1317 //Subsystem checkboxes:
1318 QMap<QString,bool> subsysstate;
1319 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList) {
1320 serialise.widgetHandled(subsys->checkbox);
1321 subsysstate.insert(subsys->checkbox->text(),subsys->checkbox->isChecked());
1322 }
1323 serialise.save(subsysstate);
1324
1325 //Volume states:
1326 QMap<quint32,QByteArray> topvolstates;
1327 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList) {
1328 if (m_d->controller->autoAdaptMuonChambersToEventData()&&subsys->hasMuonChambers())
1329 continue;//No need to store muon chamber data which will anyway be auto-adapted away.
1330 VolumeHandle::VolumeHandleListItr it(subsys->vollist.begin()),itE(subsys->vollist.end());
1331 for (;it!=itE;++it)
1332 topvolstates.insert((*it)->hashID(),(*it)->getPersistifiableState());
1333 }
1334 serialise.save(topvolstates);
1335
1336 m_d->ensureInitVisAttributes();
1337 serialise.save(m_d->detVisAttributes->getState());//version 7+
1338 serialise.save(m_d->matVisAttributes->getState());//version 7+
1339 serialise.save(m_d->volVisAttributes->getState());//version 7+
1340
1341 serialise.disableUnsavedChecks();//We do the testing in the controller
1342 return serialise.result();
1343}
1344
1345//_____________________________________________________________________________________
1347 VP1Deserialise state(ba,this);
1348 if (state.version()<0||state.version()>7) {
1349 message("Warning: State data in .vp1 file is in wrong format - ignoring!");
1350 return;
1351 }
1352 if (state.version()<=5) {
1353 message("Warning: State data in .vp1 file is in obsolete format - ignoring!");
1354 return;
1355 }
1356
1358 IVP13DSystemSimple::restoreFromState(state.restoreByteArray());
1359
1360 //Controller:
1361 m_d->controller->restoreSettings(state.restoreByteArray());
1362
1363 //Subsystem checkboxes:
1364 VP1GeoFlags::SubSystemFlags flags;
1365 QMap<QString,bool> subsysstate = state.restore<QMap<QString,bool> >();
1366 for (Imp::SubSystemInfo * subsys : m_d->subsysInfoList) {
1367 state.widgetHandled(subsys->checkbox);
1368 if (subsysstate.contains(subsys->checkbox->text())&&subsysstate[subsys->checkbox->text()])
1369 flags |= subsys->flag;
1370 }
1371 m_d->initialSubSystemsTurnedOn = flags;
1372
1373 //Volume states:
1374 QMap<quint32,QByteArray> topvolstates;
1375 topvolstates = state.restore<QMap<quint32,QByteArray> >();
1376 if (m_d->sceneroot)//(for some reason) we already have been in buildPermanentScenegraph
1377 m_d->applyTopVolStates(topvolstates,true);
1378 else
1379 m_d->restoredTopvolstates = topvolstates;//save until buildPermanentScenegraph
1380
1381 if (state.version()>=7) {
1382 m_d->ensureInitVisAttributes();
1383 m_d->detVisAttributes->applyState(state.restoreByteArray());
1384 m_d->matVisAttributes->applyState(state.restoreByteArray());
1385 m_d->volVisAttributes->applyState(state.restoreByteArray());
1386 }
1387
1388 state.disableUnrestoredChecks();//We do the testing in the controller
1389
1390 //Special:
1391 if (m_d->controller->autoAdaptMuonChambersToEventData())
1393}
1394
1395//_____________________________________________________________________________________
1396void VP1GeometrySystem::Imp::applyTopVolStates(const QMap<quint32,QByteArray>&topvolstates,bool disablenotif)
1397{
1398 if (disablenotif)
1399 phisectormanager->largeChangesBegin();
1400 QMap<quint32,QByteArray>::const_iterator topvolstatesItr;
1401 for (Imp::SubSystemInfo * subsys : subsysInfoList) {
1402 VolumeHandle::VolumeHandleListItr it(subsys->vollist.begin()),itE(subsys->vollist.end());
1403 for (;it!=itE;++it) {
1404 topvolstatesItr = topvolstates.find((*it)->hashID());
1405 if (topvolstatesItr!=topvolstates.end())
1406 (*it)->applyPersistifiableState(topvolstatesItr.value());
1407 }
1408 }
1409 if (disablenotif) {
1410 phisectormanager->updateRepresentationsOfVolsAroundZAxis();
1411 phisectormanager->largeChangesEnd();
1412 }
1413}
1414
1415//_____________________________________________________________________________________
1416void VP1GeometrySystem::Imp::createPathExtras(const VolumeHandle* volhandle, QString& prefix, QStack<QString>& entries)
1417{
1418 switch(volhandle->subsystem()){
1419 case VP1GeoFlags::Pixel: {
1420 prefix = QString("Pixel::");
1421 entries.push("IDET::IDET");
1423 entries.push("ITkPixel::ITkPixel");
1424 else
1425 entries.push("Pixel::Pixel");
1426 return;
1427 }
1428 case VP1GeoFlags::SCT:{
1429 prefix = QString("SCT::");
1430 entries.push("IDET::IDET");
1432 entries.push("ITkStrip::ITkStrip");
1433 else
1434 entries.push("SCT::SCT");
1435 return;
1436 }
1437 case VP1GeoFlags::HGTD: {
1438 prefix = QString("HGTD::");
1439 entries.push("IDET::IDET");
1440 entries.push("HGTD::HGTD");
1441 return;
1442 }
1443 case VP1GeoFlags::TRT:{
1444 prefix = QString("TRT::");
1445 entries.push("IDET::IDET");
1446 entries.push("TRT::TRT");
1447 return;
1448 }
1450 prefix = QString("InDetServMat::");
1451 entries.push("IDET::IDET");
1452 return;
1453 }
1454 case VP1GeoFlags::LAr:{
1455 prefix = QString("LArMgr::");
1456 entries.push("CALO::CALO");
1457 entries.push("LArMgr::LArMgr");
1458 return;
1459 }
1460 case VP1GeoFlags::Tile:{
1461 prefix = QString("Tile::");
1462 entries.push("CALO::CALO");
1463 entries.push("Tile::Tile");
1464 return;
1465 }
1479 prefix = QString("Muon::");
1480 entries.push("MUONQ02::MUONQ02");
1481 entries.push("Muon::MuonSys");
1482 return;
1483 }
1485 prefix = QString("BeamPipe::");
1486 entries.push("BeamPipe::BeamPipe");
1487 return;
1488 }
1489 case VP1GeoFlags::None:
1491 case VP1GeoFlags::LUCID:
1492 case VP1GeoFlags::ZDC:
1493 case VP1GeoFlags::ALFA:
1494 case VP1GeoFlags::AFP:
1497 default:{
1498 return;
1499 }
1500 }
1501}
1502
1503//_____________________________________________________________________________________
1505{
1507 if (val<0||val>100) {
1508 message("setCurvedSurfaceRealism Error: Value "+str(val)+"out of range!");
1509 return;
1510 }
1511 m_d->controller->setComplexity(val==100?1.0:(val==0?0.0:val/100.0));
1512}
1513
1514
1515
1516//_____________________________________________________________________________________
1518{
1520
1521 float transparency = m_d->controller->transparency();
1522
1523 VolumeHandle* lastSelVol = m_d->controller->lastSelectedVolume();
1524 m_d->controller->setLastSelectedVolume(0);
1525 m_d->ensureInitVisAttributes();
1526 m_d->detVisAttributes->overrideTransparencies(transparency);
1527 m_d->matVisAttributes->overrideTransparencies(transparency);
1528 m_d->volVisAttributes->overrideTransparencies(transparency);
1529 m_d->controller->setLastSelectedVolume(lastSelVol);
1530}
1531
1532//_____________________________________________________________________________________
1533void VP1GeometrySystem::resetSubSystems(VP1GeoFlags::SubSystemFlags f)
1534{
1535 if (!f) {
1536 return;
1537 }
1538
1539 deselectAll();
1540 for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
1541 if (si->flag & f) {
1542 if (!si->isbuilt) {
1543 continue;
1544 }
1545 VolumeHandle::VolumeHandleListItr it(si->vollist.begin()),itE(si->vollist.end());
1546 for (;it!=itE;++it) {
1547 messageDebug("resetting volume --> " + (*it)->getName() );
1548 (*it)->reset();
1549 }
1550 }
1551 }
1552}
1553
1554//_____________________________________________________________________________________
1556{
1557 if (m_d->muonchambers_pv2handles.empty())
1558 return;
1559
1560 std::set<GeoPVConstLink> allchambers;
1561 if (!m_d->sender2ChamberList.empty()) {
1562 allchambers = (m_d->sender2ChamberList.begin())->second;
1563 std::map<QObject*,std::set<GeoPVConstLink> >::iterator itLists,itListsE(m_d->sender2ChamberList.end());
1564 for (itLists = m_d->sender2ChamberList.begin(),++itLists;itLists != itListsE;++itLists) {
1565 allchambers.insert(itLists->second.begin(),itLists->second.end());
1566 }
1567 }
1568
1569 //Idea: Maybe just iconise them all and then selectively deiconise the few? Then we can avoid most searches!
1570 bool save = m_d->sceneroot->enableNotify(false);
1571 m_d->phisectormanager->largeChangesBegin();
1572
1573 deselectAll();
1574 std::map<PVConstLink,VolumeHandle*>::iterator it, itE=m_d->muonchambers_pv2handles.end();
1575 std::set<GeoPVConstLink>::iterator itchambersE = allchambers.end();
1576 for (it=m_d->muonchambers_pv2handles.begin();it!=itE;++it) {
1577 if (allchambers.find(it->first)==itchambersE)
1578 it->second->setState(VP1GeoFlags::ZAPPED);
1579 else {
1580 if (it->second->muonChamberDirty())
1581 m_d->updateTouchedMuonChamber(it->second);
1582 }
1583 }
1584 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
1585 m_d->phisectormanager->largeChangesEnd();
1586 if (save) {
1587 m_d->sceneroot->enableNotify(true);
1588 m_d->sceneroot->touch();
1589 }
1590}
1591
1592//_____________________________________________________________________________________
1594{
1595 //Make all chamber representations dirty:
1596 std::map<PVConstLink,VolumeHandle*>::iterator it, itE=m_d->muonchambers_pv2handles.end();
1597 for (it=m_d->muonchambers_pv2handles.begin();it!=itE;++it)
1598 it->second->setMuonChamberDirty(true);
1599
1600 //Adapt immediately if necessary:
1601 if (m_d->controller->autoAdaptMuonChambersToEventData())
1604}
1605
1606//_____________________________________________________________________________________
1608{
1609 if (!m_d->controller) {
1610 message("emit_appropriateMDTProjectionsChanged called before controller built.");
1611 return;
1612 }
1613 VP1GeoFlags::MuonChamberAdaptionStyleFlags f(m_d->controller->muonChamberAdaptionStyle());
1614 bool option_openmdtchambers = f & VP1GeoFlags::OpenMDTChambers;
1615 bool option_hidetubes = f & VP1GeoFlags::HideMDTTubes;
1616 int i (option_openmdtchambers?(option_hidetubes?0:1):2);
1617 if ( m_d->last_appropriatemdtprojections != i ) {
1618 m_d->last_appropriatemdtprojections = i;
1620 }
1621}
1622
1623//_____________________________________________________________________________________
1624void VP1GeometrySystem::reiconizeToShowSpecificMuonChambers(const std::set<GeoPVConstLink>& chambers)
1625{
1626 //Update map of touched chamber lists:
1627 bool listChanged(m_d->sender2ChamberList.find(sender())!=m_d->sender2ChamberList.end()?
1628 (chambers != m_d->sender2ChamberList[sender()]):true);
1629 m_d->sender2ChamberList[sender()] = chambers;
1630
1631 //Trigger update if list changed and in auto mode:
1632 if ( listChanged && m_d->controller->autoAdaptMuonChambersToEventData() )
1634}
1635
1636//_____________________________________________________________________________________
1638{
1639 std::string stationname = chamberhandle->getNameStdString();
1640 if (stationname.empty()) {
1641 theclass->message("Warning: Asked to handle muon chamber (station) with empty name!");
1642 return;
1643 }
1644 //NB: For efficiency we make sure that mothers are ZAPPED while
1645 //changing state of their children.
1646
1647 //options:
1648
1649 VP1GeoFlags::MuonChamberAdaptionStyleFlags f(controller->muonChamberAdaptionStyle());
1650 bool option_openmdtchambers = f & VP1GeoFlags::OpenMDTChambers;
1651 bool option_hidetubes = f & VP1GeoFlags::HideMDTTubes;
1652 bool option_hiderpcvolumes = f & VP1GeoFlags::HideRPCVolumes;
1653 bool option_opencscchambers = f & VP1GeoFlags::OpenCSCChambers;
1654 bool option_opentgcchambers = f & VP1GeoFlags::OpenTGCChambers;
1655
1656 char firstletter = stationname[0];
1657 std::string name1,name2;
1658 if (firstletter=='E' || firstletter =='B') {
1659 //Barrel/Endcap MDT.
1660 // If we are to open it, we expand two levels.
1661 // -> and possibly zap the tubes/rpc volumes also according to options.
1662 if (option_openmdtchambers) {
1663 chamberhandle->setState(VP1GeoFlags::ZAPPED);
1664 chamberhandle->contractDaughtersRecursively();
1665 chamberhandle->initialiseChildren();
1666 VolumeHandle::VolumeHandleListItr itch(chamberhandle->childrenBegin()), itchE(chamberhandle->childrenEnd());
1667 for (;itch!=itchE;++itch) {
1668 //Any daughter with the name "Ded..." should be zapped,
1669 //otherwise we loop over the children to zap tubes/rpc vols.
1670 (*itch)->setState(VP1GeoFlags::ZAPPED);
1671 name1 = (*itch)->getNameStdString();
1672 if (name1.size()>2&&name1[0]=='D'&&name1[1]=='e'&&name1[2]=='d')
1673 continue;
1674
1675 (*itch)->initialiseChildren();
1676 VolumeHandle::VolumeHandleListItr itch2((*itch)->childrenBegin()), itch2E((*itch)->childrenEnd());
1677 for (;itch2!=itch2E;++itch2) {
1678 //Any of these daughters with the name
1679 //"MDTDriftWall"/"Rpc..."/"RPC..."/"Ded..." should be
1680 //zapped (according to options). Others should be contracted.
1681 name2 = (*itch2)->getNameStdString();
1682 bool zap = false;
1683 if (option_hidetubes&&name2=="MDTDriftWall") {
1684 zap = true;
1685 } else if (name2.size()>2&&name2[0]=='R'&&((name2[1]=='p'&&name2[2]=='c')||(name2[1]=='P'&&name2[2]=='C'))) {
1686 zap = (option_hiderpcvolumes||name2!="Rpclayer");
1687 } else if (name2.size()>2&&name2[0]=='D'&&name2[1]=='e'&&name2[2]=='d') {
1688 zap = true;
1689 }
1690 (*itch2)->setState(zap?VP1GeoFlags::ZAPPED:VP1GeoFlags::CONTRACTED);
1691 }
1692 (*itch)->setState(VP1GeoFlags::EXPANDED);
1693 }
1694 chamberhandle->setState(VP1GeoFlags::EXPANDED);
1695 } else {
1696 chamberhandle->reset();
1697 }
1698 } else {
1699 if (firstletter=='C') {
1700 //CSC: We either contract completely or expand once + zap "CscArCO2" + zap spacers
1701 chamberhandle->setState(VP1GeoFlags::ZAPPED);
1702 chamberhandle->contractDaughtersRecursively();//To put into default state
1703 if (option_opencscchambers) {
1704 //We must zap spacers, and otherwise expand down three levels and zap all "CscArCO2":
1705 chamberhandle->initialiseChildren();
1706 VolumeHandle::VolumeHandleListItr itch(chamberhandle->childrenBegin()), itchE(chamberhandle->childrenEnd());
1707 for (;itch!=itchE;++itch) {
1708 if ((*itch)->hasName("CSCspacer")) {
1709 (*itch)->setState(VP1GeoFlags::ZAPPED);
1710 continue;
1711 }
1712 if ((*itch)->nChildren()<1)
1713 continue;
1714 (*itch)->initialiseChildren();
1715 VolumeHandle::VolumeHandleListItr itch2((*itch)->childrenBegin()), itch2E((*itch)->childrenEnd());
1716 for (;itch2!=itch2E;++itch2) {
1717 if ((*itch2)->nChildren()<1)
1718 continue;
1719 (*itch2)->initialiseChildren();
1720 VolumeHandle::VolumeHandleListItr itch3((*itch2)->childrenBegin()), itch3E((*itch2)->childrenEnd());
1721 for (;itch3!=itch3E;++itch3) {
1722 if ((*itch3)->getNameStdString()=="CscArCO2")
1723 (*itch3)->setState(VP1GeoFlags::ZAPPED);
1724 }
1725 (*itch2)->setState(VP1GeoFlags::EXPANDED);
1726 }
1727 (*itch)->setState(VP1GeoFlags::EXPANDED);
1728 }
1729 chamberhandle->setState(VP1GeoFlags::EXPANDED);
1730 } else {
1731 chamberhandle->setState(VP1GeoFlags::CONTRACTED);
1732 }
1733 } else {
1734 //TGC: If 'open' we expand two levels and zap all gas volumes.
1735 chamberhandle->setState(VP1GeoFlags::ZAPPED);
1736 chamberhandle->contractDaughtersRecursively();//To put into default state
1737 if (option_opentgcchambers) {
1738 //Expand once more and then zap daughters called "muo::TGCGas"
1739 chamberhandle->initialiseChildren();
1740 VolumeHandle::VolumeHandleListItr itch(chamberhandle->childrenBegin()), itchE(chamberhandle->childrenEnd());
1741 for (;itch!=itchE;++itch) {
1742 if ((*itch)->nChildren()<1)
1743 continue;
1744 (*itch)->initialiseChildren();
1745 VolumeHandle::VolumeHandleListItr itch2((*itch)->childrenBegin()), itch2E((*itch)->childrenEnd());
1746 for (;itch2!=itch2E;++itch2) {
1747 if ((*itch2)->getNameStdString()=="muo::TGCGas")
1748 (*itch2)->setState(VP1GeoFlags::ZAPPED);
1749 }
1750 (*itch)->setState(VP1GeoFlags::EXPANDED);
1751 }
1752 chamberhandle->setState(VP1GeoFlags::EXPANDED);
1753 } else {
1754 chamberhandle->setState(VP1GeoFlags::CONTRACTED);
1755 }
1756 }
1757 }
1758 chamberhandle->setMuonChamberDirty(false);
1759}
1760
1761//_____________________________________________________________________________________
1763{
1764 VP1Msg::messageDebug("VP1GeometrySystem::Imp::chamberPVToMuonSubSystemInfo()");
1765
1766 std::string name = chamberPV->getLogVol()->getName();
1767
1768 VP1Msg::messageDebug("name: " + QString::fromStdString(name) );
1769
1770 for (SubSystemInfo * subsys : subsysInfoList) {
1771 if (!subsys->hasMuonChambers())
1772 continue;
1773 if (subsys->childrenRegExpNameCompatible(name)) {
1774 //NB: We assume once again that all muon chambers are to be
1775 //compared with childrenRegExp.
1776 return subsys;
1777 }
1778 }
1779 return 0;
1780}
1781
1782//_____________________________________________________________________________________
1783void VP1GeometrySystem::orientViewToMuonChamber(const GeoPVConstLink& chamberPV)
1784{
1785 if (!m_d->sceneroot)
1786 return;
1787
1788 //Find relevant muon subsystem info:
1789 Imp::SubSystemInfo * subsys = m_d->chamberPVToMuonSubSystemInfo(chamberPV);
1790 if (!subsys) {
1791 message("Error: Asked to orient view to chamber volume '"
1792 +QString(chamberPV->getLogVol()->getName().c_str())
1793 +"', which doesn't fit the known format of any chamber!");
1794 return;
1795 }
1796
1797 //Subsystem must be available:
1798 if (!subsys->soswitch) {//NB: Could as well look at checkbox enabled state instead of whether sw pointer is null.
1799 message("Warning: Asked to orient view to muon chamber volume which is not available. Perhaps muon geometry was not built?");
1800 return;
1801 }
1802
1803 //Find handle for the muon chamber (possibly ensure that relevant muon subsystem is build):
1804 std::map<PVConstLink,VolumeHandle*>::iterator itChamber = m_d->muonchambers_pv2handles.find(chamberPV);
1805 if (itChamber==m_d->muonchambers_pv2handles.end()) {
1806 //Probably the muon relevant muon system was not initialised. Build and try again:
1807 m_d->buildSystem(subsys);
1808 itChamber = m_d->muonchambers_pv2handles.find(chamberPV);
1809 if (itChamber==m_d->muonchambers_pv2handles.end()) {
1810 message("Error: Asked to orient view to chamber volume '"
1811 +QString(chamberPV->getLogVol()->getName().c_str())
1812 +"', but could not find chamber handle!");
1813 return;
1814 }
1815 }
1816 VolumeHandle * chamberHandle = itChamber->second;
1817
1818 //Figure out if we are MDT, CSC or TGC (if not we print warning and abort);
1819
1820 std::string name = chamberHandle->getNameStdString();
1821
1822 bool isCSCOrTGC = name.size()>=2 && ( (name[0]=='C' && name[1]=='S') || (name[0]=='T') );
1823 if (!isCSCOrTGC&&!(name.size()>=1&&(name[0]=='E'||name[0]=='B'))) {
1824 //Neither CSC, TGC or MDT:
1825 message("orientViewToMuonChamber Warning: Not CSC, TGC or MDT station!");
1826 return;
1827 }
1828
1829 bool save = subsys->soswitch->enableNotify(false);//Disable notifications to avoid chamber flickering in for a moment.
1830
1831 //If subsystem soswitch is turned off, we turn it on temporarily
1832 int32_t soswitch_val = subsys->soswitch->whichChild.getValue();
1833 if (soswitch_val!=SO_SWITCH_ALL)
1834 subsys->soswitch->whichChild = SO_SWITCH_ALL;
1835
1836 VP1GeoFlags::VOLSTATE oldChamberState = chamberHandle->state();
1837 chamberHandle->setState(VP1GeoFlags::CONTRACTED);
1838
1839 SoSeparator * chambersep = chamberHandle->nodeSoSeparator();
1840 if (chambersep) {
1841 std::set<SoCamera*> cameras = getCameraList();
1842 std::set<SoCamera*>::iterator it,itE = cameras.end();
1843 for (it=cameras.begin();it!=itE;++it) {
1844 //Find desired camera orientation (must be parallel to tubes - and
1845 //we choose the one of the possible orientations which is closest to
1846 //current camera orientation - i.e. loop over tubes and try both
1847 //positive and negative directions of each tube.
1848
1849 SbRotation camrot = (*it)->orientation.getValue();
1850 SbVec3f cameraDir(0, 0, -1); // init to default view direction vector
1851 camrot.multVec(cameraDir, cameraDir);
1852 SbVec3f cameraUpVec(0, 1, 0); // init to default up vector
1853 camrot.multVec(cameraUpVec, cameraUpVec);
1854
1855 std::pair<SbVec3f,SbVec3f> chamberdirections;
1856 if (isCSCOrTGC) {
1857 //CSC/TGC chamber - look at top TRD shape for directions
1858 chamberdirections = m_d->getClosestCSCOrTGCEdgeDirections(cameraDir,chamberHandle);
1859 } else {
1860 //MDT chamber - look at tubes for direction
1861 chamberdirections = m_d->getClosestMuonDriftTubeDirections(cameraDir,cameraUpVec,chamberHandle);
1862 }
1863 SbVec3f newdirection = - chamberdirections.first;
1864 SbVec3f newup(cameraUpVec);
1865 const float epsilon(0.00001f);
1866 if (m_d->previousAlignedChamberHandle==chamberHandle&&cameraDir.equals(newdirection,epsilon)) {
1867 //If we already zoomed in the direction of the chamber,
1868 //subsequent requests aligns the upvector along the other chamber
1869 //axes.
1870 SbRotation rot(cameraDir,0.5*M_PI);
1871 SbVec3f chambdir1 = chamberdirections.second;
1872 SbVec3f chambdir2,chambdir3,chambdir4;
1873 rot.multVec(chambdir1,chambdir2);
1874 rot.multVec(chambdir2,chambdir3);
1875 rot.multVec(chambdir3,chambdir4);
1876 if (cameraUpVec.equals(chambdir1,epsilon)) {
1877 newup = chambdir2;
1878 } else if (cameraUpVec.equals(chambdir2,epsilon)) {
1879 newup = chambdir3;
1880 } else if (cameraUpVec.equals(chambdir3,epsilon)) {
1881 newup = chambdir4;
1882 } else if (cameraUpVec.equals(chambdir4,epsilon)) {
1883 newup = chambdir1;
1884 } else {
1885 //Take the closest one...
1886 float cos1 = chambdir1.dot(cameraUpVec);
1887 float cos2 = chambdir2.dot(cameraUpVec);
1888 float cos3 = chambdir3.dot(cameraUpVec);
1889 float cos4 = chambdir4.dot(cameraUpVec);
1890 float maxcos = std::max(std::max(cos1,cos2),std::max(cos3,cos4));
1891 if (cos1==maxcos)
1892 newup = chambdir1;
1893 else if (cos2==maxcos)
1894 newup = chambdir2;
1895 else if (cos3==maxcos)
1896 newup = chambdir3;
1897 else
1898 newup = chambdir4;
1899 }
1900 }
1901
1902 //Zoom to chamber with given orientation - and we make sure the
1903 //chamber is attached while we initiate the zoom (so the camera
1904 //helper can use a boundaryboxaction to find the bounding box):
1905 VP1CameraHelper::animatedZoomToSubTree(*it,m_d->sceneroot,chambersep,1.0, 100.0, 100.0, 1.0,newdirection,newup);
1906 }
1907 }
1908
1909 chamberHandle->setState(oldChamberState);
1910 if (soswitch_val!=SO_SWITCH_ALL)
1911 subsys->soswitch->whichChild.setValue(soswitch_val);
1912 if (save) {
1913 subsys->soswitch->enableNotify(true);
1914 subsys->soswitch->touch();
1915 }
1916 m_d->previousAlignedChamberHandle=chamberHandle;
1917
1918}
1919
1920//Check all tubes in chamber and returns directions parallel with a tube which is closest to present camera direction:
1921//_____________________________________________________________________________________
1922std::pair<SbVec3f,SbVec3f> VP1GeometrySystem::Imp::getClosestMuonDriftTubeDirections( const SbVec3f& cameraDirection,
1923 const SbVec3f& cameraUpDirection,
1924 VolumeHandle * chamberhandle )
1925{
1926 //We assume chamberhandle is to an MDT station (barrel or endcap).
1927 SbVec3f closesttubedir(cameraDirection);
1928 SbVec3f closesttubeupvec(cameraUpDirection);
1929 float smallestcosangle(1.1);
1930
1931 //Barrel/Endcap MDT. Expand two levels and then check the individual tubes.
1932 chamberhandle->initialiseChildren();
1933 VolumeHandle::VolumeHandleListItr itch(chamberhandle->childrenBegin()), itchE(chamberhandle->childrenEnd());
1934 for (;itch!=itchE;++itch) {
1935 //Any daughter with the name "Ded..." should be ignored
1936 std::string name1 = (*itch)->getNameStdString();
1937 if (name1.size()>2&&name1[0]=='D'&&name1[1]=='e'&&name1[2]=='d')
1938 continue;
1939
1940 (*itch)->initialiseChildren();
1941 VolumeHandle::VolumeHandleListItr itch2((*itch)->childrenBegin()), itch2E((*itch)->childrenEnd());
1942 //Various variables needed to deal with each tube:
1943 const SbVec3f unitz(0.0f,0.0f,1.0f);
1944 const SbVec3f unity(0.0f,1.0f,0.0f);
1945 SbVec3f tubeglob;
1946 SbVec3f translation, scale;
1947 SbRotation rotation, scalerotation;
1948
1949 for (;itch2!=itch2E;++itch2) {
1950 if ((*itch2)->getNameStdString()=="MDTDriftWall") {
1951 //OK, we got the handle of a tube (wall). Lets find its direction!
1952 //->We assume that the tube, in its local coordinate system, is aligned with the z axis.
1953 //Get global rotation of tube:
1954 (*itch2)->getGlobalTransformToVolume().getTransform(translation,rotation,scale,scalerotation);
1955 rotation.multVec (unitz, tubeglob);
1956 if (tubeglob.dot(cameraDirection)<smallestcosangle) {
1957 smallestcosangle = tubeglob.dot(cameraDirection);
1958 closesttubedir = tubeglob;
1959 rotation.multVec(unity, closesttubeupvec);
1960 }
1961 if (tubeglob.dot(-cameraDirection)<smallestcosangle) {
1962 smallestcosangle = tubeglob.dot(-cameraDirection);
1963 closesttubedir = -tubeglob;
1964 rotation.multVec(unity, closesttubeupvec);
1965 }
1966 }
1967 }
1968 }
1969 return std::pair<SbVec3f,SbVec3f>(closesttubedir,closesttubeupvec);
1970}
1971
1972//_____________________________________________________________________________________
1973std::pair<SbVec3f,SbVec3f> VP1GeometrySystem::Imp::getClosestCSCOrTGCEdgeDirections( const SbVec3f& cameraDirection,
1974 VolumeHandle * chamberhandle )
1975{
1976 // It turns out that the correct chamber directions for CSC/TGC chambers is the y and z axes.
1977 std::vector<SbVec3f> directions;
1978 directions.push_back(SbVec3f(0.0f,1.0f,0.0f));
1979 directions.push_back(SbVec3f(0.0f,-1.0f,0.0f));
1980 directions.push_back(SbVec3f(0.0f,0.0f,1.0f));
1981 directions.push_back(SbVec3f(0.0f,0.0f,-1.0f));
1982
1983 directions.push_back(SbVec3f(1.0f,0.0f,0.0f));
1984 directions.push_back(SbVec3f(-1.0f,0.0f,0.0f));
1985
1986 //Get local->global transformation for chamber:
1987 SbVec3f translation, scale;
1988 SbRotation rotation, scalerotation;
1989 chamberhandle->getGlobalTransformToVolume().getTransform(translation,rotation,scale,scalerotation);
1990
1991 //Put directions into global coordinates:
1992 for (unsigned i = 0; i<directions.size();++i)
1993 rotation.multVec(directions[i],directions[i]);
1994
1995 //Find the one closest to the camera:
1996 SbVec3f chamberDir(-cameraDirection);
1997 float smallestcosangle(1.1);
1998 for (unsigned i = 0; i<directions.size();++i) {
1999 if (directions.at(i).dot(cameraDirection)<smallestcosangle) {
2000 smallestcosangle = directions.at(i).dot(cameraDirection);
2001 chamberDir = directions.at(i);
2002 }
2003 }
2004
2005 //cameraUpDirection should always (0,1,0) transformed to global
2006 //coordinates:
2007 SbVec3f chamberUp;
2008 float x,y,z;
2009 chamberDir.getValue(x,y,z);
2010 if (x!=0.0f) {
2011 rotation.multVec(SbVec3f(0.0f,1.0f,0.0f),chamberUp);
2012 } else {
2013 rotation.multVec(SbVec3f(1.0f,0.0f,0.0f),chamberUp);
2014 }
2015
2016 //Done:
2017 return std::pair<SbVec3f,SbVec3f>(chamberDir,chamberUp);
2018}
2019
2020//_____________________________________________________________________________________
2022{
2023 assert(target!=VP1GeoFlags::CONTRACTED);
2024 if (handle->isAttached()) {
2025 //The volume is visible, so ignore daughters
2026 if (handle->isInitialisedAndHasNonStandardShape()) {
2027 if (target!=VP1GeoFlags::EXPANDED||handle->nChildren()>0)
2028 handle->setState(target);
2029 }
2030 return;
2031 } else if (handle->state()==VP1GeoFlags::ZAPPED)
2032 return;
2033 //Must be expanded: Let us call on any (initialised) children instead.
2034 if (handle->nChildren()==0||!handle->childrenAreInitialised())
2035 return;
2036 VolumeHandle::VolumeHandleListItr it(handle->childrenBegin()), itE(handle->childrenEnd());
2037 for(;it!=itE;++it)
2039
2040}
2041
2042//_____________________________________________________________________________________
2044{
2046 messageVerbose("Action on volumes with non-standard VRML representations. Target state is "+VP1GeoFlags::toString(target));
2047
2048 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2049 m_d->volumetreemodel->getRootHandles(roothandles);
2051
2052 bool save = m_d->sceneroot->enableNotify(false);
2053 m_d->phisectormanager->largeChangesBegin();
2054
2055 deselectAll();
2056
2057 for (unsigned i = 0; i<roothandles.size();++i) {
2058 it = roothandles.at(i).first;
2059 itE = roothandles.at(i).second;
2060 for(;it!=itE;++it) {
2061 m_d->changeStateOfVisibleNonStandardVolumesRecursively(*it,target);
2062 }
2063 }
2064
2065 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2066 m_d->phisectormanager->largeChangesEnd();
2067 if (save) {
2068 m_d->sceneroot->enableNotify(true);
2069 m_d->sceneroot->touch();
2070 }
2071}
2072
2073//_____________________________________________________________________________________
2074void VP1GeometrySystem::autoExpandByVolumeOrMaterialName(bool bymatname,const QString& targetname)
2075{
2076 if (targetname.isEmpty()) {
2077 VP1Msg::messageDebug("targetname is empty.");
2078 return;
2079 }
2080
2081 messageVerbose("Auto expansions of visible volumes requested. Target all volumes with "
2082 +str(bymatname?"material name":"name")+" matching "+targetname);
2083
2084 QRegExp selregexp(targetname,Qt::CaseSensitive,QRegExp::Wildcard);
2085
2086 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2087 m_d->volumetreemodel->getRootHandles(roothandles);
2089
2090 bool save = m_d->sceneroot->enableNotify(false);
2091 m_d->phisectormanager->largeChangesBegin();
2092
2093 deselectAll();
2094
2095 for (unsigned i = 0; i<roothandles.size();++i) {
2096 it = roothandles.at(i).first;
2097 itE = roothandles.at(i).second;
2098 for(;it!=itE;++it)
2099 m_d->expandVisibleVolumesRecursively(*it,selregexp,bymatname);
2100 }
2101
2102 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2103 m_d->phisectormanager->largeChangesEnd();
2104 if (save) {
2105 m_d->sceneroot->enableNotify(true);
2106 m_d->sceneroot->touch();
2107 }
2108}
2109
2110//_____________________________________________________________________________________
2111void VP1GeometrySystem::Imp::expandVisibleVolumesRecursively(VolumeHandle* handle,const QRegExp& selregexp,bool bymatname)
2112{
2113 if (handle->state()==VP1GeoFlags::ZAPPED)
2114 return;
2115 if (handle->state()==VP1GeoFlags::CONTRACTED) {
2116 //See if we match (and have children) - if so, update state.
2117 if (handle->nChildren()>0
2118 && selregexp.exactMatch(bymatname?QString(handle->geoMaterial()->getName().c_str()):handle->getName())) {
2119 handle->setState(VP1GeoFlags::EXPANDED);
2120 }
2121 return;
2122 }
2123 //Must be expanded: Let us call on any (initialised) children instead.
2124 if (handle->nChildren()==0||!handle->childrenAreInitialised())
2125 return;
2126 VolumeHandle::VolumeHandleListItr it(handle->childrenBegin()), itE(handle->childrenEnd());
2127 for(;it!=itE;++it)
2128 expandVisibleVolumesRecursively(*it,selregexp,bymatname);
2129}
2130
2131//_____________________________________________________________________________________
2132void VP1GeometrySystem::Imp::iconifyVisibleVolumesRecursively(VolumeHandle* handle,const QRegExp& selregexp,bool bymatname)
2133{
2134 if (handle->state()==VP1GeoFlags::ZAPPED)
2135 return;
2136
2137 if (handle->state()==VP1GeoFlags::CONTRACTED) {
2138 //See if we match -- if so, update state.
2139 if( selregexp.exactMatch(bymatname?QString(handle->geoMaterial()->getName().c_str()):handle->getName())) {
2140 handle->setState(VP1GeoFlags::ZAPPED);
2141 }
2142 return;
2143 }
2144 //Must be expanded: Let us call on any (initialised) children instead.
2145 if (handle->nChildren()==0||!handle->childrenAreInitialised())
2146 return;
2147 VolumeHandle::VolumeHandleListItr it(handle->childrenBegin()), itE(handle->childrenEnd());
2148 for(;it!=itE;++it)
2149 iconifyVisibleVolumesRecursively(*it,selregexp,bymatname);
2150}
2151
2152
2153//_____________________________________________________________________________________
2154void VP1GeometrySystem::autoIconifyByVolumeOrMaterialName(bool bymatname,const QString& targetname)
2155{
2156 if (targetname.isEmpty()) {
2157 VP1Msg::messageDebug("targetname is empty.");
2158 return;
2159 }
2160
2161 messageVerbose("Auto iconification/zapping of visible volumes requested. Target all volumes with "
2162 +str(bymatname?"material name":"name")+" matching "+targetname);
2163
2164 QRegExp selregexp(targetname,Qt::CaseSensitive,QRegExp::Wildcard);
2165
2166 std::vector<std::pair<VolumeHandle::VolumeHandleListItr,VolumeHandle::VolumeHandleListItr> > roothandles;
2167 m_d->volumetreemodel->getRootHandles(roothandles);
2169
2170 bool save = m_d->sceneroot->enableNotify(false);
2171 m_d->phisectormanager->largeChangesBegin();
2172
2173 deselectAll();
2174
2175 for (unsigned i = 0; i<roothandles.size();++i) {
2176 it = roothandles.at(i).first;
2177 itE = roothandles.at(i).second;
2178 for(;it!=itE;++it)
2179 m_d->iconifyVisibleVolumesRecursively(*it,selregexp,bymatname);
2180 }
2181
2182 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2183 m_d->phisectormanager->largeChangesEnd();
2184 if (save) {
2185 m_d->sceneroot->enableNotify(true);
2186 m_d->sceneroot->touch();
2187 }
2188}
2189#ifndef BUILDVP1LIGHT
2190//_____________________________________________________________________________________
2192{
2193 if (!elem)
2194 return;
2195 GeoPVConstLink pvlink = elem->getMaterialGeom()->getParent();
2196 const MuonGM::MuonStation * station = elem->parentMuonStation();
2197 if (!station) {
2198 theclass->message("WARNING: Ignored null station pointer");
2199 return;
2200 }
2201 pv2MuonStation[pvlink] = station;
2202}
2203
2204//_____________________________________________________________________________________
2206{
2207 if (pv2MuonStationInit) {
2208 VP1Msg::messageDebug("MuonStation map already initialized.");
2209 return;
2210 }
2211 pv2MuonStationInit = true;
2212 theclass->messageVerbose("Initializing physical volume link -> MuonStation map.");
2213
2215 if (!mgr) {
2216 VP1Msg::message("WARNING: Could not get muon detector manager to construct volume -> muon station map!");
2217 return;
2218 }
2219 if (mgr->nMdtRE()) {
2220 for (auto det_el = mgr->mdtIdHelper()->detectorElement_begin();
2221 det_el != mgr->mdtIdHelper()->detectorElement_end(); ++det_el) {
2222 updatePV2MuonStationMap(mgr->getMdtReadoutElement(*det_el));
2223 }
2224 }
2225 if (mgr->nRpcRE()) {
2226 for (auto det_el = mgr->rpcIdHelper()->detectorElement_begin();
2227 det_el != mgr->rpcIdHelper()->detectorElement_end(); ++det_el) {
2228 updatePV2MuonStationMap(mgr->getRpcReadoutElement(*det_el));
2229 }
2230 }
2231 if (mgr->nCscRE()) {
2232 for (auto det_el = mgr->cscIdHelper()->detectorElement_begin();
2233 det_el != mgr->cscIdHelper()->detectorElement_end(); ++det_el) {
2234 updatePV2MuonStationMap(mgr->getCscReadoutElement(*det_el));
2235 }
2236 }
2237 if (mgr->nTgcRE()) {
2238 for (auto det_el = mgr->tgcIdHelper()->detectorElement_begin();
2239 det_el != mgr->tgcIdHelper()->detectorElement_end(); ++det_el) {
2240 updatePV2MuonStationMap(mgr->getTgcReadoutElement(*det_el));
2241 }
2242 }
2243
2244 VP1Msg::messageDebug("Initialised physical volume link -> MuonStation map. Found "+str(pv2MuonStation.size())+" stations.");
2245
2246}
2247
2248//_____________________________________________________________________________________
2250{
2251 QStringList l;
2252 if (!station) {
2253 l <<"Null ptr!";
2254 return l;
2255 }
2256 l << "Name: "+str(station->getStationName().c_str());
2257 l << "(Eta,Phi) index: ("+str(station->getEtaIndex())+", "+str(station->getPhiIndex())+")";
2258 return l;
2259}
2260#endif
2261
2262//_____________________________________________________________________________________
2263void VP1GeometrySystem::autoAdaptPixelsOrSCT(bool pixel,bool brl, bool ecA, bool ecC, bool bcmA, bool bcmC)
2264{
2265 #ifndef BUILDVP1LIGHT
2267 return;
2268 #endif
2269 //VP1GeoFlags::SubSystemFlag subSysFlag( pixel ? VP1GeoFlags::Pixel : VP1GeoFlags::SCT );
2271
2272 bool bcm(bcmA||bcmC);
2273 bool ec(ecA||ecC);
2274
2276 //Find subsystem:
2277 Imp::SubSystemInfo* subsys(0);
2278 for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
2279 if (si->flag == subSysFlag) {
2280 subsys = si;
2281 break;
2282 }
2283 }
2284 if (!subsys) {
2285 message("AutoAdaptPixelsOrSCT Error: Could not find subsystem");
2286 return;
2287 }
2288
2289
2291 //Abort if corresponding subsystem is not built:
2292 if (!subsys->isbuilt) {
2293 VP1Msg::messageDebug("AutoAdaptPixelsOrSCT: Aborting since subsystem geometry not built yet");
2294 return;//Disabling now due to phi-sector problems if "click some phi sectors"->"adapt pixel"->"turn on pixel"
2295 }
2296 bool save = m_d->sceneroot->enableNotify(false);
2297 m_d->phisectormanager->largeChangesBegin();
2298 VolumeHandle::VolumeHandleListItr it(subsys->vollist.begin()),itE(subsys->vollist.end());
2299
2300 if (pixel) {
2301 // --> Pixel
2302 for (;it!=itE;++it) {
2303 (*it)->initialiseChildren();
2304 (*it)->setState(VP1GeoFlags::CONTRACTED);
2305 VolumeHandle::VolumeHandleListItr itChl((*it)->childrenBegin()),itChlE((*it)->childrenEnd());
2306 for (;itChl!=itChlE;++itChl) {
2307 bool unzap(false);
2308 (*itChl)->setState(VP1GeoFlags::ZAPPED);
2310 if (brl&&(*itChl)->hasName("barrelLog")) {
2311 unzap = true;
2312 m_d->showPixelModules(*itChl);
2313 } else if ((ec)&&(*itChl)->hasName("EndCapLog")) {
2314 if (((*itChl)->isPositiveZ()?ecA:ecC)) {
2315 m_d->showPixelModules(*itChl);
2316 unzap = true;
2317 }
2318 } else if (bcm&&(*itChl)->hasName("bcmModLog")) {
2319 if (((*itChl)->isPositiveZ()?bcmA:bcmC)) {
2320 (*itChl)->reset();
2321 (*itChl)->setState(VP1GeoFlags::EXPANDED);
2322 }
2323 }
2324 } else {
2325 if ((*itChl)->hasName("ITkPixelDetector")) {
2326 m_d->showITkPixelModules(*itChl, brl, ecA, ecC);
2327 unzap = true;
2328 }
2329 }
2330 if (unzap)
2331 (*itChl)->setState(VP1GeoFlags::EXPANDED);
2332 }
2333 (*it)->setState(VP1GeoFlags::EXPANDED);
2334 }
2335 } else {
2336 // --> SCT
2337 for (;it!=itE;++it) {
2338 (*it)->initialiseChildren();
2339 (*it)->setState(VP1GeoFlags::CONTRACTED);
2340 bool unzap(false);
2341 (*it)->setState(VP1GeoFlags::ZAPPED);
2343 if (brl&&(*it)->hasName("SCT_Barrel")) {
2344 unzap = true;
2345 m_d->showSCTBarrelModules(*it);
2346 } else if (ecA&&(*it)->hasName("SCT_ForwardA")) {
2347 unzap = true;
2348 m_d->showSCTEndcapModules(*it);
2349 } else if (ecC&&(*it)->hasName("SCT_ForwardC")) {
2350 unzap = true;
2351 m_d->showSCTEndcapModules(*it);
2352 }
2353 } else {
2354 m_d->showITkStripModules(*it, brl, ecA, ecC);
2355 unzap=true;
2356 }
2357 if (unzap)
2358 (*it)->setState(VP1GeoFlags::EXPANDED);
2359 }
2360 }
2361 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2362 m_d->phisectormanager->largeChangesEnd();
2363 if (save) {
2364 m_d->sceneroot->enableNotify(true);
2365 m_d->sceneroot->touch();
2366 }
2367}
2368
2369
2370//_____________________________________________________________________________________
2371void VP1GeometrySystem::autoAdaptMuonNSW(bool reset, bool stgc, bool mm, bool passiveSpacer, bool passiveStructure,bool passiveAPlate)
2372{
2373 VP1Msg::messageDebug("VP1GeometrySystem::autoAdaptMuonNSW()");
2374
2375 #ifndef BUILDVP1LIGHT
2376 // return if Muon and MuonNSW are not configured/present/ON
2378 return;
2379 #endif
2380
2381 if( reset )
2382 VP1Msg::messageDebug("resetting to full NSW...");
2383
2385
2387 //Find subsystem:
2388 Imp::SubSystemInfo* subsys(0);
2389 for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
2390 if (si->flag == subSysFlag) {
2391 subsys = si;
2392 break;
2393 }
2394 }
2395 if (!subsys) {
2396 message("autoAdaptMuonNSW Error: Could not find subsystem");
2397 return;
2398 }
2399
2400
2402 //Abort if corresponding subsystem is not built:
2403 if (!subsys->isbuilt) {
2404 VP1Msg::messageDebug("autoAdaptMuonNSW: Aborting since subsystem geometry not built yet");
2405 return;//Disabling now due to phi-sector problems if "click some phi sectors"->"adapt pixel"->"turn on pixel"
2406 }
2407 bool save = m_d->sceneroot->enableNotify(false);
2408 m_d->phisectormanager->largeChangesBegin();
2409
2410 VolumeHandle::VolumeHandleListItr it(subsys->vollist.begin()),itE(subsys->vollist.end());
2411
2412 // loop over first level children (i.e., 'NewSmallWheel')
2413 for (;it!=itE;++it) {
2414
2415 (*it)->initialiseChildren();
2416 (*it)->setState(VP1GeoFlags::CONTRACTED);
2417 VolumeHandle::VolumeHandleListItr itChl((*it)->childrenBegin()),itChlE((*it)->childrenEnd());
2418
2419 // loop over second level children (i.e., 'NSW_sTGC', 'NSW_MM')
2420 for (;itChl!=itChlE;++itChl) {
2421
2422 bool unzap( reset? true : false );
2423
2424 if ( !reset ) {
2425 (*itChl)->setState(VP1GeoFlags::ZAPPED);
2426 if ( (stgc) && (*itChl)->hasName("NSW_sTGC") ) {
2427 unzap = true;
2428 //m_d->showPixelModules(*itChl);
2429 } else if ( (mm) && (*itChl)->hasName("NSW_MM") ) {
2430 unzap = true;
2431 //m_d->showPixelModules(*itChl);
2432 } else if ( (passiveSpacer) && (*itChl)->hasName("NSW_Spacer") ) {
2433 unzap = true;
2434 } else if ( (passiveStructure) && (*itChl)->hasName("NSW_Aluminum_Structure_and_HUB") ) {
2435 unzap = true;
2436 } else if ( (passiveAPlate) && (*itChl)->hasName("A_Plate") ) {
2437 unzap = true;
2438 }
2439 }
2440 if (unzap) {
2441 (*itChl)->setState(VP1GeoFlags::EXPANDED);
2442 }
2443 }
2444 (*it)->setState(VP1GeoFlags::EXPANDED);
2445 }
2446
2447 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2448 m_d->phisectormanager->largeChangesEnd();
2449
2450 if (save) {
2451 m_d->sceneroot->enableNotify(true);
2452 m_d->sceneroot->touch();
2453 }
2454}
2455
2456
2457//_____________________________________________________________________________________
2458void VP1GeometrySystem::autoAdaptHGTD(bool reset, bool modules, bool supportStructure, bool coolingLines, bool covers, bool moderator, bool servicesElectronics)
2459{
2460 VP1Msg::messageDebug("VP1GeometrySystem::autoAdaptHGTD()");
2461
2462 #ifndef BUILDVP1LIGHT
2464 return;
2465 #endif
2466
2467 if( reset )
2468 VP1Msg::messageDebug("resetting to full HGTD...");
2469
2471
2473 //Find subsystem:
2474 Imp::SubSystemInfo* subsys(0);
2475 for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
2476 if (si->flag == subSysFlag) {
2477 subsys = si;
2478 break;
2479 }
2480 }
2481 if (!subsys) {
2482 message("autoAdaptHGTD Error: Could not find subsystem");
2483 return;
2484 }
2485
2487 //Abort if corresponding subsystem is not built:
2488 if (!subsys->isbuilt) {
2489 VP1Msg::messageDebug("autoAdaptHGTD: Aborting since subsystem geometry not built yet");
2490 return;
2491 }
2492
2493 bool save = m_d->sceneroot->enableNotify(false);
2494 m_d->phisectormanager->largeChangesBegin();
2495
2496 for (VolumeHandle* volume : subsys->vollist) {
2497 if (reset) {
2498 volume->reset();
2500 } else {
2502 handles.push_back(volume);
2503
2504 for (unsigned i = 0; i < handles.size(); ++i) {
2505 handles.at(i)->initialiseChildren();
2506 for (VolumeHandle* child : std::ranges::subrange(
2507 handles.at(i)->childrenBegin(), handles.at(i)->childrenEnd()))
2508 handles.push_back(child);
2509 }
2510
2511 for (VolumeHandle* handle : handles)
2512 handle->setState(VP1GeoFlags::ZAPPED);
2513
2514 bool unzap(false);
2515 for (VolumeHandle* handle : handles) {
2516 const QString name = handle->getName();
2517 bool selected(false);
2518 if (modules && (name=="HGTDFlexPackage" ||
2519 name.startsWith("HGTDFlexTube") ||
2520 name=="HGTDHybrid" ||
2521 name=="HGTDGlueSensor" ||
2522 name=="HGTDGlueAsic" ||
2523 name.startsWith("HGTDSiSensor") ||
2524 name=="HGTDLGADInactive" ||
2525 name=="HGTDASIC")) {
2526 selected = true;
2527 } else if (supportStructure && (name=="HGTDSupportPlate" || name=="HGTDCoolingPlate")) {
2528 selected = true;
2529 } else if (coolingLines && name=="HGTDPeripheralCoolingLines") {
2530 selected = true;
2531 } else if (covers && (name=="HGTDFrontCover" ||
2532 name=="HGTDBackCover" ||
2533 name=="HGTDOuterRCover" ||
2534 name=="HGTDInnerRCover1" ||
2535 name=="HGTDInnerRCover2" ||
2536 name=="HGTDInnerRCover3")) {
2537 selected = true;
2538 } else if (moderator && (name=="HGTDModeratorIn" || name=="HGTDModeratorOut")) {
2539 selected = true;
2540 } else if (servicesElectronics && (name=="support_F_vol" ||
2541 name=="support_B_vol" ||
2542 name.startsWith("PowerBlock_") ||
2543 name.startsWith("VTRx_"))) {
2544 selected = true;
2545 }
2546
2547 if (selected) {
2548 unzap = true;
2549 handle->setState(VP1GeoFlags::CONTRACTED);
2550 VolumeHandle* parent = handle->parent();
2551 while (parent) {
2552 parent->setState(VP1GeoFlags::EXPANDED);
2553 parent = parent->parent();
2554 }
2555 }
2556 }
2557 if (!unzap)
2559 }
2560 }
2561
2562 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2563 m_d->phisectormanager->largeChangesEnd();
2564
2565 if (save) {
2566 m_d->sceneroot->enableNotify(true);
2567 m_d->sceneroot->touch();
2568 }
2569}
2570
2571
2572
2573
2574void VP1GeometrySystem::autoAdaptITk(bool reset, bool pixelModules, bool pixelServices, bool pixelSupports, bool stripSensors, bool stripElectronics, bool stripServices, bool stripSupports)
2575{
2576 VP1Msg::messageDebug("VP1GeometrySystem::autoAdaptITk()");
2577
2578 #ifndef BUILDVP1LIGHT
2580 return;
2581 #endif
2582
2583 bool save = m_d->sceneroot->enableNotify(false);
2584 m_d->phisectormanager->largeChangesBegin();
2585
2587 for (VP1GeoFlags::SubSystemFlag subSysFlag : flags) {
2588 Imp::SubSystemInfo* subsys(0);
2589 for (Imp::SubSystemInfo*si : m_d->subsysInfoList) {
2590 if (si->flag == subSysFlag) {
2591 subsys = si;
2592 break;
2593 }
2594 }
2595 if (!subsys) {
2596 message("autoAdaptITk Error: Could not find subsystem");
2597 continue;
2598 }
2599 if (!subsys->isbuilt) {
2600 VP1Msg::messageDebug("autoAdaptITk: Aborting since subsystem geometry not built yet");
2601 continue;
2602 }
2603
2604 bool isPixel(subSysFlag==VP1GeoFlags::ITkPixel);
2605 VolumeHandle::VolumeHandleListItr it(subsys->vollist.begin()),itE(subsys->vollist.end());
2606 for (;it!=itE;++it) {
2607 (*it)->initialiseChildren();
2608 if (reset) {
2609 (*it)->reset();
2610 (*it)->setState(VP1GeoFlags::EXPANDED);
2611 } else {
2612 m_d->selectITkComponent(*it, isPixel, pixelModules, pixelServices, pixelSupports, stripSensors, stripElectronics, stripServices, stripSupports);
2613 }
2614 }
2615 }
2616
2617 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
2618 m_d->phisectormanager->largeChangesEnd();
2619
2620 if (save) {
2621 m_d->sceneroot->enableNotify(true);
2622 m_d->sceneroot->touch();
2623 }
2624}
2625
2626//_____________________________________________________________________________________
2628{
2629 VP1Msg::messageDebug("VP1GeometrySystem::Imp::showPixelModules()");
2630 h->initialiseChildren();
2631 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2632 for (;it!=itE;++it) {
2633 if ((*it)->hasName("moduleLog")) {
2634 (*it)->setState(VP1GeoFlags::ZAPPED);
2635 (*it)->contractDaughtersRecursively();
2636 (*it)->initialiseChildren();
2637 VolumeHandle::VolumeHandleListItr itMod((*it)->childrenBegin()),itModE((*it)->childrenEnd());
2638 for (;itMod!=itModE;++itMod) {
2639 if ((*itMod)->getName().startsWith("si"))
2640 (*itMod)->setState(VP1GeoFlags::CONTRACTED);
2641 else
2642 (*itMod)->setState(VP1GeoFlags::ZAPPED);
2643 }
2644 (*it)->setState(VP1GeoFlags::EXPANDED);
2645 continue;
2646 }
2647 if ((*it)->hasName("pigtailLog")||(*it)->hasName("omegaLog")) {
2648 (*it)->setState(VP1GeoFlags::ZAPPED);
2649 (*it)->contractDaughtersRecursively();
2650 continue;
2651 }
2652 if ((*it)->nChildren()<1) {
2653 (*it)->setState(VP1GeoFlags::ZAPPED);
2654 continue;
2655 }
2656 (*it)->setState(VP1GeoFlags::ZAPPED);
2657 showPixelModules(*it);
2658 (*it)->setState(VP1GeoFlags::EXPANDED);
2659 }
2660}
2661
2662void VP1GeometrySystem::Imp::expandAllChildren(VolumeHandle* h, bool isPixel, bool brl, bool ecA, bool ecC) {
2663
2664 if (h->nChildren()==0) {
2665 if (isPixel and (ecA or ecC)) {
2666 float translation_x, translation_y, translation_z, rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians;
2667 VP1LinAlgUtils::decodeTransformation( h->getGlobalTransformToVolume(),
2668 translation_x, translation_y, translation_z,
2669 rotaxis_x, rotaxis_y, rotaxis_z, rotangle_radians );
2670 if ((!ecA || !ecC) && ((ecA and (translation_z<0.)) or (ecC and (translation_z>0.) ))) {
2671 h->setState(VP1GeoFlags::ZAPPED);
2672 return;
2673 }
2674 }
2675
2676 // check if you have to select it
2677 std::vector< std::string > selected_volumes = {};
2678 if (brl) {
2679 if (isPixel) {
2680 selected_volumes.push_back("InnerBarrelSingleMod_Sensor");
2681 selected_volumes.push_back("InnerBarrelQuadMod_Sensor");
2682 selected_volumes.push_back("OuterBarrelQuadMod_Sensor");
2683 selected_volumes.push_back("LongeronCoolingTube");
2684 selected_volumes.push_back("InnerPixBarrelSupport_Stave");
2685 selected_volumes.push_back("InnerPixBarrelSupport_Stave1");
2686 selected_volumes.push_back("LongeronCornerBase");
2687 selected_volumes.push_back("LongeronCornerEnd");
2688 selected_volumes.push_back("LongeronTrussWall");
2689 selected_volumes.push_back("LongeronCapBase");
2690 selected_volumes.push_back("LongeronTopCap");
2691
2692 } else {
2693 selected_volumes.push_back("BRLSensorSS");
2694 selected_volumes.push_back("BRLSensorMS");
2695 selected_volumes.push_back("B_HybridPCB");
2696 selected_volumes.push_back("DCDC_PCB");
2697 selected_volumes.push_back("DCDC_Box");
2698 selected_volumes.push_back("Bex_HybridPCB_near");
2699 selected_volumes.push_back("Bex_HybridPCB_far");
2700 }
2701 }
2702 if (ecA or ecC) {
2703 if (isPixel) {
2704 selected_volumes.push_back("InclinedQuadMod_Sensor");
2705 selected_volumes.push_back("InnerRingSingleMod_Sensor");
2706 selected_volumes.push_back("InnerEndcapQuadMod_Sensor");
2707 selected_volumes.push_back("OuterEndcapQuadMod_Sensor");
2708 selected_volumes.push_back("L2HalfRingCoolingPipe");
2709 selected_volumes.push_back("L3HalfRingCoolingPipe");
2710 selected_volumes.push_back("L4endcapcoolingpipe");
2711 selected_volumes.push_back("InclL2HalfShell");
2712 selected_volumes.push_back("InclL2Support");
2713 selected_volumes.push_back("InclL3HalfShell");
2714 selected_volumes.push_back("InclL3Support");
2715 selected_volumes.push_back("InclL4HalfShell");
2716 selected_volumes.push_back("InclL4Support");
2717 selected_volumes.push_back("InnerPixEndcap_CoupledRingSupport");
2718 selected_volumes.push_back("InnerPixEndcap_IntermediateRingSupport");
2719 selected_volumes.push_back("InnerPixEndcap_L1RingSupport");
2720 selected_volumes.push_back("L2HalfRingCarbonFoamInner");
2721 selected_volumes.push_back("L2HalfRingCarbonFoamOuter");
2722 selected_volumes.push_back("L2HalfRingFaceSheet");
2723 selected_volumes.push_back("L3HalfRingCarbonFoamInner");
2724 selected_volumes.push_back("L3HalfRingCarbonFoamOuter");
2725 selected_volumes.push_back("L3HalfRingFaceSheet");
2726 selected_volumes.push_back("L4endcapinnerCarbonFoam");
2727 selected_volumes.push_back("L4endcapouterCarbonFoam");
2728 selected_volumes.push_back("L4endcapFaceSheet");
2729 selected_volumes.push_back("L2HalfShell");
2730 selected_volumes.push_back("L3HalfShell");
2731 selected_volumes.push_back("L4HalfShell");
2732 } else {
2733 selected_volumes.push_back("ECSensor0");
2734 selected_volumes.push_back("ECSensor1");
2735 selected_volumes.push_back("ECSensor2");
2736 selected_volumes.push_back("ECSensor3");
2737 selected_volumes.push_back("ECSensor4");
2738 selected_volumes.push_back("ECSensor5");
2739 selected_volumes.push_back("ECSensorBack0");
2740 selected_volumes.push_back("ECSensorBack1");
2741 selected_volumes.push_back("ECSensorBack2");
2742 selected_volumes.push_back("ECSensorBack3");
2743 selected_volumes.push_back("ECSensorBack4");
2744 selected_volumes.push_back("ECSensorBack5");
2745 }
2746 }
2747
2748 std::string name = h->getName().toStdString();
2749
2750 if (not isPixel and (ecA or ecC)) {
2751 // check servises in the endcap
2752 if (name.starts_with("ECHybrid") or name.starts_with("DCDC_EC"))
2753 return;
2754 }
2755
2756 if (std::find(selected_volumes.begin(), selected_volumes.end(), name) == selected_volumes.end()) {
2757 h->setState(VP1GeoFlags::ZAPPED);
2758 return;
2759 }
2760 return;
2761 } else if (not isPixel and (h->getName().toStdString()=="PetalCore" or
2762 h->getName().toStdString()=="StaveCoreSS" or
2763 h->getName().toStdString() =="StaveCoreMS")) {
2764 return;
2765 }
2766 h->initialiseChildren();
2767
2768 h->setState(VP1GeoFlags::EXPANDED);
2769 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2770 for (;it!=itE;++it) {
2771 expandAllChildren(*it, isPixel, brl, ecA, ecC);
2772 }
2773}
2774
2776{
2777 VP1Msg::messageDebug("VP1GeometrySystem::Imp::showITkPixelModules()");
2778 h->initialiseChildren();
2779 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2780 // std::cout << "Processing volume with name = " << h->getName().toStdString() << " and " << h->nChildren() << " children..." << std::endl;
2781 for (;it!=itE;++it) {
2782 expandAllChildren(*it, true, brl, ecA, ecC);
2783 }
2784}
2785
2786
2788{
2789 VP1Msg::messageDebug("VP1GeometrySystem::Imp::showITkStripModules()");
2790 h->initialiseChildren();
2791 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2792 // std::cout << "Processing volume with name = " << h->getName().toStdString() << " and " << h->nChildren() << " children..." << std::endl;
2793 for (;it!=itE;++it) {
2794 if (brl and (*it)->hasName("ITkStrip_Barrel")) {
2795 expandAllChildren(*it, false, brl, ecA, ecC);
2796 }
2797 else if (ecA and (*it)->hasName("ITkStrip_ForwardPlus")) {
2798 expandAllChildren(*it, false, brl, ecA, ecC);
2799 }
2800 else if (ecC and (*it)->hasName("ITkStrip_ForwardMinus")) {
2801 expandAllChildren(*it, false, brl, ecA, ecC);
2802 } else
2803 (*it)->setState(VP1GeoFlags::ZAPPED);
2804 }
2805}
2806
2807namespace {
2808bool itkNameIsOneOf(const QString& name, std::initializer_list<const char*> candidates)
2809{
2810 for (const char* candidate : candidates) {
2811 if (name==candidate)
2812 return true;
2813 }
2814 return false;
2815}
2816
2817bool itkNameStartsWithOneOf(const QString& name, std::initializer_list<const char*> prefixes)
2818{
2819 for (const char* prefix : prefixes) {
2820 if (name.startsWith(prefix))
2821 return true;
2822 }
2823 return false;
2824}
2825}
2826
2827bool VP1GeometrySystem::Imp::selectITkComponent(VolumeHandle* h, bool isPixel, bool pixelModules, bool pixelServices, bool pixelSupports, bool stripSensors, bool stripElectronics, bool stripServices, bool stripSupports, unsigned inheritedCategory)
2828{
2829 // Classify both logical volumes and named XML assembly placements.
2830 // Bits: Pixel modules/services/supports; Strip sensors/electronics/services/supports.
2831 unsigned category = 0;
2832 const QString names[] = {h->getName(), h->getNameTag()};
2833 for (const QString& name : names) {
2834 if (isPixel) {
2835 if (name.endsWith("_Sensor") || name.endsWith("_Chip") || name.endsWith("_Bonding") || name.endsWith("_DeadVolume"))
2836 category |= 1;
2837 if (name.contains("Svc") || name.contains("Service") || name.contains("Cooling") || name.contains("Pigtail") || name.contains("Flex") || name.contains("BusTape") || name.endsWith("_Cell") || name.startsWith("Pixel__ModuleSvc"))
2838 category |= 2;
2839 if (name.contains("Support") || name.contains("HalfShell") || name.contains("HalfRing") || name.contains("CarbonFoam") || name.contains("FaceSheet") || name.contains("Longeron") || name.contains("QuarterShell") || name.contains("Stave") || itkNameIsOneOf(name, {"IPTvol", "ISTvol", "FrontSupportFacing", "FrontSupportCore", "RearSupport"}))
2840 category |= 4;
2841 } else {
2842 if (name.startsWith("BRLSensor") || name.startsWith("ECSensor"))
2843 category |= 1;
2844 if (name.contains("Hybrid") || name.contains("DCDC") || name.contains("Bus") || itkNameIsOneOf(name, {"StaveSignalSS", "StaveGround"}))
2845 category |= 2;
2846 if (name.startsWith("SV") || name.contains("Service"))
2847 category |= 4;
2848 if (name.contains("Support") || name.contains("Stave") || name.contains("Petal") || name.contains("Core") || name.contains("Flange") || name.contains("Interlink") || name.contains("Wheel") || name.contains("Shell") || name.contains("Brace") || name.contains("Tube") || name.contains("Cyl") || name.contains("Hat") || name.contains("Bulkhead") || name.contains("Rail") || name.contains("Blade") || name.contains("Lock") || name.contains("Mount") || name.contains("Face") || name.contains("EOS") || itkNameStartsWithOneOf(name, {"StripB_", "OC", "EC_", "Ztube", "StiffDisc"}))
2849 category |= 8;
2850 }
2851
2852 }
2853 // Specific sensor/electronics categories take precedence over broad supports.
2854 if (isPixel) {
2855 if (category & 1) category = 1;
2856 else if (category & 2) category = 2;
2857 } else {
2858 if (category & 1) category = 1;
2859 else if (category & 2) category = 2;
2860 else if (category & 4) category = 4;
2861 }
2862 if (!category)
2863 category = inheritedCategory;
2864 const unsigned selected = isPixel
2865 ? (pixelModules ? 1u : 0u) | (pixelServices ? 2u : 0u) | (pixelSupports ? 4u : 0u)
2866 : (stripSensors ? 1u : 0u) | (stripElectronics ? 2u : 0u) |
2867 (stripServices ? 4u : 0u) | (stripSupports ? 8u : 0u);
2868
2869 // Hide the old representation before assigning child states bottom-up.
2870 h->setState(VP1GeoFlags::ZAPPED, false);
2871 if (h->nChildren() && !h->childrenAreInitialised())
2872 h->initialiseChildren();
2873 bool showChildren = false;
2874 for (auto it=h->childrenBegin(); it!=h->childrenEnd(); ++it) {
2875 if (selectITkComponent(*it, isPixel, pixelModules, pixelServices, pixelSupports,
2876 stripSensors, stripElectronics, stripServices, stripSupports, category))
2877 showChildren = true;
2878 }
2879 const bool showThis = !h->isEther() && (category & selected);
2880 h->setState(showChildren ? VP1GeoFlags::EXPANDED :
2881 showThis ? VP1GeoFlags::CONTRACTED : VP1GeoFlags::ZAPPED, false);
2882 return showChildren || showThis;
2883}
2884
2885//_____________________________________________________________________________________
2887{
2888 VP1Msg::messageDebug("VP1GeometrySystem::Imp::showSCTBarrelModules()");
2889 h->initialiseChildren();
2890 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2891 for (;it!=itE;++it) {
2892 if ((*it)->getName().startsWith("Layer")) {
2893 (*it)->setState(VP1GeoFlags::ZAPPED);
2894 (*it)->initialiseChildren();
2895 VolumeHandle::VolumeHandleListItr itLay((*it)->childrenBegin()),itLayE((*it)->childrenEnd());
2896 for (;itLay!=itLayE;++itLay) {
2897 if ((*itLay)->getName().endsWith("Active")&&(*itLay)->getName().startsWith("Layer")) {
2898 (*itLay)->setState(VP1GeoFlags::ZAPPED);
2899 (*itLay)->initialiseChildren();
2900 VolumeHandle::VolumeHandleListItr itActLay((*itLay)->childrenBegin()),itActLayE((*itLay)->childrenEnd());
2901 for (;itActLay!=itActLayE;++itActLay) {
2902 if ((*itActLay)->getName().startsWith("Ski")) {
2903 (*itActLay)->setState(VP1GeoFlags::ZAPPED);
2904 (*itActLay)->initialiseChildren();
2905 VolumeHandle::VolumeHandleListItr itSki((*itActLay)->childrenBegin()),itSkiE((*itActLay)->childrenEnd());
2906 for (;itSki!=itSkiE;++itSki) {
2907 //Ends with "Envelope": open, otherwise zap. Of those, zap all without "Sensor" in the name.
2908 if ((*itSki)->hasName("Module")) {
2909 //Open and zap those without "Sensor" in the name:
2910 (*itSki)->setState(VP1GeoFlags::ZAPPED);
2911 (*itSki)->initialiseChildren();
2912 VolumeHandle::VolumeHandleListItr itMod((*itSki)->childrenBegin()),itModE((*itSki)->childrenEnd());
2913 for (;itMod!=itModE;++itMod) {
2914 if ((*itMod)->getName().contains("Envelope")) {
2915 (*itMod)->setState(VP1GeoFlags::ZAPPED);
2916 (*itMod)->initialiseChildren();
2917 VolumeHandle::VolumeHandleListItr itEnv((*itMod)->childrenBegin()),itEnvE((*itMod)->childrenEnd());
2918 for(;itEnv!=itEnvE;++itEnv) {
2919 if ((*itEnv)->getName().contains("Sensor"))
2920 (*itEnv)->reset();
2921 else
2922 (*itEnv)->setState(VP1GeoFlags::ZAPPED);
2923 }
2924 (*itMod)->setState(VP1GeoFlags::EXPANDED);
2925 } else {
2926 (*itMod)->setState(VP1GeoFlags::ZAPPED);
2927 }
2928 }
2929 (*itSki)->setState(VP1GeoFlags::EXPANDED);
2930 } else {
2931 (*itSki)->setState(VP1GeoFlags::ZAPPED);
2932 }//end if-elsi "Envelope"
2933 }//endfor itSki
2934 (*itActLay)->setState(VP1GeoFlags::EXPANDED);
2935 } else {
2936 (*itActLay)->setState(VP1GeoFlags::ZAPPED);
2937 }//end if-else "Ski"
2938 }
2939 (*itLay)->setState(VP1GeoFlags::EXPANDED);
2940 } else {
2941 (*itLay)->setState(VP1GeoFlags::ZAPPED);
2942 (*itLay)->contractDaughtersRecursively();
2943 }
2944 }
2945 (*it)->setState(VP1GeoFlags::EXPANDED);
2946 } else {
2947 (*it)->setState(VP1GeoFlags::ZAPPED);
2948 (*it)->contractDaughtersRecursively();
2949 }
2950 }
2951}
2952
2953//_____________________________________________________________________________________
2955{
2956 VP1Msg::messageDebug("VP1GeometrySystem::Imp::showSCTEndcapModules()");
2957 h->initialiseChildren();
2958 VolumeHandle::VolumeHandleListItr it(h->childrenBegin()),itE(h->childrenEnd());
2959 for (;it!=itE;++it) {
2960 if ((*it)->getName().startsWith("Wheel")) {
2961 (*it)->setState(VP1GeoFlags::ZAPPED);
2962 (*it)->initialiseChildren();
2963 VolumeHandle::VolumeHandleListItr itWhl((*it)->childrenBegin()),itWhlE((*it)->childrenEnd());
2964 for (;itWhl!=itWhlE;++itWhl) {
2965 if ((*itWhl)->getName().startsWith("Ring")) {
2966 (*itWhl)->setState(VP1GeoFlags::ZAPPED);
2967 (*itWhl)->initialiseChildren();
2968 VolumeHandle::VolumeHandleListItr itRng((*itWhl)->childrenBegin()),itRngE((*itWhl)->childrenEnd());
2969 for (;itRng!=itRngE;++itRng) {
2970 if ((*itRng)->getName().startsWith("FwdModule")) {
2971 (*itRng)->setState(VP1GeoFlags::ZAPPED);
2972 (*itRng)->initialiseChildren();
2973 VolumeHandle::VolumeHandleListItr itMod((*itRng)->childrenBegin()),itModE((*itRng)->childrenEnd());
2974 for(;itMod!=itModE;++itMod) {
2975 if ((*itMod)->getName().startsWith("ECSensor")) {
2976 (*itMod)->reset();
2977 } else {
2978 (*itMod)->setState(VP1GeoFlags::ZAPPED);
2979 }
2980 }
2981 (*itRng)->setState(VP1GeoFlags::EXPANDED);
2982 } else {
2983 (*itRng)->setState(VP1GeoFlags::ZAPPED);
2984 }
2985 }
2986 (*itWhl)->setState(VP1GeoFlags::EXPANDED);
2987 } else {
2988 (*itWhl)->setState(VP1GeoFlags::ZAPPED);
2989 (*itWhl)->contractDaughtersRecursively();
2990 }
2991 }
2992 (*it)->setState(VP1GeoFlags::EXPANDED);
2993 } else {
2994 (*it)->setState(VP1GeoFlags::ZAPPED);
2995 (*it)->contractDaughtersRecursively();
2996 }
2997 }
2998}
2999
3000//_____________________________________________________________________________________
3002{
3003 //might not use this slot presently...
3004 if (!vh)
3005 return;
3006 deselectAll();
3007 vh->setState(state);
3008 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
3009}
3010
3011//_____________________________________________________________________________________
3013{
3014 if (!vh)
3015 return;
3016 deselectAll();
3017 vh->reset();
3018 m_d->phisectormanager->updateRepresentationsOfVolsAroundZAxis();
3019}
3020
3021//_____________________________________________________________________________________
3023{
3024 std::map<SoSeparator*,VolumeHandle*>::iterator it,itE(m_d->sonodesep2volhandle.end());
3025 for (it =m_d->sonodesep2volhandle.begin();it!=itE;++it)
3027}
3028
3029
3030//_____________________________________________________________________________________
3031void VP1GeometrySystem::saveMaterialsToFile(const QString& filename,bool onlyChangedMaterials)
3032{
3033 if (filename.isEmpty())
3034 return;
3035
3036 //If file exists, ask to overwrite.
3037 QFileInfo fi(filename);
3038 if (fi.exists()) {
3039 if (!fi.isWritable()) {
3040 QMessageBox::critical(0, "Error - could not save to file "+filename,
3041 "Could not save to file: <i>"+filename+"</i>"
3042 +"<br/><br/>Reason: File exists already and is write protected",QMessageBox::Ok,QMessageBox::Ok);
3043 return;
3044 }
3045 }
3046
3047 QFile file(filename);
3048 if (!file.open(QIODevice::WriteOnly)) {
3049 QMessageBox::critical(0, "Error - problems writing to file "+filename,
3050 "Problems writing to file: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3051 return;
3052 }
3053
3054 m_d->ensureInitVisAttributes();
3055 VP1Serialise s(0/*version*/,this);
3056 //Save some file ID info!!
3057 s.save(QString("VP1GeoMaterialsBegin"));
3058 s.save(m_d->detVisAttributes->getState(onlyChangedMaterials));
3059 s.save(m_d->matVisAttributes->getState(onlyChangedMaterials));
3060 s.save(m_d->volVisAttributes->getState(onlyChangedMaterials));
3061 s.save(QString("VP1GeoMaterialsEnd"));
3062 s.disableUnsavedChecks();
3063
3064 QDataStream outfile(&file);
3065 outfile<<qCompress(s.result()).toBase64();
3066
3067}
3068
3069//_____________________________________________________________________________________
3070void VP1GeometrySystem::loadMaterialsFromFile(const QString& filename)
3071{
3072 if (filename.isEmpty())
3073 return;
3074 QFileInfo fi(filename);
3075 if (!fi.exists()) {
3076 QMessageBox::critical(0, "Error - file does not exists: "+filename,
3077 "File does not exists: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3078 return;
3079 }
3080 if (!fi.isReadable()) {
3081 QMessageBox::critical(0, "Error - file is not readable: "+filename,
3082 "File is not readable: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3083 return;
3084 }
3085 //open file
3086 QFile file(filename);
3087 if (!file.open(QIODevice::ReadOnly)) {
3088 QMessageBox::critical(0, "Error - problems opening file "+filename,
3089 "Problems opening file: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3090 return;
3091 }
3092 QByteArray byteArray64;
3093 QDataStream infile(&file);
3094 infile >> byteArray64;
3095 QByteArray byteArray = qUncompress(QByteArray::fromBase64(byteArray64));
3096
3097 VP1Deserialise s(byteArray,this);
3098 if (s.version()!=0) {
3099 QMessageBox::critical(0, "Error - File in wrong format "+filename,
3100 "File in wrong format: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3101 return;
3102 }
3103 QString txtbegin, txtend;
3104 QByteArray baDet, baMat, baVol;
3105 txtbegin = s.restoreString();
3106 baDet = s.restoreByteArray();
3107 baMat = s.restoreByteArray();
3108 baVol = s.restoreByteArray();
3109 txtend = s.restoreString();
3110 s.disableUnrestoredChecks();
3111 if (txtbegin!="VP1GeoMaterialsBegin"||txtend!="VP1GeoMaterialsEnd") {
3112 QMessageBox::critical(0, "Error - File in wrong format "+filename,
3113 "File in wrong format: <i>"+filename+"</i>",QMessageBox::Ok,QMessageBox::Ok);
3114 return;
3115 }
3116
3117 m_d->ensureInitVisAttributes();
3118 m_d->detVisAttributes->applyState(baDet);
3119 m_d->matVisAttributes->applyState(baMat);
3120 m_d->volVisAttributes->applyState(baVol);
3121
3122 VolumeHandle* lastsel = m_d->controller->lastSelectedVolume();
3123 m_d->controller->setLastSelectedVolume(0);
3124 m_d->controller->setLastSelectedVolume(lastsel);
3125}
3126
3127//____________________________________________________________________
3129{
3130 messageVerbose("setLabelPosOffsets called");
3131 setLabels(m_d->controller->labels());
3132}
3133
3135 messageVerbose("setLabels "+str(i)+" for this many chambers:"+str(m_d->muonchambers_pv2handles.size()));
3136 // loop over all contained volumes (all visible volumes?) and update labels.
3137 // Just muons to start with
3138 std::map<PVConstLink,VolumeHandle*>::const_iterator it = m_d->muonchambers_pv2handles.begin(), itEnd = m_d->muonchambers_pv2handles.end();
3139 for (; it!=itEnd ; ++it){
3140 if (it->second->isInMuonChamber()) it->second->updateLabels(); // currently only do labels for Muon volumes
3141 }
3142}
3143
3145 m_d->controller->setLabelsEnabled(t0s,hits);
3146}
3147
3148void VP1GeometrySystem::muonChamberT0sChanged(const std::map<GeoPVConstLink, float>& t0s, int index){
3149 messageVerbose("muonChamberT0sChanged for this many chambers:"+str(t0s.size()));
3150 if (index>=m_d->chamberT0s.size())
3151 message("ERROR: chamber t0 index out of bounds!");
3152 else
3153 m_d->chamberT0s[index]=&t0s;
3154}
#define M_PI
double length(const pvec &v)
static Double_t ss
#define y
#define x
#define z
Header file for AthHistogramAlgorithm.
static QStringList shapeToStringList(const GeoShape *shape)
Definition DumpShape.cxx:34
GeoPhysVol * getPhysVol()
Destructor.
IVP13DSystemSimple(const QString &name, const QString &information, const QString &contact_info)
virtual void deselectAll(SoCooperativeSelection *exception_sel=0)
CamList getCameraList()
void messageVerbose(const QString &) const
virtual void restoreFromState(QByteArray)
void messageDebug(const QString &) const
const QString & name() const
State state() const
void message(const QString &) const
virtual QByteArray saveState()
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Base class for the XxxReadoutElement, with Xxx = Mdt, Rpc, Tgc, Csc.
int getEtaIndex() const
a la AMDB
int getPhiIndex() const
a la AMDB
const std::string & getStationName() const
like BMS5, T1F1, CSL1
The Athena Transient Store API.
static VP1CameraHelper * animatedZoomToSubTree(SoCamera *camera, SoGroup *sceneroot, SoNode *subtreeroot, double duration_in_secs=1.0, double clipVolPercent=100.0, double lastClipVolPercent=100.0, double slack=1.0, const SbVec3f &lookat=SbVec3f(999, 999, 999), const SbVec3f &upvec=SbVec3f(999, 999, 999), bool varySpeed=true, bool forceCircular=false)
static const MuonGM::MuonDetectorManager * muonDetMgr()
@ MuonEndcapStationTGC
Definition VP1GeoFlags.h:47
@ AllUnrecognisedVolumes
Definition VP1GeoFlags.h:73
@ MuonEndcapStationNSW
Definition VP1GeoFlags.h:65
@ MuonBarrelStationInner
Definition VP1GeoFlags.h:42
@ MuonBarrelStationMiddle
Definition VP1GeoFlags.h:44
@ MuonBarrelStationOuter
Definition VP1GeoFlags.h:45
@ MuonEndcapStationCSC
Definition VP1GeoFlags.h:46
@ MuonEndcapStationMDT
Definition VP1GeoFlags.h:49
static QString toString(const VOLSTATE &)
static QStringList geoMaterialToStringList(const GeoMaterial *)
SubSystemInfo(QCheckBox *cb, const QRegExp &the_geomodeltreetopregexp, bool the_negatetreetopregexp, const QRegExp &the_geomodelchildrenregexp, bool the_negatechildrenregexp, VP1GeoFlags::SubSystemFlag the_flag, const std::string &the_matname, const QRegExp &the_geomodelgrandchildrenregexp, bool the_negategrandchildrenregexp=false)
bool grandchildrenRegExpNameCompatible(const std::string &volname) const
bool childrenRegExpNameCompatible(const std::string &volname) const
VolumeHandle::VolumeHandleList vollist
void createPathExtras(const VolumeHandle *, QString &, QStack< QString > &)
void expandAllChildren(VolumeHandle *, bool isPixel, bool brl, bool ecA, bool ecC)
VP1GeometrySystem * theclass
void showSCTEndcapModules(VolumeHandle *)
void expandVisibleVolumesRecursively(VolumeHandle *, const QRegExp &, bool bymatname)
void showITkStripModules(VolumeHandle *, bool brl, bool ecA, bool ecC)
QStringList stationInfo(const MuonGM::MuonStation *)
SubSystemInfo * chamberPVToMuonSubSystemInfo(const GeoPVConstLink &chamberPV)
void addSubSystem(const VP1GeoFlags::SubSystemFlag &, const QString &treetopregexp, const QString &childrenregexp="", const std::string &matname="", bool negatetreetopregexp=false, bool negatechildrenregexp=false, const QString &grandchildrenregexp="", bool negategrandchildrenregexp=false)
QList< SubSystemInfo * > subsysInfoList
VP1GeoFlags::SubSystemFlags initialSubSystemsTurnedOn
void showSCTBarrelModules(VolumeHandle *)
void showPixelModules(VolumeHandle *)
static void catchKbdState(void *userData, SoEventCallback *CB)
void showITkPixelModules(VolumeHandle *, bool brl, bool ecA, bool ecC)
void updateTouchedMuonChamber(VolumeHandle *chamberhandle)
std::map< PVConstLink, VolumeHandle * > muonchambers_pv2handles
SoSeparator * m_textSep
Separator used to hold all visible labels.
PhiSectorManager * phisectormanager
std::pair< SbVec3f, SbVec3f > getClosestMuonDriftTubeDirections(const SbVec3f &cameraDirection, const SbVec3f &cameraUpDirection, VolumeHandle *chamberhandle)
VolumeHandle * previousAlignedChamberHandle
static double volume(const PVConstLink &pv)
void changeStateOfVisibleNonStandardVolumesRecursively(VolumeHandle *, VP1GeoFlags::VOLSTATE)
void buildSystem(SubSystemInfo *)
DetVisAttributes * detVisAttributes
std::map< GeoPVConstLink, const MuonGM::MuonStation * > pv2MuonStation
void updatePV2MuonStationMap(const MuonGM::MuonReadoutElement *elem)
std::map< SoSeparator *, VolumeHandle * > sonodesep2volhandle
static double inclusiveMass(const PVConstLink &pv)
VolVisAttributes * volVisAttributes
void iconifyVisibleVolumesRecursively(VolumeHandle *, const QRegExp &, bool bymatname)
GeoSysController * controller
void applyTopVolStates(const QMap< quint32, QByteArray > &, bool disablenotif=false)
Imp(VP1GeometrySystem *gs, const VP1GeoFlags::SubSystemFlags &ssf)
std::map< QObject *, std::set< GeoPVConstLink > > sender2ChamberList
const SoKeyboardEvent * kbEvent
QList< const std::map< GeoPVConstLink, float > * > chamberT0s
std::pair< SbVec3f, SbVec3f > getClosestCSCOrTGCEdgeDirections(const SbVec3f &cameraDirection, VolumeHandle *chamberhandle)
MatVisAttributes * matVisAttributes
bool selectITkComponent(VolumeHandle *, bool isPixel, bool pixelModules, bool pixelServices, bool pixelSupports, bool stripSensors, bool stripElectronics, bool stripServices, bool stripSupports, unsigned inheritedCategory=0)
VolumeTreeModel * volumetreemodel
static double exclusiveMass(const PVConstLink &pv)
QMap< quint32, QByteArray > restoredTopvolstates
void buildPermanentSceneGraph(StoreGateSvc *detstore, SoSeparator *root)
void loadMaterialsFromFile(const QString &)
void muonChamberT0sChanged(const std::map< GeoPVConstLink, float > &, int)
The map is the dt0 per chamber, plus a label identifier, which by convention (!) is 0=Moore,...
void userPickedNode(SoNode *pickedNode, SoPath *pickedPath)
void setOrientViewToMuonChambersOnClick(bool)
void autoAdaptMuonNSW(bool reset, bool stgc, bool mm, bool passiveSpacer, bool passiveStructure, bool passiveAPlate)
void autoAdaptITk(bool reset, bool pixelModules, bool pixelServices, bool pixelSupports, bool stripSensors, bool stripElectronics, bool stripServices, bool stripSupports)
void setZoomToVolumeOnClick(bool)
void emit_appropriateMDTProjectionsChanged()
void autoAdaptHGTD(bool reset, bool modules, bool supportStructure, bool coolingLines, bool covers, bool moderator, bool servicesElectronics)
void enableMuonChamberLabels(bool, bool)
first is t0s, 2nd is hits
VP1GeometrySystem(const VP1GeoFlags::SubSystemFlags &SubSystemsTurnedOn=VP1GeoFlags::None, const QString &name="Geo")
void orientViewToMuonChamber(const GeoPVConstLink &chamberPV)
void resetSubSystems(VP1GeoFlags::SubSystemFlags)
void autoIconifyByVolumeOrMaterialName(bool, const QString &)
void volumeResetRequested(VolumeHandle *)
void plotSpectrum(QStack< QString > &, int copyNumber=-1)
void autoAdaptPixelsOrSCT(bool, bool, bool, bool, bool, bool)
void volumeStateChangeRequested(VolumeHandle *, VP1GeoFlags::VOLSTATE)
void setLabelPosOffsets(const QList< int > &)
void systemcreate(StoreGateSvc *detstore)
void autoExpandByVolumeOrMaterialName(bool, const QString &)
void appropriateMDTProjectionsChanged(int)
void actionOnAllNonStandardVolumes(bool)
void setAutoAdaptMuonChambersToEventData(bool)
void reiconizeToShowSpecificMuonChambers(const std::set< GeoPVConstLink > &)
void saveMaterialsToFile(const QString &, bool)
void restoreFromState(QByteArray)
static bool hasMuonNSWGeometry()
static bool hasGeoModelExperiment()
static bool hasPixelGeometry()
static bool hasSCTGeometry()
static bool hasHGTDGeometry()
static bool hasITkGeometry()
static bool hasMuonGeometry()
static void decodeTransformation(const SbMatrix &, float &translation_x, float &translation_y, float &translation_z, float &rotaxis_x, float &rotaxis_y, float &rotaxis_z, float &rotangle_radians)
static void transformToMatrix(SoTransform *xf, SbMatrix &result)
static bool debug()
Definition VP1Msg.h:32
static void messageDebug(const QString &)
Definition VP1Msg.cxx:39
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static bool changePathTail(SoPath *path, SoNode *commonBranchPoint, SoNode *newtail)
static void setShowVolumeOutlines(SoGroup *nodesep, bool showvol)
const SbMatrix & getGlobalTransformToVolume() const
std::string getNameStdString() const
VP1GeoFlags::VOLSTATE state() const
const GeoMaterial * geoMaterial() const
void initialiseChildren()
QString getName() const
VolumeHandleListItr childrenBegin()
SbMatrix getLocalTransformToVolume() const
VolumeHandleListItr childrenEnd()
VolumeHandle * topLevelParent()
void contractDaughtersRecursively()
SoSeparator * nodeSoSeparator() const
std::vector< VolumeHandle * > VolumeHandleList
GeoPVConstLink geoPVConstLink() const
int copyNumber() const
bool isInMuonChamber() const
void setMuonChamberDirty(bool)
virtual QString getDescriptiveName() const
void setState(const VP1GeoFlags::VOLSTATE &state, bool autoExpandEther=true)
VolumeHandleList::iterator VolumeHandleListItr
VP1GeoFlags::SubSystemFlag subsystem() const
VolumeHandle * parent()
int childNumber() const
unsigned nChildren() const
const std::string reset
bool exists(const std::string &filename)
does a file exist
double entries
Definition listroot.cxx:49
HepGeom::Transform3D EigenTransformToCLHEP(const Amg::Transform3D &eigenTransf)
Converts an Eigen-based Amg::Transform3D into a CLHEP-based HepGeom::Transform3D.
path
python interpreter configuration --------------------------------------—
Definition athena.py:132
Definition index.py:1
TFile * file