]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Added fMajor/MinorVersion variables and made other changes to better make
authornilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Feb 2001 00:05:31 +0000 (00:05 +0000)
committernilsen <nilsen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 9 Feb 2001 00:05:31 +0000 (00:05 +0000)
use of the new code changes in AliITSgeom related classes.

18 files changed:
ITS/AliITSv1.h
ITS/AliITSv3.h
ITS/AliITSv5.cxx
ITS/AliITSv5.h
ITS/AliITSv5asymm.cxx
ITS/AliITSv5asymm.h
ITS/AliITSv5symm.cxx
ITS/AliITSv5symm.h
ITS/AliITSvPPRasymm.cxx
ITS/AliITSvPPRasymm.h
ITS/AliITSvPPRcoarseasymm.cxx
ITS/AliITSvPPRcoarseasymm.h
ITS/AliITSvPPRcoarsesymm.cxx
ITS/AliITSvPPRcoarsesymm.h
ITS/AliITSvPPRsymm.cxx
ITS/AliITSvPPRsymm.h
ITS/AliITSvtest.cxx
ITS/AliITSvtest.h

index 5fc24b7a3235018cb9c98a9d3af20912c246ce27..4f6a35716f53af071755687f069e02e1eac06ee5 100644 (file)
@@ -23,12 +23,55 @@ class AliITSv1 : public AliITS {
     virtual void   CreateGeometry();
     virtual void   CreateMaterials();
     virtual void   Init(); 
-    virtual Int_t  IsVersion() const {
-      // returns the ITS version number 
-      return 1;
-    } 
+    virtual Int_t  IsVersion() const {// returns the ITS version number 
+       return 1;}
     virtual void   DrawModule();
     virtual void   StepManager();
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
     ClassDef(AliITSv1,1)  //Hits manager for set:ITS version 1 cource Geometry
 };
index c33600154d05fa1a74932b8c4b6dfe6c37e68b7b..fff2d79ace2b9af21d5f8eb7639406abb304543a 100644 (file)
@@ -27,11 +27,52 @@ class AliITSv3 : public AliITS {
       // returns the ITS version number 
       return 3;
     }
-    virtual void   SetMinorVersion(Int_t version) {
-      // sets the minor version 
-      fMinorVersion=version;
-    }
     virtual void   StepManager();
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
    
     ClassDef(AliITSv3,1)//Hits manager for set:ITS version 3, TP detailed geometry
 };
index bc83b5e3a6ce012dd52e959455c9979ac14c46c0..19f74f079f457855a0ab2b3288e782c1fa51be1f 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.28  2001/02/02 23:57:28  nilsen
+Added include file that are no londer included in AliITSgeom.h
+
 Revision 1.27  2001/01/30 09:23:13  hristov
 Streamers removed (R.Brun)
 
@@ -67,10 +70,6 @@ Introduction of the Copyright and cvs Log
 // Created September 17 1999.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
-// See AliITSv5::StepManager().
-#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
-//#define ALIITSPRINTGEOM 1 // print out geometry information
 #include <iostream.h>
 #include <iomanip.h>
 #include <stdio.h>
@@ -90,13 +89,15 @@ Introduction of the Copyright and cvs Log
 
 #include "AliMC.h"
 #include "AliRun.h"
-#if ALIITSPRINTGEOM==1
 #include "../TGeant3/TGeant3.h"
-#endif
 #include "AliITShit.h"
+#include "AliITSGeant3Geometry.h"
 #include "AliITS.h"
 #include "AliITSv5.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 ClassImp(AliITSv5)
  
@@ -105,12 +106,52 @@ AliITSv5::AliITSv5() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard default constructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
     fIdN    = 0;
     fIdName = 0;
     fIdSens = 0;
-    fMajorVersion = 5;
-    fMinorVersion = -1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 1;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
+}
+//_____________________________________________________________________________
+AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
+////////////////////////////////////////////////////////////////////////
+//    Standard constructor for the ITS version 5.
+////////////////////////////////////////////////////////////////////////
+    Int_t i;
+
+    fIdN    = 6;
+    fIdName    = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (i=0;i<fIdN;i++) fIdSens[i] = 0;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 1;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+
+    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
+    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 }
 //____________________________________________________________________________
 AliITSv5::AliITSv5(const AliITSv5 &source){
@@ -118,17 +159,17 @@ AliITSv5::AliITSv5(const AliITSv5 &source){
 //     Copy Constructor for ITS version 5.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSv5\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSv5");
     return;
 }
 //_____________________________________________________________________________
 AliITSv5& AliITSv5::operator=(const AliITSv5 &source){
 ////////////////////////////////////////////////////////////////////////
-//    Assignment operator for the ITS version 1.
+//    Assignment operator for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
 
     if(&source == this) return *this;
-    printf("Not allowed to copy AliITSv3\n");
+    Warning("= operator","Not allowed to copy AliITSv5");
     return *this;
 
 }
@@ -137,40 +178,11 @@ AliITSv5::~AliITSv5() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard destructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
-//_____________________________________________________________________________
-AliITSv5::AliITSv5(const char *name, const char *title) : AliITS(name, title){
-////////////////////////////////////////////////////////////////////////
-//    Standard constructor for the ITS version 5.
-////////////////////////////////////////////////////////////////////////
-    fIdN    = 6;
-/*
-//  TObjArray of TObjStrings
-    fIdName = new TObjArray(fIdN);
-    fIdName->AddAt(new TObjString("ITS1"),0);
-    fIdName->AddAt(new TObjString("ITS2"),1);
-    fIdName->AddAt(new TObjString("ITS3"),2);
-    fIdName->AddAt(new TObjString("ITS4"),3);
-    fIdName->AddAt(new TObjString("ITS5"),4);
-    fIdName->AddAt(new TObjString("ITS6"),5);
-*/
-//  Array of TStrings.
-    fIdName    = new TString[fIdN];
-    fIdName[0] = "ITS1";
-    fIdName[1] = "ITS2";
-    fIdName[2] = "ITS3";
-    fIdName[3] = "ITS4";
-    fIdName[4] = "ITS5";
-    fIdName[5] = "ITS6";
-    fIdSens    = new Int_t[fIdN];
-    for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
-    fMajorVersion = 5;
-    fMinorVersion = 1;
-
-    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5.tme";
-    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5.euc";
-}
-//_____________________________________________________________________________
+//______________________________________________________________________
 void AliITSv5::BuildGeometry(){
 ////////////////////////////////////////////////////////////////////////
 //    Geometry builder for the ITS version 5.
@@ -186,8 +198,9 @@ void AliITSv5::BuildGeometry(){
   //const int kColorITSSDD=kGreen;
   const int kColorITSSSD=kBlue;
   //
-  top=gAlice->GetGeometry()->GetNode("alice");
   AliITSgeom  *gm = this->GetITSgeom();
+  if(gm==0) return;
+  top=gAlice->GetGeometry()->GetNode("alice");
 
   Int_t       lay,lad,det,i;
   Text_t      name[10];
@@ -540,7 +553,7 @@ void AliITSv5::CreateGeometry(){
 //    Read a file containing the geometry for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
 
-    Int_t size;
+
     char topvol[5];
     char *filtmp;
 
@@ -549,7 +562,7 @@ void AliITSv5::CreateGeometry(){
   delete [] filtmp;
   if(file) {
     fclose(file);
-    printf("Ready to read Euclid geometry file\n");
+    cout << "Ready to read Euclid geometry file" << endl;
     ReadEuclid(fEuclidGeometry.Data(),topvol);
     printf("Read in euclid geometries\n");
   } else {
@@ -569,38 +582,176 @@ void AliITSv5::CreateGeometry(){
       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
     } // end if (fEuclidOut)
 
+    cout << "finished with euclid geometrys" << endl;
+}
+//______________________________________________________________________
+void AliITSv5::ReadOldGeometry(const char *filename){
     // read in the file containing the transformations for the active
     // volumes for the ITS version 5. This is expected to be in a file
     // ending in .det. This geometry is kept in the AliITSgeom class.
-    filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
+    Int_t size;
+    char *filtmp;
+    FILE *file;
+
+    if(fITSgeom!=0) delete fITSgeom;
+    filtmp = gSystem->ExpandPathName(filename);
     size = strlen(filtmp);
-    if(size>4){
-       filtmp[size-3] = 'd'; // change from .euc to .det
+    if(size>4 && fGeomDetIn){
+        filtmp[size-3] = 'd'; // change from .euc to .det
         filtmp[size-2] = 'e';
         filtmp[size-1] = 't';
-       file = fopen(filtmp,"r");
-       if(file){ // if file exists use it to fill AliITSgeom structure.
-           fclose(file);
-           printf("ready to read .det file %s\n",filtmp);
-           fITSgeom = new AliITSgeom(filtmp);
-       }else{
-           fITSgeom = 0;
-           // fill AliITSgeom structure from geant structure just filled above
-       }// end if(file)
+        file = fopen(filtmp,"r");
+        if(file){ // if file exists use it to fill AliITSgeom structure.
+            fclose(file);
+            fITSgeom = new AliITSgeom(filtmp);
+            fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
+            // Now define the detector types/shapes.
+            fITSgeom->ReSetShape(kSPD,new AliITSgeomSPD300());
+            fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
+            fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
+        }else{
+            fITSgeom = 0;
+            // fill AliITSgeom structure from geant structure just filled above
+        }// end if(file)
         delete [] filtmp;
     }// end if(size>4)
-    printf("finished with euclid geometrys\n");
+}
+//______________________________________________________________________
+void AliITSv5::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 7;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+        {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
+        {"ALIC","ITSV","ITSD","IT12","I132","I131","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 itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
+                                              {1,1,1,1,10, 4,4}, // lay=2
+                                              {1,1,1,1,14, 6,1}, // lay=3
+                                              {1,1,1,1,22, 8,1}, // lay=4
+                                              {1,1,1,1,34,23,1}, // lay=5
+                                              {1,1,1,1,38,26,1}};// lay=6
+
+    // 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.
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
+
+    if(fITSgeom!=0) delete fITSgeom;
+    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;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD300());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
+                       break;
+                   case 5: case 6:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                           fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
+                       break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
 }
 //_____________________________________________________________________________
 void AliITSv5::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
+    Bool_t bg = kFALSE;
 
+    cout << endl;
+    for(i=0;i<30;i++) cout << "*";cout << " ITSv5_Init ";
+    for(i=0;i<30;i++) cout << "*";cout << endl;
+//
+    if(fITSgeom==0) bg = kTRUE;
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fGeomDetIn && !fGeomOldDetIn){
+       if(fITSgeom!=0) delete fITSgeom;
+       fITSgeom = new AliITSgeom();
+       fITSgeom->ReadNewFile(fRead);
+    } // end if
+    if(fGeomDetIn &&  fGeomOldDetIn) ReadOldGeometry(fEuclidGeometry.Data());
+
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
+    if(bg) BuildGeometry(); // call BuildGeometry here if fITSgeom was not
+                            // defined ealier
     AliITS::Init();
-    fMajorVersion = 5;
-    fMinorVersion = 0;
-} 
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
+}
 //_____________________________________________________________________________
 void AliITSv5::StepManager(){
 ////////////////////////////////////////////////////////////////////////
@@ -618,19 +769,6 @@ void AliITSv5::StepManager(){
   Int_t          vol[4];
   TLorentzVector position, momentum;
   TClonesArray   &lhits = *fHits;
-#if ALIITSPRINTGEOM==1
-  FILE          *fp;
-  Int_t         i;
-  Float_t       xl[3],xt[3],angl[6];
-//  Float_t       par[20],att[20];
-  Float_t      mat[9];
-  static Bool_t first=kTRUE,printit[6][50][50];
-  if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
-      for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
-  first = kFALSE;
-  }
-  // end if first
-#endif
   //
   // Track status
   vol[3] = 0;
@@ -714,52 +852,5 @@ void AliITSv5::StepManager(){
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
-#if ALIITSPRINTGEOM==1
-  if(printit[vol[0]][vol[2]][vol[1]]){
-      printit[vol[0]][vol[2]][vol[1]] = kFALSE;
-      xl[0] = xl[1] = xl[2] = 0.0;
-      gMC->Gdtom(xl,xt,1);
-      for(i=0;i<9;i++) mat[i] = 0.0;
-      mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
-      xl[0] = 1.0;
-      xl[1] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[0]),2);
-      xl[1] = 1.0;
-      xl[0] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[3]),2);
-      xl[2] = 1.0;
-      xl[1] = xl[0] =0.0;
-      gMC->Gdtom(xl,&(mat[6]),2);
-
-      angl[0] = TMath::ACos(mat[2]);
-      if(mat[2]==1.0) angl[0] = 0.0;
-      angl[1] = TMath::ATan2(mat[1],mat[0]);
-      if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
-
-      angl[2] = TMath::ACos(mat[5]);
-      if(mat[5]==1.0) angl[2] = 0.0;
-      angl[3] = TMath::ATan2(mat[4],mat[3]);
-      if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
-
-      angl[4] = TMath::ACos(mat[8]);
-      if(mat[8]==1.0) angl[4] = 0.0;
-      angl[5] = TMath::ATan2(mat[7],mat[6]);
-      if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
-
-      for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
-      fp = fopen("ITSgeometry_v5.det","a");
-      fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
-             vol[0],vol[2],vol[1], // layer ladder detector
-             xt[0],xt[1],xt[2],    // Translation vector
-             angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
-                                                           // angles (degrees)
-             );
-      fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
-            mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
-         );  // Adding the rotation matrix.
-      fprintf(fp,"\n");
-      fclose(fp);
-  } // end if printit[layer][ladder][detector]
-#endif
   return;
 }
index 9220d7ddb2778e77f57cb6bf8434e6f55927f37e..4ef99d1dea628ce9444570cfbf18d964f1219af4 100644 (file)
@@ -24,12 +24,61 @@ class AliITSv5 : public AliITS {
     virtual void   BuildGeometry();
     virtual void  CreateGeometry();
     virtual void  CreateMaterials();
-    virtual void  Init();   
-    virtual Int_t IsVersion() const {
-      // returns the ITS version number
-      return 5;
-    }
+    virtual void  Init();
+    virtual Int_t IsVersion() const { // returns the ITS version number
+       return 5;}
     virtual void  StepManager();
+    void ReadOldGeometry(const char *filename);
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadOldDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomOldDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual Bool_t GetReadDetOld() { // returns value GeomDetIn flag.
+                                return fGeomOldDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Bool_t fGeomOldDetIn;     // Flag to read old .det file.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
 
     ClassDef(AliITSv5,1)//Hits manager for ITS version 5 Official detailed geometry
index f1b4f45fa351ea4e3ec2f211481bbab84cb6b06d..3de83887c9f1f9006d9a78ce76e32c55db57cf2c 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.4  2001/02/02 23:57:29  nilsen
+Added include file that are no londer included in AliITSgeom.h
+
 Revision 1.3  2001/01/30 09:23:13  hristov
 Streamers removed (R.Brun)
 
@@ -70,10 +73,6 @@ Introduction of the Copyright and cvs Log
 // Created October 7 2000.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
-// See AliITSv5asymm::StepManager().
-#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
-//#define ALIITSPRINTGEOM 1 // print out geometry information
 #include <iostream.h>
 #include <iomanip.h>
 #include <stdio.h>
@@ -93,13 +92,15 @@ Introduction of the Copyright and cvs Log
 
 #include "AliMC.h"
 #include "AliRun.h"
-#if ALIITSPRINTGEOM==1
 #include "../TGeant3/TGeant3.h"
-#endif
 #include "AliITShit.h"
+#include "AliITSGeant3Geometry.h"
 #include "AliITS.h"
 #include "AliITSv5asymm.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 ClassImp(AliITSv5asymm)
  
@@ -108,12 +109,52 @@ AliITSv5asymm::AliITSv5asymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard default constructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
     fIdN    = 0;
     fIdName = 0;
     fIdSens = 0;
-    fMajorVersion = 5;
-    fMinorVersion = -1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kFALSE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 3;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
+}
+//_____________________________________________________________________________
+AliITSv5asymm::AliITSv5asymm(const char *name, const char *title) : AliITS(name, title){
+/////////////////////////////////////////////////////////////////////////////
+//    Standard constructor for the ITS version 5 with symmetrical services.
+/////////////////////////////////////////////////////////////////////////////
+    Int_t i;
+
+    fIdN    = 6;
+    fIdName    = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (i=0;i<fIdN;i++) fIdSens[i] = 0;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kFALSE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 3;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+
+    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5asymm.tme";
+    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5asymm.euc";
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5asymm.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 }
 //____________________________________________________________________________
 AliITSv5asymm::AliITSv5asymm(const AliITSv5asymm &source){
@@ -121,17 +162,17 @@ AliITSv5asymm::AliITSv5asymm(const AliITSv5asymm &source){
 //     Copy Constructor for ITS version 5.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSv5asymm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSv5asymm");
     return;
 }
 //_____________________________________________________________________________
 AliITSv5asymm& AliITSv5asymm::operator=(const AliITSv5asymm &source){
 ////////////////////////////////////////////////////////////////////////
-//    Assignment operator for the ITS version 1.
+//    Assignment operator for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
 
     if(&source == this) return *this;
-    printf("Not allowed to copy AliITSv3\n");
+    Warning("= operator","Not allowed to copy AliITSv5asymm");
     return *this;
 
 }
@@ -140,38 +181,9 @@ AliITSv5asymm::~AliITSv5asymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard destructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
-}
-//_____________________________________________________________________________
-AliITSv5asymm::AliITSv5asymm(const char *name, const char *title) : AliITS(name, title){
-////////////////////////////////////////////////////////////////////////
-//    Standard constructor for the ITS version 5.
-////////////////////////////////////////////////////////////////////////
-    fIdN    = 6;
-/*
-//  TObjArray of TObjStrings
-    fIdName = new TObjArray(fIdN);
-    fIdName->AddAt(new TObjString("ITS1"),0);
-    fIdName->AddAt(new TObjString("ITS2"),1);
-    fIdName->AddAt(new TObjString("ITS3"),2);
-    fIdName->AddAt(new TObjString("ITS4"),3);
-    fIdName->AddAt(new TObjString("ITS5"),4);
-    fIdName->AddAt(new TObjString("ITS6"),5);
-*/
-//  Array of TStrings.
-    fIdName    = new TString[fIdN];
-    fIdName[0] = "ITS1";
-    fIdName[1] = "ITS2";
-    fIdName[2] = "ITS3";
-    fIdName[3] = "ITS4";
-    fIdName[4] = "ITS5";
-    fIdName[5] = "ITS6";
-    fIdSens    = new Int_t[fIdN];
-    for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
-    fMajorVersion = 5;
-    fMinorVersion = 1;
-
-    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5asymm.tme";
-    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5asymm.euc";
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
 //_____________________________________________________________________________
 void AliITSv5asymm::BuildGeometry(){
@@ -594,15 +606,172 @@ void AliITSv5asymm::CreateGeometry(){
     }// end if(size>4)
     printf("finished with euclid geometrys\n");
 }
+
+//______________________________________________________________________
+void AliITSv5asymm::ReadOldGeometry(const char *filename){
+    // read in the file containing the transformations for the active
+    // volumes for the ITS version 5. This is expected to be in a file
+    // ending in .det. This geometry is kept in the AliITSgeom class.
+    Int_t size;
+    char *filtmp;
+    FILE *file;
+
+    filtmp = gSystem->ExpandPathName(filename);
+    size = strlen(filtmp);
+    if(size>4 && fGeomDetIn){
+        filtmp[size-3] = 'd'; // change from .euc to .det
+        filtmp[size-2] = 'e';
+        filtmp[size-1] = 't';
+        file = fopen(filtmp,"r");
+        if(file){ // if file exists use it to fill AliITSgeom structure.
+            fclose(file);
+            fITSgeom = new AliITSgeom(filtmp);
+            fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
+            // Now define the detector types/shapes.
+            fITSgeom->ReSetShape(kSPD,(TObject *) new AliITSgeomSPD300());
+            fITSgeom->ReSetShape(kSDD,(TObject *) new AliITSgeomSDD300());
+            fITSgeom->ReSetShape(kSSD,(TObject *) new AliITSgeomSSD());
+        }else{
+            fITSgeom = 0;
+            // fill AliITSgeom structure from geant structure just filled above
+        }// end if(file)
+        delete [] filtmp;
+    }// end if(size>4)
+}
+//______________________________________________________________________
+void AliITSv5asymm::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 7;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+        {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
+        {"ALIC","ITSV","ITSD","IT12","I132","I131","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 itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
+                                              {1,1,1,1,10, 4,4}, // lay=2
+                                              {1,1,1,1,14, 6,1}, // lay=3
+                                              {1,1,1,1,22, 8,1}, // lay=4
+                                              {1,1,1,1,34,23,1}, // lay=5
+                                              {1,1,1,1,38,26,1}};// lay=6
+
+    // 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.
+    cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
+
+    if(fITSgeom!=0) delete fITSgeom;
+    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;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                           if(fMinorVersion==1){
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD300());
+                           } else if(fMinorVersion==2)
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD300());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
+                           break;
+                   case 5: case 6:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                               fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
+                           break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
+}
 //_____________________________________________________________________________
 void AliITSv5asymm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
+    cout << endl;
+    for(i=0;i<30;i++) cout << "*";cout << " ITSv5_Init ";
+    for(i=0;i<30;i++) cout << "*";cout << endl;
+//
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn && !fGeomOldDetIn) fITSgeom->ReadNewFile(fRead);
+    if(fGeomDetIn &&  fGeomOldDetIn) this->ReadOldGeometry(fRead);
+
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-    fMajorVersion = 5;
-    fMinorVersion = 0;
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
 } 
 //_____________________________________________________________________________
 void AliITSv5asymm::StepManager(){
@@ -621,19 +790,6 @@ void AliITSv5asymm::StepManager(){
   Int_t          vol[4];
   TLorentzVector position, momentum;
   TClonesArray   &lhits = *fHits;
-#if ALIITSPRINTGEOM==1
-  FILE          *fp;
-  Int_t         i;
-  Float_t       xl[3],xt[3],angl[6];
-//  Float_t       par[20],att[20];
-  Float_t      mat[9];
-  static Bool_t first=kTRUE,printit[6][50][50];
-  if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
-      for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
-  first = kFALSE;
-  }
-  // end if first
-#endif
   //
   // Track status
   vol[3] = 0;
@@ -717,52 +873,5 @@ void AliITSv5asymm::StepManager(){
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
-#if ALIITSPRINTGEOM==1
-  if(printit[vol[0]][vol[2]][vol[1]]){
-      printit[vol[0]][vol[2]][vol[1]] = kFALSE;
-      xl[0] = xl[1] = xl[2] = 0.0;
-      gMC->Gdtom(xl,xt,1);
-      for(i=0;i<9;i++) mat[i] = 0.0;
-      mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
-      xl[0] = 1.0;
-      xl[1] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[0]),2);
-      xl[1] = 1.0;
-      xl[0] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[3]),2);
-      xl[2] = 1.0;
-      xl[1] = xl[0] =0.0;
-      gMC->Gdtom(xl,&(mat[6]),2);
-
-      angl[0] = TMath::ACos(mat[2]);
-      if(mat[2]==1.0) angl[0] = 0.0;
-      angl[1] = TMath::ATan2(mat[1],mat[0]);
-      if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
-
-      angl[2] = TMath::ACos(mat[5]);
-      if(mat[5]==1.0) angl[2] = 0.0;
-      angl[3] = TMath::ATan2(mat[4],mat[3]);
-      if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
-
-      angl[4] = TMath::ACos(mat[8]);
-      if(mat[8]==1.0) angl[4] = 0.0;
-      angl[5] = TMath::ATan2(mat[7],mat[6]);
-      if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
-
-      for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
-      fp = fopen("ITSgeometry_v5.det","a");
-      fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
-             vol[0],vol[2],vol[1], // layer ladder detector
-             xt[0],xt[1],xt[2],    // Translation vector
-             angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
-                                                           // angles (degrees)
-             );
-      fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
-            mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
-         );  // Adding the rotation matrix.
-      fprintf(fp,"\n");
-      fclose(fp);
-  } // end if printit[layer][ladder][detector]
-#endif
   return;
 }
index 0b8d4b94c40eaa097544b53202fee1b3b4e6c2d3..8a18c67e1af15c464285be6462f86f09ec9c5311 100644 (file)
@@ -25,11 +25,61 @@ class AliITSv5asymm : public AliITS {
     virtual void  CreateGeometry();
     virtual void  CreateMaterials();
     virtual void  Init();   
-    virtual Int_t IsVersion() const {
-      // returns the ITS version number
-      return 5;
-    }
+    virtual Int_t IsVersion() const { // returns the ITS version number
+       return 5;}
     virtual void  StepManager();
+    void ReadOldGeometry(const char *filename);
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadOldDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomOldDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 3;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else if(v==3) fMinorVersion = 3;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =3");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual Bool_t GetReadDetOld() { // returns value GeomDetIn flag.
+                                return fGeomOldDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Bool_t fGeomOldDetIn;     // Flag to read old .det file.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
 
     ClassDef(AliITSv5asymm,1)//Hits manager for ITS version 5 Official detailed 
index 43bc7050fbce037eecf76cda19e6ca8914400519..ebc2fb299611f1455ea75476ec54e1ac59e75c85 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.4  2001/02/02 23:57:29  nilsen
+Added include file that are no londer included in AliITSgeom.h
+
 Revision 1.3  2001/01/30 09:23:13  hristov
 Streamers removed (R.Brun)
 
@@ -70,10 +73,6 @@ Introduction of the Copyright and cvs Log
 // Created October 7 2000.
 //
 ///////////////////////////////////////////////////////////////////////////////
-
-// See AliITSv5symm::StepManager().
-#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
-//#define ALIITSPRINTGEOM 1 // print out geometry information
 #include <iostream.h>
 #include <iomanip.h>
 #include <stdio.h>
@@ -93,13 +92,15 @@ Introduction of the Copyright and cvs Log
 
 #include "AliMC.h"
 #include "AliRun.h"
-#if ALIITSPRINTGEOM==1
 #include "../TGeant3/TGeant3.h"
-#endif
 #include "AliITShit.h"
+#include "AliITSGeant3Geometry.h"
 #include "AliITS.h"
 #include "AliITSv5symm.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 ClassImp(AliITSv5symm)
  
@@ -108,12 +109,52 @@ AliITSv5symm::AliITSv5symm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard default constructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
     fIdN    = 0;
     fIdName = 0;
     fIdSens = 0;
-    fMajorVersion = 5;
-    fMinorVersion = -1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kFALSE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 2;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
+}
+//_____________________________________________________________________________
+AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
+/////////////////////////////////////////////////////////////////////////////
+//    Standard constructor for the ITS version 5 with symmetrical services.
+/////////////////////////////////////////////////////////////////////////////
+    Int_t i;
+
+    fIdN    = 6;
+    fIdName    = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (i=0;i<fIdN;i++) fIdSens[i] = 0;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kFALSE; // Read .det file
+    fGeomOldDetIn = kTRUE;  // Read old formatted .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = 2;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+
+    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
+    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_v5symm.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 }
 //____________________________________________________________________________
 AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
@@ -121,17 +162,17 @@ AliITSv5symm::AliITSv5symm(const AliITSv5symm &source){
 //     Copy Constructor for ITS version 5.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSv5symm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSv5symm");
     return;
 }
 //_____________________________________________________________________________
 AliITSv5symm& AliITSv5symm::operator=(const AliITSv5symm &source){
 ////////////////////////////////////////////////////////////////////////
-//    Assignment operator for the ITS version 1.
+//    Assignment operator for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
 
     if(&source == this) return *this;
-    printf("Not allowed to copy AliITSv3\n");
+    Warning("= operator","Not allowed to copy AliITSv5symm");
     return *this;
 
 }
@@ -140,38 +181,9 @@ AliITSv5symm::~AliITSv5symm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard destructor for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
-}
-//_____________________________________________________________________________
-AliITSv5symm::AliITSv5symm(const char *name, const char *title) : AliITS(name, title){
-/////////////////////////////////////////////////////////////////////////////
-//    Standard constructor for the ITS version 5 with symmetrical services.
-/////////////////////////////////////////////////////////////////////////////
-    fIdN    = 6;
-/*
-//  TObjArray of TObjStrings
-    fIdName = new TObjArray(fIdN);
-    fIdName->AddAt(new TObjString("ITS1"),0);
-    fIdName->AddAt(new TObjString("ITS2"),1);
-    fIdName->AddAt(new TObjString("ITS3"),2);
-    fIdName->AddAt(new TObjString("ITS4"),3);
-    fIdName->AddAt(new TObjString("ITS5"),4);
-    fIdName->AddAt(new TObjString("ITS6"),5);
-*/
-//  Array of TStrings.
-    fIdName    = new TString[fIdN];
-    fIdName[0] = "ITS1";
-    fIdName[1] = "ITS2";
-    fIdName[2] = "ITS3";
-    fIdName[3] = "ITS4";
-    fIdName[4] = "ITS5";
-    fIdName[5] = "ITS6";
-    fIdSens    = new Int_t[fIdN];
-    for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
-    fMajorVersion = 5;
-    fMinorVersion = 1;
-
-    fEuclidMaterial = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.tme";
-    fEuclidGeometry = "$ALICE_ROOT/Euclid/ITSgeometry_5symm.euc";
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
 //_____________________________________________________________________________
 void AliITSv5symm::BuildGeometry(){
@@ -542,8 +554,6 @@ void AliITSv5symm::CreateGeometry(){
 //
 //    Read a file containing the geometry for the ITS version 5.
 ////////////////////////////////////////////////////////////////////////
-
-    Int_t size;
     char topvol[5];
     char *filtmp;
 
@@ -571,38 +581,173 @@ void AliITSv5symm::CreateGeometry(){
     if (fEuclidOut) {
       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
     } // end if (fEuclidOut)
-
+    cout << "finished with euclid geometrys" << endl;
+}
+//______________________________________________________________________
+void AliITSv5symm::ReadOldGeometry(const char *filename){
     // read in the file containing the transformations for the active
     // volumes for the ITS version 5. This is expected to be in a file
     // ending in .det. This geometry is kept in the AliITSgeom class.
-    filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
+    Int_t size;
+    char *filtmp;
+    FILE *file;
+
+    filtmp = gSystem->ExpandPathName(filename);
     size = strlen(filtmp);
-    if(size>4){
-       filtmp[size-3] = 'd'; // change from .euc to .det
+    if(size>4 && fGeomDetIn){
+        filtmp[size-3] = 'd'; // change from .euc to .det
         filtmp[size-2] = 'e';
         filtmp[size-1] = 't';
-       file = fopen(filtmp,"r");
-       if(file){ // if file exists use it to fill AliITSgeom structure.
-           fclose(file);
-           printf("ready to read .det file %s\n",filtmp);
-           fITSgeom = new AliITSgeom(filtmp);
-       }else{
-           fITSgeom = 0;
-           // fill AliITSgeom structure from geant structure just filled above
-       }// end if(file)
+        file = fopen(filtmp,"r");
+        if(file){ // if file exists use it to fill AliITSgeom structure.
+            fclose(file);
+            fITSgeom = new AliITSgeom(filtmp);
+            fITSgeom->DefineShapes(3); // if fShape isn't defined define it.
+            // Now define the detector types/shapes.
+            fITSgeom->ReSetShape(kSPD,(TObject *) new AliITSgeomSPD300());
+            fITSgeom->ReSetShape(kSDD,(TObject *) new AliITSgeomSDD300());
+            fITSgeom->ReSetShape(kSSD,(TObject *) new AliITSgeomSSD());
+        }else{
+            fITSgeom = 0;
+            // fill AliITSgeom structure from geant structure just filled above
+        }// end if(file)
         delete [] filtmp;
     }// end if(size>4)
-    printf("finished with euclid geometrys\n");
+}
+//______________________________________________________________________
+void AliITSv5symm::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 7;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+        {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
+        {"ALIC","ITSV","ITSD","IT12","I132","I131","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 itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2,4}, // lay=1
+                                              {1,1,1,1,10, 4,4}, // lay=2
+                                              {1,1,1,1,14, 6,1}, // lay=3
+                                              {1,1,1,1,22, 8,1}, // lay=4
+                                              {1,1,1,1,34,23,1}, // lay=5
+                                              {1,1,1,1,38,26,1}};// lay=6
+
+    // 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.
+    cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
+
+    if(fITSgeom!=0) delete fITSgeom;
+    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;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                           if(fMinorVersion==1){
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD300());
+                           } else if(fMinorVersion==2)
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD300());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD300());
+                           break;
+                   case 5: case 6:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                               fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD175());
+                           break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
 }
 //_____________________________________________________________________________
 void AliITSv5symm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
+    cout << endl;
+    for(i=0;i<30;i++) cout << "*";cout << " ITSv5_Init ";
+    for(i=0;i<30;i++) cout << "*";cout << endl;
+//
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn && !fGeomOldDetIn) fITSgeom->ReadNewFile(fRead);
+    if(fGeomDetIn &&  fGeomOldDetIn) this->ReadOldGeometry(fRead);
+
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-    fMajorVersion = 5;
-    fMinorVersion = 0;
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
 } 
 //_____________________________________________________________________________
 void AliITSv5symm::StepManager(){
@@ -621,19 +766,6 @@ void AliITSv5symm::StepManager(){
   Int_t          vol[4];
   TLorentzVector position, momentum;
   TClonesArray   &lhits = *fHits;
-#if ALIITSPRINTGEOM==1
-  FILE          *fp;
-  Int_t         i;
-  Float_t       xl[3],xt[3],angl[6];
-//  Float_t       par[20],att[20];
-  Float_t      mat[9];
-  static Bool_t first=kTRUE,printit[6][50][50];
-  if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
-      for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
-  first = kFALSE;
-  }
-  // end if first
-#endif
   //
   // Track status
   vol[3] = 0;
@@ -717,52 +849,5 @@ void AliITSv5symm::StepManager(){
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
-#if ALIITSPRINTGEOM==1
-  if(printit[vol[0]][vol[2]][vol[1]]){
-      printit[vol[0]][vol[2]][vol[1]] = kFALSE;
-      xl[0] = xl[1] = xl[2] = 0.0;
-      gMC->Gdtom(xl,xt,1);
-      for(i=0;i<9;i++) mat[i] = 0.0;
-      mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
-      xl[0] = 1.0;
-      xl[1] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[0]),2);
-      xl[1] = 1.0;
-      xl[0] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[3]),2);
-      xl[2] = 1.0;
-      xl[1] = xl[0] =0.0;
-      gMC->Gdtom(xl,&(mat[6]),2);
-
-      angl[0] = TMath::ACos(mat[2]);
-      if(mat[2]==1.0) angl[0] = 0.0;
-      angl[1] = TMath::ATan2(mat[1],mat[0]);
-      if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
-
-      angl[2] = TMath::ACos(mat[5]);
-      if(mat[5]==1.0) angl[2] = 0.0;
-      angl[3] = TMath::ATan2(mat[4],mat[3]);
-      if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
-
-      angl[4] = TMath::ACos(mat[8]);
-      if(mat[8]==1.0) angl[4] = 0.0;
-      angl[5] = TMath::ATan2(mat[7],mat[6]);
-      if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
-
-      for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
-      fp = fopen("ITSgeometry_v5.det","a");
-      fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
-             vol[0],vol[2],vol[1], // layer ladder detector
-             xt[0],xt[1],xt[2],    // Translation vector
-             angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
-                                                           // angles (degrees)
-             );
-      fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
-            mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
-         );  // Adding the rotation matrix.
-      fprintf(fp,"\n");
-      fclose(fp);
-  } // end if printit[layer][ladder][detector]
-#endif
   return;
 }
index 5434b8b2f50293a74bf934398001b27196e32046..4b13f9877dd4798324d82fb18a5efaf0d805443d 100644 (file)
@@ -25,11 +25,61 @@ class AliITSv5symm : public AliITS {
     virtual void  CreateGeometry();
     virtual void  CreateMaterials();
     virtual void  Init();   
-    virtual Int_t IsVersion() const {
-      // returns the ITS version number
-      return 5;
-    }
+    virtual Int_t IsVersion() const {// returns the ITS version number
+       return 5;}
     virtual void  StepManager();
+    void ReadOldGeometry(const char *filename);
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadOldDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomOldDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 2;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else if(v==3) fMinorVersion = 3;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =2");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual Bool_t GetReadDetOld() { // returns value GeomDetIn flag.
+                                return fGeomOldDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Bool_t fGeomOldDetIn;     // Flag to read old .det file.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
 
     ClassDef(AliITSv5symm,1)//Hits manager for ITS version 5 Official detailed 
index 96bd52d79f5eb9f3a54602d6f27077cf0675a521..87a14d575620ce426d146e72d96fd7fe5bcff55f 100644 (file)
 
 /*
 $Log$
+
+Revision 1.9  2001/02/08 16:00:37  barbera
+New thicknesses (300+300 um) added for SPD chips and detectors and set as default. Many other refinements.
+
 Revision 1.8  2001/02/06 08:03:44  barbera
 Material redefinition in SDD
 
@@ -33,94 +37,24 @@ Some media parameters modified
 Revision 1.1.2.1  2001/01/15 13:38:08  barbera
 New ITS detailed geometry to be used for the PPR
 
-Revision 1.13  2000/12/10 16:00:45  barbera
-Added last definition of special media like end-ladder boxes and cones
-
-Revision 1.12  2000/11/02 15:44:23  barbera
-Services on the opposite side w.r.t the absorber modified to make room for rails
-
-Revision 1.10  2000/10/27 17:19:50  barbera
-Position of rails w.r.t. the interaction point corrected.
-
-Revision 1.9  2000/10/27 13:31:29  barbera
-Rails between ITS and TPC added.
-
-Revision 1.8  2000/10/27 13:03:08  barbera
-Small changes in the SPD volumes and materials
-
-Revision 1.6  2000/10/16 14:45:37  barbera
-Mother volume ITSD modified to avoid some overlaps
-
-Revision 1.5  2000/10/16 13:49:15  barbera
-Services volumes slightly modified and material added following Pierluigi Barberis' information
-
-Revision 1.4  2000/10/07 15:33:07  barbera
-Small corrections to the ITSV mother volume
-
-Revision 1.3  2000/10/07 13:06:50  barbera
-Some new materials and media defined
-
-Revision 1.2  2000/10/07 10:58:15  barbera
-Mother volume ITSV corrected
-
-Revision 1.1  2000/10/06 23:09:24  barbera
-New  geometry (asymmetric services
-
-Revision 1.20  2000/10/02 21:28:08  fca
-Removal of useless dependecies via forward declarations
-
-Revision 1.19  2000/07/10 16:07:19  fca
-Release version of ITS code
-
-Revision 1.14.2.2  2000/05/19 10:09:21  nilsen
-fix for bug with HP and Sun unix + fix for event display in ITS-working branch
-
-Revision 1.14.2.1  2000/03/04 23:45:19  nilsen
-Fixed up the comments/documentation.
-
-Revision 1.14  1999/11/25 06:52:56  fca
-Correct value of drca
-
-Revision 1.13.2.1  1999/11/25 06:52:21  fca
-Correct value of drca
-
-Revision 1.13  1999/10/27 11:16:26  fca
-Correction of problem in geometry
-
-Revision 1.12  1999/10/22 08:25:25  fca
-remove double definition of destructors
-
-Revision 1.11  1999/10/22 08:16:49  fca
-Correct destructors, thanks to I.Hrivnacova
-
-Revision 1.10  1999/10/06 19:56:50  fca
-Add destructor
-
-Revision 1.9  1999/10/05 08:05:09  fca
-Minor corrections for uninitialised variables.
-
-Revision 1.8  1999/09/29 09:24:20  fca
-Introduction of the Copyright and cvs Log
-
 */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
-//  Inner Traking System version PPR  asymmetric                                         //
+//  Inner Traking System version PPR  asymmetric                             //
 //  This class contains the base procedures for the Inner Tracking System    //
 //                                                                           //
-// Authors: R. Barbera
-// version 6.
-// Created  2000.
-//
-//  NOTE: THIS IS THE  ASYMMETRIC PPR geometry of the ITS. 
+// Authors: R. Barbera                                                       //
+// version 8.                                                                //
+// Created  January 15 2001.                                                 //
+//                                                                           //
+//  NOTE: THIS IS THE  ASYMMETRIC PPR geometry of the ITS.                   //
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
 // See AliITSvPPRasymm::StepManager().
-#define ALIITSPRINTGEOM 0 // default. don't print out gemetry information
-//#define ALIITSPRINTGEOM 1 // print out geometry information 
-
+#include <iostream.h>
+#include <iomanip.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <TMath.h>
@@ -140,13 +74,15 @@ Introduction of the Copyright and cvs Log
 #include "AliRun.h"
 #include "AliMagF.h"
 #include "AliConst.h"
-#if ALIITSPRINTGEOM==1
 #include "../TGeant3/TGeant3.h"
-#endif
+#include "AliITSGeant3Geometry.h"
 #include "AliITShit.h"
 #include "AliITS.h"
 #include "AliITSvPPRasymm.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 
 ClassImp(AliITSvPPRasymm)
@@ -156,61 +92,75 @@ AliITSvPPRasymm::AliITSvPPRasymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard default constructor for the ITS version 8.
 ////////////////////////////////////////////////////////////////////////
-
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
+    Int_t i;
+
+    fIdN          = 0;
+    fIdName       = 0;
+    fIdSens       = 0;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = -1;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //_____________________________________________________________________________
 AliITSvPPRasymm::AliITSvPPRasymm(const char *name, const char *title) : AliITS(name, title){
 ////////////////////////////////////////////////////////////////////////
 //    Standard constructor for the ITS version 8.
 ////////////////////////////////////////////////////////////////////////
-
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
-
+    Int_t i;
+
+    fIdN = 6;
+    fIdName = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for(i=0;i<fIdN;i++) fIdSens[i] = 0;
+    fMajorVersion = IsVersion();
+    fMinorVersion = 21;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+
+    fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_PPRasymm21.euc";
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPRasymm21.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 }
 //____________________________________________________________________________
 AliITSvPPRasymm::AliITSvPPRasymm(const AliITSvPPRasymm &source){
 ////////////////////////////////////////////////////////////////////////
-//     Copy Constructor for ITS version 6.
+//     Copy Constructor for ITS version 8.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSvPPRasymm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSvPPRasymm");
     return;
 }
 //_____________________________________________________________________________
 AliITSvPPRasymm& AliITSvPPRasymm::operator=(const AliITSvPPRasymm &source){
 ////////////////////////////////////////////////////////////////////////
-//    Assignment operator for the ITS version 6.
+//    Assignment operator for the ITS version 8.
 ////////////////////////////////////////////////////////////////////////
-  if(&source == this) return *this;
-    printf("Not allowed to copy AliITSvPPRasymm\n");
-  return *this;
+    if(&source == this) return *this;
+    Warning("= operator","Not allowed to copy AliITSvPPRasymm");
+    return *this;
 }
 //_____________________________________________________________________________
 AliITSvPPRasymm::~AliITSvPPRasymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard destructor for the ITS version 8.
 ////////////////////////////////////////////////////////////////////////
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
-
 //__________________________________________________________________________
 void AliITSvPPRasymm::BuildGeometry(){
 ////////////////////////////////////////////////////////////////////////
@@ -259,9 +209,6 @@ void AliITSvPPRasymm::BuildGeometry(){
 }
 //_____________________________________________________________________________
 void AliITSvPPRasymm::CreateGeometry(){
-
-
-
 ////////////////////////////////////////////////////////////////////////
 //    This routine defines and Creates the geometry for version 6 of the ITS.
 ////////////////////////////////////////////////////////////////////////
@@ -288,15 +235,16 @@ void AliITSvPPRasymm::CreateGeometry(){
 
   // Default values
   
-  Int_t thickness=2;  // detector thickness = 300 um - chip thickness = 300 um
-//  Int_t option=2;     // option 'b' for det/chip/bus stacking
-  
+//  Int_t thickness=2; // detector thickness = 300 um - chip thickness = 300 um
+//  Int_t option=2;    // option 'b' for det/chip/bus stacking
 
   // These values are NOT the default ones so leave them commented !
 
-//  Int_t thickness=1;  // detector thickness = 100 um - chip thickness = 150 um
-  Int_t option=1;     // option 'a' for det/chip/bus stacking
+//  Int_t thickness=1; // detector thickness = 100 um - chip thickness = 150 um
+//  Int_t option=1;    // option 'a' for det/chip/bus stacking
 
+  Int_t thickness = fMinorVersion/10;
+  Int_t option    = fMinorVersion - 10*thickness;
   
   Int_t *idtmed = fIdtmed->GetArray()-199;
 
@@ -305,6 +253,7 @@ void AliITSvPPRasymm::CreateGeometry(){
   
   // SPD - option 'a' (this is NOT the default so leave commented)
   
+  
   if (option == 1) {
   
      AliMatrix(idrotm[201],90.0,90.0,90.0,180.0,0.0,0.0);
@@ -4892,8 +4841,8 @@ void AliITSvPPRasymm::CreateGeometry(){
   dgh[2] = 0.6;    
   gMC->Gsvolu("ICYL", "TUBE", idtmed[210], dgh, 3);   
   gMC->Gspos("ICYL", 1, "ALIC", 0., 0., 74., 0, "ONLY");
-  gMC->Gspos("ICYL", 2, "ALIC", 0., 0., -74., idrotm[200], "ONLY");     
-  
+  gMC->Gspos("ICYL", 2, "ALIC", 0., 0., -74., idrotm[200], "ONLY");
+
   // --- Outputs the geometry tree in the EUCLID/CAD format 
   
   if (fEuclidOut) {
@@ -5061,19 +5010,148 @@ void AliITSvPPRasymm::CreateMaterials(){
   AliMedium(96, "SSD cone$",   96, 0,isxfld,sxmgmx, 10., .01, .1, .003, .003);
 
 }
+//______________________________________________________________________
+void AliITSvPPRasymm::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 7;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+     {"ALIC","ITSV","ITSD","IT12","I132","I131","ITS1"}, // lay=1
+     {"ALIC","ITSV","ITSD","IT12","I132","I186","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 itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4},// lay=1
+                                             {1,1,1,1,10, 4, 4},// lay=2
+                                             {1,1,1,1,14, 6, 1},// lay=3
+                                             {1,1,1,1,22, 8, 1},// lay=4
+                                             {1,1,1,1,34,22, 1},// lay=5
+                                             {1,1,1,1,38,25, 1}};//lay=6
+
+    // 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.
+    cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
+
+    if(fITSgeom!=0) delete fITSgeom;
+    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;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                           if(fMinorVersion==21){
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                           } else if(fMinorVersion==22)
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
+                           break;
+                       case 5:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                               fITSgeom->ReSetShape(kSSD,
+                                                  new AliITSgeomSSD275and75());
+                           break;
+                       case 6:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSDp,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSDp))) 
+                               fITSgeom->ReSetShape(kSSDp,
+                                                  new AliITSgeomSSD75and275());
+                           break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
+}
 //_____________________________________________________________________________
 void AliITSvPPRasymm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
-    //
+    cout << endl;
+    for(i=0;i<26;i++) cout << "*";
+    cout << " ITSvPPRasymm" << fMinorVersion << "_Init ";
+    for(i=0;i<25;i++) cout << "*";cout << endl;
+//
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-    fMajorVersion = 1;
-    fMinorVersion = 0;
-}  
-//_____________________________________________________________________________
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
+}
+//______________________________________________________________________
 void AliITSvPPRasymm::DrawModule(){
 ////////////////////////////////////////////////////////////////////////
 //     Draw a shaded view of the FMD version 8.
@@ -5139,19 +5217,6 @@ void AliITSvPPRasymm::StepManager(){
   Int_t         vol[4];
   TLorentzVector position, momentum;
   TClonesArray &lhits = *fHits;
-#if ALIITSPRINTGEOM==1
-  FILE          *fp;
-  Int_t         i;
-  Float_t       xl[3],xt[3],angl[6];
-//  Float_t       par[20],att[20];
-  Float_t      mat[9];
-  static Bool_t first=kTRUE,printit[6][50][50];
-  if(first){ for(copy1=0;copy1<6;copy1++)for(copy2=0;copy2<50;copy2++)
-      for(id=0;id<50;id++) printit[copy1][copy2][id] = kTRUE;
-  first = kFALSE;
-  }
-  // end if first
-#endif
   //
   // Track status
   vol[3] = 0;
@@ -5235,54 +5300,7 @@ void AliITSvPPRasymm::StepManager(){
   hits[7]=gMC->TrackTime();
   // Fill hit structure with this new hit.
   new(lhits[fNhits++]) AliITShit(fIshunt,gAlice->CurrentTrack(),vol,hits);
-#if ALIITSPRINTGEOM==1
-  if(printit[vol[0]][vol[2]][vol[1]]){
-      printit[vol[0]][vol[2]][vol[1]] = kFALSE;
-      xl[0] = xl[1] = xl[2] = 0.0;
-      gMC->Gdtom(xl,xt,1);
-      for(i=0;i<9;i++) mat[i] = 0.0;
-      mat[0] = mat[4] = mat[8] = 1.0;  // default with identity matrix
-      xl[0] = 1.0;
-      xl[1] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[0]),2);
-      xl[1] = 1.0;
-      xl[0] = xl[2] =0.0;
-      gMC->Gdtom(xl,&(mat[3]),2);
-      xl[2] = 1.0;
-      xl[1] = xl[0] =0.0;
-      gMC->Gdtom(xl,&(mat[6]),2);
-
-      angl[0] = TMath::ACos(mat[2]);
-      if(mat[2]==1.0) angl[0] = 0.0;
-      angl[1] = TMath::ATan2(mat[1],mat[0]);
-      if(angl[1]<0.0) angl[1] += 2.0*TMath::Pi();
-
-      angl[2] = TMath::ACos(mat[5]);
-      if(mat[5]==1.0) angl[2] = 0.0;
-      angl[3] = TMath::ATan2(mat[4],mat[3]);
-      if(angl[3]<0.0) angl[3] += 2.0*TMath::Pi();
-
-      angl[4] = TMath::ACos(mat[8]);
-      if(mat[8]==1.0) angl[4] = 0.0;
-      angl[5] = TMath::ATan2(mat[7],mat[6]);
-      if(angl[5]<0.0) angl[5] += 2.0*TMath::Pi();
-
-      for(i=0;i<6;i++) angl[i] *= 180.0/TMath::Pi(); // degrees
-      fp = fopen("ITSgeometry_v5.det","a");
-      fprintf(fp,"%2d %2d %2d %9e %9e %9e %9e %9e %9e %9e %9e %9e ",
-             vol[0],vol[2],vol[1], // layer ladder detector
-             xt[0],xt[1],xt[2],    // Translation vector
-             angl[0],angl[1],angl[2],angl[3],angl[4],angl[5] // Geant rotaion
-                                                           // angles (degrees)
-             );
-      fprintf(fp,"%9e %9e %9e %9e %9e %9e %9e %9e %9e",
-            mat[0],mat[1],mat[2],mat[3],mat[4],mat[5],mat[6],mat[7],mat[8]
-         );  // Adding the rotation matrix.
-      fprintf(fp,"\n");
-      fclose(fp);
-  } // end if printit[layer][ladder][detector]
-#endif
+
   return;
 
 }
-
index 328c1049813cd7a26515e30967fcc78eab94c927..25c760be7deb648d6dcd40b4de4b5c859cdd0b9d 100644 (file)
@@ -23,12 +23,55 @@ class AliITSvPPRasymm : public AliITS {
     virtual void   CreateGeometry();
     virtual void   CreateMaterials();
     virtual void   Init(); 
-    virtual Int_t  IsVersion() const {
-      // returns the ITS version number 
-      return 8;
-    } 
+    virtual Int_t  IsVersion() const {// returns the ITS version number 
+                                      return 8;} 
     virtual void   DrawModule();
     virtual void   StepManager();
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
     ClassDef(AliITSvPPRasymm,1)  //Hits manager for set:ITS version 8 
                                  // PPR detailed Geometry asymmetric
index 45a22a4faf2f7e4fd8c335ca8f4ddb79494ac455..3b6f9b46a613e38c030d8c29ea73293234b0459e 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.16  2001/01/30 09:23:13  hristov
+Streamers removed (R.Brun)
+
 Revision 1.15  2001/01/17 07:41:29  barbera
 Some media parameters modified
 
@@ -107,7 +110,7 @@ Introduction of the Copyright and cvs Log
 // strongly encouraged to uses AliITSv5.
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
+#include <iostream.h> 
 #include <TMath.h>
 #include <TRandom.h>
 #include <TVector.h>
@@ -137,16 +140,11 @@ AliITSvPPRcoarseasymm::AliITSvPPRcoarseasymm() {
 //    Standard default constructor for the ITS version 6.
 ////////////////////////////////////////////////////////////////////////
 
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
+    fIdN = 0;
+    fIdName = 0;
+    fIdSens    = 0;
+    fMajorVersion = 9;
+    fMinorVersion = 0;
 }
 //_____________________________________________________________________________
 AliITSvPPRcoarseasymm::AliITSvPPRcoarseasymm(const char *name, const char *title) : AliITS(name, title){
@@ -154,17 +152,18 @@ AliITSvPPRcoarseasymm::AliITSvPPRcoarseasymm(const char *name, const char *title
 //    Standard constructor for the ITS version 6.
 ////////////////////////////////////////////////////////////////////////
 
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
-
+    fIdN = 6;
+    fIdName = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (Int_t i=0;i<fIdN;i++) fIdSens[i]=0;
+    fMajorVersion = 9;
+    fMinorVersion = 0;
 }
 //____________________________________________________________________________
 AliITSvPPRcoarseasymm::AliITSvPPRcoarseasymm(const AliITSvPPRcoarseasymm &source){
@@ -172,7 +171,7 @@ AliITSvPPRcoarseasymm::AliITSvPPRcoarseasymm(const AliITSvPPRcoarseasymm &source
 //     Copy Constructor for ITS version 6.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSvPPRcoarseasymm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSvPPRcoarseasymm");
     return;
 }
 //_____________________________________________________________________________
@@ -181,7 +180,7 @@ AliITSvPPRcoarseasymm& AliITSvPPRcoarseasymm::operator=(const AliITSvPPRcoarseas
 //    Assignment operator for the ITS version 6.
 ////////////////////////////////////////////////////////////////////////
   if(&source == this) return *this;
-    printf("Not allowed to copy AliITSvPPRcoarseasymm\n");
+    Warning("= operator","Not allowed to copy AliITSvPPRcoarseasymm");
   return *this;
 }
 //_____________________________________________________________________________
@@ -961,11 +960,16 @@ void AliITSvPPRcoarseasymm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
-    //
+    cout << endl;
+    for(i=0;i<24;i++) cout << "*";cout << " ITSvPPRcoarseasymm_Init ";
+    for(i=0;i<25;i++) cout << "*";cout << endl;
+//
     AliITS::Init();
-    fMajorVersion = 1;
-    fMinorVersion = 0;
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
 }  
  
 //_____________________________________________________________________________
index 12e69a08569a838b381f1b2fa5a64aee3b858b1c..e001e50a7049d569a0ff683620105f7eb1d66c82 100644 (file)
@@ -23,12 +23,19 @@ class AliITSvPPRcoarseasymm : public AliITS {
     virtual void   CreateGeometry();
     virtual void   CreateMaterials();
     virtual void   Init(); 
-    virtual Int_t  IsVersion() const {
-      // returns the ITS version number 
-      return 6;
-    } 
+    virtual Int_t  IsVersion() const {// returns the ITS version number 
+       return 6;}
     virtual void   DrawModule();
     virtual void   StepManager();
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+
+ private:
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
 
     ClassDef(AliITSvPPRcoarseasymm,1)  //Hits manager for set:ITS version 6 
                                        // PPR coarse Geometry asymmetric
index 3a267a8ffa780d1fe89c5af9a7e4c4ebbe1da5a0..ec4a36ffe68018b98378115048b60de6da3a9ea0 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.15  2001/01/30 09:23:13  hristov
+Streamers removed (R.Brun)
+
 Revision 1.14  2001/01/17 07:41:29  barbera
 Some media parameters modified
 
@@ -107,7 +110,7 @@ Introduction of the Copyright and cvs Log
 // strongly encouraged to uses AliITSv5.
 //                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
+#include <iostream.h> 
 #include <TMath.h>
 #include <TRandom.h>
 #include <TVector.h>
@@ -137,16 +140,11 @@ AliITSvPPRcoarsesymm::AliITSvPPRcoarsesymm() {
 //    Standard default constructor for the ITS version 7.
 ////////////////////////////////////////////////////////////////////////
 
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
+    fIdN = 0;
+    fIdName = 0;
+    fIdSens    = 0;
+    fMajorVersion = 8;
+    fMinorVersion = 0;
 }
 //_____________________________________________________________________________
 AliITSvPPRcoarsesymm::AliITSvPPRcoarsesymm(const char *name, const char *title) : AliITS(name, title){
@@ -154,17 +152,18 @@ AliITSvPPRcoarsesymm::AliITSvPPRcoarsesymm(const char *name, const char *title)
 //    Standard constructor for the ITS version 7.
 ////////////////////////////////////////////////////////////////////////
 
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
-
+    fIdN = 6;
+    fIdName = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (Int_t i=0;i<fIdN;i++) fIdSens[i]=0;
+    fMajorVersion = 9;
+    fMinorVersion = 0;
 }
 //____________________________________________________________________________
 AliITSvPPRcoarsesymm::AliITSvPPRcoarsesymm(const AliITSvPPRcoarsesymm &source){
@@ -172,7 +171,7 @@ AliITSvPPRcoarsesymm::AliITSvPPRcoarsesymm(const AliITSvPPRcoarsesymm &source){
 //     Copy Constructor for ITS version 7.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSvPPRcoarsesymm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSvPPRcoarsesymm");
     return;
 }
 //_____________________________________________________________________________
@@ -181,7 +180,7 @@ AliITSvPPRcoarsesymm& AliITSvPPRcoarsesymm::operator=(const AliITSvPPRcoarsesymm
 //    Assignment operator for the ITS version 7.
 ////////////////////////////////////////////////////////////////////////
   if(&source == this) return *this;
-    printf("Not allowed to copy AliITSvPPRcoarsesymm\n");
+    Warning("= operator","Not allowed to copy AliITSvPPRcoarsesymm");
   return *this;
 }
 //_____________________________________________________________________________
@@ -899,11 +898,17 @@ void AliITSvPPRcoarsesymm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
-    //
+    cout << endl;
+    for(i=0;i<25;i++) cout << "*";cout << " ITSvPPRcoarsesymm_Init ";
+    for(i=0;i<25;i++) cout << "*";cout << endl;
+//
     AliITS::Init();
-    fMajorVersion = 1;
-    fMinorVersion = 0;
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
+
 }  
  
 //_____________________________________________________________________________
index b180e9f89a01621bd941b77f4475a2d7a5f67070..b2c53c141cc3d9f05af9c106aa2aed74fc9f5e5f 100644 (file)
@@ -29,6 +29,15 @@ class AliITSvPPRcoarsesymm : public AliITS {
     } 
     virtual void   DrawModule();
     virtual void   StepManager();
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+
+ private:
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
 
     ClassDef(AliITSvPPRcoarsesymm,1)  //Hits manager for set:ITS version 7 
                                        // PPR coarse Geometry symmetric
index 6af1ab6030908545e0bfde623110b39bfb4eb906..efba031872478a935ce4f660beb43431a495bece 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.3  2001/01/30 09:23:13  hristov
+Streamers removed (R.Brun)
+
 Revision 1.2  2001/01/26 20:01:19  hristov
 Major upgrade of AliRoot code
 
@@ -92,22 +95,23 @@ Introduction of the Copyright and cvs Log
 
 */
 
-///////////////////////////////////////////////////////////////////////////////
-//                                                                           //
-//  Inner Traking System version PPR  symmetric                                         //
-//  This class contains the base procedures for the Inner Tracking System    //
-//                                                                           //
-// Authors: R. Barbera
-// version 6.
-// Created  2000.
-//
-//  NOTE: THIS IS THE  SYMMETRIC PPR geometry of the ITS. 
-// THIS WILL NOT WORK
-// with the geometry or module classes or any analysis classes. You are 
-// strongly encouraged to uses AliITSv5.
-//                                                                           //
-///////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
+//                                                                          //
+//  Inner Traking System version PPR  symmetric                             //
+//  This class contains the base procedures for the Inner Tracking System   //
+//                                                                          //
+// Authors: R. Barbera                                                      //
+// version 6.                                                               //
+// Created  2000.                                                           //
+//                                                                          //
+//  NOTE: THIS IS THE  SYMMETRIC PPR geometry of the ITS.                   //
+// THIS WILL NOT WORK                                                       //
+// with the geometry or module classes or any analysis classes. You are     //
+// strongly encouraged to uses AliITSv5.                                    //
+//                                                                          //
+//////////////////////////////////////////////////////////////////////////////
+#include <iostream.h>
+#include <iomanip.h>
 #include <TMath.h>
 #include <TRandom.h>
 #include <TVector.h>
@@ -124,9 +128,15 @@ Introduction of the Copyright and cvs Log
 #include "AliMagF.h"
 #include "AliConst.h"
 
+#include "../TGeant3/TGeant3.h"
+#include "AliITSGeant3Geometry.h"
 #include "AliITShit.h"
 #include "AliITSvPPRsymm.h"
 #include "AliRun.h"
+#include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 
 ClassImp(AliITSvPPRsymm)
@@ -136,34 +146,47 @@ AliITSvPPRsymm::AliITSvPPRsymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard default constructor for the ITS version 9.
 ////////////////////////////////////////////////////////////////////////
-
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
+    Int_t i;
+
+    fIdN       = 6;
+    fIdName    = 0;
+    fIdSens    = 0;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+    fMajorVersion = IsVersion();
+    fMinorVersion = -1;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //_____________________________________________________________________________
 AliITSvPPRsymm::AliITSvPPRsymm(const char *name, const char *title) : AliITS(name, title){
 ////////////////////////////////////////////////////////////////////////
 //    Standard constructor for the ITS version 9.
 ////////////////////////////////////////////////////////////////////////
-
-  fIdN = 6;
-  fIdName = new TString[fIdN];
-  fIdName[0] = "ITS1";
-  fIdName[1] = "ITS2";
-  fIdName[2] = "ITS3";
-  fIdName[3] = "ITS4";
-  fIdName[4] = "ITS5";
-  fIdName[5] = "ITS6";
-  fIdSens    = new Int_t[fIdN];
-  for (Int_t i=0;i<fIdN;i++) fIdSens[i]=fIdName[i].Length();
+    Int_t i;
+
+    fIdN = 6;
+    fIdName = new TString[fIdN];
+    fIdName[0] = "ITS1";
+    fIdName[1] = "ITS2";
+    fIdName[2] = "ITS3";
+    fIdName[3] = "ITS4";
+    fIdName[4] = "ITS5";
+    fIdName[5] = "ITS6";
+    fIdSens    = new Int_t[fIdN];
+    for (i=0;i<fIdN;i++) fIdSens[i] = 0;
+    fMajorVersion = IsVersion();
+    fMinorVersion = 1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+
+    fEuclidGeometry="$ALICE_ROOT/ITS/ITSgeometry_PPRsymm.euc";
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 
 }
 //____________________________________________________________________________
@@ -172,7 +195,7 @@ AliITSvPPRsymm::AliITSvPPRsymm(const AliITSvPPRsymm &source){
 //     Copy Constructor for ITS version 9.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSvPPRsymm\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSvPPRsymm");
     return;
 }
 //_____________________________________________________________________________
@@ -180,17 +203,19 @@ AliITSvPPRsymm& AliITSvPPRsymm::operator=(const AliITSvPPRsymm &source){
 ////////////////////////////////////////////////////////////////////////
 //    Assignment operator for the ITS version 7.
 ////////////////////////////////////////////////////////////////////////
-  if(&source == this) return *this;
-    printf("Not allowed to copy AliITSvPPRsymm\n");
-  return *this;
+    if(&source == this) return *this;
+    Warning("= operator","Not allowed to copy AliITSvPPRsymm");
+    return *this;
 }
 //_____________________________________________________________________________
 AliITSvPPRsymm::~AliITSvPPRsymm() {
 ////////////////////////////////////////////////////////////////////////
 //    Standard destructor for the ITS version 7.
 ////////////////////////////////////////////////////////////////////////
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
-
 //__________________________________________________________________________
 void AliITSvPPRsymm::BuildGeometry(){
 ////////////////////////////////////////////////////////////////////////
@@ -2598,18 +2623,144 @@ void AliITSvPPRsymm::CreateMaterials(){
   AliMedium(86, "GEN Al$",      86, 0,isxfld,sxmgmx, 10., .01, .1, .003, .003);
 
 }
+//______________________________________________________________________
+void AliITSvPPRsymm::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 7;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+     {"ALIC","ITSV","ITSD","IT12","I132","I186","ITS1"}, // lay=1
+     {"ALIC","ITSV","ITSD","IT12","I132","I131","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 itsGeomTreeCopys[nlayers][ndeep] = {{1,1,1,1,10, 2, 4},// lay=1
+                                             {1,1,1,1,10, 4, 4},// lay=2
+                                             {1,1,1,1,14, 6, 1},// lay=3
+                                             {1,1,1,1,22, 8, 1},// lay=4
+                                             {1,1,1,1,34,22, 1},// lay=5
+                                             {1,1,1,1,38,25, 1}};//lay=6
+
+    // 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.
+    cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
+
+    if(fITSgeom!=0) delete fITSgeom;
+    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]=23;ndet[5]=26;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                           if(fMinorVersion==1){
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                           } else if(fMinorVersion==2)
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
+                           break;
+                       case 5:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                               fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
+                           break;
+                       case 6:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSDp,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSDp))) 
+                               fITSgeom->ReSetShape(kSSDp,new AliITSgeomSSD75and275());
+                           break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
+}
 //_____________________________________________________________________________
 void AliITSvPPRsymm::Init(){
 ////////////////////////////////////////////////////////////////////////
 //     Initialise the ITS after it has been created.
 ////////////////////////////////////////////////////////////////////////
+    Int_t i;
 
-    //
+    cout << endl;
+    for(i=0;i<27;i++) cout << "*";cout << " ITSvPPRsymm_Init ";
+    for(i=0;i<27;i++) cout << "*";cout << endl;
+//
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-    fMajorVersion = 1;
-    fMinorVersion = 0;
-}  
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
+}
 //_____________________________________________________________________________
 void AliITSvPPRsymm::DrawModule(){
 ////////////////////////////////////////////////////////////////////////
index 739cbc7085836d87fa841b61151e5ce1f2800901..35597d8b1d2793cbfe2517de245fedae4dc78b29 100644 (file)
@@ -23,12 +23,55 @@ class AliITSvPPRsymm : public AliITS {
     virtual void   CreateGeometry();
     virtual void   CreateMaterials();
     virtual void   Init(); 
-    virtual Int_t  IsVersion() const {
-      // returns the ITS version number 
-      return 9;
-    } 
+    virtual Int_t  IsVersion() const {// returns the ITS version number 
+       return 9;} 
     virtual void   DrawModule();
     virtual void   StepManager();
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
 
     ClassDef(AliITSvPPRsymm,1)  //Hits manager for set:ITS version 9 
                                 // PPR detailed Geometry symmetric
index 96dda15aad2e4f1381d7f8d033f32fa837832e3a..e627c7ecade7e605a66873d607f8f42ffd7e4744 100644 (file)
@@ -15,6 +15,9 @@
 
 /*
 $Log$
+Revision 1.5  2001/01/30 09:23:14  hristov
+Streamers removed (R.Brun)
+
 Revision 1.4  2001/01/18 06:25:09  barbera
 ITS geometry using test Euclid files
 
@@ -74,23 +77,34 @@ $Id$
 
 #include "AliMC.h"
 #include "AliRun.h"
+#include "../TGeant3/TGeant3.h"
+#include "AliITSGeant3Geometry.h"
 #include "AliITShit.h"
 #include "AliITS.h"
 #include "AliITSvtest.h"
 #include "AliITSgeom.h"
+#include "AliITSgeomSPD.h"
+#include "AliITSgeomSDD.h"
+#include "AliITSgeomSSD.h"
 
 ClassImp(AliITSvtest)
  
 //_____________________________________________________________________________
 AliITSvtest::AliITSvtest() {
-    //
     // Standard constructor for the ITS
-    //
+    Int_t i;
+
     fIdN    = 0;
     fIdName = 0;
     fIdSens = 0;
-    fMajorVersion = -1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
+    fMajorVersion = IsVersion();
     fMinorVersion = -1;
+    for(i=0;i<60;i++) fRead[i] = '\0';
+    for(i=0;i<60;i++) fWrite[i] = '\0';
+    for(i=0;i<60;i++) fEuclidGeomDet[i] = '\0';
 }
 //____________________________________________________________________________
 AliITSvtest::AliITSvtest(const AliITSvtest &source){
@@ -98,7 +112,7 @@ AliITSvtest::AliITSvtest(const AliITSvtest &source){
 //     Copy Constructor for ITS test version.
 ////////////////////////////////////////////////////////////////////////
     if(&source == this) return;
-    printf("Not allowed to copy AliITSvtest\n");
+    Warning("Copy Constructor","Not allowed to copy AliITSvtest");
     return;
 }
 //_____________________________________________________________________________
@@ -107,14 +121,16 @@ AliITSvtest& AliITSvtest::operator=(const AliITSvtest &source){
 //    Assignment operator for the ITS version 1.
 ////////////////////////////////////////////////////////////////////////
        if(&source == this) return *this;
-       printf("Not allowed to copy AliITSvtest\n");
+       Warning("= operator","Not allowed to copy AliITSvtest");
        return *this;
 }
 //_____________________________________________________________________________
 AliITSvtest::~AliITSvtest() {
-    //
     // Standard destructor for the ITS
-    //
+
+    if(fRead!=0) delete fRead;
+    if(fWrite!=0) delete fWrite;
+    if(fEuclidGeomDet!=0) delete fEuclidGeomDet;
 }
 //_____________________________________________________________________________
 AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
@@ -124,17 +140,6 @@ AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
     // Standard constructor for the ITS
     //
     fIdN    = 6;
-/*
-//  TObjArray of TObjStrings
-    fIdName = new TObjArray(fIdN);
-    fIdName->AddAt(new TObjString("ITS1"),0);
-    fIdName->AddAt(new TObjString("ITS2"),1);
-    fIdName->AddAt(new TObjString("ITS3"),2);
-    fIdName->AddAt(new TObjString("ITS4"),3);
-    fIdName->AddAt(new TObjString("ITS5"),4);
-    fIdName->AddAt(new TObjString("ITS6"),5);
-*/
-//  Array of TStrings.
     fIdName    = new TString[fIdN];
     fIdName[0] = "ITS1";
     fIdName[1] = "ITS2";
@@ -144,11 +149,17 @@ AliITSvtest::AliITSvtest(const char *fileeuc,const char *filetme,
     fIdName[5] = "ITS6";
     fIdSens    = new Int_t[fIdN];
     for (Int_t i=0;i<fIdN;i++) fIdSens[i] = 0;
-    fMajorVersion = -1;
+    fMajorVersion = IsVersion();
     fMinorVersion = 1;
+    fEuclidOut    = kFALSE; // Don't write Euclide file
+    fGeomDetOut   = kFALSE; // Don't write .det file
+    fGeomDetIn    = kTRUE; // Read .det file
 
     fEuclidMaterial = filetme;
     fEuclidGeometry = fileeuc;
+    strncpy(fEuclidGeomDet,"$ALICE_ROOT/ITS/ITSgeometry_PPR.det",60);
+    strncpy(fRead,fEuclidGeomDet,60);
+    strncpy(fWrite,fEuclidGeomDet,60);
 //  The .det file for the geometry must have the same name as fileeuc with
 //  .euc replaced by .det.
 }
@@ -182,8 +193,6 @@ void AliITSvtest::CreateGeometry(){
 ////////////////////////////////////////////////////////////////////////
 // Read geometry for the ITS
 //
-
-    Int_t size;
     char topvol[5];
     char *filtmp;
 //
@@ -211,37 +220,146 @@ void AliITSvtest::CreateGeometry(){
     if (fEuclidOut) {
       gMC->WriteEuclid("ITSgeometry", "ITSV", 1, 5);
     } // end if (fEuclidOut)
-
-    filtmp = gSystem->ExpandPathName(fEuclidGeometry.Data());
-    size = strlen(filtmp);
-    if(size>4){
-       filtmp[size-3] = 'd'; // change from .euc to .det
-        filtmp[size-2] = 'e';
-        filtmp[size-1] = 't';
-       file = fopen(filtmp,"r");
-       if(file){ // if file exists use it to fill AliITSgeom structure.
-           fclose(file);
-           printf("ready to read .det file %s\n",filtmp);
-           fITSgeom = new AliITSgeom(filtmp);
-       }else{
-           fITSgeom = 0;
-           // fill AliITSgeom structure from geant structure just filled above
-       }// end if(file)
-        delete [] filtmp;
-    }// end if(size>4)
-    printf("finished with euclid geometrys\n");
+    cout <<"finished with euclid geometrys"<< endl;
 }
+//______________________________________________________________________
+void AliITSvtest::InitAliITSgeom(){
+//     Based on the geometry tree defined in Geant 3.21, this
+// routine initilizes the Class AliITSgeom from the Geant 3.21 ITS geometry
+// sturture.
+    if(!((TGeant3*)gMC)) {
+       Error("InitAliITSgeom",
+               "Wrong Monte Carlo. InitAliITSgeom uses TGeant3 calls");
+       return;
+    } // end if
+    cout << "Reading Geometry transformation directly from Geant 3." << endl;
+    const Int_t nlayers = 6;
+    const Int_t ndeep = 9;
+    Int_t itsGeomTreeNames[nlayers][ndeep],lnam[20],lnum[20];
+    Int_t nlad[nlayers],ndet[nlayers];
+    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 *names[nlayers][ndeep] = {
+     {"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 itsGeomTreeCopys[nlayers][ndeep] = {{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
+
+    // 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.
+    cout << "Reading Geometry informaton from Geant3 common blocks" << endl;
+    for(i=0;i<20;i++) lnam[i] = lnum[i] = 0;
+    for(i=0;i<nlayers;i++)for(j=0;j<ndeep;j++) 
+       itsGeomTreeNames[i][j] = ig->StringToInt(names[i][j]);
+    mod = 0;
+    for(i=0;i<nlayers;i++){
+       k = 1;
+       for(j=0;j<ndeep;j++) if(itsGeomTreeCopys[i][j]!=0)
+           k *= TMath::Abs(itsGeomTreeCopys[i][j]);
+       mod += k;
+    } // end for i
 
+    if(fITSgeom!=0) delete fITSgeom;
+    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;
+    fITSgeom = new AliITSgeom(0,6,nlad,ndet,mod);
+    mod = -1;
+    for(lay=1;lay<=nlayers;lay++){
+       for(j=0;j<ndeep;j++) lnam[j] = itsGeomTreeNames[lay-1][j];
+       for(j=0;j<ndeep;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(ndeep,lnam,lnum,t,r,idshape,npar,natt,
+                                       par,att,imat,imed);
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSPD,t,r);
+                       if(!(fITSgeom->IsShapeDefined((Int_t)kSPD)))
+                           if(fMinorVersion==1){
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                           } else if(fMinorVersion==2)
+                             fITSgeom->ReSetShape(kSPD,
+                                                 new AliITSgeomSPD425Short());
+                   } // 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:
+                       fITSgeom->CreatMatrix(mod,lay,lad,det,kSDD,t,r);
+                       if(!(fITSgeom->IsShapeDefined(kSDD))) 
+                           fITSgeom->ReSetShape(kSDD,new AliITSgeomSDD256());
+                           break;
+                       case 5:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSD,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSD))) 
+                               fITSgeom->ReSetShape(kSSD,new AliITSgeomSSD275and75());
+                           break;
+                       case 6:
+                           fITSgeom->CreatMatrix(mod,lay,lad,det,kSSDp,t,r);
+                           if(!(fITSgeom->IsShapeDefined(kSSDp))) 
+                               fITSgeom->ReSetShape(kSSDp,new AliITSgeomSSD75and275());
+                           break;
+                       } // end switch
+               } // end for det
+           } // end for lad
+           break;
+       } // end switch
+    } // end for lay
+    return;
+}
 //_____________________________________________________________________________
 void AliITSvtest::Init(){
-    //
-    // Initialise the ITS after it has been created
-    //
+////////////////////////////////////////////////////////////////////////
+//     Initialise the ITS after it has been created.
+////////////////////////////////////////////////////////////////////////
+    Int_t i;
+
+    cout << endl;
+    for(i=0;i<29;i++) cout << "*";cout << " ITSvtest_Init ";
+    for(i=0;i<28;i++) cout << "*";cout << endl;
+//
+    if(fRead[0]=='\0') strncpy(fRead,fEuclidGeomDet,60);
+    if(fWrite[0]=='\0') strncpy(fWrite,fEuclidGeomDet,60);
+    if(fITSgeom!=0) delete fITSgeom;
+    fITSgeom = new AliITSgeom();
+    if(fGeomDetIn) fITSgeom->ReadNewFile(fRead);
+    if(!fGeomDetIn) this->InitAliITSgeom();
+    if(fGeomDetOut) fITSgeom->WriteNewFile(fWrite);
     AliITS::Init();
-    fMajorVersion = -1;
-    fMinorVersion = 0;
-} 
+//
+    for(i=0;i<72;i++) cout << "*";
+    cout << endl;
+}
 //_____________________________________________________________________________
 void AliITSvtest::StepManager(){
   //
index a3088878966f0220e1a2b25d8c5d6fd452be6a4e..73643597f501724e893b250e04ae6997118ac33b 100644 (file)
@@ -25,10 +25,54 @@ public:
      virtual void  CreateGeometry();
      virtual void  CreateMaterials();
      virtual void  Init();
-     virtual Int_t IsVersion() const {
-       // returns the ITS version number 
+     virtual Int_t IsVersion() const {// returns the ITS version number 
         return -1;}
      virtual void  StepManager();
+    virtual void   SetWriteDet(Bool_t det=kTRUE){ // set .det write
+                                                fGeomDetOut = det;}
+    virtual void   SetWriteDet(const char *f){ // set write file
+                                    strncpy(fWrite,f,60);fGeomDetOut = kTRUE;}
+    virtual void   SetReadDet(Bool_t det=kTRUE){ //set .det read
+                                               fGeomDetIn = det;}
+    virtual void   SetReadDet(const char *f){ // set read file
+                                      strncpy(fRead,f,60);fGeomDetIn = kTRUE;}
+    virtual void   SetEUCLID(Bool_t euclid=kTRUE){ // set write Euclid file
+                                                 fEuclidOut = euclid;}
+    virtual void   SetEUCLIDFileName(const char *f){ // set write file
+                            fEuclidGeometry=f;fEuclidOut = kTRUE;}
+    virtual void   SetMinorVersion(Int_t v){ // Choose between existing minor versions
+       fMinorVersion = 1;
+       if(v==1) fMinorVersion = 1;
+       else if(v==2) fMinorVersion = 2;
+       else Warning("SetMinorVersion","Undefined Minor Version setting =1");}
+    virtual Bool_t GetEUCLID(){return fEuclidOut;}// returns value Euclid flag.
+    virtual const char  *GetEULIIDFileName() const{ // return .euc file name
+                                      return fEuclidGeometry.Data();}
+    virtual Bool_t GetWriteDet() { // returns value GeomDetOut flag.
+                                 return fGeomDetOut;}
+    virtual Bool_t GetReadDet() { // returns value GeomDetIn flag.
+                                return fGeomDetIn;}
+    virtual char  *GetReadDetFileName(){ // return .det read file name
+                 if(fRead[0]!='\0') return fRead; else return fEuclidGeomDet;}
+    virtual char  *GetWriteDetFileName(){ // return .det write file name
+               if(fWrite[0]!='\0') return fWrite; else return fEuclidGeomDet;}
+    virtual Int_t GetMajorVersion(){// return Major Version Number
+       return fMajorVersion;}
+    virtual Int_t GetMinorVersion(){// return Major Version Number
+       return fMinorVersion;}
+
+ private:
+    void InitAliITSgeom();
+
+    // TString fEuclidGeomtery,fEuclidMaterial defined in AliModule.
+    Bool_t fEuclidOut;        // Flag to write geometry in euclid format
+    Bool_t fGeomDetOut;       // Flag to write .det file out
+    Bool_t fGeomDetIn;        // Flag to read .det file or directly from Geat.
+    Int_t  fMajorVersion;     // Major version number == IsVersion
+    Int_t  fMinorVersion;     // Minor version number
+    char   fEuclidGeomDet[60];// file where detector transormation are define.
+    char   fRead[60];         //! file name to read .det file
+    char   fWrite[60];        //! file name to write .det file
   
     ClassDef(AliITSvtest,1)  //Hits manager for ITS test version, Private ITS class for different test geometries
 };