#include #include #include #include #include #include // #include "ExpatInterface/Element.h" #include "DWUnits.hh" #include "DWBox.hh" #include "DWCons.hh" #include "DWTubs.hh" #include "DWPlacement.hh" #include "DWMaterial.hh" #include "DWBegin.hh" #include "DWEnd.hh" #include "DWPhisymm.hh" #include "preXmlManager.hh" #include "preXmlInteger.hh" #include "preXmlAngle.hh" #include "preXmlLength.hh" #include "preXmlNumber.hh" #include "SCTBarrel.preXml.hh" #include "agdbAGDB.hh" #include "agdbSection.hh" #include "agdbSolid.hh" #include "agdbCompos.hh" #include "agdbMPosPhi.hh" #include "agdbPosXYZ.hh" #include "agdbManager.hh" // LESTER Remove the following // #include "ExpatInterface/Document.h" int main(int argc, char** argv) { // Let's make sure the user gave us an input file and an output file. if (argc != 3) { // Oops! The user made a mistake. cerr << endl; cerr << "Usage: " << argv[0] << " " << endl; cerr << " At the moment, .out is added to the end of " << "the you specify." << endl; cerr << " This will be annoying, but will prevent accidents." << endl; cerr << endl; return false; } // We've got enough arguments. We can proceed. string outputFileName(argv[2]); string inputFileName(argv[1]); // The first thing we need to do is fire up the preXml::Manager // which will be the object that will handle all the communication // between us and the preXml file. preXml::Manager useMy(inputFileName); // This works. // LESTER (Note to myself): // preXml::preXmlManager useMy((string) argv[1] ); // This also works, // preXml::preXmlManager useMy( string (argv[1])); // but this fails. // Why the difference ? // At the top of the preXml file, the dtd insists on the existence // of at least one "geometry" (and possibly more, nested if necessary). // The "geometries" are very much like directories. They permit // the user to store more than one description of the detector in // one preXml file. // // So, before we can proceed, we must tell the preXml::Manager which // of these "geometries" (there may of course only be one!) we wish // to build the output-XML-file from. // This we do in the same was as "changing directories" on a file- // system. When we get to the geometry we want, we tell the // preXml::Manager to setGeometry(), and that's all there is to it. // Se here we choose the geometry to work on. useMy.geoManager().changeDir(string("G3Geometry")); useMy.setGeometry(); // Now that we've chosen the geometry, we have restricted ourselves // to a part of the preXml file that describes just one detector. // // If we were confident enough (I'm not!) that nobody working on // a different sub-detector to us had created a name-clash for us, // then we could go right ahead and start reading data from the // preXml file immediately. // If we were to follow this "go right ahead" method, the // preXml::Manager would spot any name clashes and tell us about them, // so nothing would go wrong. However, having to fixing the clash // would still involve finding the person from the other sub-detector // responsible for the clash, etc, etc, etc. This could take time. // // A much better solution is for us to use the structure of the // "sections" (again used just like directories) which each geometry // in the preXml file is broken down into. // If I "change directory" to the section that is my sole // responsibility, then if there is any problem, I only have to // grumble to myself. Since I'm working on the SCT barrel, // I'll go there: useMy.secManager().changeDir(string("ATLAS")); useMy.secManager().changeDir(string("InnerDetector")); useMy.secManager().changeDir(string("SCT")); assert(useMy.secManager().changeDir(string("Barrel"))); // I asserted the last of these just to check that I succeeded. // Now we start the geometry proper. // Let's define a section agdb::Section barrelSection; // Here are the section's parameters: barrelSection.setName("sct_section_barrel"); barrelSection.setVersion("erm ..."); barrelSection.setDate(); barrelSection.setAuthor(); // Better make a "top_volume". agdb::Compos & barrelCompos = barrelSection.adopt(new agdb::Compos()); barrelCompos.setName("sct_barrel"); barrelSection.addVolume(barrelCompos); barrelSection.setTopVol(barrelCompos); {{ #include "Atlas.geo.hh" }} // Finally let's assemble the stuff into an XML document ,,, agdb::Manager letMe; cout << "Building the XML itself ... " << flush; letMe.insertSection(barrelSection); // This "creates" the xml stuff for a given section. cout << "done." << endl; // ... show it to the user ... cout << "Here is the XML which was created:" << endl; letMe.sendDocumentTo(cout); // ... and save it to a file. const string fullOutFileName(outputFileName+".AGDD_1.04.out"); cout << "Writing xml file to " << fullOutFileName << " ... " << flush; ofstream oFileStream(fullOutFileName.c_str()); letMe.sendDocumentTo(oFileStream); cout << "done." << endl; return true; } // end of main()