1 |
#include <iostream>
|
2 |
|
3 |
#include "cute/cute.h"
|
4 |
#include "cute/cute_suite.h"
|
5 |
|
6 |
#include <boost/scoped_ptr.hpp>
|
7 |
|
8 |
#include "TChain.h"
|
9 |
#include "TString.h"
|
10 |
|
11 |
|
12 |
|
13 |
struct TestROOT {
|
14 |
private:
|
15 |
TString invalidBranch;
|
16 |
//select two related variables
|
17 |
// TString numberOfElectrons;
|
18 |
TString energyForEachElectron;
|
19 |
|
20 |
boost::scoped_ptr<TChain> input;
|
21 |
public:
|
22 |
TestROOT() :
|
23 |
invalidBranch("this is not in the chain"),
|
24 |
// numberOfElectrons("Nels"),
|
25 |
energyForEachElectron("Electron.Energy"),
|
26 |
input(new TChain(NTupleEventReader::EVENT_CHAIN)) {
|
27 |
input->Add(InputFile::ttbar);
|
28 |
|
29 |
input->GetEntries();
|
30 |
input->SetBranchStatus("*", 0);
|
31 |
input->SetBranchStatus(energyForEachElectron, 1);
|
32 |
}
|
33 |
void testInvalidTBranch() {
|
34 |
try {
|
35 |
TBranch* br = input->GetBranch(invalidBranch);
|
36 |
if (br) {
|
37 |
input->SetBranchStatus(invalidBranch, 1);
|
38 |
}
|
39 |
} catch (...) {
|
40 |
std::cout << "exception occurred" << std::endl;
|
41 |
}
|
42 |
ASSERT(input->GetBranch(invalidBranch) == NULL);
|
43 |
}
|
44 |
|
45 |
void testValidBranch(){
|
46 |
ASSERT(input->GetBranch(energyForEachElectron) != NULL);
|
47 |
}
|
48 |
|
49 |
|
50 |
};
|
51 |
|
52 |
extern cute::suite make_suite_ROOTLearnTests() {
|
53 |
cute::suite s;
|
54 |
s.push_back(CUTE_SMEMFUN(TestROOT,testInvalidTBranch));
|
55 |
s.push_back(CUTE_SMEMFUN(TestROOT,testValidBranch));
|
56 |
return s;
|
57 |
}
|