No. of copies made of given TGeoVolume

Hello,
If I have added several copies of a given volume, e.g., with

     TGeoVolume *vol, *cvol, *top;
     TGeoHMatrix *mtx1, *mtx2;
     ...
     top->AddNode( vol, 1 );
     top->AddNode( cvol, 1, mtx1 );
     top->AddNode( cvol, 2, mtx2 );
    ...

Is there any easy way of later determining how many copies of a given volume were added? As in the example above, other volumes might also have been added to the mother volume, so that I cannot simply use
TGeoVolume::GetNdaughters().

Regards,
Gora

Hi Gora,

There is no method to do this directly. There are 2 things you might want to know:

  1. how many copies of a given volume you have positioned in a given container (basically what you have asked for)
  2. how many copies of a given volume are in the whole geometry

The first is easy to implement, e.g.:

Int_t Ncopies(TGeoVolume *vol, TGeoVolume *some_container) {
   Int_t nd = some_container->GetNdaughters();
   Int_t count_duplicates = 0;
   TGeoNode *node;
   for (Int_t i=0; i<nd; i++) {
      node = some_container->GetNode(i); 
      if (node->GetVolume()==replicated_vol) count_duplicates++;
   }
   return count_duplicates;
}

The second is much more tricky, since you can also have the mother of your interesting volume replicated - this means you have to recursively search the node tree starting from the top level.
Regards,