Hi everyone, I’m new in this forum and I’m looking for an help to try to solve my problem with a Tree.
I want to plot a branch of my Tree (“Events”) but if I use from terminal
Events->Draw("-channels[1].regions[0].integral")
I can obtain what I want, instead if I put it in a macro I have some problems, because I don’t know how set the address of the branch with a vector (I need Br 37!)
*Br 35 :channels.npulses : Int_t npulses[channels_] *
*Entries : 500000 : Total Size= 8006413 bytes File Size = 690528 *
*Baskets : 53 : Basket Size= 2052096 bytes Compression= 11.59 *
*............................................................................*
*Br 36 :channels.pulses : vector<Pulse> pulses[channels_] *
*Entries : 500000 : Total Size= 11007924 bytes File Size = 803508 *
*Baskets : 67 : Basket Size= 2821120 bytes Compression= 13.70 *
*............................................................................*
*Br 37 :channels.regions : vector<Roi> regions[channels_] *
*Entries : 500000 : Total Size= 539262020 bytes File Size = 132591572 *
*Baskets : 2572 : Basket Size= 28608512 bytes Compression= 4.07 *
*............................................................................*
*Br 38 :channels.single_pe : vector<Spe> single_pe[channels_] *
*Entries : 500000 : Total Size= 11008137 bytes File Size = 805135 *
*Baskets : 67 : Basket Size= 2821632 bytes Compression= 13.67 *
*............................................................................*
*Br 39 :channels.integral_max : Double_t integral_max[channels_] *
*Entries : 500000 : Total Size= 14010002 bytes File Size = 742669 *
*Baskets : 81 : Basket Size= 3590656 bytes Compression= 18.86 *
*............................................................................*
I tried this, but it doesn’t work.
TFile* file = new TFile(fileName, "READ");
TTree* tree = (TTree*)file->Get("Events");
Long64_t nentries = tree->GetEntries();
cout<<"The tree contains "<<nentries<<" entries"<<endl;
std::vector<float> *regions[channels_] = 0;
tree->SetBranchAddress("vector<float>",®ions[channels_]);
TH1F* h_source = new TH1F("h_source", "Spectrum", 300, 0, 40000);
for(Long64_t entry = 0; entry < nentries; entry++) {
tree->GetEntry(entry);
if(regions[channels_] > 0) {
h_source->Fill(regions[channels_];
}
}
tree->Print();
TCanvas* c1 = new TCanvas();
h_source->Draw();
Probably is an easy question and I’ve done a mess, but I’m at the beginning with Root and furthermore I don’t speak english very well.
Thanks