Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions roottest/root/io/evolution/versions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,24 @@ ROOTTEST_ADD_TEST(ROOT7500
OUTREF execROOT7500.ref
LABELS longtest io)

ROOTTEST_ADD_TEST(ROOT14491writedata
MACRO ROOT14491writedata.cxx+
FIXTURES_SETUP root-io-evolution-versions-ROOT14491writedata
OUTREF ROOT14491writedata.ref
LABELS io)

ROOTTEST_ADD_TEST(ROOT14491readdata
MACRO ROOT14491readdata.cxx+
OUTREF ROOT14491readdata.ref
FIXTURES_REQUIRED root-io-evolution-versions-ROOT14491writedata
LABELS io)

ROOTTEST_ADD_TEST(ROOT14491simpleread
MACRO ROOT14491simpleread.cxx+
OUTREF ROOT14491simpleread.ref
FIXTURES_REQUIRED root-io-evolution-versions-ROOT14491writedata
LABELS io)

ROOTTEST_ADD_TEST(attmarker
COMMAND ${ROOT_hadd_CMD} -f result.root hsimple14.root hsimple20.root
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
Expand Down
76 changes: 76 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491readdata.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// See https://github.com/root-project/root/issues/14491#issuecomment-1917587621

#include <vector>
#include <iostream>
#include "Rtypes.h"

template <typename T>
struct Wrapper
{
bool present = true;
T obj;
};

struct MatchedCSCSegment
{
float someValue = 0.0;

MatchedCSCSegment(float in = 0.0) : someValue{in} {}

// The simple update failed if the class version was not set.
// ClassDef(MatchedCSCSegment, 5);
};

struct CSCSegment
{
float someValue;

operator MatchedCSCSegment()
{
return MatchedCSCSegment{someValue};
}

std::vector<MatchedCSCSegment> theDuplicateSegments;

// ClassDef(CSCSegment, 4);
};

static const char *dups_label = "dups ";
static const char *copy_label = "copy ";

#ifdef __ROOTCLING__
#pragma link C++ class MatchedCSCSegment+;
#pragma link C++ class CSCSegment+;
#pragma link C++ class Wrapper<std::vector<CSCSegment>>+;
#pragma read sourceClass="CSCSegment" targetClass="CSCSegment" version="[1-11]" \
checksum="[0x94f3cbee, 2499005422]" \
source="std::vector<CSCSegment> theDuplicateSegments" target="theDuplicateSegments" \
code = "{ std::cout << dups_label << onfile.theDuplicateSegments.size() << std::endl; \
std::copy(onfile.theDuplicateSegments.begin(), onfile.theDuplicateSegments.end(), \
std::back_inserter(theDuplicateSegments)); \
std::cout << copy_label << theDuplicateSegments.size() << std::endl; }"
#endif

#include "TFile.h"
#include "TTree.h"

void test(TTree *t, const char *bname)
{
std::string formula = bname;
formula += "[email protected]()";
t->Scan(formula.c_str());
}

int ROOT14491readdata()
{
auto file = TFile::Open("oldfile14491.root", "READ");
auto t = file->Get<TTree>("t");
t->LoadTree(0);
// gDebug = 7;
test(t, "seg_split");
// gDebug = 0;
test(t, "seg_unsplit");
file->Close();
delete file;
return 0;
}
29 changes: 29 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491readdata.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

Processing ROOT14491readdata.cxx+...
***********************************
* Row * Instance * seg_split *
***********************************
dups 0
copy 0
dups 1
copy 1
* 0 * 0 * 0 *
***********************************
dups 0
copy 0
dups 1
copy 1
***********************************
* Row * Instance * seg_unspl *
***********************************
dups 0
copy 0
dups 1
copy 2
dups 0
copy 0
dups 1
copy 3
* 0 * 0 * 1 *
***********************************
(int) 0
67 changes: 67 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491simpleread.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// See https://github.com/root-project/root/issues/14491#issuecomment-1917587621

#include <vector>
#include <iostream>
#include "Rtypes.h"

template <typename T>
struct Wrapper
{
bool present = true;
T obj;
};

struct MatchedCSCSegment
{
float someValue = 0.0;

MatchedCSCSegment(float in = 0.0) : someValue{in} {}

// The simple update failed if the class version was not set.
// ClassDef(MatchedCSCSegment, 5);
};

struct CSCSegment
{
float someValue;

operator MatchedCSCSegment()
{
return MatchedCSCSegment{someValue};
}

std::vector<MatchedCSCSegment> theDuplicateSegments;

// ClassDef(CSCSegment, 4);
};

#ifdef __ROOTCLING__
#pragma link C++ class MatchedCSCSegment+;
#pragma link C++ class CSCSegment+;
#pragma link C++ class Wrapper<std::vector<CSCSegment>>+;
#pragma read sourceClass="CSCSegment" targetClass="MatchedCSCSegment"
#endif

#include "TFile.h"
#include "TTree.h"

void test(TTree *t, const char *bname)
{
std::string formula = bname;
formula += "[email protected]()";
t->Scan(formula.c_str());
}

int ROOT14491simpleread()
{
auto file = TFile::Open("oldfile14491.root", "READ");
auto t = file->Get<TTree>("t");
t->LoadTree(0);
// gDebug = 7;
test(t, "seg_split");
// gDebug = 0;
test(t, "seg_unsplit");
file->Close();
delete file;
return 0;
}
13 changes: 13 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491simpleread.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

Processing ROOT14491simpleread.cxx+...
***********************************
* Row * Instance * seg_split *
***********************************
* 0 * 0 * 0 *
***********************************
***********************************
* Row * Instance * seg_unspl *
***********************************
* 0 * 0 * 1 *
***********************************
(int) 0
63 changes: 63 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491writedata.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <vector>
#include <iostream>
#include "Rtypes.h"

template <typename T>
struct Wrapper
{
bool present = true;
T obj;
};

struct MatchedCSCSegment
{
float someValue = 0.0;

MatchedCSCSegment(float in = 0.0) : someValue{in} {}

// The simple update failed if the class version is not set.
// ClassDef(MatchedCSCSegment, 5);
};

struct CSCSegment
{
float someValue;

operator MatchedCSCSegment()
{
return MatchedCSCSegment{someValue};
}

std::vector<CSCSegment> theDuplicateSegments;
// ClassDef(CSCSegment, 3);
};

#ifdef __ROOTCLING__
#pragma link C++ class MatchedCSCSegment+;
#pragma link C++ class CSCSegment+;
#pragma link C++ class Wrapper<std::vector<CSCSegment>>+;
#endif

#include "TFile.h"
#include "TTree.h"

int ROOT14491writedata(const char *filename = "oldfile14491.root")
{
auto file = TFile::Open(filename, "RECREATE");
auto t = new TTree("t", "t");
Wrapper<std::vector<CSCSegment>> w;

CSCSegment c;
c.theDuplicateSegments.push_back(CSCSegment{});

w.obj.push_back(c);

t->Branch("seg_split.", &w, 32000, 99);
t->Branch("seg_unsplit.", &w, 32000, 0);

t->Fill();
file->Write();
// t->Print();
delete file;
return 0;
}
3 changes: 3 additions & 0 deletions roottest/root/io/evolution/versions/ROOT14491writedata.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

Processing ROOT14491writedata.cxx+...
(int) 0
Loading