diff --git a/analysis/deprecated/do_analysis_halley.sh b/analysis/deprecated/do_analysis_halley.sh new file mode 100755 index 0000000000000000000000000000000000000000..889ef051cd753af9da8b55cc88b2238a7ba3148b --- /dev/null +++ b/analysis/deprecated/do_analysis_halley.sh @@ -0,0 +1,248 @@ +# /************************************************************************/ +# /* Package: ARTI */ +# /* Module: do_analysis-halley.sh */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: hernan.asoreyh@iteda.cnea.gov.ar */ +# /************************************************************************/ +# /* Comments: Analysis of showers files optimized for the Halley cluster */ +# /************************************************************************/ +# /* +# LICENSE BSD-3-Clause +# Copyright (c) 2015 +# The LAGO Collaboration +# https://lagoproject.net +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r9"; + +showhelp() { + echo + echo -e "$0 version $VERSION" + echo + echo -e "USAGE $0:" + echo + echo -e " -b <project base name> : Project base name (suggested format: aaa)" + echo -e " -p <project name> : Project name, typically aaann" + echo -e " -t : Only transfer files and perform checks" + echo -e " -d : Transfer all the files to final directory" + echo -e " and delete the original ones." + echo -e " -? : Shows this help and exit." + echo + echo -e "The scrip will create the working directory at:" + echo -e " /home/hN/aaa/flux-aaann/" + echo -e "where hN is the node you are working on, and where all the files " + echo -e "will be placed and the analysis will be performed." + echo -e " Suggested way is first use option -t, perform all the checks, " + echo -e "and when you are sure everything is fine, re-run but using " + echo -e "option -d instead of -t" + echo +} + +bsn=""; +prj=""; +ana=true; +era=false; + +echo + +while getopts ':b:p:td?' opt; do + case $opt in + b) + bsn=$OPTARG + echo -e "# Project base name = $bsn" + ;; + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + ana=false; + echo -e "# Perform data analysis? = $ana" + ;; + d) + era=true; + echo -e "# Erase original files? = $era" + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X${bsn}" == "X" ]; then + echo; echo -e "# ERROR: You have to provide a project base name (suggested format: nnn)" + showhelp + exit 1; +fi + +if [ "X${prj}" == "X" ]; then + echo; echo -e "# ERROR: You have to provide a project name (typically format: nnnxx)" + showhelp + exit 1; +fi + +# asuming you will work where you are +h=$(hostname | awk '{if ($1=="frontend") {print 0} else {print $0}}' | sed -e 's/halley0//') +# and them the final directory will be: +home=/home/h${h}/${bsn}/flux-${prj} + +echo; echo -e "# STATUS"; echo +echo -e "# STATUS: Working node: halley0${h}" +echo -e "# STATUS: Project base name: ${bsn}" +echo -e "# STATUS: Project name: ${prj}" +echo -e "# STATUS: Work directory: ${home}" +echo -e "# STATUS: Perform data analysis?: ${ana}" +echo -e "# STATUS: Delete original files?: ${era}" +if ${era}; then +echo; echo -e "# WARNING: Delete files enabled. It can not be undone!" +fi +echo; echo -e "# READY: Press enter to continue, <ctrl-c> to abort!" +read + +mkdir ${home} + +# transfering files +for i in $(seq 0 5); do + if ${era}; then + rsync -aPv h${i}:/home/h${i}/${bsn}/${prj}/* ${home} + rsync -aPv h${i}:/home/h${i}/${bsn}/go-${prj}*run ${home} + else + rsync -aPv h${i}:/home/h${i}/${bsn}/${prj}/DAT??????.bz2 ${home} + rsync -aPv h${i}:/home/h${i}/${bsn}/${prj}/*.lst* ${home} + fi +done + +echo -n "# Test 1:" +tst=$(ls -1 ${home}/DAT??????.bz2 | wc -l) +if [ "X${tst}" != "X60" ]; then + ls -1 ${home}/DAT??????.bz2 | wc -l + echo " FAILED." + echo "# ERROR: There are not $tst/60 output files" + echo "# ERROR: Please check" + exit 1 +fi +echo -e " PASS: There are 60 output files" + +# Test if all the processes ended correctly +echo -n "# Test 2" +tst=$(bzcat ${home}/*.lst.bz2 | tail -q -n 1 | grep -v "END OF RUN") +if [ "X${tst}" != "X" ]; then + echo " FAILED." + echo "# ERROR: Some processes failed:" + bzcat ${home}/*.lst.bz2 | tail -n 1 | grep -v "END OF RUN" + echo "# ERROR: Please check" + exit 1 +fi +echo -e " PASS: all processes ended normally" + +if ${era}; then + echo; echo -e "# READY: I will delete all the original files. Press enter to continue, <ctrl-c> to abort!" + read + for i in $(seq 0 5); do + ssh h${i} rm -r /home/h${i}/${bsn}/${prj}/ + ssh h${i} rm -r /home/h${i}/${bsn}/go-${prj}*run + done +fi + +if $ana; then + echo -e "# READY: Files transferred." +else + echo -e "# DONE: Files transferred." + exit 0 +fi + +echo; echo -e "# READY: All test passed. Press enter to continue, <ctrl-c> to abort!" +read + +#similar flux separation, using 3 branchs +cd ${home} +mkdir ${home}/f1 +mkdir ${home}/f2 +mkdir ${home}/f3 +mkdir ${home}/secs + +for i in 001206 001608 000703 002412 001105 002814 001407 002010 005626 000904 003216 002713 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521; do + mv -v DAT${i}.bz2 ${home}/f1 +done + +for j in $(seq 1 4); do + printf -v n %02d $j + i=0${j}0402 + mv -v DAT${i}.bz2 ${home}/f1 +done + +for j in $(seq 1 8); do + printf -v n %02d $j + i=${n}0014 + mv -v DAT${i}.bz2 ${home}/f1 +done + +for j in $(seq 9 20); do + printf -v n %02d $j + i=${n}0014 + mv -v DAT${i}.bz2 ${home}/f2 +done + +for j in $(seq 21 32); do + printf -v n %02d $j + i=${n}0014 + mv -v DAT${i}.bz2 ${home}/f3 +done + +# analisys +for k in $(seq 1 3); do + file=f${k} + echo "cd ${home}/f${k} +for i in DAT??????.bz2; do + j=\$(echo \$i | sed -e 's/.bz2//') + u=\$(echo \$j | sed -e 's/DAT//'); + bzip2 -v -d -k \$i + echo \$j | lagocrkread | analysis -v \$u + rm \$j +done +cd ${home}/ +mv -v ${home}/f${k}/DAT*.bz2 ${home}/ +mv -v ${home}/f${k}/*.sec.bz2 ${home}/secs/ +rmdir f${k} +rm f${k}.sh +" > f${k}.sh + chmod 744 f${k}.sh + screen -d -m -a -S flux-${k} ${home}/f${k}.sh + screen -ls +done diff --git a/eas/deprecated/check_sims_halley.sh b/eas/deprecated/check_sims_halley.sh new file mode 100755 index 0000000000000000000000000000000000000000..fe3633c96e31e70807e6ad8ead5cc7ebe8f5e048 --- /dev/null +++ b/eas/deprecated/check_sims_halley.sh @@ -0,0 +1,100 @@ +#!/bin/bash + +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: check_sims_halley.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: This module analyze corsika status in non-clusterized */ +# /* halley array of nodes */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +VERSION="v1r0"; +proc=$1 +all=false +crk=false +if [ "X$proc" == "Xall" ]; then + all=true +fi +if ! $all; then + if [ "X$proc" == "X" ]; then + proc="corsika" + crk=true + fi +fi + +st=0 +en=5 +tot=0 +nodes='0 1 2 3 4 5' + +if $all; then + for i in $nodes; do + echo; echo "halley0$i: "; echo + ssh h${i} ps -af | grep -v "grep" | grep -v "ps" | grep -v "arti" | grep -v "bash" + done +else + if $crk; then + for i in $nodes; do + echo -n "halley0$i: " + ssh h${i} ps -af | grep "${proc}" | grep -v "grep" | grep -v "arti" > tmp + loc=$(cat tmp | wc -l) + echo "$loc sessions running" + cat tmp + tot=$[ $tot + $loc ] + echo + done + echo "TOTAL: $tot sessions running" + rm tmp + else + for i in $nodes; do + echo "halley0$i: " + echo + ssh h${i} ls /home/h${i}/${proc}/run* | awk 'BEGIN{FS="/"}{print $5}' | awk 'BEGIN{FS="-"}{print $2, $3}' | tee -a sessions + echo + done + echo -n "Total for project ${proc}: " + wc -l sessions + rm sessions + fi +fi diff --git a/eas/deprecated/do_grid.sh b/eas/deprecated/do_grid.sh new file mode 100755 index 0000000000000000000000000000000000000000..718303156c7a7a8fdae1897364985a1123e92bcd --- /dev/null +++ b/eas/deprecated/do_grid.sh @@ -0,0 +1,283 @@ +#!/bin/bash +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: do_grid.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: Main script to automatize secondary flux calculations and */ +# /* run simulations in LAGO-GRID */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r0"; + +showhelp() { + echo + echo -e "$0 $VERSION" + echo + echo -e "USAGE $0:" + echo + echo -e " -p <project name> : Project name (suggested format: NAMEXX)" + echo -e " -t <flux time> : Flux time (in seconds) for simulations" + echo -e " -v <CORSIKA version> : CORSIKA version" + echo -e " -h <HE Int Model (EPOS|QGSII)> : Define the high interaction model to be used" + echo -e " -u <user name> : User Name." + echo -e " -s <site> : Location (several options)" + echo -e " -y : Select volumetric detector mode (default=flat array)" + echo -e " -d : Enable DEBUG mode" + echo -e " -a : Enable high energy cuts for secondaries" + echo -e " -k <altitude, in cm> : Fix altitude, even for predefined sites" + echo -e " -? : Shows this help and exit." + echo +} +debug=false; +highsec=false; +sites=false; +usr="LAGO"; +vol=false; +alt=false; +altitude=0.; + +echo +wdir="${HOME}/grid" + +while getopts ':k:p:t:v:u:h:s:?ayd' opt; do + case $opt in + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + tim=$OPTARG + echo -e "# Flux time = $tim" + ;; + v) + ver="$OPTARG" + echo -e "# CORSIKA version = $ver" + ;; + u) + usr="$OPTARG" + echo -e "# User name = $usr" + ;; + k) + alt=true + altitude=$OPTARG + echo -e "# Altitude = $altitude" + ;; + h) + hig=$OPTARG + echo -e "# High Energy Interaction Model = $hig" + ;; + s) + site=$OPTARG + sites=true + echo -e "# Site location = $site" + ;; + y) + vol=true + echo -e "# Volumetric detector mode for = $site" + ;; + a) + highsec=true + ;; + d) + debug=true + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +#helium -> Usually for 1 hour flux, 4 different procces is enough +prcHe=4 + +#protons -> we need at least 32 times helium, so multPr=8 +multPr=8 +prcPr=$[${prcHe}*${multPr}] # now prcPr=32 + +# Should be divisor of 60, since we are running 60 process: 32(protons)+4(helium)+24(single nuclei)=60 +procs=4 +shows=60 +max=$[$shows/$procs] +shows=$[$shows-1] + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X$prj" == "X" ]; then + echo; echo -e "ERROR: You have to provide a project name (suggested format: NAMEXX, where XX is a number between 0 and 99)" + showhelp + exit 1; +fi + +if [ "X$tim" == "X" ]; then + tim=3600 + echo -e "# WARNING: Time was not provided. Using default time: $tim s" +fi + +if [ "X$ver" == "X" ]; then + ver="75600" + echo -e "# WARNING: CORSIKA version was not provided. Using default: $ver" +fi + +if [ "X$hig" == "X" ]; then + hig="QGSII" + echo -e "# WARNING: High energy interaction model was not provided. Using default: $hig" +fi + +if $debug; then + echo -e "# WARNING: You are running in DEBUG mode." +fi + +if $highsec; then + echo -e "# WARNING: High energy cuts for secondaries will be used." +fi + +echo; echo -e "# WARNING: I will create the directory $wdir/$prj where the grid files will be created."; echo + +#codename=$(echo $wdir | sed -e 's/\/home\/h0\///' | sed -e 's/\///') +#home=$wdir +#direct=$home/$prj +basecrktools=${PWD} +if ! [ -f $basecrktools/spectra.dat ]; then + echo + echo -e "# ERROR: spectr.dat not found." + echo -e "# ERROR: You should run this script from the sims base directory." + showhelp + exit 1 +fi +############## +options="-w ${wdir} -t ${tim} -p ${prj} " +if $sites; then + options=${options}"-s ${site} " +fi +options=${options}"-u ${usr} " +if $highsec; then + options=${options}"-a " +fi +if $vol; then + options=${options}"-y " +fi +if $alt; then + options=${options}"-k $altitude " +fi +options=${options}"-f $basecrktools/spectra.dat" +$basecrktools/generate_spectra.pl ${options} +############## + +a=$(echo $prj) +#all + +rain="./rain.pl" +rain="$rain -i" # enable halley mode (not use PLOTSH and COMOUT) +rain="$rain -g" # enable grid mode + +if $sites; then + rain="$rain -s ${site}" +fi +if $debug; then + rain="$rain -d" +fi +if $highsec; then + rain="$rain -a" +fi +rain="$rain -r $wdir -v $ver -h $hig" +clear + +t=0 +for i in 001206 001608 000703 002412 001105 002814 001407 002010 005626 000904 003216 002713 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521; do + t=$[t+1]; + echo "# STATUS: Please wait, I'm processing input for DAT$i ($t/60)." + $rain -b $wdir/$prj/$i-*.run +done + +#helium +b=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $wdir/$prj/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run +done +rm $wdir/$prj/000402-*.run + +for j in $(seq 1 $prcHe); do + t=$[t+1] + i="0${j}0402" + echo "# STATUS: Please wait, I'm processing input for DAT$i ($t/60)." + $rain -b $wdir/$prj/$i-*.run +done + +b=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +for i in $(seq 1 $prcPr); do + printf -v n "%02d" $i + u=${n}'0014' + cat $wdir/$prj/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run +done +rm $wdir/$prj/000014-*.run + +for j in $(seq 1 $prcPr); do + t=$[t+1]; + printf -v n "%02d" $j + i=${n}'0014' + echo "# STATUS: Please wait, I'm processing input for DAT$i ($t/60)." + $rain -b $wdir/$prj/$i-*.run +done + +echo "# STATUS: Done, $t/60 input processed. Compresing..." +mkdir ${basecrktools}/$prj +cp -v $wdir/$prj/DAT*input $prj/ +tar cfvz $wdir/$prj/$prj-$tim-$usr.tar.gz $prj/* +rm -r ${basecrktools}/$prj +echo -e "# STATUS: Done. Now upload the compressed file" +echo -e "# STATUS: $wdir/$prj/$prj-$tim-$usr.tar.gz at" +echo -e "# STATUS: https://science-gateway.chain-project.eu/run-corsika" diff --git a/eas/deprecated/do_iafe.sh b/eas/deprecated/do_iafe.sh new file mode 100755 index 0000000000000000000000000000000000000000..41fd9fa1446e8b520b076baf22b5b0a06ada1fd6 --- /dev/null +++ b/eas/deprecated/do_iafe.sh @@ -0,0 +1,456 @@ +#!/bin/bash +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: do_ iafe.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernan Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: Main script to automatize secondary flux calculations and */ +# /* run simulations in Soleil IAFE cluster */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v3r0"; # Tue Aug 6 15:43:52 COT 2013 + +# In this new version, rain.pl includes ctarain mode (-z) ctarain usage is now deprecated + +# v3r0: Wed Oct 9 15:14:14 COT 2013 +# changes in genEspectra.pl and showers.cc. Including geomagnetic effects +# v2r3; # Fri Jun 14 09:45:11 COT 2013 +# This is the first version of do_halley.sh, added as part of v2r3 CrkTools release +# Implied modifications on genEspectra.pl, rain.pl and ctarain.pl + +# v2r2 Fri Jun 14 09:45:11 COT 2013 +# do_halley added +# in this version all stuff is separated in two different scripts + +# v2r2 (Fri May 10 09:39:30 COT 2013) +# Major release of full crktools package +# -y option added for volumetric of flat detector flux calculations in genEspectra.pl +# v2r1 (Tue Apr 16 17:17:12 COT 2013) +# OAR server usage improved. Run up to $procs (4, should be divisor of 60) simultaneously in +# a single OAR node. Produces a script that produces 15 scrips to run 15*4=60 showers. + +# v2r0 +# OAR server compatibilities, and other new features. See showhelp() + +# lot's of new features + +showhelp() { + echo + echo -e "$0 version $VERSION" + echo + echo -e "USAGE $0:" + echo + echo -e " -w <working dir> : Working directory, where bin files are located" + echo -e " -p <project name> : Project name (suggested format: NAMEXX)" + echo -e " -t <flux time> : Flux time (in seconds) for simulations" + echo -e " -v <CORSIKA version> : CORSIKA version" + echo -e " -h <HE Int Model (EPOS|QGSII)> : Define the high interaction model to be used" + echo -e " -u <user name> : User Name." + echo -e " -s <site> : Location (several options)" + echo -e " -y : Select volumetric detector mode (default=flat array)" + echo -e " -e : Enable CHERENKOV mode" + echo -e " -d : Enable DEBUG mode" + echo -e " -a : Enable high energy cuts for secondaries" + echo -e " -k <altitude, in cm> : Fix altitude, even for predefined sites" + echo -e " -l <cluster user name> : Enable OAR cluster compatibility, use \$USER" + echo -e " -? : Shows this help and exit." + echo +} +cta=false +debug=false +highsec=false +cluster=false +sites=false +usr="HgAsorey"; +vol=false +alt=false +altitude=0. + +echo + +while getopts ':w:k:p:t:v:u:h:s:l:?ayde' opt; do + case $opt in + w) + wdir=$OPTARG + echo -e "# Working dir = $wdir" + ;; + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + tim=$OPTARG + echo -e "# Flux time = $tim" + ;; + v) + ver="$OPTARG" + echo -e "# CORSIKA version = $ver" + ;; + u) + usr="$OPTARG" + echo -e "# User name = $usr" + ;; + k) + alt=true + altitude=$OPTARG + echo -e "# Altitude = $altitude" + ;; + h) + hig=$OPTARG + echo -e "# High Energy Interaction Model = $hig" + ;; + s) + site=$OPTARG + sites=true + echo -e "# Site location = $site" + ;; + e) + cta=true + echo -e "# Cherenkov mode enabled for = $site" + ;; + y) + vol=true + echo -e "# Volumetric detector mode for = $site" + ;; + l) + clsname=$OPTARG + cluster=true + echo -e "# Cluster mode enable for user = $clsname" + ;; + a) + highsec=true + ;; + d) + debug=true + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +#helium -> Usually for 1 hour flux, 4 different procces is enough +prcHe=4 + +#protons -> we need at least 32 times helium, so multPr=8 +multPr=8 +prcPr=$[${prcHe}*${multPr}] # now prcPr=32 + +# cores per node in OAR cluster +# Should be divisor of 60, since we are running 60 process: 32(protons)+4(helium)+24(single nuclei)=60 +procs=4 +shows=60 +max=$[$shows/$procs] +shows=$[$shows-1] + + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X$prj" == "X" ]; then + echo; echo -e "ERROR: You have to provide a project name (suggested format: NAMEXX, where XX is a number between 0 and 99)" + showhelp + exit 1; +fi + +if [ "X$wdir" == "X" ]; then + echo; echo -e "ERROR: You have to set the working directory (where corsika bin files are located)" + showhelp + exit 1; +fi + +if [ "X$tim" == "X" ]; then + tim=3600; + echo -e "# WARNING: Time was not provided. Using default time: $tim s" +fi + + +if [ "X$ver" == "X" ]; then + ver="75600" + echo -e "# WARNING: CORSIKA version was not provided. Using default: $ver" +fi + +if [ "X$hig" == "X" ]; then + hig="QGSII" + echo -e "# WARNING: High energy interaction model was not provided. Using default: $hig" +fi + +if $debug; then + echo -e "# WARNING: You are running in DEBUG mode." +fi + +if $cta; then + if $sites; then + echo -e "# WARNING: Cherenkov mode is enabled." + else + echo; echo -e "ERROR: You have to provide a site location in CHERENKOV mode" + showhelp + exit 1; + fi +fi + +if $cluster; then + echo -e "# ERROR: Please use do_sims for OAR CLUSTER mode." + exit +fi + +if $highsec; then + echo -e "# WARNING: High energy cuts for secondaries will be used." +fi + +#codename=$(echo $wdir | sed -e 's/\/home\/h0\///' | sed -e 's/\///') +codename=$(echo $wdir | sed -e 's/\/home\/sdasso\/corsika\/pruebas_sep2016\/run_master\///' | sed -e 's/\///') + +home=$wdir +direct=$home/$prj +basecrktools=${HOME}/arti/sims/ + +############## +options="-w ${wdir} -t ${tim} -p ${prj} " +if $sites; then + options=${options}"-s ${site} " +fi +options=${options}"-u ${usr} " +if $highsec; then + options=${options}"-a " +fi +if $vol; then + options=${options}"-y " +fi +if $alt; then + options=${options}"-k $altitude " +fi + +options=${options}"-f $basecrktools/spectra.dat" + +$basecrktools/generate_spectra.pl ${options} + +############## + +a=$(echo $prj) + +#all + +st=0 +en=5 + +if $cta; then + #for i in $(seq $st $en); do + #u=$(echo $wdir | sed -e "s/h0/h${i}/") + u=$(echo $wdir) + #scp $basecrktools/rain.pl h${i}:$u/ + cp $basecrktools/rain.pl $u/ + rain="./rain.pl -z" + #done +else + #for i in $(seq $st $en); do + # u=$(echo $wdir | sed -e "s/h0/h${i}/") + # scp $basecrktools/rain.pl h${i}:$u/ + u=$(echo $wdir) + cp $basecrktools/rain.pl $u/ + rain="./rain.pl " + #done +fi + +rain="$rain -i" # enable halley mode (not use PLOTSH and COMOUT) + +if $sites; then + rain="$rain -s ${site}" +fi + +if $debug; then + rain="$rain -d" +fi + +if $highsec; then + rain="$rain -a" +fi +rain="$rain -r $wdir -v $ver -h $hig -b $prj/\$i-*.run" + +echo "#!/bin/bash +#Stuff-01! +#h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 001206 001608 000703 002412 001105; do +# r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + r=\"$(echo $rain)\" + if [ \$t -gt 3 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +#for i in \$(seq $st $en); do +# echo \"Updating script go-$prj-all-01.sh in halley0\${i}\" +# ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-01.sh +chmod 644 $wdir/go-$prj-all-01.sh +# ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-01.sh /home/h\${i}/$codename/go-$prj-all-01-halley0\${h}.run +#done +" > $wdir/go-$prj-all-01.sh +chmod 744 $wdir/go-$prj-all-01.sh + +echo "#!/bin/bash +#Stuff-02! +#h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 002814 001407 002010 005626 000904 003216 002713; do + #r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + r=\"$(echo $rain)\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +#for i in \$(seq $st $en); do + echo \"Updating script go-$prj-all-02.sh in halley0\${i}\" + #ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-02.sh + chmod 644 $wdir/go-$prj-all-02.sh + #ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-02.sh /home/h\${i}/$codename/go-$prj-all-02-halley0\${h}.run +#done +" > $wdir/go-$prj-all-02.sh +chmod 744 $wdir/go-$prj-all-02.sh + +echo "#!/bin/bash +#Stuff-03! +#h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521; do + #r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + r=\"$(echo $rain)\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +#for i in \$(seq $st $en); do + #echo \"Updating script go-$prj-all-03.sh in halley0\${i}\" + #ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-03.sh + chmod 644 $wdir/go-$prj-all-03.sh + #ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-03.sh /home/h\${i}/$codename/go-$prj-all-03-halley0\${h}.run +#done +" > $wdir/go-$prj-all-03.sh +chmod 744 $wdir/go-$prj-all-03.sh + +#helium +b=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $wdir/$prj/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run +done + +echo "#!/bin/bash +#Helium +#h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') + +t=19 +for j in \$(seq 1 $prcHe); do + i="0\${j}0402" + #r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + r=\"$(echo $rain)\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \$r + t=\$[t+1]; +done +#for i in \$(seq $st $en); do + #echo \"Updating script go-$prj-he.sh in halley0\${i}\" + #ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-he.sh + chmod 644 $wdir/go-$prj-he.sh + #ssh h\${i} mv /home/h\${i}/$codename/go-$prj-he.sh /home/h\${i}/$codename/go-$prj-he-halley0\${h}.run +#done +" > $wdir/go-$prj-he.sh +chmod 744 $wdir/go-${prj}-he.sh +rm $wdir/$prj/000402-*.run + +#protons +b=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +ff=0 +for i in $(seq 1 $multPr); do + l=$[$i-1] + for j in $(seq 1 $prcHe); do + m=$[$l*$prcHe+$j] + printf -v n "%02d" $m + u=${n}'0014' + cat $wdir/$prj/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run + done + ii=$[$ff+1] + ff=$[$ii+$prcHe-1] +echo "#!/bin/bash +# Protons! +#h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for j in \$(seq $ii $ff); do + printf -v n "%02d" \$j + i="\${n}0014" + if [ \$t -gt 4 ]; then t=19; fi + #r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + r=\"$(echo $rain)\" + nice -n \$t \${r} + t=\$[t+1]; +done +#for k in \$(seq $st $en); do + #echo \"Updating script go-$prj-pr-$i.sh in halley0\${k}\" + #ssh h\${k} chmod 644 /home/h\${k}/$codename/go-$prj-pr-$i.sh + chmod 644 $wdir/go-$prj-pr-$i.sh + #ssh h\${k} mv /home/h\${k}/$codename/go-$prj-pr-$i.sh /home/h\${k}/$codename/go-$prj-pr-$i-halley0\${h}.run +#done +" > $wdir/go-${prj}-pr-$i.sh +done + +rm $wdir/$prj/000014-*.run +for i in $(seq 1 $multPr); do + chmod 744 $wdir/go-${prj}-pr-$i.sh +done + +st=$((st+1)) +#for i in $(seq $st $en); do +# echo "Copying scripts to halley0${i}" +# scp -r $wdir/${prj} h${i}:/home/h${i}/$codename/ +# scp -r $wdir/go-${prj}-*.sh h${i}:/home/h${i}/$codename/ +#done diff --git a/eas/deprecated/do_sims_brc.sh b/eas/deprecated/do_sims_brc.sh new file mode 100755 index 0000000000000000000000000000000000000000..f0d620b6e3c82422e2cfe3d231a034514a56f18a --- /dev/null +++ b/eas/deprecated/do_sims_brc.sh @@ -0,0 +1,446 @@ +#!/bin/bash +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: do_sims.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: Main script to automatize secondary flux calculations and */ +# /* run simulations in OAR cluster and non-cluster modes */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r0"; + + +showhelp() { + echo + echo -e "$0 version $VERSION" + echo + echo -e "USAGE $0:" + echo + echo -e " -w <working dir> : Working directory, where bin files are located" + echo -e " -p <project name> : Project name (suggested format: NAMEXX)" + echo -e " -t <flux time> : Flux time for simulations" + echo -e " -v <CORSIKA version> : CORSIKA version" + echo -e " -h <HE Int Model (EPOS|QGSII)> : Define the high interaction model to be used" + echo -e " -u <user name> : User Name." + echo -e " -s <site> : Location (several options)" + echo -e " -y : Select volumetric detector mode (default=flat array)" + echo -e " -e : Enable CHERENKOV mode" + echo -e " -d : Enable DEBUG mode" + echo -e " -a : Enable high energy cuts for secondaries. Do not use for usual fluence calculations." + echo -e " -l <cluster user name> : Enable OAR cluster compatibility, use \$USER" + echo -e " -? : Shows this help and exit." + echo +} +cta=false +debug=false +highsec=false +cluster=false +sites=false +usr="LAGO"; +vol=false + +echo + +while getopts ':w:p:t:v:u:h:s:l:aycde?' opt; do + case $opt in + w) + wdir=$OPTARG + echo -e "# Working dir = $wdir" + ;; + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + tim=$OPTARG + echo -e "# Flux time = $tim" + ;; + v) + ver="$OPTARG" + echo -e "# CORSIKA version = $ver" + ;; + u) + usr="$OPTARG" + echo -e "# User name = $usr" + ;; + h) + hig=$OPTARG + echo -e "# High Energy Interaction Model = $hig" + ;; + s) + site=$OPTARG + sites=true + echo -e "# Site location = $site" + ;; + e) + cta=true + echo -e "# Cherenkov mode enabled for = $site" + ;; + y) + vol=true + echo -e "# Volumetric detector mode for = $site" + ;; + l) + clsname=$OPTARG + cluster=true + echo -e "# Cluster mode enable for user = $clsname" + ;; + a) + highsec=true + ;; + d) + debug=true + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +#helium -> Usually for 1 hour flux, 4 different procces is enough +prcHe=4 + +#protons -> we need at least 32 times helium, so multPr=8 +multPr=8 +prcPr=$[${prcHe}*${multPr}] # now prcPr=32 + +# cores per node in OAR cluster +# Should be divisor of 60, since we are running 60 process: 32(protons)+4(helium)+24(single nuclei)=60 +procs=4 +shows=60 +max=$[$shows/$procs] +shows=$[$shows-1] + + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X$prj" == "X" ]; then + echo; echo -e "ERROR: You have to provide a project name (suggested format: NAMEXX, where XX is a number between 0 and 99)" + showhelp + exit 1; +fi + +if [ "X$wdir" == "X" ]; then + echo; echo -e "ERROR: You have to set the working directory (where corsika bin files are located)" + showhelp + exit 1; +fi + +if [ "X$tim" == "X" ]; then + tim=3600; + echo -e "# WARNING: Time was not provided. Using default time: $tim s" +fi + + +if [ "X$ver" == "X" ]; then + ver="75600" + echo -e "# WARNING: CORSIKA version was not provided. Using default: $ver" +fi + +if [ "X$hig" == "X" ]; then + hig="QGSII" + echo -e "# WARNING: High energy interaction model was not provided. Using default: $hig" +fi + +if $debug; then + echo -e "# WARNING: You are running in DEBUG mode." +fi + +if $cta; then + if $sites; then + echo -e "# WARNING: Cherenkov mode is enabled." + else + echo; echo -e "ERROR: You have to provide a site location in CHERENKOV mode" + showhelp + exit 1; + fi +fi + +if $cluster; then + echo -e "# WARNING: Cluster mode is enabled." + echo -e "# WARNING: User name was overrided. Using cluster user name: $clsname ;)" + usr=$clsname +fi + +if $highsec; then + echo -e "# WARNING: High energy cuts for secondaries will be used." +fi + +codename=$(echo $wdir | sed -e 's/\/data\/tep6\/asoreyh\///' | sed -e 's/\///') +home=$wdir +if $cluster; then + home="/home/$usr" +fi +direct=$home/$prj + +############## +options="-w ${wdir} -t ${tim} -p ${prj} " +if $sites; then + options=${options}"-s ${site} " +fi +if $cluster; then + options=${options}"-l ${usr} " +else + options=${options}"-u ${usr} " +fi +if $highsec; then + options=${options}"-a " +fi +if $vol; then + options=${options}"-y " +fi +options=${options}"-f spectra.dat" + +./generate_spectra.pl $options +############## + +a=$(echo $prj) + +#all + +# cluster mode +if $cluster; then + if $cta; then + cp $home/arti/rain.pl $home + rain="$home/rain.pl -z -l ${usr}" + else + cp $home/arti/rain.pl $home + rain="$home/rain.pl -l ${usr}" + fi + if $sites; then + rain="$rain -s ${site}" + fi + if $debug; then + rain="$rain -d" + fi + if $highsec; then + rain="$rain -a" + fi + rain="$rain -r $wdir -v $ver -h $hig -b" + + #helium + b=$(basename $(ls -1 $direct/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') + c=$(basename $(ls -1 $direct/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') + printf -v k "%06d" $c + + for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $direct/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $direct/$u-$k.run + done + rm $direct/000402-*.run + + #protons + b=$(basename $(ls -1 $direct/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') + c=$(basename $(ls -1 $direct/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') + printf -v k "%06d" $c + + ff=0 + for i in $(seq 1 $multPr); do + l=$[$i-1] + for j in $(seq 1 $prcHe); do + m=$[$l*$prcHe+$j] + printf -v n "%02d" $m + u=${n}'0014' + cat $direct/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $direct/$u-$k.run + done + ii=$[$ff+1] + ff=$[$ii+$prcHe-1] + done + rm $direct/000014-*.run + + echo "#!/bin/bash +showers=(010014 020014 030014 040014 050014 060014 070014 080014 090014 100014 110014 120014 130014 140014 150014 160014 170014 180014 190014 200014 210014 220014 230014 240014 250014 260014 270014 280014 290014 300014 310014 320014 010402 020402 030402 040402 001206 001608 000703 002412 001105 002814 001407 002010 005626 000904 003216 002713 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521) +idp=17 +for i in \$(seq 0 $procs $shows); do + job=\`printf \"%02d\" \$i\`; + network=\"quimica\" + name=\"$home/go-$prj-\$job.sh\" + echo \"#!/bin/bash\" > \$name + echo \"echo \\\"Starting simulations for job \$job using script\" >> \$name + echo \"\$name\\\"\" >> \$name + echo \"date\" >> \$name + echo \"echo\" >> \$name + echo \"cp $home/rain.pl $wdir/\" >> \$name + echo \"cd $wdir\" >> \$name + echo \"$rain $direct/\${showers[\$i+0]}-*.run &\" >> \$name + echo \"$rain $direct/\${showers[\$i+1]}-*.run &\" >> \$name + echo \"$rain $direct/\${showers[\$i+2]}-*.run &\" >> \$name + echo \"$rain $direct/\${showers[\$i+3]}-*.run \" >> \$name + echo \"chmod 644 \$name\" >> \$name + echo \"mv \$name \$name.done\" >> \$name + chmod 777 \$name + # launching job + oarsub -l nodes=1,walltime=999:00:00 -p \"cluster='\$network'\" \$name +done +mv $home/go-$prj.sh $home/go-$prj.run +chmod 644 $home/go-$prj.run +" > $home/go-$prj.sh + chmod 744 $home/go-$prj.sh +else +##### end cluster mode + if $cta; then + for i in $(seq 3 6); do + u=$(echo $wdir | sed -e "s/tep6/tep${i}/") + cp $home/arti/rain.pl $u/ + rain="./rain.pl -z" + done + else + for i in $(seq 3 6); do + u=$(echo $wdir | sed -e "s/tep6/tep${i}/") + cp $home/arti/rain.pl $u/ + rain="./rain.pl " + done + fi + if $sites; then + rain="$rain -s ${site}" + fi + if $debug; then + rain="$rain -d" + fi + + if $highsec; then + rain="$rain -a" + fi + rain="$rain -r $wdir -v $ver -h $hig -b $prj/\$i-*.run" + + echo "#!/bin/bash + #Stuff! + h=\$(hostname | sed -e 's/cab//') + d=\$(hostname | sed -e 's/cabtep//') + t=0 + for i in 001206 001608 000703 002412 001105 002814 001407 002010 005626 000904 003216 002713 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521; do + r=\"$(echo $rain | sed -e 's/tep6/\${h}/')\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; + done + for x in \$(seq 3 6); do + chmod 644 /data/tep\${x}/asoreyh/$codename/go-${prj}-all.sh + mv /data/tep\${x}/asoreyh/$codename/go-${prj}-all.sh /data/tep\${x}/asoreyh/$codename/go-${prj}-all-\${h}.run + done" > $wdir/go-$prj-all.sh + chmod 744 $wdir/go-$prj-all.sh + + + #helium + b=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') + c=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') + printf -v k "%06d" $c + + for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $wdir/$prj/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run + done + + echo "#!/bin/bash + #Helium + h=\$(hostname | sed -e 's/cab//') + d=\$(hostname | sed -e 's/cabtep//') + t=0 + for j in \$(seq 1 $prcHe); do + i="0\${j}0402" + r=\"$(echo $rain | sed -e 's/tep6/\${h}/')\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \$r + t=\$[t+1]; + done + for x in \$(seq 3 6); do + chmod 644 /data/tep\${x}/asoreyh/$codename/go-${prj}-he.sh + mv /data/tep\${x}/asoreyh/$codename/go-${prj}-he.sh /data/tep\${x}/asoreyh/$codename/go-${prj}-he-\${h}.run + done" > $wdir/go-$prj-he.sh + chmod 744 $wdir/go-${prj}-he.sh + rm $wdir/$prj/000402-*.run + + #protons + b=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') + c=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') + printf -v k "%06d" $c + + ff=0 + for i in $(seq 1 $multPr); do + l=$[$i-1] + for j in $(seq 1 $prcHe); do + m=$[$l*$prcHe+$j] + printf -v n "%02d" $m + u=${n}'0014' + cat $wdir/$prj/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run + done + ii=$[$ff+1] + ff=$[$ii+$prcHe-1] + echo "#!/bin/bash + # Protons! + h=\$(hostname | sed -e 's/cab//') + d=\$(hostname | sed -e 's/cabtep//') + t=0 + for j in \$(seq $ii $ff); do + printf -v n "%02d" \$j + i="\${n}0014" + if [ \$t -gt 4 ]; then t=19; fi + r=\"$(echo $rain | sed -e 's/tep6/\${h}/')\" + nice -n \$t \${r} + t=\$[t+1]; + done + + for x in \$(seq 3 6); do + chmod 644 /data/tep\${x}/asoreyh/$codename/go-${prj}-pr-$i.sh + mv /data/tep\${x}/asoreyh/$codename/go-${prj}-pr-$i.sh /data/tep\${x}/asoreyh/$codename/go-${prj}-pr-$i-\${h}.run + done" > $wdir/go-${prj}-pr-$i.sh + done + + rm $wdir/$prj/000014-*.run + for i in $(seq 1 $multPr); do + chmod 744 $wdir/go-${prj}-pr-$i.sh + done + + for i in $(seq 3 5); do + echo "Copying scripts to tep${i}" + cp -r $wdir/${prj} /data/tep${i}/asoreyh/$codename/ + cp -r $wdir/go-${prj}-*.sh /data/tep${i}/asoreyh/$codename/ + done +fi diff --git a/eas/deprecated/do_sims_halley.sh b/eas/deprecated/do_sims_halley.sh new file mode 100755 index 0000000000000000000000000000000000000000..18336842a39a9e561f44828c9a5f7076c1ada678 --- /dev/null +++ b/eas/deprecated/do_sims_halley.sh @@ -0,0 +1,416 @@ +#!/bin/bash +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: do_sims_halley.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: Main script to automatize secondary flux calculations and */ +# /* run simulations in semi-cluster configuration (halley) */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r0"; # Tue Aug 6 15:43:52 COT 2013 + +showhelp() { + echo + echo -e "$0 version $VERSION" + echo + echo -e "USAGE $0:" + echo + echo -e " -w <working dir> : Working directory, where bin files are located" + echo -e " -p <project name> : Project name (suggested format: NAMEXX)" + echo -e " -t <flux time> : Flux time (in seconds) for simulations" + echo -e " -v <CORSIKA version> : CORSIKA version" + echo -e " -h <HE Int Model (EPOS|QGSII)> : Define the high interaction model to be used" + echo -e " -u <user name> : User Name." + echo -e " -s <site> : Location (several options)" + echo -e " -y : Select volumetric detector mode (default=flat array)" + echo -e " -e : Enable CHERENKOV mode" + echo -e " -d : Enable DEBUG mode" + echo -e " -a : Enable high energy cuts for secondaries" + echo -e " -k <altitude, in cm> : Fix altitude, even for predefined sites" + echo -e " -l <cluster user name> : Enable OAR cluster compatibility, use \$USER" + echo -e " -? : Shows this help and exit." + echo +} +cta=false +debug=false +highsec=false +cluster=false +sites=false +usr="LAGO"; +vol=false +alt=false +altitude=0. + +echo + +while getopts ':w:k:p:t:v:u:h:s:l:?ayde' opt; do + case $opt in + w) + wdir=$OPTARG + echo -e "# Working dir = $wdir" + ;; + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + tim=$OPTARG + echo -e "# Flux time = $tim" + ;; + v) + ver="$OPTARG" + echo -e "# CORSIKA version = $ver" + ;; + u) + usr="$OPTARG" + echo -e "# User name = $usr" + ;; + k) + alt=true + altitude=$OPTARG + echo -e "# Altitude = $altitude" + ;; + h) + hig=$OPTARG + echo -e "# High Energy Interaction Model = $hig" + ;; + s) + site=$OPTARG + sites=true + echo -e "# Site location = $site" + ;; + e) + cta=true + echo -e "# Cherenkov mode enabled for = $site" + ;; + y) + vol=true + echo -e "# Volumetric detector mode for = $site" + ;; + l) + clsname=$OPTARG + cluster=true + echo -e "# Cluster mode enable for user = $clsname" + ;; + a) + highsec=true + ;; + d) + debug=true + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +#helium -> Usually for 1 hour flux, 4 different procces is enough +prcHe=4 + +#protons -> we need at least 32 times helium, so multPr=8 +multPr=8 +prcPr=$[${prcHe}*${multPr}] # now prcPr=32 + +# cores per node in OAR cluster +# Should be divisor of 60, since we are running 60 process: 32(protons)+4(helium)+24(single nuclei)=60 +procs=4 +shows=60 +max=$[$shows/$procs] +shows=$[$shows-1] + + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X$prj" == "X" ]; then + echo; echo -e "ERROR: You have to provide a project name (suggested format: NAMEXX, where XX is a number between 0 and 99)" + showhelp + exit 1; +fi + +if [ "X$wdir" == "X" ]; then + echo; echo -e "ERROR: You have to set the working directory (where corsika bin files are located)" + showhelp + exit 1; +fi + +if [ "X$tim" == "X" ]; then + tim=3600; + echo -e "# WARNING: Time was not provided. Using default time: $tim s" +fi + + +if [ "X$ver" == "X" ]; then + ver="75600" + echo -e "# WARNING: CORSIKA version was not provided. Using default: $ver" +fi + +if [ "X$hig" == "X" ]; then + hig="QGSII" + echo -e "# WARNING: High energy interaction model was not provided. Using default: $hig" +fi + +if $debug; then + echo -e "# WARNING: You are running in DEBUG mode." +fi + +if $cta; then + if $sites; then + echo -e "# WARNING: Cherenkov mode is enabled." + else + echo; echo -e "ERROR: You have to provide a site location in CHERENKOV mode" + showhelp + exit 1; + fi +fi + +if $cluster; then + echo -e "# ERROR: Please use do_sims for OAR CLUSTER mode." + exit +fi + +if $highsec; then + echo -e "# WARNING: High energy cuts for secondaries will be used." +fi + +codename=$(echo $wdir | sed -e 's/\/home\/h0\///' | sed -e 's/\///') +home=$wdir +direct=$home/$prj +basearti=/home/h0/apps/arti + +############## +options="-w ${wdir} -t ${tim} -p ${prj} " +if $sites; then + options=${options}"-s ${site} " +fi +options=${options}"-u ${usr} " +if $highsec; then + options=${options}"-a " +fi +if $vol; then + options=${options}"-y " +fi +if $alt; then + options=${options}"-k $altitude " +fi + +options=${options}"-f $basearti/spectra.dat" + +$basearti/generate_spectra.pl ${options} + +############## + +a=$(echo $prj) + +#all + +st=0 +en=5 + +if $cta; then + for i in $(seq $st $en); do + u=$(echo $wdir | sed -e "s/h0/h${i}/") + scp $basearti/rain.pl h${i}:$u/ + rain="./rain.pl -z" + done +else + for i in $(seq $st $en); do + u=$(echo $wdir | sed -e "s/h0/h${i}/") + scp $basearti/rain.pl h${i}:$u/ + rain="./rain.pl " + done +fi + +rain="$rain -i" # enable halley mode (not use PLOTSH and COMOUT) + +if $sites; then + rain="$rain -s ${site}" +fi + +if $debug; then + rain="$rain -d" +fi + +if $highsec; then + rain="$rain -a" +fi +rain="$rain -r $wdir -v $ver -h $hig -b $prj/\$i-*.run" + +echo "#!/bin/bash +#Stuff-01! +h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 001206 001608 000703 002412 001105; do + r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + if [ \$t -gt 3 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +for i in \$(seq $st $en); do + echo \"Updating script go-$prj-all-01.sh in halley0\${i}\" + ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-01.sh + ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-01.sh /home/h\${i}/$codename/go-$prj-all-01-halley0\${h}.run +done +" > $wdir/go-$prj-all-01.sh +chmod 744 $wdir/go-$prj-all-01.sh + +echo "#!/bin/bash +#Stuff-02! +h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 002814 001407 002010 005626 000904 003216 002713; do + r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +for i in \$(seq $st $en); do + echo \"Updating script go-$prj-all-02.sh in halley0\${i}\" + ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-02.sh + ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-02.sh /home/h\${i}/$codename/go-$prj-all-02-halley0\${h}.run +done +" > $wdir/go-$prj-all-02.sh +chmod 744 $wdir/go-$prj-all-02.sh + +echo "#!/bin/bash +#Stuff-03! +h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for i in 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521; do + r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \${r} + t=\$[t+1]; +done +for i in \$(seq $st $en); do + echo \"Updating script go-$prj-all-03.sh in halley0\${i}\" + ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-all-03.sh + ssh h\${i} mv /home/h\${i}/$codename/go-$prj-all-03.sh /home/h\${i}/$codename/go-$prj-all-03-halley0\${h}.run +done +" > $wdir/go-$prj-all-03.sh +chmod 744 $wdir/go-$prj-all-03.sh + +#helium +b=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $wdir/$prj/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run +done + +echo "#!/bin/bash +#Helium +h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') + +t=19 +for j in \$(seq 1 $prcHe); do + i="0\${j}0402" + r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + if [ \$t -gt 4 ]; then t=19; fi + nice -n \$t \$r + t=\$[t+1]; +done +for i in \$(seq $st $en); do + echo \"Updating script go-$prj-he.sh in halley0\${i}\" + ssh h\${i} chmod 644 /home/h\${i}/$codename/go-$prj-he.sh + ssh h\${i} mv /home/h\${i}/$codename/go-$prj-he.sh /home/h\${i}/$codename/go-$prj-he-halley0\${h}.run +done +" > $wdir/go-$prj-he.sh +chmod 744 $wdir/go-${prj}-he.sh +rm $wdir/$prj/000402-*.run + +#protons +b=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') +printf -v k "%06d" $c + +ff=0 +for i in $(seq 1 $multPr); do + l=$[$i-1] + for j in $(seq 1 $prcHe); do + m=$[$l*$prcHe+$j] + printf -v n "%02d" $m + u=${n}'0014' + cat $wdir/$prj/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run + done + ii=$[$ff+1] + ff=$[$ii+$prcHe-1] +echo "#!/bin/bash +# Protons! +h=\$(hostname | awk '{if (\$1==\"frontend\") {print 0} else if (\$1==\"hernan\") {print 5} else {print \$0}}' | sed -e 's/halley0//') +t=19 +for j in \$(seq $ii $ff); do + printf -v n "%02d" \$j + i="\${n}0014" + if [ \$t -gt 4 ]; then t=19; fi + r=\"$(echo $rain | sed -e 's/h0/h\${h}/')\" + nice -n \$t \${r} + t=\$[t+1]; +done +for k in \$(seq $st $en); do + echo \"Updating script go-$prj-pr-$i.sh in halley0\${k}\" + ssh h\${k} chmod 644 /home/h\${k}/$codename/go-$prj-pr-$i.sh + ssh h\${k} mv /home/h\${k}/$codename/go-$prj-pr-$i.sh /home/h\${k}/$codename/go-$prj-pr-$i-halley0\${h}.run +done +" > $wdir/go-${prj}-pr-$i.sh +done + +rm $wdir/$prj/000014-*.run +for i in $(seq 1 $multPr); do + chmod 744 $wdir/go-${prj}-pr-$i.sh +done + +st=$((st+1)) +for i in $(seq $st $en); do + echo "Copying scripts to halley0${i}" + scp -r $wdir/${prj} h${i}:/home/h${i}/$codename/ + scp -r $wdir/go-${prj}-*.sh h${i}:/home/h${i}/$codename/ +done diff --git a/eas/deprecated/new_project_halley.sh b/eas/deprecated/new_project_halley.sh new file mode 100755 index 0000000000000000000000000000000000000000..32c91db4f31d14ca1e93ae0f7d070f574250c1bc --- /dev/null +++ b/eas/deprecated/new_project_halley.sh @@ -0,0 +1,165 @@ +#!/bin/bash +# /************************************************************************/ +# /* */ +# /* Package: ARTI */ +# /* Module: new_project_halley.sh */ +# /* */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: asoreyh@cab.cnea.gov.ar */ +# /* */ +# /************************************************************************/ +# /* Comments: This script automates the creation of a new simulation */ +# /* project in the halley cluster */ +# /* */ +# /************************************************************************/ +# /* +# +# Copyright 2013 +# Hernán Asorey +# the LAGO Collaboration (CAB-CNEA), Argentina +# Grupo Halley (UIS), Colombia +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r0"; # Wed Dec 4 21:53:57 COT 2013 +# first version + + +showhelp() { + echo + echo -e "$0 $VERSION" + echo + echo -e "Note: You should run this script at halley cluster frontend h0" + echo + echo -e "USAGE $0:" + echo + echo -e " -s <source bin directory> : Where corsika binary files are located" + echo -e " -p <project name> : Project base name (suggested format: nnn)" + echo -e " -u <user name> : Cluster user name." + echo -e " -d <project name> : Erase project from cluster. WARNING: Can't not be undone" + echo -e " -? : Shows this help and exit." + echo +} + +src=""; +usr=""; +prj=""; + +echo + +while getopts ':s:p:u:d:?' opt; do + case $opt in + s) + src=$OPTARG + echo -e "# Source bin directory = $src" + ;; + p) + prj=$OPTARG + echo -e "# Project base name = $prj" + ;; + d) + prj=$OPTARG + echo -e "# WARNING: You will erase project ${prj}" + echo -e "# WARNING: This action can not be undone" + echo -e "# WARNING: Press enter to continue, ctrl-c to abort" + read + for i in $(seq 0 5); do + echo -e "# erasing project on halley$i" + ssh h${i} rm -r /home/h$i/${prj} + done + echo -e "# ALL DONE. Exit" + exit 0; + ;; + u) + usr="$OPTARG" + echo -e "# User name = $usr" + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +h=$(hostname | awk '{if ($1=="frontend") {print 0} else {print $0}}' | sed -e 's/halley0//') +if [ "X${h}" != "X0" ]; then + echo; echo -e "# ERROR: You should run this script at halley cluster frontend (h0)" + showhelp + exit 1; +fi + +if [ "X${prj}" == "X" ]; then + echo; echo -e "# ERROR: You have to provide a project name (suggested format: nnn)" + showhelp + exit 1; +fi + +if [ "X${src}" == "X" ]; then + echo; echo -e "# ERROR: You have to inform where corsika bin files are located" + showhelp + exit 1; +fi + +if [ "X${usr}" == "X" ]; then + usr=${USER} + echo; echo -e "# WARNING: user name don't provided. Using system user name: ${usr}" +fi + +echo; echo -e "# READY: Press enter to continue, <ctrl-c> to abort!" +read +############## + +mkdir /home/h0/${prj} +cp -r ${src}/run/* /home/h0/${prj}/ +for i in $(seq 1 5); do + rsync -aP /home/h0/${prj} h${i}:/home/h${i} +done + +#### Adding this project to .bashrc +echo "alias ${prj}=\"cd /home/h\${hn}/${prj}; ls -l\"" >> ~/.bashrc +for i in $(seq 1 5); do + rsync -aP ~/.bashrc h${i}: +done +source ~/.bashrc + +echo +echo +echo -e "# DONE: Project ${prj} has been created. You can access the project folder" +echo -e "# by just typing ${prj} anywhere." +echo -e "#" +echo -e "# Run do_sims_halley.sh to continue" +echo diff --git a/eas/do_sims.sh b/eas/do_sims.sh new file mode 100755 index 0000000000000000000000000000000000000000..4eeca2eb0dabbc35f12a742eb985bb15844b33e0 --- /dev/null +++ b/eas/do_sims.sh @@ -0,0 +1,527 @@ +#!/bin/bash +# /************************************************************************/ +# /* Package: ARTI */ +# /* Module: do_sims.sh */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: hernan.asoreyh@iteda.cnea.gov.ar */ +# /************************************************************************/ +# /* Comments: Main script to automatize secondary flux calculations */ +# /************************************************************************/ +# /* +# LICENSE BSD-3-Clause +# Copyright (c) 2015 +# The LAGO Collaboration +# https://lagoproject.net +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +VERSION="v1r9"; +showhelp() { + echo -e "$0 version $VERSION" + echo + echo -e "USAGE $0:" + echo -e + echo -e "Simulation parameters" + echo -e " -w <working dir> : Working directory, where bin (run) files are located" + echo -e " -p <project name> : Project name (suggested format: NAMEXX)" + echo -e " -v <CORSIKA version> : CORSIKA version" + echo -e " -h <HE Int Model (EPOS|QGSII)> : Define the high interaction model to be used" + echo -e " -u <user name> : User Name." + echo -e " -j <procs> : Number of processors to use" + echo -e + echo -e "Physical parameters" + echo -e " -t <flux time> : Flux time (in seconds) for simulations" + echo -e " -m <Low edge zenith angle> : Low edge of zenith angle." + echo -e " -n <High edge zenith angle> : High edge of zenith angle." + echo -e " -r <Low primary particle energy> : Lower limit of the primary particle energy." + echo -e " -i <Upper primary particle energy> : Upper limit of the primary particle energy." + echo -e " -a <high energy ecuts> : High energy cuts for ECUTS; (if set value in GV = enabled)." + echo -e " -y : Select volumetric detector mode (default=flat array)" + echo -e + echo -e "Site parameters" + echo -e " -s <site> : Location (several options)" + echo -e " -k <altitude, in cm> : Fix altitude, even for predefined sites" + echo -e " -c <atm_model> : Fix Atmospheric Model even for predefined sites." + echo -e " -o <BX> : Horizontal comp. of the Earth's mag. field." + echo -e " -q <BZ> : Vertical comp. of the Earth's mag. field." + echo -e " -b <rigidity cutoff> : Rigidity cutoff; (if set value in GV = enabled, <0 = disable)." + echo -e " -g <Lat, Lon> *dev : Obtain the current values of BX and BZ for a site located at (Lat,Lon,Alt), -k option is mandatory. If -s is used, then (Lat,Lon,Alt) will be taken from the standard characterization of the site." + echo -e + echo -e "Modifiers" + echo -e " -l : Enables SLURM cluster compatibility (with sbatch)." + echo -e " -e : Enable CHERENKOV mode" + echo -e " -d : Enable DEBUG mode" + echo -e " -x : Enable other defaults (It doesn't prompt user for unset parameters)" + echo -e " -? : Shows this help and exit." + echo +} +cta=false +debug=false +highsec=false +sites=false +usr="LAGO"; +vol=false +alt=false +altitude=0. +procs=4 +atm_m=false +rig=false +lez=false +hez=false +lppe=false +uppe=false +BXcomp=false +BZcomp=false +defaults=false +ecut=800 +slurm=false + +echo +while getopts 'w:k:p:t:v:u:h:s:j:c:b:m:n:r:i:o:q:a:?lydex' opt; do + case $opt in + w) + wdir=$OPTARG + echo -e "# Working dir = $wdir" + ;; + p) + prj=$OPTARG + echo -e "# Project name = $prj" + ;; + t) + tim=$OPTARG + echo -e "# Flux time = $tim" + ;; + v) + ver=$OPTARG + echo -e "# CORSIKA version = $ver" + ;; + u) + usr=$OPTARG + echo -e "# User name = $usr" + ;; + k) + alt=true + altitude=$OPTARG + echo -e "# Altitude = $altitude" + ;; + h) + hig=$OPTARG + echo -e "# High Energy Interaction Model = $hig" + ;; + s) + site=$OPTARG + sites=true + echo -e "# Site location = $site" + ;; + a) + highsec=true + ecut=$OPTARG + echo -e "# High energy CUTS = $ecut" + ;; + j) + procs=$OPTARG + echo -e "# Number of processors = $procs" + ;; + c) + atm_m=true + atm_model=$OPTARG + echo -e "# Atmospheric Model = $atm_model" + ;; + b) + rig=true + rigididy=$OPTARG + echo -e "# Rigidity cutoff = $rigididy" + ;; + m) + lez=true + lowez=$OPTARG + echo -e "# Low edge of zenith angle = $lowez" + ;; + n) + hez=true + highez=$OPTARG + echo -e "# High edge of zenith angle = $highez" + ;; + r) + lppe=true + lowppe=$OPTARG + echo -e "# Low primary particle energy = $lowppe" + ;; + i) + uppe=true + upperppe=$OPTARG + echo -e "# High primary particle energy = $upperppe" + ;; + o) + BXcomp=true + BX=$OPTARG + echo -e "# Horizontal gepmagnetic field = $BX" + ;; + q) + BZcomp=true + BZ=$OPTARG + echo -e "# Vertical geomagnetic field = $BZ" + ;; + e) + cta=true + echo -e "# Cherenkov mode enabled for = $site" + ;; + y) + vol=true + echo -e "# Volumetric detector mode for = $site" + ;; + l) + slurm=true + ;; + d) + debug=true + ;; + x) + defaults=true + ;; + ?) + showhelp + exit 1; + ;; + esac +done + +################################################## +## YOU SHOULD NOT EDIT ANYTHING BELOW THIS LINE ## +################################################## + +if [ "X$prj" == "X" ]; then + echo; echo -e "ERROR: You have to provide a project name (suggested format: NAMEXX, where XX is a number between 0 and 99)" + showhelp + exit 1; +fi + +if [ "X$wdir" == "X" ]; then + echo; echo -e "ERROR: You have to set the working directory (where corsika bin files are located)" + showhelp + exit 1; +fi + +if [ "X$tim" == "X" ]; then + tim=3600; + echo -e "# WARNING: Time was not provided. Using default time: $tim s" +fi + +if [ "X$procs" == "X0" ]; then + procs=4; + echo -e "# WARNING: Processors should be >0, using default: $procs" +fi + +if [ "X$ver" == "X" ]; then + ver="77402" + echo -e "# WARNING: CORSIKA version was not provided. Using default: $ver" +fi + +if [ "X$hig" == "X" ]; then + hig="QGSII" + echo -e "# WARNING: High energy interaction model was not provided. Using default: $hig" +fi + +if [ "X$atm_model" == "X" ]; then + atm_model="E1" + echo -e "# WARNING: Atmospheric Model was not provided. Using default: $atm_model" +fi + +if [ "X$rigididy" == "X" ]; then + rigididy="0" + echo -e "# WARNING: Rigidity cutoff was not provided. Using default (disabled): $rigididy" +fi + +if [ "X$lowez" == "X" ]; then + lowez="0" + echo -e "# WARNING: Low edge of zenith angle was not provided. Using default: $lowez" +fi + +if [ "X$highez" == "X" ]; then + highez="90" + echo -e "# WARNING: High edge of zenith angle was not provided. Using default: $highez" +fi + +if [ "X$lowppe" == "X" ]; then + lowppe="5" + lppe=true +fi + +if [ "X$upperppe" == "X" ]; then + upperppe="1e6" + echo -e "# WARNING: Primary particle high energy limit was not provided. Using default: $upperppe" +fi + +if [ "X$BX" == "X" ]; then + BX="12.5" + echo -e "# WARNING: Horizontal comp. Earth's mag. field was not provided. Using default: $BX" +fi + +if [ "X$BZ" == "X" ]; then + BZ="25.5" + echo -e "# WARNING: Vertical comp. Earth's mag. field was not provided. Using default: $BZ" +fi + +if $debug; then + echo -e "# WARNING: You are running in DEBUG mode." +fi + +if $defaults; then + echo -e "# WARNING: You are using some default vaules that will not be prompted." +fi + +if $cta; then + if $sites; then + echo -e "# WARNING: Cherenkov mode is enabled." + else + echo; echo -e "ERROR: You have to provide a site location in CHERENKOV mode" + showhelp + exit 1; + fi +fi + +if $highsec; then + echo -e "# WARNING: High energy cuts of $ecut GeV for secondaries will be used." + if [ $lowppe -lt $ecut ]; then + lowppe=$ecut + lppe=true + echo -e "# WARNING: Primary particle low energy limit is below energy cuts for secondaries. Changing to: $lowppe" + fi +fi + +if $slurm; then + echo -e "# WARNING: SLURM mode is enable. Will not work in other environments." +fi + +corsika_bin="corsika${ver}Linux_${hig}_gheisha" +if [ ! -e $wdir/$corsika_bin ]; then + echo; echo -e "ERROR: Can't locate corsika executable file ($corsika_bin) in the working dir you provided. Please check." + showhelp + exit 1; +fi +echo -e "# INFO : Executable file is ($corsika_bin)" + + +direct=$wdir/$prj +basearti=${LAGO_ARTI} +#helium -> Usually for 1 hour flux, 4 different procces is enough +prcHe=$procs + +#protons -> we need at least 32 times helium, so multPr=8 +multPr=8 +prcPr=$[${prcHe}*${multPr}] # now prcPr=32 + + +############## +options="-w ${wdir} -t ${tim} -p ${prj} " +if $sites; then + options=${options}"-s ${site} " +fi +options=${options}"-u ${usr} " +if $highsec; then + options=${options}"-a $ecut " +fi +if $vol; then + options=${options}"-y " +fi +if $alt; then + options=${options}"-k $altitude " +fi +if $atm_m; then + options=${options}"-c $atm_model " +fi +if $rig; then + options=${options}"-b $rigididy " +fi +if $lez; then + options=${options}"-m $lowez " +fi +if $hez; then + options=${options}"-n $highez " +fi +if $lppe; then + options=${options}"-r $lowppe " +fi +if $uppe; then + options=${options}"-i $upperppe " +fi +if $BXcomp; then + options=${options}"-o $BX " +fi +if $BZcomp; then + options=${options}"-q $BZ " +fi +if $defaults; then + options=${options}"-x " +fi + +options=${options}"-f $basearti/sims/spectra.dat" + +echo +$basearti/sims/generate_spectra.pl ${options} || exit 1 +echo +############## + +a=$(echo $prj) + +#all + +cp $basearti/sims/rain.pl $wdir/ +if $cta; then + rain="./rain.pl -z" +else + rain="./rain.pl " +fi + +rain="$rain -i" # disable PLOT mode (not use PLOTSH and COMOUT) + +if $sites; then + rain="$rain -s ${site}" +fi + +if $debug; then + rain="$rain -d" +fi + +if $highsec; then + rain="$rain -a $ecut" +fi + +if $slurm; then + rain="$rain -l" +fi + +rain="$rain -r $wdir -v $ver -h $hig -b $prj/\$i-*.run" +# echo -e "# INFO : rain command: $rain" +echo -e "# INFO : Calculations done. Now run the go_${prj}_* scripts in $wdir/" +basenice=19 +if $slurm; then + basenice=0; +fi + +if $slurm; then + echo -e "#!/bin/bash" > $wdir/go-slurm-$prj.sh + echo -e "# go slurm $prj" >> $wdir/go-slurm-$prj.sh + echo -e "" >> $wdir/go-slurm-$prj.sh + chmod 744 $wdir/go-slurm-$prj.sh +fi + +stuff=(001206 001608 000703 002412 001105 002814 001407 002010 005626 000904 003216 002713 002311 004020 001909 005224 004018 004822 005525 003919 005123 003115 003517 004521) +t=0 +for i in $(seq 0 $procs $[${#stuff[@]}-1]); do + nuc="" + t=$[$t+1] + printf -v n "%02d" $t + for j in $(seq 0 $[${procs}-1]); do + nuc+="${stuff[$i+$j]} " + done + echo "#!/bin/bash +#Stuff-$n! +for i in ${nuc}; do + r=\"$rain \" + nice -n $basenice \${r} +done +chmod 644 $wdir/go-$prj-all-$n.sh +mv $wdir/go-$prj-all-$n.sh $wdir/go-$prj-all-$n.run +" > $wdir/go-$prj-all-$n.sh + chmod 744 $wdir/go-$prj-all-$n.sh + if $slurm; then + echo $wdir/go-$prj-all-$n.sh >> $wdir/go-slurm-$prj.sh + fi +done + +#helium +b=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000402-*) .run | sed -e "s/000402-//" | awk -v p=${prcHe} '{print int($1/p+0.5)}') +printf -v k "%011d" $c + +for i in $(seq 1 $prcHe); do + u="0${i}0402" + cat $wdir/$prj/000402-*.run | sed -e "s/000402/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run +done + +echo "#!/bin/bash +#Helium +for j in \$(seq 1 $prcHe); do + i="0\${j}0402" + r=\"$rain \" + nice -n $basenice \${r} +done +chmod 644 $wdir/go-$prj-he.sh +mv $wdir/go-$prj-he.sh $wdir/go-$prj-he.run +" > $wdir/go-$prj-he.sh +chmod 744 $wdir/go-${prj}-he.sh +rm $wdir/$prj/000402-*.run +if $slurm; then + echo $wdir/go-${prj}-he.sh >> $wdir/go-slurm-$prj.sh +fi + +#protons +b=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk '{print $1*1.0}') +c=$(basename $(ls -1 $wdir/$prj/000014-*) .run | sed -e "s/000014-//" | awk -v p=${prcPr} '{print int($1/p+0.5)}') +printf -v k "%011d" $c + +ff=0 +for i in $(seq 1 $multPr); do + l=$[$i-1] + for j in $(seq 1 $prcHe); do + m=$[$l*$prcHe+$j] + printf -v n "%02d" $m + u=${n}'0014' + cat $wdir/$prj/000014-*.run | sed -e "s/000014/$u/" | sed -e "s/$b/$c/" > $wdir/$prj/$u-$k.run + done + ii=$[$ff+1] + ff=$[$ii+$prcHe-1] + echo "#!/bin/bash +# Protons! +for j in \$(seq $ii $ff); do + printf -v n "%02d" \$j + i="\${n}0014" + r=\"$rain \" + nice -n $basenice \${r} +done +chmod 644 $wdir/go-$prj-pr-$i.sh +mv $wdir/go-$prj-pr-$i.sh $wdir/go-$prj-pr-$i.run" > $wdir/go-${prj}-pr-$i.sh +if $slurm; then + echo $wdir/go-${prj}-pr-$i.sh >> $wdir/go-slurm-$prj.sh +fi +done +rm $wdir/$prj/000014-*.run +for i in $(seq 1 $multPr); do + chmod 744 $wdir/go-${prj}-pr-$i.sh +done +if $slurm; then + echo -e "squeue -u \$USER" >> $wdir/go-slurm-$prj.sh + echo -e "mv $wdir/go-slurm-$prj.sh $wdir/go-slurm-$prj.run" >> $wdir/go-slurm-$prj.sh + echo -e "chmod 644 $wdir/go-slurm-$prj.run" >> $wdir/go-slurm-$prj.sh +fi diff --git a/eas/generate_spectra.pl b/eas/generate_spectra.pl new file mode 100755 index 0000000000000000000000000000000000000000..205d7a6fc5836e8e6fdeba5d3aed8aecdef5300c --- /dev/null +++ b/eas/generate_spectra.pl @@ -0,0 +1,460 @@ +#!/usr/bin/perl -w +# /************************************************************************/ +# /* Package: ARTI */ +# /* Module: generate_spectrum.pl */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: hernan.asoreyh@iteda.cnea.gov.ar */ +# /************************************************************************/ +# /************************************************************************/ +# /* Comments: Simple meta script to generate input files from spectrum */ +# /* for all nuclei (data is read from spectra.dat) */ +# /************************************************************************/ +# /* +# LICENSE BSD-3-Clause +# Copyright (c) 2015 +# The LAGO Collaboration +# https://lagoproject.net +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# +use strict; +use warnings; +use LWP::Simple; +use JSON; + +my $VERSION="v1r9"; + +# defaults +my $pi=3.1415927; +my $site="unk"; +my $time=0; +my $prj=""; +my $file = "spectra.dat"; +my $area=1e4; +my $wdir=""; +my $user=""; +my $cluster=0; +my $clsname=""; +my $grid=0; +my $highsec=0; +my $ecut=800; +my $batch=1; +my $flat=1; +my $fixalt=0.; +my $ifixalt=0; +my $fixmodatm=0; +my $ifixmodatm=0; +my $tMin = 0; +my $tMax = 0; +my $llimit = 0.; +my $ulimit = 0.; +my $rigidity = 0.; +my $usedefaults=0; +my $gensite = 0; +my $modatm=""; +my $altitude=0.; +my $bx=0.; +my $bz=0.; + +# masses from stderr output of mass.pl +my @mid = (0, 14, 402, 703, 904, 1105, 1206, 1407, 1608, 1909, 2010, 2311, 2412, 2713, 2814, 3115, 3216, 3517, 3919, 4018, 4020, 4521, 4822, 5123, 5224, 5525, 5626); +my @mms = (0., 0.938272, 3.73338244805557, 6.53478032991106, 8.39429044902688, 10.2536061929541, 11.1787903246739, 13.045071978869, 14.898326507629, 17.6899146520668, 18.6173579550734, 21.4080199431823, 22.3362803688324, 25.1263356296296, 26.0553153433303, 28.8449660324983, 29.7745989328225, 32.5639816988633, 36.2834316370329, 37.2107457840596, 37.2142385732562, 41.8605295331555, 44.6483661801865, 47.4401999906342, 48.3681334024753, 51.1598095147594, 52.0885229269484); +my %mass = (); +for (my $i=0; $i<@mid; $i++) { + $mass {$mid[$i]} = $mms[$i]; +} + +sub get_answer { + my $question = $_[0]; + my $default = $_[1]; + my $param = $_[2]; + my $var = $_[3]; + unless ($var || $usedefaults){ + print "$question?\n<$param $default>: " if ($batch != 0); + chomp (my $tmp = <STDIN>); + $var = $tmp; + } + $var = $default unless ($var); + print "Fixed param: $param $var\n\n" if ($batch == 0); + return $var; +} + +my $help=" +$0 $VERSION +Usage: $0 options\n + +Mandatory: + -w <working dir> Where CORSIKA run files are located + -p <project name> name of the project +Recommended: + -f <file> Use file to calculate nuclei spectra, assuming a flux of the form: + j(E) = j0 * E^(-gamma), where j0=a0 x 10^-e0. + Format (See spectra.dat): + - First line: number of nuclei to process. + - Then, for each nuclei 4 lines should be included: + 1) CORSIKA particle id + 2) a0 for this nuclei + 3) e0 for this nuclei + 4) gamma for this nuclei +Optional: + -u <user name> For CORSIKA simulation (Default: none) + -t <time in sec> Flux time ( Default: 3600s) + -s <site> Choice predefined site for simulation (Default: unknown) + - Predefined sites: check the code) + - Predefined parameters: altitude, BX, BZ, and Atmospheric Model. + -k <altitude> Fix altitude even for predefined sites (It cannot be 0) + -c <Atmosph. Model> Fix Atmospheric Model even for predefined sites. + (Note: Start number with 'E' to use external atmospheres module) + -y Enable volumetric detector for flux calculations (Default: flat) + -a <HE ecuts (GeV)> Enables and set high energy cuts for ECUTS + -b <rigidity cutoff> 0 = disabled; value in GV = enabled (Default: 5.) + -m Low edge of zenith angle (THETAP) [deg] (Default: 0) + -n High edge of zenith angle (THETAP) [deg] (Default: 90) + -r Lower limit of the primary particle energy (ERANGE) [GeV] (Default: 5e0) + -i Upper limit of the primary particle energy (ERANGE) [GeV] (Default: 1e6) +Fix parameters for generic sites: + -o <BX> Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT], see values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM + -q <BZ> Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT], see values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM +Run modes: + -g Enable grid mode + -l <cluster username> Enable OAR cluster compatibility (UIS style), use -l \$USER + (and override -u) +Other: + -x Enable defaults (It doesn't prompt user for unset parameters) + -? Shows this help and exits +"; + +while (defined($_ = $ARGV[0]) && $_ =~ /^-/) { + shift; + if (/-f$/i) { + $file = $ARGV[0]; + shift; + } + if (/-u$/i) { + $user = $ARGV[0]; + shift; + } + if (/-w$/i) { + $wdir = $ARGV[0]; + shift; + } + if (/-t$/i) { + $time = $ARGV[0]; + shift; + } + if (/-s$/i) { + $site = $ARGV[0]; + shift; + } + if (/-k$/i) { + $fixalt = $ARGV[0]; + $ifixalt++; + shift; + } + if (/-c$/i) { + $fixmodatm = $ARGV[0]; + $ifixmodatm++; + shift; + } + if (/-p$/i) { + $prj = "$ARGV[0]"; + shift; + } + if (/-a$/i) { + $highsec++; + $ecut = $ARGV[0]; + shift; + } + if (/-b$/i) { + $rigidity = $ARGV[0]; + shift; + } + if (/-m$/i) { + $tMin = $ARGV[0]; + shift; + } + if (/-n$/i) { + $tMax = $ARGV[0]; + shift; + } + if (/-r$/i) { + $llimit = $ARGV[0]; + shift; + } + if (/-i$/i) { + $ulimit = $ARGV[0]; + shift; + } + if (/-o$/i) { + $bx = $ARGV[0]; + shift; + } + if (/-q$/i) { + $bz = $ARGV[0]; + shift; + } + if (/-l$/i) { + $clsname = "$ARGV[0]"; + $cluster++; + shift; + } + $grid++ if (/-g$/i); + $usedefaults++ if (/-x$/i); + $flat = 0 if (/-y$/i); + if (/-\?$/i) { + print "$help"; + exit; + } +} + +# Asking for options +print STDERR "### INTEGRATING PRIMARY SPECTRA ###\n\n"; +$file = get_answer("Spectra file", "spectra.dat", "(file)", $file); +print STDERR "\n### Project parameters ###\n\n" unless ($time && $wdir && $prj); +$prj = get_answer("Project name", "sim", "(prj)", $prj); +$wdir = get_answer("Project parent dir", ".", "(wdir)", $wdir); +$time = get_answer("Flux time [s]", 3600, "(time)", $time); +my $direct="$wdir/$prj"; +my $home = $wdir; + +$user=get_answer("User ORCID or local user","","(user)",$user); +if ($cluster != 0) { + $wdir="/opt/corsika-73500/run"; + $user=$clsname; + $home = "/home/$user"; + $direct="$home/$prj"; +} + +print STDERR "\n### Shower parameters ###\n\n" unless ($usedefaults != 0); +$tMin = get_answer("Low edge of zenith angle (THETAP) [deg]", 0, "THETPR(1)", $tMin); +$tMax = get_answer("High edge of zenith angle (THETAP) [deg]", 90, "THETPR(2)", $tMax); +$llimit = get_answer("Lower limit of the primary particle energy (ERANGE) [GeV]", 2e0, "LLIMIT", $llimit); +$ulimit = get_answer("Upper limit of the primary particle energy (ERANGE) [GeV]", 1e6, "ULIMIT", $ulimit); +if ($batch == 0) { + print STDERR "### Site parameters ###\n\n" unless ($rigidity && $modatm); +} +$rigidity = get_answer("Use rigidity cutoff? (no: <0; yes: Rigidity value [GV])", 5., "rigidity", $rigidity); +$rigidity = 0. if ($rigidity < 0); +my $userllimit=$llimit; +#all predefined sites seems to be ATMOSPHERE as default mode +my $atmcrd = "ATMOSPHERE"; + +if ($site ne "unk") { + # first, read the jsonld and build the sites hash + my $url = "https://lagoproject.github.io/DMP/defs/sitesLago.jsonld"; + my $jsonld; + die "could not get $url\n" unless (defined($jsonld = get $url)); + my $decoded = decode_json($jsonld); + my @sites_json = @{$decoded->{'@graph'}}; + my %sites = (); + foreach my $s (@sites_json) { + $sites{ $s->{'@id'} } = [ + $s->{'lago:atmcrd'}{'lago:modatm'}{'@default'}, + $s->{'lago:obsLev'}{'@default'}, + $s->{'lago:magnet'}{'@default'}{'lago:bx'}, + $s->{'lago:magnet'}{'@default'}{'lago:bz'} + ]; # 0: atm; 1: obslev(cm); 2: bx; 3: bz; + } + # second, check if + if (defined $sites{"$site"}) { + $modatm = $sites{"$site"}[0]; + $altitude = $sites{"$site"}[1]; + $bx = $sites{"$site"}[2]; + $bz = $sites{"$site"}[3]; + } else { + if ($site eq "gen" || $site eq "air" || $site eq "unk") { + print STDERR "WARNING: $site is generic. Some defaults needs to be used\n"; + $gensite = 1; + } + else { # completely unknown site. print a warning and go for unk + print STDERR "WARNING: $site is unknown. Back to manual selection\n"; + $site = "unk"; + } + } +} + +unless ($ifixmodatm != 0) { + $modatm = get_answer( + "Atmospheric model selection (ATMOD). Start number with 'E' to use external atmospheres module (ATMOSPHERE), examples: E1, E2)", $modatm, "$atmcrd", $modatm + ); + die "ERROR: missing atmospheric profile selection\n" if ($modatm eq ""); +} + +unless ($ifixalt != 0) { + while ($altitude == 0) { + $altitude = get_answer("Observation level above sea level [cm]",0,"OBSLEV", $altitude); + if ($altitude == 0) { die "ERROR: Observation level is mandatory > 0\n"; } + } +} + +while ($bx == 0) { + $bx=get_answer("Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT],\nsee values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM",0,"BX", $bx); + die "ERROR: BX is mandatory\n" if ($bx == 0); +} +while ($bz == 0) { + $bz=get_answer("Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT]",0,"BZ", $bz); + die "ERROR: BZ is mandatory\n" if ($bz == 0); +} +$altitude = $fixalt if ($ifixalt && $fixalt); +$modatm = $fixmodatm if ($ifixmodatm && $fixmodatm); +if ($gensite != 0) { + unless ($modatm ne "" && $bx && $bz && $altitude) { + die "ERROR: For generic sites, altitude (-k), atmospheric model (-c) and geomagnetic coordinates (-o, -q) are mandatory\n"; + } +} +# $modatm=uc($modatm); +# just in case :) + +###################################################### +### You should not modify anything below this line ### +###################################################### +opendir(IMD, "$direct/") or system("mkdir -p $direct"); +opendir(IMD, "$direct/") or die ("ERROR: Can't open directory $direct\n"); +closedir(IMD); + +my $fh; +open ($fh, "< $file") or die ("Error: Spectra data not found ($file)\n"); + +my $N = 0.; +if ($flat > 0) { + $N = 0.5 * ((sin($tMax * $pi / 180.))**2 - (sin($tMin * $pi / 180.))**2); +} +else { + $N = (-cos($tMax * $pi / 180.) - (-cos($tMin * $pi / 180.))); +} +$N *= (2. * $pi * $area * $time); + +my $gamma = 0.; +my $N_show= 0.; +my $j0 = 0.; +my $A = 0.; +my $alpha = 0.; +my $mantissa = 0.; +my $exponent = 0.; +my $Z = 0; +my $id = 0; +my $N_prim = 0; +my @nuc = ("", "H", "He", "Li", "Be", "B", "C", "N", "O", "F", "Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K", "Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni"); +my $mass_0 = 0.; +my %spc = (); +my $totalShowers = 0; +# print "Number of nucleus?:"; +chomp ($N_prim=<$fh>); +for (my $i = 0; $i < $N_prim; $i++) { +# Reading spectra data from file + # # print "Nucleus?: "; + chomp ($id = <$fh>); + if ($id == 14) { + $Z = 1; + $A = 0; + } + else { + $A = int ($id / 100); + $Z = $id - $A * 100; + } + # print "j0? (mantissa) : "; + chomp ($mantissa = <$fh>); + $mantissa *= 1.; + # print "e0? (exponent>0) : "; + chomp ($exponent=(<$fh>) * -1); + # print "Gamma (>0)?: "; + chomp ($gamma=(<$fh>) * -1); + $alpha = (1. + $gamma); + $j0 = $mantissa * 10**$exponent; + $mass_0 = $mass {$id}; + if ($rigidity > 0) { + my $p0 = $Z * $rigidity; + $llimit = sqrt($p0**2 + $mass_0**2); + $llimit = $userllimit if ($llimit < $userllimit); + } + #CORSIKA uses simple superposition model for nuclei + $llimit = ($A - $Z) * 0.9396 + $Z * 0.9383 if ($llimit < $mass_0); + # and finally... + my $E_reference = 1000.; # 1 TeV + $N_show = int($N * ($j0 / $alpha) * (($ulimit / $E_reference)**$alpha - ($llimit / $E_reference)**$alpha)); + $N_show = 1 if ($N_show == 0); + while (defined($spc{$N_show})) { + $N_show++; + } + $spc{$N_show} = "$A $Z $nuc[$Z] $N_show $llimit"; + $totalShowers += $N_show; + #generating input files + my $filename = sprintf("%06d-%011d.run", $id, $N_show); + my $fi; + open ($fi, "> $direct/$filename") or die "Can't open file $direct/$filename\n"; + printf $fi ("1 +$wdir +$prj +$user +%06d +0 +$N_show +$id +$gamma +%.4e +%.4e +$tMin +$tMax +-180 +180 +$altitude +$modatm +$bx +$bz +F +F +F +F +F", $id, $llimit, $ulimit); + close($fi); +} + +#generating inject file +$file = "$direct/inject"; +$altitude /= 100.; +# building descriptors +my $rig = " and using rigidity cutoff."; +$rig = " and rigidity cutoff was not used." if ($rigidity == 0); +my $vol=", using volumetric detector for flux calculations"; +$vol = ", using flat detector for flux calculations" if ($flat != 0); +my $hig=", standard energy cuts"; +$hig = ", high energy cuts at $ecut GeV" if ($highsec > 0); + +open ($fh, "> $file") or die "Can't open file $direct/$file\n"; +print $fh "Flux time: $time s ($totalShowers showers, $userllimit<E<$ulimit, $tMin<q<$tMax at site $site (h=$altitude, atm=$modatm)$vol$hig$rig\n"; +print $fh "\nA Z X N_prim E_min\n"; +print $fh "----------------------------\n"; +print $fh "$spc{$_}\n" foreach (sort {$b <=> $a} keys %spc); +close($fh); +print"\n"; +system ("cat $file"); \ No newline at end of file diff --git a/eas/mass.dat b/eas/mass.dat new file mode 100644 index 0000000000000000000000000000000000000000..7416687d13ca8fee1994608106f6816927e4e0f2 --- /dev/null +++ b/eas/mass.dat @@ -0,0 +1,25 @@ +0402 3.73338 +0703 6.53478 +0904 8.39429 +1105 10.25361 +1206 11.17879 +1407 13.04507 +1608 14.89833 +1909 17.68991 +2010 18.61736 +2311 21.40802 +2412 22.33628 +2713 25.12634 +2814 26.05532 +3115 28.84497 +3216 29.77460 +3517 32.56398 +4018 37.21075 +3919 36.28343 +4020 37.21424 +4521 41.86053 +4822 44.64837 +5123 47.44020 +5224 48.36813 +5525 51.15981 +5626 52.08852 diff --git a/eas/mass.pl b/eas/mass.pl new file mode 100755 index 0000000000000000000000000000000000000000..df73630ac3d2f24d37d84a688ddef1c7bdf7f569 --- /dev/null +++ b/eas/mass.pl @@ -0,0 +1,114 @@ +#!/usr/bin/perl -w +# /************************************************************************/ +# /* Package: ARTI */ +# /* Module: mass.pl */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: hernan.asoreyh@iteda.cnea.gov.ar */ +# /************************************************************************/ +# /* Comments: Calculate nuclei masses using the semi-empirical mass */ +# /************************************************************************/ +# /* +# LICENSE BSD-3-Clause +# Copyright (c) 2015 +# The LAGO Collaboration +# https://lagoproject.net +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ +# + +use strict; +use warnings; +my $VERSION="v1r9"; + +my $cv = 15.85; +my $cs = 18.34; +my $cc = 0.71; +my $ca = 23.21; +my $cp = 12.00; +my $mn = 939.565; +my $mp = 938.272; +my $BFSM = 0.; +my $mass = 0.; +my $id = 0; +my %masses = (); +my $tmp = <>; # discard first line +my $A = 0; +my $Z = 0; + +while (<>) { + chomp; + $id = $_; + $tmp = <>; + $tmp = <>; + $tmp = <>; + if ($id == 14) { + $BFSM = 0.; + $mass = $mp/1000.; + } + else { + $A = int($id / 100.); + $Z = int($id - $A * 100.); + my $N = $A - $Z; + + my $vol = $cv * $A; + my $sup = - $cs * $A**(2./3.); + my $cou = - $cc * $Z * ($Z-1) / $A**(1./3.); + my $asy = - $ca * (($A - 2 * $Z)**2) / $A; + my $par = $cp / (sqrt($A)); + + if (!($A%2)) { + if (!($Z%2)) { + $par *= 1.; + } + else { + $par *= -1.; + } + } + else { + $par = 0.; + } + $BFSM = $vol + $sup + $cou + $asy + $par; + $mass = ($N * $mn + $Z * $mp - $BFSM) / 1000.; + } + printf STDOUT ("%04d %.5f\n", $id, $mass); + $masses{$id} = $mass; +} +my $mass_id = "(0"; +my $mass_st = "(0."; + +foreach my $x (sort {$a <=> $b} keys %masses) { + $mass_id .= ", " . $x; + $mass_st .= ", " . $masses{$x}; +} +print STDERR "$mass_id)\n"; +print STDERR "$mass_st)\n"; \ No newline at end of file diff --git a/eas/rain.pl b/eas/rain.pl new file mode 100755 index 0000000000000000000000000000000000000000..a3858833d95b264ae555da031788d000bdcd6299 --- /dev/null +++ b/eas/rain.pl @@ -0,0 +1,616 @@ +#!/usr/bin/perl -w +# /************************************************************************/ +# /* Package: ARTI */ +# /* Module: rain.pl */ +# /************************************************************************/ +# /* Authors: Hernán Asorey */ +# /* e-mail: hernan.asoreyh@iteda.cnea.gov.ar */ +# /************************************************************************/ +# /* Comments: Main CORSIKA imput generator files and simulation launcher */ +# /* for CORSIKA. */ +# /************************************************************************/ +# /* +# LICENSE BSD-3-Clause +# Copyright (c) 2015 +# The LAGO Collaboration +# https://lagoproject.net +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN +# NO EVENT SHALL LAB DPR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# The views and conclusions contained in the software and documentation are +# those of the authors and should not be interpreted as representing +# official policies, either expressed or implied, of the LAGO Collaboration. +# +# */ +# /************************************************************************/ + +use strict; +use warnings; +use Cwd; +use JSON; +use LWP::Simple; + +my $VERSION="v1r9"; +my $tmp = ""; +my $batch = 0; +my $runmode = 0; +my $wdir = "x"; +my $crk_ver = "77402"; +my $heim = "QGSII"; +my $debug = 0; +my $help = 0; +my $slurm = 0; +my $highsec = 0; +my $curvout = ""; +my $halley = 0; +my $ithin = 0; +my $ithinh = 0; +my $ithine = 0; +my $gensite = 0; +my $thin = " \n"; +my $thine = " \n"; +my $thinh = " \n"; +my $efrcthn = 0.; +my $wmax = 0.; +my $rmax = 0.; +my $thinrath = 0.; +my $thinrate = 0.; +my $weitrath = 0.; +my $weitrate = 0.; +my $site = "unk"; +my $monoe = 0.; +my $monoq = 0; +my $monot = 0.; +my $monop = 0; +my $cherenkov = 0; +my $grid = 0; +my $imuaddi = 0; +my $nofruns = 1; +my $ecutshe = 800.; + +sub get_answer { + my $question = $_[0]; + my $default = $_[1]; + my $param = $_[2]; + my $get_tmp; + print "$question?\n<$param $default>: " unless ($batch > 0); + chomp ($get_tmp = <>); + $get_tmp = $default unless ($get_tmp); + print "Fixed param: $param $get_tmp\n\n" if ($batch == 0); + return $get_tmp; +} + +while ($_ = $ARGV[0]) { + last unless /^-/; + shift; + if (/-b$/i) { + $batch++; + } + if (/-i$/i) { + $halley++; + } + if (/-a$/i) { + $highsec++; + $curvout="CURVOUT T"; + $ecutshe = $ARGV[0]; + shift; + } + if (/-$/i) { + $highsec++; + $curvout="CURVOUT T"; + $ecutshe = $ARGV[0]; + shift; + } + if (/-t$/i) { + $ithin=1; + $efrcthn = $ARGV[0]; + shift; + $wmax = $ARGV[0]; + shift; + $rmax = $ARGV[0]; + shift; + } + if (/-s$/i) { + $site = $ARGV[0]; + shift; + } + if (/-m$/i) { + $monoe = $ARGV[0]; + shift; + } + if (/-p$/i) { + $monop = $ARGV[0]; + shift; + } + if (/-q$/i) { + $monoq = 1; + $monot = $ARGV[0]; + shift; + } + if (/-th$/i) { + $ithinh=1; + $thinrath = $ARGV[0]; + shift; + $weitrath = $ARGV[0]; + shift; + } + if (/-te$/i) { + $ithine=1; + $thinrate = $ARGV[0]; + shift; + $weitrate = $ARGV[0]; + shift; + } + if (/-\?$/i) { + $help++; + } + if (/-d$/i) { + $debug++; + } + if (/-mu$/i) { + $imuaddi=1; + } + if (/-l$/i) { + $slurm++; + } + if (/-g$/i) { + $grid=1; + } + if (/-\?$/i) { + $help++; + } + if (/-r$/i) { + $runmode++; + $wdir = $ARGV[0]; + shift; + } + if (/-v$/i) { + $crk_ver = $ARGV[0]; + shift; + } + if (/-z$/i) { + $cherenkov = 1; + } + if (/-h$/i) { + $heim = $ARGV[0]; + shift; + } +} + +my $package="corsika".$crk_ver."Linux_".$heim."_gheisha"; +$package = $package . "_thin" if ($ithin != 0); +my $usage=" + $0 $VERSION\n + Usage: $0 options\n + -b Activates batch mode + -i Disable PLOTSH and PLOTSH2 modes (usual simms production) + -d Debug mode: only shows what it should do. Don't start simulation + -r <working directory> Specify where corsika bin files are located + -v <version> Corsika version number + -h <high energy interaction model> High energy interaction model used for compilation of CORSIKA (EPOS|QGSII|SIBYLL) + -l Enables SLURM cluster compatibility (with sbatch). + -t <EFRCTHN> <WMAX> <RMAX> Enables THIN Mode (see manual for pg 62 for values) + -th <THINRAT> <WEITRAT> If THIN Mode, select different thining levels for Hadronic (THINH) ... + -te <THINRAT> <WEITRAT> ... and electromagnetic particles (THINEM) + -a <high energy ecuts (GeV)> Enables and set high energy cuts for ECUTS + -z Enables CHERENKOV mode + -mu Enables additional information from muons and EM particles + -g Enables GRID mode + -s <site> Choice site for simulation (some predefined sites: hess|sac|etn|ber|bga|lim|glr|mch|mge|and|mpc|cha|cid|mor|ccs|lsc|mbo) + -m <energy> Defines energy (in GeV) for monoenergetic showers (CHERENKOV) + -q <theta> Defines zenith angle (in degs) for fixed angle showers (CHERENKOV) + -p <prmpar> Defines primary particle (see table 4 pg 87) (CHERENKOV) + \n"; +die "$usage\n" if ($help != 0); + +print STDERR "\nWARNING! You are running in DEBUG mode. I'll only show what I should do\n\n" if ($debug != 0); +print STDERR "\nWARNING! CHERENKOV mode is enabled.\n\n" if ($cherenkov != 0); +print STDERR "\nWARNING! Site selected for simulation: $site.\n\n" unless ($site eq ""); + +if ($runmode != 0) { + die "\n\nERROR: You selected run mode without indicate working directory.\n$usage\n" if ($wdir eq "x"); +} +die "\n\nERROR: -th or -te options needs -t option.\n$usage\n" if (($ithine || $ithinh) && !($ithin)); +if ($ithin != 0) { + die "\n\nERROR: You have to specify three paramters for THIN (-t).\n$usage\n" unless ($wmax && $rmax && $efrcthn); + $thin="THIN $efrcthn $wmax $rmax\n"; +} +die "\n\nERROR: You can't specify both THINH and THINEM at the same time.\n$usage\n" if ($ithine && $ithinh); +if ($ithine != 0) { + die "\n\nERROR: You have to specify two paramters for THINE (-te).\n$usage\n" unless ($thinrate && $weitrate); + $thine="THINEM $thinrate $weitrate\n"; +} +if ($ithinh != 0) { + die "\n\nERROR: You have to specify two paramters for THINH (-th).\n$usage\n" unless ($thinrath && $weitrath); + $thinh="THINH $thinrath $weitrath\n"; +} +## ready to start +$nofruns = get_answer("Number of runs", $nofruns, "RUNS") unless ($monoe || $monoq); +my $w_dir_tmp; +if ($wdir eq "x") { + $w_dir_tmp=getcwd(); +} else { + $w_dir_tmp = $wdir; +} +if ($batch != 0) { + $w_dir_tmp=get_answer("Working directory (where CORSIKA run files are located)", "$w_dir_tmp", "WDIR"); +} else { + $wdir=get_answer("Working directory (where CORSIKA run files are located)", "$w_dir_tmp", "WDIR"); +} +my $def_prj="sims"; +$def_prj = "mono" . $site if (int($monoe) || $monoq); +my $prj=get_answer("Project name (Results will go into $wdir/<project> dir)", "$def_prj", "DIRECT"); +my $user=get_answer("User name", "LAGO", "USER"); +my $bin=$wdir."/".$package; +my $direct="$wdir/$prj"; +my $home = $wdir; +unless ($grid != 0) { + die "\n\nERROR: Couldn't find corsika at $bin. Please check\n$usage\n" unless (-e $bin); +} +system("clear"); +unless ($batch != 0) { + print "###################################################################\n"; + print "# I will run this script $nofruns times\n"; + print "# in $direct/\n"; + print "# Press enter to continue...\n"; + print "###################################################################\n"; + $tmp=<>; +} +for (my $i=0; $i < $nofruns; $i++) { + my $index = $i + 1; + unless ($batch != 0) { + system("clear"); + print "###################################################################\n"; + print "# RUN $index\n"; + print "###################################################################\n"; + print "###################################################################\n"; + print "# Simulation parameters\n"; + print "###################################################################\n"; + } + my $run_nr; + my $evt_nr; + my $prmpar; + unless ($monop != 0) { + $run_nr = get_answer("Corsika run number", $index, "RUNNR"); + $evt_nr = get_answer("number of first shower event", 0, "EVTNR"); + } + else { + $evt_nr = 1; + $prmpar = $monop; + $monop = 9 if ($monop > 6); # 9=hadrons + my $monoename = $monoe; + $monoename = 999 if ($monoename > 999); + $run_nr = int($monot + $monoename * 100. + $monop * 1e5); + } + my $N_show = get_answer("number of showers to generate", 1, "NSHOW"); + unless ($batch != 0) { + system("clear"); + print "###################################################################\n"; + print "# Primary particle parameters\n"; + print "###################################################################\n"; + } + + $prmpar = get_answer("Primary particle identification (see table 4 pg 87)", 14, "PRMPAR") unless ($monop != 0); + my $e_slope; + my $e_low; + my $e_high; + unless ($monoe != 0) { + $e_slope = get_answer("Spectral index of primary energy spectrum", -2.7, "ESLOPE"); + $e_low = get_answer("Lower limit of the primary particle energy (ERANGE) [GeV]", 1e4, "LLIMIT"); + $e_high = get_answer("Upper limit of the primary particle energy (ERANGE) [GeV]", 1e4, "ULIMIT"); + } + else { + $e_slope = -2.7; # don't used for mono-energetic showers but needed + $e_low = $e_high = $monoe; + } + my $t_low; + my $t_high; + unless ($monoq != 0) { + $t_low = get_answer("Low edge of zenith angle (THETAP) [deg]", 0, "THETPR(1)"); + $t_high = get_answer("High edge of zenith angle (THETAP) [deg]", 90, "THETPR(2)"); + } + else { + $t_low = $t_high = $monot; + } + my $f_low = get_answer("Low edge of azimuth angle (PHIP) [deg]", -180, "PHIPR(1)"); + my $f_high = get_answer("High edge of azimuth angle (PHIP) [deg]", 180, "PHIPR(2)"); + unless ($batch != 0) { + system("clear"); + print "###################################################################\n"; + print "# Observatory parameters\n"; + print "###################################################################\n"; + } + my $atmcrd = "ATMOD"; + my $modatm = ""; + my $altitude = 0.; + my $bx = 0.; + my $bz = 0.; + my $arrang = 0.; + + if ($batch == 0) { + if ($site ne "unk") { + # first, read the jsonld and build the sites hash + my $url = "https://lagoproject.github.io/DMP/defs/sitesLago.jsonld"; + my $jsonld; + die "could not get $url\n" unless (defined($jsonld = get $url)); + my $decoded = decode_json($jsonld); + my @sites_json = @{$decoded->{'@graph'}}; + my %sites = (); + foreach my $s (@sites_json) { + $sites{ $s->{'@id'} } = [ + $s->{'lago:atmcrd'}{'lago:modatm'}{'@default'}, + $s->{'lago:obsLev'}{'@default'}, + $s->{'lago:magnet'}{'@default'}{'lago:bx'}, + $s->{'lago:magnet'}{'@default'}{'lago:bz'} + ]; # 0: atm; 1: obslev(cm); 2: bx; 3: bz; + } + # second, check if + if (defined $sites{"$site"}) { + $modatm = $sites{"$site"}[0]; + $altitude = $sites{"$site"}[1]; + $bx = $sites{"$site"}[2]; + $bz = $sites{"$site"}[3]; + } + else { + if ($site eq "gen" || $site eq "air" || $site eq "unk") { + print STDERR "WARNING: $site is generic. Some defaults needs to be used\n"; + $gensite = 1; + } + else { + # completely unknown site. print a warning and go for unk + print STDERR "WARNING: site $site is unknown. Back to manual selection\n"; + $site = "unk"; + } + } + } + else { + $altitude = get_answer("Observation level above sea level [cm]", 0, "OBSLEV"); + while ($altitude == 0) { + print STDERR "Observation level is mandatory\n"; + } + $modatm = get_answer("Atmospheric model selection. Start number with 'E' to use external atmospheres module, or 'G' for GDAS module", 19, "$atmcrd"); + $bx = get_answer("Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT],\nsee values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM", 0, "BX"); + while ($bx == 0) { + print STDERR "BX is mandatory\n"; + $bx = get_answer("Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT],\nsee values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM", 0, "BX"); + } + $bz = get_answer("Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT]", 0, "BZ"); + while ($bz == 0) { + print STDERR "BZ is mandatory\n"; + $bz = get_answer("Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT]", 0, "BZ"); + } + } + } + else { + $altitude = get_answer("Observation level above sea level [cm]", 0, "OBSLEV"); + while ($altitude == 0) { + print STDERR "Observation level is mandatory\n"; + $altitude = get_answer("Observation level above sea level [cm]", 0, "OBSLEV"); + } + $modatm = get_answer("Atmospheric model selection. Start number with 'E' to use external atmospheres module, or 'G' for GDAS module", 19, "$atmcrd"); + $bx = get_answer("Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT],\nsee values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM", 0, "BX"); + while ($bx == 0) { + print STDERR "BX is mandatory\n"; + $bx = get_answer("Horizontal comp. of the Earth's mag. field (MAGNET) [North,muT],\nsee values at http://www.ngdc.noaa.gov/geomagmodels/struts/calcIGRFWMM", 0, "BX"); + } + $bz = get_answer("Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT]", 0, "BZ"); + while ($bz == 0) { + print STDERR "BZ is mandatory\n"; + $bz = get_answer("Vertical comp. of the Earth's mag. field (MAGNET) [downwards,muT]", 0, "BZ"); + } + } + if (uc(substr($modatm,0,1)) eq "E") { # using external atmospheres bernlhor + $atmcrd = "ATMOSPHERE"; + $modatm =~ s/E//g; + $modatm .= " Y"; + } else { + if (uc(substr($modatm,0,1)) eq "G") { # gdas model + $atmcrd = "ATMFILE"; + $modatm = "'atm" . lc($modatm) . ".dat'"; + $package = $package . "-atmfile"; + $bin=$wdir . "/" . $package; + die "\n\nERROR: Couldn't find corsika executable $package at $bin. Please check\n$usage\n" unless (-e $bin); + } + } + # LAGO ECUTS, minimum possible values as for the current corsika version + my @ecuts=(0.05, 0.01, 0.00005, 0.00005); + if ($highsec != 0) { + @ecuts=($ecutshe, $ecutshe, $ecutshe, $ecutshe); + $e_low = $ecutshe if ($e_low < $ecutshe); + } + unless ($batch != 0) { + print "###################################################################\n"; + print "# General (T or F) parameters\n"; + print "###################################################################\n"; + } + my $muaddi=""; # MUADDI. For v<7.4005, EMADDI AND NUADDI does not work, only MUADDI + if ($imuaddi != 0) { + if ($crk_ver eq "73500") { + $muaddi=get_answer("Get additional info for muons",'F',"MUADDI"); + } else { + $muaddi=get_answer("Get additional info for muons, EM and neutrinos",'F',"MUADDI, EMADDI, NUADDI"); + } + } + my $plotsh=get_answer("Write add- files for track plot of secondaries",'F',"PLOTSH"); + my $datbas=get_answer("Write .dbase file",'T',"DATBAS"); + my $llongi=get_answer("Track longitudinal development of secondaries (LONGI)", 'F',"LLONGI"); + my $ftabout=get_answer("Write tab output of charged particle dev file (PAROUT)",'F',"FTABOUT"); + my $s1 = int(rand(1e7)); + my $s2 = int(rand(1e7)); + my $s3 = int(rand(1e7)); + my $s4 = int(rand(1e7)); + my $cerary = "50 50 80.E2 80.E2 25 25"; + my $cards = ""; + my $plotshs = ""; + my $direct2 = $direct; + $llongi = "F"; + $datbas = "F"; + $direct2 = "." if ($grid != 0); + my $muadditxt = ""; + if ($imuaddi != 0) { + $muadditxt="MUADDI $muaddi +EMADDI $muaddi +NUADDI $muaddi"; + $muadditxt = "" if ($crk_ver * 1.0 < 74005); + } + $plotshs = "PLOTSH $plotsh" unless ($halley != 0); + $plotshs = "" if ($plotsh eq "F"); + if ($cherenkov != 0) { + $cards="RUNNR $run_nr +EVTNR $evt_nr +NSHOW $N_show +PRMPAR $prmpar +ESLOPE $e_slope +ERANGE $e_low $e_high +THETAP $t_low $t_high +PHIP $f_low $f_high +VIEWCONE 0. 0. +OBSLEV $altitude +$atmcrd $modatm +MAGNET $bx $bz +ARRANG $arrang +CERARY $cerary +FIXHEI 0. 0 +FIXCHI 0. +SEED $s1 0 0 +SEED $s2 0 0 +SEED $s3 0 0 +SEED $s4 0 0 +ECUTS $ecuts[0] $ecuts[1] $ecuts[2] $ecuts[3] +$muadditxt +MUMULT T +MAXPRT 1 +ELMFLG F T +LONGI $llongi 20. T T +ECTMAP 1.E3 +CERSIZ 1. +CERFIL T +CWAVLG 250. 700. +$plotshs +DIRECT $direct2/ +DATBAS $datbas +PAROUT T $ftabout +USER $user +EXIT +"; + } else { + $cards="RUNNR $run_nr +EVTNR $evt_nr +NSHOW $N_show +PRMPAR $prmpar +ESLOPE $e_slope +ERANGE $e_low $e_high +THETAP $t_low $t_high +PHIP $f_low $f_high +OBSLEV $altitude +$atmcrd $modatm +MAGNET $bx $bz +FIXCHI 0. +SEED $s1 0 0 +SEED $s2 0 0 +SEED $s3 0 0 +SEED $s4 0 0 +ECUTS $ecuts[0] $ecuts[1] $ecuts[2] $ecuts[3] +$curvout +$muadditxt +MUMULT T +MAXPRT 1 +ELMFLG F T +LONGI $llongi 10. T T +ECTMAP 1.E11 +$plotshs +DIRECT $direct2/ +DATBAS $datbas +PAROUT T $ftabout +$thin +$thine +$thinh +USER $user +EXIT +"; + } + unless ($batch != 0) { + system ("clear"); + print "$cards"; + print "###################################################################\n"; + print "# I will run this simulation using those parameters\n"; + print "# Please check and press ENTER to continue; CTRL-C to abort\n"; + print "###################################################################\n"; + $tmp=<>; + } + my $name = sprintf("%06d-%04d-%011d",$run_nr,$prmpar,$N_show); + my $file = "$direct/DAT$name.input"; + my $binout = sprintf("$direct/DAT%06d",$run_nr); + my $out = "$direct/DAT$name.lst"; + my $script = "$home/run-$prj-$name.sh"; + unless ($debug != 0) { + opendir(IMD, "$direct/") or system("mkdir $direct/"); + closedir(IMD); + open (my $fh ,">$file") or die "Can't open $file\n"; + print $fh "$cards"; + close($fh); + unless ($grid != 0) { + open ($fh ,">$script") or die "Can't open $script\n"; + print $fh "#!/bin/bash\n"; + print $fh "echo $name\n"; + print $fh "echo -n \"Starting simulation on \"; date\n"; + print $fh "cd $wdir\n"; + print $fh "$bin < $file > $out\n"; + print $fh "echo -n \"Simulation ended on \"; date\n"; + print $fh "echo \"compressing output files...\"\n"; + print $fh "bzip2 -9v $binout\n"; + print $fh "bzip2 -9v $out\n"; + print $fh "rm $script\n"; + close($fh); + system("chmod 777 $script"); + } + } + $name = $name . "-$prj"; + my $cmd = ""; + unless ($grid != 0) { + print "###################################################################\n"; + print "# Starting simulations $name\n"; + if ($slurm != 0) { + print "###################################################################\n"; + $cmd="sbatch -p highpri2 -o ${name}_srun_%j.log ${script}"; + } + else { + print "# in screen $name\n"; + print "###################################################################\n"; + $cmd = "screen -d -m -a -S $name $script; screen -ls"; + } + if ($debug != 0) { + print "$cmd\n"; + } + else { + system($cmd); + } + } +} +unless ($grid != 0) { + print "###################################################################\n"; + print "# BYE BYE\n"; + print "###################################################################\n"; +} \ No newline at end of file diff --git a/eas/spectra.dat b/eas/spectra.dat new file mode 100644 index 0000000000000000000000000000000000000000..9a2ceed752c8402f37c817ece4ede0065165d749 --- /dev/null +++ b/eas/spectra.dat @@ -0,0 +1,105 @@ +26 +14 +1.151 +5 +2.77 +402 +7.19 +6 +2.64 +703 +2.08 +7 +2.54 +904 +4.74 +8 +2.75 +1105 +8.95 +8 +2.95 +1206 +1.06 +6 +2.66 +1407 +2.35 +7 +2.72 +1608 +1.57 +6 +2.68 +1909 +3.28 +8 +2.69 +2010 +4.6 +7 +2.64 +2311 +7.54 +8 +2.66 +2412 +8.01 +7 +2.64 +2713 +1.15 +7 +2.66 +2814 +7.96 +7 +2.75 +3115 +2.7 +8 +2.69 +3216 +2.29 +7 +2.55 +3517 +2.94 +8 +2.68 +4018 +8.36 +8 +2.64 +3919 +5.36 +8 +2.65 +4020 +1.47 +7 +2.70 +4521 +3.04 +8 +2.64 +4822 +1.13 +7 +2.61 +5123 +6.31 +8 +2.63 +5224 +1.36 +7 +2.67 +5525 +1.35 +7 +2.46 +5626 +1.78 +6 +2.60