PageRenderTime 34ms CodeModel.GetById 11ms app.highlight 18ms RepoModel.GetById 1ms app.codeStats 1ms

/DetectorDescription/Parser/test/dumpDDCompactView.cpp

https://github.com/aivanov-cern/cmssw
C++ | 165 lines | 94 code | 28 blank | 43 comment | 5 complexity | 57ba7e394e36c03ea7ec2541e75465b4 MD5 | raw file
  1/***************************************************************************
  2                          main.cpp  -  description
  3                             -------------------
  4    begin                : Wed Oct 24 17:36:15 PDT 2001
  5    author               : 2001 Michael Case
  6    email                : case@ucdhep.ucdavis.edu
  7 ***************************************************************************/
  8
  9/***************************************************************************
 10 *                                                                         *
 11 *   This program is free software; you can redistribute it and/or modify  *
 12 *   it under the terms of the GNU General Public License as published by  *
 13 *   the Free Software Foundation; either version 2 of the License, or     *
 14 *   (at your option) any later version.                                   *
 15 *                                                                         *
 16 ***************************************************************************/
 17
 18
 19#include <iostream>
 20#include <stdlib.h>
 21#include <fstream>
 22
 23#include "DetectorDescription/Parser/interface/DDLParser.h"
 24#include "FWCore/PluginManager/interface/ProblemTracker.h"
 25#include "FWCore/PluginManager/interface/PresenceFactory.h"
 26#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
 27#include "FWCore/ServiceRegistry/interface/Service.h"
 28
 29#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
 30#include "DetectorDescription/Core/src/DDCheck.h"
 31#include "DetectorDescription/Core/src/DDCheckMaterials.cc"
 32#include "DetectorDescription/Core/interface/DDCompactView.h"
 33#include "DetectorDescription/Core/interface/adjgraph.h"
 34#include "DetectorDescription/Core/src/Material.h"
 35
 36int main(int argc, char *argv[])
 37{
 38  typedef DDCompactView::graph_type::const_adj_iterator adjl_iterator;
 39
 40  // Copied from example stand-alone program in Message Logger July 18, 2007
 41  std::string const kProgramName = argv[0];
 42  int rc = 0;
 43
 44  try {
 45
 46    // A.  Instantiate a plug-in manager first.
 47    edm::AssertHandler ah;
 48
 49    // B.  Load the message service plug-in.  Forget this and bad things happen!
 50    //     In particular, the job hangs as soon as the output buffer fills up.
 51    //     That's because, without the message service, there is no mechanism for
 52    //     emptying the buffers.
 53    boost::shared_ptr<edm::Presence> theMessageServicePresence;
 54    theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()->
 55								 makePresence("MessageServicePresence").release());
 56
 57    // C.  Manufacture a configuration and establish it.
 58    std::string config =
 59      "import FWCore.ParameterSet.Config as cms\n"
 60      "process = cms.Process('TEST')\n"
 61      "process.maxEvents = cms.untracked.PSet(\n"
 62      "    input = cms.untracked.int32(5)\n"
 63      ")\n"
 64      "process.source = cms.Source('EmptySource')\n"
 65      "process.JobReportService = cms.Service('JobReportService')\n"
 66      "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
 67      // "process.MessageLogger = cms.Service('MessageLogger')\n"
 68      "process.m1 = cms.EDProducer('IntProducer',\n"
 69      "    ivalue = cms.int32(11)\n"
 70      ")\n"
 71      "process.out = cms.OutputModule('PoolOutputModule',\n"
 72      "    fileName = cms.untracked.string('testStandalone.root')\n"
 73      ")\n"
 74      "process.p = cms.Path(process.m1)\n"
 75      "process.e = cms.EndPath(process.out)\n";
 76
 77    // D.  Create the services.
 78    edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config));
 79
 80    // E.  Make the services available.
 81    edm::ServiceRegistry::Operate operate(tempToken);
 82
 83    // END Copy from example stand-alone program in Message Logger July 18, 2007
 84
 85    std::cout << "main::initialize DDL parser" << std::endl;
 86    DDCompactView cpv;
 87    DDLParser myP(cpv);// = DDLParser::instance();
 88
 89    //   std::cout << "main:: about to start parsing field configuration..." << std::endl;
 90    //   FIPConfiguration dp2;
 91    //   dp2.readConfig("Geometry/CMSCommonData/data/FieldConfiguration.xml");
 92    //   myP->parse(dp2);
 93
 94    std::cout << "main::about to start parsing main configuration... " << std::endl;
 95    FIPConfiguration dp(cpv);
 96    dp.readConfig("DetectorDescription/Parser/test/cmsIdealGeometryXML.xml");
 97    myP.parse(dp);
 98  
 99    std::cout << "main::completed Parser" << std::endl;
100
101    std::cout << std::endl << std::endl << "main::Start checking!" << std::endl << std::endl;
102    DDCheckMaterials(std::cout);
103
104    //  cpv.setRoot(DDLogicalPart(DDName("cms:World")));
105
106    std::cout << "edge size of produce graph:" << cpv.writeableGraph().edge_size() << std::endl;
107    const DDCompactView::graph_type& gt = cpv.graph();
108    adjl_iterator git = gt.begin();
109    adjl_iterator gend = gt.end();    
110
111    DDCompactView::graph_type::index_type i=0;
112    for (; git != gend; ++git) {
113      const DDLogicalPart & ddLP = gt.nodeData(git);
114      std::cout << ++i << " P " << ddLP.name() << std::endl;
115      if (git->size()) { 
116	DDCompactView::graph_type::edge_list::const_iterator cit  = git->begin();
117	DDCompactView::graph_type::edge_list::const_iterator cend = git->end();
118	for (; cit != cend; ++cit) {
119	  const DDLogicalPart & ddcurLP = gt.nodeData(cit->first);
120	  std::cout << ++i << " c--> " << gt.edgeData(cit->second)->copyno_ << " " << ddcurLP.name() << std::endl;
121	}
122      }
123    }
124
125    cpv.writeableGraph().clear();
126    //    cpv.clear();
127    std::cout << "cleared DDCompactView.  " << std::endl;
128
129
130    //   DDExpandedView ev(cpv);
131    //   std::cout << "== got the epv ==" << std::endl;
132
133    //   while ( ev.next() ) {
134    //     if ( ev.logicalPart().name().name() == "MBAT" ) {
135    //       std::cout << ev.geoHistory() << std::endl;
136    //     }
137    //     if ( ev.logicalPart().name().name() == "MUON" ) {
138    //       std::cout << ev.geoHistory() << std::endl;
139    //     }
140    //   }
141
142  }
143  //  Deal with any exceptions that may have been thrown.
144  catch (cms::Exception& e) {
145    std::cout << "cms::Exception caught in "
146	      << kProgramName
147	      << "\n"
148	      << e.explainSelf();
149    rc = 1;
150  }
151  catch (std::exception& e) {
152    std::cout << "Standard library exception caught in "
153	      << kProgramName
154	      << "\n"
155	      << e.what();
156    rc = 1;
157  }
158  catch (...) {
159    std::cout << "Unknown exception caught in "
160	      << kProgramName;
161    rc = 2;
162  }
163
164  return rc;
165}