more macros
[u/mrichter/AliRoot.git] / test / QA / simrun.C
1 //#define VERBOSEARGS
2
3 {
4   // set job and simulation variables as :
5   // root run.C  --run <x> --event <y> --process <proc> --minhard <min> --maxhard <max> --minpt <minpt>
6   
7   int nrun = 0;
8   int nevent = 0;
9   int seed = 0;
10   
11   char sseed[1024];
12   char srun[1024];
13   char sevent[1024];
14   char sprocess[1024];
15   char sminpthard[1024];
16   char smaxpthard[1024];
17   char sminptgammapi0[1024];
18   char squench[1024];
19   char sqhat[1024];
20
21   sprintf(srun,"");
22   sprintf(sevent,"");
23   sprintf(sprocess,"");
24   sprintf(sminpthard,"");
25   sprintf(smaxpthard,"");
26   sprintf(sminptgammapi0,"");
27   sprintf(squench,"");
28   sprintf(sqhat,"");
29
30   for (int i=0; i< gApplication->Argc();i++){
31 #ifdef VERBOSEARGS
32     printf("Arg  %d:  %s\n",i,gApplication->Argv(i));
33 #endif
34     if (!(strcmp(gApplication->Argv(i),"--run")))
35       nrun = atoi(gApplication->Argv(i+1));
36     sprintf(srun,"%d",nrun);
37     if (!(strcmp(gApplication->Argv(i),"--event")))
38       nevent = atoi(gApplication->Argv(i+1));
39     sprintf(sevent,"%d",nevent);
40     
41     if (!(strcmp(gApplication->Argv(i),"--process")))
42       sprintf(sprocess, gApplication->Argv(i+1));
43     
44     if (!(strcmp(gApplication->Argv(i),"--minhard")))
45       sprintf(sminpthard,gApplication->Argv(i+1));
46     
47     if (!(strcmp(gApplication->Argv(i),"--maxhard")))
48       sprintf(smaxpthard,gApplication->Argv(i+1));
49     
50     if (!(strcmp(gApplication->Argv(i),"--minpt")))
51       sprintf(sminptgammapi0,gApplication->Argv(i+1));
52
53     if (!(strcmp(gApplication->Argv(i),"--quench")))
54       sprintf(squench,gApplication->Argv(i+1));
55
56     if (!(strcmp(gApplication->Argv(i),"--qhat")))
57       sprintf(sqhat,gApplication->Argv(i+1));
58
59   }
60   char cmd[200] ; 
61   sprintf(cmd, ".! tar zxvf DB.tgz") ; 
62   gROOT->ProcessLine(cmd) ; 
63   
64   seed = nrun * 100000 + nevent;
65   sprintf(sseed,"%d",seed);
66
67   if (seed==0) {
68     fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
69     fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
70     fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
71   } else {
72     fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
73     fprintf(stdout,"!!!  MC Seed is %d \n",seed);
74     fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
75   }
76   
77   // set the seed environment variable
78   gSystem->Setenv("CONFIG_SEED",sseed);
79   gSystem->Setenv("DC_RUN",srun);
80   gSystem->Setenv("DC_EVENT",sevent);
81   gSystem->Setenv("DC_RUN_TYPE",sprocess);//"kPyGammaJetPHOS");
82   gSystem->Setenv("PTHARDMIN",sminpthard);//"20");
83   gSystem->Setenv("PTHARDMAX",smaxpthard);//"30");
84
85   gSystem->Setenv("PTGAMMAPI0MIN",sminptgammapi0);//"1");
86   gSystem->Setenv("QUENCHING",squench);
87   gSystem->Setenv("QHAT",sqhat);
88
89
90   gSystem->Setenv("ECMS","14000");
91   gSystem->Setenv("ALIMDC_RAWDB1","./mdc1");
92   gSystem->Setenv("ALIMDC_RAWDB2","./mdc2");
93   gSystem->Setenv("ALIMDC_TAGDB","./mdc1/tag");
94   gSystem->Setenv("ALIMDC_RUNDB","./mdc1/meta");
95   cout<< "SIMRUN:: Run " << gSystem->Getenv("DC_RUN") << " Event " << gSystem->Getenv("DC_EVENT") 
96           << " Process "    << gSystem->Getenv("DC_RUN_TYPE") 
97           << " minpthard " << gSystem->Getenv("PTHARDMIN") 
98           << " maxpthard " << gSystem->Getenv("PTHARDMAX") 
99           << " minpt "     << gSystem->Getenv("PTGAMMAPI0MIN") 
100           << endl;
101   //gSystem->Exec("cp $ROOTSYS/etc/system.rootrc .rootrc");
102   cout<<">>>>> SIMULATION <<<<<"<<endl;
103   gSystem->Exec("aliroot -b -q sim.C > sim.log 2>&1");
104   cout<<">>>>> RECONSTRUCTION <<<<<"<<endl;
105   gSystem->Exec("aliroot -b -q rec.C > rec.log 2>&1");
106   cout<<">>>>> TAG <<<<<"<<endl;
107   gSystem->Exec("aliroot -b -q tag.C > tag.log 2>&1");
108   cout<<">>>>> CHECK ESD <<<<<"<<endl;
109   gSystem->Exec("aliroot -b -q CheckESD.C > check.log 2>&1");
110
111 }