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

Generate animations for every event in file

parent c3985c40
...@@ -34,9 +34,6 @@ ...@@ -34,9 +34,6 @@
Int_t esd_event_id = 0; // global variable to store unique event id Int_t esd_event_id = 0; // global variable to store unique event id
Int_t smallEventID = 0; // is equal to esd-event-id until the selected event (one with an appropriate number of tracks) is reached
Int_t mediumEventID = 0; // for events with ~200 tracks
Int_t largeEventID = 0; // for events with many many tracks
class AliAnalysisTaskMyTask; // your analysis class class AliAnalysisTaskMyTask; // your analysis class
...@@ -127,6 +124,17 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -127,6 +124,17 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
s_event >> selectedEventID; s_event >> selectedEventID;
s_event.close(); s_event.close();
if(selectedEventID == -1) {
ofstream events_number;
events_number.open ("events_number.dat",std::ofstream::out);
events_number << esd_event_id+1;
events_number.close();
} else {
ofstream esd_detail; ofstream esd_detail;
esd_detail.open ("esd-detail.dat",std::ofstream::app); esd_detail.open ("esd-detail.dat",std::ofstream::app);
...@@ -148,11 +156,11 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *) ...@@ -148,11 +156,11 @@ void AliAnalysisTaskMyTask::UserExec(Option_t *)
Double_t MagneticField = 0.1 * fESD->GetMagneticField(); // gets magnetic field, in TESLA Double_t MagneticField = 0.1 * fESD->GetMagneticField(); // gets magnetic field, in TESLA
/* /*
Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || Charge (* 1.6*10^-19 C) Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || Charge (* 1.6*10^-19 C)
*/ */
if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data if(selectedEventID == esd_event_id) { // when we get to the selected event, fill histograms and write data
...@@ -185,11 +193,13 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) || ...@@ -185,11 +193,13 @@ Assumed Units: Mass (GeV/c^2)[CONFIRMED] || Energy (GeV) || Momentum (GeV/c) ||
} }
esd_detail.close();
}
Event++; Event++;
esd_event_id++; // Increment global esd_event_id esd_event_id++; // Increment global esd_event_id
fHistEvents->Fill(Event); fHistEvents->Fill(Event);
esd_detail.close();
// continue until all the tracks are processed // continue until all the tracks are processed
PostData(1, fOutputList); // stream the results the analysis of this event to PostData(1, fOutputList); // stream the results the analysis of this event to
......
...@@ -9,7 +9,10 @@ ...@@ -9,7 +9,10 @@
int runAnalysis(int selected_event=0) int runAnalysis(int selected_event=0)
{ {
// Erase output txt files // Erase output txt files
ofstream esd_detail, s_event; ofstream esd_detail, s_event, events_number;
events_number.open ("events_number.dat");
events_number.close();
s_event.open ("s-event.dat"); s_event.open ("s-event.dat");
s_event << selected_event; s_event << selected_event;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# animate_particles.py - Animate HEP events # animate_particles.py - Animate HEP events
# #
# For console only rendering (example): # For console only rendering (example):
# $ blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=1 -camera="BarrelCamera" -datafile="esd-detail.dat" -simulated_t=0.02 -fps=24 -resolution=100 -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 -stamp_note="Texto no canto"
# #
import os import os
...@@ -34,6 +34,7 @@ parser.add_argument('-simulated_t','--simulated_t') ...@@ -34,6 +34,7 @@ parser.add_argument('-simulated_t','--simulated_t')
parser.add_argument('-fps','--fps') parser.add_argument('-fps','--fps')
parser.add_argument('-resolution','--resolution_percent') parser.add_argument('-resolution','--resolution_percent')
parser.add_argument('-stamp_note','--stamp_note') parser.add_argument('-stamp_note','--stamp_note')
parser.add_argument('-n_event','--n_event')
args = parser.parse_args() args = parser.parse_args()
bpy.context.user_preferences.view.show_splash = False bpy.context.user_preferences.view.show_splash = False
...@@ -43,6 +44,7 @@ exec(compile(open(filename).read(), filename, 'exec')) ...@@ -43,6 +44,7 @@ exec(compile(open(filename).read(), filename, 'exec'))
# Set animation parameters # Set animation parameters
r_part = float(args.r_part) # Particle radius r_part = float(args.r_part) # Particle radius
n_event = str(args.n_event) # Event number for video name
simulated_t = float(args.simulated_t) # in microsseconds simulated_t = float(args.simulated_t) # in microsseconds
duration = int(args.duration) # in seconds duration = int(args.duration) # in seconds
fps = int(args.fps) fps = int(args.fps)
...@@ -65,7 +67,7 @@ driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdent ...@@ -65,7 +67,7 @@ driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdent
""" """
# Create and configure animation driver # Create and configure animation driver
driver = dataDriver("AlirootFileGenerator",args.datafile) # Simple dataDriver takes one parameters: filename driver = dataDriver("AlirootFileGenerator",n_event,args.datafile) # Simple dataDriver takes one parameters: filename
driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent) driver.configure(renderCamera, duration, fps, simulated_t, outputPath, fileIdentifier, resolution_percent)
### Build scene ### Build scene
......
...@@ -46,7 +46,7 @@ class animationDriver: ...@@ -46,7 +46,7 @@ class animationDriver:
bcsr.ffmpeg.packetsize = 2048 bcsr.ffmpeg.packetsize = 2048
bcsr.ffmpeg.muxrate = 10080000 bcsr.ffmpeg.muxrate = 10080000
xpixels = int(bcsr.resolution_percentage * bcsr.resolution_x / 100) xpixels = int(bcsr.resolution_percentage * bcsr.resolution_x / 100)
output_prefix=fileIdentifier+str(xpixels)+"px_"+self.name output_prefix=fileIdentifier+str(xpixels)+"px_"+self.name+self.renderCamera
bcsr.filepath = "/tmp/blender/"+output_prefix bcsr.filepath = "/tmp/blender/"+output_prefix
class genDriver(animationDriver): # A driver for particle generators class genDriver(animationDriver): # A driver for particle generators
...@@ -68,8 +68,8 @@ class genDriver(animationDriver): # A driver for particle generators ...@@ -68,8 +68,8 @@ class genDriver(animationDriver): # A driver for particle generators
return particles; return particles;
class dataDriver(animationDriver): # A driver for data from files. class dataDriver(animationDriver): # A driver for data from files.
def __init__(self,name,datafile): def __init__(self,name,nEvent,datafile):
self.name = name+"_"+datafile+"_" self.name = name+"_"+datafile+"_Event_"+nEvent+"_"
self.datafile = datafile self.datafile = datafile
def getParticles(self): # Create particles acording to parameters from file def getParticles(self): # Create particles acording to parameters from file
# Count number of lines in file = number of particles # Count number of lines in file = number of particles
......
...@@ -12,7 +12,7 @@ export BLENDER_SCRIPT_DIR=$(pwd)/animate/ ...@@ -12,7 +12,7 @@ export BLENDER_SCRIPT_DIR=$(pwd)/animate/
# Directory where output animations should be placed # Directory where output animations should be placed
export BLENDER_OUTPUT=$(pwd)/output/ export BLENDER_OUTPUT=$(pwd)/output/
# alienv working directory # alienv working directory
export ALIENV_WORK_DIR=/mnt/SSD/schnorr/ALICE/sw/ export ALIENV_WORK_DIR=/home/tropos/alice/sw
export ALIENV_ID=AliPhysics/latest-aliroot5-user export ALIENV_ID=AliPhysics/latest-aliroot5-user
# Put blender 2.79b in the PATH env var # Put blender 2.79b in the PATH env var
export PATH="/home/schnorr/install/blender-2.79-linux-glibc219-x86_64/:$PATH" export PATH="/home/schnorr/install/blender-2.79-linux-glibc219-x86_64/:$PATH"
...@@ -71,6 +71,7 @@ fi ...@@ -71,6 +71,7 @@ fi
if [ -z $DEFAULT_ANIMATION ]; then if [ -z $DEFAULT_ANIMATION ]; then
# Verify if AliESDs.root is here # Verify if AliESDs.root is here
# #ALIESD_ROOT_FILE=$(pwd)/AliESDs.root # #ALIESD_ROOT_FILE=$(pwd)/AliESDs.root
mkdir --verbose -p ${BLENDER_OUTPUT}
mv --verbose $(pwd)/AliESDs.root ${ALIROOT_SCRIPT_DIR} mv --verbose $(pwd)/AliESDs.root ${ALIROOT_SCRIPT_DIR}
############################## ##############################
...@@ -80,19 +81,37 @@ if [ -z $DEFAULT_ANIMATION ]; then ...@@ -80,19 +81,37 @@ if [ -z $DEFAULT_ANIMATION ]; then
pushd ${ALIROOT_SCRIPT_DIR} pushd ${ALIROOT_SCRIPT_DIR}
# #rm --verbose AliESDs.root # #rm --verbose AliESDs.root
# #ln --verbose -s $ALIESD_ROOT_FILE AliESDs.root # #ln --verbose -s $ALIESD_ROOT_FILE AliESDs.root
aliroot -q -b "runAnalysis.C(2)" aliroot -q -b "runAnalysis.C(-1)"
ls -lh esd-detail.dat ls -lh events_number.dat
#done n_events=`more events_number.dat`
popd for ((i=0; i<n_events; i++))
do
aliroot -q -b "runAnalysis.C($i)"
############################## # Phase 2: Blender animate
# Phase 2: blender animate #
##############################
mv --verbose ${ALIROOT_SCRIPT_DIR}/esd-detail.dat ${BLENDER_SCRIPT_DIR} mv --verbose ${ALIROOT_SCRIPT_DIR}/esd-detail.dat ${BLENDER_SCRIPT_DIR}
pushd ${BLENDER_SCRIPT_DIR} pushd ${BLENDER_SCRIPT_DIR}
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=2 -camera="BarrelCamera" -datafile="esd-detail.dat" -simulated_t=0.02 -fps=5 -resolution=100 -stamp_note="Texto no canto" for type in "BarrelCamera" "OverviewCamera" "ForwardCamera"; do
blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=1 -camera=${type} -datafile="esd-detail.dat" -n_event=$i -simulated_t=0.02 -fps=5 -resolution=50 -stamp_note="Texto no canto"
echo "${type} for event $i done."
done
popd popd
mkdir --verbose -p ${BLENDER_OUTPUT} #mkdir --verbose -p ${BLENDER_OUTPUT}
#mv --verbose /tmp/blender ${BLENDER_OUTPUT}
echo "EVENT $i DONE."
done
popd
mv --verbose /tmp/blender ${BLENDER_OUTPUT} mv --verbose /tmp/blender ${BLENDER_OUTPUT}
echo "Done." ##############################
# Phase 2: blender animate #
##############################
# mv --verbose ${ALIROOT_SCRIPT_DIR}/esd-detail.dat ${BLENDER_SCRIPT_DIR}
# pushd ${BLENDER_SCRIPT_DIR}
# blender -noaudio --background -P animate_particles.py -- -radius=0.05 -duration=2 -camera="BarrelCamera" -datafile="esd-detail.dat" -simulated_t=0.02 -fps=5 -resolution=100 -stamp_note="Texto no canto"
# popd
# mkdir --verbose -p ${BLENDER_OUTPUT}
# mv --verbose /tmp/blender ${BLENDER_OUTPUT}
# echo "Done."
fi fi
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