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