summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2011-09-30 11:30:52 -0400
committerStan Seibert <stan@mtrr.org>2011-09-30 11:30:52 -0400
commitbbad0212924f725085c63d4a9133a9d73110f11a (patch)
tree597a98bf077877865b0a4387bd341f985a307e39
parent1690552ff476ae8d0994f38966ce9422b800b901 (diff)
downloadchroma-bbad0212924f725085c63d4a9133a9d73110f11a.tar.gz
chroma-bbad0212924f725085c63d4a9133a9d73110f11a.tar.bz2
chroma-bbad0212924f725085c63d4a9133a9d73110f11a.zip
Test if root.C classes have been loaded before loading in root.py. Prevents printed warnings when the user already has a .rootlogon.C to load the Chroma ROOT classes.
-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):