workflow_sketch.sh 18.7 KB
Newer Older
1
2
3
4
5
6
7
8
9
#!/bin/bash

##############################
# Configurations             #
##############################
# Put aliBuild in the PATH env var
export PATH="/mnt/SSD/schnorr/python/bin:$PATH"
# Directory where runAnalysis.C is placed
export ALIROOT_SCRIPT_DIR=$(pwd)/aliRoot/
10
# Directory where Blender scripts are
11
12
export BLENDER_SCRIPT_DIR=$(pwd)/animate/
# alienv working directory
Breno Rilho Lemos's avatar
Breno Rilho Lemos committed
13
14
export ALIENV_WORK_DIR=/home/breno/alice/sw
export ALIENV_OS_SPEC=ubuntu1804_x86-64
15
export ALIENV_ID=AliPhysics/latest-aliroot5-user
16
# Put Blender 2.79b in the PATH env var
17
18
export PATH="/home/schnorr/install/blender-2.79-linux-glibc219-x86_64/:$PATH"

19
20
21
# Progress log file
export PROGRESS_LOG=$(pwd)/progress.log

22
##############################
23
# Command-line options       #
24
##############################
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# See the following link to understand the code below
# https://stackoverflow.com/questions/192249/how-do-i-parse-command-line-arguments-in-bash

# saner programming env: these switches turn some bugs into errors
set -o errexit -o pipefail -o noclobber -o nounset

# -allow a command to fail with !’s side effect on errexit
# -use return value from ${PIPESTATUS[0]}, because ! hosed $?
! getopt --test > /dev/null
if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
    echo 'I’m sorry, `getopt --test` failed in this environment.'
    exit 1
fi

39
OPTIONS=c:hdau:m:n:t:r:
40
LONGOPTS=cameras:,mosaic,resolution:,fps:,transparency:,duration:,maxparticles:,\
41
minparticles:,numberofevents:,minavgpz:,minavgpt:,help,download,sample,url:,its,\
42
tpc,detailedtpc,trd,emcal,blendersave,picpct:
43
44
45
46
47
48
49
50
51
52
53
54
55
56

# -regarding ! and PIPESTATUS see above
# -temporarily store output to be able to check for errors
# -activate quoting/enhanced mode (e.g. by writing out “--options”)
# -pass arguments only via   -- "$@"   to separate them correctly
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
    # e.g. return value is 1
    #  then getopt has complained about wrong arguments to stdout
    exit 2
fi
# read getopt’s output this way to handle the quoting right:
eval set -- "$PARSED"

57
58
59
##############################
# Parse Parameters           #
##############################
60
CAMERAS=Overview
61
MOSAIC=false
62
63
DURATION=10
RESOLUTION=100
64
FPS=24
65
TRANSPARENCY=1
66
67
68
MAX_PARTICLES=1000
MIN_PARTICLES=0
N_OF_EVENTS=10
69
MIN_AVG_PZ=0
70
MIN_AVG_PT=0
71
72
HELP=false
DOWNLOAD=false
73
SAMPLE=false
74
URL=
75
76
ITS=1 # 1 means "build this detector", while 0 means "don't"
TPC=1
77
DETAILED_TPC=0
78
79
TRD=1
EMCAL=1
80
BLENDERSAVE=1
81
PICPCT=80
82
83
84
# now enjoy the options in order and nicely split until we see --
while true; do
    case "$1" in
85
86
87
88
89
      -h|--help)
          HELP=true
          shift
          break
          ;;
90
      -d|--download)
91
92
93
          DOWNLOAD=true
          shift
          ;;
94
      -a|--sample)
95
96
97
          SAMPLE=true
          shift
          ;;
98
99
      -u|--url)
          URL="$2"
100
101
            shift 2
            ;;
102
103
104
105
      -m|--maxparticles)
          MAX_PARTICLES="$2"
          shift 2
          ;;
106
107
108
109
110
111
112
113
      --minparticles)
          MIN_PARTICLES="$2"
          shift 2
          ;;
      -n|--numberofevents)
          N_OF_EVENTS="$2"
          shift 2
          ;;
114
115
116
117
      --minavgpz)
          MIN_AVG_PZ="$2"
          shift 2
          ;;
118
119
120
121
      --minavgpt)
          MIN_AVG_PT="$2"
          shift 2
          ;;
122
123
124
125
126
127
128
129
      -t|--duration)
          DURATION="$2"
          shift 2
          ;;
      -r|--resolution)
          RESOLUTION="$2"
          shift 2
          ;;
130
131
132
133
      --fps)
          FPS="$2"
          shift 2
          ;;
134
135
      --transparency)
          TRANSPARENCY="$2"
136
137
          shift 2
          ;;
138
139
      -c|--cameras)
      	  CAMERAS="$2"
140
141
      	  shift 2
      	  ;;
142
143
144
145
      --mosaic)
          MOSAIC=true
          shift
          ;;
146
147
148
149
      --picpct)
      	  PICPCT="$2"
      	  shift 2
      	  ;;
150
      --its)
151
152
153
          ITS=0
          shift
          ;;
154
      --tpc)
155
156
157
          TPC=0
          shift
          ;;
158
159
160
161
      --detailedtpc)
          DETAILED_TPC=1
          shift
          ;;
162
      --trd)
163
164
165
          TRD=0
          shift
          ;;
166
      --emcal)
167
168
169
          EMCAL=0
          shift
          ;;
170
171
172
173
      --blendersave)
          BLENDERSAVE=1
          shift
          ;;
174
175
176
177
178
        --)
            shift
            break
            ;;
        *)
179
            echo "Programming error $*"
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
            exit 3
            ;;
    esac
done

##############################
# Usage                      #
##############################
function usage()
{
    # Using a here doc with standard out.
    cat <<-END
Usage:
------
   -h | --help
     Display this help
   -d | --download
     Download the AliESDs.root file using the provided URL
   -u | --url URL
     Provide the URL to uniquely identify a AliESDs.root dataset.
     This should be in the format provided by http://opendata.cern.ch.
     See example below.
202
   -m | --maxparticles VALUE
203
204
     Get only events for which its number of particles does not
     exceed VALUE.
205
   --minparticles VALUE
206
207
     Get only events for which its number of particles is greater than
     or equal to VALUE.
208
   -n | --numberofevents VALUE
209
     Set number of events to be animated inside chosen ESD file (defaults to 10)
210
211
   --minavgpz VALUE
     Get only events for which its absolute value of average momentum in
212
213
     the z direction is greater than or equal to VALUE, in GeV/c. Useful
     for animating events with 'boosts' of particles to the same side.
214
215
   --minavgpt VALUE
     Get only events for which its average transversal momentum is
216
217
     greater than or equal to VALUE, in GeV/c. Useful for animating
     events with 'boosts' of particles on the xy plane.
218
219
220
   -t | --duration VALUE
     Set the animation duration in seconds.
   -r | --resolution VALUE
221
222
     Set the animation resolution percentage, where
     VALUE must be an integer from 1 to 100.
223
224
   --fps VALUE
     Set number of frames per second in animation.
225
226
227
   --transparency VALUE
     Set detector transparency as a number greater than zero,
     where zero is full transparency and 1 is standard transparency
228
229
   -c | --cameras VALUE
     Which cameras to use for the animation, where VALUE
Lucas Mello Schnorr's avatar
Lucas Mello Schnorr committed
230
     is a comma-separated list (without spaces)
231
     Options: Barrel,Side,Forward,Overview (defaults to Overview)
232
233
234
235
   --mosaic
     Make animations in all four available cameras and combine them into
     a single 2x2 clip containing all perspectives, totalizing five generated
     .mp4 videos.
236
   --picpct VALUE
237
238
     Percentage of animation to take HD picture, saved along with the clip,
     where VALUE must be an integer
239
   -a | --sample
240
     Creates a sample Blender animation of Event 2 from URL
241
242
     http://opendata.cern.ch/record/1102/files/assets/alice/2010/LHC10h/000139\
038/ESD/0001/AliESDs.root
243
   --its
244
     Removes ITS detector from animation
245
246
   --detailedtpc
     Includes more detailed version of TPC in animation
247
   --tpc
248
     Removes TPC detector from animation
249
   --trd
250
     Removes TRD detector from animation
251
   --emcal
252
     Removes EMCal detector from animation
253
254
   --blendersave
     Saves Blender file along with animation clip
255
256
257

Example:
--------
258
259
$0 --url http://opendata.cern.ch/record/1103/files/assets/alice/2010/LHC10h/000\
139173/ESD/0004/AliESDs.root --download
260
261
262

END
}
263

Lucas Mello Schnorr's avatar
Lucas Mello Schnorr committed
264
# Fix CAMERA to be accepted by the for loop
265
266
if [[ $CAMERAS != "" ]]; then
    CAMERAS=$(echo $CAMERAS | sed -e 's#,#Camera #g' -e 's#$#Camera#')
Lucas Mello Schnorr's avatar
Lucas Mello Schnorr committed
267
268
fi

269
if [[ $MOSAIC == "true" ]]; then
270
    CAMERAS=$(echo "OverviewCamera BarrelCamera SideCamera ForwardCamera")
271
272
fi

273
274
275
276
277
278
279
if [[ $HELP = "true" ]]; then
    usage
    exit
else
    echo "-------- Parsed parameters --------"
    echo "URL: $URL"
    echo "Download: $DOWNLOAD"
280
    echo "Sample: $SAMPLE"
281
    echo "Transparency Parameter: $TRANSPARENCY"
282
283
    echo "Duration: $DURATION"
    echo "Resolution: $RESOLUTION"
284
    echo "FPS: $FPS"
285
    echo "Max particles: ${MAX_PARTICLES}"
286
287
    echo "Min particles: ${MIN_PARTICLES}"
    echo "Number of events: ${N_OF_EVENTS}"
288
    echo "Min Average Z Momentum: ${MIN_AVG_PZ}"
289
    echo "Min Average Transversal Momentum: ${MIN_AVG_PT}"
290
    echo "Cameras: $CAMERAS"
291
    echo "Mosaic: $MOSAIC"
292
    echo "Picture Percentage: ${PICPCT}%"
293
    echo "-----------------------------------"
294
295
296
297
    echo "------------ Detectors ------------"
    if [[ $ITS = 1 ]]; then
      echo "Building ITS"
    fi
298
299
300
301
302
303
    if [[ $DETAILED_TPC = 1 ]]; then
      echo "Building detailed TPC"
    else
      if [[ $TPC = 1 ]]; then
        echo "Building TPC"
      fi
304
305
306
307
308
309
310
311
312
313
314
315
    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 "-----------------------------------"

316
317
fi

318
319
320
321
322
# Get number of frames
FPS_DUR="$FPS $DURATION"
FPS_DUR=$(echo $FPS_DUR | awk '{print $1*$2}')


323
324
325
326
327
328
329
# handle non-option arguments
if [[ $# -ne 0 ]]; then
    echo "$0: non-option arguments ($#, $*) are ignored."
    echo "Remove them manually as indicated between parenthesis."
    exit
fi

330

331
332
333
334
##############################
# Download Dataset           #
##############################
if [ "$DOWNLOAD" = "true" ]; then
335
    if [ -z $URL ]; then
336
        echo "Error. Must pass the dataset URL in order to download ESD file."
337
338
339
        usage
        exit
    fi
340
341
342
343
344
345

    if ! grep -q "DOWNLOAD NOT DONE" $PROGRESS_LOG; then
      echo "Downloading data."
      wget $URL
      echo "ESD DOWNLOAD DONE" >> $PROGRESS_LOG
    fi
346

347
348
349
350
351
352
353
354
355
356
357
358
    ######################################
    # Established Unique ID based on URL #
    ######################################
    UNIQUEID=$(echo $URL | sed \
                         -e "s#http://opendata.cern.ch/##" \
                         -e "s#/AliESDs.root##" \
                         -e "s#files/assets/##" \
                         -e "s#/#_#g")

    echo "The unique ID is $UNIQUEID."

fi
359

360
##############################
361
# Sample synthetic animation#
362
##############################
363
if [ "$SAMPLE" = "true" ]; then
364
    ##############################
365
    # Phase 1: Blender animate   #
366
    ##############################
367
368
369
    BLENDER_OUTPUT=$(pwd)/sample
    mkdir --verbose -p ${BLENDER_OUTPUT}

370
    pushd ${BLENDER_SCRIPT_DIR}
371
372
373
374
    echo "Preparing sample animation in Blender"

    blender -noaudio --background -P animate_particles.py -- -radius=0.05 \
    -duration=${DURATION} -cameras="${CAMERAS}" -datafile="d-esd-detail.dat" -simulated_t=0.03\
375
376
    -fps=${FPS} -resolution=${RESOLUTION} -transparency=${TRANSPARENCY} \
    -stamp_note="opendata.cern.ch_record_1102_alice_2010_LHC10h_000139038_ESD_0001_2" -its=${ITS}\
377
    -tpc=${TPC} -trd=${TRD} -emcal=${EMCAL} -detailed_tpc=${DETAILED_TPC} \
378
379
    -blendersave=${BLENDERSAVE} -picpct=${PICPCT} -tpc_blender_path=${BLENDER_SCRIPT_DIR} \
    -output_path="${BLENDER_OUTPUT}"
380

381
382
383
    popd
    echo "Done."

384
385
386
##############################
# Animation from file        #
##############################
387
elif [ "$SAMPLE" = "false" ]; then
388

389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
  if ! grep -q "DATA ANALYSIS for" $PROGRESS_LOG; then

    # Verify if AliESDs.root is here
    ALIESD_ROOT_FILE=$(pwd)/AliESDs.root
    if ! [[ -f "$ALIESD_ROOT_FILE" ]]
    then
        echo "AliESDs.root not found."
        exit
    fi

    ############################
    # Phase 1: aliroot extract #
    ############################
    eval $(alienv -w ${ALIENV_WORK_DIR} -a ${ALIENV_OS_SPEC} load ${ALIENV_ID})
    pushd ${ALIROOT_SCRIPT_DIR}
    # Remove existing symbolic link
    rm -f --verbose AliESDs.root
    # Create a symbolic link to the actual AliESDs.root
    ln --verbose -s ${ALIESD_ROOT_FILE} AliESDs.root
    # Run the extraction tool
    aliroot runAnalysis.C

    if [ "$DOWNLOAD" = "false" ]; then

      UNIQUEID=$(more uniqueid.txt)
      echo "The unique ID is $UNIQUEID."

    fi

    popd
    echo "DATA ANALYSIS for ${UNIQUEID} FINISHED" >> $PROGRESS_LOG

  else
    if [ "$DOWNLOAD" = "false" ]; then

      pushd ${ALIROOT_SCRIPT_DIR}
      UNIQUEID=$(more uniqueid.txt)
      echo "The unique ID is $UNIQUEID."
      popd

    fi
430
431
  fi

432
433
434
435
436
  if ! grep -q "ANIMATION DIRECTORY" $PROGRESS_LOG ; then

    # Create directory where animations will be saved
    BLENDER_OUTPUT=$(pwd)/$UNIQUEID
    mkdir --verbose -p ${BLENDER_OUTPUT}
437

438
439
440
    echo "ANIMATION DIRECTORY ${UNIQUEID} CREATED" >> $PROGRESS_LOG
  else
    BLENDER_OUTPUT=$(pwd)/$UNIQUEID
441
442
443
444
  fi

  pushd ${ALIROOT_SCRIPT_DIR} # push back to aliroot directory

445
446
447
448
  if ! grep -q "MOVED to animation directory" $PROGRESS_LOG; then
    #################################################
    # Phase 1: iteration for every event identifier #
    #################################################
449

450
451
    # Get all extracted files
    EXTRACTED_FILES=$(ls -1 esd_detail-event_*.dat | sort --version-sort)
452

453
    for FILE_WITH_DATA in $EXTRACTED_FILES; do
454

455
456
457
458
459
        if ! [[ -s $FILE_WITH_DATA ]]; then
            echo "File $FILE_WITH_DATA has zero size. Ignore and continue."
  	        rm $FILE_WITH_DATA
            continue
        fi
460

461
462
        mv ${ALIROOT_SCRIPT_DIR}/$FILE_WITH_DATA \
         ${BLENDER_SCRIPT_DIR}
463

464
    done
465

466
    echo "DATA ANALYSIS FILES of ${UNIQUEID} MOVED to animation directory" >> $PROGRESS_LOG
467

468
  fi
469

470
471
  popd
  pushd ${BLENDER_SCRIPT_DIR}
472

473
  if ! grep -q "CREATED EVENT COUNTER FILE" $PROGRESS_LOG; then
474

475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
    # Event counter for animating no more events than the informed amount
    EVENT_COUNTER=0
    echo "$EVENT_COUNTER" > event_counter.txt
    echo "CREATED EVENT COUNTER FILE" >> $PROGRESS_LOG

  fi

  if ! grep -q "DATA FILES RENAMED according to UNIQUEID" $PROGRESS_LOG; then

    EXTRACTED_FILES=$(ls -1 esd_detail-event_*.dat | sort --version-sort)

    for FILE_WITH_DATA in $EXTRACTED_FILES; do

        EVENT_ID=$(echo $FILE_WITH_DATA | \
                   sed -e "s#esd_detail-event_##" \
                     -e "s#\.dat##")
        EVENT_UNIQUE_ID=${UNIQUEID}_${EVENT_ID}

        LOCAL_FILE_WITH_DATA=${EVENT_UNIQUE_ID}.dat

        mv $FILE_WITH_DATA $LOCAL_FILE_WITH_DATA

    done
498

499
    echo "DATA FILES RENAMED according to UNIQUEID ${UNIQUEID}" >> $PROGRESS_LOG
500

501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
  fi

  EXTRACTED_FILES=$(ls -1 ${UNIQUEID}_*.dat | sort --version-sort)

  for LOCAL_FILE_WITH_DATA in $EXTRACTED_FILES; do

    pushd ${BLENDER_SCRIPT_DIR}

    EVENT_ID=$(echo $LOCAL_FILE_WITH_DATA | \
               sed -e "s#${UNIQUEID}_##" \
                 -e "s#\.dat##")
    EVENT_UNIQUE_ID=${UNIQUEID}_${EVENT_ID}

    ##############################
    # Phase 2: blender animate   #
    ##############################

    NUMBER_OF_PARTICLES=$(wc -l $LOCAL_FILE_WITH_DATA | \
                      awk '{ print $1 }')

    AVERAGE_PZ=$(awk 'BEGIN {pzsum=0;n=0} {pzsum+=$8;n++} END {print sqrt(pzsum*pzsum/n/n)}'\
    ${LOCAL_FILE_WITH_DATA})

    AVERAGE_PT=$(awk 'BEGIN {ptsum=0;n=0} {ptsum+=$9;n++} END {print ptsum/n}' \
    ${LOCAL_FILE_WITH_DATA})

    echo "File $LOCAL_FILE_WITH_DATA has $NUMBER_OF_PARTICLES particles."
    echo "Average Z momentum: $AVERAGE_PZ"
    echo "Average transversal momentum $AVERAGE_PT"

    EVENT_COUNTER=$(more event_counter.txt)

    if (( $(echo "$AVERAGE_PT >= $MIN_AVG_PT" |bc -l) )); then
      if (( $(echo "$AVERAGE_PZ >= $MIN_AVG_PZ" |bc -l) )); then
        if [[ $NUMBER_OF_PARTICLES -le $MAX_PARTICLES && $NUMBER_OF_PARTICLES \
-ge $MIN_PARTICLES && $EVENT_COUNTER -lt $N_OF_EVENTS ]]; then

          if ! grep -q "Scene from ${EVENT_UNIQUE_ID} READY." $PROGRESS_LOG; then

            echo "Processing ${EVENT_UNIQUE_ID} ($NUMBER_OF_PARTICLES tracks) in Blender"
541
542
543
544
545
546
547
548

            echo "Processing ${EVENT_UNIQUE_ID} in Blender"

            blender -noaudio --background -P animate_particles.py -- -radius=0.05 \
            -duration=${DURATION} -cameras="${CAMERAS}" -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} -detailed_tpc=${DETAILED_TPC} \
549
550
551
            -blendersave=${BLENDERSAVE} -picpct=${PICPCT} -tpc_blender_path=${BLENDER_SCRIPT_DIR}\
            -output_path="${BLENDER_OUTPUT}"
            echo "Scene from ${EVENT_UNIQUE_ID} READY." >> $PROGRESS_LOG
552

553
          fi
554

555

556
          for type in $CAMERAS; do
557

558
559
560
561
562
563
564
565
566
567
568
569
570
            if ! grep -q "${type} for $EVENT_UNIQUE_ID FINISHED" $PROGRESS_LOG; then
              blender -noaudio --background -P render.py -- -cam ${type} -datafile\
               "${LOCAL_FILE_WITH_DATA}" -n_event ${EVENT_ID} -pic_pct ${PICPCT} -output_path "${BLENDER_OUTPUT}"

              echo "${type} for $EVENT_UNIQUE_ID FINISHED" >> $PROGRESS_LOG
            fi

          done

          if [ "$MOSAIC" = "true" ]; then

            if ! grep -q "MOSAIC for $EVENT_UNIQUE_ID FINISHED" $PROGRESS_LOG; then
              pushd ${BLENDER_OUTPUT}
571
572

              # Setting input names for clips in order to make mosaic clip
573
574
575
576
              INPUT_ONE=$(ls *$EVENT_UNIQUE_ID*${FPS_DUR}.mp4 | awk 'NR==1')
              INPUT_TWO=$(ls *$EVENT_UNIQUE_ID*${FPS_DUR}.mp4 | awk 'NR==2')
              INPUT_THREE=$(ls *$EVENT_UNIQUE_ID*${FPS_DUR}.mp4 | awk 'NR==3')
              INPUT_FOUR=$(ls *$EVENT_UNIQUE_ID*${FPS_DUR}.mp4 | awk 'NR==4')
577

578
579
580
              ffmpeg -i ${INPUT_FOUR} -i ${INPUT_TWO} -i ${INPUT_THREE} -i ${INPUT_ONE} -filter_complex\
               "[0:v][1:v]hstack=inputs=2[top];[2:v][3:v]hstack=inputs=2[bottom];[top][bottom]vstack=inputs=2[v]"\
               -map "[v]" ${EVENT_UNIQUE_ID}_Mosaic.mp4
581

582
              echo "MOSAIC for $EVENT_UNIQUE_ID FINISHED" >> $PROGRESS_LOG
583

584
              popd
585
586
            fi

587
          fi
588

589
          if ! grep -q "TEXT DATA of $EVENT_UNIQUE_ID MOVED to final location" $PROGRESS_LOG; then
590
591
            # Move processed file to final location
            mv $LOCAL_FILE_WITH_DATA ${BLENDER_OUTPUT}/$LOCAL_FILE_WITH_DATA
592
593
            echo "TEXT DATA of $EVENT_UNIQUE_ID MOVED to final location" >> $PROGRESS_LOG
          fi
594

595
          echo "EVENT ${EVENT_UNIQUE_ID} DONE with FILE $LOCAL_FILE_WITH_DATA."
596

597
598
599
600
          # Increment event counter
          EVENT_COUNTER=$EVENT_COUNTER+1
          rm event_counter.txt
          echo "$EVENT_COUNTER" > event_counter.txt
601

602
        else
603

604
605
606
607
608
609
          if [[ $NUMBER_OF_PARTICLES -lt $MIN_PARTICLES ]]; then
            echo "Too little particles (minimum accepted is $MIN_PARTICLES). Continue."
          elif [[ $NUMBER_OF_PARTICLES -gt $MAX_PARTICLES ]]; then
            echo "Too many particles (maximum accepted is $MAX_PARTICLES). Continue."
          elif [[ $EVENT_COUNTER -ge $N_OF_EVENTS ]]; then
            echo "Numbers of events set to be animated has already been reached. Continue."
610
          fi
611

612
613
          # Remove non-processed files
          rm $LOCAL_FILE_WITH_DATA
614

615
616
        fi
      else
617
        echo "Average Z Momentum too low (minimum accepted is $MIN_AVG_PZ). Continue."
618
619
620

        # Remove non-processed files
        rm $LOCAL_FILE_WITH_DATA
621
      fi
622
623
624
625
626
627
628
629
630
    else
      echo "Average Transversal Momentum too low (minimum accepted is $MIN_AVG_PT). Continue."

      # Remove non-processed files
      rm $LOCAL_FILE_WITH_DATA
    fi

    popd

Lucas Mello Schnorr's avatar
Lucas Mello Schnorr committed
631
  done
632

633

634
fi