Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 : * *
4 : * Author: The ALICE Off-line Project. *
5 : * Contributors are mentioned in the code where appropriate. *
6 : * *
7 : * Permission to use, copy, modify and distribute this software and its *
8 : * documentation strictly for non-commercial purposes is hereby granted *
9 : * without fee, provided that the above copyright notice appears in all *
10 : * copies and that both the copyright notice and this permission notice *
11 : * appear in the supporting documentation. The authors make no claims *
12 : * about the suitability of this software for any purpose. It is *
13 : * provided "as is" without express or implied warranty. *
14 : **************************************************************************/
15 :
16 : /* $Id$ */
17 :
18 : //////////////////////////////////////////////////////////////////////////
19 : // //
20 : // aliroot //
21 : // //
22 : // Main program used to create aliroot application. //
23 : // //
24 : // //
25 : // To be able to communicate between the FORTRAN code of GEANT and the //
26 : // ROOT data structure, a number of interface routines have been //
27 : // developed. //
28 : //Begin_Html
29 : /*
30 : <img src="picts/newg.gif">
31 : */
32 : //End_Html
33 : //////////////////////////////////////////////////////////////////////////
34 :
35 : //Standard Root includes
36 : #include <TROOT.h>
37 : #include <TRint.h>
38 : #include <TFile.h>
39 : #include <AliRun.h>
40 : #include "Riostream.h"
41 : #include "ARVersion.h"
42 : // STD
43 : #include <iostream>
44 : #include <algorithm>
45 : #include <sstream>
46 : #include <stdexcept>
47 : #include <functional>
48 : #include <AliLog.h>
49 : #include <sys/resource.h>
50 : #include <stdlib.h>
51 : #include <string>
52 :
53 : #if defined __linux
54 : //On linux Fortran wants this, so we give to it!
55 : int xargv=0;
56 : int xargc=0;
57 : #endif
58 :
59 : #ifdef FORTRAN_G95
60 : extern "C" void g95_runtime_start();
61 : #endif
62 :
63 : #if defined WIN32
64 : extern "C" int __fastflag=0;
65 : extern "C" int _pctype=0;
66 : extern "C" int __mb_cur_max=0;
67 : #endif
68 :
69 : using std::cout;
70 : using std::endl;
71 : using std::exception;
72 : using std::cerr;
73 :
74 : //_____________________________________________________________________________
75 : int main(int argc, char **argv)
76 : {
77 : //
78 : // gAlice main program.
79 : // It creates the main Geant3 and AliRun objects.
80 : //
81 : // The Hits are written out after each track in a ROOT Tree structure TreeH,
82 : // of the file galice.root. There is one such tree per event. The kinematics
83 : // of all the particles that produce hits, together with their genealogy up
84 : // to the primary tracks is stared in the galice.root file in an other tree
85 : // TreeK of which exists one per event. Finally the information of the events
86 : // in the run is stored in the same file in the tree TreeE, containing the
87 : // run and event number, the number of vertices, tracks and primary tracks
88 : // in the event.
89 :
90 : //RS: use maximum stack size
91 : const long kMB = 1024L * 1024L;
92 : rlim_t newStackSize = 8L; // new default stack size
93 : // check if it was overriden by env.var
94 6 : const char* envStack = getenv("ALIROOT_STACK_SIZE"); // expect size in MB
95 6 : if (envStack) {
96 0 : rlim_t envSiz = atoll(envStack);
97 0 : if (envSiz<8) {
98 0 : AliFatalGeneralF("AliRoot","ALIROOT_STACK_SIZE=%s must request stack size in MB, 8MB at least",envStack);
99 0 : }
100 : newStackSize = envSiz;
101 0 : }
102 6 : newStackSize *= kMB;
103 6 : struct rlimit rl;
104 : int result;
105 6 : result = getrlimit(RLIMIT_STACK, &rl);
106 6 : if (result == 0) {
107 6 : rlim_t oldss = rl.rlim_cur;
108 6 : if (newStackSize > rl.rlim_max) {
109 0 : AliWarningGeneralF("AliRoot","Requestested new stack size %lld > hard limit %lld MB",newStackSize/kMB,rl.rlim_max/kMB);
110 0 : newStackSize = rl.rlim_max;
111 0 : }
112 6 : if (rl.rlim_cur < newStackSize) {
113 0 : rl.rlim_cur = newStackSize;
114 0 : result = setrlimit(RLIMIT_STACK, &rl);
115 0 : if (result != 0) fprintf(stderr, "setrlimit returned result = %d\n", result);
116 0 : else AliInfoGeneralF("AliRoot","Set stack size from %lld to %lld MB",oldss/kMB,rl.rlim_cur/kMB);
117 : }
118 6 : }
119 :
120 48 : for ( int i = 1; i < argc; ++i )
121 : {
122 15 : TString argument(argv[i]);
123 :
124 30 : if (argument=="--version")
125 : {
126 0 : cout << "aliroot " << ALIROOT_REVISION << " " << ALIROOT_VERSION << endl;
127 0 : return 0;
128 : }
129 30 : }
130 :
131 : // Create new configuration
132 :
133 6 : new AliRun("gAlice","The ALICE Off-line Simulation Framework");
134 6 : AliLog::GetRootLogger(); // force AliLog to initialize at start time
135 : // Start interactive geant
136 :
137 6 : TRint *theApp = new TRint("aliroot", &argc, argv);
138 : #ifdef FORTRAN_G95
139 : g95_runtime_start();
140 : #endif
141 :
142 : // --- Start the event loop ---
143 : // run.Info("Start AliRoot");
144 : try{
145 0 : theApp->Run();
146 0 : } catch(const exception &e){
147 0 : cerr << "Excception catched" << e.what() << endl;
148 0 : AliLog::Message(0, "Exception catched", "ROOT", NULL, "Exception catched", NULL, 0);
149 0 : }
150 :
151 : return(0);
152 0 : }
153 :
|