Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PHGeomTGeo.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file PHGeomTGeo.cc
1 // $Id: $
2 
11 #include "PHGeomTGeo.h"
12 
13 #include "TGeoManager.h"
14 
15 #include <cassert>
16 #include <cstdlib>
17 #include <iostream>
18 
19 using namespace std;
20 
22  : _fGeom(nullptr)
23 {
24 }
25 
27 {
29  if (_fGeom)
30  {
31  _fGeom->UnlockGeometry();
32  }
33  delete _fGeom;
34 }
35 
36 void PHGeomTGeo::SetGeometry(TGeoManager* g)
37 {
39  assert(_fGeom == nullptr);
40 
41  if (!g)
42  {
43  cout << __PRETTY_FUNCTION__ << " - Error - Invalid input" << endl;
44  return;
45  }
46 
47  _fGeom = g;
48  _fGeom->LockGeometry();
49 
51 }
52 
53 TGeoManager*
55 {
56  if (_fGeom == nullptr)
57  return nullptr;
58 
60 
61  if (_fGeom == gGeoManager)
62  return _fGeom;
63  else
64  {
65  return nullptr;
66  }
67 }
68 
72 void PHGeomTGeo::identify(std::ostream& os) const
73 {
74  os << "PHGeomTGeo - ";
75  if (_fGeom)
76  os << " with geometry data " << _fGeom->GetName() << ": "
77  << _fGeom->GetTitle();
78  else
79  os << "Empty";
80  os << endl;
82 }
83 
86 {
88 
89  if (_fGeom)
90  {
91  _fGeom->UnlockGeometry();
92  delete _fGeom;
93  }
94  _fGeom = nullptr;
95 }
96 
99 {
101 
102  if (_fGeom == nullptr)
103  return 0;
104  if (_fGeom->IsZombie())
105  return 0;
106  return 1;
107 }
108 
110 {
111  if (_fGeom == nullptr)
112  return true; // uninitialized
113 
114  if (_fGeom == gGeoManager)
115  return true;
116  else
117  {
118  cout << __PRETTY_FUNCTION__
119  << " - ERROR - gGeoManager is overridden by another TGeoManager. "
120  << "Please avoid using multiple TGeoManager in processing. Stop the process."
121  << endl;
122  exit(1);
123  return false;
124  }
125 }