Skip to content

Replace exit(x) with return x in ROOT macros #47391

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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
146 changes: 73 additions & 73 deletions DataFormats/FWLite/test/chainevent_looping_cint.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ using namespace std;

#if defined(__CINT__) && !defined(__MAKECINT__)
class loadFWLite {
public:
loadFWLite() {
gSystem->Load("libFWCoreFWLite");
FWLiteEnabler::enable();
}
public:
loadFWLite() {
gSystem->Load("libFWCoreFWLite");
FWLiteEnabler::enable();
}
};

static loadFWLite lfw;
Expand All @@ -20,93 +20,93 @@ static loadFWLite lfw;
#include "DataFormats/TestObjects/interface/ThingCollection.h"
#endif

void chainevent_looping_cint()
{
vector<string> files;
files.push_back("empty_a.root");
files.push_back("good_a.root");
files.push_back("empty_a.root");
files.push_back("good_b.root");
files.push_back("empty_a.root");
fwlite::ChainEvent e(files);
int chainevent_looping_cint() {
vector<string> files;
files.push_back("empty_a.root");
files.push_back("good_a.root");
files.push_back("empty_a.root");
files.push_back("good_b.root");
files.push_back("empty_a.root");
fwlite::ChainEvent e(files);

int i = 0;
int returnValue = 0;
TFile* f = 0;

int i =0;
int returnValue = 0;
TFile* f = 0;
for (; e.isValid(); ++e, ++i) {
if (e.getTFile() != f) {
f = e.getTFile();
cout << "New file " << f->GetName() << endl;
}

for( ;e.isValid();++e,++i) {
if (e.getTFile() != f) {
f = e.getTFile();
cout << "New file " << f->GetName() << endl;
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e, "Thing");

for (i = 0; i != pThing.ref().size(); ++i) {
cout << pThing.ref().at(i).a << " ";
}
cout << endl;
}
if (i == 0) {
cout << "First loop failed!" << endl;
returnValue = 1;
}
e.toBegin();

fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e,"Thing");

for(i=0; i!=pThing.ref().size();++i) {
cout <<pThing.ref().at(i).a<<" ";
i = 0;
for (; e; ++e, ++i) {
}
cout << endl;
}
if (i==0) {
cout <<"First loop failed!"<<endl;
returnValue = 1;
}
e.toBegin();

i=0;
for( ;e;++e,++i) {
}
if (i == 0) {
cout << "Second loop failed!" << endl;
returnValue = 1;
}

if (i==0) {
cout <<"Second loop failed!"<<endl;
returnValue = 1;
}
i = 0;
for (e.toBegin(); !e.atEnd(); ++e, ++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e, "Thing");

i=0;
for(e.toBegin(); !e.atEnd();++e,++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e,"Thing");

for(i=0; i!=pThing.ref().size();++i) {
cout <<pThing.ref().at(i).a<<" ";
}
cout << endl;
//DOES NOT WORK in CINT
//for(vector<edmtest::Thing>::const_iterator it = pThing.data()->begin(); it != pThing.data()->end();++it) {
// cout <<(*it).a<<endl;
//}
}
if (i==0) {
cout <<"Third loop failed!"<<endl;
returnValue = 1;
}
e.to(0);
for (int j = 0; j<20; ++j) {
int k = rand() % 10;
if(e.to(k)) {
edm::EventID id = e.id();
cout << "Entry " << k << " Run " << id.run() << " event " << id.event() << endl;
} else {
cout <<"Entry "<<k<<" is not valid"<<endl;
for (i = 0; i != pThing.ref().size(); ++i) {
cout << pThing.ref().at(i).a << " ";
}
cout << endl;
//DOES NOT WORK in CINT
//for(vector<edmtest::Thing>::const_iterator it = pThing.data()->begin(); it != pThing.data()->end();++it) {
// cout <<(*it).a<<endl;
//}
}
if (i == 0) {
cout << "Third loop failed!" << endl;
returnValue = 1;
}
e.to(0);
for (int j = 0; j < 20; ++j) {
int k = rand() % 10;
if (e.to(k)) {
edm::EventID id = e.id();
cout << "Entry " << k << " Run " << id.run() << " event " << id.event() << endl;
} else {
cout << "Entry " << k << " is not valid" << endl;
}
}
}

e.to(0);
long size = e.size();
edm::EventID last;
for (long l = 0; l<size; ++l) {
for (long l = 0; l < size; ++l) {
e.to(l);
edm::EventID id = e.id();
cout << "Entry " << l << " Run " << id.run() << " event " << id.event() << endl;
if(last == id) {
if (last == id) {
returnValue = 1;
cout <<"duplicate event ("<<id.run()<<","<<id.event()<<") seen at index "<<l<<" while testing 'to'"<<endl;
cout << "duplicate event (" << id.run() << "," << id.event() << ") seen at index " << l << " while testing 'to'"
<< endl;
break;
}
}

exit(returnValue);
return returnValue;
}
103 changes: 51 additions & 52 deletions DataFormats/FWLite/test/event_looping_cint.C
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ using namespace std;

#if defined(__CINT__) && !defined(__MAKECINT__)
class loadFWLite {
public:
loadFWLite() {
gSystem->Load("libFWCoreFWLite");
FWLiteEnabler::enable();
}
public:
loadFWLite() {
gSystem->Load("libFWCoreFWLite");
FWLiteEnabler::enable();
}
};

static loadFWLite lfw;
Expand All @@ -20,57 +20,56 @@ static loadFWLite lfw;
#include "DataFormats/TestObjects/interface/ThingCollection.h"
#endif

void event_looping_cint()
{
TFile f("good_a.root");
fwlite::Event e(&f);
int event_looping_cint() {
TFile f("good_a.root");
fwlite::Event e(&f);

int i = 0;
int returnValue = 0;
for (; e.isValid(); ++e, ++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e, "Thing");

int i =0;
int returnValue = 0;
for( ;e.isValid();++e,++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e,"Thing");

for(int i=0; i!=pThing.ref().size();++i) {
cout <<pThing.ref().at(i).a<< " ";
for (int i = 0; i != pThing.ref().size(); ++i) {
cout << pThing.ref().at(i).a << " ";
}
cout << endl;
}
cout << endl;
}
if (i==0) {
cout <<"First loop failed!"<<endl;
returnValue = 1;
}
e.toBegin();
if (i == 0) {
cout << "First loop failed!" << endl;
returnValue = 1;
}
e.toBegin();

i=0;
for( ;e;++e,++i) {
}
i = 0;
for (; e; ++e, ++i) {
}

if (i==0) {
cout <<"Second loop failed!"<<endl;
returnValue = 1;
}
if (i == 0) {
cout << "Second loop failed!" << endl;
returnValue = 1;
}

i=0;
for(e.toBegin(); !e.atEnd();++e,++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e,"Thing");

for(int i=0; i!=pThing.ref().size();++i) {
cout <<pThing.ref().at(i).a<<" ";
}
cout << endl;
i = 0;
for (e.toBegin(); !e.atEnd(); ++e, ++i) {
fwlite::Handle<vector<edmtest::Thing> > pThing;
//pThing.getByLabel(e,"Thing","","TEST"); //WORKS
pThing.getByLabel(e, "Thing");

//DOES NOT WORK
//for(vector<edmtest::Thing>::const_iterator it = pThing.data()->begin(); it != pThing.data()->end();++it) {
// cout <<(*it).a<<endl;
//}
}
if (i==0) {
cout <<"Third loop failed!"<<endl;
returnValue = 1;
}
exit(returnValue);
for (int i = 0; i != pThing.ref().size(); ++i) {
cout << pThing.ref().at(i).a << " ";
}
cout << endl;

//DOES NOT WORK
//for(vector<edmtest::Thing>::const_iterator it = pThing.data()->begin(); it != pThing.data()->end();++it) {
// cout <<(*it).a<<endl;
//}
}
if (i == 0) {
cout << "Third loop failed!" << endl;
returnValue = 1;
}
return returnValue;
}
4 changes: 2 additions & 2 deletions DataFormats/FWLite/test/event_looping_consumes_cint.C
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static loadFWLite lfw;
#include "DataFormats/TestObjects/interface/ThingCollection.h"
#endif

void event_looping_consumes_cint() {
int event_looping_consumes_cint() {
TFile f("good_a.root");
fwlite::Event e(&f);

Expand All @@ -43,5 +43,5 @@ void event_looping_consumes_cint() {
cout << "First loop failed!" << endl;
returnValue = 1;
}
exit(returnValue);
return returnValue;
}
Loading