// @(#)root/geom:$Id$
// Author: Andrei Gheata   02/06/05

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/


#include "Riostream.h"

#include "TGeoManager.h"
#include "TGeoVoxelFinder.h"
#include "TGeoMatrix.h"
#include "TGeoVolume.h"
#include "TGeoNode.h"
#include "TGeoShapeAssembly.h"
#include "TBuffer3D.h"
#include "TBuffer3DTypes.h"
#include "TMath.h"

//_____________________________________________________________________________
// TGeoShapeAssembly - The shape encapsulating an assembly (union) of volumes.
//
//_____________________________________________________________________________


ClassImp(TGeoShapeAssembly)

//_____________________________________________________________________________
TGeoShapeAssembly::TGeoShapeAssembly()
{
// Default constructor
   fVolume  = 0;
   fBBoxOK = kFALSE;
}


//_____________________________________________________________________________
TGeoShapeAssembly::TGeoShapeAssembly(TGeoVolumeAssembly *vol)
{
// Constructor specifying hyperboloid parameters.
   fVolume  = vol;
   fBBoxOK = kFALSE;
}


//_____________________________________________________________________________
TGeoShapeAssembly::~TGeoShapeAssembly()
{
// destructor
}

//_____________________________________________________________________________
void TGeoShapeAssembly::ComputeBBox()
{
// Compute bounding box of the assembly
   if (!fVolume) {
      Fatal("ComputeBBox", "Assembly shape %s without volume", GetName());
      return;
   }
   // Make sure bbox is computed only once or recomputed only if invalidated (by alignment)
   if (fBBoxOK) return;
   Int_t nd = fVolume->GetNdaughters();
   if (!nd) {fBBoxOK = kTRUE; return;}
   TGeoNode *node;
   TGeoBBox *box;
   Double_t xmin, xmax, ymin, ymax, zmin, zmax;
   xmin = ymin = zmin = TGeoShape::Big();
   xmax = ymax = zmax = -TGeoShape::Big();
   Double_t vert[24];
   Double_t pt[3];
   for (Int_t i=0; i<nd; i++) {
      node = fVolume->GetNode(i);
      // Make sure that all assembly daughters have computed their bboxes
      if (node->GetVolume()->IsAssembly()) node->GetVolume()->GetShape()->ComputeBBox();
      box = (TGeoBBox*)node->GetVolume()->GetShape();
      box->SetBoxPoints(vert);
      for (Int_t ipt=0; ipt<8; ipt++) {
         node->LocalToMaster(&vert[3*ipt], pt);
         if (pt[0]<xmin) xmin=pt[0];
         if (pt[0]>xmax) xmax=pt[0];
         if (pt[1]<ymin) ymin=pt[1];
         if (pt[1]>ymax) ymax=pt[1];
         if (pt[2]<zmin) zmin=pt[2];
         if (pt[2]>zmax) zmax=pt[2];
      }
   }
   fDX = 0.5*(xmax-xmin);
   fOrigin[0] = 0.5*(xmin+xmax);
   fDY = 0.5*(ymax-ymin);
   fOrigin[1] = 0.5*(ymin+ymax);
   fDZ = 0.5*(zmax-zmin);
   fOrigin[2] = 0.5*(zmin+zmax);
   if (fDX>0 && fDY>0 && fDZ>0) fBBoxOK = kTRUE;
}

//_____________________________________________________________________________
void TGeoShapeAssembly::RecomputeBoxLast()
{
// Recompute bounding box of the assembly after adding a node.
   Int_t nd = fVolume->GetNdaughters();
   if (!nd) {
      Warning("RecomputeBoxLast", "No daughters for volume %s yet", fVolume->GetName());
      return;
   }
   TGeoNode *node = fVolume->GetNode(nd-1);
   Double_t xmin, xmax, ymin, ymax, zmin, zmax;
   if (nd==1) {
      xmin = ymin = zmin = TGeoShape::Big();
      xmax = ymax = zmax = -TGeoShape::Big();
   } else {
      xmin = fOrigin[0]-fDX;
      xmax = fOrigin[0]+fDX;
      ymin = fOrigin[1]-fDY;
      ymax = fOrigin[1]+fDY;
      zmin = fOrigin[2]-fDZ;
      zmax = fOrigin[2]+fDZ;
   }
   Double_t vert[24];
   Double_t pt[3];
   TGeoBBox *box = (TGeoBBox*)node->GetVolume()->GetShape();
   if (TGeoShape::IsSameWithinTolerance(box->GetDX(), 0) ||
       node->GetVolume()->IsAssembly()) node->GetVolume()->GetShape()->ComputeBBox();
   box->SetBoxPoints(vert);
   for (Int_t ipt=0; ipt<8; ipt++) {
      node->LocalToMaster(&vert[3*ipt], pt);
      if (pt[0]<xmin) xmin=pt[0];
      if (pt[0]>xmax) xmax=pt[0];
      if (pt[1]<ymin) ymin=pt[1];
      if (pt[1]>ymax) ymax=pt[1];
      if (pt[2]<zmin) zmin=pt[2];
      if (pt[2]>zmax) zmax=pt[2];
   }
   fDX = 0.5*(xmax-xmin);
   fOrigin[0] = 0.5*(xmin+xmax);
   fDY = 0.5*(ymax-ymin);
   fOrigin[1] = 0.5*(ymin+ymax);
   fDZ = 0.5*(zmax-zmin);
   fOrigin[2] = 0.5*(zmin+zmax);
   fBBoxOK = kTRUE;
}

//_____________________________________________________________________________
void TGeoShapeAssembly::ComputeNormal(const Double_t *point, const Double_t *dir, Double_t *norm)
{
// Compute normal to closest surface from POINT. Should not be called.
   if (!fBBoxOK) ((TGeoShapeAssembly*)this)->ComputeBBox();
   Int_t inext = fVolume->GetNextNodeIndex();
   if (inext<0) {
      DistFromOutside(point,dir,3);
      inext = fVolume->GetNextNodeIndex();
      if (inext<0) {
         Error("ComputeNormal","Invalid inext=%i (Ncomponents=%i)",inext,fVolume->GetNdaughters());
         return;
      }
   }
   TGeoNode *node = fVolume->GetNode(inext);
   Double_t local[3],ldir[3],lnorm[3];
   node->MasterToLocal(point,local);
   node->MasterToLocalVect(dir,ldir);
   node->GetVolume()->GetShape()->ComputeNormal(local,ldir,lnorm);
   node->LocalToMasterVect(lnorm,norm);
}

//_____________________________________________________________________________
Bool_t TGeoShapeAssembly::Contains(const Double_t *point) const
{
// Test if point is inside the assembly
   if (!fBBoxOK) ((TGeoShapeAssembly*)this)->ComputeBBox();
   if (!TGeoBBox::Contains(point)) return kFALSE;
   TGeoVoxelFinder *voxels = fVolume->GetVoxels();
   TGeoNode *node;
   TGeoShape *shape;
   Int_t *check_list = 0;
   Int_t ncheck, id;
   Double_t local[3];
   if (voxels) {
      // get the list of nodes passing thorough the current voxel
      TGeoNavigator *nav = gGeoManager->GetCurrentNavigator();
      TGeoStateInfo &td = *nav->GetCache()->GetInfo();
      check_list = voxels->GetCheckList(point, ncheck, td);
      if (!check_list) {
         nav->GetCache()->ReleaseInfo();
         return kFALSE;
      }
      for (id=0; id<ncheck; id++) {
         node = fVolume->GetNode(check_list[id]);
         shape = node->GetVolume()->GetShape();
         node->MasterToLocal(point,local);
         if (shape->Contains(local)) {
            fVolume->SetCurrentNodeIndex(check_list[id]);
            fVolume->SetNextNodeIndex(check_list[id]);
            nav->GetCache()->ReleaseInfo();
            return kTRUE;
         }
      }
      nav->GetCache()->ReleaseInfo();
      return kFALSE;
   }
   Int_t nd = fVolume->GetNdaughters();
   for (id=0; id<nd; id++) {
      node = fVolume->GetNode(id);
      shape = node->GetVolume()->GetShape();
      node->MasterToLocal(point,local);
      if (shape->Contains(local)) {
         fVolume->SetCurrentNodeIndex(id);
         fVolume->SetNextNodeIndex(id);
         return kTRUE;
      }
   }
   return kFALSE;
}

//_____________________________________________________________________________
Int_t TGeoShapeAssembly::DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)
{
// compute closest distance from point px,py to each vertex. Should not be called.
   return 9999;
}

//_____________________________________________________________________________
Double_t TGeoShapeAssembly::DistFromInside(const Double_t * /*point*/, const Double_t * /*dir*/, Int_t /*iact*/, Double_t /*step*/, Double_t * /*safe*/) const
{
// Compute distance from inside point to surface of the hyperboloid.
   Info("DistFromInside", "Cannot compute distance from inside the assembly (but from a component)");
   return TGeoShape::Big();
}


//_____________________________________________________________________________
Double_t TGeoShapeAssembly::DistFromOutside(const Double_t *point, const Double_t *dir, Int_t iact, Double_t step, Double_t *safe) const
{
// compute distance from outside point to surface of the hyperboloid.
//   fVolume->SetNextNodeIndex(-1);
#ifdef TGEO_DEBUG
   static int indent=0;
   indent++;
   TString sindent = "";
   for (Int_t k=0; k<indent; k++) sindent += "  ";
   Int_t idebug = TGeoManager::GetVerboseLevel();
#endif
   if (!fBBoxOK) ((TGeoShapeAssembly*)this)->ComputeBBox();
   if (iact<3 && safe) {
      *safe = Safety(point, kFALSE);
#ifdef TGEO_DEBUG
      indent--;
#endif
      if (iact==0) return TGeoShape::Big();
      if ((iact==1) && (step<=*safe)) return TGeoShape::Big();
#ifdef TGEO_DEBUG
      indent++;
#endif
   }
   // find distance to assembly
   Double_t snext = 0.0;
   Double_t dist;
   Double_t stepmax = step;
   Double_t pt[3];
   Int_t i;
   Bool_t found = kFALSE;
   memcpy(pt,point,3*sizeof(Double_t));
#ifdef TGEO_DEBUG
   if (idebug>4) printf("%s[%d] assembly %s checking distance to %d daughters...\n", sindent.Data(), indent, fVolume->GetName(), fVolume->GetNdaughters());
#endif

   if (!TGeoBBox::Contains(point)) {
      snext = TGeoBBox::DistFromOutside(point, dir, 3, stepmax);
      // Approach bounding box to minimize errors
      snext = TMath::Min(0.01*snext, 1.E-6);
#ifdef TGEO_DEBUG
      if (idebug>4 && snext > stepmax) printf("%s[%d] %s: bbox not crossed\n",sindent.Data(), indent, fVolume->GetName());
      indent--;
#endif
      if (snext > stepmax) return TGeoShape::Big();
#ifdef TGEO_DEBUG
      indent++;
#endif
      for (i=0; i<3; i++) pt[i] += snext*dir[i];
//      if (Contains(pt)) {
#ifdef TGEO_DEBUG
//         if (idebug>4) printf("%s[%d] Propagation to BBox of %s entered the component %s at %f\n", sindent.Data(), indent, fVolume->GetName(), fVolume->GetNode(fVolume->GetCurrentNodeIndex())->GetName(), snext);
//         indent--;
#endif
//         fVolume->SetNextNodeIndex(fVolume->GetCurrentNodeIndex());
//         return snext;
//      }
//      snext += TGeoShape::Tolerance();
      stepmax -= snext;
   }
   // Point represented by pt is now inside the bounding box - find distance to components
   Int_t nd = fVolume->GetNdaughters();
   TGeoNode *node;
   Double_t lpoint[3],ldir[3];
   TGeoVoxelFinder *voxels = fVolume->GetVoxels();
   if (nd<5 || !voxels) {
      for (i=0; i<nd; i++) {
         node = fVolume->GetNode(i);
         if (voxels && voxels->IsSafeVoxel(pt, i, stepmax)) continue;
         node->MasterToLocal(pt, lpoint);
         node->MasterToLocalVect(dir, ldir);
#ifdef TGEO_DEBUG
         if (idebug>4) printf("%s[%d] distance to %s ...\n", sindent.Data(), indent, node->GetName());
#endif
         dist = node->GetVolume()->GetShape()->DistFromOutside(lpoint, ldir, 3, stepmax);
         if (dist<stepmax) {
#ifdef TGEO_DEBUG
            if (idebug>4) {
               printf("%s[%d] %s -> from local=(%19.16f, %19.16f, %19.16f, %19.16f, %19.16f, %19.16f)\n",
                      sindent.Data(), indent, fVolume->GetName(), lpoint[0],lpoint[1],lpoint[2],ldir[0],ldir[1],ldir[2]);
               printf("%s[%d] -> (l)to: %s shape %s snext=%g\n", sindent.Data(), indent, node->GetName(),
                      node->GetVolume()->GetShape()->ClassName(), dist);
            }
#endif

            stepmax = dist;
            fVolume->SetNextNodeIndex(i);
            found = kTRUE;
         }
      }
      if (found) {
         snext += stepmax;
#ifdef TGEO_DEBUG
         if (idebug>4) printf("%s[%d] %s: found %s at %f\n", sindent.Data(), indent, fVolume->GetName(), fVolume->GetNode(fVolume->GetNextNodeIndex())->GetName(), snext);
         indent--;
#endif
         return snext;
      }
#ifdef TGEO_DEBUG
      if (idebug>4) printf("%s[%d] %s: no daughter crossed\n", sindent.Data(), indent, fVolume->GetName());
      indent--;
#endif
      return TGeoShape::Big();
   }
   // current volume is voxelized, first get current voxel
   Int_t ncheck = 0;
   Int_t *vlist = 0;
   TGeoNavigator *nav = gGeoManager->GetCurrentNavigator();
   TGeoStateInfo &td = *nav->GetCache()->GetInfo();

   voxels->SortCrossedVoxels(pt, dir, td);
   while ((vlist=voxels->GetNextVoxel(pt, dir, ncheck, td))) {
      for (i=0; i<ncheck; i++) {
         node = fVolume->GetNode(vlist[i]);
         node->MasterToLocal(pt, lpoint);
         node->MasterToLocalVect(dir, ldir);
#ifdef TGEO_DEBUG
         if (idebug>4) printf("%s[%d] distance to %s ...\n", sindent.Data(), indent, node->GetName());
#endif
         dist = node->GetVolume()->GetShape()->DistFromOutside(lpoint, ldir, 3, stepmax);
         if (dist<stepmax) {
#ifdef TGEO_DEBUG
            if (idebug>4) {
               printf("%s[%d] %s -> from local=(%19.16f, %19.16f, %19.16f, %19.16f, %19.16f, %19.16f)\n",
                      sindent.Data(), indent, fVolume->GetName(), lpoint[0],lpoint[1],lpoint[2], ldir[0],ldir[1],ldir[2]);
               printf("%s[%d] -> to: %s shape %s snext=%g\n", sindent.Data(), indent, node->GetName(),
                      node->GetVolume()->GetShape()->ClassName(), dist);
            }
#endif
            stepmax = dist;
            fVolume->SetNextNodeIndex(vlist[i]);
            found = kTRUE;
         }
      }
   }
   nav->GetCache()->ReleaseInfo();
   if (found) {
      snext += stepmax;
#ifdef TGEO_DEBUG
      if (idebug>4) printf("%s[%d] %s: found %s at %f\n", sindent.Data(), indent, fVolume->GetName(), fVolume->GetNode(fVolume->GetNextNodeIndex())->GetName(), snext);
      indent--;
#endif
      return snext;
   }
#ifdef TGEO_DEBUG
   if (idebug>4) printf("%s[%d] %s: no daughter crossed\n", sindent.Data(), indent, fVolume->GetName());
   indent--;
#endif
   return TGeoShape::Big();
}

//_____________________________________________________________________________
TGeoVolume *TGeoShapeAssembly::Divide(TGeoVolume * /*voldiv*/, const char *divname, Int_t /*iaxis*/, Int_t /*ndiv*/,
                             Double_t /*start*/, Double_t /*step*/)
{
// Cannot divide assemblies.
   Error("Divide", "Assemblies cannot be divided. Division volume %s not created", divname);
   return 0;
}

//_____________________________________________________________________________
TGeoShape *TGeoShapeAssembly::GetMakeRuntimeShape(TGeoShape * /*mother*/, TGeoMatrix * /*mat*/) const
{
// in case shape has some negative parameters, these has to be computed
// in order to fit the mother
   Error("GetMakeRuntimeShape", "Assemblies cannot be parametrized.");
   return NULL;
}

//_____________________________________________________________________________
void TGeoShapeAssembly::InspectShape() const
{
// print shape parameters
   printf("*** Shape %s: TGeoShapeAssembly ***\n", GetName());
   printf("    Volume assembly %s with %i nodes\n", fVolume->GetName(), fVolume->GetNdaughters());
   printf(" Bounding box:\n");
   if (!fBBoxOK) ((TGeoShapeAssembly*)this)->ComputeBBox();
   TGeoBBox::InspectShape();
}

//_____________________________________________________________________________
void TGeoShapeAssembly::SetSegsAndPols(TBuffer3D & /*buff*/) const
{
// Fill TBuffer3D structure for segments and polygons.
   Error("SetSegsAndPols", "Drawing functions should not be called for assemblies, but rather for their content");
}

//_____________________________________________________________________________
Double_t TGeoShapeAssembly::Safety(const Double_t *point, Bool_t in) const
{
// computes the closest distance from given point to this shape, according
// to option. The matching point on the shape is stored in spoint.
   Double_t safety = TGeoShape::Big();
   Double_t pt[3], loc[3];
   if (!fBBoxOK) ((TGeoShapeAssembly*)this)->ComputeBBox();
   if (in) {
      Int_t index = fVolume->GetCurrentNodeIndex();
      TGeoVolume *vol = fVolume;
      TGeoNode *node;
      memcpy(loc, point, 3*sizeof(Double_t));
      while (index>=0) {
         memcpy(pt, loc, 3*sizeof(Double_t));
         node = vol->GetNode(index);
         node->GetMatrix()->MasterToLocal(pt,loc);
         vol = node->GetVolume();
         index = vol->GetCurrentNodeIndex();
         if (index<0) {
            safety = vol->GetShape()->Safety(loc, in);
            return safety;
         }
      }
      return TGeoShape::Big();
   }
   Double_t safe;
   TGeoVoxelFinder *voxels = fVolume->GetVoxels();
   Int_t nd = fVolume->GetNdaughters();
   Double_t *boxes = 0;
   if (voxels) boxes = voxels->GetBoxes();
   TGeoNode *node;
   for (Int_t id=0; id<nd; id++) {
      if (boxes && id>0) {
         Int_t ist = 6*id;
         Double_t dxyz = 0.;
         Double_t dxyz0 = TMath::Abs(point[0]-boxes[ist+3])-boxes[ist];
         if (dxyz0 > safety) continue;
         Double_t dxyz1 = TMath::Abs(point[1]-boxes[ist+4])-boxes[ist+1];
         if (dxyz1 > safety) continue;
         Double_t dxyz2 = TMath::Abs(point[2]-boxes[ist+5])-boxes[ist+2];
         if (dxyz2 > safety) continue;
         if (dxyz0>0) dxyz+=dxyz0*dxyz0;
         if (dxyz1>0) dxyz+=dxyz1*dxyz1;
         if (dxyz2>0) dxyz+=dxyz2*dxyz2;
         if (dxyz >= safety*safety) continue;
      }
      node = fVolume->GetNode(id);
      safe = node->Safety(point, kFALSE);
      if (safe<=0.0) return 0.0;
      if (safe<safety) safety = safe;
   }
   return safety;
}

//_____________________________________________________________________________
void TGeoShapeAssembly::SavePrimitive(std::ostream & /*out*/, Option_t * /*option*/ /*= ""*/)
{
// Save a primitive as a C++ statement(s) on output stream "out".
}

//_____________________________________________________________________________
void TGeoShapeAssembly::SetPoints(Double_t * /*points*/) const
{
// No mesh for assemblies.
   Error("SetPoints", "Drawing functions should not be called for assemblies, but rather for their content");
}

//_____________________________________________________________________________
void TGeoShapeAssembly::SetPoints(Float_t * /*points*/) const
{
// No mesh for assemblies.
   Error("SetPoints", "Drawing functions should not be called for assemblies, but rather for their content");
}

//_____________________________________________________________________________
void TGeoShapeAssembly::GetMeshNumbers(Int_t &nvert, Int_t &nsegs, Int_t &npols) const
{
// Returns numbers of vertices, segments and polygons composing the shape mesh.
   nvert = 0;
   nsegs = 0;
   npols = 0;
}

//_____________________________________________________________________________
void TGeoShapeAssembly::Contains_v(const Double_t *points, Bool_t *inside, Int_t vecsize) const
{
// Check the inside status for each of the points in the array.
// Input: Array of point coordinates + vector size
// Output: Array of Booleans for the inside of each point
   for (Int_t i=0; i<vecsize; i++) inside[i] = Contains(&points[3*i]);
}

//_____________________________________________________________________________
void TGeoShapeAssembly::ComputeNormal_v(const Double_t *points, const Double_t *dirs, Double_t *norms, Int_t vecsize)
{
// Compute the normal for an array o points so that norm.dot.dir is positive
// Input: Arrays of point coordinates and directions + vector size
// Output: Array of normal directions
   for (Int_t i=0; i<vecsize; i++) ComputeNormal(&points[3*i], &dirs[3*i], &norms[3*i]);
}

//_____________________________________________________________________________
void TGeoShapeAssembly::DistFromInside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step) const
{
// Compute distance from array of input points having directions specisied by dirs. Store output in dists
   for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromInside(&points[3*i], &dirs[3*i], 3, step[i]);
}

//_____________________________________________________________________________
void TGeoShapeAssembly::DistFromOutside_v(const Double_t *points, const Double_t *dirs, Double_t *dists, Int_t vecsize, Double_t* step) const
{
// Compute distance from array of input points having directions specisied by dirs. Store output in dists
   for (Int_t i=0; i<vecsize; i++) dists[i] = DistFromOutside(&points[3*i], &dirs[3*i], 3, step[i]);
}

//_____________________________________________________________________________
void TGeoShapeAssembly::Safety_v(const Double_t *points, const Bool_t *inside, Double_t *safe, Int_t vecsize) const
{
// Compute safe distance from each of the points in the input array.
// Input: Array of point coordinates, array of statuses for these points, size of the arrays
// Output: Safety values
   for (Int_t i=0; i<vecsize; i++) safe[i] = Safety(&points[3*i], inside[i]);
}
 TGeoShapeAssembly.cxx:1
 TGeoShapeAssembly.cxx:2
 TGeoShapeAssembly.cxx:3
 TGeoShapeAssembly.cxx:4
 TGeoShapeAssembly.cxx:5
 TGeoShapeAssembly.cxx:6
 TGeoShapeAssembly.cxx:7
 TGeoShapeAssembly.cxx:8
 TGeoShapeAssembly.cxx:9
 TGeoShapeAssembly.cxx:10
 TGeoShapeAssembly.cxx:11
 TGeoShapeAssembly.cxx:12
 TGeoShapeAssembly.cxx:13
 TGeoShapeAssembly.cxx:14
 TGeoShapeAssembly.cxx:15
 TGeoShapeAssembly.cxx:16
 TGeoShapeAssembly.cxx:17
 TGeoShapeAssembly.cxx:18
 TGeoShapeAssembly.cxx:19
 TGeoShapeAssembly.cxx:20
 TGeoShapeAssembly.cxx:21
 TGeoShapeAssembly.cxx:22
 TGeoShapeAssembly.cxx:23
 TGeoShapeAssembly.cxx:24
 TGeoShapeAssembly.cxx:25
 TGeoShapeAssembly.cxx:26
 TGeoShapeAssembly.cxx:27
 TGeoShapeAssembly.cxx:28
 TGeoShapeAssembly.cxx:29
 TGeoShapeAssembly.cxx:30
 TGeoShapeAssembly.cxx:31
 TGeoShapeAssembly.cxx:32
 TGeoShapeAssembly.cxx:33
 TGeoShapeAssembly.cxx:34
 TGeoShapeAssembly.cxx:35
 TGeoShapeAssembly.cxx:36
 TGeoShapeAssembly.cxx:37
 TGeoShapeAssembly.cxx:38
 TGeoShapeAssembly.cxx:39
 TGeoShapeAssembly.cxx:40
 TGeoShapeAssembly.cxx:41
 TGeoShapeAssembly.cxx:42
 TGeoShapeAssembly.cxx:43
 TGeoShapeAssembly.cxx:44
 TGeoShapeAssembly.cxx:45
 TGeoShapeAssembly.cxx:46
 TGeoShapeAssembly.cxx:47
 TGeoShapeAssembly.cxx:48
 TGeoShapeAssembly.cxx:49
 TGeoShapeAssembly.cxx:50
 TGeoShapeAssembly.cxx:51
 TGeoShapeAssembly.cxx:52
 TGeoShapeAssembly.cxx:53
 TGeoShapeAssembly.cxx:54
 TGeoShapeAssembly.cxx:55
 TGeoShapeAssembly.cxx:56
 TGeoShapeAssembly.cxx:57
 TGeoShapeAssembly.cxx:58
 TGeoShapeAssembly.cxx:59
 TGeoShapeAssembly.cxx:60
 TGeoShapeAssembly.cxx:61
 TGeoShapeAssembly.cxx:62
 TGeoShapeAssembly.cxx:63
 TGeoShapeAssembly.cxx:64
 TGeoShapeAssembly.cxx:65
 TGeoShapeAssembly.cxx:66
 TGeoShapeAssembly.cxx:67
 TGeoShapeAssembly.cxx:68
 TGeoShapeAssembly.cxx:69
 TGeoShapeAssembly.cxx:70
 TGeoShapeAssembly.cxx:71
 TGeoShapeAssembly.cxx:72
 TGeoShapeAssembly.cxx:73
 TGeoShapeAssembly.cxx:74
 TGeoShapeAssembly.cxx:75
 TGeoShapeAssembly.cxx:76
 TGeoShapeAssembly.cxx:77
 TGeoShapeAssembly.cxx:78
 TGeoShapeAssembly.cxx:79
 TGeoShapeAssembly.cxx:80
 TGeoShapeAssembly.cxx:81
 TGeoShapeAssembly.cxx:82
 TGeoShapeAssembly.cxx:83
 TGeoShapeAssembly.cxx:84
 TGeoShapeAssembly.cxx:85
 TGeoShapeAssembly.cxx:86
 TGeoShapeAssembly.cxx:87
 TGeoShapeAssembly.cxx:88
 TGeoShapeAssembly.cxx:89
 TGeoShapeAssembly.cxx:90
 TGeoShapeAssembly.cxx:91
 TGeoShapeAssembly.cxx:92
 TGeoShapeAssembly.cxx:93
 TGeoShapeAssembly.cxx:94
 TGeoShapeAssembly.cxx:95
 TGeoShapeAssembly.cxx:96
 TGeoShapeAssembly.cxx:97
 TGeoShapeAssembly.cxx:98
 TGeoShapeAssembly.cxx:99
 TGeoShapeAssembly.cxx:100
 TGeoShapeAssembly.cxx:101
 TGeoShapeAssembly.cxx:102
 TGeoShapeAssembly.cxx:103
 TGeoShapeAssembly.cxx:104
 TGeoShapeAssembly.cxx:105
 TGeoShapeAssembly.cxx:106
 TGeoShapeAssembly.cxx:107
 TGeoShapeAssembly.cxx:108
 TGeoShapeAssembly.cxx:109
 TGeoShapeAssembly.cxx:110
 TGeoShapeAssembly.cxx:111
 TGeoShapeAssembly.cxx:112
 TGeoShapeAssembly.cxx:113
 TGeoShapeAssembly.cxx:114
 TGeoShapeAssembly.cxx:115
 TGeoShapeAssembly.cxx:116
 TGeoShapeAssembly.cxx:117
 TGeoShapeAssembly.cxx:118
 TGeoShapeAssembly.cxx:119
 TGeoShapeAssembly.cxx:120
 TGeoShapeAssembly.cxx:121
 TGeoShapeAssembly.cxx:122
 TGeoShapeAssembly.cxx:123
 TGeoShapeAssembly.cxx:124
 TGeoShapeAssembly.cxx:125
 TGeoShapeAssembly.cxx:126
 TGeoShapeAssembly.cxx:127
 TGeoShapeAssembly.cxx:128
 TGeoShapeAssembly.cxx:129
 TGeoShapeAssembly.cxx:130
 TGeoShapeAssembly.cxx:131
 TGeoShapeAssembly.cxx:132
 TGeoShapeAssembly.cxx:133
 TGeoShapeAssembly.cxx:134
 TGeoShapeAssembly.cxx:135
 TGeoShapeAssembly.cxx:136
 TGeoShapeAssembly.cxx:137
 TGeoShapeAssembly.cxx:138
 TGeoShapeAssembly.cxx:139
 TGeoShapeAssembly.cxx:140
 TGeoShapeAssembly.cxx:141
 TGeoShapeAssembly.cxx:142
 TGeoShapeAssembly.cxx:143
 TGeoShapeAssembly.cxx:144
 TGeoShapeAssembly.cxx:145
 TGeoShapeAssembly.cxx:146
 TGeoShapeAssembly.cxx:147
 TGeoShapeAssembly.cxx:148
 TGeoShapeAssembly.cxx:149
 TGeoShapeAssembly.cxx:150
 TGeoShapeAssembly.cxx:151
 TGeoShapeAssembly.cxx:152
 TGeoShapeAssembly.cxx:153
 TGeoShapeAssembly.cxx:154
 TGeoShapeAssembly.cxx:155
 TGeoShapeAssembly.cxx:156
 TGeoShapeAssembly.cxx:157
 TGeoShapeAssembly.cxx:158
 TGeoShapeAssembly.cxx:159
 TGeoShapeAssembly.cxx:160
 TGeoShapeAssembly.cxx:161
 TGeoShapeAssembly.cxx:162
 TGeoShapeAssembly.cxx:163
 TGeoShapeAssembly.cxx:164
 TGeoShapeAssembly.cxx:165
 TGeoShapeAssembly.cxx:166
 TGeoShapeAssembly.cxx:167
 TGeoShapeAssembly.cxx:168
 TGeoShapeAssembly.cxx:169
 TGeoShapeAssembly.cxx:170
 TGeoShapeAssembly.cxx:171
 TGeoShapeAssembly.cxx:172
 TGeoShapeAssembly.cxx:173
 TGeoShapeAssembly.cxx:174
 TGeoShapeAssembly.cxx:175
 TGeoShapeAssembly.cxx:176
 TGeoShapeAssembly.cxx:177
 TGeoShapeAssembly.cxx:178
 TGeoShapeAssembly.cxx:179
 TGeoShapeAssembly.cxx:180
 TGeoShapeAssembly.cxx:181
 TGeoShapeAssembly.cxx:182
 TGeoShapeAssembly.cxx:183
 TGeoShapeAssembly.cxx:184
 TGeoShapeAssembly.cxx:185
 TGeoShapeAssembly.cxx:186
 TGeoShapeAssembly.cxx:187
 TGeoShapeAssembly.cxx:188
 TGeoShapeAssembly.cxx:189
 TGeoShapeAssembly.cxx:190
 TGeoShapeAssembly.cxx:191
 TGeoShapeAssembly.cxx:192
 TGeoShapeAssembly.cxx:193
 TGeoShapeAssembly.cxx:194
 TGeoShapeAssembly.cxx:195
 TGeoShapeAssembly.cxx:196
 TGeoShapeAssembly.cxx:197
 TGeoShapeAssembly.cxx:198
 TGeoShapeAssembly.cxx:199
 TGeoShapeAssembly.cxx:200
 TGeoShapeAssembly.cxx:201
 TGeoShapeAssembly.cxx:202
 TGeoShapeAssembly.cxx:203
 TGeoShapeAssembly.cxx:204
 TGeoShapeAssembly.cxx:205
 TGeoShapeAssembly.cxx:206
 TGeoShapeAssembly.cxx:207
 TGeoShapeAssembly.cxx:208
 TGeoShapeAssembly.cxx:209
 TGeoShapeAssembly.cxx:210
 TGeoShapeAssembly.cxx:211
 TGeoShapeAssembly.cxx:212
 TGeoShapeAssembly.cxx:213
 TGeoShapeAssembly.cxx:214
 TGeoShapeAssembly.cxx:215
 TGeoShapeAssembly.cxx:216
 TGeoShapeAssembly.cxx:217
 TGeoShapeAssembly.cxx:218
 TGeoShapeAssembly.cxx:219
 TGeoShapeAssembly.cxx:220
 TGeoShapeAssembly.cxx:221
 TGeoShapeAssembly.cxx:222
 TGeoShapeAssembly.cxx:223
 TGeoShapeAssembly.cxx:224
 TGeoShapeAssembly.cxx:225
 TGeoShapeAssembly.cxx:226
 TGeoShapeAssembly.cxx:227
 TGeoShapeAssembly.cxx:228
 TGeoShapeAssembly.cxx:229
 TGeoShapeAssembly.cxx:230
 TGeoShapeAssembly.cxx:231
 TGeoShapeAssembly.cxx:232
 TGeoShapeAssembly.cxx:233
 TGeoShapeAssembly.cxx:234
 TGeoShapeAssembly.cxx:235
 TGeoShapeAssembly.cxx:236
 TGeoShapeAssembly.cxx:237
 TGeoShapeAssembly.cxx:238
 TGeoShapeAssembly.cxx:239
 TGeoShapeAssembly.cxx:240
 TGeoShapeAssembly.cxx:241
 TGeoShapeAssembly.cxx:242
 TGeoShapeAssembly.cxx:243
 TGeoShapeAssembly.cxx:244
 TGeoShapeAssembly.cxx:245
 TGeoShapeAssembly.cxx:246
 TGeoShapeAssembly.cxx:247
 TGeoShapeAssembly.cxx:248
 TGeoShapeAssembly.cxx:249
 TGeoShapeAssembly.cxx:250
 TGeoShapeAssembly.cxx:251
 TGeoShapeAssembly.cxx:252
 TGeoShapeAssembly.cxx:253
 TGeoShapeAssembly.cxx:254
 TGeoShapeAssembly.cxx:255
 TGeoShapeAssembly.cxx:256
 TGeoShapeAssembly.cxx:257
 TGeoShapeAssembly.cxx:258
 TGeoShapeAssembly.cxx:259
 TGeoShapeAssembly.cxx:260
 TGeoShapeAssembly.cxx:261
 TGeoShapeAssembly.cxx:262
 TGeoShapeAssembly.cxx:263
 TGeoShapeAssembly.cxx:264
 TGeoShapeAssembly.cxx:265
 TGeoShapeAssembly.cxx:266
 TGeoShapeAssembly.cxx:267
 TGeoShapeAssembly.cxx:268
 TGeoShapeAssembly.cxx:269
 TGeoShapeAssembly.cxx:270
 TGeoShapeAssembly.cxx:271
 TGeoShapeAssembly.cxx:272
 TGeoShapeAssembly.cxx:273
 TGeoShapeAssembly.cxx:274
 TGeoShapeAssembly.cxx:275
 TGeoShapeAssembly.cxx:276
 TGeoShapeAssembly.cxx:277
 TGeoShapeAssembly.cxx:278
 TGeoShapeAssembly.cxx:279
 TGeoShapeAssembly.cxx:280
 TGeoShapeAssembly.cxx:281
 TGeoShapeAssembly.cxx:282
 TGeoShapeAssembly.cxx:283
 TGeoShapeAssembly.cxx:284
 TGeoShapeAssembly.cxx:285
 TGeoShapeAssembly.cxx:286
 TGeoShapeAssembly.cxx:287
 TGeoShapeAssembly.cxx:288
 TGeoShapeAssembly.cxx:289
 TGeoShapeAssembly.cxx:290
 TGeoShapeAssembly.cxx:291
 TGeoShapeAssembly.cxx:292
 TGeoShapeAssembly.cxx:293
 TGeoShapeAssembly.cxx:294
 TGeoShapeAssembly.cxx:295
 TGeoShapeAssembly.cxx:296
 TGeoShapeAssembly.cxx:297
 TGeoShapeAssembly.cxx:298
 TGeoShapeAssembly.cxx:299
 TGeoShapeAssembly.cxx:300
 TGeoShapeAssembly.cxx:301
 TGeoShapeAssembly.cxx:302
 TGeoShapeAssembly.cxx:303
 TGeoShapeAssembly.cxx:304
 TGeoShapeAssembly.cxx:305
 TGeoShapeAssembly.cxx:306
 TGeoShapeAssembly.cxx:307
 TGeoShapeAssembly.cxx:308
 TGeoShapeAssembly.cxx:309
 TGeoShapeAssembly.cxx:310
 TGeoShapeAssembly.cxx:311
 TGeoShapeAssembly.cxx:312
 TGeoShapeAssembly.cxx:313
 TGeoShapeAssembly.cxx:314
 TGeoShapeAssembly.cxx:315
 TGeoShapeAssembly.cxx:316
 TGeoShapeAssembly.cxx:317
 TGeoShapeAssembly.cxx:318
 TGeoShapeAssembly.cxx:319
 TGeoShapeAssembly.cxx:320
 TGeoShapeAssembly.cxx:321
 TGeoShapeAssembly.cxx:322
 TGeoShapeAssembly.cxx:323
 TGeoShapeAssembly.cxx:324
 TGeoShapeAssembly.cxx:325
 TGeoShapeAssembly.cxx:326
 TGeoShapeAssembly.cxx:327
 TGeoShapeAssembly.cxx:328
 TGeoShapeAssembly.cxx:329
 TGeoShapeAssembly.cxx:330
 TGeoShapeAssembly.cxx:331
 TGeoShapeAssembly.cxx:332
 TGeoShapeAssembly.cxx:333
 TGeoShapeAssembly.cxx:334
 TGeoShapeAssembly.cxx:335
 TGeoShapeAssembly.cxx:336
 TGeoShapeAssembly.cxx:337
 TGeoShapeAssembly.cxx:338
 TGeoShapeAssembly.cxx:339
 TGeoShapeAssembly.cxx:340
 TGeoShapeAssembly.cxx:341
 TGeoShapeAssembly.cxx:342
 TGeoShapeAssembly.cxx:343
 TGeoShapeAssembly.cxx:344
 TGeoShapeAssembly.cxx:345
 TGeoShapeAssembly.cxx:346
 TGeoShapeAssembly.cxx:347
 TGeoShapeAssembly.cxx:348
 TGeoShapeAssembly.cxx:349
 TGeoShapeAssembly.cxx:350
 TGeoShapeAssembly.cxx:351
 TGeoShapeAssembly.cxx:352
 TGeoShapeAssembly.cxx:353
 TGeoShapeAssembly.cxx:354
 TGeoShapeAssembly.cxx:355
 TGeoShapeAssembly.cxx:356
 TGeoShapeAssembly.cxx:357
 TGeoShapeAssembly.cxx:358
 TGeoShapeAssembly.cxx:359
 TGeoShapeAssembly.cxx:360
 TGeoShapeAssembly.cxx:361
 TGeoShapeAssembly.cxx:362
 TGeoShapeAssembly.cxx:363
 TGeoShapeAssembly.cxx:364
 TGeoShapeAssembly.cxx:365
 TGeoShapeAssembly.cxx:366
 TGeoShapeAssembly.cxx:367
 TGeoShapeAssembly.cxx:368
 TGeoShapeAssembly.cxx:369
 TGeoShapeAssembly.cxx:370
 TGeoShapeAssembly.cxx:371
 TGeoShapeAssembly.cxx:372
 TGeoShapeAssembly.cxx:373
 TGeoShapeAssembly.cxx:374
 TGeoShapeAssembly.cxx:375
 TGeoShapeAssembly.cxx:376
 TGeoShapeAssembly.cxx:377
 TGeoShapeAssembly.cxx:378
 TGeoShapeAssembly.cxx:379
 TGeoShapeAssembly.cxx:380
 TGeoShapeAssembly.cxx:381
 TGeoShapeAssembly.cxx:382
 TGeoShapeAssembly.cxx:383
 TGeoShapeAssembly.cxx:384
 TGeoShapeAssembly.cxx:385
 TGeoShapeAssembly.cxx:386
 TGeoShapeAssembly.cxx:387
 TGeoShapeAssembly.cxx:388
 TGeoShapeAssembly.cxx:389
 TGeoShapeAssembly.cxx:390
 TGeoShapeAssembly.cxx:391
 TGeoShapeAssembly.cxx:392
 TGeoShapeAssembly.cxx:393
 TGeoShapeAssembly.cxx:394
 TGeoShapeAssembly.cxx:395
 TGeoShapeAssembly.cxx:396
 TGeoShapeAssembly.cxx:397
 TGeoShapeAssembly.cxx:398
 TGeoShapeAssembly.cxx:399
 TGeoShapeAssembly.cxx:400
 TGeoShapeAssembly.cxx:401
 TGeoShapeAssembly.cxx:402
 TGeoShapeAssembly.cxx:403
 TGeoShapeAssembly.cxx:404
 TGeoShapeAssembly.cxx:405
 TGeoShapeAssembly.cxx:406
 TGeoShapeAssembly.cxx:407
 TGeoShapeAssembly.cxx:408
 TGeoShapeAssembly.cxx:409
 TGeoShapeAssembly.cxx:410
 TGeoShapeAssembly.cxx:411
 TGeoShapeAssembly.cxx:412
 TGeoShapeAssembly.cxx:413
 TGeoShapeAssembly.cxx:414
 TGeoShapeAssembly.cxx:415
 TGeoShapeAssembly.cxx:416
 TGeoShapeAssembly.cxx:417
 TGeoShapeAssembly.cxx:418
 TGeoShapeAssembly.cxx:419
 TGeoShapeAssembly.cxx:420
 TGeoShapeAssembly.cxx:421
 TGeoShapeAssembly.cxx:422
 TGeoShapeAssembly.cxx:423
 TGeoShapeAssembly.cxx:424
 TGeoShapeAssembly.cxx:425
 TGeoShapeAssembly.cxx:426
 TGeoShapeAssembly.cxx:427
 TGeoShapeAssembly.cxx:428
 TGeoShapeAssembly.cxx:429
 TGeoShapeAssembly.cxx:430
 TGeoShapeAssembly.cxx:431
 TGeoShapeAssembly.cxx:432
 TGeoShapeAssembly.cxx:433
 TGeoShapeAssembly.cxx:434
 TGeoShapeAssembly.cxx:435
 TGeoShapeAssembly.cxx:436
 TGeoShapeAssembly.cxx:437
 TGeoShapeAssembly.cxx:438
 TGeoShapeAssembly.cxx:439
 TGeoShapeAssembly.cxx:440
 TGeoShapeAssembly.cxx:441
 TGeoShapeAssembly.cxx:442
 TGeoShapeAssembly.cxx:443
 TGeoShapeAssembly.cxx:444
 TGeoShapeAssembly.cxx:445
 TGeoShapeAssembly.cxx:446
 TGeoShapeAssembly.cxx:447
 TGeoShapeAssembly.cxx:448
 TGeoShapeAssembly.cxx:449
 TGeoShapeAssembly.cxx:450
 TGeoShapeAssembly.cxx:451
 TGeoShapeAssembly.cxx:452
 TGeoShapeAssembly.cxx:453
 TGeoShapeAssembly.cxx:454
 TGeoShapeAssembly.cxx:455
 TGeoShapeAssembly.cxx:456
 TGeoShapeAssembly.cxx:457
 TGeoShapeAssembly.cxx:458
 TGeoShapeAssembly.cxx:459
 TGeoShapeAssembly.cxx:460
 TGeoShapeAssembly.cxx:461
 TGeoShapeAssembly.cxx:462
 TGeoShapeAssembly.cxx:463
 TGeoShapeAssembly.cxx:464
 TGeoShapeAssembly.cxx:465
 TGeoShapeAssembly.cxx:466
 TGeoShapeAssembly.cxx:467
 TGeoShapeAssembly.cxx:468
 TGeoShapeAssembly.cxx:469
 TGeoShapeAssembly.cxx:470
 TGeoShapeAssembly.cxx:471
 TGeoShapeAssembly.cxx:472
 TGeoShapeAssembly.cxx:473
 TGeoShapeAssembly.cxx:474
 TGeoShapeAssembly.cxx:475
 TGeoShapeAssembly.cxx:476
 TGeoShapeAssembly.cxx:477
 TGeoShapeAssembly.cxx:478
 TGeoShapeAssembly.cxx:479
 TGeoShapeAssembly.cxx:480
 TGeoShapeAssembly.cxx:481
 TGeoShapeAssembly.cxx:482
 TGeoShapeAssembly.cxx:483
 TGeoShapeAssembly.cxx:484
 TGeoShapeAssembly.cxx:485
 TGeoShapeAssembly.cxx:486
 TGeoShapeAssembly.cxx:487
 TGeoShapeAssembly.cxx:488
 TGeoShapeAssembly.cxx:489
 TGeoShapeAssembly.cxx:490
 TGeoShapeAssembly.cxx:491
 TGeoShapeAssembly.cxx:492
 TGeoShapeAssembly.cxx:493
 TGeoShapeAssembly.cxx:494
 TGeoShapeAssembly.cxx:495
 TGeoShapeAssembly.cxx:496
 TGeoShapeAssembly.cxx:497
 TGeoShapeAssembly.cxx:498
 TGeoShapeAssembly.cxx:499
 TGeoShapeAssembly.cxx:500
 TGeoShapeAssembly.cxx:501
 TGeoShapeAssembly.cxx:502
 TGeoShapeAssembly.cxx:503
 TGeoShapeAssembly.cxx:504
 TGeoShapeAssembly.cxx:505
 TGeoShapeAssembly.cxx:506
 TGeoShapeAssembly.cxx:507
 TGeoShapeAssembly.cxx:508
 TGeoShapeAssembly.cxx:509
 TGeoShapeAssembly.cxx:510
 TGeoShapeAssembly.cxx:511
 TGeoShapeAssembly.cxx:512
 TGeoShapeAssembly.cxx:513
 TGeoShapeAssembly.cxx:514
 TGeoShapeAssembly.cxx:515
 TGeoShapeAssembly.cxx:516
 TGeoShapeAssembly.cxx:517
 TGeoShapeAssembly.cxx:518
 TGeoShapeAssembly.cxx:519
 TGeoShapeAssembly.cxx:520
 TGeoShapeAssembly.cxx:521
 TGeoShapeAssembly.cxx:522
 TGeoShapeAssembly.cxx:523
 TGeoShapeAssembly.cxx:524
 TGeoShapeAssembly.cxx:525
 TGeoShapeAssembly.cxx:526
 TGeoShapeAssembly.cxx:527
 TGeoShapeAssembly.cxx:528
 TGeoShapeAssembly.cxx:529
 TGeoShapeAssembly.cxx:530
 TGeoShapeAssembly.cxx:531
 TGeoShapeAssembly.cxx:532
 TGeoShapeAssembly.cxx:533
 TGeoShapeAssembly.cxx:534
 TGeoShapeAssembly.cxx:535
 TGeoShapeAssembly.cxx:536
 TGeoShapeAssembly.cxx:537
 TGeoShapeAssembly.cxx:538
 TGeoShapeAssembly.cxx:539
 TGeoShapeAssembly.cxx:540
 TGeoShapeAssembly.cxx:541
 TGeoShapeAssembly.cxx:542
 TGeoShapeAssembly.cxx:543
 TGeoShapeAssembly.cxx:544