Skip to content

Commit a853c5d

Browse files
committed
[roottest] use cmake for treeformula/schemaEvolution
1 parent 27642be commit a853c5d

File tree

10 files changed

+112
-167
lines changed

10 files changed

+112
-167
lines changed
Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,35 @@
1-
#-------------------------------------------------------------------------------
2-
#
3-
# Placeholder file to translate the tests to the new CTest system. Meanwhile we
4-
# define a CTest test that calls 'make' in ${CMAKE_CURRENT_SOURCE_DIR}
5-
#
6-
#-------------------------------------------------------------------------------
7-
ROOTTEST_ADD_OLDTEST()
1+
ROOTTEST_GENERATE_DICTIONARY(libTreeFormulaScemaEvolution
2+
Event.h
3+
LINKDEF EventLinkDef.h
4+
SOURCES Event.cxx
5+
NO_ROOTMAP
6+
NO_CXXMODULE
7+
FIXTURES_SETUP root-treeformula-schemaEvolution-lib1-fixture)
8+
9+
ROOTTEST_GENERATE_DICTIONARY(libTreeFormulaScemaEvolution2
10+
Event_2.h
11+
LINKDEF EventLinkDef.h
12+
SOURCES Event_2.cxx
13+
NO_ROOTMAP
14+
NO_CXXMODULE
15+
FIXTURES_SETUP root-treeformula-schemaEvolution-lib2-fixture)
16+
17+
ROOTTEST_GENERATE_EXECUTABLE(ScemaEvolutionMainEvent
18+
MainEvent.cxx
19+
LIBRARIES Core RIO libTreeFormulaScemaEvolutionlibgen
20+
FIXTURES_REQUIRED root-treeformula-schemaEvolution-lib1-fixture
21+
FIXTURES_SETUP root-treeformula-schemaEvolution-exec-fixture)
22+
23+
ROOTTEST_ADD_TEST(write
24+
COMMAND ./ScemaEvolutionMainEvent 10 0 7 1
25+
FIXTURES_REQUIRED root-treeformula-schemaEvolution-exec-fixture
26+
FIXTURES_SETUP root-treeformula-schemaEvolution-write-fixture)
27+
28+
29+
foreach(arg 1 2 2a 3 3a 4 4a)
30+
ROOTTEST_ADD_TEST(schemaRun${arg}
31+
MACRO schemaRun${arg}.C
32+
FIXTURES_REQUIRED root-treeformula-schemaEvolution-write-fixture
33+
root-treeformula-schemaEvolution-lib1-fixture
34+
root-treeformula-schemaEvolution-lib2-fixture)
35+
endforeach()

roottest/root/treeformula/schemaEvolution/Event.cxx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
// Double32_t fTemperature;
1818
// Int_t fMeasures[10];
1919
// Double32_t fMatrix[4][4];
20-
// Double32_t *fClosestDistance; //[fNvertex] indexed array!
20+
// Double32_t *fClosestDistance; //[fNvertex] indexed array!
2121
// EventHeader fEvtHdr;
2222
// TClonesArray *fTracks;
2323
// TRefArray *fHighPt; //array of High Pt tracks only
@@ -91,8 +91,8 @@ TClonesArray *Event::fgTracks = 0;
9191
TH1F *Event::fgHist = 0;
9292

9393
//______________________________________________________________________________
94-
Event::Event(): fEventName(0), fNtrack(0), fNseg(0), fNvertex(0), fFlag(0),
95-
fTemperature(0), fClosestDistance(0), fTracks(0), fHighPt(0),
94+
Event::Event(): fEventName(0), fNtrack(0), fNseg(0), fNvertex(0), fFlag(0),
95+
fTemperature(0), fClosestDistance(0), fTracks(0), fHighPt(0),
9696
fMuons(0), fH(0)
9797
{
9898
// Create an Event object.
@@ -139,7 +139,7 @@ void Event::Build(Int_t ev, Int_t arg5, Float_t ptmin) {
139139
Clear();
140140
fHighPt->Delete();
141141
fMuons->Delete();
142-
142+
143143
Int_t nch = 15;
144144
if (ev >= 100) nch += 3;
145145
if (ev >= 10000) nch += 3;
@@ -169,13 +169,13 @@ void Event::Build(Int_t ev, Int_t arg5, Float_t ptmin) {
169169

170170
// Create and Fill the Track objects
171171
for (Int_t t = 0; t < ntrack; t++) AddTrack(random,ptmin);
172-
173-
//Restore Object count
172+
173+
//Restore Object count
174174
//To save space in the table keeping track of all referenced objects
175-
//we assume that our events do not address each other. We reset the
175+
//we assume that our events do not address each other. We reset the
176176
//object count to what it was at the beginning of the event.
177177
TProcessID::SetObjectCount(ObjectNumber);
178-
}
178+
}
179179

180180
//______________________________________________________________________________
181181
Track *Event::AddTrack(Float_t random, Float_t ptmin)
@@ -198,15 +198,15 @@ Track *Event::AddTrack(Float_t random, Float_t ptmin)
198198
}
199199

200200
//______________________________________________________________________________
201-
void Event::Clear(Option_t *option)
201+
void Event::Clear(Option_t *)
202202
{
203203
fTracks->Clear("C"); //will also call Track::Clear
204204
fHighPt->Delete();
205205
fMuons->Delete();
206206
}
207207

208208
//______________________________________________________________________________
209-
void Event::Reset(Option_t *option)
209+
void Event::Reset(Option_t *)
210210
{
211211
// Static function to reset all static objects for this event
212212
// fgTracks->Delete(option);
@@ -251,7 +251,7 @@ Track::Track(const Track &orig) : TObject(orig)
251251

252252
fPx = orig.fPx;
253253
fPy = orig.fPy;
254-
fPz = orig.fPx;
254+
fPz = orig.fPx;
255255
fRandom = orig.fRandom;
256256
fMass2 = orig.fMass2;
257257
fBx = orig.fBx;
@@ -339,9 +339,9 @@ Track::Track(Float_t random) : TObject(),fTriggerBits(64)
339339
//______________________________________________________________________________
340340
void Track::Clear(Option_t * /*option*/)
341341
{
342-
fTriggerBits.Clear();
343-
delete [] fPointValue;
344-
fPointValue=0;
342+
fTriggerBits.Clear();
343+
delete [] fPointValue;
344+
fPointValue=0;
345345
}
346346

347347
//______________________________________________________________________________

roottest/root/treeformula/schemaEvolution/MainEvent.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@
8080
//
8181
////////////////////////////////////////////////////////////////////////
8282

83-
#include <stdlib.h>
83+
#include <cstdlib>
84+
#include <iostream>
8485

85-
#include "Riostream.h"
8686
#include "TROOT.h"
8787
#include "TFile.h"
8888
#include "TNetFile.h"
@@ -202,7 +202,7 @@ int main(int argc, char **argv)
202202
}
203203

204204
// Create a ROOT Tree and one superbranch
205-
TTree *tree = new TTree("T","An example of a ROOT tree");
205+
tree = new TTree("T","An example of a ROOT tree");
206206
tree->SetAutoSave(1000000000); // autosave when 1 Gbyte written
207207
bufsize = 64000;
208208
if (split) bufsize /= 4;
Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1+
int schemaRun1()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
63
TFile f("Event.root");
7-
8-
#ifdef ClingWorkAroundMissingDynamicScope
9-
TTree *T; f.GetObject("T",T);
10-
#endif
11-
4+
5+
TTree *T = nullptr;
6+
f.GetObject("T",T);
7+
128
T->Show(5); //ok
139
Long64_t n = T->Scan("fTemperature"); //ok
14-
15-
#ifdef ClingWorkAroundBrokenUnnamedReturn
16-
gApplication->Terminate(n!=0);
17-
#else
18-
return (n!=0);
19-
#endif
20-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
21-
}
22-
#ifndef ClingWorkAroundBrokenUnnamedReturn
23-
return 1;
24-
#endif
25-
#endif
10+
11+
return !n;
2612
}
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1+
int schemaRun2()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
63
TFile f("Event.root");
7-
gSystem->Load("./libEvent");
4+
gSystem->Load("libTreeFormulaScemaEvolution");
5+
6+
TTree *T = nullptr;
7+
f.GetObject("T",T);
88

9-
#ifdef ClingWorkAroundMissingDynamicScope
10-
TTree *T; f.GetObject("T",T);
11-
#endif
12-
139
T->Show(5); //ok
1410
Long64_t n = T->Scan("fTemperature"); //ok
1511

16-
#ifdef ClingWorkAroundBrokenUnnamedReturn
17-
gApplication->Terminate(n!=0);
18-
#else
19-
return (n!=0);
20-
#endif
21-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
22-
}
23-
#ifndef ClingWorkAroundBrokenUnnamedReturn
24-
return 1;
25-
#endif
26-
#endif
12+
return !n;
2713
}
Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1+
int schemaRun2a()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
6-
gSystem->Load("./libEvent");
3+
gSystem->Load("libTreeFormulaScemaEvolution");
74
TFile f("Event.root");
85

9-
#ifdef ClingWorkAroundMissingDynamicScope
10-
TTree *T; f.GetObject("T",T);
11-
#endif
12-
6+
TTree *T = nullptr;
7+
f.GetObject("T",T);
8+
139
T->Show(5); //ok
1410
Long64_t n = T->Scan("fTemperature"); //ok
1511

16-
#ifdef ClingWorkAroundBrokenUnnamedReturn
17-
gApplication->Terminate(n!=0);
18-
#else
19-
return (n!=0);
20-
#endif
21-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
22-
}
23-
#ifndef ClingWorkAroundBrokenUnnamedReturn
24-
return 1;
25-
#endif
26-
#endif
12+
return !n;
2713
}
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1+
int schemaRun3()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
63
TFile f("Event.root");
7-
gSystem->Load("./libEvent_2");
8-
9-
#ifdef ClingWorkAroundMissingDynamicScope
10-
TTree *T; f.GetObject("T",T);
11-
#endif
12-
4+
gSystem->Load("libTreeFormulaScemaEvolution2");
5+
6+
TTree *T = nullptr;
7+
f.GetObject("T",T);
8+
139
T->Show(5); //ok
1410
T->Scan("fTemperature"); //ok
15-
// gSystem->Load("libTreePlayer");
1611
auto tf = new TTreeFormula("tf","fTemperature",T);
17-
18-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
19-
}
20-
#endif
12+
return 0;
2113
}
Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1+
int schemaRun3a()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
6-
gSystem->Load("./libEvent_2");
3+
gSystem->Load("libTreeFormulaScemaEvolution2");
74
TFile f("Event.root");
8-
9-
#ifdef ClingWorkAroundMissingDynamicScope
10-
TTree *T; f.GetObject("T",T);
11-
#endif
12-
5+
6+
TTree *T = nullptr;
7+
f.GetObject("T",T);
8+
139
T->Show(5); //ok
1410
T->Scan("fTemperature"); //ok
15-
// gSystem->Load("libTreePlayer");
1611
auto tf = new TTreeFormula("tf","fTemperature",T);
17-
18-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
19-
}
20-
#endif
12+
return 0;
2113
}
Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,25 @@
1+
int schemaRun4()
12
{
2-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
3-
if (1) {
4-
#endif
5-
6-
TFile *f = new TFile("Event.root");
7-
gSystem->Load("./libEvent_2");
3+
auto f = TFile::Open("Event.root");
4+
gSystem->Load("libTreeFormulaScemaEvolution2");
5+
86
#ifdef ClingWorkAroundMissingDynamicScope
9-
gROOT->ProcessLine("Event * e = 0;");
7+
gROOT->ProcessLine("Event * e = nullptr;");
108
#else
11-
Event * e =0;
9+
Event * e = nullptr;
1210
#endif
1311

14-
#ifdef ClingWorkAroundMissingDynamicScope
15-
TTree *T; f->GetObject("T",T);
16-
#endif
17-
12+
TTree *T = nullptr;
13+
f->GetObject("T",T);
14+
1815
#ifdef ClingWorkAroundMissingDynamicScope
1916
gROOT->ProcessLine("T->SetBranchAddress(\"event\",&e);");
2017
#else
2118
T->SetBranchAddress("event",&e);
2219
#endif
20+
2321
T->Show(5); //ok
2422
Long64_t n = T->Scan("fTemperature"); //ok
25-
26-
#ifdef ClingWorkAroundBrokenUnnamedReturn
27-
gApplication->Terminate(n!=0);
28-
#else
29-
return (n!=0);
30-
#endif
31-
#if defined(ClingWorkAroundIncorrectTearDownOrder)
32-
}
33-
#ifndef ClingWorkAroundBrokenUnnamedReturn
34-
return 1;
35-
#endif
36-
#endif
23+
24+
return !n;
3725
}

0 commit comments

Comments
 (0)