{ // draws a single track as found in fdcData.txt // create a canvas TCanvas *universe = new TCanvas( "universe", "track", 100, 100, 700, 500 ); // define the geometry gSystem->Load("libGeom"); // load geometry routines new TGeoManager("world", "the simplest geometry"); // define global // geometry // manager TGeoMaterial *mat = new TGeoMaterial("Vacuum", 0, 0,0); // define // vacuum // material TGeoMedium *med = new TGeoMedium("Vacuum", 1, mat); // define medium // made of // vacuum // define a box, destined to be the top volume TGeoVolume *top = gGeoManager->MakeBox("Top", med, 100.0, 100.0, 500.0); // define sphere shape TGeoSphere *sphere = new TGeoSphere(0.0, 0.2, 0.0, 180.0, 0.0, 360.0); // define the volume bubble as a sphere made of vacuum TGeoVolume *sphereVac = new TGeoVolume("bubble", sphere, med); TGeoTranslation *trans[100]; // define an array of translations for hits Double_t x, y, z; // to receive data from file Int_t index; // ditto ifstream input("fdcData.txt"); // open the file Double_t xmin = 1.e10; // initialize the bounding parameters Double_t xmax = -1.e10; Double_t ymin = 1.e10; Double_t ymax = -1.e10; Double_t zmin = 1.e10; Double_t zmax = -1.e10; Int_t nhits = 0; // zero hit counter while (input >> index >> x >> y >> z) { // while data can be read // from the file cout << index << ' ' << x << ' ' << y << ' ' << z << endl; if (x < xmin) xmin = x; // test for new bounding parameters if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; if (z < zmin) zmin = z; if (z > zmax) zmax = z; // store the tranlation for this hit trans[nhits] = new TGeoTranslation(x, y, z); top->AddNode(sphereVac, nhits, trans[nhits]); // add the ball to // the world volume nhits++; // increment hit counter } input.close(); /* cout << xmin << ' ' << xmax << ' ' << ymin << ' ' << ymax << ' ' << zmin << ' ' << zmax << endl; */ Double_t rmin[3], rmax[3]; // store bounds into an array rmin[0] = xmin; rmax[0] = xmax; rmin[1] = ymin; rmax[1] = ymax; rmin[2] = zmin; rmax[2] = zmax; TVirtualGeoTrack* track[2]; Int_t track_index, track_id; for (track_id = 0; track_id < 2; track_id++) { track_index = gGeoManager->AddTrack(track_id,0,0); // create a track track[track_id] = gGeoManager->GetTrack(track_index); // get its pointer } //read in the track ifstream intraj("fdcTraj.txt"); // open the trajectory file Int_t npoints = 0; // zero point counter Int_t id; // track id (starting or final) while (intraj >> track_id >> index >> x >> y >> z) { // while data can be read // from the file /* cout << track_id << ' ' << index << ' ' << x << ' ' << y << ' ' << z << endl; */ // store the point on the track track[track_id]->AddPoint(x, y, z, (Double_t)(index)); // use index as a // surrogate for time npoints++; // increment point counter } intraj.close(); // define virtual track bounding box for visual effect only TGeoBBox *trackBox = new TGeoBBox("trackBox", 0.5*(xmax - xmin), 0.5*(ymax - ymin), 0.5*(zmax - zmin)); TGeoVolume *trackVol = new TGeoVolume("track_volume", trackBox, med); TGeoTranslation *trackTrans = new TGeoTranslation((xmax + xmin)*0.5, (ymax + ymin)*0.5, (zmax + zmin)*0.5); top->AddNode(trackVol, 0, trackTrans); gGeoManager->SetTopVolume(top); // make top the top volume gGeoManager->CloseGeometry(); // we are finished with creating the geometry top->SetLineColor(kMagenta); // set color of the universe gGeoManager->SetTopVisible(); // allow top volume to be seen top->Draw(); // draw it track[0]->SetLineColor(1); track[1]->SetLineColor(2); track[0]->Draw(); track[1]->Draw(); // draw some axes TAxis3D *axes = new TAxis3D(); axes->Draw(); // zoom in on the track TView *view = TView::CreateView(1, rmin, rmax); universe->Update(); }