38 #include <boost/assign/list_of.hpp>
45 #include "reportingUtils.hpp"
50 using namespace boost::assign;
55 main(
int argc,
char** argv)
60 #ifdef USE_STD_COMPLEX_TREE_LEAFS
62 const unsigned int nmbEvents = 1000000;
63 const unsigned int nmbIncohSubAmps = 3;
64 gRandom->SetSeed(123456789);
68 gROOT->ProcessLine(
"#include <complex>");
71 TFile* outFile = TFile::Open(
"testAmplitudeTree.root",
"RECREATE");
73 const vector<string> subAmpLabels = list_of(
"lambda=-1")(
"lambda=0")(
"lambda=+1");
74 TTree* tree =
new TTree(
"test",
"test");
76 tree->Branch(
"amp", &Leaf);
77 for (
unsigned int i = 0;
i < nmbEvents; ++
i) {
80 for (
unsigned int j = 0; j < nmbIncohSubAmps; ++j)
82 ampLeaf->
setIncohSubAmp(complex<double>(gRandom->Rndm(), gRandom->Rndm()), j);
85 cout <<
"written event " <<
i <<
": " << *ampLeaf;
90 for (
unsigned int i = 0;
i < subAmpLabels.size(); ++
i)
91 cout << subAmpLabels[
i] <<
": [" << ampLeaf->
incohSubAmpIndex(subAmpLabels[
i]) <<
"]" << endl;
96 TFile* inFile = TFile::Open(
"testAmplitudeTree.root",
"READ");
98 inFile->GetObject(
"test", tree);
100 tree->SetBranchAddress(
"amp", &Leaf);
101 for (
unsigned int i = 0;
i < tree->GetEntriesFast(); ++
i) {
104 cout <<
"read event " <<
i <<
": " << *ampLeaf;
109 printInfo <<
"original: " << *ampLeaf << endl;
111 printInfo <<
"copy: "<< ampLeaf2 << endl;
112 if (ampLeaf2 != *ampLeaf)
113 printErr <<
"problem with assignment" << endl;
115 printInfo <<
"arithmetic test: " << ampLeaf3 << endl;
116 if (ampLeaf3 != *ampLeaf)
117 printErr <<
"problem with arithmetic" << endl;
120 #endif // USE_STD_COMPLEX_TREE_LEAFS