18 #include "TObjString.h"
27 fxType(0),fxDataSet(), fxDataSpace(0), fxFileSpace(0), fiEntries(0),
28 fxData(0), fiParentOffset(0),fiDataSize(datasize), fiReadOffset(0),
29 fxEvent(0), fxParentSource(0), fbDataSetExists(false), fbDataSetActive(false)
32 fxType =
new H5::CompType(datasize);
33 go4hdfdbg(
"TGo4HDF5DataHandle DDD created %s for size %ld \n",
fxTypeName.Data(), datasize);
55 fxType->insertMember( name, offset, new_member);
77 if(strcmp(cursor->
GetTypeName(),name)==0)
return cursor;
81 if (subcursor)
return subcursor;
101 go4hdfdbg(
"TGo4HDF5DataHandle SetObjectPointer for %s with memptr 0x%lx and parentoffset 0x%lx has fxData:0x%lx\n",
118 "TTTTTTTT TGo4HDF5DataHandle %s - SetTopEvent sets pointer to %ld \n",
180 hsize_t offset[1]= {sequencenum};
181 hsize_t onerow[1] ={1};
182 fxFileSpace.selectHyperslab( H5S_SELECT_SET, onerow, offset );
186 go4hdfdbg(
"TGo4HDF5DataHandle::Read of %s has selected hyperslab for onerow:[%ld] offset:[%ld]\n",
187 fxTypeName.Data(),(
unsigned long) onerow[0], (
unsigned long) offset[0]);
197 entry->
Read(sequencenum, file);
214 go4hdfdbg(
"TGo4HDF5DataHandle::Write %s base function will extend dataset for %lld \n",
fxTypeName.Data(), sequencenum);
215 hsize_t offset[1] = { sequencenum };
216 hsize_t nextsize[1] = { sequencenum + 1 };
221 hsize_t onerow[1] = { 1 };
222 fxFileSpace.selectHyperslab(H5S_SELECT_SET, onerow, offset);
234 entry->
Write(sequencenum, file);
249 go4hdfdbg(
"TGo4HDF5BasicDataHandle ctor\n");
266 go4hdfdbg(
"TGo4HDF5DataHandle: AllocReadBuffer has created read buffer 0x%lx for size %ld \n",
280 hsize_t dims[1] = { 1};
281 hsize_t maxdims[1] = {H5S_UNLIMITED};
282 fxDataSpace=
new H5::DataSpace(rank, dims, maxdims);
285 hsize_t onerow[1] ={1};
286 hsize_t offset[1]= {0};
287 fxDataSpace->selectHyperslab( H5S_SELECT_SET, onerow, offset );
304 H5T_class_t type_class = fxDataSet.getTypeClass();
306 if( type_class == H5T_COMPOUND)
308 intype= fxDataSet.getCompType();
310 go4hdfdbg(
"TGo4HDF5DataHandle::BuildReadDataSet finds in file compound type of size %ld \n", intype.getSize());
312 else if( type_class == H5T_VLEN)
314 H5::VarLenType vtype = fxDataSet.getVarLenType();
315 H5::DataType entrytype = vtype.getSuper();
319 H5T_class_t entry_class = entrytype.getClass();
320 go4hdfdbg(
"TGo4HDF5DataHandle::BuildReadDataSet finds in file vlen type of size %ld, with entry class %d , size %ld \n",
321 vtype.getSize(), entry_class, entrytype.getSize());
322 if( entry_class == H5T_COMPOUND)
325 H5::DataType* ptype=&entrytype;
326 H5::CompType* entrycomp =
static_cast<H5::CompType*
>(ptype);
329 go4hdfdbg(
"TGo4HDF5DataHandle::BuildReadDataSet uses compound entry of vlen dtype %d \n", entry_class );
333 go4hdfdatahandlethrow(
"TGo4HDF5DataHandle: BuildReadDataSet - could not assign component entry of varlen data type !\n");
339 go4hdfdatahandlethrow(
"TGo4HDF5DataHandle: BuildReadDataSet - varlen data type without compound, but contains class %d!\n", entry_class);
344 go4hdfdatahandlethrow(
"TGo4HDF5DataHandle: BuildReadDataSet - file contains no compound or varlen data type, but type %d!\n",type_class)
350 hsize_t dims_out[frank];
352 go4hdfdbg(
"TGo4HDF5DataHandle::BuildReadDataSet file dataspace has rank %d, dimensions:%d, #1. dimension=%ld \n",
355 (
unsigned long)(dims_out[0]));
360 int nfilemembers= intype.getNmembers ();
361 int neventmembers=
fxType->getNmembers ();
364 go4hdfdbg(
"Type comparison: number of compound members: file %d, event %d\n",nfilemembers, neventmembers);
367 for (
int i = 0; i < nfilemembers; ++i)
369 H5::DataType mem_type=intype.getMemberDataType(i);
370 go4hdfdbg(
"\t %d: name:%s class:%s", i, intype.getMemberName(i).c_str(), mem_type.fromClass().c_str());
371 H5T_class_t mem_class = intype.getMemberClass(i);
372 if (mem_class == H5T_ARRAY)
374 H5::ArrayType artyp = intype.getMemberArrayType(i);
375 int ardim = artyp.getArrayNDims();
377 artyp.getArrayDims(dims);
378 go4hdfdbg(
" array dimensions:%d [", ardim);
379 for (
int j = 0; j < ardim; ++j)
387 go4hdfdbg(
"Dump Type from event structure:\n");
388 for (
int i = 0; i < neventmembers; ++i)
390 H5::DataType mem_type=
fxType->getMemberDataType(i);
391 go4hdfdbg(
"\t %d: name:%s class:%s", i, intype.getMemberName(i).c_str(), mem_type.fromClass().c_str());
392 H5T_class_t mem_class =
fxType->getMemberClass(i);
393 if (mem_class == H5T_ARRAY)
395 H5::ArrayType artyp =
fxType->getMemberArrayType(i);
396 int ardim = artyp.getArrayNDims();
398 artyp.getArrayDims(dims);
399 go4hdfdbg(
"array dimensions:%d [", ardim);
400 for (
int j = 0; j < ardim; ++j)
402 go4hdfdbg(
"%lu", (
unsigned long) dims[j]);
413 TString
msg= TString::Format(
"BuildReadDataSet type mismatch between event structure(%s) and input from file (%s)\n",
414 fxType->fromClass().c_str(), intype.fromClass().c_str());
437 go4hdfdbg(
"TGo4HDF5BasicDataHandle: BuildWriteDataset for event set %s\n",
fxTypeName.Data());
439 hsize_t dims[1] = { 1 };
440 hsize_t maxdims[1] = { H5S_UNLIMITED };
441 fxDataSpace =
new H5::DataSpace(rank, dims, maxdims);
443 H5::DSetCreatPropList cparms;
444 hsize_t chunk_dims[1] = { 1 };
445 cparms.setChunk(rank, chunk_dims);
478 memcpy (target, source, copylen);
481 printf(
"Copy %ld bytes from %lx to %lx, fiReadOffset=%ld, fiDataSize=%ld \n",
482 copylen, (
long) source, (
long)target, fiReadOffset,
fiDataSize);
512 go4hdfdbg(
"TGo4HDF5CompositeDataHandle ctor use go4 composite event component\n");
575 go4hdfdbg(
"TGo4HDF5VectorDataHandle ctor \n");
585 go4hdfdbg(
"TGo4HDF5VectorDataHandle ctor, typename is %s\n",
623 char** p_collection = (
char**)
fxData;
624 char** p_begin_ptr = p_collection;
625 char** p_end_ptr = p_collection + 1;
628 go4hdfdbg(
"TGo4HDF5VectorDataHandle SetObjectPointer has fxData=0x%lx elementsize=%ld\n",
640 static unsigned debugcount = 0;
641 char** p_cap_ptr = p_collection + 2;
643 if (debugcount < 10000)
646 "TGo4HDF5VectorDataHandle SetObjectPointer for count %d has collection size: %ld capacity: %ld pointer to buffer 0x%lx, ACTIVE=%d\n",
671 go4hdfdbg(
"TGo4HDF5VectorDataHandle: BuildWriteDataset for collection set %s \n",
fxTypeName.Data());
674 hsize_t dims[1] = { 1};
675 hsize_t maxdims[1] = {H5S_UNLIMITED};
676 fxDataSpace=
new H5::DataSpace(rank, dims, maxdims);
677 H5::DSetCreatPropList cparms;
678 hsize_t chunk_dims[1] ={1};
679 cparms.setChunk( rank, chunk_dims );
719 go4hdfdbg(
"TGo4HDF5VectorDataHandle::Read LLLL length after reading is %ld, buffer is 0x%lx \n",
775 TString vectorhandle = TString::Format(
"myevent->%s",
fxMemberHandle.Data());
776 TString copycom = TString::Format(
"%s * myevent= (%s *) %ld; %s.insert(%s.end(), (%s *) %ld, (%s *) %ld)",
780 go4hdfdbg(
"TGo4HDF5VectorDataHandle::Read will use command: %s \n", copycom.Data());
781 gROOT->ProcessLineFast(copycom.Data());
786 char** p_collection = (
char**)
fxData;
787 char** p_begin_ptr = p_collection;
788 char** p_end_ptr = p_collection + 1;
789 char** p_cap_ptr = p_collection + 2;
795 "TGo4HDF5VectorDataHandle::Read after INSERT has collection size: %ld capacity: %ld pointer to buffer 0x%lx, end: 0x%lx cap: 0x%lx\n",
796 len, cap, (
unsigned long) *p_begin_ptr, (
unsigned long) *p_end_ptr, (
unsigned long) *p_cap_ptr);
825 go4hdfdbg(
"TGo4HDF5VectorDataHandle::Write DO NOT WRITE inactive %s collection\n",
fxTypeName.Data());
844 go4hdfdbg(
"TGo4HDF5SubVectorDataHandle ctor \n");
871 size_t innersize=datatype.Size();
883 TString fullname= TString::Format(
"%s[%d]",
GetTypeName(), ix );
884 TString membername = TString::Format(
"%s[%d]",
fxMemberHandle.Data(),ix);
887 "TGo4HDF5SubVectorDataHandle SetObjectPointer updating element %s , inner class is %s\n",
894 TString memberclass = TString::Format(
"vector<%s>",
fxInnerClassName.Data());
895 TString searchname = TString::Format(
"%s[%s]",fullname.Data(), memberclass.Data());
900 "TGo4HDF5SubVectorDataHandle SetObjectPointer finds element %s , already in subcomponents\n",
902 subhandle->SetActive(
true);
907 "TGo4HDF5SubVectorDataHandle SetObjectPointer creates new subcomponent %s \n",
910 subhandle =
AddSubMember(fullname.Data(), innersize, memberclass.Data());
916 subhandle->SetActive(
true);
928 char* subvector = cursor;
930 size_t delta= (
char*) cursor - (
char*) super;
931 go4hdfdbg(
"TGo4HDF5SubVectorDataHandle SetObjectPointer sets parent offset %ld (subvector:0x%lx, super:0x%lx) cursor was 0x%lx\n",
932 delta, (
unsigned long) subvector, (
unsigned long) super, (
unsigned long) cursor);
934 subhandle->SetParentOffset(delta);
935 subhandle->SetObjectPointer(super);
959 go4hdfdbg(
"TGo4HDF5SubVectorDataHandle: BuildWriteDataset NOP for collection set %s \n",
fxTypeName.Data());
1020 if (strstr(type,
"vector<vector") != 0)
1023 TString theName(name);
1024 TString theCollection(type);
1026 theName = theName.Append(theCollection);
1030 TObjArray* tokens = theCollection.Tokenize(
"<");
1033 TObjString* part =
dynamic_cast<TObjString*
>(tokens->At(2));
1036 TString rtype = part->GetString();
1037 TObjArray* stokens = rtype.Tokenize(
">");
1040 TObjString* spart =
dynamic_cast<TObjString*
>(stokens->At(0));
1041 TString valuetype = spart->GetString();
1043 go4hdfdbg(
"TGo4HDF5DataHandleFactory::CreateDataHandle for %s sets inner class name to %s\n", type,
1049 go4hdfdbg(
"TGo4HDF5DataHandleFactory::CreateDataHandle for %s could not evaluate valuetype from %ss\n", type,
1050 theCollection.Data());
1055 go4hdfdbg(
"TGo4HDF5DataHandleFactory::CreateDataHandle for %s could not evaluate valuetype from %ss\n", type,
1056 theCollection.Data());
1062 else if (strstr(type,
"vector") != 0)
1065 TString theName(name);
1066 TString theCollection(type);
1068 theName = theName.Append(theCollection);
1074 else if (strstr(type,
"Go4Comp") != 0)
void SetInnerClassName(const char *nm)
void SetActive(Bool_t on)
virtual void BuildReadDataset(H5::H5File *file, TGo4HDF5Source *parent)
H5::DataSpace * fxDataSpace
virtual void BuildReadDataset(H5::H5File *file, TGo4HDF5Source *parent)
void InsertTypeMember(const H5std_string &name, size_t offset, const H5::DataType &new_member)
void AllocReadBuffer(size_t size)
virtual ~TGo4HDF5BasicDataHandle()
TGo4HDF5DataHandle * CreateDataHandle(const char *name, size_t datasize, const char *type)
TGo4EventElement * fxEvent
#define go4hdfdatahandlethrow(args...)
void Read(hsize_t sequencenum, H5::H5File *file)
virtual void Write(hsize_t sequencenum, H5::H5File *ile)
virtual void BuildWriteDataset(H5::H5File *file)
virtual void SetObjectPointer(void *memptr)
static void FillTypeInfo(TGo4HDF5DataHandle *handle, TClass *rootclass, const char *basename=0)
virtual void Read(hsize_t sequencenum, H5::H5File *file)
virtual void BuildReadDataset(H5::H5File *file, TGo4HDF5Source *parent)
void SetAllSubMembersActive(Bool_t on)
virtual void BuildWriteDataset(H5::H5File *file)
H5::DataSpace fxFileSpace
virtual void Write(hsize_t sequencenum, H5::H5File *file)
virtual void Read(hsize_t sequencenum, H5::H5File *file)
void SetErrMess(const char *txt)
std::vector< TGo4HDF5DataHandle * > fxSubcomponents
virtual void Read(hsize_t sequencenum, H5::H5File *file)
virtual ~TGo4HDF5SubVectorDataHandle()
virtual void Write(hsize_t sequencenum, H5::H5File *file)
virtual void Write(hsize_t sequencenum, H5::H5File *file)
virtual void BuildWriteDataset(H5::H5File *file)
void BuildWriteDataset(H5::H5File *file)
#define go4hdfdbg(args...)
virtual ~TGo4HDF5VectorDataHandle()
virtual ~TGo4HDF5DataHandle()
void SetTopEventClass(const char *classname)
const char * GetTypeName()
void SetTopEvent(TGo4EventElement *eve)
TGo4HDF5CompositeDataHandle(const char *name, size_t datasize)
TGo4HDF5BasicDataHandle(const char *name, size_t datasize)
virtual void BuildReadDataset(H5::H5File *file, TGo4HDF5Source *parent)
TGo4HDF5Source * fxParentSource
virtual void BuildWriteDataset(H5::H5File *file)
TGo4HDF5SubVectorDataHandle(const char *name, size_t datasize)
void Write(hsize_t sequencenum, H5::H5File *file)
TGo4HDF5DataHandle(const char *name, size_t datasize)
TGo4HDF5DataHandle * FindSubMember(const char *name)
virtual void SetObjectPointer(void *memptr)
virtual void Read(hsize_t sequencenum, H5::H5File *file)
virtual void SetObjectPointer(void *memptr)
static TGo4HDF5DataHandleFactory fxFactory
TGo4HDF5VectorDataHandle(const char *name, size_t datasize)
TGo4HDF5VarContainer fxVarHandle
H5::CompType * fxCollection
TGo4HDF5DataHandle * AddSubMember(const char *name, size_t datasize, const char *collectiontype=0)
static void Error(const char *text,...)
void BuildReadDataset(H5::H5File *file, TGo4HDF5Source *parent)
void SetMemberName(const char *name)
void SetElementSize(size_t len)
virtual ~TGo4HDF5CompositeDataHandle()