Skip to content

Commit

Permalink
adress comments
Browse files Browse the repository at this point in the history
  • Loading branch information
harrypuuter committed Jun 10, 2024
1 parent 0b2ed17 commit d9d73d4
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 16 deletions.
6 changes: 3 additions & 3 deletions docs/sphinx_source/correction_manager.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ For now, the CorrectionManager supports the following correction files:
- correctionlib files of type ``correction::CompoundCorrection`` using the :cpp:func:`correctionManager::CorrectionManager::loadCompoundCorrection` function
- json files using the :cpp:func:`correctionManager::CorrectionManager::loadjson` function

A Documentation of all CorrectionManager functions can be found in :ref:`Namespace: Correctionmanager`
A Documentation of all Correction Manager functions can be found in :ref:`Namespace:Correctionmanager`

Requrired Changes
Required Changes
******************

Using the CorrectionManager slightly changes the signature of CROWN functions. In the following, one simple example is shown, how to use the CorrectionManager in a CROWN executable.
Using the Correction Manager slightly changes the signature of CROWN functions. In the following, one simple example is shown, how to use the Correction Manager in a CROWN executable.

Python Producer Old

Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_source/introduction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ and source the current LCG stack (at the moment we use a nightly build)
source init.sh
after this, the framework should be installed, but without any analysis, other than the example analysis. If you want to set up a specific analysis, you can do so by adding the name of the analysis to your ``init.sh`` command. So e.g. to set the `tau` Analysis, you can do so by running
After this, the framework should be installed, but without any analysis, other than the example analysis. If you want to set up a specific analysis, you can do so by adding the name of the analysis to your ``init.sh`` command. So e.g. to set up the `tau` Analysis, you can do so by running

.. code-block:: console
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx_source/kingmaker.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Workflow Management
====================

KingMaker is a workflow management for producing ntuples with the CROWN framework. The workflow management is based on law (https://github.com/riga/law), which uses luigi (https://github.com/spotify/luigi) as the backend. Kingmaker is used to orchestrated the production of ntuples and friend trees for the CROWN framework. The workflow is designed to be flexible and can be adapted to different analyses. Kingmaker takes care of building all required CROWN executables, submitting jobs to a batch systema and writing the output to a remote storage. On top of that, Kingmaker can be used to generate FriendTrees, which can be used to store additional information in the ntuples. A sample manager is provided to manage the samples and keep track of the individual input files that have to be processed.
KingMaker is a workflow management for producing ntuples with the CROWN framework. The workflow management is based on law (https://github.com/riga/law), which uses luigi (https://github.com/spotify/luigi) as the backend. Kingmaker is used to orchestrate the production of ntuples and friend trees for the CROWN framework. The workflow is designed to be flexible and can be adapted to different analyses. Kingmaker takes care of building all required CROWN executables, submitting jobs to a batch system and writing the output to a remote storage. On top of that, Kingmaker can be used to generate FriendTrees, which can be used to store additional information in the ntuples. A sample manager is provided to manage the samples and keep track of the individual input files that have to be processed.

.. image:: ../images/kingmaker_sketch.png
:width: 900
Expand Down
36 changes: 25 additions & 11 deletions src/utility/CorrectionMananger.cxx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#include "../../include/utility/CorrectionManager.hxx"
#include "../../include/utility/Logger.hxx"
#include <fstream>
#include <memory>
#include <nlohmann/json.hpp>
#include <string>
#include <unordered_map>
#include <nlohmann/json.hpp>
#include <fstream>
/// namespace used for the CorrectionManager
namespace correctionManager {
/**
* @brief Load a correctionlib correction from a file and return it. This
* function works for most corrections found in correctionlib files (the default
* type for corrections is correction::Correction) . If the requested Correction
* is already loaded, it will return a pointer to the already loaded Correction.
* If not, the Correction will be loaded and stored in the CorrectionManager.
* type for corrections is correction::Correction) . If the requested correction
* is already loaded, it will return a pointer to the already loaded correction.
* If not, the correction will be loaded and stored in the CorrectionManager.
*
* @param filePath The path to the correctionlib file
* @param corrName The name of the correction to load
Expand All @@ -24,7 +24,9 @@ CorrectionManager::loadCorrection(const std::string &filePath,
auto filePath_it = correction_map.find(filePath);
if (filePath_it == correction_map.end()) {
Logger::get("CorrectionManager")
->debug("CorrectionFile {} not loaded yet, adding it...", filePath);
->debug("CorrectionFile {} not loaded yet, adding it to the "
"CorrectionManager...",
filePath);
auto result = correction_map.emplace(
filePath,
std::unordered_map<
Expand Down Expand Up @@ -67,7 +69,9 @@ CorrectionManager::loadCompoundCorrection(const std::string &filePath,
auto filePath_it = correctionCompound_map.find(filePath);
if (filePath_it == correctionCompound_map.end()) {
Logger::get("CorrectionManager")
->debug("CorrectionFile {} not loaded yet, adding it...", filePath);
->debug("CorrectionFile {} not loaded yet, adding it to the "
"CorrectionManager...",
filePath);
auto result = correctionCompound_map.emplace(
filePath,
std::unordered_map<
Expand Down Expand Up @@ -96,11 +100,23 @@ CorrectionManager::loadCompoundCorrection(const std::string &filePath,
}
return corrName_it->second.get();
};
const nlohmann::json *CorrectionManager::loadjson(const std::string &filePath){
/**
* @brief Load a json file from a file and return it. This
* function works works for all json files. If the requested
* json file is already loaded, it will return a pointer to the already
* loaded json. If not, the json will be loaded and
* stored in the CorrectionManager.
*
* @param filePath The path to the json file
* @return const nlohmann::json
*/
const nlohmann::json *CorrectionManager::loadjson(const std::string &filePath) {
auto json_it = json_map.find(filePath);
if (json_it == json_map.end()) {
Logger::get("CorrectionManager")
->debug("Json file {} not loaded yet, adding it...", filePath);
->debug("Json file {} not loaded yet, adding it to the "
"CorrectionManager...",
filePath);
std::ifstream json_file(filePath);
auto result = json_map.emplace(
filePath,
Expand All @@ -121,6 +137,4 @@ void CorrectionManager::report() {
n_corrections);
};



} // namespace correctionManager

0 comments on commit d9d73d4

Please sign in to comment.