ROOT logo
Bool_t Shuttle(const char* param = "listen", const char* dets=0) {

	// WARNING: if ldap is built with ssl support it may cause confilcts with the 
	// AliEn interface. If this happens, grid storage activation must be done BEFORE 
	// loading LDAP libraries!!!

	gSystem->Load("libRAliEn.so");
	gSystem->Load("libRLDAP.so");
	gSystem->Load("libMonaLisa");
	gSystem->Load("libSHUTTLE");
	gSystem->Load("libThread");
//	gSystem->Load("$ALICE_ROOT/SHUTTLE/test/libTest.so");

	AliLog::SetGlobalDebugLevel(2);
	
	const char* pwd = gSystem->pwd();
	
	if( !gSystem->Getenv("SHUTTLE_DIR")) 
	{
		printf("Setting base SHUTTLE folder to %s\n", pwd);
		gSystem->Setenv("SHUTTLE_DIR", pwd);
	} else {
		printf("Shuttle base folder is %s\n", gSystem->Getenv("SHUTTLE_DIR"));
	}

// 	Setting local CDB and reference storage locations
	  AliShuttle::SetMainCDB("alien://user=aliprod?folder=testShuttle/OCDB");
	  AliShuttle::SetMainRefStorage("alien://user=aliprod?folder=testShuttle/Reference");

//        AliShuttle::SetMainCDB("local://$SHUTTLE_DIR/LocalShuttleCDB");
//        AliShuttle::SetMainRefStorage("local://$SHUTTLE_DIR/LocalShuttleRefStorage");

	AliShuttle::SetLocalCDB("local://$SHUTTLE_DIR/LocalShuttleCDB");
	AliShuttle::SetLocalRefStorage("local://$SHUTTLE_DIR/LocalShuttleRefStorage");

// 	Setting Shuttle log and temp folders
	AliShuttle::SetShuttleLogDir("$SHUTTLE_DIR/log");
	AliShuttle::SetShuttleTempDir("$SHUTTLE_DIR/temp");
	
	
	
	AliShuttle::SetProcessDCS(kTRUE);

//	AliShuttleConfig config("pcalice290.cern.ch", 389, "o=alice,dc=cern,dc=ch");
	AliShuttleConfig config("pcalishuttle01.cern.ch", 389, "", "", "o=alice,dc=cern,dc=ch");
	config.SetProcessAll(kTRUE);
        config.Print();

	AliShuttleTrigger trigger(&config, 100000);

	AliShuttle* shuttle = trigger.GetShuttle();

	// Add here detectors preprocessor ...

	TString detector = dets;
	
	printf ("Processing detectors: %s \n", detector.Data());

	if (detector.Contains("SPD")) 
		new AliITSPreprocessorSPD(shuttle);
	if (detector.Contains("SDD")) 
		new AliITSPreprocessorSDD(shuttle);
	if (detector.Contains("SSD")) 
		new AliITSPreprocessorSSD(shuttle);
	if (detector.Contains("TPC")) 
		new AliTPCPreprocessor(shuttle);
	if (detector.Contains("TRD")) 
		new AliTRDPreprocessor(shuttle);
	if (detector.Contains("TOF")) 
		new AliTOFPreprocessor(shuttle);
	if (detector.Contains("PHS")) 
	{
		gSystem->Load("libPHOSshuttle");
		new AliPHOSPreprocessor(shuttle);
	}
	if (detector.Contains("CPV")) 
		new AliCPVPreprocessor(shuttle);
	if (detector.Contains("HMP")) 
		new AliHMPIDPreprocessor(shuttle);
	if (detector.Contains("EMC")) 
		new AliEMCALPreprocessor(shuttle);
	if (detector.Contains("MCH")) 
		new AliMUONPreprocessor(shuttle);
	if (detector.Contains("MTR")) 
		new AliMTRPreprocessor(shuttle);
	if (detector.Contains("FMD")) 
		new AliFMDPreprocessor(shuttle);
	if (detector.Contains("ZDC")) 
		new AliZDCPreprocessor(shuttle);
	if (detector.Contains("PMD")) 
		new AliPMDPreprocessor("PMD", shuttle);
	if (detector.Contains("T00")) 
	{
		gSystem->Load("libT0shuttle");
		new AliT0Preprocessor("T00", shuttle);
	}
	if (detector.Contains("V00")) 
		new AliVZEROPreprocessor(shuttle);
	if (detector.Contains("GRP")) 
		new AliGRPPreprocessor(shuttle);

//	AliTOFPreprocessor *tofPrep = new AliTOFPreprocessor(shuttle);
//	AliTRDPreprocessor *trdPrep = new AliTRDPreprocessor(shuttle);
//	AliGRPPreprocessor *grpPrep = new AliGRPPreprocessor(shuttle);
	
	TString paramStr(param);
	
	TStopwatch stopwatch;
	stopwatch.Start();

      if (paramStr.IsDigit() || paramStr == "-1") {
	      Int_t run = paramStr.Atoi();
	      trigger.Collect(run);
      } else if (paramStr == "new") {
	      Bool_t result = trigger.Collect();
      } else if (paramStr == "listen") {
	      trigger.Run();
      } else {
	      cout<<"Bad parameter: "<<param<<endl;
	      cout<<"Parameter options: "<<endl;
	      cout<<"<run> - collect data for the given run"<<endl;
	      cout<<"new - collect data only for the new runs"<<endl;
	      cout<<"listen - start listening for DAQ notification"<<endl;
	      cout<<"<empty parameter> - the same as 'listen'"<<endl;
      }

	printf("Execution time: R:%.2fs C:%.2fs \n",
	       stopwatch.RealTime(),stopwatch.CpuTime());

	AliCDBManager::Destroy();
}


 Shuttle.C:1
 Shuttle.C:2
 Shuttle.C:3
 Shuttle.C:4
 Shuttle.C:5
 Shuttle.C:6
 Shuttle.C:7
 Shuttle.C:8
 Shuttle.C:9
 Shuttle.C:10
 Shuttle.C:11
 Shuttle.C:12
 Shuttle.C:13
 Shuttle.C:14
 Shuttle.C:15
 Shuttle.C:16
 Shuttle.C:17
 Shuttle.C:18
 Shuttle.C:19
 Shuttle.C:20
 Shuttle.C:21
 Shuttle.C:22
 Shuttle.C:23
 Shuttle.C:24
 Shuttle.C:25
 Shuttle.C:26
 Shuttle.C:27
 Shuttle.C:28
 Shuttle.C:29
 Shuttle.C:30
 Shuttle.C:31
 Shuttle.C:32
 Shuttle.C:33
 Shuttle.C:34
 Shuttle.C:35
 Shuttle.C:36
 Shuttle.C:37
 Shuttle.C:38
 Shuttle.C:39
 Shuttle.C:40
 Shuttle.C:41
 Shuttle.C:42
 Shuttle.C:43
 Shuttle.C:44
 Shuttle.C:45
 Shuttle.C:46
 Shuttle.C:47
 Shuttle.C:48
 Shuttle.C:49
 Shuttle.C:50
 Shuttle.C:51
 Shuttle.C:52
 Shuttle.C:53
 Shuttle.C:54
 Shuttle.C:55
 Shuttle.C:56
 Shuttle.C:57
 Shuttle.C:58
 Shuttle.C:59
 Shuttle.C:60
 Shuttle.C:61
 Shuttle.C:62
 Shuttle.C:63
 Shuttle.C:64
 Shuttle.C:65
 Shuttle.C:66
 Shuttle.C:67
 Shuttle.C:68
 Shuttle.C:69
 Shuttle.C:70
 Shuttle.C:71
 Shuttle.C:72
 Shuttle.C:73
 Shuttle.C:74
 Shuttle.C:75
 Shuttle.C:76
 Shuttle.C:77
 Shuttle.C:78
 Shuttle.C:79
 Shuttle.C:80
 Shuttle.C:81
 Shuttle.C:82
 Shuttle.C:83
 Shuttle.C:84
 Shuttle.C:85
 Shuttle.C:86
 Shuttle.C:87
 Shuttle.C:88
 Shuttle.C:89
 Shuttle.C:90
 Shuttle.C:91
 Shuttle.C:92
 Shuttle.C:93
 Shuttle.C:94
 Shuttle.C:95
 Shuttle.C:96
 Shuttle.C:97
 Shuttle.C:98
 Shuttle.C:99
 Shuttle.C:100
 Shuttle.C:101
 Shuttle.C:102
 Shuttle.C:103
 Shuttle.C:104
 Shuttle.C:105
 Shuttle.C:106
 Shuttle.C:107
 Shuttle.C:108
 Shuttle.C:109
 Shuttle.C:110
 Shuttle.C:111
 Shuttle.C:112
 Shuttle.C:113
 Shuttle.C:114
 Shuttle.C:115
 Shuttle.C:116
 Shuttle.C:117
 Shuttle.C:118
 Shuttle.C:119
 Shuttle.C:120
 Shuttle.C:121
 Shuttle.C:122
 Shuttle.C:123
 Shuttle.C:124
 Shuttle.C:125
 Shuttle.C:126
 Shuttle.C:127
 Shuttle.C:128
 Shuttle.C:129
 Shuttle.C:130
 Shuttle.C:131
 Shuttle.C:132
 Shuttle.C:133
 Shuttle.C:134