Thanks for the suggestion.
However, I need to use the array of vectors to keep the correct position of each element in the array in the output file.
Here is a similar example code of what I try to do:
#define test_class_cxx
#include “test_class.h”
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
using namespace std;
Double_t b1[12][12];
vector a1[12];
void test_class::Loop()
{
TFile *out_file = new TFile(“temp.root”, “recreate”);
TTree *t1 = new TTree(“Mytree”,“Mytree”);
t1->Branch(“b1”,b1,“b1[13][13]/F”);
Long64_t nentries = fChain->GetEntriesFast();
Long64_t nbytes = 0, nb = 0;
for (Long64_t jentry=0; jentry<nentries;jentry++) {
Long64_t ientry = LoadTree(jentry);
if (ientry < 0) break;
nb = fChain->GetEntry(jentry); nbytes += nb;
for(int i=0;i<12;i++) {
a1[i].clear();
}
for (int i=0;i<12;i++) {
for (int j=0;j<12;j++){
b1[i][j]=0;
}}
for(int i=0; i<12 ; i++) {
for(int j=0; j<12; j++) {
a1[j].push_back(Particle_jer[i]);
}}
for(int i=0; i<12 ; i++) {
for(int j=0; j<12; j++) {
b1[i][j]=a1[i][j];
}}
t1->Fill();
}
out_file->Write();
out_file->Close();
}
I should point out that the array of vectors for float and double variables behave similarly.
Although the input variable (Particle_jer) range is in only 2 bins [-1000,-999],[0,1], the range of X-axe in the output b1 branch is extended to 10^36.
Could you let me know how to solve the problem?
Thanks.