DAS  3.0
Das Analysis System
MetaInfo.cc File Reference
#include <boost/test/included/unit_test.hpp>
#include <boost/exception/all.hpp>
#include "test.h"
#include "MetaInfo.h"
#include <TFile.h>
#include <TTree.h>
#include <memory>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/info_parser.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/xml_parser.hpp>
+ Include dependency graph for MetaInfo.cc:

Macros

#define BOOST_TEST_MODULE   testMetaInfo
 

Functions

 BOOST_AUTO_TEST_CASE (flags_and_corrections)
 
 BOOST_AUTO_TEST_CASE (labels)
 
 BOOST_AUTO_TEST_CASE (software_version)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   testMetaInfo

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( flags_and_corrections  )
29  {
30  pt::ptree config;
31  BOOST_REQUIRE_NO_THROW( pt::read_info(DARWIN "/test/example.info", config) );
32 
33  auto events = make_shared<TTree>("events", "events");
34 
35  BOOST_REQUIRE_THROW( MetaInfo(events, config.get_child("corrections")), boost::wrapexcept<pt::ptree_error> ); // expecting a certain format
36 
37  MetaInfo metainfo1(events, config);
38  BOOST_TEST( metainfo1.Get<bool>("flags", "isMC") == true );
39  BOOST_TEST_WARN( metainfo1.Get<bool>("git", "reproducible") == true );
40  events->GetUserInfo()->ls();
41  BOOST_REQUIRE_THROW( MetaInfo(events, config), boost::wrapexcept<std::invalid_argument> ); // cannot initialise (from scratch) again the same metainfo
42 
43  config.put<bool>("flags.isMC", false);
44  config.put<bool>("flags.label", "aNewLabel");
45  MetaInfo metainfo2(events);
46  BOOST_REQUIRE_THROW( metainfo2.Check(config), boost::wrapexcept<std::invalid_argument> ); // inconsistent flags
47  hash<UserInfo> HashM;
48  BOOST_TEST( HashM(metainfo1) == HashM(metainfo2) );
49 
50  auto events2 = make_shared<TTree>("events2", "events");
51  MetaInfo metainfo3(events2, config);
52  BOOST_TEST( HashM(metainfo1) != HashM(metainfo3) );
53  hash<TTree*> HashT;
54  BOOST_TEST( HashT(events.get()) != HashT(events2.get()));
55  }

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( labels  )
58  {
59  pt::ptree config;
60  pt::read_info(DARWIN "/test/example.info", config);
61 
62  {
63  auto events = make_shared<TTree>("events", "events");
64  config.get_child("flags").erase("labels");
65  config.put<string>("flags.labels.this", ""); // will not fail
66  BOOST_REQUIRE_NO_THROW( MetaInfo(events, config) );
67  }
68 
69  {
70  auto events = make_shared<TTree>("events", "events");
71  config.get_child("flags").erase("labels");
72  config.put<string>("flags.labels.this", "will fail");
73  BOOST_REQUIRE_THROW( MetaInfo(events, config), boost::wrapexcept<std::invalid_argument> );
74  }
75  }

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( software_version  )
78  {
79  pt::ptree config;
80  pt::read_info(DARWIN "/test/example.info", config);
81  auto events = make_shared<TTree>("events", "events");
82  MetaInfo metainfo(events, config);
83  cout << "Forcing inconsistent version (42 everywhere)" << endl;
84  metainfo.Set<const char *>("software", "gpp" , "42");
85  metainfo.Set<const char *>("software", "Cpp" , "42");
86  metainfo.Set<const char *>("software", "ROOT" , "42");
87  metainfo.Set<const char *>("software", "Boost", "42");
88  BOOST_REQUIRE_NO_THROW( MetaInfo{events} );
89  }
BOOST_TEST
BOOST_TEST(gendijet.Rapidity()==1.3573785791881385)
std::hash< TTree * >
Hash from TTree obtained by combination of different elements.
Definition: UserInfo.h:286
Darwin::Tools::MetaInfo
Generic meta-information for n-tuple (including speficities to Darwin).
Definition: MetaInfo.h:65
Ntupliser_cfg.config
config
Definition: Ntupliser_cfg.py:264