-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from oglez/cppcodeandcichecks_dec2024
Cppcodeandcichecks dec2024
- Loading branch information
Showing
11 changed files
with
1,522 additions
and
5 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,52 @@ | ||
name: Software_check | ||
on: | ||
push: | ||
pull_request: | ||
types: [opened] | ||
jobs: | ||
check_compile-job: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: cmscloud/al9-cms:latest | ||
options: --user root | ||
steps: | ||
- name: Checking_out_code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Checking_python_3.9 | ||
run: | | ||
python3 -V | ||
ls | ||
pwd | ||
python3 -m py_compile src/cmsstyle/cmsstyle.py | ||
ls -lh src/cmsstyle/__pycache__/ | ||
- name: Checking_Cpp_compilation | ||
run: | | ||
cd src | ||
echo '{gROOT->LoadMacro("cmsstyle.C++");}' > hola.C | ||
dnf install -y root | ||
echo 'ROOT VERSION='`root-config --version` | ||
root -q hola.C | ||
ls -lh cmsstyle_C.so | ||
# | ||
py2-job: | ||
runs-on: ubuntu-latest | ||
container: | ||
image: cmscloud/cc7-cms:latest | ||
options: --user root | ||
steps: | ||
- name: Checking_python_2.7 | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# fetch-depth: 0 | ||
run: | | ||
python -V | ||
ls | ||
git clone --depth 1 https://github.com/oglez/cmsstyle.git | ||
cd cmsstyle | ||
pwd | ||
python -m py_compile src/cmsstyle/cmsstyle.py | ||
ls -lh src/cmsstyle/cmsstyle.pyc | ||
# |
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 |
---|---|---|
|
@@ -5,6 +5,8 @@ __pycache__/ | |
|
||
# C extensions | ||
*.so | ||
*.d | ||
*.pcm | ||
|
||
# Distribution / packaging | ||
.Python | ||
|
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,44 @@ | ||
# | ||
# This script, to be run in bash to setup the CMSStyle for ROOT (C++ version) | ||
# | ||
# Called with | ||
# source .../scripts/setup_cmstyle | ||
# using the directory of the actual implementation we want to use of CMSStyle. | ||
# | ||
# Written by O. Gonzalez (2024_11_12) | ||
# 2024_12_01 Changing the used directory for a real one. | ||
# | ||
fich_=${BASH_SOURCE[0]} | ||
|
||
if [ ".${fich_::1}" != "./" ] ; then # Relative directory | ||
fich_="$PWD/${fich_}" | ||
fi | ||
|
||
# Getting the simplest name of the directory | ||
if [[ ${fich_:(-22):1} == "/" ]] ; then | ||
cd ${fich_::-21} >& /dev/null | ||
else # We are in scripts! | ||
cd .. >& /dev/null | ||
fi | ||
export CMSSTYLE_DIR=`pwd -P` | ||
cd - >& /dev/null | ||
|
||
echo "Using CMSStyle located in $CMSSTYLE_DIR" | ||
|
||
# Setting up the related variables: | ||
|
||
if [[ ! $ROOT_INCLUDE_PATH == *"${CMSSTYLE_DIR}/src"* ]]; then | ||
export ROOT_INCLUDE_PATH=${CMSSTYLE_DIR}/src${ROOT_INCLUDE_PATH:+":$ROOT_INCLUDE_PATH"} | ||
fi | ||
|
||
# We also put the same version for python, in case... | ||
if [[ ".${PYTHONPATH}" != *"${CMSSTYLE_DIR}/src"* ]] ; then | ||
export PYTHONPATH=${CMSSTYLE_DIR}/src${PYTHONPATH:+":$PYTHONPATH"} | ||
fi | ||
# | ||
# Note: | ||
# The following command allows to get the location of the CMSStyle that | ||
# it is used/setup already for python: | ||
# | ||
# $ python3 -c "import cmsstyle ; print(cmsstyle.__file__)" | ||
# |
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,100 @@ | ||
///@file | ||
/// | ||
/// This code contains the declaration and definition of the class TCmsCanvas | ||
/// that inherits from a normal TCanvas en ROOT but keep track of created | ||
/// objects that are not visible to the user, for its proper deletion as the | ||
/// TCanvas is destroyed. | ||
/// | ||
/// <PRE> | ||
/// Written by O. Gonzalez (2024_11_12) | ||
/// </PRE> | ||
/// | ||
|
||
#ifndef CMSSTYLE_TCMSCANVAS__H_ | ||
#define CMSSTYLE_TCMSCANVAS__H_ | ||
|
||
#include <TCanvas.h> | ||
#include <TASImage.h> | ||
|
||
#include <vector> | ||
|
||
namespace cmsstyle { | ||
|
||
|
||
/// This is the class that CMSStyle (in the C++ version) uses to handle the | ||
/// TCanvases that are defined to be plotted, but one has to keep in mind that | ||
/// externally | ||
|
||
class TCmsCanvas : public TCanvas { | ||
|
||
// Internal variables (pointers to keep track) | ||
|
||
TASImage *CMS_logo; ///< CMS Logo when used in the TCanvas. | ||
TPad *pad_logo; ///< TPad containing the CMS logo, when used. | ||
|
||
// Internal methods | ||
|
||
/// Initialization of the internal variables... | ||
void Initialize (void) { | ||
CMS_logo=nullptr; | ||
pad_logo=nullptr; | ||
} | ||
|
||
public: | ||
|
||
/// Normal constructor: It just creates the Canvas using the arguments and | ||
/// the corresponding constructor method ot eh TCanvas. It also initializes | ||
/// the values to keep track of when needed. | ||
/// | ||
/// Arguments: | ||
/// name: Name of the created object | ||
/// title: Title for the TCanvas | ||
/// wtopx: X position of the top left corner of the canvas in pixels. | ||
/// wtopy: Y position of the top left corner of the canvas in pixels | ||
/// ww: the window size in pixels along X. | ||
/// wh: the window size in pixels along Y. | ||
/// | ||
TCmsCanvas (const char *name, | ||
const char *title, | ||
Int_t wtopx, | ||
Int_t wtopy, | ||
Int_t ww, | ||
Int_t wh) : TCanvas(name,title,wtopx,wtopy,ww,wh) { | ||
Initialize(); | ||
} | ||
|
||
/// Destructor of the class, as the most important object since it handles | ||
/// the deletion of objects defined | ||
~TCmsCanvas () { | ||
if (CMS_logo!=nullptr) delete CMS_logo; | ||
if (pad_logo!=nullptr) delete pad_logo; | ||
} | ||
|
||
|
||
/// Method to draw the CMS Logo in the defined TCanvas in a TPad set at the indicated location | ||
/// of the currently used TPad. | ||
void AddCmsLogo (Float_t x0, Float_t y0, Float_t x1, Float_t y1, const char *logofile) | ||
{ | ||
if (CMS_logo!=nullptr) delete CMS_logo; | ||
CMS_logo = new TASImage(logofile); | ||
|
||
auto oldpad = gPad; | ||
|
||
if (pad_logo!=nullptr) delete pad_logo; | ||
pad_logo = new TPad("logo", "logo", x0, y0, x1, y1); | ||
pad_logo->Draw(); | ||
pad_logo->cd(); | ||
CMS_logo->Draw("X"); | ||
pad_logo->Modified(); | ||
|
||
oldpad->cd(); | ||
} | ||
|
||
|
||
|
||
|
||
}; | ||
|
||
} // Namespace cmsstyle | ||
#endif | ||
///---------------------------------------------------------------------- |
Oops, something went wrong.