Skip to content

Commit

Permalink
WIP: Code cleanup (#205)
Browse files Browse the repository at this point in the history
* update get-diff shell script

* add badge

* remove unneeded imports

* shell script formatting

* code cleanup

* Update zenodo release
  • Loading branch information
harrypuuter authored Sep 14, 2023
1 parent 15c4d2b commit 73f43ea
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 52 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

<p align="left">
<a href="https://github.com/psf/black"><img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg"></a>
<a href="https://app.codacy.com/gh/KIT-CMS/CROWN/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"><img src="https://app.codacy.com/project/badge/Grade/681a25523b544d788155696eb829e38b"/></a>
<a href="https://crown.readthedocs.io/en/latest/?badge=latest"><img alt="Documentation Status" src="https://readthedocs.org/projects/crown/badge/?version=latest"></a>
<a href="https://doi.org/10.5281/zenodo.7181926"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.7181926.svg" alt="DOI"></a>
<a href="https://doi.org/10.5281/zenodo.8325327"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.8325327.svg" alt="DOI"></a>
</p>

---
Expand Down
4 changes: 1 addition & 3 deletions analysis_configurations/unittest/generate.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from os import path, makedirs
from os import path
import importlib
from code_generation.code_generation import CodeGenerator
from code_generation.friend_trees import FriendTreeConfiguration
import inspect


def run(args):
Expand Down
4 changes: 1 addition & 3 deletions analysis_configurations/unittest/generate_friends.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from os import path, makedirs
from os import path
import importlib
from code_generation.code_generation import CodeGenerator
from code_generation.friend_trees import FriendTreeConfiguration
import inspect


def run(args):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from ..quantities import output as q
from ..quantities import nanoAOD as nanoAOD
from code_generation.producer import Producer


Expand Down
2 changes: 0 additions & 2 deletions analysis_configurations/unittest/unittest_friends.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
from typing import List, Union
import os
from .producers import muon_sf_friends as muon_sf_friends
from .producers import pairquantities as pairquantities
from .producers import scalefactors as scalefactors
from .quantities import output as q

# from code_generation.configuration import Cnofiguration
Expand Down
2 changes: 1 addition & 1 deletion checks/cpp-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

for FILENAME in $(find . -name "*.[h,c]xx");
do
clang-format -i $FILENAME
clang-format -i "$FILENAME"
done

DIFF=$(git --no-pager diff)
Expand Down
22 changes: 11 additions & 11 deletions checks/get-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ if [ -z "$analysis" ] || [ -z "$base_path" ] || [ -z "$result_dir" ]; then
fi
# create the result folder if it does not exist
if [ ! -d "$result_dir" ]; then
mkdir -p $result_dir
mkdir -p "$result_dir"
fi
# go to the base_path
cd $base_path
cd "$base_path"
base_diff=$result_dir/base_diff.patch
commit_hash=$result_dir/base_commit_hash.txt
touch $base_diff
touch "$base_diff"
for next in $(git ls-files --others --exclude-standard); do
git --no-pager diff --no-index /dev/null $next >>$base_diff
git --no-pager diff --no-index /dev/null "$next" >>"$base_diff"
done
git rev-parse HEAD >$commit_hash
git rev-parse HEAD >"$commit_hash"

# cd into the analysis directory
analysis_path=$base_path/analysis_configurations/$analysis
if [ -d "$analysis_path" ]; then
cd $analysis_path
cd "$analysis_path"
analysis_diff=$result_dir/analysis_diff.patch
analysis_commit=$result_dir/analysis_commit_hash.txt
analysis_name=$result_dir/analysis_name.txt
touch $analysis_diff
touch "$analysis_diff"
for next in $(git ls-files --others --exclude-standard); do
git --no-pager diff --no-index /dev/null $next >>$analysis_diff
git --no-pager diff --no-index /dev/null "$next" >>"$analysis_diff"
done
git rev-parse HEAD >$analysis_commit
echo $analysis >$analysis_name
git rev-parse HEAD >"$analysis_commit"
echo "$analysis" >"$analysis_name"
else
analysiscommit="not_found"
echo "ERROR: analysis directory does not exist"
fi
6 changes: 3 additions & 3 deletions checks/git-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ -z "$analysis" ] || [ -z "$basepath" ]; then
exit 1
fi
# go to the basepath
cd $basepath
cd "$basepath"
# get the status of the git repo and store it in a variable
if output=$(git status --porcelain) && [ -z "$output" ]; then
crown_is_clean="true"
Expand All @@ -19,9 +19,9 @@ fi
# get the current commit hash and store it in a variable
maingitcommit=$(git rev-parse HEAD)
# cd into the analysis directory
analysispath=$basepath/analysis_configurations/$analysis
analysispath="$basepath/analysis_configurations/$analysis"
if [ -d "$analysispath" ]; then
cd $analysispath
cd "$analysispath"
# get the status of the git repo and store it in a variable
if output=$(git status --porcelain) && [ -z "$output" ]; then
analysis_is_clean="true"
Expand Down
4 changes: 2 additions & 2 deletions checks/python-formatting.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ FOUND_ISSUE=0

for FILENAME in $(find . -name "*.py");
do
black --check $FILENAME
black --check "$FILENAME"
RETURN_VALUE=$?
if [ $RETURN_VALUE -ne 0 ]
then
black --diff $FILENAME 2> /dev/null
black --diff "$FILENAME" 2> /dev/null
FOUND_ISSUE=1
fi
done
Expand Down
30 changes: 15 additions & 15 deletions checks/setup_from_tarball.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ if [ -z "$tarball" ]; then
fi
# create the checkout location if it does not exist
if [ ! -d "$checkout_location" ]; then
mkdir -p $checkout_location
mkdir -p "$checkout_location"
fi

if [ -d "$tarball" ]; then
echo "Using tarball folder $tarball"
mkdir temp
cp -r $tarball temp/
tarball=$(realpath temp/$tarball)
cp -r "$tarball" temp/
tarball=$(realpath "temp/$tarball")
# if tarball is a file, unpack it here
elif [ -f "$tarball" ]; then
echo "Using tarball file $tarball"
mkdir temp
tar -xzf $tarball -C temp/
tar -xzf "$tarball" -C temp/
tarball=$(realpath temp)
else
echo "ERROR: tarball must be a file or a folder"
exit 1
fi
# go to the checkout location
cd $checkout_location
cd "$checkout_location"
echo "Using temporary tarball copy in $tarball"
# read the commit hashes from the diff folder in the tarball
base_commit=$(cat $tarball/diff/base_commit_hash.txt)
analysis_commit=$(cat $tarball/diff/analysis_commit_hash.txt)
analysis_name=$(cat $tarball/diff/analysis_name.txt)
base_commit=$(cat "$tarball/diff/base_commit_hash.txt")
analysis_commit=$(cat "$tarball/diff/analysis_commit_hash.txt")
analysis_name=$(cat "$tarball/diff/analysis_name.txt")

# checkout the base repository with the commit hash
git clone --recursive [email protected]:KIT-CMS/CROWN
cd CROWN
git checkout $base_commit
git checkout "$base_commit"
# apply the base diff
git apply $tarball/diff/base_diff.patch
git apply "$tarball/diff/base_diff.patch"
# setup the analysis with the init script
bash init.sh $analysis_name
bash init.sh "$analysis_name"
# checkout the analysis repository with the commit hash
cd analysis_configurations/$analysis_name
git checkout $analysis_commit
cd "analysis_configurations/$analysis_name"
git checkout "$analysis_commit"
# apply the analysis diff
git apply $tarball/diff/analysis_diff.patch
git apply "$tarball/diff/analysis_diff.patch"
# cleanup the temporary tarball
rm -rf $tarball
rm -rf "$tarball"
echo "**************************************************************"
echo "* Setup from tarball finished. You can now run the analysis *"
echo "**************************************************************"
7 changes: 3 additions & 4 deletions include/SVFit/FastMTT.hxx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef FastMTT_FastMTT_H
#define FastMTT_FastMTT_H

#include "Math/LorentzVector.h"
#include "TBenchmark.h"
#include "TMatrixD.h"
#include <bitset>
#include <string>
#include <tuple>
Expand All @@ -18,10 +21,6 @@ class Functor;
} // namespace ROOT
class TVector2;

#include "Math/LorentzVector.h"
#include "TBenchmark.h"
#include "TMatrixD.h"

typedef ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double>> LorentzVector;

namespace fastMTT {
Expand Down
11 changes: 5 additions & 6 deletions init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,15 @@ if [ -z "$1" ]; then
else
if [[ "$1" == "tau" && ! -d "${SCRIPT_DIR}/analysis_configurations/tau" ]]; then
echo "Cloning analysis tau into ${SCRIPT_DIR}/analysis_configurations/tau"
git clone [email protected]:KIT-CMS/TauAnalysis-CROWN.git ${SCRIPT_DIR}/analysis_configurations/tau
git clone [email protected]:KIT-CMS/TauAnalysis-CROWN.git "${SCRIPT_DIR}/analysis_configurations/tau"
elif [[ "$1" == "earlyrun3" && ! -d "${SCRIPT_DIR}/analysis_configurations/earlyrun3" ]]; then
echo "Cloning analysis earlyrun3 into ${SCRIPT_DIR}/analysis_configurations/earlyrun3"
git clone https://github.com/khaosmos93/CROWN-config-earlyRun3.git ${SCRIPT_DIR}/analysis_configurations/earlyrun3
git clone https://github.com/khaosmos93/CROWN-config-earlyRun3.git "${SCRIPT_DIR}/analysis_configurations/earlyrun3"
elif [[ "$1" == "whtautau" && ! -d "${SCRIPT_DIR}/analysis_configurations/whtautau" ]]; then
echo "Cloning analysis whtautau into ${SCRIPT_DIR}/analysis_configurations/whtautau"
git clone [email protected]:KIT-CMS/WHTauTauAnalysis-CROWN.git ${SCRIPT_DIR}/analysis_configurations/whtautau
elif [[ "$1" == "s" && ! -d "${SCRIPT_DIR}/analysis_configurations/s" ]]
then
git clone [email protected]:KIT-CMS/WHTauTauAnalysis-CROWN.git "${SCRIPT_DIR}/analysis_configurations/whtautau"
elif [[ "$1" == "s" && ! -d "${SCRIPT_DIR}/analysis_configurations/s" ]]; then
echo "Cloning analysis s-channel into ${SCRIPT_DIR}/analysis_configurations/s"
git clone [email protected]:nfaltermann/CROWNs.git ${SCRIPT_DIR}/analysis_configurations/s
git clone [email protected]:nfaltermann/CROWNs.git "${SCRIPT_DIR}/analysis_configurations/s"
fi
fi

0 comments on commit 73f43ea

Please sign in to comment.