Re: How can I view tracks from different events and how can I visualize them in X3D or OpenGL?

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Wed, 23 May 2007 21:46:27 +0200


replace your statement

   tr->Draw("same");
by

   tr->DrawClone("same");
otherwise the next call to t->GetEntry will delete the previous object.

Rene Brun

MikeTaverne wrote:
> Hi,
>
> I am trying to display tracks from several events on the same 3D
> structure.
> However, I am facing 2 problems:
> 1)Everytime I change the entry of the TTree by doing "t->GetEntry(j);"
> to switch to the next event, all previously drawn tracks disappear.
> 2)I cannot view the tracks in the X3D or OpenGL viewer. I can only see
> the solid 3D structure in it.
>
> How can I superpose tracks from different events?
> And what must I do to view them in X3D or OpenGL?
>
>
> ------------------------------------------------------------------------
>
> {
>
> gROOT->LoadMacro("$VMCWORKDIR/gconfig/basiclibs.C");
> basiclibs();
>
> gSystem->Load("libGeoBase");
> gSystem->Load("libParBase");
> gSystem->Load("libBase");
> gSystem->Load("libField");
> gSystem->Load("libGen");
> gSystem->Load("libPassive");
> gSystem->Load("libSts");
> gSystem->Load("libRich");
> gSystem->Load("libTrd");
> gSystem->Load("libTof");
> gSystem->Load("libGeom.so");
>
> TFile* f = new TFile("auaumbias.root");
>
> TTree *t=f->Get("cbmsim") ;
>
>
> TClonesArray *fT=new TClonesArray("TGeoTrack");
>
> t->SetBranchAddress("GeoTracks",&fT) ;
>
> TGeoManager *geoMan = (TGeoManager*) f->Get("CBMGeom");
> TCanvas* c1 = new TCanvas("c1", "", 100, 100, 800, 800);
> c1->SetFillColor(10);
>
> geoMan->GetTopVolume()->Draw("same");
> TGeoTrack *tr;
> //TGeoTrack *tr1;
> int event_nb=t->GetEntriesFast();
> cout<<"event_nb="<<event_nb<<endl;
> for (Int_t j=0; j< event_nb; j++) {
> t->GetEntry(j);
> int track_nb=fT->GetEntriesFast();
> cout<<"track_nb="<<track_nb<<endl;
> for (Int_t i=0; i<track_nb; i++) {
> tr=(TGeoTrack *)fT->At(i);
> tr->Draw("same");
> cout << " Track id " << tr->GetPDG() <<"->"<< tr->GetName() <<endl;
> }
>
> }
>
> }
>
>
Received on Wed May 23 2007 - 21:46:32 CEST

This archive was generated by hypermail 2.2.0 : Thu May 24 2007 - 05:50:01 CEST