GEANT4submit builder.C

From New IAC Wiki
Jump to navigation Jump to search
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <fstream>
using namespace std;

//      

void GEANT4submit_builder()
{

for(int file_parts=0;file_parts<106;file_parts++)
        {       
                char file[200]; 
                if(file_parts<10)
                {
                        sprintf(file,"./submit/submit00%d", file_parts);
                }
                if(file_parts<100 && file_parts>9)
                {
                        sprintf(file,"./submit/submit0%d", file_parts);
                }
                if(file_parts<1000 && file_parts>99)
                {
                        sprintf(file,"./submit/submit%d", file_parts);
                }

                //printf("%s\n",file);
        ofstream myfile;
        myfile.open (file);


          if(file_parts<10)
                {
                        myfile << "cd /home/lds/src/GEANT4/4.9.6/geant4.9.6.p02/examples/novice/N02";
                        myfile << "\n";         
                        myfile << "./exampleN02 ParticleGunInputs/Run00";
                        myfile << file_parts;
                        myfile << ".mac > out/Run00";
                        myfile << file_parts;
                        myfile << ".out \n";
                        myfile << "mv MollerShield.dat AfterShieldInteraction/MollerShield_00";
                        myfile << file_parts;
                        myfile << ".dat \n";
                        myfile << "\n";

                }
        if(file_parts<100 && file_parts>9)
                {
                        myfile << "cd /home/lds/src/GEANT4/4.9.6/geant4.9.6.p02/examples/novice/N02";
                        myfile << "\n";         
                        myfile << "./exampleN02 ParticleGunInputs/Run0";
                        myfile << file_parts;
                        myfile << ".mac > out/Run0";
                        myfile << file_parts;
                        myfile << ".out \n";
                        myfile << "mv MollerShield.dat AfterShieldInteraction/MollerShield_0";
                        myfile << file_parts;
                        myfile << ".dat \n";
                        myfile << "\n";

                }
        if(file_parts<1000 && file_parts>99)
                {
                        myfile << "cd /home/lds/src/GEANT4/4.9.6/geant4.9.6.p02/examples/novice/N02";
                        myfile << "\n";         
                        myfile << "./exampleN02 ParticleGunInputs/Run";
                        myfile << file_parts;
                        myfile << ".mac > out/Run";
                        myfile << file_parts;
                        myfile << ".out \n";
                        myfile << "mv MollerShield.dat AfterShieldInteraction/MollerShield_";
                        myfile << file_parts;
                        myfile << ".dat \n";
                        myfile << "\n";

                }
        myfile.close();
        }
}