Hi,
I am creating a function for plotting graph from tree.
Something like this:
TGraph * DrawGraph(string xname, string yname, TTree* tree)
{
float time = 0.0;//
float NimplantOuterVoltage = 0.0;//
float NimplantInnerVoltage = 0.0;//
float NimplantQuasiFermiPotential = 0.0;//
float NimplantDisplacementCurrent = 0.0;//
float NimplanteCurrent = 0.0;//
float NimplanthCurrent = 0.0;//
float NimplantTotalCurrent = 0.0;//
float NimplantCharge = 0.0;//
tree->SetBranchAddress("time",&time);
tree->SetBranchAddress("NimplantOuterVoltage",&NimplantOuterVoltage);
tree->SetBranchAddress("NimplantInnerVoltage",&NimplantInnerVoltage);
tree->SetBranchAddress("NimplantQuasiFermiPotential",&NimplantQuasiFermiPotential);
tree->SetBranchAddress("NimplantDisplacementCurrent",&NimplantDisplacementCurrent);
tree->SetBranchAddress("NimplanteCurrent",&NimplanteCurrent);
tree->SetBranchAddress("NimplanthCurrent",&NimplanthCurrent);
tree->SetBranchAddress("NimplantTotalCurrent",&NimplantTotalCurrent);
tree->SetBranchAddress("NimplantCharge",&NimplantCharge);
// push data to tree
int entries = tree->GetEntries();
vector <float> xvector;
vector <float> yvector;
for (Int_t i = -1; i <entries ; i++)
{
tree->GetEntry(i);
xvector.push_back(NimplantInnerVoltage);
yvector.push_back(NimplantTotalCurrent);
}
Float_t *x= &xvector[0];
Float_t *y= &yvector[0];
// plot graph
//c1->cd();
TGraph *g = new TGraph(entries, x, y);
return g;
}
void TcadChoseBranch (string xname, string yname, char *dirname="output/", const char *ext="_des.csv") {
> read file and call function
TGraph * g = DrawGraph(xname,yname, tree);
}
problem with passing the name of brunch like a parameter to vector, because xname and yname is string
{
tree->GetEntry(i);
xvector.push_back(xname);
yvector.push_back(yname);
}
how push data from the needed branch?