PageRenderTime 36ms CodeModel.GetById 13ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 0ms

/DetectorDescription/Parser/test/testDDCompactView.cpp

https://github.com/aivanov-cern/cmssw
C++ | 135 lines | 83 code | 22 blank | 30 comment | 5 complexity | 19f7836ae1b1dd25223cc30eafb31ca3 MD5 | raw file
  1/***************************************************************************
  2                          main.cpp  -  description
  3                             -------------------
  4    begin                : Wed Oct 24 17:36:15 PDT 2001
  5    author               : 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 *   mec: 2008-08-05 : need to make this an analyzer instead?              *
 17 *                     for now use the "main" of cmssw                     *
 18 ***************************************************************************/
 19
 20#include <iostream>
 21#include <stdlib.h>
 22#include "FWCore/PluginManager/interface/ProblemTracker.h"
 23#include "FWCore/PluginManager/interface/PresenceFactory.h"
 24#include "FWCore/PythonParameterSet/interface/MakeParameterSets.h"
 25#include "FWCore/ServiceRegistry/interface/Service.h"
 26
 27#include "DetectorDescription/Parser/interface/DDLParser.h"
 28#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
 29#include "DetectorDescription/Core/src/DDCheck.h"
 30#include "DetectorDescription/Core/interface/DDExpandedView.h"
 31#include "DetectorDescription/Core/interface/DDExpandedNode.h"
 32#include "DetectorDescription/Core/interface/DDCompactView.h"
 33
 34int main(int argc, char *argv[])
 35{
 36  // Copied from example stand-alone program in Message Logger July 18, 2007
 37  std::string const kProgramName = argv[0];
 38  int rc = 0;
 39
 40  try {
 41
 42    // A.  Instantiate a plug-in manager first.
 43    edm::AssertHandler ah;
 44
 45    // B.  Load the message service plug-in.  Forget this and bad things happen!
 46    //     In particular, the job hangs as soon as the output buffer fills up.
 47    //     That's because, without the message service, there is no mechanism for
 48    //     emptying the buffers.
 49    boost::shared_ptr<edm::Presence> theMessageServicePresence;
 50    theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()->
 51								 makePresence("MessageServicePresence").release());
 52
 53    // C.  Manufacture a configuration and establish it.
 54    std::string config =
 55      "import FWCore.ParameterSet.Config as cms\n"
 56      "process = cms.Process('TEST')\n"
 57      "process.maxEvents = cms.untracked.PSet(\n"
 58      "    input = cms.untracked.int32(5)\n"
 59      ")\n"
 60      "process.source = cms.Source('EmptySource')\n"
 61      "process.JobReportService = cms.Service('JobReportService')\n"
 62      "process.InitRootHandlers = cms.Service('InitRootHandlers')\n"
 63      // "process.MessageLogger = cms.Service('MessageLogger')\n"
 64      "process.m1 = cms.EDProducer('IntProducer',\n"
 65      "    ivalue = cms.int32(11)\n"
 66      ")\n"
 67      "process.out = cms.OutputModule('PoolOutputModule',\n"
 68      "    fileName = cms.untracked.string('testStandalone.root')\n"
 69      ")\n"
 70      "process.p = cms.Path(process.m1)\n"
 71      "process.e = cms.EndPath(process.out)\n";
 72
 73    // D.  Create the services.
 74    edm::ServiceToken tempToken(edm::ServiceRegistry::createServicesFromConfig(config));
 75
 76    // E.  Make the services available.
 77    edm::ServiceRegistry::Operate operate(tempToken);
 78
 79    // END Copy from example stand-alone program in Message Logger July 18, 2007
 80
 81    std::cout << "main::initialize DDL parser" << std::endl;
 82    DDCompactView cpv;
 83
 84    DDLParser myP(cpv); // = DDLParser::instance();
 85
 86    FIPConfiguration dp(cpv);
 87
 88    dp.readConfig("DetectorDescription/Parser/test/cmsIdealGeometryXML.xml");
 89
 90    std::cout << "main::about to start parsing" << std::endl;
 91 
 92    myP.parse(dp);
 93
 94    std::cout << "main::completed Parser" << std::endl;
 95  
 96    std::cout << std::endl << std::endl << "main::Start checking!" << std::endl << std::endl;
 97    DDCheckMaterials(std::cout);
 98
 99    DDExpandedView ev(cpv);
100    std::cout << "== got the epv ==" << std::endl;
101
102    while ( ev.next() ) {
103      if ( ev.logicalPart().name().name() == "MBAT" ) {
104	std::cout << ev.geoHistory() << std::endl;
105      }
106      if ( ev.logicalPart().name().name() == "MUON" ) {
107	std::cout << ev.geoHistory() << std::endl;
108      }
109    }
110    //    cpv.clear();
111    std::cout << "cleared DDCompactView.  " << std::endl;
112  }
113  //  Deal with any exceptions that may have been thrown.
114  catch (cms::Exception& e) {
115    std::cout << "cms::Exception caught in "
116	      << kProgramName
117	      << "\n"
118	      << e.explainSelf();
119    rc = 1;
120  }
121  catch (std::exception& e) {
122    std::cout << "Standard library exception caught in "
123	      << kProgramName
124	      << "\n"
125	      << e.what();
126    rc = 1;
127  }
128  catch (...) {
129    std::cout << "Unknown exception caught in "
130	      << kProgramName;
131    rc = 2;
132  }
133
134  return rc;
135}