30 if(gSystem->Getenv(
"CWB_CLONEDIR_CHECK")!=NULL) {
36 cwb_clonedir_options_output.ToUpper();
37 if(cwb_clonedir_options_output!=
"") {
39 if(cwb_clonedir_options_output==
"LINKS") check=
true;
40 if(cwb_clonedir_options_output==
"MERGE") check=
true;
42 cout << endl <<
"cwb_clonedir Error : --output available value are : links/merge!!!" << endl << endl;
50 cwb_clonedir_options_config.ToUpper();
51 if(cwb_clonedir_options_config!=
"") {
53 if(cwb_clonedir_options_config==
"CHECK") check=
true;
55 cout << endl <<
"cwb_clonedir Error : --check available values are : true/false!!!" << endl << endl;
63 cwb_clonedir_options_simulation.ToUpper();
64 if(cwb_clonedir_options_simulation!=
"") {
66 if(cwb_clonedir_options_simulation==
"TRUE") check=
true;
67 if(cwb_clonedir_options_simulation==
"FALSE") check=
true;
69 cout << endl <<
"cwb_clonedir Error : --simulation available values are : true/false!!!" << endl << endl;
77 if(cwb_clonedir_options_chunk!=
"") {
81 if(cwb_clonedir_options_label!=
"") {
82 cout << endl <<
"cwb_clonedir Error : --chunk option can not be used when --label option is used!!!" << endl << endl;
85 if(!cwb_clonedir_options_chunk.IsDigit()) {
86 cout << endl <<
"cwb_clonedir Error : ckunk option is not a positive integer number!!!" << endl << endl;
94 if(cwb_clonedir_options==
"") {
96 cout <<
"Destination directory already exist ..." << endl;
101 TB.
checkFile(gSystem->Getenv(
"CWB_ROOTLOGON_FILE"));
102 TB.
checkFile(gSystem->Getenv(
"CWB_PARAMETERS_FILE"));
103 TB.
checkFile(gSystem->Getenv(
"CWB_UPARAMETERS_FILE"));
107 if(gSystem->Getenv(
"CWB_CLONEDIR_PWD")!=NULL) {
108 cwb_clonedir_pwd=
TString(gSystem->Getenv(
"CWB_CLONEDIR_PWD"));
110 cout <<
"cwb_clonedir.C - Error : CWB_CLONEDIR_PWD not declared" << endl;
116 if(gSystem->Getenv(
"CWB_CLONEDIR_SRC")!=NULL) {
117 cwb_clonedir_src=
TString(gSystem->Getenv(
"CWB_CLONEDIR_SRC"));
118 if(!cwb_clonedir_src.BeginsWith(
"/")) {
122 cout <<
"cwb_clonedir.C - Error : CWB_CLONEDIR_SRC not declared" << endl;
129 if(gSystem->Getenv(
"CWB_CLONEDIR_DEST")!=NULL) {
130 cwb_clonedir_dest=
TString(gSystem->Getenv(
"CWB_CLONEDIR_DEST"));
132 cout <<
"cwb_clonedir.C - Error : CWB_CLONEDIR_DEST not declared" << endl;
139 cwb_clonedir_options_output.ToUpper();
144 cwb_clonedir_options_config.ToUpper();
149 cwb_clonedir_options_simulation.ToUpper();
162 cwb_clonedir_options_jstage.ToUpper();
165 if(cwb_clonedir_options_jstage==
"FULL") cwb_stage_label=
"wave_";
166 if(cwb_clonedir_options_jstage==
"INIT") cwb_stage_label=
"init_";
167 if(cwb_clonedir_options_jstage==
"STRAIN") cwb_stage_label=
"strain_";
168 if(cwb_clonedir_options_jstage==
"CSTRAIN") cwb_stage_label=
"cstrain_";
169 if(cwb_clonedir_options_jstage==
"COHERENCE") cwb_stage_label=
"coherence_";
170 if(cwb_clonedir_options_jstage==
"SUPERCLUSTER") cwb_stage_label=
"supercluster_";
171 if(cwb_clonedir_options_jstage==
"LIKELIHOOD") cwb_stage_label=
"wave_";
173 char src_output_dir[1024];
177 if(cwb_clonedir_src.EndsWith(
"/")) cwb_clonedir_src.Resize(cwb_clonedir_src.Sizeof()-2);
179 const char* src_data_label = gSystem->BaseName(cwb_clonedir_src.Data());
182 if(cwb_clonedir_options_config==
"CHECK") {
186 sprintf(fparms,
"%s/%s",cwb_clonedir_src.Data(),gSystem->ExpandPathName(
"$CWB_UPARAMETERS_FILE"));
191 cout <<
"fparms : " << fparms << endl;
194 sprintf(cmd,
"diff %s %s | less",fparms,gSystem->ExpandPathName(
"$CWB_UPARAMETERS_FILE"));
200 cout <<
"Are src & dest config files compatibles ? (y/n) " << endl;
202 cout << endl << endl;
203 }
while ((strcmp(answer,
"y")!=0)&&(strcmp(answer,
"n")!=0));
204 if (strcmp(answer,
"n")==0) gSystem->Exit(1);
209 if(cwb_clonedir_options_output==
"LINKS") {
211 cwb_stage_label, src_data_label);
212 cout <<
"cwb_clonedir : create symbolic links in output dir ..." << endl;
218 for(
int i=0;
i<fileList.size();
i++) {
219 if(
i%100==0) cout <<
i <<
"/" << fileList.size() << endl;
221 const char* file_name_base = gSystem->BaseName(fileList[
i].Data());
222 TString sfile_name_base = file_name_base;
223 sfile_name_base.ReplaceAll(src_data_label,
data_label);
226 estat = gSystem->GetPathInfo(filePath,&
id,&size,&flags,&mt);
230 gSystem->Symlink(fileList[
i].Data(),link_to);
233 cout <<
"Number of new links " << newlinks <<
"/" << fileList.size() << endl;
240 if(cwb_clonedir_options_output==
"MERGE") {
244 cout <<
"cwb_clonedir : merge src wave&live in output dir ..." << endl;
245 TRegexp reg1(
".*M[0-9]+.root");
248 for(
int i=0;
i<fileList.size();
i++) {
250 if(fileList[
i].Contains(reg1)) {
253 TString smergeID = ((TObjString*)token->At(token->GetEntries()-2))->GetString();
254 smergeID.ReplaceAll(
"M",
"");
255 if(smergeID.IsDigit()) {
256 int mergeID = smergeID.Atoi();
257 if(max_version<mergeID) max_version=mergeID;
269 if(cwb_clonedir_options_label==
"") {
270 sprintf(fwave,
"%s/wave_%s.M%d%s.root",src_merge_dir,src_data_label,max_version,chunk_label.Data());
271 sprintf(flive,
"%s/live_%s.M%d%s.root",src_merge_dir,src_data_label,max_version,chunk_label.Data());
272 sprintf(fmerge,
"%s/wave_%s.M%d%s.root",
output_dir,src_data_label,max_version,chunk_label.Data());
273 sprintf(flist,
"%s/wave_%s.M%d%s.lst",
output_dir,src_data_label,max_version,chunk_label.Data());
274 sprintf(fmdc,
"%s/mdc_%s.M%d%s.root",src_merge_dir,src_data_label,max_version,chunk_label.Data());
276 sprintf(fwave,
"%s/wave_%s.%s.root",src_merge_dir,src_data_label,cwb_clonedir_options_label.Data());
277 sprintf(flive,
"%s/live_%s.%s.root",src_merge_dir,src_data_label,cwb_clonedir_options_label.Data());
278 sprintf(fmerge,
"%s/wave_%s.%s.root",
output_dir,src_data_label,cwb_clonedir_options_label.Data());
279 sprintf(flist,
"%s/wave_%s.%s.lst",
output_dir,src_data_label,cwb_clonedir_options_label.Data());
280 sprintf(fmdc,
"%s/mdc_%s.%s.root",src_merge_dir,src_data_label,cwb_clonedir_options_label.Data());
282 cout <<
"fwave : " << fwave << endl;
283 cout <<
"flive : " << flive << endl;
284 cout <<
"fmerge : " << fmerge << endl;
285 cout <<
"flist : " << flist << endl;
286 cout <<
"fmdc : " << fmdc << endl;
288 estat = gSystem->GetPathInfo(fwave,&
id,&size,&flags,&mt);
289 if (estat!=0) {cout <<
"cwb_clonedir.C : Error - wave not exist : " << fwave << endl;
exit(1);}
290 if(cwb_clonedir_options_simulation==
"TRUE") {
291 estat = gSystem->GetPathInfo(fmdc,&
id,&size,&flags,&mt);
292 if (estat!=0) {cout <<
"cwb_clonedir.C : Error - mdc not exist : " << fmdc << endl;
exit(1);}
294 estat = gSystem->GetPathInfo(flive,&
id,&size,&flags,&mt);
295 if (estat!=0) {cout <<
"cwb_clonedir.C : Error - live not exist : " << flive << endl;
exit(1);}
299 if(checkList.size()!=0) {
301 cout <<
"cwb_clonedir.C : Error - files with source label : " << src_data_label << endl;
302 cout <<
"already exist in the output directory : " << cwb_clonedir_dest <<
304 cout <<
"Before to apply cwb_clonedir.C the following files must be removed !!!" << endl << endl;
305 for(
int i=0;
i<checkList.size();
i++) {
306 cout <<
i <<
" " << checkList[
i].Data() << endl;
310 if(chunk_label!=
"") {
313 if(checkList.size()!=0) {
315 cout <<
"cwb_clonedir.C : Error - files with chunk label : " << chunk_label << endl;
316 cout <<
"already exist in the output directory : " << cwb_clonedir_dest <<
318 cout <<
"Before to apply cwb_clonedir.C the following files must be removed !!!" << endl << endl;
319 for(
int i=0;
i<checkList.size();
i++) {
320 cout <<
i <<
" " << checkList[
i].Data() << endl;
327 M.AddFile(fwave,
true);
328 if(cwb_clonedir_options_simulation==
"TRUE") {
329 M.AddFile(fmdc,
true);
331 M.AddFile(flive,
true);
333 M.OutputFile(fmerge);
339 cout <<
"cwb_clonedir.C : Error - Merge failed !!!" << endl;
343 vector<TString> mergeList(2);
345 if(cwb_clonedir_options_simulation==
"TRUE") {
TString cwb_clonedir_options_output
TString cwb_clonedir_options_chunk
TString cwb_clonedir_options
TString cwb_clonedir_dest
TString cwb_clonedir_options_jstage
cout<< "Starting reading output directory ..."<< endl;vector< TString > fileList
TString cwb_clonedir_options_config
strcpy(RunLabel, RUN_LABEL)
TString cwb_clonedir_options_simulation
sprintf(src_merge_dir,"%s/%s", cwb_clonedir_src.Data(), merge_dir)
TString cwb_clonedir_options_label