TTreeTableInterface, problem in compyling the code

Hi all,

I have to write a fuction that plot in a table 2 type of values: std::string and int.
I chose to use the TGTable.

Going through internet documentation it seems that I need to create a TTree with all the information that I need and use the TTreeTableInterface class.

This is what I’m doing in my function:

[code]TGMainFrame* AvailableModulesSummaryTable(ProcessPosition PP, std::vectorstd::string modules){

HistoReader *module_reader_HV_1, *module_reader_noHV_1,*module_reader_HV_2, *module_reader_noHV_2;

// std::vector disconnectedbumps, bad_digi_ana, high_noise, merged, badpixelmonsterhierarchy;
// std::vectorstd::string FE_ID;

int disconnectedbumps, bad_digi_ana, high_noise, merged;
std::vector badpixelmonsterhierarchy;
std::string FE_ID;

// FILLING THE VECTORS FOR THE TABLE
TNtuple *ntuple = new TNtuple(“ntuple”, “DemoNtuple”, “Bad_digi_ana:Disconnected:High_noise:Merged”);
TTree *tl = new TTree(“tl”,“a simple TTree with simples variables”);
tl->Branch(“FE_ID”, &FE_ID);
tl->Branch(“bad_digi_ana”,&bad_digi_ana);
tl->Branch(“high_noise”,&high_noise);
tl->Branch(“merged”,&merged);

int counter = 0;
for(std::vectorstd::string::iterator iii = modules.begin(); iii != modules.end(); iii++){

if (DbTools::GetInstance()->IsDoubleChip(iii->c_str())==1) {
  module_reader_HV_1 = new HistoReader(iii->c_str(), PP, 0,1);
module_reader_noHV_1 = new HistoReader(iii->c_str(), PP, 0,0);

badpixelmonsterhierarchy = BadPixelMonsterHierarchy(module_reader_HV_1, module_reader_noHV_1);

/* bad_digi_ana.push_back(badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4]);
disconnectedbumps.push_back(badpixelmonsterhierarchy[2]);
merged.push_back(badpixelmonsterhierarchy[0]);
high_noise.push_back(badpixelmonsterhierarchy[1]);
FE_ID.push_back(*iii+"_0");
*/
bad_digi_ana=badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4];
disconnectedbumps=badpixelmonsterhierarchy[2];
merged=badpixelmonsterhierarchy[0];
high_noise=badpixelmonsterhierarchy[1];
FE_ID=(*iii+"_0");

counter++;
tl->Fill();

// ntuple->Fill(bad_digi_ana[counter], disconnectedbumps[counter],merged[counter],high_noise[counter],counter);

module_reader_HV_2 = new HistoReader(iii->c_str(), PP, 1,1);
module_reader_noHV_2 = new HistoReader(iii->c_str(), PP, 1,0);

badpixelmonsterhierarchy = BadPixelMonsterHierarchy(module_reader_HV_2, module_reader_noHV_2); 

/* bad_digi_ana.push_back(badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4]);
disconnectedbumps.push_back(badpixelmonsterhierarchy[2]);
merged.push_back(badpixelmonsterhierarchy[0]);
high_noise.push_back(badpixelmonsterhierarchy[1]);
FE_ID.push_back(*iii+"_1");
counter++;
ntuple->Fill(bad_digi_ana[counter], disconnectedbumps[counter],merged[counter],high_noise[counter],counter);
*/
bad_digi_ana=badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4];
disconnectedbumps=badpixelmonsterhierarchy[2];
merged=badpixelmonsterhierarchy[0];
high_noise=badpixelmonsterhierarchy[1];
FE_ID = (*iii+"_0");

counter++;
tl->Fill();

}else{
module_reader_HV_1 = new HistoReader(iii->c_str(), PP, 0,1);
module_reader_noHV_1 = new HistoReader(iii->c_str(), PP, 0,0);

badpixelmonsterhierarchy = BadPixelMonsterHierarchy(module_reader_HV_1, module_reader_noHV_1);

/* bad_digi_ana.push_back(badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4]);
disconnectedbumps.push_back(badpixelmonsterhierarchy[2]);
merged.push_back(badpixelmonsterhierarchy[0]);
high_noise.push_back(badpixelmonsterhierarchy[1]);
FE_ID.push_back(*iii);

counter++;
ntuple->Fill(bad_digi_ana[counter], disconnectedbumps[counter],merged[counter],high_noise[counter],counter);

*/
bad_digi_ana=badpixelmonsterhierarchy[9]+badpixelmonsterhierarchy[8]+badpixelmonsterhierarchy[7]+badpixelmonsterhierarchy[6]+badpixelmonsterhierarchy[5]+badpixelmonsterhierarchy[4];
disconnectedbumps=badpixelmonsterhierarchy[2];
merged=badpixelmonsterhierarchy[0];
high_noise=badpixelmonsterhierarchy[1];
FE_ID = (*iii+"_0");

counter++;
tl->Fill();


}

}

/* tl->SetBranchAddress(“FE_ID”, &FE_ID);
tl->SetBranchAddress(“bad_digi_ana”,&bad_digi_ana);
tl->SetBranchAddress(“high_noise”,&high_noise);
tl->SetBranchAddress(“merged”,&merged);
*/

std::cout<<"SIZE: "<<FE_ID.size()<<std::endl;
//Int_t i = 0, j = 0;
int ncolumns = 4, nrows = FE_ID.size();
Double_t** data = new Double_t*[nrows];
for (int i = 0; i < nrows; i++) {
data[i] = new Double_t[ncolumns];
// for (j = 0; j < ncolumns; j++) {
// data[i][j] = 10 * i + j;
// data[i][0] = (Double_t)bad_digi_ana[i];
// data[i][1] = (Double_t)disconnectedbumps[i];
// data[i][2] = (Double_t)high_noise[i];
// data[i][3] = (Double_t)merged[i];

    //}
}   

/*
Double_t** data = new Double_t*[ncolumns];
for (int i = 0; i < ncolumns; i++) {
data[0][i] = (Double_t*)&bad_digi_ana[0];
data[1][i] = (Double_t*)&disconnectedbumps[0];
data[2][i] = (Double_t*)&high_noise[0];
data[3][i] = (Double_t*)&merged[0];
//data[i] = new Double_t[ncolumns];
}

  //for (int j = 0; j < ncolumns; j++) {
  //   data[i][j] = 10 * i + j;
  //}

//}
/
// Create a main frame to contain the table
TGMainFrame
mainframe = new TGMainFrame(0, 400, 200);
mainframe->SetCleanup(kDeepCleanup);

TString varexp = “FE_ID:Bad_digi_ana:Disconnected:High_Noise:Merged”;
TString select = “”;
TString options = “”;

// Create an interface
// TGSimpleTableInterface *iface = new TGSimpleTableInterface(data, nrows, ncolumns);
// TTreeTableInterface *iface = new TTreeTableInterface(ntuple);
TTreeTableInterface *iface = new TTreeTableInterface(tl,varexp.Data(),select.Data(),options.Data());

// Create the table
TGTable *table = new TGTable(mainframe, 999, iface);

// Add the table to the main frame
mainframe->AddFrame(table, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));

//Update data
// data[5][1] = 3.01;
//update the table view
table->Update();

// Layout and map the main frame
mainframe->SetWindowName("Available Modules Summary ") ;
mainframe->MapSubwindows() ;
mainframe->Layout();
mainframe->Resize();
mainframe->MapWindow() ;

return mainframe;

}[/code]

Unfortunately I have an error in my compilation:

iblsla-Analysis.o: In function `AvailableModulesSummaryTable(ProcessPosition, std::vector<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >)': /users/amiucci/iblsla/trunk/analysis/src/Analysis.cc:3309: undefined reference to `TTreeTableInterface::TTreeTableInterface(TTree*, char const*, char const*, char const*, long long, long long)' collect2: ld returned 1 exit status make: *** [iblsla] Error 1

I have to say that on the top of this Analysis.cc file there is the expected "include" <TTreTableInterface.h>:

Do someone has some ideas? I have the same error trying to use a ntuple.

Many thanks in advance.
Antonello.

Try to add “-lTreePlayer” to your linking command line.

Thanks, it seems to be solved now.

Have you any idea how to add -lTreePlayer in a Makefile generated by automake? I Already added the #include TTreePlayer on my .c file

I think you should have something like a “Makefile.in” and there should be a place inside where the “standard” ROOT libraries are added, so simply add “-lTreePlayer” there, too.