ROOT logo
// $Id$
//
// #define VERBOSEARGS
// simrun.C
//
// Set job and simulation variables as :
// root.exe -b -q simrun.C  --run <x> --event <y> --process <kPythia6/kPhojet/kPythia6ATLAS_Flat/kPythia6D6T> --field <kNoField/k5kG> --energy <900/2360/10000> --physicslist <QGSP_BERT_CHIPS/CHIPS/QGSP_BERT_EMV>
//
// For production test:
// root.exe -b -q simrun.C  --run 126007 --event 1 --process kPythiaPerugia0 --field k5kG --energy 7000 --physicslist FTFP_BERT_EMV_OPTICAL
//
// By E. Sicking, CERN
{
  int nrun = 0;
  int nevent = 0;
  int seed = 0;

  char sseed[1024];
  char srun[1024];
  char sevent[1024];
  char sprocess[1024];
  char sfield[1024];
  char senergy[1024];
  char sphysicslist[1024];

  sprintf(srun,"");
  sprintf(sevent,"");
  sprintf(sprocess,"");
  sprintf(sfield,"");
  sprintf(senergy,"");
  sprintf(sphysicslist,"");

  for (int i=0; i< gApplication->Argc();i++){
#ifdef VERBOSEARGS
    printf("Arg  %d:  %s\n",i,gApplication->Argv(i));
#endif
    if (!(strcmp(gApplication->Argv(i),"--run")))
      nrun = atoi(gApplication->Argv(i+1));
    sprintf(srun,"%d",nrun);

    if (!(strcmp(gApplication->Argv(i),"--event")))
      nevent = atoi(gApplication->Argv(i+1));
    sprintf(sevent,"%d",nevent);

    if (!(strcmp(gApplication->Argv(i),"--process")))
      sprintf(sprocess, gApplication->Argv(i+1));

    if (!(strcmp(gApplication->Argv(i),"--field")))
      sprintf(sfield,gApplication->Argv(i+1));

    if (!(strcmp(gApplication->Argv(i),"--energy")))
      sprintf(senergy,gApplication->Argv(i+1));

    if (!(strcmp(gApplication->Argv(i),"--physicslist")))
      sprintf(sphysicslist,gApplication->Argv(i+1));
  }

  seed = nrun * 100000 + nevent;
  //seed = nrun + nevent;   // LHC10c9 production test 
  sprintf(sseed,"%d",seed);

  if (seed==0) {
    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
    fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
    fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  } else {
    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
    fprintf(stdout,"!!!  MC Seed is %d \n",seed);
    fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
  }
  
// set the seed environment variable
  gSystem->Setenv("CONFIG_SEED",sseed);
  gSystem->Setenv("CONFIG_RUN_TYPE",sprocess);           // kPythia6 or kPhojet
  gSystem->Setenv("CONFIG_FIELD",sfield);                // kNoField or k5kG
  gSystem->Setenv("CONFIG_ENERGY",senergy);              // 900 or 10000 (GeV)
  gSystem->Setenv("CONFIG_PHYSICSLIST",sphysicslist);    // "QGSP_BERT_EMV", "CHIPS", "QGSP_BERT_CHIPS", 
                                                         // also plus "_OPTICAL" to the 3 names
  gSystem->Setenv("DC_RUN",srun); // Not used in Config.C
  gSystem->Setenv("DC_EVENT",sevent); // Not used in Config.C
  
// Needed to produce simulated RAW data
  gSystem->Setenv("ALIMDC_RAWDB1","./mdc1");
  gSystem->Setenv("ALIMDC_RAWDB2","./mdc2");
  gSystem->Setenv("ALIMDC_TAGDB","./mdc1/tag");
  gSystem->Setenv("ALIMDC_RUNDB","./mdc1/meta");
  cout<< "SIMRUN:: Run " << gSystem->Getenv("DC_RUN") << " Event " << gSystem->Getenv("DC_EVENT")
	  << " Generator "    << gSystem->Getenv("CONFIG_RUN_TYPE")
	  << " Field " << gSystem->Getenv("CONFIG_FIELD")
	  << " Energy " << gSystem->Getenv("CONFIG_ENERGY")
	  << " Physics list " << gSystem->Getenv("CONFIG_PHYSICSLIST")
	  << endl;

  cout<<">>>>> SIMULATION <<<<<"<<endl;
  gSystem->Exec("aliroot -b -q sim.C > sim.log 2>&1");
  gSystem->Exec("mv syswatch.log simwatch.log");
  cout<<">>>>> RECONSTRUCTION <<<<<"<<endl;
  gSystem->Exec("aliroot -b -q rec.C > rec.log 2>&1");
  //   gSystem->Exec("mv syswatch.log recwatch.log");
  //   cout<<">>>>> TAG <<<<<"<<endl;
  //   gSystem->Exec("aliroot -b -q tag.C > tag.log 2>&1");
  //   cout<<">>>>> CHECK ESD <<<<<"<<endl;
  //   gSystem->Exec("aliroot -b -q CheckESD.C > check.log 2>&1");
  //   cout<<">>>>> AOD <<<<<"<<endl;
  //   gSystem->Exec("aliroot -b -q CreateAODfromESD.C > aod.log 2>&1");
  
}
 simrun.C:1
 simrun.C:2
 simrun.C:3
 simrun.C:4
 simrun.C:5
 simrun.C:6
 simrun.C:7
 simrun.C:8
 simrun.C:9
 simrun.C:10
 simrun.C:11
 simrun.C:12
 simrun.C:13
 simrun.C:14
 simrun.C:15
 simrun.C:16
 simrun.C:17
 simrun.C:18
 simrun.C:19
 simrun.C:20
 simrun.C:21
 simrun.C:22
 simrun.C:23
 simrun.C:24
 simrun.C:25
 simrun.C:26
 simrun.C:27
 simrun.C:28
 simrun.C:29
 simrun.C:30
 simrun.C:31
 simrun.C:32
 simrun.C:33
 simrun.C:34
 simrun.C:35
 simrun.C:36
 simrun.C:37
 simrun.C:38
 simrun.C:39
 simrun.C:40
 simrun.C:41
 simrun.C:42
 simrun.C:43
 simrun.C:44
 simrun.C:45
 simrun.C:46
 simrun.C:47
 simrun.C:48
 simrun.C:49
 simrun.C:50
 simrun.C:51
 simrun.C:52
 simrun.C:53
 simrun.C:54
 simrun.C:55
 simrun.C:56
 simrun.C:57
 simrun.C:58
 simrun.C:59
 simrun.C:60
 simrun.C:61
 simrun.C:62
 simrun.C:63
 simrun.C:64
 simrun.C:65
 simrun.C:66
 simrun.C:67
 simrun.C:68
 simrun.C:69
 simrun.C:70
 simrun.C:71
 simrun.C:72
 simrun.C:73
 simrun.C:74
 simrun.C:75
 simrun.C:76
 simrun.C:77
 simrun.C:78
 simrun.C:79
 simrun.C:80
 simrun.C:81
 simrun.C:82
 simrun.C:83
 simrun.C:84
 simrun.C:85
 simrun.C:86
 simrun.C:87
 simrun.C:88
 simrun.C:89
 simrun.C:90
 simrun.C:91
 simrun.C:92
 simrun.C:93
 simrun.C:94
 simrun.C:95
 simrun.C:96
 simrun.C:97
 simrun.C:98
 simrun.C:99
 simrun.C:100
 simrun.C:101
 simrun.C:102
 simrun.C:103
 simrun.C:104
 simrun.C:105
 simrun.C:106
 simrun.C:107
 simrun.C:108