[size=150]
Hallo,
I’ve a problem with a vector I want to store in a tree and read out again afterwards. I fill the tree with the following code:
[/size]
vector *tidentivec = new vector;
TFile fi(“identi.root”,“recreate”);
TTree *Treeidenti = new TTree(“Treeidenti”,“Vectortree”);
Treeidenti->Branch(“tidentivec”,“vector”,&tidentivec);
for(Int_t i=0; ipush_back(Identivec[idselectarr->At(i)]);
Treeidenti->Fill();
}
fi.cd();
Treeidenti->Write();
}
[size=150]and afterwards I read it out with the following code[/size]
//identifiertree
TFile *ifile = new TFile(“identi.root”);
TTree Treeidenti = (TTree)ifile->Get(“Treeidenti”);
//Declaration of leaves types
vector *tidentivec = new vector;
//Set branch address
Treeidenti->SetBranchAddress(“tidentivec”,&tidentivec);
Int_t id = Treeidenti->GetEntries();
//create canvas and histogram with time on xaxis
c1 = new TCanvas(“c1”,“Time on Axis”,10,10,600,800);
int i=0;
int c=0;
Int_t p = tfg->GetEntries();
c = ceil(sqrt(4));
c1->Divide(c,c);
TDatime da(2006,05,11,00,00,00);
gStyle->SetTimeOffset(da.Convert());
gStyle->SetOptStat(11);
TH2F *hist = new TH2F(“hist”, “Temperature vs. time”,900,40000,86400,100,-30,30);
TArrayD *tstoparr = new TArrayD§;
for(Int_t i=0;i
GetEntry(i);
tstoparr -> AddAt(tstop,i);
}
//read all entries and fill histogram
Int_t nentries = Envronetree->GetEntries();
for (Int_t z=1;z<4>cd(z);
for(Int_t i=tstoparr->At(z-1); iAt(z); i++){
Envronetree->GetEntry(i);
hist->Fill(ttsec,tval);
}
[size=150] Treeidenti->GetEntry(i); [/size]
hist -> SetTitle(“Temperature vs.time”);
hist -> GetYaxis() -> SetTitle(“temperature [#circC]”);
hist -> GetXaxis() -> SetTitle(“time [sec]”);
hist -> GetXaxis() -> SetLabelSize(0.03);
hist -> GetXaxis() -> SetTimeDisplay(1);
hist -> GetXaxis() -> SetTimeFormat("%H:%M");
hist -> DrawCopy();
hist -> Reset();
[size=150]
Now I want to know how to display the string. It’s not possible with cout<< tidentivec <<endl; … because I get a number then. Or is there a mistake in filling and reading the tree?
I would like to use the strings stored in the vector as title of the Histograms . How is this possible ?
Many thanks for any help
[/size]
Readdat.C (5.96 KB)
Drawdat.C (3.26 KB)