]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muondep/AccEffTemplates/simrun.C
end-of-line normalization
[u/mrichter/AliRoot.git] / PWG / muondep / AccEffTemplates / simrun.C
1 // #define VERBOSEARGS
2 // simrun.C
3 {
4 // set job and simulation variables as :
5 // root.exe -b -q simrun.C  --run <x> --chunk <y> --event <n> 
6
7   int nrun = 0;
8   int nchunk = 0;
9   int nevent = 0;
10   int seed = 0;
11   Bool_t snapshot(kFALSE);
12   
13   char sseed[1024];
14   char srun[1024];
15   char schunk[1024];
16
17   sprintf(srun,"");
18   sprintf(schunk,"");
19
20   for (int i=0; i< gApplication->Argc();i++){
21 #ifdef VERBOSEARGS
22     printf("Arg  %d:  %s\n",i,gApplication->Argv(i));
23 #endif
24     if (!(strcmp(gApplication->Argv(i),"--run")))
25       nrun = atoi(gApplication->Argv(i+1));
26     sprintf(srun,"%d",nrun);
27
28     if (!(strcmp(gApplication->Argv(i),"--chunk")))
29       nchunk = atoi(gApplication->Argv(i+1));
30     sprintf(schunk,"%d",nchunk);
31
32     if (!(strcmp(gApplication->Argv(i),"--event")))
33       nevent = atoi(gApplication->Argv(i+1));
34
35     if (!(strcmp(gApplication->Argv(i),"--snapshot")))
36       snapshot = kTRUE;
37   }
38
39   seed = nrun * 10000 + nchunk;
40   sprintf(sseed,"%d",seed);
41
42   if (seed==0) {
43     fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
44     fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
45     fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
46   } else {
47     fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
48     fprintf(stdout,"!!!  MC Seed is %d \n",seed);
49     fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
50   }
51   
52 // set the seed environment variable
53   gSystem->Setenv("CONFIG_SEED",sseed);
54   gSystem->Setenv("DC_RUN",srun); // used in AliSimulation.cxx
55   gSystem->Setenv("DC_EVENT",schunk); // Not used in Config.C (used for setting seed)
56   
57 // Needed to produce simulated RAW data
58   gSystem->Setenv("ALIMDC_RAWDB1","./mdc1");
59   gSystem->Setenv("ALIMDC_RAWDB2","./mdc2");
60   gSystem->Setenv("ALIMDC_TAGDB","./mdc1/tag");
61   gSystem->Setenv("ALIMDC_RUNDB","./mdc1/meta");
62   cout<< "SIMRUN:: Run " << gSystem->Getenv("DC_RUN")
63           << " Chunk " << gSystem->Getenv("DC_EVENT")
64           << endl;
65
66   cout<<">>>>> SIMULATION <<<<<"<<endl;
67   if ( snapshot )
68   {
69     gSystem->Setenv("OCDB_SNAPSHOT_CREATE","kTRUE");
70     gSystem->Setenv("OCDB_SNAPSHOT_FILENAME","OCDB_sim.root");
71   }
72   
73   gSystem->Exec(Form("aliroot -b -q sim.C\\(%d\\) > sim.log 2>&1",nevent));
74   gSystem->Exec("mv syswatch.log simwatch.log");
75
76   if ( snapshot )
77   {
78     gSystem->Setenv("OCDB_SNAPSHOT_FILENAME","OCDB_rec.root");
79   }
80   
81   cout<<">>>>> RECONSTRUCTION <<<<<"<<endl;
82   
83   if ( snapshot )
84   {
85     // for some reason must include ITS objects in the snapshot
86     // (to be able to instantiante the vertexer later on ?)
87     gSystem->Exec("aliroot -b -q rec.C\\(1\\) > rec.log 2>&1");
88   }
89   else
90   {
91     gSystem->Exec("aliroot -b -q rec.C > rec.log 2>&1");
92   }
93   
94   gSystem->Exec("mv syswatch.log recwatch.log");
95
96   if ( snapshot )
97   {
98     gSystem->Exec(Form("mkdir -p OCDB/%s",srun));
99     gSystem->Exec(Form("mv OCDB_*.root OCDB/%s/",srun));
100   }
101   else
102   {
103     //  cout<<">>>>> TAG <<<<<"<<endl;
104     //  gSystem->Exec("aliroot -b -q tag.C > tag.log 2>&1");
105   
106     cout<<">>>>> CHECK ESD <<<<<"<<endl;
107     gSystem->Exec("aliroot -b -q CheckESD.C > checkesd.log 2>&1");
108     cout<<">>>>> MAKE AOD <<<<<"<<endl;
109     gSystem->Exec("aliroot -b -q AODtrain.C > aod.log 2>&1");
110     cout<<">>>>> CHECK AOD <<<<<"<<endl;
111     gSystem->Exec("aliroot -b -q CheckAOD.C > checkaod.log 2>&1");
112   }
113   
114   return 0;
115 }