]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TFluka/TFlukaGeo.cxx
TFlukaCerenkov added.
[u/mrichter/AliRoot.git] / TFluka / TFlukaGeo.cxx
index 42bd5b19b9c96275b60277154907603e9cab834a..981b607d941203fcacdc423ec36d02e65c2a346b 100644 (file)
@@ -17,6 +17,8 @@
 
 #include <Riostream.h>
 
+#include "AliModule.h"
+#include "AliRun.h"
 #include "TClonesArray.h"
 #include "TFlukaGeo.h"
 #include "TCallf77.h"      //For the fortran calls
 
 #include "TVirtualMC.h"
 #include "TGeoManager.h"
+#include "TGeoMaterial.h"
+#include "TGeoMedium.h"
 #include "TFlukaMCGeometry.h"
-
+#include "TFlukaCerenkov.h"
 #include "TLorentzVector.h"
 
 // Fluka methods that may be needed.
@@ -83,6 +87,7 @@ TFluka::TFluka()
    fNVolumes = 0;
    fCurrentFlukaRegion = -1;
    fGeom = 0;
+   fMaterials = 0;
 } 
  
 //______________________________________________________________________________ 
@@ -101,6 +106,7 @@ TFluka::TFluka(const char *title, Int_t verbosity, Bool_t isRootGeometrySupporte
    fNVolumes      = 0;
    fCurrentFlukaRegion = -1;
    fGeom = new TFlukaMCGeometry("geom", "ALICE geometry");
+   fMaterials = 0;
 }
 
 //______________________________________________________________________________ 
@@ -120,48 +126,24 @@ TFluka::~TFluka() {
 //______________________________________________________________________________ 
 void TFluka::Init() {
 
-  if (fVerbosityLevel >=3)
-    cout << "==> TFluka::Init() called." << endl;
-
-   if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
-   fApplication->ConstructGeometry();
-   TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
-   gGeoManager->SetTopVolume(top);
-   gGeoManager->CloseGeometry("di");
-   gGeoManager->DefaultColors();  // to be removed
-   fNVolumes = fGeom->NofVolumes();
-   printf("== Number of volumes: %i\n ==", fNVolumes);
-   fGeom->CreateFlukaMatFile("flukaMat.inp");   
-  cout << "\t* InitPhysics() - Prepare input file to be called" << endl; 
-  // now we have TGeo geometry created and we have to patch alice.inp
-  // with the material mapping file FlukaMat.inp
-  InitPhysics(); // prepare input file with the current physics settings
-    cout << "\t* InitPhysics() - Prepare input file was called" << endl; 
-
-  if (fVerbosityLevel >=2)
-    cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
-        << ") in fluka..." << endl;
-  GLOBAL.lfdrtr = true;
-
-  if (fVerbosityLevel >=2)
-    cout << "\t* Opening file " << sInputFileName << endl;
-  const char* fname = sInputFileName;
-  fluka_openinp(lunin, PASSCHARA(fname));
-
-  if (fVerbosityLevel >=2)
-    cout << "\t* Calling flukam..." << endl;
-  flukam(1);
-
-  if (fVerbosityLevel >=2)
-    cout << "\t* Closing file " << sInputFileName << endl;
-  fluka_closeinp(lunin);
-
-  FinishGeometry();
-
-  if (fVerbosityLevel >=3)
-    cout << "<== TFluka::Init() called." << endl;
+    if (fVerbosityLevel >=3)
+       cout << "==> TFluka::Init() called." << endl;
+    
+    if (!gGeoManager) new TGeoManager("geom", "FLUKA geometry");
+    fApplication->ConstructGeometry();
+    TGeoVolume *top = (TGeoVolume*)gGeoManager->GetListOfVolumes()->First();
+    gGeoManager->SetTopVolume(top);
+    gGeoManager->CloseGeometry("di");
+    gGeoManager->DefaultColors();  // to be removed
+    fNVolumes = fGeom->NofVolumes();
+    printf("== Number of volumes: %i\n ==", fNVolumes);
+    fGeom->CreateFlukaMatFile("flukaMat.inp");   
+    cout << "\t* InitPhysics() - Prepare input file to be called" << endl; 
+    // now we have TGeo geometry created and we have to patch alice.inp
+    // with the material mapping file FlukaMat.inp
 }
 
+
 //______________________________________________________________________________ 
 void TFluka::FinishGeometry() {
 //
@@ -178,12 +160,37 @@ void TFluka::FinishGeometry() {
 
 //______________________________________________________________________________ 
 void TFluka::BuildPhysics() {
-  if (fVerbosityLevel >=3)
-    cout << "==> TFluka::BuildPhysics() called." << endl;
-
-
-  if (fVerbosityLevel >=3)
-    cout << "<== TFluka::BuildPhysics() called." << endl;
+    if (fVerbosityLevel >=3)
+       cout << "==> TFluka::BuildPhysics() called." << endl;
+    InitPhysics(); // prepare input file with the current physics settings
+    cout << "\t* InitPhysics() - Prepare input file was called" << endl; 
+    
+    if (fVerbosityLevel >=2)
+       cout << "\t* Changing lfdrtr = (" << (GLOBAL.lfdrtr?'T':'F')
+            << ") in fluka..." << endl;
+    GLOBAL.lfdrtr = true;
+    
+    if (fVerbosityLevel >=2)
+       cout << "\t* Opening file " << sInputFileName << endl;
+    const char* fname = sInputFileName;
+    fluka_openinp(lunin, PASSCHARA(fname));
+    
+    if (fVerbosityLevel >=2)
+       cout << "\t* Calling flukam..." << endl;
+    flukam(1);
+    
+    if (fVerbosityLevel >=2)
+       cout << "\t* Closing file " << sInputFileName << endl;
+    fluka_closeinp(lunin);
+    
+    FinishGeometry();
+    
+    if (fVerbosityLevel >=3)
+       cout << "<== TFluka::Init() called." << endl;
+    
+    
+    if (fVerbosityLevel >=3)
+       cout << "<== TFluka::BuildPhysics() called." << endl;
 }  
 
 //______________________________________________________________________________ 
@@ -297,10 +304,39 @@ void TFluka::Matrix(Int_t& krot, Double_t thetaX, Double_t phiX,
 } 
 
 //______________________________________________________________________________ 
-void TFluka::Gstpar(Int_t /*itmed*/, const char */*param*/, Double_t /*parval*/) {
+void TFluka::Gstpar(Int_t itmed, const char* param, Double_t parval) {
 //
 // Is it needed with TGeo ??? - to clear-up
-   Warning("Gstpar", "Not implemented with TGeo");
+//
+    
+   printf("Gstpar called with %6d %5s %12.4e %6d\n", itmed, param, parval, fGeom->GetFlukaMaterial(itmed));
+   Bool_t process = kFALSE;
+   if (strncmp(param, "DCAY",  4) == 0 ||
+       strncmp(param, "PAIR",  4) == 0 ||
+       strncmp(param, "COMP",  4) == 0 ||
+       strncmp(param, "PHOT",  4) == 0 ||
+       strncmp(param, "PFIS",  4) == 0 ||
+       strncmp(param, "DRAY",  4) == 0 ||
+       strncmp(param, "ANNI",  4) == 0 ||
+       strncmp(param, "BREM",  4) == 0 ||
+       strncmp(param, "MUNU",  4) == 0 ||
+       strncmp(param, "CKOV",  4) == 0 ||
+       strncmp(param, "HADR",  4) == 0 ||
+       strncmp(param, "LOSS",  4) == 0 ||
+       strncmp(param, "MULS",  4) == 0 ||
+       strncmp(param, "RAYL",  4) == 0) 
+   {
+       process = kTRUE;
+   } 
+   if (process) {
+       SetProcess(param, Int_t (parval), fGeom->GetFlukaMaterial(itmed));
+   } else {
+       SetCut(param, parval, fGeom->GetFlukaMaterial(itmed));
+   }
+   
+   
+   
 }    
 
 // functions from GGEOM 
@@ -390,11 +426,26 @@ void TFluka::Gsbool(const char* /*onlyVolName*/, const char* /*manyVolName*/) {
 }
 
 //______________________________________________________________________________ 
-void TFluka::SetCerenkov(Int_t /*itmed*/, Int_t /*npckov*/, Float_t */*ppckov*/,
-                        Float_t * /*absco*/, Float_t * /*effic*/, Float_t * /*rindex*/) {
+void TFluka::SetCerenkov(Int_t itmed, Int_t npckov, Float_t* ppckov,
+                        Float_t* absco, Float_t* effic, Float_t* rindex) {
 //
-// Not implemented with TGeo - what G4 did ? Any FLUKA card generated?
-   Warning("SetCerenkov", "Not implemented with TGeo");
+// Set Cerenkov properties for medium itmed
+//
+// npckov: number of sampling points
+// ppckov: energy values
+// absco:  absorption length
+// effic:  quantum efficiency
+// rindex: refraction index
+//
+//
+//  
+//  Create object holding Cerenkov properties
+//  
+    TFlukaCerenkov* cerenkovProperties = new TFlukaCerenkov(npckov, ppckov, absco, effic, rindex);
+//
+//  Pass object to medium
+    TGeoMedium* medium = gGeoManager->GetMedium(itmed);
+    medium->SetCerenkovProperties(cerenkovProperties);
 }  
 
 //______________________________________________________________________________ 
@@ -490,44 +541,58 @@ Int_t TFluka::PDGFromId(Int_t id) const
 // set methods
 //
 
+void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
+{
+    strcpy(&fProcessFlag[fNbOfProc][0],flagName);
+    fProcessValue[fNbOfProc] = flagValue;
+    fProcessMedium[fNbOfProc] = imed;
+    fNbOfProc++;
+}
+
 //______________________________________________________________________________ 
 void TFluka::SetProcess(const char* flagName, Int_t flagValue)
 {
   Int_t i;
-  if (iNbOfProc < 100) {
-    for (i=0; i<iNbOfProc; i++) {
-      if (strcmp(&sProcessFlag[i][0],flagName) == 0) {
-        iProcessValue[iNbOfProc] = flagValue;
-       goto fin;
+  if (fNbOfProc < 100) {
+    for (i=0; i<fNbOfProc; i++) {
+      if (strcmp(&fProcessFlag[i][0],flagName) == 0) {
+        fProcessValue[fNbOfProc] = flagValue;
+       return;
       }
     }
-    strcpy(&sProcessFlag[iNbOfProc][0],flagName);
-    iProcessValue[iNbOfProc++] = flagValue;
+    strcpy(&fProcessFlag[fNbOfProc][0],flagName);
+    fProcessValue[fNbOfProc++] = flagValue;
   }
   else
     cout << "Nb of SetProcess calls exceeds 100 - ignored" << endl;
-fin:
-  iNbOfProc = iNbOfProc;
+}
+
+//______________________________________________________________________________ 
+void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
+{
+    strcpy(&fCutFlag[fNbOfCut][0],cutName);
+    fCutValue[fNbOfCut]  = cutValue;
+    fCutMedium[fNbOfCut] = imed;
+    fNbOfCut++;
 }
 
 //______________________________________________________________________________ 
 void TFluka::SetCut(const char* cutName, Double_t cutValue)
 {
   Int_t i;
-  if (iNbOfCut < 100) {
-    for (i=0; i<iNbOfCut; i++) {
-      if (strcmp(&sCutFlag[i][0],cutName) == 0) {
-        fCutValue[iNbOfCut] = cutValue;
-       goto fin;
+  if (fNbOfCut < 100) {
+    for (i=0; i<fNbOfCut; i++) {
+      if (strcmp(&fCutFlag[i][0],cutName) == 0) {
+        fCutValue[fNbOfCut] = cutValue;
+       return;
       }
     }
-    strcpy(&sCutFlag[iNbOfCut][0],cutName);
-    fCutValue[iNbOfCut++] = cutValue;
+    strcpy(&fCutFlag[fNbOfCut][0],cutName);
+    fCutMedium[fNbOfCut] = -1;
+    fCutValue[fNbOfCut++] = cutValue;
   }
   else
     cout << "Nb of SetCut calls exceeds 100 - ignored" << endl;
-fin:
-  iNbOfCut = iNbOfCut;
 }
 
 //______________________________________________________________________________ 
@@ -542,46 +607,82 @@ void TFluka::InitPhysics()
 {
   Int_t i, j, k;
   Double_t fCut;
+
+  FILE *pAliceCoreInp, *pAliceFlukaMat, *pAliceInp, *pGaliceCuts;
+
+  Double_t zero  = 0.0;
+  Double_t one   = 1.0;
+  Double_t two   = 2.0;
+  Double_t three = 3.0;
+
   Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
   printf("   last FLUKA material is %g\n", fLastMaterial);
 
+  // Prepare  Cerenkov
+  TList *matList = gGeoManager->GetListOfMaterials();
+  Int_t nmaterial =  matList->GetSize();
+  fMaterials = new Int_t[nmaterial];
+             
+             
+
 // construct file names
+
   TString sAliceCoreInp = getenv("ALICE_ROOT");
+  TString sGaliceCuts = sAliceCoreInp;
   sAliceCoreInp +="/TFluka/input/";
   TString sAliceTmp = "flukaMat.inp";
   TString sAliceInp = GetInputFileName();
   sAliceCoreInp += GetCoreInputFileName();
-  ifstream AliceCoreInp(sAliceCoreInp.Data());
-  ifstream AliceFlukaMat(sAliceTmp.Data());
-  ofstream AliceInp(sAliceInp.Data());
+  sGaliceCuts +="/data/galice.cuts";
+
+// open files 
+
+  if ((pAliceCoreInp = fopen(sAliceCoreInp.Data(),"r")) == NULL) {
+      printf("\nCannot open file %s\n",sAliceCoreInp.Data());
+      exit(1);
+  }
+  if ((pAliceFlukaMat = fopen(sAliceTmp.Data(),"r")) == NULL) {
+      printf("\nCannot open file %s\n",sAliceTmp.Data());
+      exit(1);
+  }
+  if ((pAliceInp = fopen(sAliceInp.Data(),"w")) == NULL) {
+      printf("\nCannot open file %s\n",sAliceInp.Data());
+      exit(1);
+  }
+
+  if ((pGaliceCuts = fopen(sGaliceCuts.Data(),"r")) == NULL) {
+    printf("\nCannot open file %s\n",sGaliceCuts.Data());
+    exit(1);
+  }
 
 // copy core input file 
   Char_t sLine[255];
   Float_t fEventsPerRun;
-
-  while (AliceCoreInp.getline(sLine,255)) {
-    if (strncmp(sLine,"GEOEND",6) != 0)
-      AliceInp << sLine << endl; // copy until GEOEND card
-    else {
-      AliceInp << "GEOEND" << endl; // add GEOEND card
-      goto flukamat;
-    }
+  
+  while ((fgets(sLine,255,pAliceCoreInp)) != NULL) {
+      if (strncmp(sLine,"GEOEND",6) != 0)
+         fprintf(pAliceInp,"%s",sLine); // copy until GEOEND card
+      else {
+         fprintf(pAliceInp,"GEOEND\n");   // add GEOEND card
+         goto flukamat;
+      }
   } // end of while until GEOEND card
+  
 
-flukamat:
-  while (AliceFlukaMat.getline(sLine,255)) { // copy flukaMat.inp file
-        AliceInp << sLine << endl;
+ flukamat:
+  while ((fgets(sLine,255,pAliceFlukaMat)) != NULL) { // copy flukaMat.inp file
+      fprintf(pAliceInp,"%s\n",sLine);
   }
-
-  while (AliceCoreInp.getline(sLine,255)) {
-    if (strncmp(sLine,"START",5) != 0)
-      AliceInp << sLine << endl;
-    else {
-      sscanf(sLine+10,"%10f",&fEventsPerRun);
+  
+  while ((fgets(sLine,255,pAliceCoreInp)) != NULL) { 
+      if (strncmp(sLine,"START",5) != 0)
+         fprintf(pAliceInp,"%s\n",sLine);
+      else {
+         sscanf(sLine+10,"%10f",&fEventsPerRun);
       goto fin;
-    }
+      }
   } //end of while until START card
-
+  
 fin:
 // in G3 the process control values meaning can be different for
 // different processes, but for most of them is:
@@ -597,15 +698,21 @@ fin:
 //   HADR:  may be > 2
 //
  
-// Loop over number of SetProcess calls  
-  AliceInp << "*----------------------------------------------------------------------------- "; 
-  AliceInp << endl;
-  AliceInp << "*----- The following data are generated from SetProcess and SetCut calls ----- "; 
-  AliceInp << endl;
-  AliceInp << "*----------------------------------------------------------------------------- "; 
-    AliceInp << endl;
-  for (i=0; i<iNbOfProc; i++) {
-
+// Loop over number of SetProcess calls 
+  fprintf(pAliceInp,"*----------------------------------------------------------------------------- \n");
+  fprintf(pAliceInp,"*----- The following data are generated from SetProcess and SetCut calls ----- \n");
+  fprintf(pAliceInp,"*----------------------------------------------------------------------------- \n");
+
+  for (i = 0; i < fNbOfProc; i++) {
+      Float_t matMin = three;
+      Float_t matMax = fLastMaterial;
+      Bool_t  global = kTRUE;
+      if (fProcessMedium[i] != -1) {
+         matMin = Float_t(fProcessMedium[i]);
+         matMax = matMin;
+         global = kFALSE;
+      }
+      
     // annihilation
     // G3 default value: 1
     // G4 processes: G4eplusAnnihilation/G4IeplusAnnihilation
@@ -615,45 +722,28 @@ fin:
     // flag = 1 annihilation, decays processed
     // flag = 2 annihilation, no decay product stored
     // gMC ->SetProcess("ANNI",1); // EMFCUT   -1.   0.  0. 3. lastmat 0. ANNH-THR
-    if (strncmp(&sProcessFlag[i][0],"ANNI",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0."; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "EMFCUT    "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << -1.0; // kinetic energy threshold (GeV) for e+ annihilation (resets to default=0)
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // step length in assigning indices
-        AliceInp << setw(8)  << "ANNH-THR"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No annihilation - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('ANNI',0)"; 
-        AliceInp << endl;
+      if (strncmp(&fProcessFlag[i][0],"ANNI",4) == 0) {
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2) {
+             fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+ annihilation - resets to default=0.\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('ANNI',1) or SetProcess('ANNI',2)\n");
+             // -one = kinetic energy threshold (GeV) for e+ annihilation (resets to default=0)
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             // "ANNH-THR"; 
+             fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fANNH-THR\n",-one,zero,zero,matMin,matMax,one);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No annihilation - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('ANNI',0)\n");
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('ANNI',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
       }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('ANNI',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    }
     
     // bremsstrahlung and pair production are both activated
     // G3 default value: 1
@@ -678,1253 +768,927 @@ fin:
     // flag = 2 delta rays, no secondaries stored
     // gMC ->SetProcess("PAIR",1); // PAIRBREM  1.   0.  0. 3. lastmat
                                  // EMFCUT    0.   0. -1. 3. lastmat 0. PHOT-THR
-    else if ((strncmp(&sProcessFlag[i][0],"PAIR",4) == 0) && (iProcessValue[i] == 1 || iProcessValue[i] == 2)) {
-      for (j=0; j<iNbOfProc; j++) {
-        if ((strncmp(&sProcessFlag[j][0],"BREM",4) == 0) && (iProcessValue[j] == 1 || iProcessValue[j] == 2)) {
-          AliceInp << "*"; 
-          AliceInp << endl;
-          AliceInp << "*Bremsstrahlung and pair production by muons and charged hadrons both activated"; 
-          AliceInp << endl;
-          AliceInp << "*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)"; 
-          AliceInp << endl;
-          AliceInp << "*Energy threshold set by call SetCut('BCUTM',cut) or set to 0."; 
-          AliceInp << endl;
-          AliceInp << "*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0."; 
-          AliceInp << endl;
-          AliceInp << setw(10) << "PAIRBREM  "; 
-          AliceInp << setiosflags(ios::scientific) << setprecision(5);
-          AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-          AliceInp << setw(10) << 3.0; // bremsstrahlung and pair production by muons and charged hadrons both are activated
-          // direct pair production by muons
-          // G4 particles: "e-", "e+"
-          // G3 default value: 0.01 GeV
-          //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
-          fCut = 0.0;
-          for (k=0; k<iNbOfCut; k++) {
-            if (strncmp(&sCutFlag[k][0],"PPCUTM",6) == 0) fCut = fCutValue[k];
-          }
-          AliceInp << setiosflags(ios::scientific) << setprecision(5);
-          AliceInp << setw(10) << fCut; // e+, e- kinetic energy threshold (in GeV) for explicit pair production.
-          // muon and hadron bremsstrahlung
-          // G4 particles: "gamma"
-          // G3 default value: CUTGAM=0.001 GeV
-          //gMC ->SetCut("BCUTM",cut);  // cut for muon and hadron bremsstrahlung
-          fCut = 0.0;
-          for (k=0; k<iNbOfCut; k++) {
-            if (strncmp(&sCutFlag[k][0],"BCUTM",5) == 0) fCut = fCutValue[k];
-          }
-          AliceInp << setiosflags(ios::scientific) << setprecision(5);
-          AliceInp << setw(10) << fCut; // photon energy threshold (GeV) for explicit bremsstrahlung production
-          AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-          AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply
-          AliceInp << setw(10) << setprecision(2);
-          AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-          AliceInp << endl;
-         
-          // for e+ and e-
-          AliceInp << "*"; 
-          AliceInp << endl;
-          AliceInp << "*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0."; 
-          AliceInp << endl;
-          AliceInp << "*Generated from call: SetProcess('BREM',1);"; 
-          AliceInp << endl;
-          AliceInp << setw(10) << "EMFCUT    "; 
-          fCut = -1.0;
-          for (k=0; k<iNbOfCut; k++) {
-            if (strncmp(&sCutFlag[k][0],"BCUTE",5) == 0) fCut = fCutValue[k];
-          }
-          AliceInp << setiosflags(ios::scientific) << setprecision(5);
-          AliceInp << setw(10) << fCut; // kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
-          AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-          AliceInp << setw(10) << 0.0;  // not used
-          AliceInp << setw(10) << 0.0;  // not used
-          AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-          AliceInp << setw(10) << setprecision(2);
-          AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-          AliceInp << setprecision(1);
-          AliceInp << setw(10) << 1.0; // step length in assigning indices
-          AliceInp << setw(8)  << "ELPO-THR"; 
-          AliceInp << endl;
-      
+    else if ((strncmp(&fProcessFlag[i][0],"PAIR",4) == 0) && (fProcessValue[i] == 1 || fProcessValue[i] == 2)) {
+
+       for (j=0; j<fNbOfProc; j++) {
+           if ((strncmp(&fProcessFlag[j][0],"BREM",4) == 0) && 
+               (fProcessValue[j] == 1 || fProcessValue[j] == 2) &&
+               (fProcessMedium[j] == fProcessMedium[i])) {
+               fprintf(pAliceInp,"*\n*Bremsstrahlung and pair production by muons and charged hadrons both activated\n");
+               fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1) and SetProcess('PAIR',1)\n");
+               fprintf(pAliceInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
+               fprintf(pAliceInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
+               // three = bremsstrahlung and pair production by muons and charged hadrons both are activated
+               fprintf(pAliceInp,"PAIRBREM  %10.1f",three);
+               // direct pair production by muons
+               // G4 particles: "e-", "e+"
+               // G3 default value: 0.01 GeV
+               //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
+               fCut = 0.0;
+               for (k=0; k<fNbOfCut; k++) {
+                   if (strncmp(&fCutFlag[k][0],"PPCUTM",6) == 0 &&
+                       (fCutMedium[k] == fProcessMedium[i])) fCut = fCutValue[k];
+               }
+               fprintf(pAliceInp,"%10.4g",fCut);
+               // fCut; = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
+               // muon and hadron bremsstrahlung
+               // G4 particles: "gamma"
+               // G3 default value: CUTGAM=0.001 GeV
+               //gMC ->SetCut("BCUTM",cut);  // cut for muon and hadron bremsstrahlung
+               fCut = 0.0;
+               for (k=0; k<fNbOfCut; k++) {
+                   if (strncmp(&fCutFlag[k][0],"BCUTM",5) == 0 &&
+                       (fCutMedium[k] == fProcessMedium[i])) fCut = fCutValue[k];
+               }
+               fprintf(pAliceInp,"%10.4g%10.1f%10.1f\n",fCut,matMin,matMax);
+               // fCut = photon energy threshold (GeV) for explicit bremsstrahlung production
+               // matMin = lower bound of the material indices in which the respective thresholds apply
+               // matMax = upper bound of the material indices in which the respective thresholds apply
+               
+               // for e+ and e-
+               fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
+               fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1);\n");
+               fCut = -1.0;
+               for (k=0; k<fNbOfCut; k++) {
+                   if (strncmp(&fCutFlag[k][0],"BCUTE",5) == 0 &&
+                       (fCutMedium[k] == fProcessMedium[i])) fCut = fCutValue[k];
+               }
+               //fCut = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
+               // zero = not used
+               // zero = not used
+               // matMin = lower bound of the material indices in which the respective thresholds apply
+               // matMax = upper bound of the material indices in which the respective thresholds apply
+               // one = step length in assigning indices
+               // "ELPO-THR"; 
+               fprintf(pAliceInp,"EMFCUT    %10.4g%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",fCut,zero,zero,matMin,matMax,one);
+               
           // for e+ and e-
-          AliceInp << "*"; 
-          AliceInp << endl;
-          AliceInp << "*Pair production by electrons is activated"; 
-          AliceInp << endl;
-          AliceInp << "*Generated from call: SetProcess('PAIR',1);"; 
-          AliceInp << endl;
-          AliceInp << setw(10) << "EMFCUT    "; 
-          AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-          AliceInp << setw(10) << 0.0;  // energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
-          AliceInp << setw(10) << 0.0;  // energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
-          fCut = -1.0;
-          for (j=0; j<iNbOfCut; j++) {
-            if (strncmp(&sCutFlag[j][0],"CUTGAM",6) == 0) fCut = fCutValue[j];
-          }
-          AliceInp << setiosflags(ios::scientific) << setprecision(5);
-          AliceInp << setw(10) << fCut; // energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
-          AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-          AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-          AliceInp << setprecision(2);
-          AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-          AliceInp << setprecision(1);
-          AliceInp << setw(10) << 1.0;  // step length in assigning indices
-          AliceInp << setw(8) << "PHOT-THR"; 
-          AliceInp << endl;
-         goto BOTH;
-        } // end of if for BREM
-      } // end of loop for BREM
-
-      // only pair production by muons and charged hadrons is activated
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Pair production by muons and charged hadrons is activated"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)"; 
-      AliceInp << endl;
-      AliceInp << "*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0."; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PAIRBREM  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 1.0; // pair production by muons and charged hadrons is activated
-      // direct pair production by muons
-      // G4 particles: "e-", "e+"
-      // G3 default value: 0.01 GeV
-      //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 0.0; // e+, e- kinetic energy threshold (in GeV) for explicit pair production.
-      AliceInp << setw(10) << 0.0; // no explicit bremsstrahlung production is simulated
-      AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply
-      AliceInp << setprecision(2);
-      AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-      AliceInp << endl;
+               fprintf(pAliceInp,"*\n*Pair production by electrons is activated\n");
+               fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1);\n");
+               fCut = -1.0;
+               for (k=0; k<fNbOfCut; k++) {
+                   if (strncmp(&fCutFlag[k][0],"CUTGAM",6) == 0 &&
+                       (fCutMedium[k] == fProcessMedium[i])) fCut = fCutValue[k];
+               }
+               // fCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
+               // matMin = lower bound of the material indices in which the respective thresholds apply
+               // matMax =  upper bound of the material indices in which the respective thresholds apply
+               // one = step length in assigning indices
+               fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,fCut,matMin,matMax,one);
+               goto BOTH;
+           } // end of if for BREM
+       } // end of loop for BREM
+       
+       // only pair production by muons and charged hadrons is activated
+       fprintf(pAliceInp,"*\n*Pair production by muons and charged hadrons is activated\n");
+       fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
+       fprintf(pAliceInp,"*Energy threshold set by call SetCut('PPCUTM',cut) or set to 0.\n");
+       // direct pair production by muons
+       // G4 particles: "e-", "e+"
+       // G3 default value: 0.01 GeV
+       //gMC ->SetCut("PPCUTM",cut); // total energy cut for direct pair prod. by muons
+       // one = pair production by muons and charged hadrons is activated
+       // zero = e+, e- kinetic energy threshold (in GeV) for explicit pair production.
+       // zero = no explicit bremsstrahlung production is simulated
+       // matMin = lower bound of the material indices in which the respective thresholds apply
+       // matMax = upper bound of the material indices in which the respective thresholds apply
+       fprintf(pAliceInp,"PAIRBREM  %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
+       
+       // for e+ and e-
+       fprintf(pAliceInp,"*\n*Pair production by electrons is activated\n");
+       fprintf(pAliceInp,"*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)\n");
+       fCut = -1.0;
+       for (j=0; j<fNbOfCut; j++) {
+           if (strncmp(&fCutFlag[j][0],"CUTGAM",6) == 0 &&
+               (fCutMedium[j] == fProcessMedium[i])) fCut = fCutValue[j];
+       }
+       // zero = energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
+       // zero = energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
+       // fCut = energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
+       // matMin = lower bound of the material indices in which the respective thresholds apply
+       // matMax = upper bound of the material indices in which the respective thresholds apply
+       // one = step length in assigning indices
+       fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.4g%10.1f%10.1f%10.1fPHOT-THR\n",zero,zero,fCut,matMin,matMax,one);
       
-      // for e+ and e-
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Pair production by electrons is activated"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetProcess('PAIR',1) or SetProcess('PAIR',2)"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "EMFCUT    "; 
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 0.0;  // energy threshold (GeV) for Compton scattering (= 0.0 : ignored)
-      AliceInp << setw(10) << 0.0;  // energy threshold (GeV) for Photoelectric (= 0.0 : ignored)
-
-      fCut = -1.0;
-      for (j=0; j<iNbOfCut; j++) {
-        if (strncmp(&sCutFlag[j][0],"CUTGAM",6) == 0) fCut = fCutValue[j];
-      }
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << fCut; // energy threshold (GeV) for gamma pair production (< 0.0 : resets to default, = 0.0 : ignored)
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-      AliceInp << setprecision(2);
-      AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-      AliceInp << setprecision(1);
-      AliceInp << setw(10) << 1.0;  // step length in assigning indices
-      AliceInp << setw(8) << "PHOT-THR"; 
-      AliceInp << endl;
-
-BOTH:
-    k = 0;
+    BOTH:
+       k = 0;
     } // end of if for PAIR
+      
+      
+      
+      // bremsstrahlung
+      // G3 default value: 1
+      // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
+      //               G4MuBremsstrahlung/G4IMuBremsstrahlung,
+      //               G4LowEnergyBremstrahlung
+      // Particles: e-/e+; mu+/mu-
+      // Physics:   EM
+      // flag = 0 no bremsstrahlung
+      // flag = 1 bremsstrahlung, photon processed
+      // flag = 2 bremsstrahlung, no photon stored
+      // gMC ->SetProcess("BREM",1); // PAIRBREM  2.   0.  0. 3. lastmat
+      // EMFCUT   -1.   0.  0. 3. lastmat 0. ELPO-THR
+      else if (strncmp(&fProcessFlag[i][0],"BREM",4) == 0) {
+         for (j = 0; j < fNbOfProc; j++) {
+             if ((strncmp(&fProcessFlag[j][0],"PAIR",4) == 0) && 
+                 fProcessValue[j] == 1 &&
+                 (fProcessMedium[j] == fProcessMedium[i])) goto NOBREM;
+         }
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2) { 
+             fprintf(pAliceInp,"*\n*Bremsstrahlung by muons and charged hadrons is activated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)\n");
+             fprintf(pAliceInp,"*Energy threshold set by call SetCut('BCUTM',cut) or set to 0.\n");
+             // two = bremsstrahlung by muons and charged hadrons is activated
+             // zero = no meaning
+             // muon and hadron bremsstrahlung
+             // G4 particles: "gamma"
+             // G3 default value: CUTGAM=0.001 GeV
+             //gMC ->SetCut("BCUTM",cut);  // cut for muon and hadron bremsstrahlung
+             fCut = 0.0;
+             for (j=0; j<fNbOfCut; j++) {
+                 if (strncmp(&fCutFlag[j][0],"BCUTM",5) == 0 &&
+                     (fCutMedium[j] == fProcessMedium[i])) fCut = fCutValue[j];
+             }
+             // fCut = photon energy threshold (GeV) for explicit bremsstrahlung production
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"PAIRBREM  %10.1f%10.1f%10.4g%10.1f%10.1f\n",two,zero,fCut,matMin,matMax);
+             
+             // for e+ and e-
+             fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0.\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',1);");
+             // - one = kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             //"ELPO-THR"; 
+             fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fELPO-THR\n",-one,zero,zero,matMin,matMax,one);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No bremsstrahlung - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('BREM',0)\n");
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('BREM',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      NOBREM:
+         j = 0;
+      } // end of else if (strncmp(&fProcessFlag[i][0],"BREM",4) == 0)
+      
+      // Cerenkov photon generation
+      // G3 default value: 0
+      // G4 process: G4Cerenkov
+      // 
+      // Particles: charged
+      // Physics:   Optical
+      // flag = 0 no Cerenkov photon generation
+      // flag = 1 Cerenkov photon generation
+      // flag = 2 Cerenkov photon generation with primary stopped at each step
+      //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
+      
+      else if (strncmp(&fProcessFlag[i][0],"CKOV",4) == 0) {
+         if ((fProcessValue[i] == 1 || fProcessValue[i] == 2) && global) {
+             // Write comments
+             fprintf(pAliceInp, "* \n"); 
+             fprintf(pAliceInp, "*Cerenkov photon generation\n"); 
+             fprintf(pAliceInp, "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)\n"); 
+             // Loop over media 
+             for (Int_t im = 0; im < nmaterial; im++)
+             {
+                 TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
+                 Int_t idmat = material->GetIndex();
+
+                 if (!global && idmat != fProcessMedium[i]) continue;
+                 
+                 fMaterials[idmat] = im;
+                 // Skip media with no Cerenkov properties
+                 TFlukaCerenkov* cerenkovProp;
+                 if (!(cerenkovProp = dynamic_cast<TFlukaCerenkov*>(material->GetCerenkovProperties()))) continue;
+                 //
+                 // This medium has Cerenkov properties 
+                 //
+                 //
+                 // Write OPT-PROD card for each medium 
+                 Float_t  emin  = cerenkovProp->GetMinimumEnergy();
+                 Float_t  emax  = cerenkovProp->GetMaximumEnergy();          
+                 fprintf(pAliceInp, "OPT-PROD  %10.4g%10.4g%10.4g%10.4g%10.4g%10.4gCERENKOV\n", emin, emax, 0., 
+                         Float_t(idmat), Float_t(idmat), 0.); 
+                 //
+                 // Write OPT-PROP card for each medium 
+                 // Forcing FLUKA to call user routines (queffc.cxx, rflctv.cxx, rfrndx.cxx)
+                 //
+                 fprintf(pAliceInp, "OPT-PROP  %10.4g%10.4g%10.4g%10.1f%10.1f%10.1fWV-LIMIT\n",  
+                         cerenkovProp->GetMinimumWavelength(),
+                         cerenkovProp->GetMaximumWavelength(), 
+                         cerenkovProp->GetMaximumWavelength(), 
+                         Float_t(idmat), Float_t(idmat), 0.0);
+                 
+                 if (cerenkovProp->IsMetal()) {
+                     fprintf(pAliceInp, "OPT-PROP  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fMETAL\n",  
+                             -100., -100., -100., 
+                             Float_t(idmat), Float_t(idmat), 0.0);
+                 } else {
+                     fprintf(pAliceInp, "OPT-PROP  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f\n",  
+                             -100., -100., -100., 
+                             Float_t(idmat), Float_t(idmat), 0.0);
+                 }
+                 
+                 
+                 for (Int_t j = 0; j < 3; j++) {
+                     fprintf(pAliceInp, "OPT-PROP  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1f&\n",  
+                             -100., -100., -100., 
+                             Float_t(idmat), Float_t(idmat), 0.0);
+                 }
+                 // Photon detection efficiency user defined
+                 
+                 if (cerenkovProp->IsSensitive())
+                     fprintf(pAliceInp, "OPT-PROP  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fSENSITIV\n",  
+                             -100., -100., -100., 
+                             Float_t(idmat), Float_t(idmat), 0.0);
+                 
+             } // materials
+         } else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No Cerenkov photon generation\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('CKOV',0)\n");
+             // zero = not used
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             //"CERE-OFF"; 
+             fprintf(pAliceInp,"OPT-PROD  %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fCERE-OFF\n",zero,zero,zero,matMin,matMax,one);
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('CKOV',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"CKOV",4) == 0)
+      
+      // Compton scattering
+      // G3 default value: 1
+      // G4 processes: G4ComptonScattering,
+      //               G4LowEnergyCompton,
+      //               G4PolarizedComptonScattering
+      // Particles: gamma
+      // Physics:   EM
+      // flag = 0 no Compton scattering
+      // flag = 1 Compton scattering, electron processed
+      // flag = 2 Compton scattering, no electron stored
+      // gMC ->SetProcess("COMP",1); // EMFCUT   -1.   0.  0. 3. lastmat 0. PHOT-THR
+      else if (strncmp(&fProcessFlag[i][0],"COMP",4) == 0) {
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2) { 
+             fprintf(pAliceInp,"*\n*Energy threshold (GeV) for Compton scattering - resets to default=0.\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('COMP',1);\n");
+             // - one = energy threshold (GeV) for Compton scattering - resets to default=0.
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             //"PHOT-THR"; 
+             fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",-one,zero,zero,matMin,matMax,one);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No Compton scattering - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('COMP',0)\n");
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('COMP',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"COMP",4) == 0)
+      
+      // decay
+      // G3 default value: 1
+      // G4 process: G4Decay
+      // 
+      // Particles: all which decay is applicable for
+      // Physics:   General
+      // flag = 0 no decays
+      // flag = 1 decays, secondaries processed
+      // flag = 2 decays, no secondaries stored
+      //gMC ->SetProcess("DCAY",1); // not available
+      else if ((strncmp(&fProcessFlag[i][0],"DCAY",4) == 0) && fProcessValue[i] == 1) 
+         cout << "SetProcess for flag=" << &fProcessFlag[i][0] << " value=" << fProcessValue[i] << " not avaliable!" << endl;
+      
+      // delta-ray
+      // G3 default value: 2
+      // !! G4 treats delta rays in different way
+      // G4 processes: G4eIonisation/G4IeIonization,
+      //               G4MuIonisation/G4IMuIonization,
+      //               G4hIonisation/G4IhIonisation
+      // Particles: charged
+      // Physics:   EM
+      // flag = 0 no energy loss
+      // flag = 1 restricted energy loss fluctuations
+      // flag = 2 complete energy loss fluctuations
+      // flag = 3 same as 1
+      // flag = 4 no energy loss fluctuations
+      // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0.  0. 3. lastmat 0.
+      else if (strncmp(&fProcessFlag[i][0],"DRAY",4) == 0) {
+         if (fProcessValue[i] == 0 || fProcessValue[i] == 4) {
+             fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)\n");
+             fprintf(pAliceInp,"*No delta ray production by muons - threshold set artificially high\n");
+             Double_t emin = 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
+             // zero = ignored
+             // zero = ignored
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             fprintf(pAliceInp,"DELTARAY  %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",emin,zero,zero,matMin,matMax,one);
+         }
+         else if (fProcessValue[i] == 1 || fProcessValue[i] == 2 || fProcessValue[i] == 3) {
+             fprintf(pAliceInp,"*\n*Kinetic energy threshold (GeV) for delta ray production\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('DRAY',flag), flag=1,2,3\n");
+             fprintf(pAliceInp,"*Delta ray production by muons switched on\n");
+             fprintf(pAliceInp,"*Energy threshold set by call SetCut('DCUTM',cut) or set to 1.0e+6.\n");
+             fCut = 1.0e+6;
+             for (j = 0; j < fNbOfCut; j++) {
+                 if (strncmp(&fCutFlag[j][0],"DCUTM",5) == 0 &&
+                     fCutMedium[j] == fProcessMedium[i]) fCut = fCutValue[j];
+             }
+             // fCut = kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
+             // zero = ignored
+             // zero = ignored
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax =  upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             fprintf(pAliceInp,"DELTARAY  %10.4g%10.1f%10.1f%10.1f%10.1f%10.1f\n",fCut,zero,zero,matMin,matMax,one);
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('DRAY',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"DRAY",4) == 0)
+      
+      // hadronic process
+      // G3 default value: 1
+      // G4 processes: all defined by TG4PhysicsConstructorHadron
+      //  
+      // Particles: hadrons
+      // Physics:   Hadron
+      // flag = 0 no multiple scattering
+      // flag = 1 hadronic interactions, secondaries processed
+      // flag = 2 hadronic interactions, no secondaries stored
+      // gMC ->SetProcess("HADR",1); // ??? hadronic process
+      //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
+      else if (strncmp(&fProcessFlag[i][0],"HADR",4) == 0) {
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2) {
+             fprintf(pAliceInp,"*\n*Hadronic interaction is ON by default in FLUKA\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*Hadronic interaction is set OFF\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('HADR',0);\n");
+             // zero = ignored
+             // three = multiple scattering for hadrons and muons is completely suppressed
+             // zero = no spin-relativistic corrections
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"MULSOPT   %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,zero,matMin,matMax);
+             
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('HADR',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"HADR",4) == 0)
+      
+      
+      // energy loss
+      // G3 default value: 2
+      // G4 processes: G4eIonisation/G4IeIonization,
+      //               G4MuIonisation/G4IMuIonization,
+      //               G4hIonisation/G4IhIonisation
+      // 
+      // Particles: charged
+      // Physics:   EM
+      // flag=0 no energy loss
+      // flag=1 restricted energy loss fluctuations
+      // flag=2 complete energy loss fluctuations
+      // flag=3 same as 1
+      // flag=4 no energy loss fluctuations
+      // If the value ILOSS is changed, then (in G3) cross-sections and energy
+      // loss tables must be recomputed via the command 'PHYSI'
+      // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
+      else if (strncmp(&fProcessFlag[i][0],"LOSS",4) == 0) {
+         if (fProcessValue[i] == 2) { // complete energy loss fluctuations
+             fprintf(pAliceInp,"*\n*Complete energy loss fluctuations do not exist in FLUKA\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('LOSS',2);\n");
+             fprintf(pAliceInp,"*flag=2=complete energy loss fluctuations\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+         else if (fProcessValue[i] == 1 || fProcessValue[i] == 3) { // restricted energy loss fluctuations
+             fprintf(pAliceInp,"*\n*Restricted energy loss fluctuations\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)\n");
+             // one = restricted energy loss fluctuations (for hadrons and muons) switched on
+             // one = restricted energy loss fluctuations (for e+ and e-) switched on
+             // one = minimal accuracy
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"IONFLUCT  %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
+         }
+         else if (fProcessValue[i] == 4) { // no energy loss fluctuations
+             fprintf(pAliceInp,"*\n*No energy loss fluctuations\n");
+             fprintf(pAliceInp,"*\n*Generated from call: SetProcess('LOSS',4)\n");
+             // - one = restricted energy loss fluctuations (for hadrons and muons) switched off
+             // - one = restricted energy loss fluctuations (for e+ and e-) switched off
+             // one = minimal accuracy
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"IONFLUCT  %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,-one,one,matMin,matMax);
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('LOSS',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"LOSS",4) == 0)
+      
+      
+      // multiple scattering
+      // G3 default value: 1
+      // G4 process: G4MultipleScattering/G4IMultipleScattering
+      // 
+      // Particles: charged
+      // Physics:   EM
+      // flag = 0 no multiple scattering
+      // flag = 1 Moliere or Coulomb scattering
+      // flag = 2 Moliere or Coulomb scattering
+      // flag = 3 Gaussian scattering
+      // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
+      else if (strncmp(&fProcessFlag[i][0],"MULS",4) == 0) {
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2 || fProcessValue[i] == 3) {
+             fprintf(pAliceInp,"*\n*Multiple scattering is ON by default for e+e- and for hadrons/muons\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*Multiple scattering is set OFF\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('MULS',0);\n");
+             // zero = ignored
+             // three = multiple scattering for hadrons and muons is completely suppressed
+             // three = multiple scattering for e+ and e- is completely suppressed
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"MULSOPT   %10.1f%10.1f%10.1f%10.1f%10.1f\n",zero,three,three,matMin,matMax);
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('MULS',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"MULS",4) == 0)
+      
 
-
-
-    // bremsstrahlung
-    // G3 default value: 1
-    // G4 processes: G4eBremsstrahlung/G4IeBremsstrahlung,
-    //               G4MuBremsstrahlung/G4IMuBremsstrahlung,
-    //               G4LowEnergyBremstrahlung
-    // Particles: e-/e+; mu+/mu-
-    // Physics:   EM
-    // flag = 0 no bremsstrahlung
-    // flag = 1 bremsstrahlung, photon processed
-    // flag = 2 bremsstrahlung, no photon stored
-    // gMC ->SetProcess("BREM",1); // PAIRBREM  2.   0.  0. 3. lastmat
-                                 // EMFCUT   -1.   0.  0. 3. lastmat 0. ELPO-THR
-    else if (strncmp(&sProcessFlag[i][0],"BREM",4) == 0) {
-      for (j=0; j<iNbOfProc; j++) {
-        if ((strncmp(&sProcessFlag[j][0],"PAIR",4) == 0) && iProcessValue[j] == 1) goto NOBREM;
-      }
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { 
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Bremsstrahlung by muons and charged hadrons is activated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('BREM',1) or SetProcess('BREM',2)"; 
-        AliceInp << endl;
-        AliceInp << "*Energy threshold set by call SetCut('BCUTM',cut) or set to 0."; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "PAIRBREM  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 2.0; // bremsstrahlung by muons and charged hadrons is activated
-        AliceInp << setw(10) << 0.0; // no meaning
-        // muon and hadron bremsstrahlung
-        // G4 particles: "gamma"
-        // G3 default value: CUTGAM=0.001 GeV
-        //gMC ->SetCut("BCUTM",cut);  // cut for muon and hadron bremsstrahlung
-        fCut = 0.0;
-        for (j=0; j<iNbOfCut; j++) {
-          if (strncmp(&sCutFlag[j][0],"BCUTM",5) == 0) fCut = fCutValue[j];
-        }
-        AliceInp << setw(10) << fCut; // photon energy threshold (GeV) for explicit bremsstrahlung production
-        AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
-        // for e+ and e-
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Kinetic energy threshold (GeV) for e+/e- bremsstrahlung - resets to default=0."; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('BREM',1);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "EMFCUT    "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << -1.0; // kinetic energy threshold (GeV) for e+/e- bremsstrahlung (resets to default=0)
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << setw(8)  << "ELPO-THR"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No bremsstrahlung - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('BREM',0)"; 
-        AliceInp << endl;
-      }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('BREM',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+      // muon nuclear interaction
+      // G3 default value: 0
+      // G4 processes: G4MuNuclearInteraction,
+      // G4MuonMinusCaptureAtRest
+      // 
+      // Particles: mu
+      // Physics:   Not set
+      // flag = 0 no muon-nuclear interaction
+      // flag = 1 nuclear interaction, secondaries processed
+      // flag = 2 nuclear interaction, secondaries not processed
+      // gMC ->SetProcess("MUNU",1); // MUPHOTON  1.   0.  0. 3. lastmat
+      else if (strncmp(&fProcessFlag[i][0],"MUNU",4) == 0) {
+         if (fProcessValue[i] == 1) {
+             fprintf(pAliceInp,"*\n*Muon nuclear interactions with production of secondary hadrons\n");
+             fprintf(pAliceInp,"*\n*Generated from call: SetProcess('MUNU',1);\n");
+             // one = full simulation of muon nuclear interactions and production of secondary hadrons
+             // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
+             // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"MUPHOTON  %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
+         }
+         else if (fProcessValue[i] == 2) {
+             fprintf(pAliceInp,"*\n*Muon nuclear interactions without production of secondary hadrons\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('MUNU',2);\n");
+             // two = full simulation of muon nuclear interactions and production of secondary hadrons
+             // zero = ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
+             // zero = fraction of rho-like interactions ( must be < 1) - Default = 0.75.
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"MUPHOTON  %10.1f%10.1f%10.1f%10.1f%10.1f\n",two,zero,zero,matMin,matMax);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No muon nuclear interaction - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('MUNU',0)\n");
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('MUNU',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"MUNU",4) == 0)
+      
+      
+      // photofission
+      // G3 default value: 0
+      // G4 process: ??
+      //
+      // Particles: gamma
+      // Physics:   ??
+      // gMC ->SetProcess("PFIS",0); // PHOTONUC -1.   0.  0. 3. lastmat 0.
+      // flag = 0 no photon fission
+      // flag = 1 photon fission, secondaries processed
+      // flag = 2 photon fission, no secondaries stored
+      else if (strncmp(&fProcessFlag[i][0],"PFIS",4) == 0) {
+         if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No photonuclear interactions\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',0);\n");
+             // - one = no photonuclear interactions
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"PHOTONUC  %10.1f%10.1f%10.1f%10.1f%10.1f\n",-one,zero,zero,matMin,matMax);
+         }
+         else if (fProcessValue[i] == 1) {
+             fprintf(pAliceInp,"*\n*Photon nuclear interactions are activated at all energies\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',1);\n");
+             // one = photonuclear interactions are activated at all energies
+             // zero = not used
+             // zero = not used
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"PHOTONUC  %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,zero,zero,matMin,matMax);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No photofission - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('PFIS',0)\n");
+         }
+         else {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('PFIS',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
       }
-NOBREM:
-      j = 0;
-    } // end of else if (strncmp(&sProcessFlag[i][0],"BREM",4) == 0)
 
-    
-    // Cerenkov photon generation
-    // G3 default value: 0
-    // G4 process: G4Cerenkov
-    // 
-    // Particles: charged
-    // Physics:   Optical
-    // flag = 0 no Cerenkov photon generation
-    // flag = 1 Cerenkov photon generation
-    // flag = 2 Cerenkov photon generation with primary stopped at each step
-    //xx gMC ->SetProcess("CKOV",1); // ??? Cerenkov photon generation
-    else if (strncmp(&sProcessFlag[i][0],"CKOV",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { 
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Cerenkov photon generation"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('CKOV',1) or SetProcess('CKOV',2)"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "OPT-PROD  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setw(10) <<  2.07e-9 ; //  minimum Cerenkov photon emission energy (in GeV!). Default: 2.07E-9 GeV (corresponding to 600 nm)
-        AliceInp << setw(10) << 4.96e-9;  // maximum Cerenkov photon emission energy (in GeV!). Default: 4.96E-9 GeV (corresponding to 250 nm)
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << setw(8) << "CERENKOV"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No Cerenkov photon generation"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('CKOV',0)"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "OPT-PROD  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << setw(8) << "CERE-OFF"; 
-        AliceInp << endl;
+      // photo electric effect
+      // G3 default value: 1
+      // G4 processes: G4PhotoElectricEffect
+      //               G4LowEnergyPhotoElectric
+      // Particles: gamma
+      // Physics:   EM
+      // flag = 0 no photo electric effect
+      // flag = 1 photo electric effect, electron processed
+      // flag = 2 photo electric effect, no electron stored
+      // gMC ->SetProcess("PHOT",1); // EMFCUT    0.  -1.  0. 3. lastmat 0. PHOT-THR
+      else if (strncmp(&fProcessFlag[i][0],"PHOT",4) == 0) {
+         if (fProcessValue[i] == 1 || fProcessValue[i] == 2) {
+             fprintf(pAliceInp,"*\n*Photo electric effect is activated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('PHOT',1);\n");
+             // zero = ignored
+             // - one = resets to default=0.
+             // zero = ignored
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             // one = step length in assigning indices
+             //"PHOT-THR"; 
+             fprintf(pAliceInp,"EMFCUT    %10.1f%10.1f%10.1f%10.1f%10.1f%10.1fPHOT-THR\n",zero,-one,zero,matMin,matMax,one);
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*No photo electric effect - no FLUKA card generated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('PHOT',0)\n");
+         }
+         else {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('PHOT',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // else if (strncmp(&fProcessFlag[i][0],"PHOT",4) == 0)
+      
+      
+      // Rayleigh scattering
+      // G3 default value: 0
+      // G4 process: G4OpRayleigh
+      // 
+      // Particles: optical photon
+      // Physics:   Optical
+      // flag = 0 Rayleigh scattering off
+      // flag = 1 Rayleigh scattering on
+      //xx gMC ->SetProcess("RAYL",1);
+      else if (strncmp(&fProcessFlag[i][0],"RAYL",4) == 0) {
+         if (fProcessValue[i] == 1) {
+             fprintf(pAliceInp,"*\n*Rayleigh scattering is ON by default in FLUKA\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+         else if (fProcessValue[i] == 0) {
+             fprintf(pAliceInp,"*\n*Rayleigh scattering is set OFF\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('RAYL',0);\n");
+             // - one = no Rayleigh scattering and no binding corrections for Compton
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"EMFRAY    %10.1f%10.1f%10.1f%10.1f\n",-one,three,matMin,matMax);
+         }
+         else  {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('RAYL',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // end of else if (strncmp(&fProcessFlag[i][0],"RAYL",4) == 0)
+      
+      
+      // synchrotron radiation in magnetic field
+      // G3 default value: 0
+      // G4 process: G4SynchrotronRadiation
+      // 
+      // Particles: ??
+      // Physics:   Not set
+      // flag = 0 no synchrotron radiation
+      // flag = 1 synchrotron radiation
+      //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
+      else if (strncmp(&fProcessFlag[i][0],"SYNC",4) == 0) {
+         fprintf(pAliceInp,"*\n*Synchrotron radiation generation is NOT implemented in FLUKA\n");
+         fprintf(pAliceInp,"*No FLUKA card generated\n");
       }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('CKOV',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+      
+      
+      // Automatic calculation of tracking medium parameters
+      // flag = 0 no automatic calculation
+      // flag = 1 automatic calculation
+      //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
+      else if (strncmp(&fProcessFlag[i][0],"AUTO",4) == 0) {
+         fprintf(pAliceInp,"*\n*Automatic calculation of tracking medium parameters is always ON in FLUKA\n");
+         fprintf(pAliceInp,"*No FLUKA card generated\n");
       }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"CKOV",4) == 0)
-           
+      
+      
+      // To control energy loss fluctuation model
+      // flag = 0 Urban model
+      // flag = 1 PAI model
+      // flag = 2 PAI+ASHO model (not active at the moment)
+      //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
+      else if (strncmp(&fProcessFlag[i][0],"STRA",4) == 0) {
+         if (fProcessValue[i] == 0 || fProcessValue[i] == 2 || fProcessValue[i] == 3) {
+             fprintf(pAliceInp,"*\n*Ionization energy losses calculation is activated\n");
+             fprintf(pAliceInp,"*Generated from call: SetProcess('STRA',n);, n=0,1,2\n");
+             // one = restricted energy loss fluctuations (for hadrons and muons) switched on
+             // one = restricted energy loss fluctuations (for e+ and e-) switched on
+             // one = minimal accuracy
+             // matMin = lower bound of the material indices in which the respective thresholds apply
+             // matMax = upper bound of the material indices in which the respective thresholds apply
+             fprintf(pAliceInp,"IONFLUCT  %10.1f%10.1f%10.1f%10.1f%10.1f\n",one,one,one,matMin,matMax);
+         }
+         else {
+             fprintf(pAliceInp,"*\n*Illegal flag value in SetProcess('STRA',?) call.\n");
+             fprintf(pAliceInp,"*No FLUKA card generated\n");
+         }
+      } // else if (strncmp(&fProcessFlag[i][0],"STRA",4) == 0)
+      
 
-    // Compton scattering
-    // G3 default value: 1
-    // G4 processes: G4ComptonScattering,
-    //               G4LowEnergyCompton,
-    //               G4PolarizedComptonScattering
-    // Particles: gamma
-    // Physics:   EM
-    // flag = 0 no Compton scattering
-    // flag = 1 Compton scattering, electron processed
-    // flag = 2 Compton scattering, no electron stored
-    // gMC ->SetProcess("COMP",1); // EMFCUT   -1.   0.  0. 3. lastmat 0. PHOT-THR
-    else if (strncmp(&sProcessFlag[i][0],"COMP",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) { 
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Energy threshold (GeV) for Compton scattering - resets to default=0."; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('COMP',1);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "EMFCUT    "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << -1.0; // energy threshold (GeV) for Compton scattering - resets to default=0.
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << setw(8) << "PHOT-THR"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No Compton scattering - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('COMP',0)"; 
-        AliceInp << endl;
-      }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('COMP',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"COMP",4) == 0)
 
-    // decay
-    // G3 default value: 1
-    // G4 process: G4Decay
-    // 
-    // Particles: all which decay is applicable for
-    // Physics:   General
-    // flag = 0 no decays
-    // flag = 1 decays, secondaries processed
-    // flag = 2 decays, no secondaries stored
-    //gMC ->SetProcess("DCAY",1); // not available
-    else if ((strncmp(&sProcessFlag[i][0],"DCAY",4) == 0) && iProcessValue[i] == 1) 
-      cout << "SetProcess for flag=" << &sProcessFlag[i][0] << " value=" << iProcessValue[i] << " not avaliable!" << endl;
-      
-    // delta-ray
-    // G3 default value: 2
-    // !! G4 treats delta rays in different way
-    // G4 processes: G4eIonisation/G4IeIonization,
-    //               G4MuIonisation/G4IMuIonization,
-    //               G4hIonisation/G4IhIonisation
-    // Particles: charged
-    // Physics:   EM
-    // flag = 0 no energy loss
-    // flag = 1 restricted energy loss fluctuations
-    // flag = 2 complete energy loss fluctuations
-    // flag = 3 same as 1
-    // flag = 4 no energy loss fluctuations
-    // gMC ->SetProcess("DRAY",0); // DELTARAY 1.E+6 0.  0. 3. lastmat 0.
-    else if (strncmp(&sProcessFlag[i][0],"DRAY",4) == 0) {
-      if (iProcessValue[i] == 0 || iProcessValue[i] == 4) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Kinetic energy threshold (GeV) for delta ray production"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('DRAY',0) or SetProcess('DRAY',4)"; 
-        AliceInp << endl;
-        AliceInp << "*No delta ray production by muons - threshold set artificially high"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "DELTARAY  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setw(10) << 1.0e+6; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0; // ignored
-        AliceInp << setw(10) << 0.0; // ignored
-        AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 1 || iProcessValue[i] == 2 || iProcessValue[i] == 3) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Kinetic energy threshold (GeV) for delta ray production"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('DRAY',flag), flag=1,2,3"; 
-        AliceInp << endl;
-        AliceInp << "*Delta ray production by muons switched on"; 
-        AliceInp << endl;
-        AliceInp << "*Energy threshold set by call SetCut('DCUTM',cut) or set to 0."; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "DELTARAY  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        fCut = 1.0e+6;
-        for (j=0; j<iNbOfCut; j++) {
-          if (strncmp(&sCutFlag[j][0],"DCUTM",5) == 0) fCut = fCutValue[j];
-        }
-        AliceInp << setw(10) << fCut; // kinetic energy threshold (GeV) for delta ray production (discrete energy transfer)
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0; // ignored
-        AliceInp << setw(10) << 0.0; // ignored
-        AliceInp << setw(10) << 3.0; // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << endl;
-      }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('DRAY',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"DRAY",4) == 0)
-    
-    // hadronic process
-    // G3 default value: 1
-    // G4 processes: all defined by TG4PhysicsConstructorHadron
-    //  
-    // Particles: hadrons
-    // Physics:   Hadron
-    // flag = 0 no multiple scattering
-    // flag = 1 hadronic interactions, secondaries processed
-    // flag = 2 hadronic interactions, no secondaries stored
-    // gMC ->SetProcess("HADR",1); // ??? hadronic process
-    //Select pure GEANH (HADR 1) or GEANH/NUCRIN (HADR 3) ?????
-    else if (strncmp(&sProcessFlag[i][0],"HADR",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Hadronic interaction is ON by default in FLUKA"; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Hadronic interaction is set OFF"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('HADR',0);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "MULSOPT  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0;  // ignored
-        AliceInp << setw(10) << 3.0;  // multiple scattering for hadrons and muons is completely suppressed
-        AliceInp << setw(10) << 0.0;  // no spin-relativistic corrections
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
 
-      }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('HADR',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"HADR",4) == 0)
+      else { // processes not yet treated
+         
+         // light photon absorption (Cerenkov photons)
+         // it is turned on when Cerenkov process is turned on
+         // G3 default value: 0
+         // G4 process: G4OpAbsorption, G4OpBoundaryProcess
+         // 
+         // Particles: optical photon
+         // Physics:   Optical
+         // flag = 0 no absorption of Cerenkov photons
+         // flag = 1 absorption of Cerenkov photons
+         // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
+         
 
 
-    // energy loss
-    // G3 default value: 2
-    // G4 processes: G4eIonisation/G4IeIonization,
-    //               G4MuIonisation/G4IMuIonization,
-    //               G4hIonisation/G4IhIonisation
-    // 
-    // Particles: charged
-    // Physics:   EM
-    // flag=0 no energy loss
-    // flag=1 restricted energy loss fluctuations
-    // flag=2 complete energy loss fluctuations
-    // flag=3 same as 1
-    // flag=4 no energy loss fluctuations
-    // If the value ILOSS is changed, then (in G3) cross-sections and energy
-    // loss tables must be recomputed via the command 'PHYSI'
-    // gMC ->SetProcess("LOSS",2); // ??? IONFLUCT ? energy loss
-    else if (strncmp(&sProcessFlag[i][0],"LOSS",4) == 0) {
-      if (iProcessValue[i] == 2) { // complete energy loss fluctuations
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Complete energy loss fluctuations do not exist in FLUKA"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('LOSS',2);"; 
-        AliceInp << endl;
-        AliceInp << "*flag=2=complete energy loss fluctuations"; 
-        AliceInp << endl;
-        AliceInp << "*No input card generated"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 1 || iProcessValue[i] == 3) { // restricted energy loss fluctuations
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Restricted energy loss fluctuations"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('LOSS',1) or SetProcess('LOSS',3)"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "IONFLUCT  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // restricted energy loss fluctuations (for hadrons and muons) switched on
-        AliceInp << setw(10) << 1.0;  // restricted energy loss fluctuations (for e+ and e-) switched on
-        AliceInp << setw(10) << 1.0;  // minimal accuracy
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 4) { // no energy loss fluctuations
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No energy loss fluctuations"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('LOSS',4)"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << -1.0;  // restricted energy loss fluctuations (for hadrons and muons) switched off
-        AliceInp << setw(10) << -1.0;  // restricted energy loss fluctuations (for e+ and e-) switched off
-        AliceInp << setw(10) << 1.0;  // minimal accuracy
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
+         cout << "SetProcess for flag=" << &fProcessFlag[i][0] << " value=" << fProcessValue[i] << " not yet implemented!" << endl;
       }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('LOSS',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"LOSS",4) == 0)
-       
+  } //end of loop number of SetProcess calls
+
  
-    // multiple scattering
-    // G3 default value: 1
-    // G4 process: G4MultipleScattering/G4IMultipleScattering
-    // 
-    // Particles: charged
-    // Physics:   EM
-    // flag = 0 no multiple scattering
-    // flag = 1 Moliere or Coulomb scattering
-    // flag = 2 Moliere or Coulomb scattering
-    // flag = 3 Gaussian scattering
-    // gMC ->SetProcess("MULS",1); // MULSOPT multiple scattering
-    else if (strncmp(&sProcessFlag[i][0],"MULS",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2 || iProcessValue[i] == 3) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Multiple scattering is ON by default for e+e- and for hadrons/muons"; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Multiple scattering is set OFF"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('MULS',0);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "MULSOPT  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0;  // ignored
-        AliceInp << setw(10) << 3.0;  // multiple scattering for hadrons and muons is completely suppressed
-        AliceInp << setw(10) << 3.0;  // multiple scattering for e+ and e- is completely suppressed
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
-      }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('MULS',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-      }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"MULS",4) == 0)
-
-
-    // muon nuclear interaction
-    // G3 default value: 0
-    // G4 processes: G4MuNuclearInteraction,
-    // G4MuonMinusCaptureAtRest
-    // 
-    // Particles: mu
-    // Physics:   Not set
-    // flag = 0 no muon-nuclear interaction
-    // flag = 1 nuclear interaction, secondaries processed
-    // flag = 2 nuclear interaction, secondaries not processed
-    // gMC ->SetProcess("MUNU",1); // MUPHOTON  1.   0.  0. 3. lastmat
-    else if (strncmp(&sProcessFlag[i][0],"MUNU",4) == 0) {
-      if (iProcessValue[i] == 1) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Muon nuclear interactions with production of secondary hadrons"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('MUNU',1);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "MUPHOTON  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // full simulation of muon nuclear interactions and production of secondary hadrons
-        AliceInp << setw(10) << 0.0; // ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
-        AliceInp << setw(10) << 0.0; // fraction of rho-like interactions ( must be < 1) - Default = 0.75.
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 2) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Muon nuclear interactions without production of secondary hadrons"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('MUNU',2);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "MUPHOTON  "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 2.0; // full simulation of muon nuclear interactions and production of secondary hadrons
-        AliceInp << setw(10) << 0.0; // ratio of longitudinal to transverse virtual photon cross-section - Default = 0.25.
-        AliceInp << setw(10) << 0.0; // fraction of rho-like interactions ( must be < 1) - Default = 0.75.
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No muon nuclear interaction - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('MUNU',0)"; 
-        AliceInp << endl;
+// Loop over number of SetCut calls  
+  for (Int_t i = 0; i < fNbOfCut; i++) {
+      Float_t matMin = three;
+      Float_t matMax = fLastMaterial;
+      Bool_t global  = kTRUE;
+      if (fCutMedium[i] != -1) {
+         matMin = Float_t(fCutMedium[i]);
+         matMax = matMin;
+         global = kFALSE;
       }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('MUNU',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+    // cuts handled in SetProcess calls
+      if (strncmp(&fCutFlag[i][0],"BCUTM",5) == 0) continue;
+      else if (strncmp(&fCutFlag[i][0],"BCUTE",5) == 0) continue;
+      else if (strncmp(&fCutFlag[i][0],"DCUTM",5) == 0) continue;
+      else if (strncmp(&fCutFlag[i][0],"PPCUTM",6) == 0) continue;
+      
+      // gammas
+      // G4 particles: "gamma"
+      // G3 default value: 0.001 GeV
+      // gMC ->SetCut("CUTGAM",cut); // cut for gammas
+      
+      else if (strncmp(&fCutFlag[i][0],"CUTGAM",6) == 0 && global) {
+         fprintf(pAliceInp,"*\n*Cut for gamma\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
+         // -fCutValue[i];
+         // 7.0 = lower bound of the particle id-numbers to which the cut-off
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f\n",-fCutValue[i],7.0);
       }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"MUNU",4) == 0)
 
-
-    // photofission
-    // G3 default value: 0
-    // G4 process: ??
-    //
-    // Particles: gamma
-    // Physics:   ??
-    // gMC ->SetProcess("PFIS",0); // PHOTONUC -1.   0.  0. 3. lastmat 0.
-    // flag = 0 no photon fission
-    // flag = 1 photon fission, secondaries processed
-    // flag = 2 photon fission, no secondaries stored
-    else if (strncmp(&sProcessFlag[i][0],"PFIS",4) == 0) {
-      if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No photonuclear interactions";
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('PFIS',0);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "PHOTONUC  "; 
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << -1.0; // no photonuclear interactions
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 0.0;  // not used
-        AliceInp << setw(10) << 3.0;  // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2); 
-        AliceInp << setw(10) << fLastMaterial;
-        AliceInp << setprecision(1);  // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // step length in assigning indices
-        AliceInp << endl;
+      else if (strncmp(&fCutFlag[i][0],"CUTGAM",6) == 0 && !global) {
+         fprintf(pAliceInp,"*\n*Cut specific to  material for gamma\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTGAM',cut);\n");
+         // -fCutValue[i];
+         // 7.0 = lower bound of the particle id-numbers to which the cut-off
+         fprintf(pAliceInp,"EMFCUT    %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", 0., fCutValue[i], zero, matMin, matMax, one);
       }
-      else if (iProcessValue[i] == 1) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Photon nuclear interactions are activated at all energies";
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('PFIS',1);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "PHOTONUC  "; 
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 1.0; // photonuclear interactions are activated at all energies
-        AliceInp << setw(10) << 0.0; // not used
-        AliceInp << setw(10) << 0.0; // not used
-        AliceInp << setprecision(2); 
-        AliceInp << setw(10) << 3.0; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setw(10) << fLastMaterial;
-        AliceInp << setprecision(1); // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0; // step length in assigning indices
-        AliceInp << endl;
-      }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No photofission - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('PFIS',0)"; 
-        AliceInp << endl;
-      }
-      else {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('PFIS',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+      
+      // electrons
+      // G4 particles: "e-"
+      // ?? positrons
+      // G3 default value: 0.001 GeV
+      //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
+      else if (strncmp(&fCutFlag[i][0],"CUTELE",6) == 0 && global) {
+         fprintf(pAliceInp,"*\n*Cut for electrons\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTELE',cut);\n");
+         // -fCutValue[i];
+         // three = lower bound of the particle id-numbers to which the cut-off
+         // 4.0 = upper bound of the particle id-numbers to which the cut-off
+         // one = step length in assigning numbers
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f%10.1f\n",-fCutValue[i],three,4.0,one);
       }
-    }
-
-    // photo electric effect
-    // G3 default value: 1
-    // G4 processes: G4PhotoElectricEffect
-    //               G4LowEnergyPhotoElectric
-    // Particles: gamma
-    // Physics:   EM
-    // flag = 0 no photo electric effect
-    // flag = 1 photo electric effect, electron processed
-    // flag = 2 photo electric effect, no electron stored
-    // gMC ->SetProcess("PHOT",1); // EMFCUT    0.  -1.  0. 3. lastmat 0. PHOT-THR
-    else if (strncmp(&sProcessFlag[i][0],"PHOT",4) == 0) {
-      if (iProcessValue[i] == 1 || iProcessValue[i] == 2) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Photo electric effect is activated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('PHOT',1);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "EMFCUT    "; 
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 0.0;  // ignored
-        AliceInp << setw(10) << -1.0; // resets to default=0.
-        AliceInp << setw(10) << 0.0;  // ignored
-        AliceInp << setw(10) << 3.0;  // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // step length in assigning indices
-        AliceInp << setw(8) << "PHOT-THR"; 
-        AliceInp << endl;
+    
+      else if (strncmp(&fCutFlag[i][0],"CUTELE",6) == 0 && !global) {
+         fprintf(pAliceInp,"*\n*Cut specific to material for electrons\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTELE',cut);\n");
+         // -fCutValue[i];
+         // three = lower bound of the particle id-numbers to which the cut-off
+         // 4.0 = upper bound of the particle id-numbers to which the cut-off
+         // one = step length in assigning numbers
+         fprintf(pAliceInp,"EMFCUT    %10.4g%10.4g%10.1f%10.1f%10.1f%10.1f\n", -fCutValue[i], zero, zero, matMin, matMax, one);
       }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*No photo electric effect - no FLUKA card generated"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('PHOT',0)"; 
-        AliceInp << endl;
+      
+      // neutral hadrons
+      // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
+      // G3 default value: 0.01 GeV
+      //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
+      else if (strncmp(&fCutFlag[i][0],"CUTNEU",6) == 0 && global) {
+         fprintf(pAliceInp,"*\n*Cut for neutral hadrons\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTNEU',cut);\n");
+         
+         // 8.0 = Neutron
+         // 9.0 = Antineutron
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],8.0,9.0);
+         
+         // 12.0 = Kaon zero long
+         // 12.0 = Kaon zero long
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],12.0,12.0);
+         
+         // 17.0 = Lambda, 18.0 = Antilambda
+         // 19.0 = Kaon zero short
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],17.0,19.0);
+         
+         // 22.0 = Sigma zero, Pion zero, Kaon zero
+         // 25.0 = Antikaon zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],22.0,25.0);
+         
+         // 32.0 = Antisigma zero
+         // 32.0 = Antisigma zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],32.0,32.0);
+         
+         // 34.0 = Xi zero
+         // 35.0 = AntiXi zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],34.0,35.0);
+         
+         // 47.0 = D zero
+         // 48.0 = AntiD zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],47.0,48.0);
+         
+         // 53.0 = Xi_c zero
+         // 53.0 = Xi_c zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],53.0,53.0);
+         
+         // 55.0 = Xi'_c zero
+         // 56.0 = Omega_c zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],55.0,56.0);
+         
+         // 59.0 = AntiXi_c zero
+         // 59.0 = AntiXi_c zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],59.0,59.0);
+         
+         // 61.0 = AntiXi'_c zero
+         // 62.0 = AntiOmega_c zero
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],61.0,62.0);
       }
-      else {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('PHOT',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+      
+      // charged hadrons
+      // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
+      // G3 default value: 0.01 GeV
+      //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
+      else if (strncmp(&fCutFlag[i][0],"CUTHAD",6) == 0 && global) {
+         fprintf(pAliceInp,"*\n*Cut for charged hadrons\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTHAD',cut);\n");
+         
+         // 1.0 = Proton
+         // 2.0 = Antiproton
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],1.0,2.0);
+         
+         // 13.0 = Positive Pion, Negative Pion, Positive Kaon
+         // 16.0 = Negative Kaon
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],13.0,16.0);
+         
+         // 20.0 = Negative Sigma
+         // 21.0 = Positive Sigma
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],20.0,21.0);
+         
+         // 31.0 = Antisigma minus
+         // 33.0 = Antisigma plus
+         // 2.0 = step length
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f%10.1f\n",-fCutValue[i],31.0,33.0,2.0);
+         
+         // 36.0 = Negative Xi, Positive Xi, Omega minus
+         // 39.0 = Antiomega
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],36.0,39.0);
+         
+         // 45.0 = D plus
+         // 46.0 = D minus
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],45.0,46.0);
+         
+         // 49.0 = D_s plus, D_s minus, Lambda_c plus
+         // 52.0 = Xi_c plus
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],49.0,52.0);
+         
+         // 54.0 = Xi'_c plus
+         // 60.0 = AntiXi'_c minus
+         // 6.0 = step length
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f%10.1f\n",-fCutValue[i],54.0,60.0,6.0);
+         
+         // 57.0 = Antilambda_c minus
+         // 58.0 = AntiXi_c minus
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],57.0,58.0);
       }
-    } // else if (strncmp(&sProcessFlag[i][0],"PHOT",4) == 0)
-
-
-    // Rayleigh scattering
-    // G3 default value: 0
-    // G4 process: G4OpRayleigh
-    // 
-    // Particles: optical photon
-    // Physics:   Optical
-    // flag = 0 Rayleigh scattering off
-    // flag = 1 Rayleigh scattering on
-    //xx gMC ->SetProcess("RAYL",1);
-    else if (strncmp(&sProcessFlag[i][0],"RAYL",4) == 0) {
-      if (iProcessValue[i] == 1) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Rayleigh scattering is ON by default in FLUKA"; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+
+      // muons
+      // G4 particles: "mu+", "mu-"
+      // G3 default value: 0.01 GeV
+      //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
+      else if (strncmp(&fCutFlag[i][0],"CUTMUO",6)== 0 && global) {
+         fprintf(pAliceInp,"*\n*Cut for muons\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('CUTMUO',cut);\n");
+         // 10.0 = Muon+
+         // 11.0 = Muon-
+         fprintf(pAliceInp,"PART-THR  %10.4g%10.1f%10.1f\n",-fCutValue[i],10.0,11.0);
       }
-      else if (iProcessValue[i] == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Rayleigh scattering is set OFF"; 
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('RAYL',0);"; 
-        AliceInp << endl;
-        AliceInp << setw(10) << "EMFRAY    "; 
-        AliceInp << setiosflags(ios::scientific) << setprecision(5);
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << -1.0;  // no Rayleigh scattering and no binding corrections for Compton
-        AliceInp << setw(10) << 3.0;  // lower bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << endl;
+      
+      // delta-rays by electrons
+      // G4 particles: "e-"
+      // G3 default value: 10**4 GeV
+      // gMC ->SetCut("DCUTE",cut);  // cut for deltarays by electrons ???????????????
+      else if (strncmp(&fCutFlag[i][0],"DCUTE",5) == 0) {
+         fprintf(pAliceInp,"*\n*Cut for delta rays by electrons ????????????\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('DCUTE',cut);\n");
+         // -fCutValue[i];
+         // zero = ignored
+         // zero = ignored
+         // matMin = lower bound of the material indices in which the respective thresholds apply
+         // fLastMaterial = upper bound of the material indices in which the respective thresholds apply
+         fprintf(pAliceInp,"EMFCUT    %10.4g%10.1f%10.1f%10.1f%10.1f\n",-fCutValue[i],zero,zero,matMin,matMax);
+         fprintf(pAliceInp,"DELTARAY  %10.4g%10.3f%10.3f%10.1f%10.1f%10.1f\n",fCutValue[i], 100., 1.03, matMin, matMax, 1.0);
+         fprintf(pAliceInp,"STEPSIZE  %10.4g%10.3f%10.3f%10.1f%10.1f\n", 0.1, 1.0, 1.00, 
+                 Float_t(gGeoManager->GetListOfUVolumes()->GetEntriesFast()-1), 1.0);
       }
-      else  {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('RAYL',?) call."; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
+    
+      //
+      // time of flight cut in seconds
+      // G4 particles: all
+      // G3 default value: 0.01 GeV
+      //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
+      else if (strncmp(&fCutFlag[i][0],"TOFMAX",6) == 0) {
+         fprintf(pAliceInp,"*\n*Time of flight cuts in seconds\n");
+         fprintf(pAliceInp,"*Generated from call: SetCut('TOFMAX',tofmax);\n");
+         // zero = ignored
+         // zero = ignored
+         // -6.0 = lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
+         // 64.0 = upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
+         fprintf(pAliceInp,"TIME-CUT  %10.4g%10.1f%10.1f%10.1f%10.1f\n",fCutValue[i]*1.e9,zero,zero,-6.0,64.0);
       }
-    } // end of else if (strncmp(&sProcessFlag[i][0],"RAYL",4) == 0)
-
-
-    // synchrotron radiation in magnetic field
-    // G3 default value: 0
-    // G4 process: G4SynchrotronRadiation
-    // 
-    // Particles: ??
-    // Physics:   Not set
-    // flag = 0 no synchrotron radiation
-    // flag = 1 synchrotron radiation
-    //xx gMC ->SetProcess("SYNC",1); // synchrotron radiation generation
-    else if (strncmp(&sProcessFlag[i][0],"SYNC",4) == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Synchrotron radiation generation is NOT implemented in FLUKA"; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-    }
-       
-
-    // Automatic calculation of tracking medium parameters
-    // flag = 0 no automatic calculation
-    // flag = 1 automatic calculation
-    //xx gMC ->SetProcess("AUTO",1); // ??? automatic computation of the tracking medium parameters
-    else if (strncmp(&sProcessFlag[i][0],"AUTO",4) == 0) {
-        AliceInp << "*"; 
-        AliceInp << endl;
-        AliceInp << "*Automatic calculation of tracking medium parameters is always ON in FLUKA"; 
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated"; 
-        AliceInp << endl;
-    }
-       
-
-    // To control energy loss fluctuation model
-    // flag = 0 Urban model
-    // flag = 1 PAI model
-    // flag = 2 PAI+ASHO model (not active at the moment)
-    //xx gMC ->SetProcess("STRA",1); // ??? energy fluctuation model
-    else if (strncmp(&sProcessFlag[i][0],"STRA",4) == 0) {
-      if (iProcessValue[i] == 0 || iProcessValue[i] == 2 || iProcessValue[i] == 3) {
-        AliceInp << "*";
-        AliceInp << endl;
-        AliceInp << "*Ionization energy losses calculation is activated";
-        AliceInp << endl;
-        AliceInp << "*Generated from call: SetProcess('STRA',n);, n=0,1,2";
-        AliceInp << endl;
-        AliceInp << setw(10) << "IONFLUCT  ";
-        AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // restricted energy loss fluctuations
-                                      // (for hadrons and muons) switched on
-        AliceInp << setw(10) << 1.0;  // restricted energy loss fluctuations
-                                      // (for e+ and e-) switched on
-        AliceInp << setw(10) << 1.0;  // minimal accuracy
-        AliceInp << setw(10) << 3.0;  // upper bound of the material indices in
-                                      // which the respective thresholds apply
-        AliceInp << setprecision(2);
-        AliceInp << setw(10) << fLastMaterial; // upper bound of the material indices in which the respective thresholds apply
-        AliceInp << setprecision(1);
-        AliceInp << setw(10) << 1.0;  // step length in assigning indices
-        AliceInp << endl;
+      
+      else if (global){
+         cout << "SetCut for flag=" << &fCutFlag[i][0] << " value=" << fCutValue[i] << " not yet implemented!" << endl;
       }
       else {
-        AliceInp << "*";
-        AliceInp << endl;
-        AliceInp << "*Illegal flag value in SetProcess('STRA',?) call.";
-        AliceInp << endl;
-        AliceInp << "*No FLUKA card generated";
-        AliceInp << endl;
+         cout << "SetCut for flag=" << &fCutFlag[i][0] << " value=" << fCutValue[i] << " (material specific) not yet implemented!" << endl;
       }
-    } // else if (strncmp(&sProcessFlag[i][0],"STRA",4) == 0)
-
-
-
-
-    else { // processes not yet treated
-
-    // light photon absorption (Cerenkov photons)
-    // it is turned on when Cerenkov process is turned on
-    // G3 default value: 0
-    // G4 process: G4OpAbsorption, G4OpBoundaryProcess
-    // 
-    // Particles: optical photon
-    // Physics:   Optical
-    // flag = 0 no absorption of Cerenkov photons
-    // flag = 1 absorption of Cerenkov photons
-    // gMC ->SetProcess("LABS",2); // ??? Cerenkov light absorption
-
-
-
-      cout << "SetProcess for flag=" << &sProcessFlag[i][0] << " value=" << iProcessValue[i] << " not yet implemented!" << endl;
-    }
-  } //end of loop number of SetProcess calls
-
-// Loop over number of SetCut calls  
-  for (Int_t i=0; i<iNbOfCut; i++) {
-
-    // cuts used in SetProcess calls
-    if (strncmp(&sCutFlag[i][0],"BCUTM",5) == 0) continue;
-    else if (strncmp(&sCutFlag[i][0],"BCUTE",5) == 0) continue;
-    else if (strncmp(&sCutFlag[i][0],"DCUTM",5) == 0) continue;
-    else if (strncmp(&sCutFlag[i][0],"PPCUTM",6) == 0) continue;
-
-    // gammas
-    // G4 particles: "gamma"
-    // G3 default value: 0.001 GeV
-    //gMC ->SetCut("CUTGAM",cut); // cut for gammas
-    else if (strncmp(&sCutFlag[i][0],"CUTGAM",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for gamma"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('CUTGAM',cut);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 7.0;
-      AliceInp << endl;
-    }
-
-    // electrons
-    // G4 particles: "e-"
-    // ?? positrons
-    // G3 default value: 0.001 GeV
-    //gMC ->SetCut("CUTELE",cut); // cut for e+,e-
-    else if (strncmp(&sCutFlag[i][0],"CUTELE",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for electrons"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('CUTELE',cut);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 3.0;
-      AliceInp << setw(10) << 4.0;
-      AliceInp << setw(10) << 1.0;
-      AliceInp << endl;
-    }
-
-    // neutral hadrons
-    // G4 particles: of type "baryon", "meson", "nucleus" with zero charge
-    // G3 default value: 0.01 GeV
-    //gMC ->SetCut("CUTNEU",cut); // cut for neutral hadrons
-    else if (strncmp(&sCutFlag[i][0],"CUTNEU",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for neutral hadrons"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('CUTNEU',cut);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 8.0; // Neutron
-      AliceInp << setw(10) << 9.0; // Antineutron
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 12.0; // Kaon zero long
-      AliceInp << setw(10) << 12.0; // Kaon zero long
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 17.0; // Lambda, 18=Antilambda
-      AliceInp << setw(10) << 19.0; // Kaon zero short
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 22.0; // Sigma zero, Pion zero, Kaon zero
-      AliceInp << setw(10) << 25.0; // Antikaon zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 32.0; // Antisigma zero
-      AliceInp << setw(10) << 32.0; // Antisigma zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 34.0; // Xi zero
-      AliceInp << setw(10) << 35.0; // AntiXi zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 47.0; // D zero
-      AliceInp << setw(10) << 48.0; // AntiD zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 53.0; // Xi_c zero
-      AliceInp << setw(10) << 53.0; // Xi_c zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 55.0; // Xi'_c zero
-      AliceInp << setw(10) << 56.0; // Omega_c zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 59.0; // AntiXi_c zero
-      AliceInp << setw(10) << 59.0; // AntiXi_c zero
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 61.0; // AntiXi'_c zero
-      AliceInp << setw(10) << 62.0; // AntiOmega_c zero
-      AliceInp << endl;
-    }
-
-    // charged hadrons
-    // G4 particles: of type "baryon", "meson", "nucleus" with non-zero charge
-    // G3 default value: 0.01 GeV
-    //gMC ->SetCut("CUTHAD",cut); // cut for charged hadrons
-    else if (strncmp(&sCutFlag[i][0],"CUTHAD",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for charged hadrons"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('CUTHAD',cut);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 1.0; // Proton
-      AliceInp << setw(10) << 2.0; // Antiproton
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 13.0; // Positive Pion, Negative Pion, Positive Kaon
-      AliceInp << setw(10) << 16.0; // Negative Kaon
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 20.0; // Negative Sigma
-      AliceInp << setw(10) << 16.0; // Positive Sigma
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 31.0; // Antisigma minus
-      AliceInp << setw(10) << 33.0; // Antisigma plus
-      AliceInp << setprecision(1);
-      AliceInp << setw(10) << 2.0;  // step length
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 36.0; // Negative Xi, Positive Xi, Omega minus
-      AliceInp << setw(10) << 39.0; // Antiomega
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 45.0; // D plus
-      AliceInp << setw(10) << 46.0; // D minus
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 49.0; // D_s plus, D_s minus, Lambda_c plus
-      AliceInp << setw(10) << 52.0; // Xi_c plus
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 54.0; // Xi'_c plus
-      AliceInp << setw(10) << 60.0; // AntiXi'_c minus
-      AliceInp << setprecision(1);
-      AliceInp << setw(10) << 6.0;  // step length
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);
-      AliceInp << setw(10) << 57.0; // Antilambda_c minus
-      AliceInp << setw(10) << 58.0; // AntiXi_c minus
-      AliceInp << endl;
-    }
-
-    // muons
-    // G4 particles: "mu+", "mu-"
-    // G3 default value: 0.01 GeV
-    //gMC ->SetCut("CUTMUO",cut); // cut for mu+, mu-
-    else if (strncmp(&sCutFlag[i][0],"CUTMUO",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for muons"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('CUTMUO',cut);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "PART-THR  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setprecision(2);
-      AliceInp << setw(10) << 10.0;
-      AliceInp << setw(10) << 11.0;
-      AliceInp << endl;
-    }
-    // delta-rays by electrons
-    // G4 particles: "e-"
-    // G3 default value: 10**4 GeV
-    // gMC ->SetCut("DCUTE",cut);  // cut for deltarays by electrons ???????????????
-    else if (strncmp(&sCutFlag[i][0],"DCUTE",5) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Cut for delta rays by electrons ????????????";
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('DCUTE',cut);";
-      AliceInp << endl;
-      AliceInp << setw(10) << "EMFCUT    ";
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << -fCutValue[i];
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 0.0;
-      AliceInp << setw(10) << 0.0;
-      AliceInp << setw(10) << 3.0;
-      AliceInp << setprecision(2);
-      AliceInp << setw(10) << fLastMaterial;
-      AliceInp << setprecision(1);
-      AliceInp << setw(10) << 1.0;
-      AliceInp << endl;
-    }
-    
-    //
-    // time of flight cut in seconds
-    // G4 particles: all
-    // G3 default value: 0.01 GeV
-    //gMC ->SetCut("TOFMAX",tofmax); // time of flight cuts in seconds
-    else if (strncmp(&sCutFlag[i][0],"TOFMAX",6) == 0) {
-      AliceInp << "*"; 
-      AliceInp << endl;
-      AliceInp << "*Time of flight cuts in seconds"; 
-      AliceInp << endl;
-      AliceInp << "*Generated from call: SetCut('TOFMAX',tofmax);"; 
-      AliceInp << endl;
-      AliceInp << setw(10) << "TIME-CUT  "; 
-      AliceInp << setiosflags(ios::scientific) << setprecision(5);
-      AliceInp << setw(10) << fCutValue[i]*1.e9;
-      AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(1);
-      AliceInp << setw(10) << 0.0;
-      AliceInp << setw(10) << 0.0;
-      AliceInp << setw(10) << -6.0; // lower bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
-      AliceInp << setprecision(2);
-      AliceInp << setw(10) << 64.0; // upper bound of the particle numbers for which the transport time cut-off and/or the start signal is to be applied
-      AliceInp << setprecision(1);
-      AliceInp << setw(10) << 1.0; // step length in assigning numbers
-      AliceInp << endl;
-    }
-
-    else {
-      cout << "SetCut for flag=" << &sCutFlag[i][0] << " value=" << fCutValue[i] << " not yet implemented!" << endl;
-    }
-  } //end of loop over SeCut calls
-    
+      
+  } //end of loop over SetCut calls
+  
 // Add START and STOP card
-   AliceInp << setw(10) << "START     "; 
-   AliceInp << setiosflags(ios::fixed) << setiosflags(ios::showpoint);
-   AliceInp << setw(10) << fEventsPerRun;
-   AliceInp << endl;
-   AliceInp << setw(10) << "STOP      "; 
-   AliceInp << endl;
-
+  fprintf(pAliceInp,"START     %10.1f\n",fEventsPerRun);
+  fprintf(pAliceInp,"STOP      \n");
+   
+  
+// Close files
+  
+   fclose(pAliceCoreInp);
+   fclose(pAliceFlukaMat);
+   fclose(pAliceInp);
+   fclose(pGaliceCuts);
+   
 } // end of InitPhysics
 
 
@@ -2595,3 +2359,6 @@ void TFluka::SetMreg(Int_t l)
    fGeom->SetMreg(l);
 }
 
+
+
+