264 std::cout <<
"Preparsing '" << inName <<
"'"
265 "\n => '" << outName1 <<
"' (complete description)";
266 if (!outName2.IsNull())
267 std::cout <<
"\n => '" << outName2 <<
"' (without TPC wires)";
272 bool noWiresFiles = 1;
273 if(outName2!=
"") noWiresFiles = 0;
275 ofstream output1, output2;
276 output1.open(outName1);
277 if(!noWiresFiles) output2.open(outName2);
280 ifstream input(inName);
285 std::vector<std::string> loopLine;
288 std::vector<aSetup> stpList;
291 TString
name, loopkey;
296 uint64_t lineCounter = 0;
299 key.ReadLine(input,0);
300 if(
debug>3)
cout << lineCounter <<
"\t::\t" << key <<
"\n";
301 if ((key.Contains(
"<variable") && !key.Contains(
"<!--")) || (key.Contains(
"<constant") && !key.Contains(
"<!--"))) {
303 }
else if (key.Contains(
"<loop")) {
305 if(key.Contains(
"#wire")) isWire=1;
307 }
else if (key.Contains(
"</loop")) {
309 for (std::vector<std::string>::iterator it = loopLine.begin() ; it != loopLine.end(); ++it){
312 if(loopkey.Contains(
"--")) {
314 std::cout <<
"checking double minus sign " << std::endl;
317 loopkey.ReplaceAll(
"--",
"+");
321 output1 << loopkey << endl;
322 if(!isWire && !noWiresFiles) output2 << loopkey << endl;
326 else {keepLoop = (variables[theLoop.
varName] >= theLoop.
varTo);}
332 loopLine.push_back(key.Data());
334 if( !(
isComment(key) || key.IsWhitespace() ) ){
335 if(key.Contains(
"<setup")){
340 if(key.Contains(
"</setup")) {
341 stpList.push_back(theSetup);
349 output1 << key << endl;
350 if(!noWiresFiles) output2 << key << endl;
354 }
while(!input.eof());
358 if(!noWiresFiles) output2.close();
368 ver.Replace(0,pos+1,
"");
373 for (std::vector<aSetup>::iterator itx = stpList.begin() ; itx != stpList.end(); ++itx){
377 else {goAhead =
false;}
381 cout <<
"ERROR: Setup " <<
mySetup <<
" or its version not found." << endl;
384 TString inName1, inName2, comm;
385 inName1 = outName1+
"~";
386 inName2 = outName2+
"~";
387 TString inNameVec[]={inName1,inName2};
388 TString outNameVec[]={outName1,outName2};
390 const int kmax = 1+(!noWiresFiles);
392 for(
int k=0;
k<kmax;
k++){
394 rename(outNameVec[
k], inNameVec[k]);
396 std::cerr <<
"Error renaming '" << outNameVec[
k] <<
"' into '" << inNameVec[
k] <<
"': "
397 << strerror(errno) << std::endl;
400 output1.open(outNameVec[
k]);
401 ifstream input1(inNameVec[k]);
405 key.ReadLine(input1,0);
406 if((!key.Contains(
"<setup") && !inSetup) ){
411 output1 << key << endl;
413 }
while(!input1.eof());
415 output1 <<
"\t<setup name=\"Default\" version=\"1.0\">" << endl;
416 output1 <<
"\t\t<world ref=\"volWorld\" />" << endl;
417 output1 <<
"\t</setup>" << endl;
418 output1 <<
"</gdml_simple_extension>" << endl;
421 remove(inNameVec[
k]);
BEGIN_PROLOG could also be cerr
void makeLoop(TString &key, aLoop &theLoop)
std::map< std::string, double > Variables_t
void evalFormulas(TString &key)
bool isComment(TString key)
void getSetup(TString key, aSetup &theSetup)
void replaceKeyword(TString &key, TString word, TString keyword)
void SetDefaultVariables(Variables_t &variables)
std::string stpWorldVolume
void getVariable(TString key, Variables_t &variables)
void replaceVariable(TString &key, Variables_t const &variables)
BEGIN_PROLOG could also be cout