Need an example that can covert data to tevetrack and tevepointset for jsroot


ROOT Version: 6.27/01
Platform: Ubuntu 20.04
Compiler: c++ (GCC) 11.2.0


Dear Experts!

I am a beginner with root. In our group, we are working for a simulation project. I’m asked to develop a simple event displayer. I planned to use jsroot, then I built an jsroot server and imported our detector geometry. They’re working properly! But as an event displayer, it needs to show some hits and tracks. I have many data that the simulation program worked out. As the post have said, I need a root program that can convert this data to TEvePointSet and TEveTrack. But I find it’s hard to find an example program that can generate data like this.

So could anyone give me an example program that can randomly generated some data then save as TEvePointSet or TEveTrack object into a .root file (like tracks_hits.root)?

Thanks a lot for any help

Hi and welcome on the forum.

Meanwhile one can use other classes in jsroot to display tracks and hits.
For tracks - TPolyLine3D and for hits - TPolyMarker3D
Most simple way is to create TList object, add all tracks and hits there and then append that list to geometry drawing.

Regards,
Sergey

1 Like

There is also possibility to add several TGeoTrack to geometry.
See ROOT: tutorials/http/httpgeom.C File Reference
Unfortunately, there is no such class for hits.

1 Like

Sorry, it took me some time to learn how to save TList. Your advice help me a lot! I put the simplest example below that can generate some random data and save as root file. By the way, what are the differences between TPolyLine3D & TGeoTrack & TEveTrack and TPolyMarker3D & TEvePointSet? They look same in JSROOT. What do you recommend for event displayer?

Thank you,
Aiyu

void random_hits_tracks()
{
    const Int_t n_hits = 150;
    TPolyMarker3D *hits = new TPolyMarker3D(n_hits, 1);

    Double_t x, y, z;
    auto r = new TRandom();

    hits->SetMarkerColor(kGreen);
    for (Int_t i=0;i<n_hits;i++) {
        r->Sphere(x, y, z, 30);
        hits->SetPoint(i,x+1,y+1,z+1);
    }

    const Int_t n_tracks_points = 150;
    const Int_t scale_tracks = 10;
    TPolyLine3D *tracks = new TPolyLine3D(n_tracks_points);
    for (Int_t i=0;i<n_tracks_points;i++) {
        tracks->SetPoint(i,scale_tracks*std::sin(.1*i),scale_tracks*std::cos(.1*i),0.1*i);
    }

    tracks->SetLineColor(kRed);
    // tracks->SetLineWidth(20); //doesn't work
    

    TFile* f = new TFile("random_hits_tracks.root", "recreate");
    TList* fList_hits = new TList();
    fList_hits->Add(hits,"testhit1");
    TList* fList_tracks = new TList();
    fList_tracks->Add(tracks,"testtrack1");
    
    f->cd();
    fList_hits->Write("testhit", 1);
    fList_tracks->Write("testtrack", 1);
    f->Close();
}

Hi,

What do you recommend for event displayer?

It is up to you. If you starts from scratch - then just use TPolyLine3D and TPolyMarker3D.

Regards,
Sergey

1 Like