summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chroma/io/root.py34
1 files changed, 18 insertions, 16 deletions
diff --git a/chroma/io/root.py b/chroma/io/root.py
index 3fb7062..b74a887 100644
--- a/chroma/io/root.py
+++ b/chroma/io/root.py
@@ -5,22 +5,24 @@ import chroma.event as event
from chroma.rootimport import ROOT
-# Create .chroma directory if it doesn't exist
-chroma_dir = os.path.expanduser('~/.chroma')
-if not os.path.isdir(chroma_dir):
- if os.path.exists(chroma_dir):
- raise Exception('$HOME/.chroma file exists where directory should be')
- else:
- os.mkdir(chroma_dir)
-# Check if latest ROOT file is present
-package_root_C = os.path.join(os.path.dirname(__file__), 'root.C')
-home_root_C = os.path.join(chroma_dir, 'root.C')
-if not os.path.exists(home_root_C) or \
- os.stat(package_root_C).st_mtime > os.stat(home_root_C).st_mtime:
- shutil.copy2(src=package_root_C, dst=home_root_C)
-# Import this C file for access to data structure
-ROOT.gROOT.ProcessLine('.L '+home_root_C+'+')
-
+# Check if we have already imported the ROOT class due to a user's
+# rootlogon.C script
+if not hasattr(ROOT, 'Vertex') or not hasattr(ROOT, 'Channel'):
+ # Create .chroma directory if it doesn't exist
+ chroma_dir = os.path.expanduser('~/.chroma')
+ if not os.path.isdir(chroma_dir):
+ if os.path.exists(chroma_dir):
+ raise Exception('$HOME/.chroma file exists where directory should be')
+ else:
+ os.mkdir(chroma_dir)
+ # Check if latest ROOT file is present
+ package_root_C = os.path.join(os.path.dirname(__file__), 'root.C')
+ home_root_C = os.path.join(chroma_dir, 'root.C')
+ if not os.path.exists(home_root_C) or \
+ os.stat(package_root_C).st_mtime > os.stat(home_root_C).st_mtime:
+ shutil.copy2(src=package_root_C, dst=home_root_C)
+ # Import this C file for access to data structure
+ ROOT.gROOT.ProcessLine('.L '+home_root_C+'+')
def tvector3_to_ndarray(vec):