DAS  3.0
Das Analysis System
FileUtils.cc File Reference
#include <boost/test/included/unit_test.hpp>
#include <boost/exception/all.hpp>
#include "darwin.h"
#include "Event.h"
#include "test.h"
#include <TFile.h>
+ Include dependency graph for FileUtils.cc:

Classes

struct  EventBoom
 

Macros

#define BOOST_TEST_MODULE   testOptions
 
#define DARWIN_EXAMPLE   DARWIN "/test/example.info"
 

Functions

 BOOST_AUTO_TEST_CASE (write_only)
 
 BOOST_AUTO_TEST_CASE (read_write)
 
 BOOST_AUTO_TEST_CASE (read_only)
 

Macro Definition Documentation

◆ BOOST_TEST_MODULE

#define BOOST_TEST_MODULE   testOptions

◆ DARWIN_EXAMPLE

#define DARWIN_EXAMPLE   DARWIN "/test/example.info"

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

BOOST_AUTO_TEST_CASE ( read_only  )
57  {
58  auto t1 = make_shared<TTree>("t1", "t1");
59  DP::RecEvent * recEvent = GetBranchWriteOnly(t1, "recEvent", &recEvent, verbose);
60 
61  DP::RecEvent * recEvent2 = nullptr;
62  BOOST_TEST_MESSAGE( "Trying to read an existing branch with the correct type" );
63  BOOST_REQUIRE_NO_THROW( GetBranchReadOnly(t1, "recEvent", &recEvent2, verbose) );
64 
65  BOOST_TEST_MESSAGE( "Trying to read inexisting branch" );
66  BOOST_REQUIRE_THROW( GetBranchReadOnly(t1, "recEvent2", &recEvent2, verbose), boost::wrapexcept<DE::BadInput> );
67 
68  BOOST_TEST_MESSAGE( "Trying to read a branch assuming a wrong type" );
69  DP::GenEvent * genEvent = nullptr;
70  BOOST_REQUIRE_THROW( GetBranchReadOnly(t1, "recEvent", &genEvent, verbose), boost::wrapexcept<DE::BadInput> );
71  }

◆ BOOST_AUTO_TEST_CASE() [2/3]

BOOST_AUTO_TEST_CASE ( read_write  )
46  {
47  auto t1 = make_shared<TTree>("t1", "t1");
48  DP::RecEvent * recEvent = GetBranchWriteOnly(t1, "recEvent", &recEvent, verbose);
49 
50  auto t2 = unique_ptr<TTree>(t1->CloneTree(0));
51  DP::RecEvent * recEvent2 = nullptr;
52  BOOST_REQUIRE_NO_THROW( GetBranchReadWrite(t1, t2, "recEvent", &recEvent2, verbose) );
53  BOOST_REQUIRE_THROW( GetBranchReadWrite(t1, t2, "recEvent2", &recEvent2, verbose), boost::wrapexcept<DE::BadInput> );
54  }

◆ BOOST_AUTO_TEST_CASE() [3/3]

BOOST_AUTO_TEST_CASE ( write_only  )
33  {
34  auto t1 = make_shared<TTree>("t1", "t1");
35 
36  DP::RecEvent * recEvent = nullptr;
37  BOOST_TEST_MESSAGE( "The first call should work." );
38  BOOST_REQUIRE_NO_THROW( GetBranchWriteOnly(t1, "recEvent", &recEvent, verbose) );
39 
40  EventBoom * recEventBoom = nullptr;
41  BOOST_TEST_MESSAGE( "The second call should fail." );
42  BOOST_REQUIRE_THROW( GetBranchWriteOnly(t1, "recEventBOOM", &recEventBoom, verbose), boost::wrapexcept<DE::BadInput> );
43  }
Step::verbose
static bool verbose
Definition: Step.h:40
Darwin::Tools::GetBranchWriteOnly
T * GetBranchWriteOnly(TTreePtr &tOut, const std::string &name, T **t, const int steering=0)
Wrapper to initialise write-only branches.
Definition: FileUtils.h:162
Darwin::Tools::GetBranchReadOnly
T * GetBranchReadOnly(const TTreePtr &tIn, const std::string &name, T **t, const int steering=0, bool raise_exception=true)
Wrapper to initialise read-only branches.
Definition: FileUtils.h:121
Darwin::Physics::GenEvent
Generic generator-level event.
Definition: Event.h:43
Darwin::Physics::RecEvent
Generic detector-level event.
Definition: Event.h:64
Darwin::Tools::GetBranchReadWrite
T * GetBranchReadWrite(const TTreePtrIn &tIn, TTreePtrOut &tOut, const std::string &name, T **t, const int steering=0, bool raise_exception=true)
Wrapper to initialise read-write branches.
Definition: FileUtils.h:195
EventBoom
Definition: FileUtils.cc:26