21 gSystem->Load(
"libTable");
25 TObject *nextObject = 0;
30 UInt_t totalEvent = 4;
31 UInt_t runNumber = 20010301;
35 for (i = 1;i<totalEvent;i++) {
36 outSet->
NextEventPut(ds,UInt_t(i),UInt_t(runNumber+j+10*run.Rndm()-5));
41 printf(
" ----------------------> TFile has been created <--------------------\n");
42 TFile *f =
new TFile(
"test.root");
45 Int_t size = readObj.TotalKeys();
46 printf(
" The total number of the objects: %d\n",size);
51 printf(
" -- > Loop over all objects, read them in to memory one by one < -- \n");
52 printf(
" -- > Use the second iterator that with the pace twice as large as the first one < -- \n");
55 for( readObj = 0; int(readObj) < size; ++readObj,secondIter += 2)
57 nextObject = *readObj;
58 printf(
" -- %d bytes of the object \"%s\" of class \"%s\" written with TKey \"%s\" has been read from file\n"
60 ,nextObject->GetName()
61 ,nextObject->IsA()->GetName()
62 ,(
const char *)readObj
64 delete nextObject; nextObject = 0;
65 nextObject = *secondIter;
67 printf(
" %d bytes of the object \"%s\" of class \"%s\" written with TKey \"%s\" has been read from file\n\n"
68 ,secondIter.GetObjlen()
69 ,nextObject->GetName()
70 ,nextObject->IsA()->GetName()
71 ,(
const char *)secondIter
77 printf(
" Leaving the scope to destroy the stack allocated secondIter\n");
81 printf(
" -- > Now loop over all objects in inverse order < -- \n");
82 for( readObj = size-1; (int)readObj >= 0; --readObj)
84 nextObject = *readObj;
86 printf(
" Object \"%s\" of class \"%s\" written with TKey \"%s\" has been read from file\n"
87 ,nextObject->GetName()
88 , nextObject->IsA()->GetName()
89 ,(
const char *)readObj
93 printf(
"Error reading file by index\n");
98 printf(
" -- > Loop over the objects starting from the object with the key name \"event.02.01\" < -- \n");
99 for( readObj =
"event.02.01"; (
const char *)readObj != 0; ++readObj){
100 nextObject = *readObj;
101 printf(
" Object \"%s\" of class \"%s\" written with Tkey \"%s\" has been read from file\n"
102 , nextObject->GetName()
103 , nextObject->IsA()->GetName()
104 , (
const char *)readObj
109 printf(
" -- > Loop over the objects starting from the 86-th object < -- \n");
110 for( readObj = (
const char *)(readObj = 86); (
const char *)readObj != 0; ++readObj){
111 nextObject = *readObj;
112 printf(
" Object \"%s\" of class \"%s\" written with Tkey \"%s\" has been read from file\n"
113 , nextObject->GetName()
114 , nextObject->IsA()->GetName()
115 , (
const char *)readObj
120 printf(
" -- > Check file name mapping facility. < -- \n");
123 resource.open(TFileIter::GetDefaultMapFileName());
124 resource << TFileIter::GetLocalFileNameKey()<<
" /hpss/test" << endl;
125 resource << TFileIter::GetForeignFileSystemKey() <<
" test" << endl;
128 TFileIter testMapping(
"/hpss/test.root");
129 if (testMapping.TotalKeys() == readObj.TotalKeys()) {
130 printf(
" -- > the fake file \"/hpss/test.root\" has been mapped to the real file \"test.root\"\n");
132 printf(
" -- > the fake file \"/hpss/test.root\" failed to be mapped to the real file \"test.root\"\n");
virtual Int_t NextEventPut(TObject *obj, UInt_t eventNum, UInt_t runNumber, const char *name=0)
Create a special TKey name with obj provided and write it out.