+//
+// set methods
+//
+
+void TFluka::SetProcess(const char* flagName, Int_t flagValue, Int_t imed)
+{
+// Set process user flag for material imat
+//
+//
+// Update if already in the list
+//
+ TIter next(fUserConfig);
+ TFlukaConfigOption* proc;
+ while((proc = (TFlukaConfigOption*)next()))
+ {
+ if (proc->Medium() == imed) {
+ proc->SetProcess(flagName, flagValue);
+ return;
+ }
+ }
+ proc = new TFlukaConfigOption(imed);
+ proc->SetProcess(flagName, flagValue);
+ fUserConfig->Add(proc);
+}
+
+//______________________________________________________________________________
+Bool_t TFluka::SetProcess(const char* flagName, Int_t flagValue)
+{
+// Set process user flag
+//
+//
+ SetProcess(flagName, flagValue, -1);
+ return kTRUE;
+}
+
+//______________________________________________________________________________
+void TFluka::SetCut(const char* cutName, Double_t cutValue, Int_t imed)
+{
+// Set user cut value for material imed
+//
+ TIter next(fUserConfig);
+ TFlukaConfigOption* proc;
+ while((proc = (TFlukaConfigOption*)next()))
+ {
+ if (proc->Medium() == imed) {
+ proc->SetCut(cutName, cutValue);
+ return;
+ }
+ }
+
+ proc = new TFlukaConfigOption(imed);
+ proc->SetCut(cutName, cutValue);
+ fUserConfig->Add(proc);
+}
+
+//______________________________________________________________________________
+Bool_t TFluka::SetCut(const char* cutName, Double_t cutValue)
+{
+// Set user cut value
+//
+//
+ SetCut(cutName, cutValue, -1);
+ return kTRUE;
+}
+
+
+void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what)
+{
+//
+// Adds a user scoring option to the list
+//
+ TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr,outfile,what);
+ fUserScore->Add(opt);
+}
+//______________________________________________________________________________
+void TFluka::SetUserScoring(const char* option, Int_t npr, char* outfile, Float_t* what, const char* det1, const char* det2, const char* det3)
+{
+//
+// Adds a user scoring option to the list
+//
+ TFlukaScoringOption* opt = new TFlukaScoringOption(option, "User Scoring", npr, outfile, what, det1, det2, det3);
+ fUserScore->Add(opt);
+}
+
+//______________________________________________________________________________
+Double_t TFluka::Xsec(char*, Double_t, Int_t, Int_t)
+{
+ Warning("Xsec", "Not yet implemented.!\n"); return -1.;
+}
+
+
+//______________________________________________________________________________
+void TFluka::InitPhysics()
+{
+//
+// Physics initialisation with preparation of FLUKA input cards
+//
+// Construct file names
+ FILE *pFlukaVmcCoreInp, *pFlukaVmcFlukaMat, *pFlukaVmcInp;
+ TString sFlukaVmcCoreInp = getenv("ALICE_ROOT");
+ sFlukaVmcCoreInp +="/TFluka/input/";
+ TString sFlukaVmcTmp = "flukaMat.inp";
+ TString sFlukaVmcInp = GetInputFileName();
+ sFlukaVmcCoreInp += GetCoreInputFileName();
+
+// Open files
+ if ((pFlukaVmcCoreInp = fopen(sFlukaVmcCoreInp.Data(),"r")) == NULL) {
+ Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcCoreInp.Data());
+ exit(1);
+ }
+ if ((pFlukaVmcFlukaMat = fopen(sFlukaVmcTmp.Data(),"r")) == NULL) {
+ Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcTmp.Data());
+ exit(1);
+ }
+ if ((pFlukaVmcInp = fopen(sFlukaVmcInp.Data(),"w")) == NULL) {
+ Warning("InitPhysics", "\nCannot open file %s\n",sFlukaVmcInp.Data());
+ exit(1);
+ }
+
+// Copy core input file
+ Char_t sLine[255];
+ Float_t fEventsPerRun;
+
+ while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
+ if (strncmp(sLine,"GEOEND",6) != 0)
+ fprintf(pFlukaVmcInp,"%s",sLine); // copy until GEOEND card
+ else {
+ fprintf(pFlukaVmcInp,"GEOEND\n"); // add GEOEND card
+ goto flukamat;
+ }
+ } // end of while until GEOEND card
+
+
+ flukamat:
+ while ((fgets(sLine,255,pFlukaVmcFlukaMat)) != NULL) { // copy flukaMat.inp file
+ fprintf(pFlukaVmcInp,"%s\n",sLine);
+ }
+
+ while ((fgets(sLine,255,pFlukaVmcCoreInp)) != NULL) {
+ if (strncmp(sLine,"START",5) != 0)
+ fprintf(pFlukaVmcInp,"%s\n",sLine);
+ else {
+ sscanf(sLine+10,"%10f",&fEventsPerRun);
+ goto fin;
+ }
+ } //end of while until START card
+
+ fin:
+
+
+// Pass information to configuration objects
+
+ Float_t fLastMaterial = fGeom->GetLastMaterialIndex();
+ TFlukaConfigOption::SetStaticInfo(pFlukaVmcInp, 3, fLastMaterial, fGeom);
+
+ TIter next(fUserConfig);
+ TFlukaConfigOption* proc;
+ while((proc = dynamic_cast<TFlukaConfigOption*> (next()))) proc->WriteFlukaInputCards();
+//
+// Process Fluka specific scoring options
+//
+ TFlukaScoringOption::SetStaticInfo(pFlukaVmcInp, fGeom);
+ Float_t loginp = 49.0;
+ Int_t inp = 0;
+ Int_t nscore = fUserScore->GetEntries();
+
+ TFlukaScoringOption *mopo = 0;
+ TFlukaScoringOption *mopi = 0;
+
+ for (Int_t isc = 0; isc < nscore; isc++)
+ {
+ mopo = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isc));
+ char* fileName = mopo->GetFileName();
+ Int_t size = strlen(fileName);
+ Float_t lun = -1.;
+//
+// Check if new output file has to be opened
+ for (Int_t isci = 0; isci < isc; isci++) {
+
+
+ mopi = dynamic_cast<TFlukaScoringOption*> (fUserScore->At(isci));
+ if(strncmp(mopi->GetFileName(), fileName, size)==0) {
+ //
+ // No, the file already exists
+ lun = mopi->GetLun();
+ mopo->SetLun(lun);
+ break;
+ }
+ } // inner loop
+
+ if (lun == -1.) {
+ // Open new output file
+ inp++;
+ mopo->SetLun(loginp + inp);
+ mopo->WriteOpenFlukaFile();
+ }
+ mopo->WriteFlukaInputCards();
+ }
+
+// Add RANDOMIZ card
+ fprintf(pFlukaVmcInp,"RANDOMIZ %10.1f%10.0f\n", 1., Float_t(gRandom->GetSeed()));
+// Add START and STOP card
+ fprintf(pFlukaVmcInp,"START %10.1f\n",fEventsPerRun);
+ fprintf(pFlukaVmcInp,"STOP \n");
+
+
+// Close files
+ fclose(pFlukaVmcCoreInp);
+ fclose(pFlukaVmcFlukaMat);
+ fclose(pFlukaVmcInp);
+
+
+//
+// Initialisation needed for Cerenkov photon production and transport
+ TObjArray *matList = GetFlukaMaterials();
+ Int_t nmaterial = matList->GetEntriesFast();
+ fMaterials = new Int_t[nmaterial+3];
+
+ for (Int_t im = 0; im < nmaterial; im++)
+ {
+ TGeoMaterial* material = dynamic_cast<TGeoMaterial*> (matList->At(im));
+ Int_t idmat = material->GetIndex();
+ fMaterials[idmat] = im;
+ }
+} // end of InitPhysics
+
+
+//______________________________________________________________________________
+void TFluka::SetMaxStep(Double_t step)
+{
+// Set the maximum step size
+ if (step > 1.e4) return;
+
+ Int_t mreg, latt;
+ fGeom->GetCurrentRegion(mreg, latt);
+ STEPSZ.stepmx[mreg - 1] = step;
+}
+
+
+Double_t TFluka::MaxStep() const
+{
+// Return the maximum for current medium
+ Int_t mreg, latt;
+ fGeom->GetCurrentRegion(mreg, latt);
+ return (STEPSZ.stepmx[mreg - 1]);
+}
+
+//______________________________________________________________________________
+void TFluka::SetMaxNStep(Int_t)
+{
+// SetMaxNStep is dummy procedure in TFluka !
+ if (fVerbosityLevel >=3)
+ cout << "SetMaxNStep is dummy procedure in TFluka !" << endl;
+}
+
+//______________________________________________________________________________
+void TFluka::SetUserDecay(Int_t)
+{
+// SetUserDecay is dummy procedure in TFluka !
+ if (fVerbosityLevel >=3)
+ cout << "SetUserDecay is dummy procedure in TFluka !" << endl;
+}
+