]>
Commit | Line | Data |
---|---|---|
27eb9bff | 1 | |
c5d00b61 | 2 | void mergeByComponent(TString component, |
3 | const Char_t* fileList="calib.list", | |
4 | const Char_t* apath=0, | |
5 | const Char_t* apattern=0, | |
6 | Int_t fileDownloadTimeOut=10, | |
7 | const Char_t* localFileList="calib.list", | |
8 | const Char_t* mergedFileName="CalibObjects.root" ) | |
27eb9bff | 9 | { |
c5d00b61 | 10 | // merging procedure |
11 | // component can be COPY, MAKEALIENLIST, component name or ALL | |
12 | // ALL will merge the full file | |
13 | // selecting components will only merge the selected top level | |
14 | // objects in the file | |
15 | // COPY only copies the the alien files from fileList then | |
16 | // saves a list of local downloaded files in localFileList. | |
17 | // MAKEALIENLIST produces a list of files on alien, uses root | |
18 | // to connect in case alien_xx utilities are not available | |
19 | // liek on the alien nodes | |
27eb9bff | 20 | /* load libs */ |
c5d00b61 | 21 | printf("Executing mergeByComponent.C\n"); |
cd9dc5c7 | 22 | gROOT->Macro("$ALICE_ROOT/PWGPP/CalibMacros/CPass0/LoadLibraries.C"); |
27eb9bff | 23 | TH1::AddDirectory(0); |
24 | ||
c5d00b61 | 25 | Int_t fileDownloadTimeOut=10; |
26 | ||
d157f353 | 27 | /* copy only */ |
27eb9bff | 28 | if (component == "COPY") { |
d157f353 | 29 | if (!apath || ! apattern){ |
30 | printf("Alien find path or pattern not specified"); | |
31 | exit(1); | |
32 | } | |
c5d00b61 | 33 | CopyCPass(fileList, localFileList, fileDownloadTimeOut); |
34 | return; | |
35 | } | |
36 | /* make file list only */ | |
37 | if (component == "MAKEALIENLIST") { | |
38 | if (!apath || ! apattern){ | |
39 | printf("Alien find path or pattern not specified"); | |
40 | exit(1); | |
41 | } | |
42 | MakeFileList(apath, apattern, fileList); | |
27eb9bff | 43 | return; |
44 | } | |
c5d00b61 | 45 | |
27eb9bff | 46 | /* merge component */ |
c5d00b61 | 47 | MergeCPass(fileList, component, mergedFileName); |
27eb9bff | 48 | } |
49 | ||
50 | //___________________________________________________________________ | |
51 | ||
c5d00b61 | 52 | void MergeCPass(const Char_t *list, TString component, TString outputFileName="CalibObjects.root") |
27eb9bff | 53 | { |
e9129651 | 54 | //AliTPCcalibTimeGain::SetMergeEntriesCut(2000000); |
55 | //AliTPCcalibGainMult::SetMergeEntriesCut(2000000); | |
56 | //AliTPCcalibAlign::SetMergeEntriesCut(10000000); | |
57 | //AliTPCcalibTracks::SetMergeEntriesCut(10000000); | |
27eb9bff | 58 | AliFileMerger merger; |
59 | /* select what to merge */ | |
7b58b4ed | 60 | merger.SetNoTrees(kFALSE); |
27eb9bff | 61 | if (component == "ALL") |
62 | merger.AddReject("esdFriend"); | |
63 | else | |
64 | merger.AddAccept(component.Data()); | |
65 | /* merge */ | |
c5d00b61 | 66 | merger.IterTXT(list, outputFileName.Data(), kFALSE); |
27eb9bff | 67 | /* notify */ |
68 | gSystem->Exec(Form("touch %s_merge_done", component.Data())); | |
69 | return; | |
70 | } | |
71 | ||
72 | //___________________________________________________________________ | |
c5d00b61 | 73 | void MakeFileList(const char *searchdir, const char *pattern, const char* outputFileName="calib.list", Int_t timeOut=10) |
27eb9bff | 74 | { |
27eb9bff | 75 | gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut)); |
76 | gEnv->SetValue("XNet.RequestTimeout", timeOut); | |
77 | gEnv->SetValue("XNet.ConnectTimeout", timeOut); | |
78 | gEnv->SetValue("XNet.TransactionTimeout", timeOut); | |
79 | TFile::SetOpenTimeout(timeOut); | |
80 | ||
81 | TGrid::Connect("alien"); | |
82 | ||
27eb9bff | 83 | TString command; |
84 | command = Form("find %s/ %s", searchdir, pattern); | |
85 | cerr<<"command: "<<command<<endl; | |
86 | TGridResult *res = gGrid->Command(command); | |
87 | if (!res) return; | |
88 | TIter nextmap(res); | |
89 | TMap *map = 0; | |
90 | ||
91 | ofstream outputFile; | |
c5d00b61 | 92 | outputFile.open(Form(outputFileName)); |
27eb9bff | 93 | |
94 | while((map=(TMap*)nextmap())) | |
95 | { | |
96 | TObjString *objs = dynamic_cast<TObjString*>(map->GetValue("turl")); | |
97 | if (!objs || !objs->GetString().Length()) | |
98 | { | |
99 | delete res; | |
100 | break; | |
101 | } | |
102 | ||
103 | TString src=Form("%s",objs->GetString().Data()); | |
c5d00b61 | 104 | outputFile << src.Data()<< endl; |
105 | } | |
106 | outputFile.close(); | |
107 | return; | |
108 | } | |
109 | ||
110 | //___________________________________________________________________ | |
111 | void CopyCPass(const char* alienFileList="alien.list", const char* outputFileList="local.list", Int_t timeOut=10) | |
112 | { | |
113 | //copy all the alien files to local | |
114 | gSystem->Setenv("XRDCLIENTMAXWAIT",Form("%d",timeOut)); | |
115 | gEnv->SetValue("XNet.RequestTimeout", timeOut); | |
116 | gEnv->SetValue("XNet.ConnectTimeout", timeOut); | |
117 | gEnv->SetValue("XNet.TransactionTimeout", timeOut); | |
118 | TFile::SetOpenTimeout(timeOut); | |
119 | ||
120 | TGrid::Connect("alien"); | |
121 | ||
122 | ifstream inputFile; | |
123 | inputFile.open(alienFileList); | |
124 | ofstream outputFile; | |
125 | outputFile.open(Form(outputFileList)); | |
126 | ||
127 | if (!inputFile.is_open()) | |
128 | { | |
129 | printf("input file %s not found! exiting...\n",alienFileList); | |
130 | exit(1); | |
131 | } | |
132 | ||
133 | Int_t counter=0; | |
134 | while( inputFile.good()) | |
135 | { | |
136 | TString src(""); | |
137 | src.ReadLine(inputFile); | |
138 | if (src.IsNull()) continue; | |
27eb9bff | 139 | TString dst=src; |
140 | dst.ReplaceAll("alien:///",""); | |
141 | dst.ReplaceAll("/","_"); | |
27eb9bff | 142 | Bool_t result = TFile::Cp(src.Data(),dst.Data(),kTRUE); |
27eb9bff | 143 | AliSysInfo::AddStamp(dst.Data(),counter, result); |
c5d00b61 | 144 | if (result) |
27eb9bff | 145 | { |
27eb9bff | 146 | outputFile << dst.Data()<< endl; |
c5d00b61 | 147 | counter++; |
27eb9bff | 148 | } |
149 | } | |
150 | cout<<counter<<" files copied!"<<endl; | |
151 | ||
c5d00b61 | 152 | inputFile.close(); |
27eb9bff | 153 | outputFile.close(); |
154 | gSystem->Exec("touch copy_done"); | |
27eb9bff | 155 | } |
156 |