Logo coherent WaveBurst  
Library Reference Guide
Logo
FixUserParametersROOT6.C
Go to the documentation of this file.
1 // ===============================================================================
2 // this macro makes ROOT5 user_parameters C++ compliant (ROOT6)
3 // ===============================================================================
4 
6 
7 #ifdef _USE_ROOT6
8 
9  // working dir
10  char work_dir[1024];
11  sprintf(work_dir,"%s",gSystem->WorkingDirectory());
12 
13  // data label
14  char data_label[1024];
15  sprintf(data_label,"%s",gSystem->BaseName(work_dir));
16  //cout << "--------------------------> data_label : " << data_label << endl;
17 
18  Long_t id,size,flags,mt;
19  int estat = gSystem->GetPathInfo(ifName.Data(),&id,&size,&flags,&mt);
20  if (estat==0) {
21 
22  ifstream in;
23  in.open(ifName.Data(),ios::in);
24  if (!in.good()) {cout << "Error Opening File : " << ifName.Data() << endl;exit(1);}
25 
26  ofstream out;
27  TString ifName_tmp = ifName+".tmp";
28  out.open(ifName_tmp.Data(),ios::out);
29  if (!out.good()) {cout << "Error Opening File : " << ifName_tmp << endl;exit(1);}
30 
31  TString nDQF="";
32 
33  char str[1024];
34  while(true) {
35  in.getline(str,1024);
36  if (!in.good()) break;
37  TString ostr = str;
38  ostr.ReplaceAll(" ","");
39  ostr.ReplaceAll("\t","");
40  if(type=="p") { // config/user_parameters.C
41  if(ostr.BeginsWith("search=")) {
42  ostr = str;
43  ostr="// "+ostr+"\t// #ROOT5";
44  out << ostr.Data() << endl;
45  ostr = str;
46  ostr.ReplaceAll("search","cfg_search");
47  ostr+="\t// #ROOT6";
48  } else if(ostr.BeginsWith("gamma=")) {
49  ostr = str;
50  ostr="// "+ostr+"\t// #ROOT5";
51  out << ostr.Data() << endl;
52  ostr = str;
53  ostr.ReplaceAll("gamma","cfg_gamma");
54  ostr+="\t// #ROOT6";
55  } else if(ostr.BeginsWith("nDQF=")) {
56  ostr = str;
57  ostr = ostr(ostr.First("=")+1,ostr.First(";")-ostr.First("=")-1);
58  nDQF=ostr;
59  ostr = str;
60  } else if(!ostr.BeginsWith("//")&&ostr.Contains("nDQF")&&(nDQF!="")) {
61  ostr = str;
62  ostr="// "+ostr+"\t// #ROOT5";
63  out << ostr.Data() << endl;
64  ostr = str;
65  ostr.ReplaceAll("nDQF",nDQF);
66  ostr+="\t// #ROOT6";
67  } else ostr = str;
68  }
69  if(type=="mp") { // merge/cwb_user_parameters.C
70  if(ostr.BeginsWith("chardata_label[1024]=")) {
71  ostr = str;
72  ostr="// "+ostr+"\t// #ROOT5";
73  out << ostr.Data() << endl;
74  ostr = str;
75  TString old_label = ostr(ostr.First("=")+1,ostr.First(";")-ostr.First("=")-1);
76  ostr.ReplaceAll(old_label,TString(" \"")+TString(data_label)+TString("\""));
77  ostr+="\t// #ROOT6";
78  } else if (ostr.BeginsWith("char*lagFile=\"")) {
79  // fix wrong user_parameter file syntax produced by the config class
80  ostr = str;
81  ostr="// "+ostr+"\t// #ROOT5";
82  out << ostr.Data() << endl;
83  ostr = str;
84  ostr = ostr(0, ostr.First("=")+1)+TString(" NULL;");
85  ostr+="\t// #ROOT6";
86  } else if (ostr.BeginsWith("char*slagFile=\"")) {
87  // fix wrong user_parameter file syntax produced by the config class
88  ostr = str;
89  ostr="// "+ostr+"\t// #ROOT5";
90  out << ostr.Data() << endl;
91  ostr = str;
92  ostr = ostr(0, ostr.First("=")+1)+TString(" NULL;");
93  ostr+="\t// #ROOT6";
94  } else ostr = str;
95  }
96  if(type=="pp") { // config/user_pparameters.C
97  if(ostr.BeginsWith("intchunkID=")) {
98  ostr = str;
99  ostr="// "+ostr+"\t// #ROOT5";
100  out << ostr.Data() << endl;
101  ostr = str;
102  ostr.ReplaceAll("int ","");
103  ostr+="\t// #ROOT6";
104  } else if(ostr.BeginsWith("TStringcalibVer=")) {
105  ostr = str;
106  ostr="// "+ostr+"\t// #ROOT5";
107  out << ostr.Data() << endl;
108  ostr = str;
109  ostr.ReplaceAll("TString ","");
110  ostr+="\t// #ROOT6";
111  } else ostr = str;
112  }
113  out << ostr.Data() << endl;
114  }
115  out.close();
116  in.close();
117 
118  char cmd[1024];
119  sprintf(cmd,"mv %s %s",ifName_tmp.Data(),ifName.Data());
120  //cout << cmd << endl;
121  gSystem->Exec(cmd);
122  }
123 #endif
124 
125  exit(0);
126 }
127 
TString("c")
ofstream out
Definition: cwb_merge.C:214
Long_t flags
Long_t size
nDQF
Definition: cwb_eced.C:109
char data_label[512]
Definition: test_config1.C:160
char str[1024]
ifstream in
char cmd[1024]
int estat
void FixUserParametersROOT6(TString ifName, TString type)
sprintf(tfres,"(1/%g)x(%g) (sec)x(Hz)", 2 *df, df)
Long_t mt
Long_t id
char work_dir[512]
Definition: test_config1.C:143
exit(0)