Commit fb4d68a2 authored by Breno Rilho Lemos's avatar Breno Rilho Lemos 💬
Browse files

Add options for not building detectors in workflow_sketch.sh

parent b08f74da
......@@ -2,7 +2,7 @@
# 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 -transperency=1.2 -stamp_note="Texto no canto"
# $ 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 -transperency=1.2 -stamp_note="Texto no canto" -its=1 -tpc=0 -trd=1 -emcal=0
#
import os
......@@ -36,6 +36,10 @@ parser.add_argument('-resolution','--resolution_percent')
parser.add_argument('-stamp_note','--stamp_note')
parser.add_argument('-n_event','--n_event')
parser.add_argument('-transperency','--transp_par')
parser.add_argument('-its','--its')
parser.add_argument('-tpc','--tpc')
parser.add_argument('-trd','--trd')
parser.add_argument('-emcal','--emcal')
args = parser.parse_args()
bpy.context.user_preferences.view.show_splash = False
......@@ -50,7 +54,9 @@ simulated_t = float(args.simulated_t) # in microsseconds
duration = int(args.duration) # in seconds
fps = int(args.fps)
resolution_percent = int(args.resolution_percent)
stamp_note = args.stamp_note
transp_par = float(args.transp_par)
detectors = [int(args.its),int(args.tpc),int(args.trd),int(args.emcal)] # Array that stores which detectors to build
#configure output
outputPath = "/tmp/blender/"
......@@ -73,7 +79,7 @@ driver = dataDriver("AlirootFileGenerator",n_event,args.datafile) # Simple dataD
driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent)
### Build scene
init(args.stamp_note,renderCamera,transp_par) # Cleanup, addCameras, addALICE_TPC
init(stamp_note,renderCamera,transp_par,detectors) # 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):
def init(unique_id,camera_type,transp_par,detectors):
bcs = bpy.context.scene
# Configure Environment
......@@ -31,190 +31,194 @@ def init(unique_id,camera_type,transp_par):
addCameras() # Add cameras
if camera_type == "ForwardCamera":
addALICE_Geometry(True,transp_par) # ALICE TPC, EMCal, ITS, TRD
addALICE_Geometry(True,transp_par,detectors) # ALICE TPC, EMCal, ITS, TRD
else:
addALICE_Geometry(False,transp_par)
addALICE_Geometry(False,transp_par,detectors)
def addALICE_Geometry(bright_colors=True, transp_par=1.0):
def addALICE_Geometry(bright_colors=True, transp_par=1.0, detectors=[1,1,1,1]):
if bright_colors: # Defining sequence of RGB values to fill 'createMaterial' functions below
rgb_v = [13,13,25,10] # Colors for "ForwardCamera"
else:
rgb_v = [0.5,0.9,1,0.2] # Colors for "OverviewCamera" and "BarrelCamera"
# ADD TPC
# Material
createMaterial("tpc",R=0,G=rgb_v[0],B=0,shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add TPC
bpy.ops.mesh.primitive_cylinder_add(radius=2.461, depth=5.1, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
TPC = bpy.context.object
TPC.name = "TPC"
# Set material
TPC.data.materials.clear()
TPC.data.materials.append(bpy.data.materials["tpc"])
# ADD EMCal
# Material
createMaterial("emcal",R=rgb_v[1],G=rgb_v[1],B=0,shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.05,emit=1.5,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add cylinder for EMCal
bpy.ops.mesh.primitive_cylinder_add(radius=4.7, depth=5.1, vertices=19, view_align=False, enter_editmode=False, location=(0, 0, 0))
EMCal = bpy.context.object
EMCal.name = "EMCal"
# Add cylinder to be removed from center
bpy.ops.mesh.primitive_cylinder_add(radius=4.35, depth=5.2, vertices=19, view_align=False, enter_editmode=False, location=(0, 0, 0))
emcal_hole = bpy.context.object
emcal_hole.name = "Hole"
subtract(emcal_hole,EMCal);
# Adds rotated cube to be removed from EMCal so that there's a 7.3° angle with top y axis, clockwise
bpy.ops.mesh.primitive_cube_add(location=(2.85,2.2,0), rotation=(0,0,-0.1274), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube1 = bpy.context.object # first quadrant
subtract(cube1,EMCal)
# Adds rotated cube to be removed from EMCal so that there's a 9.7° angle with left x axis, anticlockwise
bpy.ops.mesh.primitive_cube_add(location=(-2.08,-2.95,0), rotation=(0,0,0.1693), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube3 = bpy.context.object # third quadrant
subtract(cube3,EMCal)
# ADD ITS
if detectors[0]:
#Adds cube with right angle in fourth quadrant to be removed from EMCal
bpy.ops.mesh.primitive_cube_add(location=(2.55,-2.55,0), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube4 = bpy.context.object # fourth quadrant
subtract(cube4,EMCal)
# ADD ITS INNER BARREL
# Set Material
EMCal.data.materials.clear()
EMCal.data.materials.append(bpy.data.materials["emcal"])
# Material
createMaterial("innerITS",R=rgb_v[2],G=0,B=rgb_v[2],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.7,emit=0,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add Inner ITS
bpy.ops.mesh.primitive_cylinder_add(radius=0.0421, depth=0.271, view_align=False, enter_editmode=False, location=(0, 0, 0))
inner_TPC = bpy.context.object
inner_TPC.name = "innerITS"
# ADD ITS INNER BARREL
# Set Material
inner_TPC.data.materials.clear()
inner_TPC.data.materials.append(bpy.data.materials["innerITS"])
# Material
createMaterial("innerITS",R=rgb_v[2],G=0,B=rgb_v[2],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.7,emit=0,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add Inner ITS
bpy.ops.mesh.primitive_cylinder_add(radius=0.0421, depth=0.271, view_align=False, enter_editmode=False, location=(0, 0, 0))
inner_TPC = bpy.context.object
inner_TPC.name = "innerITS"
# ADD ITS OUTER BARREL
# Set Material
inner_TPC.data.materials.clear()
inner_TPC.data.materials.append(bpy.data.materials["innerITS"])
# Material
createMaterial("outerITS",R=rgb_v[3],G=0,B=rgb_v[3],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.4,emit=0.8,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# ADD ITS MIDDLE LAYERS
# ADD ITS OUTER BARREL
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=0.1944, depth=0.9, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
middle_ITS_hole = bpy.context.object
middle_ITS_hole.name = "Hole"
# Material
createMaterial("outerITS",R=rgb_v[3],G=0,B=rgb_v[3],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.4,emit=0.8,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add actual middle layer ITS part
bpy.ops.mesh.primitive_cylinder_add(radius=0.247, depth=0.843, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
middle_ITS = bpy.context.object
middle_ITS.name = "middleITS"
# ADD ITS MIDDLE LAYERS
# Subtract hole from main TPC part
subtract(middle_ITS_hole,middle_ITS)
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=0.1944, depth=0.9, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
middle_ITS_hole = bpy.context.object
middle_ITS_hole.name = "Hole"
# Set material
middle_ITS.data.materials.clear()
middle_ITS.data.materials.append(bpy.data.materials["outerITS"])
# Add actual middle layer ITS part
bpy.ops.mesh.primitive_cylinder_add(radius=0.247, depth=0.843, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
middle_ITS = bpy.context.object
middle_ITS.name = "middleITS"
# Subtract hole from main TPC part
subtract(middle_ITS_hole,middle_ITS)
# ADD ITS OUTER LAYERS
# Set material
middle_ITS.data.materials.clear()
middle_ITS.data.materials.append(bpy.data.materials["outerITS"])
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=0.3423, depth=1.5, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
outer_ITS_hole = bpy.context.object
outer_ITS_hole.name = "Hole"
# Add actual outer layer ITS part
bpy.ops.mesh.primitive_cylinder_add(radius=0.3949, depth=1.475, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
outer_ITS = bpy.context.object
outer_ITS.name = "outerITS"
# ADD ITS OUTER LAYERS
# Subtract hole from main TPC part
subtract(outer_ITS_hole,outer_ITS)
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=0.3423, depth=1.5, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
outer_ITS_hole = bpy.context.object
outer_ITS_hole.name = "Hole"
# Set material
outer_ITS.data.materials.clear()
outer_ITS.data.materials.append(bpy.data.materials["outerITS"])
# Add actual outer layer ITS part
bpy.ops.mesh.primitive_cylinder_add(radius=0.3949, depth=1.475, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
outer_ITS = bpy.context.object
outer_ITS.name = "outerITS"
# Make ITS middle and outer layers a single object
joinObjects([middle_ITS,outer_ITS])
Outer_ITS = bpy.context.object
Outer_ITS.name = "OuterITS"
# Subtract hole from main TPC part
subtract(outer_ITS_hole,outer_ITS)
# ADD TPC
if detectors[1]:
# Set material
outer_ITS.data.materials.clear()
outer_ITS.data.materials.append(bpy.data.materials["outerITS"])
# Material
createMaterial("tpc",R=0,G=rgb_v[0],B=0,shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.2,emit=0.3,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Make ITS middle and outer layers a single object
joinObjects([middle_ITS,outer_ITS])
Outer_ITS = bpy.context.object
Outer_ITS.name = "OuterITS"
# Add TPC
bpy.ops.mesh.primitive_cylinder_add(radius=2.461, depth=5.1, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
TPC = bpy.context.object
TPC.name = "TPC"
# Set material
TPC.data.materials.clear()
TPC.data.materials.append(bpy.data.materials["tpc"])
# ADD ALICE TRD
if detectors[2]:
# Material
createMaterial("TRD",R=rgb_v[3],G=0,B=rgb_v[3],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.15,emit=0.8,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Material
createMaterial("TRD",R=rgb_v[3],G=0,B=rgb_v[3],shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.15,emit=0.8,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=2.9, depth=6, vertices=18, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
TRD_hole = bpy.context.object
TRD_hole.name = "Hole"
# Add "hole" to subtract from the middle
bpy.ops.mesh.primitive_cylinder_add(radius=2.9, depth=6, vertices=18, view_align=False, enter_editmode=False, location=(0, 0, 0)) #smaller cylinder
TRD_hole = bpy.context.object
TRD_hole.name = "Hole"
# Add actual TRD part
bpy.ops.mesh.primitive_cylinder_add(radius=3.7, depth=5.1, vertices=18, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
TRD = bpy.context.object
TRD.name = "TRD"
# Add actual TRD part
bpy.ops.mesh.primitive_cylinder_add(radius=3.7, depth=5.1, vertices=18, view_align=False, enter_editmode=False, location=(0, 0, 0)) #bigger cylinder
TRD = bpy.context.object
TRD.name = "TRD"
# Subtract hole from main TRD part
subtract(TRD_hole,TRD)
# Subtract hole from main TRD part
subtract(TRD_hole,TRD)
# Set material
TRD.data.materials.clear()
TRD.data.materials.append(bpy.data.materials["TRD"])
# Set material
TRD.data.materials.clear()
TRD.data.materials.append(bpy.data.materials["TRD"])
# Add 'slices' to subtract from TRD structure
bpy.ops.mesh.primitive_cube_add(radius=1, location=(2.855942,0.50358,0))
slice = bpy.context.object
slice.name = "slice"
bpy.ops.transform.resize(value=(1,0.03,4))
bpy.context.object.rotation_euler[2] = 0.174533
subtract(slice,TRD)
# Add 'slices' to subtract from TRD structure
bpy.ops.mesh.primitive_cube_add(radius=1, location=(2.855942,0.50358,0))
slice = bpy.context.object
slice.name = "slice"
bpy.ops.transform.resize(value=(1,0.03,4))
bpy.context.object.rotation_euler[2] = 0.174533
subtract(slice,TRD)
def rad(theta): # Convert degrees to radians
return theta * math.pi / 180
def rad(theta): # Convert degrees to radians
return theta * math.pi / 180
xn = 2.9 * math.cos(rad(10))
yn = 2.9 * math.sin(rad(10))
xn = 2.9 * math.cos(rad(10))
yn = 2.9 * math.sin(rad(10))
for n in range(1,18):
for n in range(1,18):
dx = -2 * 2.9 * math.sin(rad(10)) * math.sin(rad(n * 20))
xn += dx
dx = -2 * 2.9 * math.sin(rad(10)) * math.sin(rad(n * 20))
xn += dx
dy = 2 * 2.9 * math.sin(rad(10)) * math.cos(rad(n * 20))
yn += dy
dy = 2 * 2.9 * math.sin(rad(10)) * math.cos(rad(n * 20))
yn += dy
rotat = rad(10 + n*20)
rotat = rad(10 + n*20)
bpy.ops.mesh.primitive_cube_add(radius=1, location=(xn,yn,0))
slice = bpy.context.object
slice.name = "slice"
bpy.ops.transform.resize(value=(1,0.03,4))
bpy.context.object.rotation_euler[2] = rotat
bpy.ops.mesh.primitive_cube_add(radius=1, location=(xn,yn,0))
slice = bpy.context.object
slice.name = "slice"
bpy.ops.transform.resize(value=(1,0.03,4))
bpy.context.object.rotation_euler[2] = rotat
subtract(slice,TRD)
subtract(slice,TRD)
# ADD EMCal
if detectors[3]:
# Material
createMaterial("emcal",R=rgb_v[1],G=rgb_v[1],B=0,shadows=False,cast_shadows=False,transperency=True,alpha=transp_par*0.05,emit=1.5,specular_alpha=0,fresnel_factor=5,fresnel=0.3)
# Add cylinder for EMCal
bpy.ops.mesh.primitive_cylinder_add(radius=4.7, depth=5.1, vertices=19, view_align=False, enter_editmode=False, location=(0, 0, 0))
EMCal = bpy.context.object
EMCal.name = "EMCal"
# Add cylinder to be removed from center
bpy.ops.mesh.primitive_cylinder_add(radius=4.35, depth=5.2, vertices=19, view_align=False, enter_editmode=False, location=(0, 0, 0))
emcal_hole = bpy.context.object
emcal_hole.name = "Hole"
subtract(emcal_hole,EMCal);
# Adds rotated cube to be removed from EMCal so that there's a 7.3° angle with top y axis, clockwise
bpy.ops.mesh.primitive_cube_add(location=(2.85,2.2,0), rotation=(0,0,-0.1274), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube1 = bpy.context.object # first quadrant
subtract(cube1,EMCal)
# Adds rotated cube to be removed from EMCal so that there's a 9.7° angle with left x axis, anticlockwise
bpy.ops.mesh.primitive_cube_add(location=(-2.08,-2.95,0), rotation=(0,0,0.1693), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube3 = bpy.context.object # third quadrant
subtract(cube3,EMCal)
#Adds cube with right angle in fourth quadrant to be removed from EMCal
bpy.ops.mesh.primitive_cube_add(location=(2.55,-2.55,0), radius=2.55)
bpy.ops.transform.resize(value=(1.5,1.5,1.5), constraint_axis=(False,False,True))
cube4 = bpy.context.object # fourth quadrant
subtract(cube4,EMCal)
# Set Material
EMCal.data.materials.clear()
EMCal.data.materials.append(bpy.data.materials["emcal"])
def addCameras():
......
......@@ -33,8 +33,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
exit 1
fi
OPTIONS=c:hdau:m:t:r:b:
LONGOPTS=camera:,resolution:,transperency:,duration:,maxparticles:,help,download,default,url:
OPTIONS=c:hdau:m:t:r:b:ipqe
LONGOPTS=camera:,resolution:,transperency:,duration:,maxparticles:,help,download,default,url:,its,tpc,trd,emcal
# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
......@@ -61,6 +61,10 @@ HELP=false
DOWNLOAD=false
DEFAULT=false
URL=
ITS=1 # 1 means "build this detector", while 0 means "don't"
TPC=1
TRD=1
EMCAL=1
# now enjoy the options in order and nicely split until we see --
while true; do
case "$1" in
......@@ -101,6 +105,22 @@ while true; do
CAMERA="$2"
shift 2
;;
-i|--its)
ITS=0
shift
;;
-p|--tpc)
TPC=0
shift
;;
-q|--trd)
TRD=0
shift
;;
-e|--emcal)
EMCAL=0
shift
;;
--)
shift
break
......@@ -144,6 +164,14 @@ Usage:
Options: Barrel,Forward,Overview (defaults to Barrel)
-a | --default
Creates a default animation with blender.
-i | --its
Removes ITS detector from animation
-p | --tpc
Removes TPC detector from animation
-q | --trd
Removes TRD detector from animation
-e | --emcal
Removes EMCal detector from animation
Example:
--------
......@@ -171,6 +199,24 @@ else
echo "Max particles: ${MAX_PARTICLES}"
echo "Camera: $CAMERA"
echo "-----------------------------------"
echo "------------ Detectors ------------"
if [[ $ITS = 1 ]]; then
echo "Building ITS"
fi
if [[ $TPC = 1 ]]; then
echo "Building TPC"
fi
if [[ $TRD = 1 ]]; then
echo "Building TRD"
fi
if [[ $EMCAL = 1 ]]; then
echo "Building EMCAL"
fi
if [[ $TPC = 0 && $TPC = 0 && $TRD = 0 && $EMCAL = 0 ]]; then
echo "Not building any detectors"
fi
echo "-----------------------------------"
fi
if [[ $URL = "" ]]; then
......@@ -218,7 +264,7 @@ if [ "$DEFAULT" = "true" ]; then
# Phase 1: blender animate #
##############################
pushd ${BLENDER_SCRIPT_DIR}
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${CAMERA} -datafile="d-esd-detail.dat" -simulated_t=0.03 -fps=24 -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="Default animation"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${CAMERA} -datafile="d-esd-detail.dat" -simulated_t=0.03 -fps=24 -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="Default animation" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL}
popd
BLENDER_OUTPUT=.
mkdir --verbose -p ${BLENDER_OUTPUT}
......@@ -291,7 +337,7 @@ elif [ "$DEFAULT" = "false" ]; then
for type in $CAMERA; do
echo "Processing ${EVENT_UNIQUE_ID} with $type Camera in blender"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="${LOCAL_FILE_WITH_DATA}" -n_event=${EVENT_ID} -simulated_t=0.03 -fps=24 -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="${EVENT_UNIQUE_ID}"
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=${DURATION} -camera=${type} -datafile="${LOCAL_FILE_WITH_DATA}" -n_event=${EVENT_ID} -simulated_t=0.03 -fps=24 -resolution=${RESOLUTION} -transperency=${TRANSPERENCY} -stamp_note="${EVENT_UNIQUE_ID}" -its=${ITS} -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL}
# Move generated file to final location
mv /tmp/blender/* ${BLENDER_OUTPUT}
echo "${type} for event ${EVENT_UNIQUE_ID} 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