// // This file test the functionalities of the Block class. // Interectly it also test the functionalities of the ColumnAttribs class. // // test harness #include "TestManager.h" #include "HepTuple/HepHBookNtuple.h" #include "HepTuple/HepNtuple.h" #include "HepTuple/Column.h" #include "HepTuple/Block.h" ZM_USING_NAMESPACE( zmht ) #include "ZMutility/iostream" #include USING( namespace std ) #ifdef DEBUGZ extern "C" { void debugz_(); } #endif Int4 c; Int4 func () { return c; } class Test { int _a; public: Int4 a() {return _a;}; void seta(Int4 f) { _a = f; }; }; int main (int argc, char** argv) { PARSE; Int4 at = 55; Test object; //Float8 arr[10][10]; Float8 arr[3][3]; int dim1 = 3; int dim2 = 3; HepFileManager* manager = OPEN_FILE("complex"); if (manager == NULL ) { cerr << "Could not open file\n"; ::exit(-1); } manager->mkdir("junk"); manager->cd("junk"); HepNtuple & hep = manager->ntuple("CWNTUPLE",1); hep.setColumnWise(); #ifdef DEBUGZ debugz_(); #endif hep.newColumn("Col1",3.2,7.0); hep.newColumn("Col2",8.2); hep.columnAt("colAt",&at); hep.columnAt("colAt2",&at); hep.columnArray("colArray",2,(Float8)8).dimension(dim1,dim2); // The call to capture() doesn't seem to have worked after I declared // some blocks. I have replaced it with captureBlock(...) below. // On a closer look, the question arises -- why are we capturing here at all? // It looks as though we get default values for the simple variables and // random trash for the array!? hep.capture(); hep.storeCapturedData(); hep.clearData(); cout << "\nchform for block: " << hep.blockFormat("_1") << endl; cout << endl; cout << "For loop: "; for (int i=0; i<50; i++) { cout << i << ":"; at = -3*i; c = i; object.seta(5*i); for (int j=0; j < dim1; j++) for (int k=0; k< dim2; k++) { arr[j][k] = 8.2/(i+1)*(j+1)*(k+1); // if ( i < 3 ) cout << j << "," << k << ": " << arr[j][k] << endl; } hep.capture("colArray",&(arr[0][0])); hep.capture(); hep.storeCapturedData(); hep.clearData(); } hep.release(); cout << endl; cout << "\n>>>Make some directory listings." << endl; cout << manager->ls("","r"); delete manager; return 0; }