22 #include "Cintex/Cintex.h"
23 #include "Reflex/Reflex.h"
39 const std::string
sname =
"ROOT::Math::SMatrix<Double32_t,5,5,ROOT::Math::MatRepStd<Double32_t,5,5> >";
40 const std::string
sname_sym =
"ROOT::Math::SMatrix<Double32_t,5,5,ROOT::Math::MatRepSym<Double32_t,5> >";
45 const std::string
sname =
"ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepStd<double,5,5> >";
46 const std::string
sname_sym =
"ROOT::Math::SMatrix<double,5,5,ROOT::Math::MatRepSym<double,5> >";
52 std::string
sfile1 =
"smatrix_rflx.root";
53 std::string
sfile2 =
"smatrix.root";
55 std::string
symfile1 =
"smatrixsym_rflx.root";
56 std::string
symfile2 =
"smatrixsym.root";
59 std::string
sfile2 =
"smatrix_rflx.root";
70 template<
class Matrix>
72 for (
int i = 0; i < 5; ++i) {
73 for (
int j = 0; j < 5; ++j) {
74 m(i,j) = R.
Rndm() + 1;
80 for (
int i = 0; i < 5; ++i) {
81 for (
int j = 0; j < 5; ++j) {
82 m[i*5+j] = R.
Rndm() + 1;
87 template<
class Matrix>
89 for (
int i = 0; i < 5; ++i) {
90 for (
int j = 0; j < 5; ++j) {
91 if (j>=i)
m(i,j) = R.
Rndm() + 1;
100 for (
int i = 0; i < 5*5; ++i) {
108 for (
int i = 0; i < 5*5; ++i) {
117 const double * d = m.GetMatrixArray();
118 for (
int i = 0; i < 5*5; ++i) {
133 for (
int i = 0; i <
n; ++i) {
137 std::cout <<
" Time to fill SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
142 for (
int i = 0; i <
n; ++i) {
146 std::cout <<
" Time to fill SMatrix Sym " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
151 for (
int i = 0; i <
n; ++i) {
155 std::cout <<
" Time to fill TMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
160 for (
int i = 0; i <
n; ++i) {
164 std::cout <<
" Time to fill TMatrix Sym " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
173 std::cout <<
"**************************************************\n";
174 std::cout <<
" Test writing a C Array ........\n";
175 std::cout <<
"**************************************************\n";
177 TFile f1(
"cmatrix.root",
"RECREATE");
181 TTree t1(
"t1",
"Tree with C Array");
184 t1.
Branch(
"C Array branch",m1,
"m1[25]/D");
189 for (
int i = 0; i <
n; ++i) {
198 std::cout <<
" Time to Write CArray " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
202 int pr = std::cout.precision(18);
203 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
204 std::cout.precision(pr);
213 std::cout <<
"**************************************************\n";
214 std::cout <<
" Test writing SMatrix ........\n";
215 std::cout <<
"**************************************************\n";
217 TFile f1(file.c_str(),
"RECREATE");
220 TTree t1(
"t1",
"Tree with SMatrix");
225 t1.Branch(
"SMatrix branch",
sname.c_str(),&m1,16000,0);
230 for (
int i = 0; i <
n; ++i) {
239 std::cout <<
" Time to Write SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
242 int pr = std::cout.precision(18);
243 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
244 std::cout.precision(pr);
255 std::cout <<
"**************************************************\n";
256 std::cout <<
" Test writing SMatrix Sym.....\n";
257 std::cout <<
"**************************************************\n";
259 TFile f1(file.c_str(),
"RECREATE");
262 TTree t1(
"t1",
"Tree with SMatrix");
266 t1.Branch(
"SMatrixSym branch",
sname_sym.c_str(),&m1,16000,0);
271 for (
int i = 0; i <
n; ++i) {
281 std::cout <<
" Time to Write SMatrix Sym " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
284 int pr = std::cout.precision(18);
285 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
286 std::cout.precision(pr);
300 std::cout <<
"**************************************************\n";
301 std::cout <<
" Test writing TMatrix........\n";
302 std::cout <<
"**************************************************\n";
305 TFile f2(
"tmatrix.root",
"RECREATE");
306 TTree t2(
"t2",
"Tree with TMatrix");
312 t2.
Branch(
"TMatrix branch",&m2,16000,2);
317 for (
int i = 0; i <
n; ++i) {
326 std::cout <<
" Time to Write TMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
329 int pr = std::cout.precision(18);
330 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
331 std::cout.precision(pr);
332 std::cout <<
"\n\n\n";
343 std::cout <<
"**************************************************\n";
344 std::cout <<
" Test writing TMatrix.Sym....\n";
345 std::cout <<
"**************************************************\n";
348 TFile f2(
"tmatrixsym.root",
"RECREATE");
349 TTree t2(
"t2",
"Tree with TMatrix");
355 t2.
Branch(
"TMatrixSym branch",&m2,16000,0);
360 for (
int i = 0; i <
n; ++i) {
369 std::cout <<
" Time to Write TMatrix Sym " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
372 int pr = std::cout.precision(18);
373 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
374 std::cout.precision(pr);
375 std::cout <<
"\n\n\n";
391 std::cout <<
"**************************************************\n";
392 std::cout <<
" Test reading TMatrix........\n";
393 std::cout <<
"**************************************************\n";
398 std::cerr <<
"Error opening the ROOT file" << std::endl;
410 for (
int i = 0; i <
n; ++i) {
416 std::cout <<
" Time for TMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
417 double val = etot/
double(n);
419 std::cout <<
" Tree Entries " << n << std::endl;
420 int pr = std::cout.precision(18);
421 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
422 std::cout.precision(pr);
434 std::cout <<
"**************************************************\n";
435 std::cout <<
" Test reading TMatrix.Sym....\n";
436 std::cout <<
"**************************************************\n";
441 std::cerr <<
"Error opening the ROOT file" << std::endl;
455 for (
int i = 0; i <
n; ++i) {
461 std::cout <<
" Time for TMatrix Sym" << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
462 double val = etot/
double(n);
464 std::cout <<
" Tree Entries " << n << std::endl;
465 int pr = std::cout.precision(18);
466 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
467 std::cout.precision(pr);
478 std::cout <<
"**************************************************\n";
479 std::cout <<
" Test reading SMatrix........\n";
480 std::cout <<
"**************************************************\n";
485 std::cerr <<
"Error opening the ROOT file" << file << std::endl;
498 for (
int i = 0; i <
n; ++i) {
505 std::cout <<
" Time for SMatrix : " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
508 std::cout <<
" Tree Entries " << n << std::endl;
509 int pr = std::cout.precision(18);
510 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
511 std::cout.precision(pr);
524 std::cout <<
"**************************************************\n";
525 std::cout <<
" Test reading SMatrix.Sym....\n";
526 std::cout <<
"**************************************************\n";
531 std::cerr <<
"Error opening the ROOT file" << file << std::endl;
545 for (
int i = 0; i <
n; ++i) {
552 std::cout <<
" Time for SMatrix Sym : " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
555 std::cout <<
" Tree Entries " << n << std::endl;
556 int pr = std::cout.precision(18);
557 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
558 std::cout.precision(pr);
569 std::cout <<
"**************************************************\n";
570 std::cout <<
" Test writing Track class........\n";
571 std::cout <<
"**************************************************\n";
573 TFile f1(
"track.root",
"RECREATE");
576 TTree t1(
"t1",
"Tree with Track based on SMatrix");
580 t1.
Branch(
"Track branch",&m1,16000,0);
585 for (
int i = 0; i <
n; ++i) {
594 std::cout <<
" Time to Write TrackD of SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
598 int pr = std::cout.precision(18);
599 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
600 std::cout.precision(pr);
610 std::cout <<
"**************************************************\n";
611 std::cout <<
" Test writing TrackD32 class........\n";
612 std::cout <<
"**************************************************\n";
614 TFile f1(
"track32.root",
"RECREATE");
617 TTree t1(
"t1",
"Tree with Track based on SMatrix");
620 t1.
Branch(
"Track32 branch",&m1,16000,0);
625 for (
int i = 0; i <
n; ++i) {
634 std::cout <<
" Time to Write TrackD32 of SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
638 int pr = std::cout.precision(18);
639 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
640 std::cout.precision(pr);
650 std::cout <<
"**************************************************\n";
651 std::cout <<
" Test reading Track class........\n";
652 std::cout <<
"**************************************************\n";
656 std::cerr <<
"Error opening the ROOT file" << std::endl;
669 for (
int i = 0; i <
n; ++i) {
676 std::cout <<
" Time to Read TrackD of SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
679 std::cout <<
" Tree Entries " << n << std::endl;
680 int pr = std::cout.precision(18);
681 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
682 std::cout.precision(pr);
691 std::cout <<
"**************************************************\n";
692 std::cout <<
" Test reading Track32 class........\n";
693 std::cout <<
"**************************************************\n";
697 std::cerr <<
"Error opening the ROOT file" << std::endl;
710 for (
int i = 0; i <
n; ++i) {
717 std::cout <<
" Time to Read TrackD32 of SMatrix " << timer.
RealTime() <<
" " << timer.
CpuTime() << std::endl;
720 std::cout <<
" Tree Entries " << n << std::endl;
721 int pr = std::cout.precision(18);
722 std::cout <<
" sum " << n<<
" " << etot <<
" " << etot/
double(n) << std::endl;
723 std::cout.precision(pr);
741 std::cout <<
"\nERROR: Differeces SMatrix-TMatrix found when writing" << std::endl;
742 int pr = std::cout.precision(18); std::cout << w1 <<
" != " << w2 << std::endl; std::cout.precision(pr);
746 std::cout <<
"\nERROR: Differeces TMatrix-C Array found when writing" << std::endl;
747 int pr = std::cout.precision(18); std::cout << w1 <<
" != " << w0 << std::endl; std::cout.precision(pr);
751 std::cout <<
"\n\n*************************************************************\n";
753 std::cout <<
" Writing Test:\t" <<
"OK";
755 std::cout <<
" Writing Test:\t" <<
"FAILED";
757 std::cout <<
"\n*************************************************************\n\n";
772 std::cout <<
"\nERROR: Differeces SMatrix-TMatrix found when reading " << std::endl;
773 int pr = std::cout.precision(18); std::cout << r1 <<
" != " << r2 << std::endl; std::cout.precision(pr);
778 std::cout <<
"try to read file written with CINT using Reflex Dictionaries " << std::endl;
780 std::cout <<
"try to read file written with Reflex using CINT Dictionaries " << std::endl;
783 if ( r3 != -1. &&
fabs(r2-r3) >
tol) {
784 std::cout <<
"\nERROR: Differeces Reflex-CINT found when reading SMatrices" << std::endl;
785 int pr = std::cout.precision(18); std::cout << r2 <<
" != " << r3 << std::endl; std::cout.precision(pr);
803 std::cout <<
"\nERROR: Differeces found when writing" << std::endl;
804 int pr = std::cout.precision(18); std::cout << w1 <<
" != " << w2 << std::endl; std::cout.precision(pr);
808 std::cout <<
"\n\n*************************************************************\n";
810 std::cout <<
" Writing Test:\t" <<
"OK";
812 std::cout <<
" Writing Test:\t" <<
"FAILED";
814 std::cout <<
"\n*************************************************************\n\n";
827 std::cout <<
"\nERROR: Differeces SMatrixSym-TMAtrixSym found when reading " << std::endl;
828 int pr = std::cout.precision(18); std::cout << r1 <<
" != " << r2 << std::endl; std::cout.precision(pr);
833 std::cout <<
"try to read file written with CINT using Reflex Dictionaries " << std::endl;
835 std::cout <<
"try to read file written with Reflex using CINT Dictionaries " << std::endl;
839 if ( r3 != -1. &&
fabs(r2-r3) >
tol) {
840 std::cout <<
"\nERROR: Differeces Reflex-CINT found when reading SMatricesSym" << std::endl;
841 int pr = std::cout.precision(18); std::cout << r2 <<
" != " << r3 << std::endl; std::cout.precision(pr);
853 std::cout <<
"\nERROR: Differeces found when reading TMatrices" << std::endl;
854 int pr = std::cout.precision(18); std::cout << w1 <<
" != " << r1 << std::endl; std::cout.precision(pr);
858 std::cout <<
"\nERROR: Differeces found when reading SMatrices" << std::endl;
859 int pr = std::cout.precision(18); std::cout << w2 <<
" != " << r2 << std::endl; std::cout.precision(pr);
862 if ( r3 != -1. &&
fabs(w2-r3) >
tol) {
863 std::cout <<
"\nERROR: Differeces found when reading SMatrices with different Dictionary" << std::endl;
864 int pr = std::cout.precision(18); std::cout << w2 <<
" != " << r2 << std::endl; std::cout.precision(pr);
884 std::cout <<
"\nERROR: Differeces found when writing Track" << std::endl;
885 int pr = std::cout.precision(18); std::cout << wt2 <<
" != " << wt1 << std::endl; std::cout.precision(pr);
891 std::cout <<
"\nERROR: Differeces found when reading Track" << std::endl;
892 int pr = std::cout.precision(18); std::cout << rt1 <<
" != " << wt1 << std::endl; std::cout.precision(pr);
898 std::cout <<
"\nERROR: Differeces found when reading Track 32" << std::endl;
899 int pr = std::cout.precision(18); std::cout << rt2 <<
" != " << wt2 << std::endl; std::cout.precision(pr);
918 ROOT::Cintex::Cintex::SetDebug(1);
919 ROOT::Cintex::Cintex::Enable();
921 std::cout <<
"Use Reflex dictionary " << std::endl;
923 #ifdef USE_REFLEX_SMATRIX
951 std::cout <<
"\n\n*************************************************************\n";
953 std::cout <<
" Reading Test:\t" <<
"OK";
955 std::cout <<
" Reading Test:\t" <<
"FAILED";
957 std::cout <<
"\n*************************************************************\n\n";
962 std::cout <<
"\n*****************************************************\n";
963 std::cout <<
" Test Symmetric matrices";
964 std::cout <<
"\n*****************************************************\n\n";
970 std::cout <<
"\n\n*************************************************************\n";
972 std::cout <<
" Reading Test:\t" <<
"OK";
974 std::cout <<
" Reading Test:\t" <<
"FAILED";
976 std::cout <<
"\n*************************************************************\n\n";
981 std::cout <<
"\n*****************************************************\n";
982 std::cout <<
" Test Track class";
983 std::cout <<
"\n*****************************************************\n\n";
987 if (iret != 0 )
return iret;
990 std::cout <<
"\n\n*************************************************************\n";
992 std::cout <<
" Track Test:\t" <<
"OK";
994 std::cout <<
" Track Test:\t" <<
"FAILED";
996 std::cout <<
"\n*************************************************************\n\n";
1007 std::cout <<
"\n\n*************************************************************\n";
1009 std::cerr <<
"\nERROR !!!!! " << iret << std::endl;
1010 std::cerr <<
"TESTIO \t FAILED " << std::endl;
1013 std::cerr <<
"TESTIO \t OK " << std::endl;
1015 std::cout <<
"*************************************************************\n\n";
void FillMatrix(Matrix &m)
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
Random number generator class based on M.
void FillMatrixSym(Matrix &m)
Double_t RealTime()
Stop the stopwatch (if it is running) and return the realtime (in seconds) passed between the start a...
double writeTrackD32(int n)
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
double writeTMatrix(int n)
int testTrack(int nEvents)
virtual Int_t Fill()
Fill all branches.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
int testRead(double &r1, double &r2, double &r3)
virtual TObject * Get(const char *namecycle)
Return pointer to object identified by namecycle.
virtual Int_t GetEntry(Long64_t entry=0, Int_t getall=0)
Read all branches of entry and return total number of bytes read.
virtual int Load(const char *module, const char *entry="", Bool_t system=kFALSE)
Load a shared library.
Double_t CpuTime()
Stop the stopwatch (if it is running) and return the cputime (in seconds) passed between the start an...
int testReadSym(double &r1, double &r2, double &r3)
void FillCArray(double *m)
ROOT::Math::SMatrix< double, 5, 5 > SMatrix5
int testWriteSym(int nEvents, double &w1, double &w2)
double SumCArray(double *m)
double readSMatrix(const std::string &file)
virtual void Print(Option_t *option="") const
Print a summary of the tree contents.
void Stop()
Stop the stopwatch.
SMatrix: a generic fixed size D1 x D2 Matrix class.
virtual Int_t SetBranchAddress(const char *bname, void *add, TBranch **ptr=0)
Change branch address, dealing with clone trees properly.
unsigned int r3[N_CITIES]
T apply(unsigned int i) const
access the parse tree with the index starting from zero and following the C convention for the order ...
double writeSMatrix(int n, const std::string &file)
virtual Double_t Rndm(Int_t i=0)
Machine independent random number generator.
TMatrixT< Double_t > TMatrixD
double writeSMatrixSym(int n, const std::string &file)
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
virtual void SetSeed(UInt_t seed=0)
Set the random generator sequence if seed is 0 (default value) a TUUID is generated and used to fill ...
R__EXTERN TSystem * gSystem
virtual Int_t Write(const char *name=0, Int_t opt=0, Int_t bufsiz=0)
Write memory objects to this file.
unsigned int r1[N_CITIES]
double SumSMatrix(ROOT::Math::SMatrix< double, 5, 5, R > &m)
const std::string sname_sym
double writeCArray(int n)
TMatrixTSym< Double_t > TMatrixDSym
double readSMatrixSym(const std::string &file)
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
double f2(const double *x)
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > SMatrixSym5
int testWrite(int nEvents, double &w1, double &w2)
virtual Long64_t GetEntries() const
A TTree object has a header with a name and a title.
double writeTMatrixSym(int n)
unsigned int r2[N_CITIES]
double writeTrackD(int n)
int testResult(double w1, double r1, double w2, double r2, double r3)