Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:35

0001 #include <iostream>
0002 #include <cstdlib>
0003 #include <vector>
0004 
0005 #include "DetectorDescription/Parser/interface/DDLParser.h"
0006 #include "DetectorDescription/RegressionTest/src/DDCheck.h"
0007 #include "DetectorDescription/Core/interface/DDRoot.h"
0008 #include "DetectorDescription/Core/interface/DDException.h"
0009 #include "DetectorDescription/Core/interface/DDSpecifics.h"
0010 #include "DetectorDescription/Core/interface/DDFilter.h"
0011 #include "DetectorDescription/Core/interface/DDFilteredView.h"
0012 #include "DetectorDescription/Core/interface/DDValue.h"
0013 #include "DetectorDescription/Core/src/tutorial.h"
0014 #include "DetectorDescription/Core/interface/Specific.h"
0015 #include "DetectorDescription/Core/interface/DDException.h"
0016 #include "DetectorDescription/Core/interface/DDComparator.h"
0017 
0018 /**********
0019 
0020 SEE LINES 93ff
0021 
0022 ***********/
0023 using namespace DDI;
0024 using namespace std;
0025 
0026 // Helper class
0027 class PSCreator : public Specific {
0028 public:
0029   PSCreator(const vector<string>& s, DDsvalues_type dummy) : Specific(s, dummy) {}
0030   vector<DDPartSelection> selections() { return Specific::partSelections_; }
0031 };
0032 
0033 int main(int argc, char* argv[]) {
0034   try {  // DDD Prototype can throw DDException defined in DetectorDescription/Core/interface/DDException.h
0035 
0036     // Initialize a DDL Schema aware parser for DDL-documents
0037     // (DDL ... Detector Description Language)
0038     cout << "initialize DDL parser" << endl;
0039     DDLParser* myP = DDLParser::Instance();
0040 
0041     cout << "about to set configuration" << endl;
0042     /* The configuration file tells the parser what to parse.
0043      The sequence of files to be parsed does not matter but for one exception:
0044      XML containing SpecPar-tags must be parsed AFTER all corresponding
0045      PosPart-tags were parsed. (Simply put all SpecPars-tags into seperate
0046      files and mention them at end of configuration.xml. Functional SW 
0047     will not suffer from this restriction).
0048   */
0049     myP->SetConfig("configuration.xml");
0050 
0051     cout << "about to start parsing" << endl;
0052     int parserResult = myP->StartParsing();
0053     if (parserResult != 0) {
0054       cout << " problem encountered during parsing. exiting ... " << endl;
0055       exit(1);
0056     }
0057     cout << " parsing completed" << endl;
0058 
0059     cout << endl << endl << "Start checking!" << endl << endl;
0060 
0061     /* Currently only materials are checked.
0062      (Checking means that additional consitency test are done which
0063       can not be guaranteed to be ok by simple Schema conformance)
0064       Functional SW will automatically call various Tests after parsing 
0065       is finished)
0066   */
0067 
0068     //DDCheckMaterials(cout);
0069     DDCheck(cout);
0070 
0071     /* Now start the 'user-code' */
0072     bool loop = true;
0073 
0074     DDCompactView cpv;
0075     DDExpandedView ex(cpv);
0076     while (loop) {
0077       vector<string> selV(1);
0078       cout << "Part-Selection (//doc1:name1//doc2:name2[cpno2]/nam4 ...)" << endl;
0079       cin >> selV[0];
0080       if (selV[0] == "end")
0081         loop = false;
0082       DDsvalues_type dummy;
0083       vector<DDPartSelection> partSelV = PSCreator(selV, dummy).selections();
0084       int I = partSelV.size();
0085       int i = 0;
0086       for (; i < I; ++i) {
0087         bool go = true;
0088         while (go) {
0089           if (DDCompareEqual(ex.geoHistory(), partSelV[i])(ex.geoHistory(), partSelV[i])) {
0090             // HERE THE SELECTION STRING MATCHES A PART IN EXPANDEDVIEW:
0091             cout << ex.geoHistory() << endl;
0092             cout << ex.translation() << endl;
0093             // << ' ' << ex.rotation() << endl;
0094           }
0095           go = ex.next();
0096         }
0097         ex.reset();
0098       }
0099     }
0100     return 0;
0101 
0102   } catch (DDException& e)  // DDD-Exceptions are simple string for the Prototype
0103   {
0104     cerr << "DDD-PROBLEM:" << endl << e << endl;
0105   }
0106 }