Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:18:21

0001 #!/bin/bash
0002 export LC_NUMERIC="en_US.UTF-8"
0003 unset -v IFS
0004 if [[ $# -eq 0 ]] ; then
0005     echo 'You can add more than one options'
0006     echo 'The code assumes there is no conflict with number of generated events in hepmc and inside tuning.h'    
0007     echo 'bash AustomatedSimulationChain.sh -<option1> -<option2> ...'  
0008                 echo '-N Name initials ak/cc/cn/jd are available options'
0009     echo '-v G Geometry Visulaization mode # No output file will be saved'
0010     echo '-v R Running Full simulation chain #It will generate all files'
0011     echo '-H D Default values in hepmc files'
0012     echo '-H U User defined momentum and eta range'
0013     echo '-P PDGCodes Set Particle Types(4 at max)'
0014     echo '-m <momMin> <MomMax> Lower level of momentum '
0015     echo '-e <etaMin> <etaMax> Lower level of momentum '
0016     echo '-b bin size for kinematics first argument for eta second one for momentum'
0017     echo '-E  Nevent  Number of events to be processed(Default 1000)'
0018     echo '-A 0 No analysis will be performed'
0019     echo '-A 1 Analysis will be performed'
0020     echo '-F S All user defined kinematics ranges will be generated in single  Hepmc files and so for simulation output'
0021     echo '-F B All user defined kinematics ranges will be generated in different Hepmc files (defined or 0.5 default bins) and so for simulation output'
0022     echo 'Example: '
0023     echo '   bash AutomatedSimulationChain.sh -N cc -v R -t 1 -P 211 -P 11 -m 0.05 -m 5 -e -2.5 -e -1.5 -E 1000 -A 1 -F 1'
0024     echo 'For user cc the code will run the Full simulations and analysis' 
0025     echo 'for pions and electrons of Momentum 0.05 and 5 GeV/c; at eta -1.5 and -2.5 storing files with 0.01 bins'    
0026     exit 0
0027 fi
0028 
0029 while getopts v:H:P:m:e:b:E:A:F:N: flag
0030 do 
0031         case "${flag}" in
0032                 v)  Version=${OPTARG};;
0033                 H)  Type=${OPTARG};;
0034                 P)  Part+=($OPTARG);;
0035                 m)  Mom+=($OPTARG);;
0036                 e)  Eta+=($OPTARG);;
0037                 b)  Bin=${OPTARG};;
0038                 E)  Events=${OPTARG};;
0039                 A)  Analysis=${OPTARG};;
0040                 F)  Filing=${OPTARG};;
0041                 N)  Name=${OPTARG};;
0042         esac    
0043 done
0044 shift $((OPTIND -1))
0045 ########## Folder Settings############
0046 if [[ $Name == "" ]];then
0047         echo "Provide a name initial to create directory to copy files"
0048   exit 0
0049 elif [[ $Name != "" ]]; then
0050         MyDir="./scripts/cc"
0051         LogBook="$MyDir/LogBook.txt"
0052         HepMC3Dir="./scripts/$Name/HepMC3Files"
0053         SimulationDir="./scripts/$Name/SimulationFiles"
0054         OutputDir="./scripts/$Name/OutputFiles"
0055   echo "'${OutputDir}'"
0056   mkdir -p ${HepMC3Dir} && mkdir -p ${SimulationDir} && mkdir -p ${OutputDir}
0057 fi
0058 now=$(date)
0059 
0060 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0061 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0062 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0063 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@   Start of log Book By $Name at $now@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0064 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0065 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0066 echo "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@">>$LogBook
0067 
0068 ######################################
0069 if [ $Version == "G" ]; then
0070         echo "Visulaization Mode is running"
0071         ./build/pfrich -m macro/$Name/vis.mac
0072 fi      
0073 if [ $Version == "R" ]; then  
0074         echo "Full Simulation Mode activated "
0075         if [[ $Type == "" ]]; then
0076         echo "You need to specify Hepmc Type"
0077         elif [[ $Type == "D" ]]; then
0078                 echo "Default hepmc Values are in use"
0079                 root -l "${MyDir}/hepmc_writer_two_particles.C+($Events)"
0080                 ./build/pfrich -i out.hepmc
0081                 root -l "$MyDir/multi-eval.C"
0082         elif [[ $Type == "U" ]]; then
0083                 echo "You are feeding momentum, particle pdg, eta and number of events"
0084           echo "Momentum: '${Mom[@]}' Particles: '${Part[@]}' Eta:'${Eta[@]}'"
0085                 if [[ $Filing == "S" ]]; then
0086                         moml=${Mom[0]}
0087                         momh=${Mom[1]}
0088                         etal=${Eta[0]}
0089                         etah=${Eta[1]}
0090                         if [[ $Events == "" ]]; then 
0091                         Events=1000 
0092                         echo "$Events set to ${Events}"
0093                         fi
0094                         echo "${#Part[@]} Particles are passed" 
0095                         for part in  "${Part[@]}"
0096                          do 
0097                            echo "$part"
0098                            PName+=$part","
0099                         done
0100                         echo "$PName"
0101                         echo "root -l './scripts/$Name/hepmc_writer_two_particles_full.C+($moml,$momh,$etal,$etah",${PName}"$Events)' evoked">>$LogBook
0102                         root -l "./scripts/$Name/hepmc_writer_two_particles_full.C+($moml,$momh,$etal,$etah",${PName}"$Events)"
0103                         echo "./build/pfrich -i out.hepmc -s $Events Evoked">>$LogBook
0104                         ./build/pfrich -i out.hepmc -s $Events
0105                         HepMC3File="$HepMC3Dir/out.p.$moml_$momh.eta.$etal_$etah.${PName}.hepmc"
0106                         SimulationFile="$SimulationDir/pfrich.p.$moml_$momh.eta.$etal_$etah.${PName}.root"
0107                         cp out.hepmc $HepMC3File && cp pfrich.root $SimulationFile
0108                         if [[ $Analysis == 1 ]]; then
0109                                 echo "root -l $MyDir/multi-eval.C Evoked">>$LogBook
0110                                 root -l "$MyDir/multi-eval.C"                           
0111                                 OutputFile="$OutputDir/result.p.$moml_$momh.eta.$etal_$etah.${PName}.root"
0112                                 cp output.root $OutputFile
0113                         else echo "No Anlysis Argument passed">>$LogBook
0114                         fi                              
0115                         now=$(date)
0116                         echo "############################################################">>$LogBook
0117       echo "                   Copy of Tuning file used                 ">>$LogBook
0118       echo "############################################################">>$LogBook
0119                         cat include/tuning.h>>$LogBook
0120                                 echo "!!!!!!!!!!!!!!!!File Location!!!!!!!!!!!!">>$LogBook
0121                         ls -ltrh $HepMC3File $SimulationFile $OutputFile >> $LogBook
0122                         echo "$HepMC3File $SimulationFile $OutputFile"          
0123                         echo "@@@@@@@@@@@@@@@@@@@@@Log Book Closed: $now by $Name ">>$LogBook
0124                   elif [[ $Filing == "B" ]]; then
0125                                 moml=${Mom[0]}
0126                                 momh=${Mom[1]}
0127                                 etal=${Eta[0]}
0128                                 etah=${Eta[1]}
0129                                 if [[ $Events == "" ]]; then 
0130                                 Events=1000 
0131                                 echo "$Events set to ${Events}"
0132                                 fi
0133                                 echo "${#Part[@]} Particles are passed" 
0134                                 for part in  "${Part[@]}"
0135                                         do 
0136                                         echo "$part"
0137                                         PName+=$part","
0138                                         done
0139                                 if [[ $Bin == "" ]]; then
0140                                         Bin=1.5
0141                                         for et in $(seq $etal $Bin $etah);
0142                                                 do
0143                                                         ee=`echo $et+$Bin|bc`
0144                                                         echo "Eta bins: $et $ee"
0145                                                         for pp in $(seq $moml $Bin $momh)
0146                                                                 do
0147                                                                         mom=`echo $pp+$Bin|bc`
0148                                                                         echo "Mom Bins: $pp $mom"
0149                                                                         echo "root -l '$MyDir/hepmc_writer_two_particles_user.C+($pp,$et",${PName}"$Events)' evoked">>$LogBook
0150                                                                         root -l "${MyDir}/hepmc_writer_two_particles_user.C+($pp,$et",${PName}"$Events)"
0151                                                         
0152                                                                         HepMC3File="$HepMC3Dir/out.p.$pp.eta.$et.${PName}.hepmc"
0153                                                                         echo "./build/pfrich -i out.hepmc evoked">>$LogBook
0154                                                                         ./build/pfrich -i out.hepmc -s $Events
0155                                                                         cp out.hepmc $HepMC3File && cp pfrich.root $SimulationFile
0156                                                                         SimulationFile="$SimulationDir/pfrich.p.$moml_$momh.eta.$etal_$etah.${PName}.root"
0157                                                                         echo "root -l $MyDir/multi-eval.C  evoked "
0158                                                                         if [ $Analysis == 1 ]; then 
0159                                                                                 root -l "$MyDir/multi-eval.C"
0160                                                                                 OutputFile="$OutputDir/result.p.$moml_$momh.eta.$etal_$etah.${PName}.root"
0161                                                                                 cp output.root $OutputFile
0162                                                                         else echo "You have not switched ON analysis Command"
0163                                                                         fi
0164                                                                 done
0165                                         done
0166                                         now=$(date)
0167                                         echo "############################################################">>$LogBook
0168                                         echo "                   Copy of Tuning file used                 ">>$LogBook
0169                                         echo "############################################################">>$LogBook
0170                                         cat include/tuning.h>>$LogBook
0171                                         echo "!!!!!!!!!!!!!!!!File Location!!!!!!!!!!!!">>$LogBook
0172                                         ls -ltrh $HepMC3File $SimulationFile $OutputFile >> $LogBook
0173                                         ls -ltrh $HepMC3File $SimulationFile $OutputFile >> $LogBook
0174                                         now=$(date)
0175                                         echo "@@@@@@@@@@@@@@@@@@@@@Log Book Closed: $now by $Name ">>$LogBook
0176                                         elif [[ $Bin != "" ]]; then
0177                                 BinEta=${Bin[0]}
0178                                 BinMom=${Bin[1]} 
0179                                         for et in $(seq $etal $BinEta $etah)
0180                                                 do
0181                                                         for pp in $(seq $moml $BinMom $momh)
0182                                                         do
0183                                                                 echo "root -l '$MyDir/hepmc_writer_two_particles_user.C+("out.hepmc",$pp,$et",${PName}"$Events)'   Evoked">>$LogBook
0184                                                                 root -l "$MyDir/hepmc_writer_two_particles_user.C+($pp,$et",${PName}"$Events)"
0185                                                                 HepMC3File="$HepMC3Dir/out.p.$pp.eta.$et.${PName}.hepmc"
0186                                                                 echo "./build/pfrich -i out.hepmc   Evoked">>$LogBook
0187                                                                 ./build/pfrich -i out.hepmc -s $Events
0188                                                                 cp out.hepmc $HepMC3File && cp pfrich.root $SimulationFile
0189                                                                 SimulationFile="$SimulationDir/pfrich.p.$pp.eta.$et.${PName}.root"
0190                                                                 echo "root -l $MyDir/mult-eval.C evoked">>$LogBook
0191                                                                 if [[ $Analysis == 1 ]]; then
0192                                                                         echo 'root -l "$MyDir/multi-eval.C" Evoked'
0193                                                                         root -l "$MyDir/multi-eval.C"
0194                                                                         OutputFile="$OutputDir/result.p.$pp.eta.$et.${PName}.root"
0195                                                                         cp output.root $OutputFile
0196                                                                         else echo "You have not switched ON analysis Command"
0197                                                                 fi
0198                                                         done
0199                                 done
0200                                 now=$(date)
0201                                 echo "############################################################">>$LogBook
0202                                 echo "                   Copy of Tuning file used                 ">>$LogBook
0203                                 echo "############################################################">>$LogBook
0204                                 cat include/tuning.h>>$LogBook
0205                                 echo "!!!!!!!!!!!!!!!!File Location!!!!!!!!!!!!">>$LogBook
0206                                 ls -ltrh $HepMC3File $SimulationFile $OutputFile >> $LogBook
0207                                 now=$(date)
0208                                 echo "@@@@@@@@@@@@@@@@@@@@@Log Book Closed: $now by $Name ">>$LogBook
0209                         fi                                              
0210                 fi                              
0211         else echo "Put a correct argument to run this mode"                     
0212  fi     
0213 fi