4d79de3b9e2a3589218084a96010b9613e571ed9
[u/mrichter/AliRoot.git] / SHUTTLE / Shuttle.C
1 Bool_t Shuttle(const char* param = "listen", const char* dets=0) {
2
3         // WARNING: if ldap is built with ssl support it may cause confilcts with the 
4         // AliEn interface. If this happens, grid storage activation must be done BEFORE 
5         // loading LDAP libraries!!!
6
7         gSystem->Load("libRAliEn");
8         gSystem->Load("libRLDAP");
9         gSystem->Load("libMonaLisa");
10         gSystem->Load("libSHUTTLE");
11         gSystem->Load("libThread");
12 //      gSystem->Load("$ALICE_ROOT/SHUTTLE/test/libTest.so");
13
14         AliLog::SetGlobalDebugLevel(2);
15         
16         const char* pwd = gSystem->pwd();
17         
18         if( !gSystem->Getenv("SHUTTLE_DIR")) 
19         {
20                 printf("Setting base SHUTTLE folder to %s\n", pwd);
21                 gSystem->Setenv("SHUTTLE_DIR", pwd);
22         } else {
23                 printf("Shuttle base folder is %s\n", gSystem->Getenv("SHUTTLE_DIR"));
24         }
25
26 //      Setting local CDB and reference storage locations
27           AliShuttle::SetMainCDB("alien://user=aliprod?folder=testShuttle/OCDB");
28           AliShuttle::SetMainRefStorage("alien://user=aliprod?folder=testShuttle/Reference");
29
30 //        AliShuttle::SetMainCDB("local://$SHUTTLE_DIR/LocalShuttleCDB");
31 //        AliShuttle::SetMainRefStorage("local://$SHUTTLE_DIR/LocalShuttleRefStorage");
32
33         AliShuttle::SetLocalCDB("local://$SHUTTLE_DIR/LocalShuttleCDB");
34         AliShuttle::SetLocalRefStorage("local://$SHUTTLE_DIR/LocalShuttleRefStorage");
35
36 //      Setting Shuttle log and temp folders
37         AliShuttle::SetShuttleLogDir("$SHUTTLE_DIR/log");
38         AliShuttle::SetShuttleTempDir("$SHUTTLE_DIR/temp");
39         
40         
41         
42         AliShuttle::SetProcessDCS(kTRUE);
43
44 //      AliShuttleConfig config("pcalice290.cern.ch", 389, "o=alice,dc=cern,dc=ch");
45         AliShuttleConfig config("pcalishuttle01.cern.ch", 389, "", "", "o=alice,dc=cern,dc=ch");
46         config.SetProcessAll(kTRUE);
47         config.Print();
48
49         AliShuttleTrigger trigger(&config, 100000);
50
51         AliShuttle* shuttle = trigger.GetShuttle();
52
53         // Add here detectors preprocessor ...
54
55         TString detector = dets;
56         
57         printf ("Processing detectors: %s \n", detector.Data());
58
59         if (detector.Contains("SPD")) 
60                 new AliITSPreprocessorSPD(shuttle);
61         if (detector.Contains("SDD")) 
62                 new AliITSPreprocessorSDD(shuttle);
63         if (detector.Contains("SSD")) 
64                 new AliITSPreprocessorSSD(shuttle);
65         if (detector.Contains("TPC")) 
66                 new AliTPCPreprocessor(shuttle);
67         if (detector.Contains("TRD")) 
68                 new AliTRDPreprocessor(shuttle);
69         if (detector.Contains("TOF")) 
70                 new AliTOFPreprocessor(shuttle);
71         if (detector.Contains("PHS")) 
72         {
73                 gSystem->Load("libPHOSshuttle");
74                 new AliPHOSPreprocessor(shuttle);
75         }
76         if (detector.Contains("CPV")) 
77                 new AliCPVPreprocessor(shuttle);
78         if (detector.Contains("HMP")) 
79                 new AliHMPIDPreprocessor(shuttle);
80         if (detector.Contains("EMC")) 
81                 new AliEMCALPreprocessor(shuttle);
82         if (detector.Contains("MCH")) 
83                 new AliMUONPreprocessor(shuttle);
84         if (detector.Contains("MTR")) 
85                 new AliMTRPreprocessor(shuttle);
86         if (detector.Contains("FMD")) 
87                 new AliFMDPreprocessor(shuttle);
88         if (detector.Contains("ZDC")) 
89                 new AliZDCPreprocessor(shuttle);
90         if (detector.Contains("PMD")) 
91                 new AliPMDPreprocessor("PMD", shuttle);
92         if (detector.Contains("T00")) 
93         {
94                 gSystem->Load("libT0shuttle");
95                 new AliT0Preprocessor("T00", shuttle);
96         }
97         if (detector.Contains("V00")) 
98                 new AliVZEROPreprocessor(shuttle);
99         if (detector.Contains("GRP")) 
100                 new AliGRPPreprocessor(shuttle);
101
102 //      AliTOFPreprocessor *tofPrep = new AliTOFPreprocessor(shuttle);
103 //      AliTRDPreprocessor *trdPrep = new AliTRDPreprocessor(shuttle);
104 //      AliGRPPreprocessor *grpPrep = new AliGRPPreprocessor(shuttle);
105         
106         TString paramStr(param);
107         
108         TStopwatch stopwatch;
109         stopwatch.Start();
110
111       if (paramStr.IsDigit() || paramStr == "-1") {
112               Int_t run = paramStr.Atoi();
113               trigger.Collect(run);
114       } else if (paramStr == "new") {
115               Bool_t result = trigger.Collect();
116       } else if (paramStr == "listen") {
117               trigger.Run();
118       } else {
119               cout<<"Bad parameter: "<<param<<endl;
120               cout<<"Parameter options: "<<endl;
121               cout<<"<run> - collect data for the given run"<<endl;
122               cout<<"new - collect data only for the new runs"<<endl;
123               cout<<"listen - start listening for DAQ notification"<<endl;
124               cout<<"<empty parameter> - the same as 'listen'"<<endl;
125       }
126
127         printf("Execution time: R:%.2fs C:%.2fs \n",
128                stopwatch.RealTime(),stopwatch.CpuTime());
129
130         AliCDBManager::Destroy();
131 }
132
133