当前位置: 首页>>代码示例>>C++>>正文


C++ TBranch::Write方法代码示例

本文整理汇总了C++中TBranch::Write方法的典型用法代码示例。如果您正苦于以下问题:C++ TBranch::Write方法的具体用法?C++ TBranch::Write怎么用?C++ TBranch::Write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TBranch的用法示例。


在下文中一共展示了TBranch::Write方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Write

void Write(bool write=false) 
{
   TFile *f    = new TFile("RootRelations.root", "RECREATE", "Root RootRelations test",0);
   TTree *tree = new TTree("T","An example of a ROOT tree");
   Relation1D<int,float>* obj = new Relation1D<int,float>();

   if (gDebug>0) {
      fprintf(stderr,"Relation1D<int,float> is %p\n",obj);
      fprintf(stderr,"DataObject is %p\n",(DataObject*)obj);
      fprintf(stderr,"Relation<int,float> is %p\n",(Relation<int,float>*)obj);
      fprintf(stderr,"m_direct is %p\n",&(obj->m_direct));
      fprintf(stderr,"m_direct.m_entries is %p\n",&(obj->m_direct.m_entries));
   }

   TBranch *b = tree->Branch("B", "Relation1D<int,float>", &obj);

   
   if (write) {
      
      printf("relations' write\n");
      for(int i=0; i < 10; ++i) {

         obj->m_direct.m_entries.push_back(std::pair<int,float>(10*i,i));
         DataTObject *dobj = new ( obj->m_direct.m_tentries[0] ) DataTObject(i*22,i*22/3.0);
         DataTObject *dobj2 = new ( (*(obj->m_direct.m_ptentries))[0] ) DataTObject(i*44,i*44/3.0);
	 if (!dobj || !dobj2) return;

         printf("byte written for entry   #%d: %d\n",i,tree->Fill());

         if (gDebug>0) {
            printf("byte re-read for the same entry: %d %p\n", tree->GetEvent(i), obj); 
         }
	 if (i<0) {
           fprintf(stderr,"the pointer are %p and %p\n",
                   dobj,obj->m_direct.m_tentries.At(0));
         }
         printf("values written for entry #%d: %d, %f, %d, %f, %d, %f\n", i,
                obj->m_direct.m_entries[0].first,
                obj->m_direct.m_entries[0].second,
                ((DataTObject*)obj->m_direct.m_tentries.At(0))->i,
                ((DataTObject*)obj->m_direct.m_tentries.At(0))->j,
                ((DataTObject*)obj->m_direct.m_ptentries->At(0))->i,
                ((DataTObject*)obj->m_direct.m_ptentries->At(0))->j
                ); 

         obj->m_direct.m_entries.clear();
         obj->m_direct.m_tentries.Clear();
      }
      b->Write();
      tree->Write();
      tree->Print();
      f->Write();
   }
   delete f;
};
开发者ID:asmagina1995,项目名称:roottest,代码行数:55,代码来源:relations_write.C


注:本文中的TBranch::Write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。