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


C++ TTree::GetUserInfo方法代码示例

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


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

示例1: Algorithm

RawHitMapMaker::RawHitMapMaker(Parameters* p,bool d)
: Algorithm("RawHitMapMaker")
{
  parameters = p;
  display = d;
  CommonTools::defineColorMap();
  
  TFile* inputFile = TFile::Open(parameters->eventFile.c_str(), "READ");
  TTree* tbtree = (TTree*)inputFile->Get("tbtree");
  summary = (TestBeamDataSummary*)tbtree->GetUserInfo()->At(0);
}
开发者ID:StevenGreen1,项目名称:CLICpix_TestBeamCode,代码行数:11,代码来源:RawHitMapMaker.C

示例2: Algorithm

AkraiaApodosi::AkraiaApodosi(Parameters* p, bool d)
  : Algorithm("AkraiaApodosi") {

  parameters = p;
  display = d;
  TFile* inputFile = TFile::Open(parameters->eventFile.c_str(), "READ");
  TTree* tbtree = (TTree*)inputFile->Get("tbtree");
  summary = (TestBeamDataSummary*)tbtree->GetUserInfo()->At(0);
  m_debug = false;

}
开发者ID:StevenGreen1,项目名称:CLICpix_TestBeamCode,代码行数:11,代码来源:AkraiaApodosi.C

示例3: test5

void test5()
{
  TFile file("test.root"); 
  TTree* tree = (TTree *)file.Get("tree;1");
  TList* list = tree->GetUserInfo() ;
  list->Print();
 
  TObjString* objstr = (TObjString*)list->At(0);
  objstr->Print();

  TString xmlstring = objstr->GetString();
  cout << xmlstring << endl;
}
开发者ID:affablelochan,项目名称:2013codev2,代码行数:13,代码来源:example.C

示例4: cloneAODTreeAndRemoveObject

void cloneAODTreeAndRemoveObject(const char *newFileName = "AliAOD_new.root", const char *orgFileName = "AliAOD.root") {
  // This little macro takes an already created AOD file and clones it.
  // After removing an old brach, the new TTree is written to a new file.

  // open input file and get the TTree
  TFile orgFile(orgFileName, "READ");
  // get original TTree
  TTree *orgAodTree = (TTree*)orgFile.Get("aodTree");
  // switch off one branch (and its subbranches!)
  orgAodTree->SetBranchStatus("tracks*", 0);

  // open new output file
  TFile *newFile = new TFile(newFileName, "RECREATE");
  // clone old TTree (only clones branches that are switched on)
  TTree *newAodTree = orgAodTree->CloneTree();

  // get the event within the new TTree
  AliAODEvent *evNew = new AliAODEvent();
  evNew->ReadFromTree(newAodTree);

  // remove TObject from the list
  evNew->RemoveObject(evNew->GetTracks());

  // delete old and write new UserInfo
  newAodTree->GetUserInfo()->Clear();
  newAodTree->GetUserInfo()->Add(evNew);

  // write new TTree to file
  newAodTree->Write();

  // close files
  newFile->Close();
  delete newFile;

  orgFile.Close();
}
开发者ID:alisw,项目名称:AliRoot,代码行数:36,代码来源:cloneAODTreeAndRemoveObject.C

示例5: writeData

void writeData()
{
  Long_t events = 0;

  // Open file and create tree
  TFile* file = new TFile ("tree1.root", "RECREATE", "", 0);
  TTree* tree = new TTree ("T", Form ("Test Tree for %ld events.", events));

  // Create simple data
  ParamClass* a = new ParamClass ("Alpha", 1);
  a->simpleField = 101;

  tree->GetUserInfo()->Add(a);

  // Create branch for events
  EventClass* eve = 0;

  tree->Branch("EventClass", "EventClass", &eve);
  
  // Fill tree with events
  eve = new EventClass (a, 1);

  // Set TRef using my function
  eve->setTRef(*a);
  ParamClass *b = eve->getTRef();
  std::cout << "b->GetId() " << b->GetId() << std::endl;

  // Set TRef using my function (vector)
  ParamClass* c = new ParamClass ("C", 1);
  eve->addTRefKB(*c);
  ParamClass *d = eve->getTRef();
  std::cout << "d->GetId() " << d->GetId() << std::endl;
  
  tree->Fill();

  // write data and close file
  file->Write();
  file->Close();
}
开发者ID:alekgajos,项目名称:j-pet-framework,代码行数:39,代码来源:gen4.cpp

示例6: Generate

void Generate (Long_t events) {
  
  Long_t r;
  //srand (0);

  // Open file and create tree

  TFile* file = new TFile ("tree1.root", "RECREATE", "", 0);
  TTree* tree = new TTree ("T", Form ("Test Tree for %ld events.", events));

  // Create simple database

  ParamClass* a = new ParamClass ("Alpha",       1);
  ParamClass* b = new ParamClass ("Bravo",       2);
  ParamClass* c = new ParamClass ("ChuckNorris", 3);
  ParamClass* d = new ParamClass ("Damian",      4);

  tree->GetUserInfo()->Add(a);
  tree->GetUserInfo()->Add(b);
  tree->GetUserInfo()->Add(c);
  tree->GetUserInfo()->Add(d);

  // Create branch for events
  
  EventClass* eve = 0;

  tree->Branch("EventClass", "EventClass", &eve);
  
  // Fill tree with events

  for (Long_t i = 0; i < events; ++i) {
    
    //r = rand()%4;
    r = i%4;
    switch (r) {
    
      case 0:
      
      eve = new EventClass (a, 1);
      break;

      case 1:

      eve = new EventClass (b, 2);
      break;

      case 2:

      eve = new EventClass (c, 3);
      break;

      case 3:

      eve = new EventClass (d, 4);
      break;

      default:

      break;
    }

    tree->Fill();
  }

  // write data and close file

  file->Write();
  file->Close();

}
开发者ID:alexkernphysiker,项目名称:j-pet-framework-examples,代码行数:70,代码来源:gen1.cpp

示例7: ReadSpecAOD

void ReadSpecAOD(const char *fileName = "AliMuonAOD.root") {

    gSystem->Load("libTree");
    gSystem->Load("libGeom");
    gSystem->Load("libSTEERBase");
    gSystem->Load("libAOD");
    gSystem->Load("libANALYSIS");			
    gSystem->Load("libPWGHFbase");



  gStyle->SetOptStat(111111);
  gStyle->SetFrameFillColor(10);
  gStyle->SetCanvasColor(10);
  gStyle->SetOptStat(0);
  TH1F *mass=new TH1F("mass","Invariant mass",100,0.,20.);
  TH1F *rap=new TH1F("rap","Rapidity",100,-5.,0.);
  TH1F *cost=new TH1F("cost","Cost_CS",100,-1.,1.);
  TH1F *pt=new TH1F("pt","Pt",100,0.,50.);
  TH1F *ptmuon=new TH1F("ptmuon","single muon Pt",100,0.,50.);

  // open input file and get the TTree
  TFile inFile(fileName, "READ");
  TTree *aodTree = (TTree*)inFile.Get("AOD");

  AliAODEvent *aod = (AliAODEvent*)aodTree->GetUserInfo()->FindObject("AliAODEvent");

  TClonesArray *Dimuons;
  TClonesArray *tracks;
  TClonesArray *vertices;
  AliAODEventInfo *MuonInfos;
  
  aodTree->SetBranchAddress("Dimuons",&Dimuons);
  aodTree->SetBranchAddress("tracks",&tracks);
  aodTree->SetBranchAddress("vertices",&vertices);
  aodTree->SetBranchAddress("MuonInfos",&MuonInfos);

  // loop over events
  Int_t nEvents = aodTree->GetEntries();
  for (Int_t nEv = 0; nEv < nEvents; nEv++) {
    cout << "Event: " << nEv+1 << "/" << nEvents << endl;
    aodTree->GetEntry(nEv);
    // loop over tracks
    Int_t nTracks = tracks->GetEntries();
    for (Int_t nTr = 0; nTr < nTracks; nTr++) {
      AliAODTrack *tr = (AliAODTrack *)tracks->At(nTr);
      ptmuon->Fill(tr->Pt());
      // print track info
      cout << nTr+1 << "/" << nTracks << ": track pt: " << tr->Pt();
      if (tr->GetProdVertex()) {
	cout << ", vertex z of this track: " << tr->GetProdVertex()->GetZ();
      }
      cout << endl;
    }
    // loop over dimuons
    
    Int_t nDimuons = Dimuons->GetEntries();
    cout << nDimuons << " dimuon(s)" << endl;
    for(Int_t nDi=0; nDi < nDimuons; nDi++){
      AliAODDimuon *di=(AliAODDimuon*)Dimuons->At(nDi);
       if((MuonInfos->MUON_Unlike_HPt_L0())){
         mass->Fill(di->M());
         pt->Fill(di->Pt());
         rap->Fill(di->Y());
         cost->Fill(di->CostCS());
         cout << "Dimuon: " << nDi << " q: " << di->Charge() 
	      << " m: " << di->M() << " Y: " << di->Y() << " Pt: " << di->Pt()<< " CostCS: " << di->CostCS() << endl  ;
       }
    }
//     // loop over vertices
//     Int_t nVtxs = vertices->GetEntries();
//     for (Int_t nVtx = 0; nVtx < nVtxs; nVtx++) {
//       
//       // print track info
//       cout << nVtx+1 << "/" << nVtxs << ": vertex z position: " <<vertices->At(nVtx)->GetZ() << endl;
//     }
  }
  inFile.Close();
  TCanvas *c1=new TCanvas();
  c1->Show();
  c1->Divide(2,2);
  c1->ForceUpdate();
  c1->cd(1);
  mass->DrawClone();
  c1->cd(2);
  rap->DrawClone();
  c1->cd(3);
  pt->DrawClone();
  c1->cd(4);
  cost->DrawClone();
  
  TCanvas *c2 = new TCanvas();
  c2->cd();
  ptmuon->DrawClone();
  return;
}
开发者ID:ktf,项目名称:AliPhysics,代码行数:96,代码来源:ReadSpecAOD.C


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