-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add scripts for processing ntuples from the ntuple maker
- Loading branch information
1 parent
93bb2c6
commit 981d26e
Showing
2 changed files
with
155 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
#!/bin/bash | ||
|
||
# Make box around text @climagic | ||
function box() { t="$1xxxx";c=${2:-=}; echo ${t//?/$c}; echo "$c $1 $c"; echo ${t//?/$c}; } | ||
|
||
usage() { echo "Usage: $0 [-i <path to input txt files>] [-o <path to output directory>] [-n] (optional : for numi)" 1>&2; exit 1; } | ||
|
||
numi=false | ||
while getopts ":i:o:nh" opt; do | ||
case "$opt" in | ||
i) | ||
inputtxt="$OPTARG" | ||
;; | ||
o) | ||
outdir="$OPTARG" | ||
;; | ||
n) | ||
numi=true | ||
;; | ||
h | *) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ ! -e "$inputtxt" || -z "$outdir" ]]; then | ||
echo "Either an invalid input text file provided with -i or an invalid output directory with -o - Exiting!" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d "$outdir" ]]; then | ||
echo "Making output directory" | ||
mkdir -p "$outdir" | ||
fi | ||
|
||
if [[ "$numi" ]]; then | ||
box "Processing for NuMI" | ||
fi | ||
|
||
box "Pruning CV to "$outdir"/cv.root" | ||
prune_checkout_trees $inputtxt $outdir"/cv.root" | ||
|
||
# process systs | ||
systs=("UBGenieFluxSmallUni" \ | ||
"expskin_FluxUnisim" "horncurrent_FluxUnisim" "kminus_PrimaryHadronNormalization" \ | ||
"kplus_PrimaryHadronFeynmanScaling" "kzero_PrimaryHadronSanfordWang" "nucleoninexsec_FluxUnisim" "nucleonqexsec_FluxUnisim" "nucleontotxsec_FluxUnisim" \ | ||
"piminus_PrimaryHadronSWCentralSplineVariation" "pioninexsec_FluxUnisim" "pionqexsec_FluxUnisim" "piontotxsec_FluxUnisim" "piplus_PrimaryHadronSWCentralSplineVariation" \ | ||
\ | ||
"reinteractions_piminus_Geant4" "reinteractions_piplus_Geant4" "reinteractions_proton_Geant4") | ||
|
||
box "Launching threads for pruning the systematic files" | ||
for syst in "${systs[@]}"; do | ||
echo $syst | ||
if [[ "$numi" ]]; then | ||
prune_weightsep24_trees $inputtxt $outdir"/"$syst".root" $syst & | ||
else | ||
prune_weightsep24_trees_numi $inputtxt $outdir"/"$syst".root" $syst & | ||
fi | ||
sleep 10 | ||
done | ||
wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/bin/bash | ||
|
||
# Make box around text @climagic | ||
function box() { t="$1xxxx";c=${2:-=}; echo ${t//?/$c}; echo "$c $1 $c"; echo ${t//?/$c}; } | ||
|
||
usage() { echo "Usage: $0 [-c <path to pruned cv file>] [-s <path to folder containing pruned syst files>] [-o <path to output folder>] [-p \"prefix name for the output CV file\"]" 1>&2; exit 1; } | ||
|
||
data=false | ||
while getopts ":c:s:o:p:h" opt; do | ||
case "$opt" in | ||
c) | ||
inputcv="$OPTARG" | ||
;; | ||
s) | ||
inputsystfolder="$OPTARG" | ||
;; | ||
o) | ||
outfolder="$OPTARG" | ||
;; | ||
p) | ||
outcvname="$OPTARG" | ||
;; | ||
h | *) | ||
usage | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -z "$inputsystfolder" ]]; then | ||
echo "No input syst folder provided. Assuming data!" | ||
data=true | ||
fi | ||
|
||
if [[ -z "$outfolder" || -z "$outcvname" ]]; then | ||
echo "Either no output folder (with -o) or no output prefix provided (with -p). Exiting!" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -e "$inputcv" ]]; then | ||
echo "Provide valid input cv file with -c - Exiting!" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d "$inputsystfolder" ]]; then | ||
echo "Could not find input syst folder provided by -s - Exiting!" | ||
usage | ||
exit 1 | ||
fi | ||
|
||
if [[ ! -d "$outfolder" ]]; then | ||
echo "Making output directory" | ||
mkdir -p "$outfolder" | ||
fi | ||
|
||
if [[ ! -d $outfolder"/systs" && ! "$data" ]]; then | ||
echo "Making output directory for systs" | ||
mkdir -p $outfolder"/systs" | ||
fi | ||
|
||
|
||
systs=("UBGenieFluxSmallUni" \ | ||
"expskin_FluxUnisim" "horncurrent_FluxUnisim" "kminus_PrimaryHadronNormalization" \ | ||
"kplus_PrimaryHadronFeynmanScaling" "kzero_PrimaryHadronSanfordWang" "nucleoninexsec_FluxUnisim" "nucleonqexsec_FluxUnisim" "nucleontotxsec_FluxUnisim" \ | ||
"piminus_PrimaryHadronSWCentralSplineVariation" "pioninexsec_FluxUnisim" "pionqexsec_FluxUnisim" "piontotxsec_FluxUnisim" "piplus_PrimaryHadronSWCentralSplineVariation" \ | ||
"reinteractions_piminus_Geant4" "reinteractions_piplus_Geant4" "reinteractions_proton_Geant4") | ||
|
||
# process CV first | ||
box "Processing CV" | ||
|
||
box "BDT Convert" | ||
bdt_convert $inputcv cv_bdt.tmp.root | ||
|
||
cvfile=$outfolder"/"$outcvname".root" | ||
|
||
box "Converting CV and writing to "$cvfile | ||
convert_cv_spec "cv_bdt.tmp.root" $cvfile | ||
rm cv_bdt.tmp.root | ||
|
||
# process systs | ||
if [[ !"$data" ]]; then | ||
box "Processing for systematics" | ||
|
||
for syst in "${systs[@]}"; do | ||
box $syst | ||
merge_xf $cvfile $inputsystfolder"/"$syst".root" $outfolder"/systs/"$syst".root" $syst & | ||
sleep 5 | ||
done | ||
wait | ||
fi |