本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}