Working on the electron cut
[u/mrichter/AliRoot.git] / prod / LHC08d8 / 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 secms[1024];
15         char sprocess[1024];
16         char sminpthard[1024];
17         char smaxpthard[1024];
18         char sminptgammapi0[1024];
19         char spi0gammafrag[1024];
20         char squench[1024];
21         char sqhat[1024];
22         char smedlength[1024];
23         char strig[1024];
24         char syear[1024];
25         
26         sprintf(srun,"");
27         sprintf(sevent,"");
28         sprintf(secms,"");
29         sprintf(sprocess,"");
30         sprintf(sminpthard,"");
31         sprintf(smaxpthard,"");
32         sprintf(sminptgammapi0,"");
33         sprintf(spi0gammafrag,"");
34         sprintf(squench,"");
35         sprintf(sqhat,"");
36         //sprintf(smedlength,"");
37         sprintf(strig,"");
38         sprintf(syear,"");
39         
40         for (int i=0; i< gApplication->Argc();i++){
41 #ifdef VERBOSEARGS
42                 printf("Arg  %d:  %s\n",i,gApplication->Argv(i));
43 #endif
44                 if (!(strcmp(gApplication->Argv(i),"--run")))
45                         nrun = atoi(gApplication->Argv(i+1));
46                 sprintf(srun,"%d",nrun);
47         
48                 if (!(strcmp(gApplication->Argv(i),"--event")))
49                         nevent = atoi(gApplication->Argv(i+1));
50                 sprintf(sevent,"%d",nevent);
51                                 
52                 if (!(strcmp(gApplication->Argv(i),"--process")))
53                         sprintf(sprocess, gApplication->Argv(i+1));
54                                 
55                 if (!(strcmp(gApplication->Argv(i),"--year")))
56                         sprintf(syear, gApplication->Argv(i+1));
57
58                 if (!(strcmp(gApplication->Argv(i),"--ecms")))
59                         sprintf(secms,gApplication->Argv(i+1));
60                                                 
61                 if (!(strcmp(gApplication->Argv(i),"--minhard")))
62                         sprintf(sminpthard,gApplication->Argv(i+1));
63                                                         
64                 if (!(strcmp(gApplication->Argv(i),"--maxhard")))
65                         sprintf(smaxpthard,gApplication->Argv(i+1));
66         
67                 if (!(strcmp(gApplication->Argv(i),"--pi0gammafrag")))
68                         sprintf(spi0gammafrag,gApplication->Argv(i+1));
69                                                                                                                                                                                 
70                 if (!(strcmp(gApplication->Argv(i),"--minpt")))
71                         sprintf(sminptgammapi0,gApplication->Argv(i+1));
72                                                                                                                                         
73                 if (!(strcmp(gApplication->Argv(i),"--quench")))
74                         sprintf(squench,gApplication->Argv(i+1));
75                                                                                 
76                 if (!(strcmp(gApplication->Argv(i),"--qhat")))
77                         sprintf(sqhat,gApplication->Argv(i+1));
78                                                                                         
79                 //if (!(strcmp(gApplication->Argv(i),"--medlength")))
80                 //      sprintf(smedlength,gApplication->Argv(i+1));
81                                                                                         
82                 if (!(strcmp(gApplication->Argv(i),"--trigger")))
83                         sprintf(strig,gApplication->Argv(i+1));
84                                                                                                         
85         }
86         
87         //rec params for reconstruction
88         //only for release < 16
89         //char cmd[200] ; 
90         //sprintf(cmd, ".! tar zxvf DBpp.tgz") ; 
91         //gROOT->ProcessLine(cmd) ; 
92         
93         seed = nrun * 100000 + nevent;
94         sprintf(sseed,"%d",seed);
95         
96         if (seed==0) {
97                 fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
98                 fprintf(stderr,"!!!!  WARNING! Seeding variable for MC is 0          !!!!\n");
99                 fprintf(stderr,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
100         } else {
101                 fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
102                 fprintf(stdout,"!!!  MC Seed is %d \n",seed);
103                 fprintf(stdout,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
104         }
105         
106         // set the seed environment variable
107         gSystem->Setenv("CONFIG_SEED",sseed);
108         gSystem->Setenv("RUN",srun);
109         gSystem->Setenv("EVENT",sevent);
110         gSystem->Setenv("DC_RUN_TYPE",sprocess);//"kPyGammaJetPHOS");
111         gSystem->Setenv("YEAR",syear);//"14000");       
112         gSystem->Setenv("ECMS",secms);//"14000");
113         gSystem->Setenv("PTHARDMIN",sminpthard);//"20");
114         gSystem->Setenv("PTHARDMAX",smaxpthard);//"30");
115         gSystem->Setenv("PI0GAMMAINDET",spi0gammafrag);//"1");
116         gSystem->Setenv("PTGAMMAPI0MIN",sminptgammapi0);//"1");
117         gSystem->Setenv("QUENCHING",squench);
118         gSystem->Setenv("QHAT",sqhat);
119         //gSystem->Setenv("MEDLENGTH",smedlength);
120         gSystem->Setenv("TRIGGER",strig);
121         
122         cout<< "SIMRUN:: Run = " << gSystem->Getenv("RUN") << "; Event = " << gSystem->Getenv("EVENT") 
123         << "; Process = "    << gSystem->Getenv("DC_RUN_TYPE")
124         << "; E cms = " << gSystem->Getenv("ECMS") 
125         << "; Trigger configuration = "<< gSystem->Getenv("TRIGGER")
126         << "; Year = "<<gSystem->Getenv("YEAR") << endl;
127         
128         cout<< "         minpthard = " << gSystem->Getenv("PTHARDMIN") 
129         << "; maxpthard =" << gSystem->Getenv("PTHARDMAX") 
130         << "; force pi0/gamma frag in detector = "     << gSystem->Getenv("PI0GAMMAINDET") 
131         << "; minpt = "     << gSystem->Getenv("PTGAMMAPI0MIN") 
132         << "; quenching option ="<<gSystem->Getenv("QUENCHING") 
133         << "; qhat = "<<gSystem->Getenv("QHAT") 
134         //<< "; medium length = "<<gSystem->Getenv("MEDIUMLENGTH")
135         << endl;
136         
137         cout<<">>>>> SIMULATION <<<<<"<<endl;
138         gSystem->Exec("aliroot -b -q sim.C > sim.log 2>&1");
139         cout<<">>>>> RECONSTRUCTION <<<<<"<<endl;
140         gSystem->Exec("aliroot -b -q rec.C > rec.log 2>&1");
141         cout<<">>>>> TAG <<<<<"<<endl;
142         gSystem->Exec("aliroot -b -q tag.C > tag.log 2>&1");
143         cout<<">>>>> CHECK ESD <<<<<"<<endl;
144         gSystem->Exec("aliroot -b -q CheckESD.C > check.log 2>&1");
145         
146 }