Commit 2b0f6b7d authored by Maximilian Caspar's avatar Maximilian Caspar
Browse files

Find library path automatically

parent 2d606332
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -18,21 +18,20 @@ parser = argparse.ArgumentParser()
parser.add_argument("-l", metavar='libAllpixObjects', required=False,
                    help="specify path to the libAllpixObjects library (generally in allpix-squared/lib/)) ")
args = parser.parse_args()

if args.l is not None:  # Try to find Allpix Library
    lib_file_name = (str(args.l))
else:  # Look in LD_LIBRARY_PATH
    libraryPaths = os.environ['LD_LIBRARY_PATH'].split(':')
    for p in libraryPaths:
        if p.endswith("lib/libAllpixObjects.so"):
            lib_file_name = p
            break

if (not os.path.isfile(lib_file_name)):
    print("WARNING: ", lib_file_name, " does not exist, exiting")
    exit(1)

elif os.path.isfile(path.abspath(path.join(__file__, "..", "..", "opt", "allpix-squared", "lib", "libAllpixObjects.so"))):  # For native installs
    lib_file_name = path.abspath(path.join(
        __file__, "..", "..", "opt", "allpix-squared", "lib", "libAllpixObjects.so"))

elif os.path.isfile(path.join(path.sep, "opt", "allpix-squared", "lib", "libAllpixObjects.so")):  # For Docker installs
    lib_file_name = path.join(
        path.sep, "opt", "allpix-squared", "lib", "libAllpixObjects.so")


histogram = Histogram(granularity=[1, 15])

# load library and rootfile
@@ -40,6 +39,7 @@ gSystem.Load(lib_file_name)
rootFile = ROOT.TFile("output/cosmicsMC.root")
McParticle = rootFile.Get('MCParticle')


def getTracks():
    "Load tracks from the ROOT file"
    time = SimulatedTime("cosmic_flux_log.txt").time
@@ -64,6 +64,7 @@ def getTracks():
                              direction.x(), direction.y(), direction.z()], 0, 0, 0, 0))
    return tracks, time


# Get tracks from file
tracks, time = getTracks()
histogram.addTracks(tracks, time)