 |
DAS
3.0
Das Analysis System
|
Generic meta-information for n-tuple (including speficities to Darwin).
Wrapper for TList
information typically stored in TTree::GetUserInfo()
. The list includes information such as:
- a list of generic flags, e.g. the R parameter and jet algo (
flags
)
- some minimal software version information (
git
),
- the list of corrections applied so far (
corrections
),
- the successive commands run so far (
history
)
- and anything else that is possibly relevant (the format is flexible). The information stored in the list can be converted into a config file to reproduce identical results.
To initialise the meta information in a new TTree
, a config with flags is required:
To modify the meta information of an existing TTree
, only the tree is necessary, but the config may be compared to the existing meta information:
This is typically useful for reproducibility purposes, in the case where the config
was extracted from another TTree
at a more advanced stage.
A typical use case is to determine generic flags for the data processing:
bool isMC = metainfo.Get<
bool>(
"flags",
"isMC");
int year = metainfo.Get<
bool>(
"flags",
"year");
The metainfo
can then be used like any other UserInfo
instance. Although one is entirely free to store any sort of information, it is important to keep in mind the minimal structure of the file (see above) and respect it as much as possible. For instance, to indicate an additional correction, the preferred way is the following:
metainfo.Set<string>("corrections", "nameOfMyCorrection", "value");
#include <MetaInfo.h>
|
| MetaInfo (const IKnowWhatIAmDoing &, const char *git_repo=DARWIN_GIT_REPO, bool git_init=true) |
|
| MetaInfo (TTree *t, const boost::property_tree::ptree &config, bool git_init=true) |
|
| MetaInfo (TTree *t, bool git_init=true) |
|
| MetaInfo (TList *l, bool git_init=true) |
|
template<typename Ptr , typename ... Args> |
| MetaInfo (const Ptr &t, Args... args) |
|
| ~MetaInfo () |
|
void | Check (const boost::property_tree::ptree &) const |
|
template<unsigned h> |
unsigned | Seed (std::pair< unsigned short, unsigned short > slice={1, 0}) const |
|
std::set< Darwin::Physics::Variation > | AddVars (const std::string &, const std::vector< std::string > &, const int=Darwin::Physics::symmetric, const int=1) |
|
std::set< Darwin::Physics::Variation > | GetVars (const std::string &, const std::string &="") const |
|
std::set< Darwin::Physics::Variation > | GetVars () const |
|
| MetaInfo (const IKnowWhatIAmDoing &, const char *git_repo=DARWIN_GIT_REPO, bool git_init=true) |
|
| MetaInfo (TTree *t, const boost::property_tree::ptree &config, bool git_init=true) |
|
| MetaInfo (TTree *t, bool git_init=true) |
|
| MetaInfo (TList *l, bool git_init=true) |
|
template<typename Ptr , typename ... Args> |
| MetaInfo (const Ptr &t, Args... args) |
|
| ~MetaInfo () |
|
void | Check (const boost::property_tree::ptree &) const |
|
template<unsigned h> |
unsigned | Seed (std::pair< unsigned short, unsigned short > slice={1, 0}) const |
|
std::set< Darwin::Physics::Variation > | AddVars (const std::string &, const std::vector< std::string > &, const int=Darwin::Physics::symmetric, const int=1) |
|
std::set< Darwin::Physics::Variation > | GetVars (const std::string &, const std::string &="") const |
|
std::set< Darwin::Physics::Variation > | GetVars () const |
|
template<typename... Args> |
TList * | List (const char *key, Args... args) const |
|
TList * | List () const |
|
template<class T , typename... Args> |
T | Get (const char *key, Args... args) const |
|
template<typename... Args> |
bool | Find (const char *key, Args... args) const |
|
template<class T , typename... Args> |
void | Set (const char *key, Args... args) const |
|
| UserInfo (const char *="UserInfo") |
|
| UserInfo (const boost::property_tree::ptree &) |
|
| UserInfo (TList *) |
|
| UserInfo (TTree *) |
|
| UserInfo (TTree *, const boost::property_tree::ptree &) |
|
| ~UserInfo () |
|
void | Write () const |
|
bool | Empty () const |
|
boost::property_tree::ptree | Write (std::ostream &, Format=INFO) const |
|
boost::property_tree::ptree | Write (const std::filesystem::path &) const |
|
boost::property_tree::ptree | MkPtree (Format format=INFO) const |
|
void | ls () const |
|
template<typename... Args> |
TList * | List (const char *key, Args... args) const |
|
TList * | List () const |
|
template<class T , typename... Args> |
T | Get (const char *key, Args... args) const |
|
template<typename... Args> |
bool | Find (const char *key, Args... args) const |
|
template<class T , typename... Args> |
void | Set (const char *key, Args... args) const |
|
| UserInfo (const char *="UserInfo") |
|
| UserInfo (const boost::property_tree::ptree &) |
|
| UserInfo (TList *) |
|
| UserInfo (TTree *) |
|
| UserInfo (TTree *, const boost::property_tree::ptree &) |
|
| ~UserInfo () |
|
void | Write () const |
|
bool | Empty () const |
|
boost::property_tree::ptree | Write (std::ostream &, Format=INFO) const |
|
boost::property_tree::ptree | Write (const std::filesystem::path &) const |
|
boost::property_tree::ptree | MkPtree (Format format=INFO) const |
|
void | ls () const |
|
|
static std::map< std::string, std::string > | versions |
|
|
void | GitInit () |
|
void | PrintStatus () const |
|
bool | AllChangesCommitted () const |
|
void | SetupGit (bool) |
|
void | SetupVersions () |
|
void | UpdateList (const bool) const |
|
| MetaInfo (bool, const char *) |
|
| MetaInfo (TTree *, const boost::property_tree::ptree &, bool, const char *) |
|
| MetaInfo (TTree *, bool, const char *) |
|
| MetaInfo (TList *, bool, const char *) |
|
void | GitInit () |
|
void | PrintStatus () const |
|
bool | AllChangesCommitted () const |
|
void | SetupGit (bool) |
|
void | SetupVersions () |
|
void | UpdateList (const bool) const |
|
| MetaInfo (bool, const char *) |
|
| MetaInfo (TTree *, const boost::property_tree::ptree &, bool, const char *) |
|
| MetaInfo (TTree *, bool, const char *) |
|
| MetaInfo (TList *, bool, const char *) |
|
|
enum | Format {
INFO,
JSON,
XML,
INFO,
JSON,
XML
} |
|
enum | Format {
INFO,
JSON,
XML,
INFO,
JSON,
XML
} |
|
void | ConvertPtree (const boost::property_tree::ptree &, const std::string &, TList *) |
|
boost::property_tree::ptree | MkPtree (TList *, Format=INFO) const |
|
boost::property_tree::ptree | Write (const boost::property_tree::ptree &, std::ostream &, Format=INFO) const |
|
void | ConvertPtree (const boost::property_tree::ptree &, const std::string &, TList *) |
|
boost::property_tree::ptree | MkPtree (TList *, Format=INFO) const |
|
boost::property_tree::ptree | Write (const boost::property_tree::ptree &, std::ostream &, Format=INFO) const |
|
◆ MetaInfo() [1/18]
MetaInfo |
( |
bool |
git_init, |
|
|
const char * |
origin |
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
284 int preseed = time(
nullptr) % numeric_limits<int>::max();
285 Set<int>(
"preseed", preseed);
◆ MetaInfo() [2/18]
MetaInfo |
( |
TTree * |
t, |
|
|
const boost::property_tree::ptree & |
config, |
|
|
bool |
git_init, |
|
|
const char * |
origin |
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
312 if (
config.count(
"history"))
313 Set<string>(
"history",
config.get<
string>(
"history"));
315 if (
config.count(
"preseed"))
316 Set<int>(
"preseed",
config.get<
int>(
"preseed"));
318 int preseed = time(
nullptr) % numeric_limits<int>::max();
319 Set<int>(
"preseed", preseed);
325 Set<string>(
"git",
"commit",
config.get<
string>(
"git.commit"));
326 Set<bool>(
"git",
"reproducible",
config.get<
bool>(
"git.reproducible"));
331 catch (
const pt::ptree_error& e) {
332 BOOST_THROW_EXCEPTION(e);
◆ MetaInfo() [3/18]
MetaInfo |
( |
TTree * |
t, |
|
|
bool |
git_init, |
|
|
const char * |
origin |
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
340 if (!git_init)
return;
◆ MetaInfo() [4/18]
MetaInfo |
( |
TList * |
l, |
|
|
bool |
git_init, |
|
|
const char * |
origin |
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
349 if (!git_init)
return;
◆ MetaInfo() [5/18]
Special constructor for very specific cases.
Constsructor for first call ever. This creates a minimal MetaInfo.
This is a low-level constructor and the produced MetaInfo lacks some information:
- The preseed is chosen randomly.
- The caller is responsible for populating "flags".
- No command history is recorded.
- git.complete is set to false. Do not use this constructor.
◆ MetaInfo() [6/18]
MetaInfo |
( |
TTree * |
t, |
|
|
const boost::property_tree::ptree & |
config, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constructor.
The second parameter should be extracted from the config file or from the command line. At first call, the userinfo will be set; at any next call, the userinfo and the config will be compared.
The preseed is taken from the config file or generated on the fly in a non-reproducible way. Use getMetaInfo
for see how to force the seed to a value from the config file.
- Parameters
-
t | `TTree` whose `UserInfo` will be populated |
config | input config (must include flags) |
◆ MetaInfo() [7/18]
MetaInfo |
( |
TTree * |
t, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constsructor for call of existing n-tuple. By default, the git.complete
flag will be reset to false
. It should be set to true
after the event loop in the executable.
- Parameters
-
t | `TTree` whose `UserInfo` will be modified |
git_init | flag to init git repo |
◆ MetaInfo() [8/18]
MetaInfo |
( |
TList * |
l, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constsructor for direct call to a list (typically from a projection). By default, the git.complete
will be kept as it is.
- Parameters
-
l | `TList` that will be modified |
git_init | flag to init git repo |
◆ MetaInfo() [9/18]
MetaInfo |
( |
const Ptr & |
t, |
|
|
Args... |
args |
|
) |
| |
|
inline |
Generic constsructor for smart pointers.
◆ ~MetaInfo() [1/2]
Destructor (releases memory & shuts down Git).
356 if (
repo ==
nullptr)
return;
357 git_repository_free(
repo);
358 git_libgit2_shutdown();
◆ MetaInfo() [10/18]
Used internally to set the git repo location (last parameter).
◆ MetaInfo() [11/18]
MetaInfo |
( |
TTree * |
, |
|
|
const boost::property_tree::ptree & |
, |
|
|
bool |
, |
|
|
const char * |
|
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
◆ MetaInfo() [12/18]
MetaInfo |
( |
TTree * |
, |
|
|
bool |
, |
|
|
const char * |
|
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
◆ MetaInfo() [13/18]
MetaInfo |
( |
TList * |
, |
|
|
bool |
, |
|
|
const char * |
|
|
) |
| |
|
private |
Used internally to set the git repo location (last parameter).
◆ MetaInfo() [14/18]
Special constructor for very specific cases.
Constsructor for first call ever. This creates a minimal MetaInfo.
This is a low-level constructor and the produced MetaInfo lacks some information:
- The preseed is chosen randomly.
- The caller is responsible for populating "flags".
- No command history is recorded.
- git.complete is set to false. Do not use this constructor.
◆ MetaInfo() [15/18]
MetaInfo |
( |
TTree * |
t, |
|
|
const boost::property_tree::ptree & |
config, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constructor.
The second parameter should be extracted from the config file or from the command line. At first call, the userinfo will be set; at any next call, the userinfo and the config will be compared.
The preseed is taken from the config file or generated on the fly in a non-reproducible way. Use getMetaInfo
for see how to force the seed to a value from the config file.
- Parameters
-
t | `TTree` whose `UserInfo` will be populated |
config | input config (must include flags) |
◆ MetaInfo() [16/18]
MetaInfo |
( |
TTree * |
t, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constsructor for call of existing n-tuple. By default, the git.complete
flag will be reset to false
. It should be set to true
after the event loop in the executable.
- Parameters
-
t | `TTree` whose `UserInfo` will be modified |
git_init | flag to init git repo |
◆ MetaInfo() [17/18]
MetaInfo |
( |
TList * |
l, |
|
|
bool |
git_init = true |
|
) |
| |
|
inline |
Constsructor for direct call to a list (typically from a projection). By default, the git.complete
will be kept as it is.
- Parameters
-
l | `TList` that will be modified |
git_init | flag to init git repo |
◆ MetaInfo() [18/18]
MetaInfo |
( |
const Ptr & |
t, |
|
|
Args... |
args |
|
) |
| |
|
inline |
Generic constsructor for smart pointers.
◆ ~MetaInfo() [2/2]
Destructor (releases memory & shuts down Git).
◆ AddVars() [1/2]
Define a family of uncertainties.
This function offers a unique proxy to define a large number of similar uncertainties, including various sources, correlation bits, up and down variations, and replicas. For instance, for various JES uncertainties:
auto variations = metainfo.AddVars(RecJet::ScaleVar, {"FlavourQCD",
or for a hundred replicas (e.g. when the seed of a generator is changed):
auto variations = metainfo.AddVars(GenEvent::WeightVar, {
"Replica"}, 100,
replicas);
or for the impact of a binned correction caused by physics objects on the whole event (where 20 is the number of bins):
auto variations = metainfo.AddVars(RecEvent::WeightVar, {
"Prefiring"}, 20,
symmetric |
replicas);
or for to express partial correlations:
auto variations = metainfo.AddVars(RecJet::WeightVar, {
"bSFstat"}, 3,
symmetric |
bits);
- Parameters
-
group | group |
names | names |
vartype | variation type |
n | number of members (replicas or correlation bit) |
421 set<DP::Variation> variations;
423 size_t index =
Find(
"variations", group.c_str()) ?
424 List(
"variations", group.c_str())->GetSize() : 0;
427 BOOST_THROW_EXCEPTION(
428 invalid_argument(
"The number of members must be larger than 0."));
430 if (vartype ==
single && n != 1)
431 BOOST_THROW_EXCEPTION(
432 invalid_argument(
"Single variations must have exactly one member."));
434 const vector suffixes = (vartype &
symmetric) ? vector{
"Up"s,
"Down"s}
437 for (
auto name: names) {
440 for (
const auto& suffix: suffixes) {
441 string fullname =
name + suffix;
442 Set<int>(
"variations", group.c_str(), fullname.c_str(), n);
446 for (
int i = 1; i <= n; ++i)
447 for (
const auto& suffix: suffixes)
448 variations.emplace(group,
name + suffix, ++index, i);
◆ AddVars() [2/2]
Define a family of uncertainties.
This function offers a unique proxy to define a large number of similar uncertainties, including various sources, correlation bits, up and down variations, and replicas. For instance, for various JES uncertainties:
auto variations = metainfo.AddVars(RecJet::ScaleVar, {"FlavourQCD",
or for a hundred replicas (e.g. when the seed of a generator is changed):
auto variations = metainfo.AddVars(GenEvent::WeightVar, {
"Replica"}, 100,
replicas);
or for the impact of a binned correction caused by physics objects on the whole event (where 20 is the number of bins):
auto variations = metainfo.AddVars(RecEvent::WeightVar, {
"Prefiring"}, 20,
symmetric |
replicas);
or for to express partial correlations:
auto variations = metainfo.AddVars(RecJet::WeightVar, {
"bSFstat"}, 3,
symmetric |
bits);
◆ AllChangesCommitted() [1/2]
bool AllChangesCommitted |
( |
| ) |
const |
|
private |
Function to check possibly uncommitted changes per file. It calls internally MetaInfo::get_one_status
with a foreach loop.
- Returns
true
if all changes have been committed
◆ AllChangesCommitted() [2/2]
bool AllChangesCommitted |
( |
| ) |
const |
|
private |
Function to check possibly uncommitted changes per file. It calls internally MetaInfo::get_one_status
with a foreach loop.
- Returns
true
if all changes have been committed
◆ Check() [1/2]
void Check |
( |
const boost::property_tree::ptree & |
config | ) |
const |
Compare the meta information with the config given in argument. Either warnings or errors are thrown according to the severity of the inconsistencies. It also completes the records of successive commands.
363 const auto& flagsOut =
config.get_child_optional(
"flags");
365 hash<pt::ptree> Hash;
367 if (Hash(*flagsOut) != Hash(flagsIn)) {
368 string what =
"Inconsistent flags between metainfo and config";
369 BOOST_THROW_EXCEPTION( invalid_argument(what) );
374 const auto& git =
config.get_child_optional(
"git");
378 if (
auto child = git->get_child_optional(
"repo"); child && child->size() > 0)
379 cerr <<
orange <<
"Warning: input config was built from a workflow with more than one base repo.\n" <<
def;
380 else if (
auto child = git->get_child_optional(
"commit"); child && child->size() > 0)
381 cerr <<
orange <<
"Warning: input config was built from a workflow with more than one commit.\n" <<
def;
383 else if (Get<fs::path>(
"git",
"repo") != git->get<fs::path>(
"repo"))
384 cerr <<
orange <<
"Warning: inconsistent repositories between metainfo ("
385 << Get<fs::path>(
"git",
"repo") <<
") and config ("
386 << git->get<fs::path>(
"repo") <<
").\n" <<
def;
387 else if (Get<string>(
"git",
"commit") != git->get<
string>(
"commit"))
388 cerr <<
orange <<
"Warning: inconsistent commits between metainfo ("
389 << Get<string>(
"git",
"commit") <<
") and config ("
390 << git->get<
string>(
"commit") <<
").\n" <<
def;
391 else if (!git->get<
bool>(
"complete"))
392 cerr <<
orange <<
"Warning: the input config was generated from an incomplete file.\n" <<
def;
393 else if (!git->get<
bool>(
"reproducible"))
394 cerr <<
orange <<
"Warning: the input config was generated from an irreproducible file.\n" <<
def;
396 cerr <<
green <<
"Expecting to reproduce the same result as the one used to generate the input config!\n" <<
def;
399 if (
config.count(
"history"))
400 Set<string>(
"history",
config.get<
string>(
"history"));
402 if (
config.count(
"preseed")) {
403 auto c =
config.get<
int>(
"preseed"),
404 s = Get<int>(
"preseed");
406 cerr <<
orange <<
"The preseed in the sample (" << s <<
") differs from the preseed in the config (" << c <<
"). The value from the config will be " <<
bold <<
"ignored" <<
normal <<
".\n" <<
def;
409 catch (
const pt::ptree_error& e) {
410 string what =
"Problem while reading input config: "s + e.what();
411 BOOST_THROW_EXCEPTION( pt::ptree_error(what) );
◆ Check() [2/2]
void Check |
( |
const boost::property_tree::ptree & |
| ) |
const |
Compare the meta information with the config given in argument. Either warnings or errors are thrown according to the severity of the inconsistencies. It also completes the records of successive commands.
◆ get_one_status() [1/2]
int get_one_status |
( |
const char * |
p, |
|
|
unsigned int |
, |
|
|
void * |
data |
|
) |
| |
|
staticprivate |
Function to check if a file is ignored.
- Returns
- EXIT_SUCCESS or EXIT_FAILURE
- Parameters
-
p | path to file |
data | pointer to `git_repository` |
42 auto repo =
static_cast<git_repository *
>(
data);
48 return (ignore == 1) ? EXIT_SUCCESS : EXIT_FAILURE;
◆ get_one_status() [2/2]
static int get_one_status |
( |
const char * |
, |
|
|
unsigned int |
, |
|
|
void * |
|
|
) |
| |
|
staticprivate |
Function to check if a file is ignored.
- Returns
- EXIT_SUCCESS or EXIT_FAILURE
◆ GetVars() [1/4]
Retrieve all variations, including the nominal one.
◆ GetVars() [2/4]
Retrieve all variations, including the nominal one.
490 const TList * groupList =
List(
"variations");
491 for (
const TObject * groupObj: *groupList) {
492 const string group = groupObj->GetName();
493 variations.merge(
GetVars(group));
◆ GetVars() [3/4]
Retrieve a series of uncertainties.
◆ GetVars() [4/4]
Retrieve a series of uncertainties.
- Parameters
-
group | group |
expression | regex search |
457 set<DP::Variation> variations;
459 if (!
Find(
"variations", group.c_str()))
460 BOOST_THROW_EXCEPTION( invalid_argument(
"No variation found for "s + group) );
463 for (
const TObject * obj: *
List(
"variations", group.c_str())) {
464 const char *
name = obj->GetName();
465 auto n = Get<int>(
"variations", group.c_str(),
name);
467 BOOST_THROW_EXCEPTION(
468 invalid_argument(
"The number of members must be larger than 0."));
471 regex re(expression);
472 if (regex_search(
name, re))
473 for (
int i = 1; i <= n; ++i)
474 variations.emplace(group,
name, ++index, i);
478 catch (
const regex_error& e) {
479 BOOST_THROW_EXCEPTION(e);
◆ GitInit() [1/2]
Inits and opens git repo, sets sha
to the value at running time.
57 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Empty path to Git repository",
origin, make_error_code(errc::invalid_argument)));
61 BOOST_THROW_EXCEPTION(fs::filesystem_error(
"Git repository cannot be found",
origin, make_error_code(errc::not_a_directory)));
69 git_object * head_commit =
nullptr;
71 git_error = git_revparse_single(&head_commit,
repo,
"HEAD^{commit}");
74 "(check if $DARWIN_GIT_REPO has been defined and points to the root of the git repository)"));
75 auto commit =
reinterpret_cast<git_commit *
>(head_commit);
78 const git_oid *
id = git_commit_id(commit);
80 git_oid_tostr(
sha, 16,
id);
84 const git_signature * author = git_commit_author(commit);
86 cerr <<
underline <<
"latest commit" <<
def <<
": " << git_commit_message(commit)
87 <<
" by " << author->name <<
" (" <<
sha <<
")\n";
90 git_commit_free(commit);
◆ GitInit() [2/2]
Inits and opens git repo, sets sha
to the value at running time.
◆ libgit2_version() [1/2]
std::string libgit2_version |
( |
| ) |
|
|
static |
- Returns
- string with libgit2 version.
264 int major, minor, rev;
266 int git_error = git_libgit2_version(&major, &minor, &rev);
268 BOOST_THROW_EXCEPTION(runtime_error(
"Unable to get libgit2 version"));
269 return Form(
"%d.%d.%d", major, minor, rev);
◆ libgit2_version() [2/2]
static std::string libgit2_version |
( |
| ) |
|
|
static |
- Returns
- string with libgit2 version.
◆ PrintStatus() [1/2]
void PrintStatus |
( |
| ) |
const |
|
private |
◆ PrintStatus() [2/2]
void PrintStatus |
( |
| ) |
const |
|
private |
Mimicks git status
.
Adapted from this example. See also the documentation.
95 git_status_list * status =
nullptr;
101 const size_t maxi = git_status_list_entrycount(status);
103 for (
size_t i = 0; i < maxi; ++i) {
104 const git_status_entry * s = git_status_byindex(status, i);
106 if (s->status == GIT_STATUS_CURRENT)
continue;
107 if (s->status & GIT_STATUS_IGNORED)
continue;
111 const char * extra =
"",
116 if (s->status & GIT_STATUS_INDEX_NEW ) istatus =
'A';
117 else if (s->status & GIT_STATUS_INDEX_MODIFIED ) istatus =
'M';
118 else if (s->status & GIT_STATUS_INDEX_DELETED ) istatus =
'D';
119 else if (s->status & GIT_STATUS_INDEX_RENAMED ) istatus =
'R';
120 else if (s->status & GIT_STATUS_INDEX_TYPECHANGE) istatus =
'T';
122 if (s->status & GIT_STATUS_WT_NEW) {
123 if (istatus ==
' ') { istatus =
'?'; }
126 else if (s->status & GIT_STATUS_WT_MODIFIED ) wstatus =
'M';
127 else if (s->status & GIT_STATUS_WT_DELETED ) wstatus =
'D';
128 else if (s->status & GIT_STATUS_WT_RENAMED ) wstatus =
'R';
129 else if (s->status & GIT_STATUS_WT_TYPECHANGE) wstatus =
'T';
130 if (istatus ==
'?' && wstatus ==
'?')
continue;
133 if (s->index_to_workdir &&
134 s->index_to_workdir->new_file.mode == GIT_FILEMODE_COMMIT) {
135 unsigned int smstatus = 0;
138 if (!git_submodule_status(&smstatus,
repo, s->index_to_workdir->new_file.path,
139 GIT_SUBMODULE_IGNORE_UNSPECIFIED)) {
140 if (smstatus & GIT_SUBMODULE_STATUS_WD_MODIFIED ) extra =
" (new commits)";
141 else if (smstatus & GIT_SUBMODULE_STATUS_WD_INDEX_MODIFIED) extra =
" (modified content)";
142 else if (smstatus & GIT_SUBMODULE_STATUS_WD_WD_MODIFIED ) extra =
" (modified content)";
143 else if (smstatus & GIT_SUBMODULE_STATUS_WD_UNTRACKED ) extra =
" (untracked content)";
148 if (s->head_to_index) {
149 a = s->head_to_index->old_file.path;
150 b = s->head_to_index->new_file.path;
152 if (s->index_to_workdir) {
153 if (!a) a = s->index_to_workdir->old_file.path;
154 if (!b) b = s->index_to_workdir->old_file.path;
155 c = s->index_to_workdir->new_file.path;
158 cerr << istatus << wstatus <<
' ' << a;
159 if (istatus ==
'R')
cerr <<
' ' << b;
160 if (wstatus ==
'R')
cerr <<
' ' << c;
161 cerr << extra <<
'\n';
164 for (
size_t i = 0; i < maxi; ++i) {
166 const git_status_entry * s = git_status_byindex(status, i);
167 if (s->status != GIT_STATUS_WT_NEW)
continue;
168 cerr <<
"?? " << s->index_to_workdir->old_file.path <<
'\n';
171 git_status_list_free(status);
◆ Seed() [1/2]
unsigned Seed |
( |
std::pair< unsigned short, unsigned short > |
slice = {1,0} | ) |
const |
|
inline |
Generate the seed in a reproducible way:
\[ s = h + (k+1) \times b \]
where
- $h$ is hard-coded in the program and should be different for every call of the functor,
- $k$ corresponds to the (incremented) slice index,
- and $b$ should be different for every sample (a.k.a. preseed).
- Parameters
-
234 unsigned b = Get<int>(
"preseed");
235 unsigned k = slice.second;
236 return h + (k+1) * b;
◆ Seed() [2/2]
unsigned Seed |
( |
std::pair< unsigned short, unsigned short > |
slice = {1,0} | ) |
const |
|
inline |
Generate the seed in a reproducible way:
\[ s = h + (k+1) \times b \]
where
- $h$ is hard-coded in the program and should be different for every call of the functor,
- $k$ corresponds to the (incremented) slice index,
- and $b$ should be different for every sample (a.k.a. preseed).
- Parameters
-
234 unsigned b = Get<int>(
"preseed");
235 unsigned k = slice.second;
236 return h + (k+1) * b;
◆ SetupGit() [1/2]
void SetupGit |
( |
bool |
git_init | ) |
|
|
private |
Fills in git information in the MetaInfo.
182 bool all_changes_committed =
false;
186 if (!all_changes_committed) {
187 cerr <<
orange <<
"Warning: uncommited changes.\n";
192 Set<string>(
"git",
"commit",
string(
sha));
194 Set<fs::path>(
"git",
"repo" ,
origin );
195 Set<bool> (
"git",
"reproducible", all_changes_committed);
196 Set<bool> (
"git",
"complete" ,
false );
◆ SetupGit() [2/2]
Fills in git information in the MetaInfo.
◆ SetupVersions() [1/2]
Fills in software version information in the MetaInfo.
◆ SetupVersions() [2/2]
Fills in software version information in the MetaInfo.
202 string const& soft =
version.first,
204 Set<string>(
"software", soft.c_str(), vers);
◆ UpdateList() [1/2]
void UpdateList |
( |
const bool |
assumeComplete | ) |
const |
|
private |
Update list with present git information. The flags
and git
blocks are expected to be found, otherwise it crashes smoothly. Then it updates the Git information.
- Parameters
-
assumeComplete | should assume completeness (typically `false` for event loops) |
211 BOOST_THROW_EXCEPTION(invalid_argument(
"No metainfo in input to update."));
214 BOOST_THROW_EXCEPTION(invalid_argument(
"Missing git information in input."));
218 if (
origin != Get<fs::path>(
"git",
"repo")) {
219 cerr <<
orange <<
"Warning: inconsistent repositories between input and output.\n" <<
def;
220 Set<fs::path>(
"git",
"repo",
origin);
222 else if (
sha != Get<string>(
"git",
"commit")) {
223 cerr <<
orange <<
"Warning: inconsistent commits between input and output.\n" <<
def;
224 Set<string>(
"git",
"commit",
string(
sha));
228 if (!all_changes_committed) {
229 cerr <<
orange <<
"Warning: uncommited changes.\n";
233 auto reproducible = Get<bool>(
"git",
"reproducible");
235 cerr <<
orange <<
"Warning: input tree not reproducible.\n" <<
def;
236 Set<bool>(
"git",
"reproducible", all_changes_committed && reproducible);
238 auto complete = Get<bool>(
"git",
"complete");
240 cerr <<
orange <<
"Warning: input tree not complete.\n" <<
def;
241 Set<bool>(
"git",
"complete", assumeComplete && complete);
246 string const& soft =
version.first,
248 if (!
Find(
"software", soft.c_str()))
continue;
249 auto vers2 = Get<string>(
"software", soft.c_str());
251 if (vers1 == vers2)
continue;
252 cerr <<
orange <<
"Warning: inconsistent " << soft <<
" versions ("
253 << vers1 <<
" vs " << vers2 <<
")\n" <<
def;
258 if (!
Find(
"preseed"))
259 BOOST_THROW_EXCEPTION(invalid_argument(
"No preseed could be found."));
◆ UpdateList() [2/2]
void UpdateList |
( |
const bool |
| ) |
const |
|
private |
Update list with present git information. The flags
and git
blocks are expected to be found, otherwise it crashes smoothly. Then it updates the Git information.
◆ git_error
C-style error code from Git operations (see source code)
◆ origin
const std::filesystem::path origin |
|
private |
path to local repo determined at compilation time
◆ repo
pointer to local Git repo
◆ sha
commit SHA at running time
◆ versions
static std::map< std::string, std::string > versions |
|
static |
Initial value:= {
{"gpp" , Form("%d.%d.%d", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)},
{"Cpp" , Form("C++%ld", __cplusplus/100-2000)},
{"ROOT" , gROOT->GetVersion()},
{"Boost" , BOOST_LIB_VERSION},
}
software version
The documentation for this class was generated from the following files:
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Darwin/interface/MetaInfo.h
- /builds/cms-analysis/general/DasAnalysisSystem/Core/Installer/Darwin/src/MetaInfo.cc
name
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:48
@ replicas
Definition: Variation.h:16
cerr
Definition: Ntupliser_cfg.py:101
pt
Definition: jmarExample.py:19
static const char * def
Definition: Step.h:36
args
Definition: Ntupliser_cfg.py:11
git_error_category
Error category for libgit2.
static const char * underline
Definition: colours.h:10
int year
Definition: Ntupliser_cfg.py:63
@ bits
Definition: Variation.h:17
p
Definition: Ntupliser_cfg.py:174
data
Definition: btvExample_106X.py:10
VarType
Definition: Variation.h:13
#define DARWIN_GIT_REPO
Definition: main.cc:21
const Variation nominal
Definition: Variation.h:55
static const char * orange
Definition: colours.h:6
version
Definition: DYToLL_M-50_13TeV_pythia8_cff_GEN_SIM_RECOBEFMIX_DIGI_L1_DIGI2RAW_L1Reco_RECO.py:49
static const char * normal
Definition: colours.h:8
@ single
Definition: Variation.h:14
static const char * green
Definition: Step.h:33
#define DARWIN_VERSION
Definition: version.h:1
dictionary isMC
Definition: Ntupliser_cfg.py:61
dictionary flags
Definition: Ntupliser_cfg.py:27
@ symmetric
Definition: Variation.h:15
static const char * bold
Definition: Step.h:35