// // This file test the possibility of adding columns // after the first store of a row-wise or a column wise // ntuple. // #include #include #include #include #include #include void rowWiseAdd(HepFileManager* manager) { HepNtuple& hep = manager->ntuple("rowNtuple",1); hep.setRowWise(); hep.newColumn("Col1",(float)3.2,(float)99); hep.newColumn("Col2",(float)8.2,(float)99); hep.storeCapturedData(); hep.clearData(); cout << "loop: "; for (int i=0; i<50; i++) { cout << i << "."; hep.capture("Col1",(float)3.2+i); hep.capture("Col2",(float)8.2+2*i); hep.storeCapturedData(); hep.clearData(); } hep.newColumn("Col3",(float)7.2,(float)99); hep.newColumn("Col4",(float)11.2,(float)99); hep.storeCapturedData(); hep.clearData(); cout << "loop: "; for (int i=0; i<50; i++) { cout << i << "."; hep.capture("Col3",(float)7.2+i); hep.capture("Col4",(float)11.2+2*i); hep.storeCapturedData(); hep.clearData(); } cout << endl; } void columnWiseAdd(HepFileManager* manager) { HepNtuple& hep = manager->ntuple("columnNtuple",2); hep.setColumnWise(); hep.newColumn("Col1",(float)3.2,(float)99); hep.newColumn("Col2",(float)8.2,(float)99); hep.storeCapturedData(); hep.clearData(); cout << "loop: "; for (int i=0; i<50; i++) { cout << i << "."; hep.capture("Col1",(float)3.2+i); hep.capture("Col2",(float)8.2+2*i); hep.storeCapturedData(); hep.clearData(); } hep.newColumn("Col3",(float)7.2,(float)99); hep.newColumn("Col4",(float)11.2,(float)99); hep.captureColumn("Col1"); hep.captureColumn("Col2"); hep.storeCapturedData(); hep.clearData(); cout << "loop: "; for (int i=0; i<50; i++) { cout << i << "."; hep.captureColumn("Col1"); hep.captureColumn("Col2"); hep.capture("Col3",(float)7.2+i); hep.capture("Col4",(float)11.2+2*i); hep.storeCapturedData(); hep.clearData(); } cout << endl; } int main (int argc, char* argv[]) { HepFileManager* manager = new HepHBookFileManager("add.rz"); rowWiseAdd(manager); columnWiseAdd(manager); delete manager; return 0; }