Re: alignment vs "good practice"

From: Andrei Gheata <Andrei.Gheata_at_cern.ch>
Date: Mon, 28 Nov 2005 15:25:20 +0100


Hi Michal,

It was not a usage fault, but nobody made such tests so far... I added some optimizations in CVS related to extensive usage of physical nodes. After checking out, have a look/run the attached testing macro (~15000 nodes). You are right, physical nodes/alignment issues are not documented in the users guide - I will add something very soon.

Regarding the matrix question: the global matrix for an positioned object is piling-up all local transformations in the branch, so there is no easy recipy on how to get this from just the final local one. You can always get the matrix associated with a given path:

gGeoManager->cd(path);
TGeoMatrix *global = gGeoManager->GetCurrentMatrix();

You should know that for a physical node you are only allowed to change the local matrix for the final node in the branch (therefore in a relative way)

Cheers,
Andrei

MichaƂ DwuĆŒnik wrote:

>Hi Rooters!
>
>I'm building a viewer for some geometry, which shall provide means for
>viewing real (moved from ideal position) modules. Recently I found
>the possibility
>of using TGeoPhysicalNode (well, I'm a bit curious why User's Guide
>does not mention
>physical nodes at all?). As far as I understood the geodemo.C and its' vicinity
>using TGeoPhysicalNode::Align lets you "move" the nodes in a already
>closed geometry,
>which is a very nice feature, cause you may easily show the user an
>ideal geometry and then Align(..) the physical nodes. The problem is
>following - for me creating the geometry with ~10000 nodes takes +/-
>ten seconds (which is reasonable), and than invoking
>
> TGeoPhysicalNode t[ncorr];
> for (idx=0 ; idx < ncorr ; idx++)
> {
> geometry->MakePhysicalNode(boxname[idx]);
> t[idx] = geometry->GetPhysicalNode(idx);
> }
> cout << " Done." <<endl;
>
>
> for (idx=0 ; idx < ncorr ; idx++)
> {
> t[idx]->Align(placement[idx]);
>// cout <<idx <<endl;
> }
>
>takes next to infinity (few nodes per second).
>
>So, the first question is if I'm doing the alignment in _that_ non optomal way,
>or it's just as slow as it gets ?
>
>So, for now I'm stuck with building one set of nodes (ideal) and
>another with "real"
>coordinates.
>
>Another question is :
>what's the correct way of computing e.g. a TGeoCombiTrans expressed in a global
>frame, when I have it expressed in the local frame of a module ?
>
>Let's assume a module is a rectangular box (really a TRD1), and
>TGeoCombiTrans *ideal_position (global frame)
>TGeoCombiTrans *correction (local module (node) frame)
>TGeoCombiTrans *real_position
>
> What is "nice" way of finding the real_position ?
>
>Regards
>Michal
>
>PS:Sorry, the appropriate User's Guide chapter coupled with
>Master2Local gave me some
>nice time but I can't get it right, so please forgive me the question above...
>
>
>
>

TStopwatch time;
void aligntest()
{

   time.Start();
   new TGeoManager("test", "alignment");    TGeoMaterial *VacMat = new TGeoMaterial("Vac",0,0,0);

   TGeoMedium *Vac = new TGeoMedium("Vac",1,VacMat);
   TGeoVolume *top = gGeoManager->MakeBox("TOP",Vac,110.,110.,110.);
   TGeoVolume *box = gGeoManager->MakeBox("BOX",Vac,1.,1.,1.);
   TGeoTranslation *tr;
   Double_t x,y,z;
   for (Int_t i=0; i<25; i++) {
      for (Int_t j=0; j<25; j++) {
         for (Int_t k=0; k<25; k++) {
            x = -100. + 8.*i;
            y = -100. + 8.*j;
            z = -100. + 8.*k;
            tr = new TGeoTranslation(x,y,z);
            top->AddNode(box,625*i+25*j+k,tr);
         }
      }

   }
   gGeoManager->SetTopVolume(top);
   gGeoManager->CloseGeometry();
   gGeoManager->SetVisLevel(2);

   time.Stop();
   printf("Geometry creation:\n");
   time.Print();
   time.Start();
   top->Draw("");
   time.Stop();
   printf("Geometry drawing:\n");
   time.Print();
   makenodes();
   printf("TYPE: align() few times\n");
}  

void makenodes()
{

   time.Start();
   char path[20];
   for (Int_t i=0; i<25; i++) {

      for (Int_t j=0; j<25; j++) {
         for (Int_t k=0; k<25; k++) {
            sprintf(path, "/TOP_1/BOX_%i",625*i+25*j+k);
            gGeoManager->MakePhysicalNode(path);
         }
      }

   }
   time.Stop();
   printf("Making physical nodes:\n");
   time.Print();
}

void align()
{

   time.Start();
   TGeoTranslation *tr;
   TGeoPhysicalNode *node;
   gRandom = new TRandom3();
   Double_t *tr_vec;
   Double_t x,y,z;
   TIter next(gGeoManager->GetListOfPhysicalNodes());    while ((node=(TGeoPhysicalNode*)next())) {

      tr = (TGeoTranslation*)node->GetNode()->GetMatrix();
      tr_vec = tr->GetTranslation();
      x = tr_vec[0] + (0.5-gRandom->Rndm());
      y = tr_vec[1] + (0.5-gRandom->Rndm());
      z = tr_vec[2] + (0.5-gRandom->Rndm());
      tr->SetTranslation(x,y,z);
      node->Align(tr);

   }
   time.Stop();
   printf("Align all existing physical nodes:\n");    time.Print();
   gPad->Modified();
}        Received on Mon Nov 28 2005 - 15:20:49 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET