CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Fireworks/Geometry/plugins/DisplayGeom.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    DisplayGeom
00004 // Class:      DisplayGeom
00005 // 
00013 //
00014 // Original Author:  Chris D Jones
00015 //         Created:  Wed Sep 26 08:27:23 EDT 2007
00016 // $Id: DisplayGeom.cc,v 1.2 2010/09/01 19:36:13 amraktad Exp $
00017 //
00018 //
00019 
00020 // system include files
00021 #include <memory>
00022 #include <iostream>
00023 #include <sstream>
00024 
00025 #include "TROOT.h"
00026 #include "TSystem.h"
00027 #include "TApplication.h"
00028 #include "TError.h"
00029 
00030 // user include files
00031 #include "FWCore/Framework/interface/Frameworkfwd.h"
00032 #include "FWCore/Framework/interface/EDAnalyzer.h"
00033 
00034 #include "FWCore/Framework/interface/MakerMacros.h"
00035 #include "Fireworks/Geometry/interface/DisplayPluginFactory.h"
00036 
00037 
00038 //
00039 // class decleration
00040 //
00041 using namespace fireworks::geometry;
00042        
00043 class DisplayGeom : public edm::EDAnalyzer {
00044 
00045    public:
00046       explicit DisplayGeom(const edm::ParameterSet&);
00047       ~DisplayGeom();
00048 
00049    private:
00050       virtual void beginJob() ;
00051       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00052       virtual void endJob() ;
00053 
00054       // ----------member data ---------------------------
00055       int level_;
00056       bool verbose_;
00057       TApplication* app_;
00058       DisplayPlugin* plugin_;
00059 };
00060 
00061 //
00062 // constants, enums and typedefs
00063 //
00064 
00065 //
00066 // static data member definitions
00067 //
00068 
00069 //
00070 // constructors and destructor
00071 //
00072 DisplayGeom::DisplayGeom(const edm::ParameterSet& iConfig):
00073    level_(iConfig.getUntrackedParameter<int>("level",4)),
00074    verbose_(iConfig.getUntrackedParameter<bool>("verbose",false)),
00075    app_(0),
00076    plugin_(0)
00077 {
00078    //now do what ever initialization is needed
00079 
00080   std::cout <<" is batch "<<gROOT->IsBatch()<<std::endl;
00081   std::cout <<" display "<<gSystem->Getenv("DISPLAY")<<std::endl;
00082 
00083   const char* dummyArgvArray[] = {"cmsRun"};
00084   char** dummyArgv = const_cast<char**>(dummyArgvArray);
00085   int dummyArgc = 1;
00086   app_ = new TApplication("App", &dummyArgc, dummyArgv);
00087   assert(TApplication::GetApplications()->GetSize());
00088   
00089   gROOT->SetBatch(kFALSE);
00090   //TApplication* app = dynamic_cast<TApplication*>(TApplication::GetApplications()->First());
00091   //assert(app!=0);
00092   std::cout<<"calling NeedGraphicsLibs()"<<std::endl;
00093   TApplication::NeedGraphicsLibs();
00094 
00095   DisplayPluginFactory* factory = DisplayPluginFactory::get();
00096   plugin_ = factory->create("EveDisplayPlugin");
00097 }
00098 
00099 
00100 DisplayGeom::~DisplayGeom()
00101 {
00102  
00103    // do anything here that needs to be done at desctruction time
00104    // (e.g. close files, deallocate resources etc.)
00105   
00106    delete plugin_;
00107 }
00108 
00109 
00110 //
00111 // member functions
00112 //
00113 
00114 // ------------ method called to for each event  ------------
00115 void
00116 DisplayGeom::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00117 {
00118   std::cout << "In the DisplayGeom::analyze method..." << std::endl;
00119    using namespace edm;
00120 
00121    //need to reset the Error handler to avoid error messages becoming exceptions
00122    ErrorHandlerFunc_t old = SetErrorHandler(DefaultErrorHandler);
00123 
00124    plugin_->run(iSetup);
00125    app_->Run(kTRUE);
00126 
00127    SetErrorHandler(old);
00128 
00129    // Exit from fireworks
00130    // gApplication
00131    //app->Terminate(0);
00132 
00133 }
00134 
00135 
00136 // ------------ method called once each job just before starting event loop  ------------
00137 void 
00138 DisplayGeom::beginJob()
00139 {
00140 }
00141 
00142 // ------------ method called once each job just after ending the event loop  ------------
00143 void 
00144 DisplayGeom::endJob() {
00145 }
00146 
00147 //define this as a plug-in
00148 DEFINE_FWK_MODULE(DisplayGeom);