File indexing completed on 2025-12-16 09:20:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "PHGeomTGeo.h"
0012
0013 #include "TGeoManager.h"
0014
0015 #include <cassert>
0016 #include <cstdlib>
0017 #include <iostream>
0018
0019 PHGeomTGeo::~PHGeomTGeo()
0020 {
0021 ConsistencyCheck();
0022 if (_fGeom)
0023 {
0024 TGeoManager::UnlockGeometry();
0025 }
0026 delete _fGeom;
0027 }
0028
0029 void PHGeomTGeo::SetGeometry(TGeoManager* g)
0030 {
0031 ConsistencyCheck();
0032 assert(_fGeom == nullptr);
0033
0034 if (!g)
0035 {
0036 std::cout << __PRETTY_FUNCTION__ << " - Error - Invalid input" << std::endl;
0037 return;
0038 }
0039
0040 _fGeom = g;
0041 TGeoManager::LockGeometry();
0042
0043 ConsistencyCheck();
0044 }
0045
0046 TGeoManager*
0047 PHGeomTGeo::GetGeometry()
0048 {
0049 if (_fGeom == nullptr)
0050 {
0051 return nullptr;
0052 }
0053
0054 ConsistencyCheck();
0055
0056 if (_fGeom == gGeoManager)
0057 {
0058 return _fGeom;
0059 }
0060
0061 return nullptr;
0062 }
0063
0064
0065
0066
0067 void PHGeomTGeo::identify(std::ostream& os) const
0068 {
0069 os << "PHGeomTGeo - ";
0070 if (_fGeom)
0071 {
0072 os << " with geometry data " << _fGeom->GetName() << ": "
0073 << _fGeom->GetTitle();
0074 }
0075 else
0076 {
0077 os << "Empty";
0078 }
0079 os << std::endl;
0080 ConsistencyCheck();
0081 }
0082
0083
0084 void PHGeomTGeo::Reset()
0085 {
0086 ConsistencyCheck();
0087
0088 if (_fGeom)
0089 {
0090 TGeoManager::UnlockGeometry();
0091 delete _fGeom;
0092 }
0093 _fGeom = nullptr;
0094 }
0095
0096
0097 int PHGeomTGeo::isValid() const
0098 {
0099 ConsistencyCheck();
0100
0101 if (_fGeom == nullptr)
0102 {
0103 return 0;
0104 }
0105 if (_fGeom->IsZombie())
0106 {
0107 return 0;
0108 }
0109 return 1;
0110 }
0111
0112 bool PHGeomTGeo::ConsistencyCheck() const
0113 {
0114 if (_fGeom == nullptr)
0115 {
0116 return true;
0117 }
0118
0119 if (_fGeom == gGeoManager)
0120 {
0121 return true;
0122 }
0123
0124 std::cout << __PRETTY_FUNCTION__
0125 << " - ERROR - gGeoManager is overridden by another TGeoManager. "
0126 << "Please avoid using multiple TGeoManager in processing. Stop the process."
0127 << std::endl;
0128 exit(1);
0129 return false;
0130 }