]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TGeant3/TGeant3.cxx
Adding possibility to set ISTRA, PAI model
[u/mrichter/AliRoot.git] / TGeant3 / TGeant3.cxx
index 3c65eeb033a119d463e1fdf246c708c5c26736e2..fe2b882136cc04e2b904b48cd2fc8942ff25a0d2 100644 (file)
 
 /*
 $Log$
+Revision 1.26  2000/05/16 13:10:41  fca
+New method IsNewTrack and fix for a problem in Father-Daughter relations
+
+Revision 1.25  2000/04/07 11:12:35  fca
+G4 compatibility changes
+
+Revision 1.24  2000/02/28 21:03:57  fca
+Some additions to improve the compatibility with G4
+
+Revision 1.23  2000/02/23 16:25:25  fca
+AliVMC and AliGeant3 classes introduced
+ReadEuclid moved from AliRun to AliModule
+
+Revision 1.22  2000/01/18 15:40:13  morsch
+Interface to GEANT3 routines GFTMAT, GBRELM and GPRELM added
+Define geant particle type 51: Feedback Photon with Cherenkov photon properties.
+
+Revision 1.21  2000/01/17 19:41:17  fca
+Add SetERAN function
+
+Revision 1.20  2000/01/12 11:29:27  fca
+Close material file
+
+Revision 1.19  1999/12/17 09:03:12  fca
+Introduce a names array
+
+Revision 1.18  1999/11/26 16:55:39  fca
+Reimplement CurrentVolName() to avoid memory leaks
+
+Revision 1.17  1999/11/03 16:58:28  fca
+Correct source of address violation in creating character string
+
+Revision 1.16  1999/11/03 13:17:08  fca
+Have ProdProcess return const char*
+
 Revision 1.15  1999/10/26 06:04:50  fca
 Introduce TLorentzVector in AliMC::GetSecondary. Thanks to I.Hrivnacova
 
@@ -60,6 +95,7 @@ Introduction of the Copyright and cvs Log
 # define gfmate  gfmate_ 
 # define gfpart  gfpart_ 
 # define gftmed  gftmed_ 
+# define gftmat  gftmat_ 
 # define gmate   gmate_ 
 # define gpart   gpart_ 
 # define gsdk    gsdk_ 
@@ -137,6 +173,8 @@ Introduction of the Copyright and cvs Log
 # define setclip setclip_
 # define gcomad gcomad_
 
+# define gbrelm gbrelm_
+# define gprelm gprelm_
 #else 
 # define gzebra  GZEBRA 
 # define grfile  GRFILE 
@@ -154,6 +192,7 @@ Introduction of the Copyright and cvs Log
 # define gfmate  GFMATE 
 # define gfpart  GFPART 
 # define gftmed  GFTMED 
+# define gftmat  GFTMAT
 # define gmate   GMATE 
 # define gpart   GPART 
 # define gsdk    GSDK 
@@ -232,6 +271,9 @@ Introduction of the Copyright and cvs Log
 # define setclip SETCLIP
 # define gcomad  GCOMAD
  
+# define gbrelm GBRELM
+# define gprelm GPRELM
+
 #endif 
 
 //____________________________________________________________________________ 
@@ -338,6 +380,10 @@ extern "C"
                           Float_t &, Float_t &, Float_t &, Float_t &,
                           Float_t &, Float_t &, Float_t *, Int_t * DEFCHARL); 
 
+  void type_of_call gftmat(const Int_t&, const Int_t&, DEFCHARD, const Int_t&,
+                          Float_t*, Float_t*
+                          ,Float_t *, Int_t & DEFCHARL);
+
   void type_of_call gsmate(const Int_t&, DEFCHARD, Float_t &, Float_t &,
                           Float_t &, Float_t &, Float_t &, Float_t *,
                           Int_t & DEFCHARL); 
@@ -446,6 +492,9 @@ extern "C"
                           const Int_t &ipa, DEFCHARD DEFCHARL);
 
   void type_of_call ertrgo();
+  
+    float type_of_call gbrelm(const Float_t &z, const Float_t& t, const Float_t& cut);
+    float type_of_call gprelm(const Float_t &z, const Float_t& t, const Float_t& cut);
 }
 
 //
@@ -538,6 +587,7 @@ void TGeant3::LoadAddress()
   gcomad(PASSCHARD("GCBANK"),(int*&) fGcbank  PASSCHARL("GCBANK"));
   gcomad(PASSCHARD("GCLINK"),(int*&) fGclink  PASSCHARL("GCLINK"));
   gcomad(PASSCHARD("GCCUTS"),(int*&) fGccuts  PASSCHARL("GCCUTS"));
+  gcomad(PASSCHARD("GCMULO"),(int*&) fGcmulo  PASSCHARL("GCMULO"));
   gcomad(PASSCHARD("GCFLAG"),(int*&) fGcflag  PASSCHARL("GCFLAG"));
   gcomad(PASSCHARD("GCKINE"),(int*&) fGckine  PASSCHARL("GCKINE"));
   gcomad(PASSCHARD("GCKING"),(int*&) fGcking  PASSCHARL("GCKING"));
@@ -551,6 +601,7 @@ void TGeant3::LoadAddress()
   gcomad(PASSCHARD("GCNUM"), (int*&) fGcnum   PASSCHARL("GCNUM"));
   gcomad(PASSCHARD("GCSETS"),(int*&) fGcsets  PASSCHARL("GCSETS"));
   gcomad(PASSCHARD("GCPHYS"),(int*&) fGcphys  PASSCHARL("GCPHYS"));
+  gcomad(PASSCHARD("GCPHLT"),(int*&) fGcphlt  PASSCHARL("GCPHLT"));
   gcomad(PASSCHARD("GCOPTI"),(int*&) fGcopti  PASSCHARL("GCOPTI"));
   gcomad(PASSCHARD("GCTLIT"),(int*&) fGctlit  PASSCHARL("GCTLIT"));
   gcomad(PASSCHARD("GCVDMA"),(int*&) fGcvdma  PASSCHARL("GCVDMA"));
@@ -579,6 +630,13 @@ void TGeant3::GeomIter()
   fNextVol=fGcvolu->nlevel;
 }
 
+//____________________________________________________________________________ 
+void TGeant3::FinishGeometry()
+{
+  //Close the geometry structure
+  Ggclos();
+}
+  
 //____________________________________________________________________________ 
 Int_t TGeant3::NextVolUp(Text_t *name, Int_t &copy)
 {
@@ -590,16 +648,21 @@ Int_t TGeant3::NextVolUp(Text_t *name, Int_t &copy)
   fNextVol--;
   if(fNextVol>=0) {
     gname=fGcvolu->names[fNextVol];
-    strncpy(name,(char *) &gname, 4);
-    name[4]='\0';
     copy=fGcvolu->number[fNextVol];
     i=fGcvolu->lvolum[fNextVol];
+    name = fVolNames[i-1];
     if(gname == fZiq[fGclink->jvolum+i]) return i;
     else printf("GeomTree: Volume %s not found in bank\n",name);
   }
   return 0;
 }
 
+//_____________________________________________________________________________
+void TGeant3::BuildPhysics()
+{
+  Gphysi();
+}
+
 //_____________________________________________________________________________
 Int_t TGeant3::CurrentVolID(Int_t &copy) const
 {
@@ -647,17 +710,13 @@ const char* TGeant3::CurrentVolName() const
   // Returns the current volume name
   //
   Int_t i, gname;
-  char *name;
   if( (i=fGcvolu->nlevel-1) < 0 ) {
     Warning("CurrentVolName","Stack depth %d\n",fGcvolu->nlevel);
   } else {
     gname=fGcvolu->names[i];
-    name = new char[5];
-    strncpy(name,(char *) &gname, 4);
-    name[4]='\0';
     i=fGcvolu->lvolum[i];   
-    if(gname == fZiq[fGclink->jvolum+i]) return name;
-    else Warning("CurrentVolName","Volume %4s not found\n",name);
+    if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
+    else Warning("CurrentVolName","Volume %4s not found\n",(char*) &gname);
   }
   return 0;
 }
@@ -671,18 +730,14 @@ const char* TGeant3::CurrentVolOffName(Int_t off) const
   // if name=0 no name is returned
   //
   Int_t i, gname;
-  char *name;
   if( (i=fGcvolu->nlevel-off-1) < 0 ) {
     Warning("CurrentVolOffName",
            "Offset requested %d but stack depth %d\n",off,fGcvolu->nlevel);
   } else {
     gname=fGcvolu->names[i];
-    name = new char[5];
-    strncpy(name,(char *) &gname, 4);
-    name[4]='\0';
     i=fGcvolu->lvolum[i];    
-    if(gname == fZiq[fGclink->jvolum+i]) return name;
-    else Warning("CurrentVolOffName","Volume %4s not found\n",name);
+    if(gname == fZiq[fGclink->jvolum+i]) return fVolNames[i-1];
+    else Warning("CurrentVolOffName","Volume %4s not found\n",(char*)&gname);
   }
   return 0;
 }
@@ -827,6 +882,11 @@ void TGeant3::DefineParticles()
                     0,0,"Special",kspe+50);
   fPDGCode[fNPDGCodes++]=kspe+50;   // 50 = Cherenkov
 
+  Gspart(51, "FeedbackPhoton", 7, 0., 0.,1.e20 );
+  pdgDB->AddParticle("FeedbackPhoton","FeedbackPhoton",0,kFALSE,
+                    0,0,"Special",kspe+51);
+  fPDGCode[fNPDGCodes++]=kspe+51;   // 51 = FeedbackPhoton
+
 /* --- Define additional decay modes --- */
 /* --- omega(783) --- */
     for (kz = 0; kz < 6; ++kz) {
@@ -964,7 +1024,7 @@ void TGeant3::DefineParticles()
 }
 
 //_____________________________________________________________________________
-Int_t TGeant3::VolId(Text_t *name) const
+Int_t TGeant3::VolId(const Text_t *name) const
 {
   //
   // Return the unique numeric identifier for volume name
@@ -992,13 +1052,75 @@ const char* TGeant3::VolName(Int_t id) const
   //
   // Return the volume name given the volume identifier
   //
-  static char name[5];
+  const char name[5]="NULL";
   if(id<1 || id > fGcnum->nvolum || fGclink->jvolum<=0) 
-    strcpy(name,"NULL");
+    return name;
   else
-    strncpy(name,(char *)&fZiq[fGclink->jvolum+id],4);
-  name[4]='\0';
-  return name;
+    return fVolNames[id-1];
+}
+
+//_____________________________________________________________________________
+void    TGeant3::SetCut(const char* cutName, Float_t cutValue)
+{
+  if(!strcmp(cutName,"CUTGAM")) 
+    fGccuts->cutgam=cutValue; 
+  else if(!strcmp(cutName,"CUTGAM")) 
+    fGccuts->cutele=cutValue; 
+  else if(!strcmp(cutName,"CUTELE")) 
+    fGccuts->cutneu=cutValue; 
+  else if(!strcmp(cutName,"CUTHAD")) 
+    fGccuts->cuthad=cutValue; 
+  else if(!strcmp(cutName,"CUTMUO")) 
+    fGccuts->cutmuo=cutValue; 
+  else if(!strcmp(cutName,"BCUTE")) 
+    fGccuts->bcute=cutValue; 
+  else if(!strcmp(cutName,"BCUTM")) 
+    fGccuts->bcutm=cutValue; 
+  else if(!strcmp(cutName,"DCUTE")) 
+    fGccuts->dcute=cutValue; 
+  else if(!strcmp(cutName,"DCUTM")) 
+    fGccuts->dcutm=cutValue; 
+  else if(!strcmp(cutName,"PPCUTM")) 
+    fGccuts->ppcutm=cutValue; 
+  else if(!strcmp(cutName,"TOFMAX")) 
+    fGccuts->tofmax=cutValue; 
+  else Warning("SetCut","Cut %s not implemented\n",cutName);
+}
+
+//_____________________________________________________________________________
+void    TGeant3::SetProcess(const char* flagName, Int_t flagValue)
+{
+  if(!strcmp(flagName,"PAIR")) 
+    fGcphys->ipair=flagValue;
+  else if(!strcmp(flagName,"COMP")) 
+    fGcphys->icomp=flagValue;
+  else if(!strcmp(flagName,"PHOT")) 
+    fGcphys->iphot=flagValue;
+  else if(!strcmp(flagName,"PFIS")) 
+    fGcphys->ipfis=flagValue;
+  else if(!strcmp(flagName,"DRAY")) 
+    fGcphys->idray=flagValue;
+  else if(!strcmp(flagName,"ANNI")) 
+    fGcphys->ianni=flagValue;
+  else if(!strcmp(flagName,"BREM")) 
+    fGcphys->ibrem=flagValue;
+  else if(!strcmp(flagName,"HADR")) 
+    fGcphys->ihadr=flagValue;
+  else if(!strcmp(flagName,"MUNU")) 
+    fGcphys->imunu=flagValue;
+  else if(!strcmp(flagName,"DCAY")) 
+    fGcphys->idcay=flagValue;
+  else if(!strcmp(flagName,"LOSS")) 
+    fGcphys->iloss=flagValue;
+  else if(!strcmp(flagName,"MULS")) 
+    fGcphys->imuls=flagValue;
+  else if(!strcmp(flagName,"RAYL")) 
+    fGcphys->irayl=flagValue;
+  else if(!strcmp(flagName,"STRA")) 
+    fGcphlt->istra=flagValue;
+  else if(!strcmp(flagName,"SYNC")) 
+    fGcphlt->isync=flagValue;
+  else  Warning("SetFlag","Flag %s not implemented\n",flagName);
 }
 
 //_____________________________________________________________________________
@@ -1095,6 +1217,15 @@ Float_t TGeant3::TrackLength() const
   return fGctrak->sleng;
 }
 
+//_____________________________________________________________________________
+Bool_t TGeant3::IsNewTrack() const
+{
+  //
+  // True if the track is not at the boundary of the current volume
+  //
+  return (fGctrak->sleng>0);
+}
+
 //_____________________________________________________________________________
 Bool_t TGeant3::IsTrackInside() const
 {
@@ -1268,40 +1399,6 @@ Float_t TGeant3::MaxStep() const
   return fGctmed->stemax;
 }
 
-//_____________________________________________________________________________
-void TGeant3::SetColors()
-{
-  //
-  // Set the colors for all the volumes
-  // this is done sequentially for all volumes
-  // based on the number of their medium
-  //
-  Int_t kv, icol;
-  Int_t jvolum=fGclink->jvolum;
-  //Int_t jtmed=fGclink->jtmed;
-  //Int_t jmate=fGclink->jmate;
-  Int_t nvolum=fGcnum->nvolum;
-  char name[5];
-  //
-  //    Now for all the volumes
-  for(kv=1;kv<=nvolum;kv++) {
-    //     Get the tracking medium
-    Int_t itm=Int_t (fZq[fZlq[jvolum-kv]+4]);
-    //     Get the material
-    //Int_t ima=Int_t (fZq[fZlq[jtmed-itm]+6]);
-    //     Get z
-    //Float_t z=fZq[fZlq[jmate-ima]+7];
-    //     Find color number
-    //icol = Int_t(z)%6+2;
-    //icol = 17+Int_t(z*150./92.);
-    //icol = kv%6+2;
-    icol = itm%6+2;
-    strncpy(name,(char*)&fZiq[jvolum+kv],4);
-    name[4]='\0';
-    Gsatt(name,"COLO",icol);
-  }
-}
-
 //_____________________________________________________________________________
 void TGeant3::SetMaxStep(Float_t maxstep)
 {
@@ -1576,6 +1673,13 @@ void  TGeant3::Ggclos()
   //   through the routine GHCLOS. 
   //
   ggclos(); 
+  // Create internal list of volumes
+  fVolNames = new char[fGcnum->nvolum][5];
+  Int_t i;
+  for(i=0; i<fGcnum->nvolum; ++i) {
+    strncpy(fVolNames[i], (char *) &fZiq[fGclink->jvolum+i+1], 4);
+    fVolNames[i][4]='\0';
+  }
 } 
  
 //_____________________________________________________________________________
@@ -1696,7 +1800,30 @@ void  TGeant3::Gftmed(Int_t numed, char *name, Int_t &nmat, Int_t &isvol,
   //
   gftmed(numed, PASSCHARD(name), nmat, isvol, ifield, fieldm, tmaxfd, stemax,  
          deemax, epsil, stmin, ubuf, nbuf PASSCHARL(name)); 
+}
+
+ void  TGeant3::Gftmat(Int_t imate, Int_t ipart, char *chmeca, Int_t kdim,
+                     Float_t* tkin, Float_t* value, Float_t* pcut,
+                     Int_t &ixst)
+{ 
+  //
+  // Return parameters for tracking medium NUMED
+  //
+  gftmat(imate, ipart, PASSCHARD(chmeca), kdim,
+        tkin, value, pcut, ixst PASSCHARL(chmeca));
+
 } 
+
+Float_t TGeant3::Gbrelm(Float_t z, Float_t t, Float_t bcut)
+{
+    return gbrelm(z,t,bcut);
+}
+
+Float_t TGeant3::Gprelm(Float_t z, Float_t t, Float_t bcut)
+{
+    return gprelm(z,t,bcut);
+}
  
 //_____________________________________________________________________________
 void  TGeant3::Gmate() 
@@ -3171,6 +3298,20 @@ void TGeant3::SetDRAY(Int_t par)
   fGcphys->idray = par;
 }
  
+//_____________________________________________________________________________
+void TGeant3::SetERAN(Float_t ekmin, Float_t ekmax, Int_t nekbin)
+{
+  //
+  //  To control cross section tabulations
+  //   ekmin = minimum kinetic energy in GeV
+  //   ekmax = maximum kinetic energy in GeV
+  //   nekbin = number of logatithmic bins (<200)
+  //  
+  fGcmulo->ekmin = ekmin;
+  fGcmulo->ekmax = ekmax;
+  fGcmulo->nekbin = nekbin;
+}
 //_____________________________________________________________________________
 void TGeant3::SetHADR(Int_t par)
 {
@@ -3310,6 +3451,18 @@ void TGeant3::SetRAYL(Int_t par)
   fGcphys->irayl = par;
 }
  
+//_____________________________________________________________________________
+void TGeant3::SetSTRA(Int_t par)
+{
+  //
+  //  To control energy loss fluctuations
+  //  with the PhotoAbsorption Ionisation model.
+  //   par =0 no Straggling.
+  //       =1 Straggling yes => no Delta rays.
+  //  
+  fGcphlt->istra = par;
+}
 //_____________________________________________________________________________
 void TGeant3::SetSWIT(Int_t sw, Int_t val)
 {
@@ -3452,8 +3605,8 @@ void TGeant3::WriteEuclid(const char* filnam, const char* topvol,
     end=i;
     break;
   }
-  filext=new char[end+4];
-  filetme=new char[end+4];
+  filext=new char[end+5];
+  filetme=new char[end+5];
   strncpy(filext,filnam,end);
   strncpy(filetme,filnam,end);
   //
@@ -3838,6 +3991,7 @@ void TGeant3::WriteEuclid(const char* filnam, const char* topvol,
     }
   }
   fprintf(lun,"END\n");
+  fclose(lun);
   printf(" *** GWEUCL *** file: %s is now written out\n",filext);
   printf(" *** GWEUCL *** file: %s is now written out\n",filetme);
   // Clean up