# R way of retrieving token
token=readLines('/home/idies/keystone.token')
# soucrgin some scripts specially written for querying CAS jobs from R,
# and for plotting galaxy and halo merger trees respectively
source('query_CAS.r')
source('HandleTrees.r')
# find some random galaxies from the L-Galaxies semi-analytical simulation
# from Henriques etal 2015 (9)2015MNRAS.451.2663H)
# available on this version of CasJobs as context Henriques2015a
sql="
select galaxyId, haloId
from mrscplanck1
where snapnum=58 and stellarmass between 11 and 11.1 and type=0"
r=queryCAS(sql,token=token,context="Henriques2015a")
# plot the merger tree for the first galaxy
gt=galaxyTree(root=r$galaxyId[1],token=token,plot=TRUE)
# plot the merger tree for the corresponding dark matter halo
ht=haloTree(root=r$haloId[1],token=token,plot=TRUE)