// // This file test the functionalities of the Block class. // Interectly it also test the functionalities of the ColumnAttribs class. // #include #include #include #include #include #include Int4 c; Int4 func () { return c; } void readFunc (Int4 i) { c = i; } class Test { int _a; public: Int4 a() {return _a;}; void seta(Int4 f) { _a = f; }; }; int main (int argc, Int1* argv[]) { Int4 atInt1 = 55; Int4 atInt2 = 55; Float8 atDouble = 55.0; Test object; // Float8 arr[10][10]; Float8 arr[100][10]; int dim1 = 10; int dim2 = 10; for (int i = 0; i < dim1 ; i++) { ((double*)arr)[i] = 1.0; } HepFileManager* manager = new HepHBookFileManager("compCWN.out"); cout << " will create ntuple \n"; HepNtuple& hep = manager->ntuple("NTUPLE",1); hep.setColumnWise(); hep.newColumn("Col1",3.2,7.0); hep.newColumn("Col2",8.2); hep.columnVia("colF",func,(Int4)0); hep.columnVia("colM",newUseMethod(&object, object.a)); hep.newColumn("Col3",8.2,99.0); hep.newColumn("Col4",8.2,99.0); hep.columnAt("colAt",&atInt1); hep.columnAt("colAt2",&atInt2); hep.columnArray("colArray",2,(Float8)8).dimension(dim1,dim2); hep.capture(); hep.storeCapturedData(); hep.clearData(); cerr << hep.blockFormat(0) << endl; cerr << "loop: "; for (int i=0; i<50; i++) { cerr << i << ":"; hep.capture("Col1",3.2+i); hep.capture("Col2",8.2+2*i); atInt1 = -3*i; c = i; object.seta(5*i); // cout << "before loop " << dim1 << "," << dim2 << "\n"; for (int j=0; j < dim1+1; j++) { for (int k=0; k< dim2+1; k++) { arr[j][k] = 8.2/(i+1)*j*k; // cerr << j << "," << k << ":" << arr[j][k] << ";"; } } hep.capture("colArray",&(arr[0][0])); hep.capture(); hep.storeCapturedData(); hep.clearData(); } cout << endl; // set the readColumn back destinations. Float8 col1; hep.readColumn(1,"Col1",&col1); if ( col1 != 3.2 ) { cerr << "first col1 is wrong " << col1 << endl; } hep.readColumn(1,"Col2",&col1); if ( col1 != 8.2 ) { cerr << "first col2 is wrong " << col1 << endl; } hep.readColumn(1,"Col3",&col1); if ( col1 != 8.2 ) { cerr << "first col3 is wrong " << col1 << endl; } hep.readColumn(1,"Col4",&col1); if ( col1 != 8.2 ) { cerr << "first col4 is wrong " << col1 << endl; } Int4 creadColumn; hep.readColumn(1,"colF",&creadColumn); if ( creadColumn != 0 ) { cerr << "first colF is wrong " << creadColumn <