Modified AliITSvPPRasymmFMD.cxx so that it will, using the Virtual MC,
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 10 Feb 2006 21:00:31 +0000 (21:00 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 10 Feb 2006 21:00:31 +0000 (21:00 +0000)
initlized AliITSgeom directly from the geometrical modeler (not
just directly from GEANT3's zebra banks). Add an inline function
to AliITSgeom needed to do this initilization. Compairing the old
ITS/ITSgeometry_vPPRasymmFMD.det to a new file created using
this new Virtual MC interface. The files are NOT IDENTICAL but
differ in the translation and rotation maxtix values at the
1 in 1E-6 or less. Everthing else is exact, including the detector
sizes. Why this differene, I don't know.

ITS/AliITSgeom.h
ITS/AliITSvPPRasymmFMD.cxx

index 7dc9f9738e6a41eb3cae97b982b87cc7fad8bad3..adcffaa01d5fbc9e5a5c620986ad5afeffd860be 100644 (file)
@@ -219,6 +219,12 @@ class AliITSgeom : public TObject {
           Double_t rot[3][3];
          GetGeomMatrix(index)->GetMatrix(rot);
           for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) mat[3*i+j] = rot[i][j];}
+    //     This function sets the rotation matrix in a Double
+    // precision pointer for a given module. mat[i][j] => mat[3*i+j].
+    void  SetRotMatrix(Int_t index,Double_t *mat){Double_t rot[3][3];
+          for(Int_t i=0;i<3;i++)for(Int_t j=0;j<3;j++) rot[i][j]=mat[3*i+j];
+          GetGeomMatrix(index)->SetMatrix(rot);}
+
 //
     //     Will define fShape if it isn't already defined.
     void DefineShapes(Int_t size=4)
index 217c97b2e51a2af3446baad40869f0bcb68122af..edebeef577e2164104e0bd3f87473127d28da3bb 100644 (file)
 #include <TClonesArray.h>
 #include <TGeometry.h>
 #include <TLorentzVector.h>
+#include <TGeoMatrix.h>
+#include <TArrayD.h>
+#include <TArrayF.h>
+#include <TString.h>
 #include <TNode.h>
 #include <TTUBE.h>
 
@@ -5008,142 +5012,103 @@ void AliITSvPPRasymmFMD::InitAliITSgeom(){
     //   none.
     // Return:
     //   none.
-//#if GEANTGEOMETRY
-    if(strcmp(gMC->GetName(),"TGeant3")) {
-       Error("InitAliITSgeom",
-             "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
-       return;
-    } // end if
-    AliDebug(1,"Reading Geometry transformation directly from Geant 3.");
     const Int_t knlayers = 6;
-    const Int_t kndeep = 9;
-    Int_t itsGeomTreeNames[knlayers][kndeep],lnam[20],lnum[20];
-    Int_t nlad[knlayers],ndet[knlayers];
-    Double_t t[3],r[10];
-    Float_t  par[20],att[20];
-    Int_t    npar,natt,idshape,imat,imed;
-    AliITSGeant3Geometry *ig = new AliITSGeant3Geometry();
-    Int_t mod,lay,lad,det,i,j,k;
-    Char_t names[knlayers][kndeep][4];
-    Int_t itsGeomTreeCopys[knlayers][kndeep];
-    if(fMinorVersion == 1){ // Option A
-    const char *namesA[knlayers][kndeep] = {
-     {"ALIC","ITSV","ITSD","IT12","I12A","I10A","I103","I101","ITS1"}, // lay=1
-     {"ALIC","ITSV","ITSD","IT12","I12A","I20A","I1D3","I1D1","ITS2"}, // lay=2
-     {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3","    ","    "}, // lay=3
-     {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4","    ","    "}, // lay=4
-     {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5","    ","    "}, // lay=5
-     {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6","    ","    "}};// lay=6
-    Int_t itsGeomTreeCopysA[knlayers][kndeep]= {{1,1,1,1,10, 2, 4,1,1},// lay=1
-                                             {1,1,1,1,10, 4, 4,1,1},// lay=2
-                                             {1,1,1,1,14, 6, 1,0,0},// lay=3
-                                             {1,1,1,1,22, 8, 1,0,0},// lay=4
-                                             {1,1,1,1,34,22, 1,0,0},// lay=5
-                                             {1,1,1,1,38,25, 1,0,0}};//lay=6
-    for(i=0;i<knlayers;i++)for(j=0;j<kndeep;j++){
-       for(k=0;k<4;k++) names[i][j][k] = namesA[i][j][k];
-       itsGeomTreeCopys[i][j] = itsGeomTreeCopysA[i][j];
-    } // end for i,j
-    }else if(fMinorVersion == 2){ // Option B
-    const char *namesB[knlayers][kndeep] = {
-     {"ALIC","ITSV","ITSD","IT12","I12B","I10B","I107","I101","ITS1"}, // lay=1
-     {"ALIC","ITSV","ITSD","IT12","I12B","I20B","I1D7","I1D1","ITS2"}, // lay=2
-     {"ALIC","ITSV","ITSD","IT34","I004","I302","ITS3","    ","    "}, // lay=3
-     {"ALIC","ITSV","ITSD","IT34","I005","I402","ITS4","    ","    "}, // lay=4
-     {"ALIC","ITSV","ITSD","IT56","I565","I562","ITS5","    ","    "}, // lay=5
-     {"ALIC","ITSV","ITSD","IT56","I569","I566","ITS6","    ","    "}};// lay=6
-    Int_t itsGeomTreeCopysB[knlayers][kndeep]= {{1,1,1,1,10, 2, 4,1,1},// lay=1
-                                             {1,1,1,1,10, 4, 4,1,1},// lay=2
-                                             {1,1,1,1,14, 6, 1,0,0},// lay=3
-                                             {1,1,1,1,22, 8, 1,0,0},// lay=4
-                                             {1,1,1,1,34,22, 1,0,0},// lay=5
-                                             {1,1,1,1,38,25, 1,0,0}};//lay=6
-    for(i=0;i<knlayers;i++)for(j=0;j<kndeep;j++){
-       for(k=0;k<4;k++) names[i][j][k] = namesB[i][j][k];
-       itsGeomTreeCopys[i][j] = itsGeomTreeCopysB[i][j];
-    } // end for i,j
-    } // end if fMinorVersion
-    // Sorry, but this is not very pritty code. It should be replaced
-    // at some point with a version that can search through the geometry
-    // tree its self.
-    AliDebug(1,"Reading Geometry informaton from Geant3 common blocks");
-    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
-    for(i=0;i<knlayers;i++)for(j=0;j<kndeep;j++)
-        strncpy((char*) &itsGeomTreeNames[i][j],names[i][j],4); 
-    // itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    const Int_t kndeep = 3;
+    const AliITSDetector idet[knlayers]={kSPD,kSPD,kSDD,kSDD,kSSD,kSSD};
+    const TString names[2][knlayers] = {
+     {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I10A_%d/I103_%d/I101_1/ITS1_1", // lay=1
+      "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12A_%d/I20A_%d/I1D3_%d/I1D1_1/ITS2_1", // lay=2
+      "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
+      "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
+      "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
+      "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"},// lay=6
+     {"/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I10B_%d/I107_%d/I101_1/ITS1_1", // lay=1
+      "/ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_%d/I20B_%d/I1D7_%d/I1D1_1/ITS2_1", // lay=2
+      "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_%d/I302_%d/ITS3_%d", // lay=3
+      "/ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_%d/I402_%d/ITS4_%d", // lay=4
+      "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_%d/I562_%d/ITS5_%d", // lay=5
+      "/ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_%d/I566_%d/ITS6_%d"}
+    };
+    const Int_t itsGeomTreeCopys[knlayers][kndeep]= {{10, 2, 4},// lay=1
+                                                     {10, 4, 4},// lay=2
+                                                     {14, 6, 1},// lay=3
+                                                     {22, 8, 1},// lay=4
+                                                     {34,22, 1},// lay=5
+                                                     {38,25, 1}};//lay=6
+    Int_t       nlad[knlayers],ndet[knlayers];
+    Int_t       mod,lay,lad=0,det=0,i,j,k,cp0,cp1,cp2;
+    TString path,shapeName;
+    TGeoHMatrix materix;
+    Double_t trans[3]={3*0.0},rot[10]={9*0.0,1.0};
+    TArrayD shapePar;
+    TArrayF shapeParF;
+
+    AliDebug(1,"Reading Geometry transformation directly from Modler.");
     mod = 0;
     for(i=0;i<knlayers;i++){
-       k = 1;
-       for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
-           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
-       mod += k;
+        k = 1;
+        for(j=0;j<kndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+            k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+        mod += k;
     } // end for i
 
-    if(GetITSgeom()!=0) SetITSgeom(0x0);
+    if(GetITSgeom()!=0) delete GetITSgeom();
+    SetITSgeom(0);
     nlad[0]=20;nlad[1]=40;nlad[2]=14;nlad[3]=22;nlad[4]=34;nlad[5]=38;
-    ndet[0]=4;ndet[1]=4;ndet[2]=6;ndet[3]=8;ndet[4]=22;ndet[5]=25;
+    ndet[0]= 4;ndet[1]= 4;ndet[2]= 6;ndet[3]= 8;ndet[4]=22;ndet[5]=25;
     AliITSgeom* geom = new AliITSgeom(0,6,nlad,ndet,mod);
     SetITSgeom(geom);
-    mod = -1;
+    mod = 0;
     for(lay=1;lay<=knlayers;lay++){
-       for(j=0;j<kndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
-       for(j=0;j<kndeep;j++) lnum[j] = itsGeomTreeCopys[lay-1][j];
-       switch (lay){
-       case 1: case 2: // layers 1 and 2 are a bit special
-           lad = 0;
-           for(j=1;j<=itsGeomTreeCopys[lay-1][4];j++){
-               lnum[4] = j;
-               for(k=1;k<=itsGeomTreeCopys[lay-1][5];k++){
-                   lad++;
-                   lnum[5] = k;
-                   for(det=1;det<=itsGeomTreeCopys[lay-1][6];det++){
-                       lnum[6] = det;
-                       mod++;
-                       ig->GetGeometry(kndeep,lnam,lnum,t,r,idshape,npar,natt,
-                                       par,att,imat,imed);
-                       GetITSgeom()->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
-                       if(!(GetITSgeom()->IsShapeDefined((Int_t)kSPD)))
-                             GetITSgeom()->ReSetShape(kSPD,
-                                         new AliITSgeomSPD425Short(npar,par));
-                   } // end for det
-               } // end for k
-            } // end for j
-           break;
-       case 3: case 4: case 5: case 6: // layers 3-6
-           lnum[6] = 1;
-           for(lad=1;lad<=itsGeomTreeCopys[lay-1][4];lad++){
-               lnum[4] = lad;
-               for(det=1;det<=itsGeomTreeCopys[lay-1][5];det++){
-                   lnum[5] = det;
-                   mod++;
-                   ig->GetGeometry(7,lnam,lnum,t,r,idshape,npar,natt,
-                                   par,att,imat,imed);
-                   switch (lay){
-                   case 3: case 4:
-                       GetITSgeom()->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
-                       if(!(GetITSgeom()->IsShapeDefined(kSDD))) 
-                           GetITSgeom()->ReSetShape(kSDD,
-                                            new AliITSgeomSDD256(npar,par));
-                           break;
-                       case 5:
-                           GetITSgeom()->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
-                           if(!(GetITSgeom()->IsShapeDefined(kSSD))) 
-                               GetITSgeom()->ReSetShape(kSSD,
-                                         new AliITSgeomSSD275and75(npar,par));
-                           break;
-                       case 6:
-                           GetITSgeom()->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
-                           if(!(GetITSgeom()->IsShapeDefined(kSSD))) 
-                               GetITSgeom()->ReSetShape(kSSD,
-                                         new AliITSgeomSSD75and275(npar,par));
-                           break;
-                       } // end switch
-               } // end for det
-           } // end for lad
-           break;
-       } // end switch
+        for(cp0=1;cp0<=itsGeomTreeCopys[lay-1][0];cp0++){
+            for(cp1=1;cp1<=itsGeomTreeCopys[lay-1][1];cp1++){
+                for(cp2=1;cp2<=itsGeomTreeCopys[lay-1][2];cp2++){
+                    path.Form(names[fMinorVersion-1][lay-1].Data(),
+                              cp0,cp1,cp2);
+                    switch (lay){
+                    case 1:{
+                        det = cp2;
+                        lad = cp1+2*(cp0-1);
+                    }break;
+                    case 2:{
+                        det = cp2;
+                        lad = cp1+4*(cp0-1);
+                    } break;
+                    case 3: case 4: case 5: case 6:{
+                        det = cp1;
+                        lad = cp0;
+                    } break;
+                    } // end switch
+                         //AliInfo(Form("path=%s lay=%d lad=%d det=%d",
+                         //             path.Data(),lay,lad,det));
+                    gMC->GetTransformation(path.Data(),materix);
+                    gMC->GetShape(path.Data(),shapeName,shapePar);
+                    shapeParF.Set(shapePar.GetSize());
+                    for(i=0;i<shapePar.GetSize();i++) shapeParF[i]=shapePar[i];
+                    geom->CreatMatrix(mod,lay,lad,det,idet[lay-1],trans,rot);
+                    geom->SetTrans(mod,materix.GetTranslation());
+                    geom->SetRotMatrix(mod,materix.GetRotationMatrix());
+                    switch (lay){
+                    case 1: case 2:{
+                        geom->ReSetShape(kSPD,new AliITSgeomSPD425Short(
+                                shapeParF.GetSize(),shapeParF.GetArray()));
+                    }break;
+                    case 3: case 4:{
+                        geom->ReSetShape(kSDD,new AliITSgeomSDD256(
+                                shapeParF.GetSize(),shapeParF.GetArray()));
+                    }break;
+                    case 5: case 6:{
+                        geom->ReSetShape(kSSD,new AliITSgeomSSD75and275(
+                                shapeParF.GetSize(),shapeParF.GetArray()));
+                    }break;
+                    default:{
+                    }break;
+                    } // end switch
+                    mod++;
+                } /// end for cp2
+            } // end for cp1
+        } // end for cp0
     } // end for lay
-//#endif
     return;
 }
 //______________________________________________________________________