I want to draw a graph, but I can’t write a graph when it says “zombie”. I’ve never seen an error message “zombie” before, but when does it appear?

Can you provide a code example demonstrating a such situation?

The macro without the parts not related to graphing looks like this:

```
gStyle->SetMarkerStyle(20);
gStyle->SetMarkerSize(0.7);
for (unsigned int n = 0; n < fastAll.size(); n++)
{
fastjet::PseudoJet aFastJet = fastAll[n];
TGraph2D *g[n];
g[n]=new TGraph2D(Form("h%d",n));
vector<fastjet::PseudoJet> constituents = jetAll.constituents(aFastJet);
unsigned int nconst = constituents.size();
for(unsigned int iconst = 0; iconst<nconst; iconst++){
double consteta = constituents[iconst].pseudorapidity();
double constphi = constituents[iconst].phi();
double constpt = constituents[iconst].pt();
g[n]->SetMarkerColor(kBlue);
g[n]->SetFillStyle(1001);
g[n]->SetMarkerSize(0.7);
cout<<consteta<<":"<<constphi<<":"<<constpt<<endl;
g[n]->SetPoint(iconst,consteta,constphi,constpt);
}
if(n==0){
g[n]->Draw("p");
}
if(n>0){
g[n]->Draw("same");
}
```

Nothing obviously wrong in that code. It is not complete therefore it cannot be run.

Can you copy/paste here the exact error messages you get ?

Instead of “`g[n]`

” use simply “`g`

” everywhere and then use the drawing one-liner: `g->Draw((n ? "SAME PCOL" : "PCOL"));`

I get the following error message:

Error in TGraph2D::TGraph2D: Cannot open file: h0, TGraph2D is Zombie

100000:0:0

When I changed it that way, the error message disappeared, but only one graph was displayed. I want to write n graphs on the same graph.

`TGraph2D *g = new TGraph2D(); g->SetName(Form("h%d", n));`

In other words, it will be the following macro, right? I’m having trouble seeing only one graph.

```
for(n<20;n++){
TGraph2D *g = new TGraph2D(); g->SetName(Form("h%d", n));
vector<fastjet::PseudoJet> constituents = jetAll.constituents(aFastJet);
unsigned int nconst = constituents.size();
for(unsigned int iconst = 0; iconst<nconst; iconst++){
double consteta = constituents[iconst].pseudorapidity();
double constphi = constituents[iconst].phi();
double constpt = constituents[iconst].pt();
g->SetMarkerColor(kBlue);
g->SetFillStyle(1001);
g->SetMarkerSize(0.7);
cout<<consteta<<":"<<constphi<<":"<<constpt<<endl;
g->SetPoint(iconst,consteta,constphi,constpt);
}
g->Draw((n ? "P" : "AP"));
}
```

```
gStyle->SetMarkerStyle(20);
gStyle->SetMarkerSize(0.7);
for (unsigned int n = 0; n < fastAll.size(); n++) {
TGraph2D *g = new TGraph2D();
g->SetName(Form("h%d",n));
g->SetMarkerColor(kBlue);
g->SetFillStyle(1001);
g->SetMarkerSize(0.7);
fastjet::PseudoJet aFastJet = fastAll[n];
vector<fastjet::PseudoJet> constituents = jetAll.constituents(aFastJet);
unsigned int nconst = constituents.size();
for(unsigned int iconst = 0; iconst<nconst; iconst++) {
double consteta = constituents[iconst].pseudorapidity();
double constphi = constituents[iconst].phi();
double constpt = constituents[iconst].pt();
cout<<consteta<<":"<<constphi<<":"<<constpt<<endl;
g->SetPoint(iconst,consteta,constphi,constpt);
}
g->Draw((n ? "SAME PCOL" : "PCOL"));
}
```

Well, I finally noticed you were using a TGraph2D so, the drawing options could be something like:

`g->Draw((n ? "SAME PCOL" : "PCOL"));`

or:

`g->Draw((n ? "SAME P0" : "P0"));`

or:

`g->Draw((n ? "SAME P" : "P"));`

Note that the very first graph (for “n = 0”) will define the axes, so if the following graphs (for “n > 0”) require (very) different ranges, you will not see (some) their points. So, maybe you want:

```
gStyle->SetMarkerStyle(20);
gStyle->SetMarkerSize(0.7);
TGraph2D *g = new TGraph2D();
g->SetName("g_all");
g->SetMarkerColor(kBlue);
g->SetFillStyle(1001);
g->SetMarkerSize(0.7);
for (unsigned int n = 0; n < fastAll.size(); n++) {
fastjet::PseudoJet aFastJet = fastAll[n];
vector<fastjet::PseudoJet> constituents = jetAll.constituents(aFastJet);
unsigned int nconst = constituents.size();
for(unsigned int iconst = 0; iconst<nconst; iconst++) {
double consteta = constituents[iconst].pseudorapidity();
double constphi = constituents[iconst].phi();
double constpt = constituents[iconst].pt();
cout<<consteta<<":"<<constphi<<":"<<constpt<<endl;
g->SetPoint(g->GetN(), consteta, constphi, constpt);
}
}
g->Draw("PCOL");
```

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.