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();
}