Invert US<->LS in trigger response according to hardware (Valerie)
[u/mrichter/AliRoot.git] / TPC / macros / testTPC / AliTPCjobs.cxx
CommitLineData
baf19816 1#include <fstream>
2#include <TFile.h>
3#include <TSystem.h>
4
5/*
c6d9a3a0 6
7
baf19816 8.L $ALICE_ROOT/TPC/macros/testTPC/AliTPCjobs.cxx+
c6d9a3a0 9
10
baf19816 11AliTPCJobs jobs;
12jobs.fJobFile="job.list"
8b35d234 13jobs.ProcessAllJobs();
baf19816 14*/
c6d9a3a0 15
16
baf19816 17class AliTPCJobs : public TNamed{
18public:
19 AliTPCJobs();
20 void ProcessAllJobs();
21 Bool_t GetNextJob();
22 void ProcessJob(TString jobID, TString inputData, TString outputDir, TString action);
23
24 void SetLock(TString jobID);
25 void SetDone(TString jobID);
26 Bool_t IsLocked(TString jobID);
27
28 TString fJobFile;
29 TString fWorkDir;
8b35d234 30 ClassDef(AliTPCJobs,0)
baf19816 31};
32
8b35d234 33 ClassImp(AliTPCJobs)
baf19816 34
35AliTPCJobs::AliTPCJobs(){
36 //
37 //
38 //
39 gSystem->Load("libXrdClient.so");
40 gSystem->Load("libNetx.so");
41}
42
43void AliTPCJobs::ProcessAllJobs(){
44 //
45 //
46 //
47 Int_t counter=0;
48 while (GetNextJob()){
49 //
8b35d234 50 printf("PROCESSING JOB\t%d\n",counter);
baf19816 51 counter++;
52 if (!GetNextJob()) break;
53 }
54}
55
56
57Bool_t AliTPCJobs::GetNextJob(){
58 ifstream in;
59 in.open(fJobFile);
60 TString id;
61 TString inputData;
62 TString outputDir;
63 TString action;
64 Bool_t hasJob=kFALSE;
65 while(in.good()) {
66 in>>id;
67 in>>inputData;
68 in>>outputDir;
69 in>>action;
70 if (!IsLocked(id)){
71 hasJob=kTRUE;
72 break;
73 }
74 }
75 printf("Process %s\n",id.Data());
76 if (hasJob) ProcessJob(id,inputData,outputDir, action);
77 return hasJob;
78}
79
80
81void AliTPCJobs::SetLock(TString jobID){
82 printf("touch out/%s.lock\n",jobID.Data());
83 gSystem->Exec(Form("touch out/%s.lock",jobID.Data()));
84}
85
86void AliTPCJobs::SetDone(TString jobID){
87 printf("touch out/%s.done\n",jobID.Data());
88 gSystem->Exec(Form("touch out/%s.done", jobID.Data()));
89}
90
91
92Bool_t AliTPCJobs::IsLocked(TString jobID){
93 TString path = "out/";
94 path+=jobID;
95 path+=".lock";
96 Long_t pid; Long_t psize; Long_t pflags; Long_t pmodtime;
97 Int_t status = gSystem->GetPathInfo(path,&pid,&psize,&pflags,&pmodtime);
98 return (status==0);
99}
100
101
102void AliTPCJobs::ProcessJob(TString jobID, TString inputData, TString outputDir, TString action){
103 //
104 //
105 // 1. Create lock file
106 // 2. Get Input data
107 // 3. Process data
108 // 4. Create Done file
109 SetLock(jobID);
110 if (action.Contains("COPY")){
111 char command[10000];
c6d9a3a0 112 sprintf(command,"xrdcp -DIFirstConnectMaxCnt 4 -DIConnectTimeout 4 -DIRequestTimeout 4 -DIMaxRedirectcount 4 -DIRedirCntTimeout 4 %s\t%s\n",inputData.Data(), outputDir.Data());
baf19816 113 printf("Exec\t%s\n", command);
114 gSystem->Exec(command);
115 //TFile::Cp(inputData.Data(), outputDir.Data());
8b35d234 116 }else{
117 char command[10000];
118 sprintf(command,"$ALICE_ROOT/TPC/macros/testTPC/action.sh %s %s %s %s", jobID.Data(), inputData.Data(), outputDir.Data(), action.Data());
119 printf("%s\n\n",command);
120 gSystem->Exec(command);
121 printf("\n\n");
122
baf19816 123 }
8b35d234 124
baf19816 125 SetDone(jobID);
126}
c6d9a3a0 127
128
129
130void AliTPCjobs(){
131 //
132 //
133 //
134 AliTPCJobs jobs;
135 jobs.fJobFile="job.list";
136 jobs.ProcessAllJobs();
137}