Problem to adjust the z scale in a TGraph2D object

Hello,

I try to build a TGraph2D where I want to dump some events by the following way:
X axis Event ID
Y Axis: Detector ID
Z AXis: Energy

I used the following macro:

//--- BEGIN OF THE MACRO -----------------------------
#include <iostream.h>

void readtreeobj() {


  gROOT->Reset() ;
  gStyle->SetPalette(1) ;
  
  if(!TClassTable::GetDict("CaloEvent")) {
    gSystem->Load("$DIRPANDA/rootobject/libCaloEvent.so") ;

  }
  
  const Int_t nbhist=49 ;

  TFile* tf=new TFile("panda.root") ;
  
   TTree* calotree=(TTree*)tf->Get("CaloData") ;

  TCanvas* c1 = new TCanvas("c1", "View of crystal energy event by event", 0, 0, 1000, 800) ;
  c1->SetFillColor(0) ;
 
   Int_t nevent= calotree->GetEntries() ;
  Int_t evtid,idc ;
  Int_t  nbc=0 ;
  Double_t emax=2.0 ; 
  
  Double_t ec ;

  const Int_t ngd=nevent*nbhist ;
  TGraph2D* giec= new TGraph2D() ; 

 
  cout << "Number of event = " << nevent << endl ;
 
  CaloEvent* caevt= new CaloEvent(nbhist) ;

  TClonesArray* crystals= caevt->GetCrystals() ;

  
  TBranch* branch=calotree->GetBranch("CaloEvent_branch") ;
  
  branch->SetAddress(&caevt) ;
  cout << "OK" << endl ;

  
  
  Int_t nb=0 ;
  Int_t ipoint=0 ;
  
  for(Int_t i=0; i<10; i++) {
    
    
    nb+= calotree->GetEvent(i) ;
    
    evtid=caevt->GetEvtID() ;
    // cout << "Event number: " << evtid  << endl ;
     nbc=caevt->GetNbCryst() ;
     //cout << "Number of crystals " << nbc << endl ;
    
    //if(i<2) caevt->Print() ;
  
    
     
   for(Int_t icrystal=0; icrystal<nbc;icrystal++) {
        
        CaloCryst* cc= (CaloCryst*)crystals->At(icrystal) ;
        idc=cc->GetID() ;
        ec=cc->GetEnergy() ;
        //cout << "ipoint value " << ipoint << endl ;
        //cout << "Evt ID " << evtid << " Crystal number " << idc << " Energy " << ec << "GeV" << endl ;
        giec->SetPoint(ipoint,(Double_t)evtid,(Double_t)idc,ec) ;
	
	//cout << " Crystal ID "<< idc << " Energy " << ec << " GeV" << endl ;
	ipoint++ ; 
     }

   // caevt->Print() ;
    caevt->Clear() ;

  }  
  cout << "Points in graph 2D " << (ipoint-1) << endl ;

  
  giec->SetFillColor(0) ;
  
  giec->GetXaxis()->SetTitle("Event ID") ;
  giec->GetYaxis()->SetTitle("Crystal ID") ;
  giec->GetZaxis()->SetTitle("Energy (GeV)") ;
  giec->Draw("LEGO2") ;
  
  Double_t xmin=giec->GetXmin() ;
  Double_t xmax=giec->GetXmax() ;
  Double_t ymin=giec->GetYmin() ;
  Double_t ymax=giec->GetYmax() ;
  Double_t zmin=giec->GetZmin() ;
  Double_t zmax=giec->GetZmax() ;
  cout << "Xmin " << xmin << " Xmax " << xmax << endl ;
  cout << "Ymin " << ymin << " Ymax " << ymax << endl ;
  cout << "Zmin " << zmin << " Zmax " << zmax << endl ;
  //giec->SetMaximum(emax) ;
 if(gROOT->IsBatch()) return ;

     


}

 
    
    
    

//--------END OF THE MACRO -----

I read a tree with branch made by objects I Have included in the ROOT library. At this point, everything is OK and the data are perfectly read. But when I draw the TGraph2D the maximum of the Z-axis stays at 0.6 despite of the fact that my energy goes until 1.24 (unit is GeV). And so is the Palette of color which stays at this maximum value.
So it is just a problem to put the right scale. I try several possibilities (with SetRangeUser, or by superimposing the TGraph2D in an empty TH3D histogram) but none of them give the result I want.
Do you have any suggestion ? I use ROOT version 4.00/08.

Thanks a lot for the answer.

Yours kindly,

                    Thomas 

[

Are you sure the points you put in TGraph2D using SetPoint really go up to 1.24 ? if they do then you should see them… there is no reason they are cut at 0.6 … may be put a printf just before the SetPioint to check that the values you put in TGraph2D are correct.