File: TraceTrack.cpp

package info (click to toggle)
vecgeom 1.2.8%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 24,016 kB
  • sloc: cpp: 88,803; ansic: 6,888; python: 1,035; sh: 582; sql: 538; makefile: 23
file content (599 lines) | stat: -rw-r--r-- 21,468 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
/*
 * XRayBenchmarkFromROOTFile.cpp
 *
 * this benchmark performs an X-Ray scan of a (logical volume
 * in a) detector
 *
 * the benchmark stresses the distance functions of the volumes as well as
 * the basic higher level navigation functionality
 */

#include "VecGeomTest/RootGeoManager.h"

#include "VecGeom/volumes/LogicalVolume.h"

#include "VecGeom/base/Global.h"
#include "VecGeom/base/Vector3D.h"
#include "VecGeom/base/Stopwatch.h"
#include "VecGeom/navigation/GlobalLocator.h"
#include "VecGeom/navigation/VNavigator.h"
#include "VecGeom/navigation/VSafetyEstimator.h"
#include "VecGeom/base/Transformation3D.h"
#include "VecGeom/base/SOA3D.h"
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <cmath>
#include <map>
#include <sstream>

#include "TGeoManager.h"
#include "TGeoBBox.h"
#include "TGeoNavigator.h"
#include "TGeoManager.h"
#include "TGeoVolume.h"
#include "TGeoVoxelFinder.h"

#ifdef VECGEOM_GEANT4
#include "G4Navigator.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Box.hh"
#include "G4ThreeVector.hh"
#include "G4TouchableHistoryHandle.hh"
#include "G4GDMLParser.hh"
#include "G4LogicalVolumeStore.hh"
#include "G4PVPlacement.hh"
#include "G4GeometryManager.hh"
#include "VecGeomTest/G4GeoManager.h"
#endif

#undef NDEBUG

#define VERBOSE false // true or false

using namespace vecgeom;

// a global variable to switch voxels on or off
bool voxelize = true;

// produce a bmp image out of pixel information given in volume_results
int make_bmp(int const *image_result, char const *, int data_size_x, int data_size_y);

__attribute__((noinline)) void DeleteROOTVoxels()
{
  std::cout << " IN DELETE VOXEL METHOD \n";
  int counter       = 0;
  TObjArray *volist = gGeoManager->GetListOfVolumes();

  std::cout << " entries " << volist->GetEntries() << "\n";

  for (int i = 0; i < volist->GetEntries(); ++i) {
    TGeoVolume *vol = (TGeoVolume *)volist->At(i);
    if (vol != NULL && vol->GetVoxels() != 0) {
      counter++;
      delete vol->GetVoxels();
      vol->SetVoxelFinder(0);
    }
  }
  std::cout << " deleted " << counter << " Voxels \n";
}

void XRayWithROOT(int axis, Vector3D<Precision> origin, Vector3D<Precision> bbox, Vector3D<Precision> dir,
                  Precision axis1_start, Precision axis1_end, Precision axis2_start, Precision axis2_end,
                  int data_size_x, int data_size_y, Precision pixel_axis, int *image)
{

  int counter = 0;

  // set start point of geantino
  Vector3D<Precision> p(0., 0., 0);

  TGeoNavigator *nav = gGeoManager->GetCurrentNavigator();
  nav->SetCurrentPoint(p.x(), p.y(), p.z());
  nav->SetCurrentDirection(dir.x(), dir.y(), dir.z());

  Precision distancetravelled = 0.;
  int crossedvolumecount      = 0;

  if (VERBOSE) {
    std::cout << " StartPoint(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
    std::cout << " Direction <" << dir[0] << ", " << dir[1] << ", " << dir[2] << ">" << std::endl;
  }

  // propagate until we leave detector
  TGeoNode const *node = nav->FindNode();

  std::cout << "INITIAL MAT :" << node->GetVolume()->GetMaterial()->GetName() << "\n";

  //  if( node ) std::cout <<    node->GetVolume()->GetName() << "\t";
  while (node != NULL) {
    node = nav->FindNextBoundaryAndStep(vecgeom::kInfLength);
    distancetravelled += nav->GetStep();
    counter++;

    if (VERBOSE) {
      if (node != NULL)
        std::cout << " *R " << counter << " * "
                  << " point(" << p[0] << ", " << p[1] << ", " << p[2] << ") goes to "
                  << " VolumeName: " << node->GetVolume()->GetName()
                  << " (MAT: " << node->GetVolume()->GetMaterial()->GetName() << ") :";
      else
        std::cout << "  NULL: ";

      std::cout << " step[" << nav->GetStep() << "]" << std::endl;
      double const *pROOT = nav->GetCurrentPoint();
      p                   = Vector3D<Precision>(pROOT[0], pROOT[1], pROOT[2]);
    }
    // Increase passed_volume
    // TODO: correct counting of travel in "world" bounding box
    crossedvolumecount++;
  } // end while
  // std::cout << crossedvolumecount << "\n";

  if (VERBOSE) {
    std::cout << " PassedVolume:"
              << "<" << crossedvolumecount << " ";
    std::cout << " total distance travelled: " << distancetravelled << std::endl;
  }
} // end XRayWithROOT

void XRayWithVecGeom(int axis, Vector3D<Precision> origin, Vector3D<Precision> bbox, Vector3D<Precision> dir,
                     Precision axis1_start, Precision axis1_end, Precision axis2_start, Precision axis2_end,
                     int data_size_x, int data_size_y, Precision pixel_axis, int *image)
{

  Stopwatch internaltimer;

  NavigationState *newnavstate = NavigationState::MakeInstance(GeoManager::Instance().getMaxDepth());
  NavigationState *curnavstate = NavigationState::MakeInstance(GeoManager::Instance().getMaxDepth());
  int counter                  = 0;
  //   std::cout << pixel_count_1 << " " << pixel_count_2 << "\n";

  internaltimer.Start();

  // set start point of XRay
  Vector3D<Precision> p(0, 0, 0);
  curnavstate->Clear();
  GlobalLocator::LocateGlobalPoint(GeoManager::Instance().GetWorld(), p, *curnavstate, true);

#ifdef VECGEOM_DISTANCE_DEBUG
  gGeoManager->GetCurrentNavigator()->FindNode(p.x(), p.y(), p.z());
#endif

  Precision distancetravelled = 0.;
  int crossedvolumecount      = 0;

  if (VERBOSE) {
    std::cout << " StartPoint(" << p[0] << ", " << p[1] << ", " << p[2] << ")";
    std::cout << " Direction <" << dir[0] << ", " << dir[1] << ", " << dir[2] << ">" << std::endl;
  }

  while (!curnavstate->IsOutside()) {
    Precision step = 0;
    newnavstate->Clear();

    auto nav         = curnavstate->Top()->GetLogicalVolume()->GetNavigator();
    Precision safety = nav->GetSafetyEstimator()->ComputeSafety(p, *curnavstate);
    nav->FindNextBoundaryAndStep(p, dir, *curnavstate, *newnavstate, 1e20, step);

    distancetravelled += step;

    if (VERBOSE) {
      if (newnavstate->Top() != NULL)
        std::cout << " *VG " << counter++ << " * point" << p << " goes to "
                  << " VolumeName: " << newnavstate->Top()->GetLabel();
      else
        std::cout << "  NULL: ";

      std::cout << " step[" << step << "]";
      std::cout << " safety[" << safety << "]";
      std::cout << " boundary[" << newnavstate->IsOnBoundary() << "]\n";
    }
    // here we have to propagate particle ourselves and adjust navigation state
    p = p + dir * (step + 1E-6);

    newnavstate->CopyTo(curnavstate);

    // Increase passed_volume
    // TODO: correct counting of travel in "world" bounding box
    if (step > 0) crossedvolumecount++;
  } // end while
  if (VERBOSE) {
    std::cout << " PassedVolume:"
              << "<" << crossedvolumecount << " ";
    std::cout << " Distance: " << distancetravelled << std::endl;
  }

  internaltimer.Stop();

  std::cout << "VecGeom time " << internaltimer.Elapsed() << "\n";

  NavigationState::ReleaseInstance(curnavstate);
  NavigationState::ReleaseInstance(newnavstate);

} // end XRayWithVecGeom

// stressing the vector interface of navigator
// TODO: This needs adjustment to new VNavigator interface
// void XRayWithVecGeom_VecNav(int axis, Vector3D<Precision> origin, Vector3D<Precision> bbox, Vector3D<Precision> dir,
//                            Precision axis1_start, Precision axis1_end, Precision axis2_start, Precision axis2_end,
//                            int data_size_x, int data_size_y, Precision pixel_axis, int *image)
//{
//  int counter = 0;
//
//  // we need N navstates ( where N should be a multiple of the SIMD width )
//  unsigned int N                 = 8;
//  NavigationState **newnavstates = new NavigationState *[N];
//  NavigationState **curnavstates = new NavigationState *[N];
//  for (unsigned int j = 0; j < N; ++j) {
//    newnavstates[j] = NavigationState::MakeInstance(GeoManager::Instance().getMaxDepth());
//    curnavstates[j] = NavigationState::MakeInstance(GeoManager::Instance().getMaxDepth());
//  }
//
//  SOA3D<Precision> points(N);
//  SOA3D<Precision> dirs(N);
//  SOA3D<Precision> workspaceforlocalpoints(N);
//  SOA3D<Precision> workspaceforlocaldirs(N);
//
//  // initialize dirs from dir
//  for (unsigned int j = 0; j < N; ++j)
//    dirs.set(j, dir.x(), dir.y(), dir.z());
//
//  Precision *steps          = new Precision[N];
//  Precision *psteps         = new Precision[N];
//  Precision *safeties       = new Precision[N];
//  int *nextnodeworkspace = new int[N]; // some workspace for the navigator; not important here
//  // initialize physical steps to infinity
//  for (unsigned int j = 0; j < N; ++j)
//    psteps[j]         = vecgeom::kInfLength;
//
//  Stopwatch internaltimer;
//  internaltimer.Start();
//  // initialize points and locate them is serialized
//  for (unsigned int j = 0; j < N; ++j) {
//    points.set(j, 0, 0, 0);
//    curnavstates[j]->Clear();
//    GlobalLocator::LocateGlobalPoint(GeoManager::Instance().GetWorld(), points[j], *curnavstates[j], true);
//  }
//
//  Precision distancetravelled = 0.;
//  int crossedvolumecount   = 0;
//  if (VERBOSE) {
//    std::cout << " StartPoint(" << points[0].x() << ", " << points[1].y() << ", " << points[2].z() << ")";
//    std::cout << " Direction <" << dirs[0].x() << ", " << dirs[1].y() << ", " << dirs[2].z() << ">" << std::endl;
//  }
//
//  // we do the while loop only over the first "particle index"
//  // the rest of the particles should follow exactly the same path
//  while (!curnavstates[0]->IsOutside()) {
//	auto nav = curnavstates[0]->Top()->GetLogicalVolume()->GetNavigator();
//    nav->FindNextBoundaryAndStep(points, dirs, workspaceforlocalpoints, workspaceforlocaldirs, curnavstates,
//                                newnavstates, psteps, safeties, steps, nextnodeworkspace);
//
//    // std::cout << "step " << step << "\n";
//    distancetravelled += steps[0];
//
//    // TODO: DO HERE AN ASSERTION THAT ALL STEPS AGREE
//
//    if (VERBOSE) {
//      if (newnavstates[0]->Top() != NULL)
//        std::cout << " *VGV " << counter++ << " * point" << points[0] << " goes to "
//                  << " VolumeName: " << newnavstates[0]->Top()->GetLabel();
//      else
//        std::cout << "  NULL: ";
//
//      std::cout << " step[" << steps[0] << "]";
//      std::cout << " boundary[" << newnavstates[0]->IsOnBoundary() << "]\n";
//    }
//
//    // here we have to propagate particle ourselves and adjust navigation state
//    // propagate points
//    for (unsigned int j = 0; j < N; ++j) {
//      points.set(j, points[j] + dirs[j] * (steps[0] + 1E-6));
//      newnavstates[j]->CopyTo(curnavstates[j]);
//    }
//
//    // Increase passed_volume
//    // TODO: correct counting of travel in "world" bounding box
//    if (steps[0] > 0) crossedvolumecount++;
//  } // end while
//
//  internaltimer.Stop();
//  std::cout << "VecGeom vec time (per track) " << internaltimer.Elapsed() / N << "\n";
//
//  for (unsigned int j = 0; j < N; ++j) {
//    NavigationState::ReleaseInstance(curnavstates[j]);
//    NavigationState::ReleaseInstance(newnavstates[j]);
//  }
//} // end XRayWithVecGeomVectorInterface

#ifdef VECGEOM_GEANT4
G4VPhysicalVolume *SetupGeant4Geometry(std::string volumename, Vector3D<Precision> worldbbox)
{

  // ATTENTION: THERE IS A (OR MIGHT BE) UNIT MISSMATCH HERE BETWEEN ROOT AND GEANT
  // ROOT = cm and GEANT4 = mm; basically a factor of 10 in all dimensions

  const double UNITCONV = 10.;

  //   // take G4 geometry from gdml file
  G4GDMLParser parser;
  parser.Read("cms2015.gdml");

  G4LogicalVolumeStore *store = G4LogicalVolumeStore::GetInstance();
  //
  int found                    = 0;
  G4LogicalVolume *foundvolume = NULL;
  for (auto v : *store) {
    std::size_t founds = volumename.compare(v->GetName());
    if (founds == 0) {
      found++;
      foundvolume = v;
    }
  }
  std::cerr << " found logical volume " << volumename << " " << found << " times "
            << "\n";

  // embed logical volume in a Box
  // create box first
  G4Box *worldb =
      new G4Box("BoundingBox", UNITCONV * worldbbox.x(), UNITCONV * worldbbox.y(), UNITCONV * worldbbox.z());
  G4LogicalVolume *worldlv = new G4LogicalVolume(worldb, 0, "world", 0, 0, 0);
  G4PVPlacement *worldpv   = new G4PVPlacement(0, G4ThreeVector(0, 0, 0), "BoundingBox", worldlv, 0, false, 0, 0);

  // embed found logical volume "foundvolume" into world bounding box
  new G4PVPlacement(NULL,                   /* rotation */
                    G4ThreeVector(0, 0, 0), /* translation */
                    foundvolume,            /* current logical */
                    "xrayedpl", worldlv,    /* this is where it is placed */
                    0, 0);

  G4GeometryManager::GetInstance()->CloseGeometry(voxelize);

  return worldpv;
}
#endif

// performs the XRay scan using Geant4
#ifdef VECGEOM_GEANT4
int XRayWithGeant4(G4VPhysicalVolume *world /* the detector to scan */, int axis, Vector3D<Precision> origin,
                   Vector3D<Precision> bboxscreen, Vector3D<Precision> dir, double axis1_start, double axis1_end,
                   double axis2_start, double axis2_end, int data_size_x, int data_size_y, double pixel_axis,
                   int *image)
{

  // ATTENTION: THERE IS A (OR MIGHT BE) UNIT MISSMATCH HERE BETWEEN ROOT AND GEANT
  // ROOT = cm and GEANT4 = mm; basically a factor of 10 in all dimensions

  // const double UNITCONV=10.;
  G4Navigator *nav = new G4Navigator();

  // now start XRay procedure
  nav->SetWorldVolume(world);

  G4ThreeVector d(dir.x(), dir.y(), dir.z());

  G4ThreeVector p(0, 0, 0);

  // false == locate from top
  G4VPhysicalVolume const *vol = nav->LocateGlobalPointAndSetup(p, &d, false);

  double distancetravelled = 0.;
  int crossedvolumecount   = 0;
  int counter              = 0;
  while (vol != NULL) {
    crossedvolumecount++;
    double safety;
    // do one step ( this will internally adjust the current point and so on )
    // also calculates safety

    double step = nav->ComputeStep(p, d, vecgeom::kInfLength, safety);

    //                       std::cerr << " STEP " << step << " ENTERING " << nav->EnteredDaughterVolume() << "\n";

    // calculate next point ( do transportation ) and volume ( should go across boundary )
    G4ThreeVector next = p + (step)*d;
    distancetravelled += step;
    nav->SetGeometricallyLimitedStep();
    vol = nav->LocateGlobalPointAndSetup(next, &d, true);

    if (VERBOSE) {
      if (vol != NULL)
        std::cout << " *G4 " << counter++ << " * point" << p / 10. << " goes to "
                  << " VolumeName: " << vol->GetName();
      else
        std::cout << "  NULL: ";

      std::cout << " step[" << step / 10. << "]" << std::endl;
    }
    p = next;
  } // end while

  if (VERBOSE) {
    std::cout << " PassedVolume:"
              << "<" << crossedvolumecount << " ";
    std::cout << " Distance: " << distancetravelled / 10. << std::endl;
  }
  return 0;
}
#endif

//////////////////////////////////
// main function
int main(int argc, char *argv[])
{
  int axis = 0;

  double axis1_start = 0.;
  double axis1_end   = 0.;

  double axis2_start = 0.;
  double axis2_end   = 0.;

  double pixel_axis = 1.;

  if (argc < 5) {
    std::cerr << std::endl;
    std::cerr << "Need to give rootfile, volumename, direction phi and direction theta (in degrees)" << std::endl;
    return 1;
  }

  TGeoManager::Import(argv[1]);
  std::string testvolume(argv[2]);

  // double directionphi   = atof(argv[3])*vecgeom::kDegToRad;
  // double directiontheta = atof(argv[4])*vecgeom::kDegToRad;

  for (auto i = 5; i < argc; i++) {
    if (!strcmp(argv[i], "--novoxel")) voxelize = false;
  }

  int found               = 0;
  TGeoVolume *foundvolume = NULL;
  // now try to find shape with logical volume name given on the command line
  TObjArray *vlist = gGeoManager->GetListOfVolumes();
  for (auto i = 0; i < vlist->GetEntries(); ++i) {
    TGeoVolume *vol = reinterpret_cast<TGeoVolume *>(vlist->At(i));
    std::string fullname(vol->GetName());

    std::size_t founds = fullname.compare(testvolume);
    if (founds == 0) {
      found++;
      foundvolume = vol;

      std::cerr << "(" << i << ")found matching volume " << foundvolume->GetName() << " of type "
                << foundvolume->GetShape()->ClassName() << "\n";
    }
  }

  std::cerr << "volume found " << found << " times \n\n";

  // if volume not found take world
  if (!foundvolume) {
    std::cerr << "specified volume not found; xraying complete detector\n";
    foundvolume = gGeoManager->GetTopVolume();
  }

  if (foundvolume) {
    foundvolume->GetShape()->InspectShape();
    std::cerr << "volume capacity " << foundvolume->GetShape()->Capacity() << "\n";

    // get bounding box to generate x-ray start positions
    double dx        = ((TGeoBBox *)foundvolume->GetShape())->GetDX() * 1.5;
    double dy        = ((TGeoBBox *)foundvolume->GetShape())->GetDY() * 1.5;
    double dz        = ((TGeoBBox *)foundvolume->GetShape())->GetDZ() * 1.5;
    double origin[3] = {
        0.,
    };
    origin[0] = ((TGeoBBox *)foundvolume->GetShape())->GetOrigin()[0];
    origin[1] = ((TGeoBBox *)foundvolume->GetShape())->GetOrigin()[1];
    origin[2] = ((TGeoBBox *)foundvolume->GetShape())->GetOrigin()[2];

    TGeoMaterial *matVacuum = new TGeoMaterial("Vacuum", 0, 0, 0);
    TGeoMedium *vac         = new TGeoMedium("Vacuum", 1, matVacuum);

    TGeoVolume *boundingbox = gGeoManager->MakeBox("BoundingBox", vac, std::abs(origin[0]) + dx,
                                                   std::abs(origin[1]) + dy, std::abs(origin[2]) + dz);

    // TGeoManager * geom = boundingbox->GetGeoManager();
    std::cout << gGeoManager->CountNodes() << "\n";

    if (!voxelize) DeleteROOTVoxels();

    //    TGeoManager * mg1 = gGeoManager;
    gGeoManager = 0;

    TGeoManager *mgr2 = new TGeoManager();

    //    delete gGeoManager;
    //    gGeoManager = new TGeoManager();
    boundingbox->AddNode(foundvolume, 1);
    mgr2->SetTopVolume(boundingbox);
    mgr2->CloseGeometry();
    gGeoManager = mgr2;
    gGeoManager->Export("DebugGeom.root");

    mgr2->GetTopNode()->GetMatrix()->Print();

    std::cout << gGeoManager->CountNodes() << "\n";
    // delete world->GetVoxels();
    // world->SetVoxelFinder(0);

    std::cout << std::endl;
    std::cout << "BoundingBoxDX: " << dx << std::endl;
    std::cout << "BoundingBoxDY: " << dy << std::endl;
    std::cout << "BoundingBoxDZ: " << dz << std::endl;

    std::cout << std::endl;
    std::cout << "BoundingBoxOriginX: " << origin[0] << std::endl;
    std::cout << "BoundingBoxOriginY: " << origin[1] << std::endl;
    std::cout << "BoundingBoxOriginZ: " << origin[2] << std::endl << std::endl;

    Vector3D<Precision> p;
    // Vector3D<Precision> dir( std::cos(directionphi)*std::sin(directiontheta),
    // std::sin(directionphi)*std::sin(directiontheta),  std::cos(directiontheta) );

    //
    Vector3D<Precision> dir(-0.00366952650659481318523580384294, 0.00101412421199570282163981982393,
                            0.999991248519344400058628252737);

    // Vector3D<Precision> dir( 1 , 0. , 0. );

    dir.FixZeroes();

    // init data for image
    int data_size_x    = 1; //(axis1_end-axis1_start)/pixel_axis;
    int data_size_y    = 1; //(axis2_end-axis2_start)/pixel_axis;
    int *volume_result = (int *)new int[data_size_y * data_size_x * 3];

    Stopwatch timer;
    timer.Start();
    XRayWithROOT(axis, Vector3D<Precision>(origin[0], origin[1], origin[2]), Vector3D<Precision>(dx, dy, dz), dir,
                 axis1_start, axis1_end, axis2_start, axis2_end, data_size_x, data_size_y, pixel_axis, volume_result);
    timer.Stop();

    std::cout << std::endl;
    std::cout << " ROOT Elapsed time : " << timer.Elapsed() << std::endl;

#ifdef VECGEOM_GEANT4

    G4VPhysicalVolume *world = SetupGeant4Geometry(
        testvolume, Vector3D<Precision>(std::abs(origin[0]) + dx, std::abs(origin[1]) + dy, std::abs(origin[2]) + dz));
    G4GeoManager::Instance().LoadG4Geometry(world);

    timer.Start();

    XRayWithGeant4(world, axis, Vector3D<Precision>(origin[0], origin[1], origin[2]), Vector3D<Precision>(dx, dy, dz),
                   dir, axis1_start, axis1_end, axis2_start, axis2_end, data_size_x, data_size_y, pixel_axis,
                   volume_result);
    timer.Stop();
    std::cout << " Geant4 Elapsed time : " << timer.Elapsed() << std::endl;

#endif

    // convert current gGeoManager to a VecGeom geometry
    RootGeoManager::Instance().LoadRootGeometry();
    std::cout << "Detector loaded "
              << "\n";
    timer.Start();
    XRayWithVecGeom(axis, Vector3D<Precision>(origin[0], origin[1], origin[2]), Vector3D<Precision>(dx, dy, dz), dir,
                    axis1_start, axis1_end, axis2_start, axis2_end, data_size_x, data_size_y, pixel_axis,
                    volume_result);
    timer.Stop();

    std::cout << " VecGeom Elapsed time : " << timer.Elapsed() << std::endl;

    //    // use the vector interface
    //    timer.Start();
    //    XRayWithVecGeom_VecNav(axis, Vector3D<Precision>(origin[0], origin[1], origin[2]), Vector3D<Precision>(dx, dy,
    //    dz),
    //                           dir, axis1_start, axis1_end, axis2_start, axis2_end, data_size_x, data_size_y,
    //                           pixel_axis, volume_result);
    //    timer.Stop();
    //    std::cout << std::endl;
    //    std::cout << " VecGeom Vector Interface Elapsed time : " << timer.Elapsed() << std::endl;

    delete[] volume_result;
  }
  return 0;
}