Commit fb2716a1 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬

Include detailed TPC geometry

parent 75f4fbaa
......@@ -2,7 +2,9 @@
# animate_particles.py - Animate HEP events
#
# For console only rendering (example):
# $ blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=1 -camera="BarrelCamera" -datafile="esd-detail.dat" -n_event=0 -simulated_t=0.02 -fps=24 -resolution=100 -transparency=1.2 -stamp_note="Texto no canto" -its=1 -tpc=0 -trd=1 -emcal=0 -blendersave=0 -picpct=5
# $ blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=1 -camera="BarrelCamera" \
# -datafile="esd-detail.dat" -n_event=0 -simulated_t=0.02 -fps=24 -resolution=100 -transparency=1.2 \
# -stamp_note="Texto no canto" -its=1 -tpc=0 -trd=1 -detailed_tpc=1 -emcal=0 -blendersave=0 -picpct=5 -tpc_blender_path="/home/files/blender"
#
import os
......@@ -42,6 +44,8 @@ parser.add_argument('-trd','--trd')
parser.add_argument('-emcal','--emcal')
parser.add_argument('-blendersave','--blendersave')
parser.add_argument('-picpct','--picpct')
parser.add_argument('-tpc_blender_path','--tpc_blender_path')
parser.add_argument('-detailed_tpc','--detailed_tpc')
args = parser.parse_args()
bpy.context.user_preferences.view.show_splash = False
......@@ -59,9 +63,10 @@ resolution_percent = int(args.resolution_percent)
stamp_note = args.stamp_note
transp_par = float(args.transp_par)
datafile = str(args.datafile)
detectors = [int(args.its),int(args.tpc),int(args.trd),int(args.emcal)] # Array that stores which detectors to build
detectors = [int(args.its),int(args.tpc),int(args.trd),int(args.emcal),int(args.detailed_tpc)] # Array that stores which detectors to build
blendersave = int(args.blendersave) # 1 (save Blender file) or 0 (don't)
picpct = int(args.picpct) # percentage of animation to take picture
tpc_blender_path = str(args.tpc_blender_path) # path to 'animate' directory, where .blend file for detailed TPC is saved
#configure output
outputPath = "/tmp/alice_blender/"
......@@ -84,7 +89,7 @@ driver = dataDriver("AlirootFileGenerator",n_event,datafile) # Simple dataDriver
driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent)
### Build scene
init(stamp_note,renderCamera,transp_par,detectors) # Cleanup, addCameras, addALICE_TPC
init(stamp_note,renderCamera,transp_par,detectors,tpc_blender_path) # Cleanup, addCameras, addALICE_TPC
particles = driver.getParticles()
blender_particles, blender_tracks = createSceneParticles(particles,createTracks = True) # Create blender objects - one sphere per particle
......
......@@ -2,7 +2,7 @@
filename = os.path.join(os.path.basename(bpy.data.filepath), "blender_functions.py")
exec(compile(open(filename).read(), filename, 'exec'))
def init(unique_id,camera_type,transp_par,detectors):
def init(unique_id,camera_type,transp_par,detectors,blender_path):
bcs = bpy.context.scene
# Configure Environment
......@@ -39,11 +39,11 @@ def init(unique_id,camera_type,transp_par,detectors):
addLamps() # Add Lamps
if camera_type == "ForwardCamera":
addALICE_Geometry(True,transp_par,detectors) # ALICE TPC, EMCal, ITS, TRD
addALICE_Geometry(True,transp_par,detectors,blender_path) # ALICE TPC, EMCal, ITS, TRD
else:
addALICE_Geometry(False,transp_par,detectors)
addALICE_Geometry(False,transp_par,detectors,blender_path)
def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1,0], blender_path="/home/"):
if bright_colors: # Defining sequence of RGB values to fill 'createMaterial' functions below
rgb_v = [13,13,25,10] # Colors for "ForwardCamera"
......@@ -51,8 +51,19 @@ def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
rgb_v = [0.5,0.9,1,0.2] # Colors for "OverviewCamera", "AntiOverviewCamera" and "BarrelCamera"
# ADD ITS
if detectors[0]:
addALICE_ITS(transp_par,rgb_v)
if detectors[4]:
importALICE_detailed_TPC(transp_par,blender_path)
else:
if detectors[1]:
addALICE_TPC(transp_par,rgb_v)
if detectors[2]:
addALICE_TRD(transp_par,rgb_v)
if detectors[3]:
addALICE_EMCal(transp_par,rgb_v)
def addALICE_ITS(transp_par,rgb_v):
# ADD ITS INNER BARREL
......@@ -106,7 +117,7 @@ def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
outer_ITS = bpy.context.object
outer_ITS.name = "outerITS"
# Subtract hole from main TPC part
# Subtract hole from main ITS part
subtract(outer_ITS_hole,outer_ITS)
# Set material
......@@ -118,8 +129,7 @@ def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
Outer_ITS = bpy.context.object
Outer_ITS.name = "OuterITS"
# ADD TPC
if detectors[1]:
def addALICE_TPC(transp_par,rgb_v):
# Material
createMaterial("tpc",R=0,G=rgb_v[0],B=0,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
......@@ -133,8 +143,26 @@ def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
TPC.data.materials.clear()
TPC.data.materials.append(bpy.data.materials["tpc"])
# ADD ALICE TRD
if detectors[2]:
def importALICE_detailed_TPC(transp_par,blender_path):
# Materials
createMaterial("tpc_part_1",R=0,G=1,B=0,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
createMaterial("tpc_part_2",R=1,G=1,B=0,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
createMaterial("tpc_part_3",R=1,G=0,B=0,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
createMaterial("tpc_part_4",R=0,G=1,B=1,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Import detailed TPC
for i in range(1,5):
bpy.ops.wm.append(filename="tpc_part"+str(i), directory=blender_path+"/Detailed_TPC.blend/Object/")
bpy.context.scene.objects.active = bpy.data.objects["tpc_part"+str(i)]
TPC_part = bpy.context.object
TPC_part.name = "TPC_part_"+str(i)
# Set material
TPC_part.data.materials.clear()
TPC_part.data.materials.append(bpy.data.materials["tpc_part_"+str(i)])
def addALICE_TRD(transp_par,rgb_v):
# Material
createMaterial("TRD",R=rgb_v[3],G=0,B=rgb_v[3],shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.15,emit=0.8,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
......@@ -188,8 +216,7 @@ def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
subtract(slice,TRD)
# ADD EMCal
if detectors[3]:
def addALICE_EMCal(transp_par,rgb_v):
# Material
createMaterial("emcal",R=rgb_v[1],G=rgb_v[1],B=0,shadows=False,cast_shadows=False,transparency=True,alpha=transp_par*0.05,emit=1.5,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
......
......@@ -36,7 +36,7 @@ fi
OPTIONS=c:hdau:m:n:t:r:
LONGOPTS=camera:,mosaic,resolution:,fps:,transparency:,duration:,maxparticles:,\
minparticles:,numberofevents:,minavgpz:,minavgpt:,help,download,sample,url:,its,\
tpc,trd,emcal,blendersave,picpct:
tpc,detailedtpc,trd,emcal,blendersave,picpct:
# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
......@@ -71,6 +71,7 @@ SAMPLE=false
URL=
ITS=1 # 1 means "build this detector", while 0 means "don't"
TPC=1
DETAILED_TPC=0
TRD=1
EMCAL=1
BLENDERSAVE=0
......@@ -151,6 +152,10 @@ while true; do
TPC=0
shift
;;
--detailedtpc)
DETAILED_TPC=1
shift
;;
--trd)
TRD=0
shift
......@@ -234,6 +239,8 @@ Usage:
038/ESD/0001/AliESDs.root
--its
Removes ITS detector from animation
--detailedtpc
Includes more detailed version of TPC in animation
--tpc
Removes TPC detector from animation
--trd
......@@ -285,9 +292,13 @@ else
if [[ $ITS = 1 ]]; then
echo "Building ITS"
fi
if [[ $DETAILED_TPC = 1 ]]; then
echo "Building detailed TPC"
else
if [[ $TPC = 1 ]]; then
echo "Building TPC"
fi
fi
if [[ $TRD = 1 ]]; then
echo "Building TRD"
fi
......@@ -347,7 +358,8 @@ if [ "$SAMPLE" = "true" ]; then
-duration=${DURATION} -camera=${type} -datafile="d-esd-detail.dat" -simulated_t=0.03\
-fps=${FPS} -resolution=${RESOLUTION} -transparency=${TRANSPARENCY} -stamp_note=\
"opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS} \
-tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} -blendersave=${BLENDERSAVE} -picpct=5
-tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} -detailed_tpc=${DETAILED_TPC} \
-blendersave=${BLENDERSAVE} -picpct=${PICPCT} -tpc_blender_path=${BLENDER_SCRIPT_DIR}
done
popd
BLENDER_OUTPUT=.
......@@ -457,7 +469,8 @@ elif [ "$SAMPLE" = "false" ]; then
-duration=${DURATION} -camera=${type} -datafile="${LOCAL_FILE_WITH_DATA}"\
-n_event=${EVENT_ID} -simulated_t=0.03 -fps=${FPS} -resolution=${RESOLUTION}\
-transparency=${TRANSPARENCY} -stamp_note="${EVENT_UNIQUE_ID}" -its=${ITS}\
-tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} -blendersave=${BLENDERSAVE} -picpct=${PICPCT}
-tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} -detailed_tpc=${DETAILED_TPC} \
-blendersave=${BLENDERSAVE} -picpct=${PICPCT} -tpc_blender_path=${BLENDER_SCRIPT_DIR}
echo "${type} for event ${EVENT_UNIQUE_ID} done."
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment