summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Seibert <stan@mtrr.org>2011-09-17 16:50:04 -0400
committerStan Seibert <stan@mtrr.org>2011-09-17 16:50:04 -0400
commit8c317cf4892395aa61c00fdf72f1cfd32b089db9 (patch)
treea8783789f5c6415d6de5cbb3a866cd0c02f63963
parent94ffd5cf1cd6a3e7042f4cf232f664e4adcadb10 (diff)
downloadchroma-8c317cf4892395aa61c00fdf72f1cfd32b089db9.tar.gz
chroma-8c317cf4892395aa61c00fdf72f1cfd32b089db9.tar.bz2
chroma-8c317cf4892395aa61c00fdf72f1cfd32b089db9.zip
.chroma directory is now used to build the ROOT shared library describing the event data structure. No more writing files to chroma package directory.
-rw-r--r--chroma/io/root.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/chroma/io/root.py b/chroma/io/root.py
index bb4b39a..55f7858 100644
--- a/chroma/io/root.py
+++ b/chroma/io/root.py
@@ -1,11 +1,26 @@
import ROOT
-import os.path
+import os, os.path
+import shutil
import numpy as np
+import chroma.event as event
+
+# 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+'+')
-ROOT.gROOT.ProcessLine('.L '+os.path.join(os.path.dirname(__file__), 'root.C'))
-import ROOT
-import chroma.event as event
def tvector3_to_ndarray(vec):
'''Convert a ROOT.TVector3 into a numpy np.float32 array'''