CMS 3D CMS Logo

VisEventProcessorService Class Reference

#include <VisFramework/VisFrameworkBase/interface/VisEventProcessorService.h>

Inheritance diagram for VisEventProcessorService:

IgStateElement

List of all members.

Public Member Functions

std::string configFile (void)
std::string configRootFile (std::string fileName)
void initEventProcessor (void)
edm::JobReportjobReport (void)
void off ()
void on ()
void onCmsException (lat::Callback1< cms::Exception * > callback)
void onConfigFailure (lat::Callback1< cms::Exception * > callback)
void onException (lat::Callback1< std::exception * > callback)
void onFrameworkException (lat::Callback1< lat::Error * > callback)
void onProcessorStarted (lat::Callback callback)
void onProcessorStopped (lat::Callback callback)
void onStartingProcessor (lat::Callback callback)
void onStatusMessage (lat::Callback1< const std::string & > callback)
void onStoppingProcessor (lat::Callback callback)
void onUnhandledException (lat::Callback callback)
edm::EventProcessoroperator-> ()
void reInitEventProcessor (const std::string &parameterSet)
bool running (void)
void scheduleAbort (void)
 VisEventProcessorService (IgState *state)
 ~VisEventProcessorService (void)

Private Member Functions

 IG_DECLARE_STATE_ELEMENT (VisEventProcessorService)
void init (void)

Private Attributes

bool m_callEndJob
std::auto_ptr
< edm::EventProcessor
m_ep
std::auto_ptr< edm::JobReportm_jobRep
boost::shared_ptr< edm::Presencem_messageServicePresence
lat::Callback1< cms::Exception * > m_onCmsException
lat::Callback1< cms::Exception * > m_onConfigFailure
lat::Callback1< std::exception * > m_onException
lat::Callback1< lat::Error * > m_onFrameworkException
lat::Callback m_onProcessorStarted
lat::Callback m_onProcessorStopped
lat::Callback m_onStartingProcessor
lat::Callback1< const
std::string & > 
m_onStatusMessage
lat::Callback m_onStoppingProcessor
lat::Callback m_onUnhandledException
bool m_running
IgStatem_state


Detailed Description

Definition at line 28 of file VisEventProcessorService.h.


Constructor & Destructor Documentation

VisEventProcessorService::VisEventProcessorService ( IgState state  ) 

Definition at line 42 of file VisEventProcessorService.cc.

References ASSERT, init(), LFfwvis, LOG, IgState::put(), and GsfMatrixTools::trace().

00043     : m_ep (0),
00044       m_jobRep (new edm::JobReport ()),
00045       m_callEndJob (false),
00046       m_running (false),
00047       m_state (state)
00048 {
00049     LOG (0, trace, LFfwvis, "VisEventProcessorService::VisEventProcessorService\n");
00050 
00051     ASSERT (state);
00052     state->put (s_key, this);
00053 
00054     init ();
00055 }

VisEventProcessorService::~VisEventProcessorService ( void   ) 

Definition at line 90 of file VisEventProcessorService.cc.

References ASSERT, IgState::detach(), m_callEndJob, m_ep, and m_state.

00091 {
00092     ASSERT (m_state);
00093     if (m_ep.get () && m_callEndJob) m_ep->endJob ();
00094     m_state->detach (s_key);
00095 }


Member Function Documentation

std::string VisEventProcessorService::configFile ( void   ) 

Definition at line 98 of file VisEventProcessorService.cc.

References m_onStatusMessage.

Referenced by initEventProcessor().

00099 {
00100     if (this->m_onStatusMessage)
00101         this->m_onStatusMessage ("Creating an empty configuration....");
00102 
00103     std::string configString = 
00104         "import FWCore.ParameterSet.Config as cms\n\n"
00105         "from FWCore.MessageLogger.MessageLogger_cfi import *\n"
00106         "process = cms.Process(\"IGUANA\")\n"
00107         "process.load(\"Configuration.StandardSequences.FakeConditions_cff\")\n"
00108         "process.load(\"Configuration.StandardSequences.Geometry_cff\")\n"
00109         "process.load(\"Configuration.StandardSequences.MagneticField_cff\")\n"
00110         "process.load(\"Configuration.StandardSequences.Reconstruction_cff\")\n\n"
00111         "process.load(\"VisFramework.VisFrameworkBase.VisConfigurationService_cff\")\n"
00112         "process.source = cms.Source(\"EmptySource\")\n";
00113 
00114     QDateTime dt = QDateTime::currentDateTime ();
00115     QString cfgFilename = "iguana-EmptySource-" + dt.toString ("hh:mm:ss.zzz-dd.MM.yyyy") + "_cfg.py";
00116     
00117     QFile iguanaConfigFile (cfgFilename);
00118     if (! iguanaConfigFile.exists ())
00119     {    
00120         if (iguanaConfigFile.open (IO_WriteOnly)) 
00121         {
00122             QTextStream cfgStream (&iguanaConfigFile);
00123             cfgStream << configString;
00124             iguanaConfigFile.close ();
00125         }       
00126     }
00127 
00128     return cfgFilename.latin1 ();
00129 }

std::string VisEventProcessorService::configRootFile ( std::string  fileName  ) 

Definition at line 132 of file VisEventProcessorService.cc.

Referenced by initEventProcessor().

00133 {
00134     std::string configstring =  
00135         "import FWCore.ParameterSet.Config as cms\n\n"
00136         "from FWCore.MessageLogger.MessageLogger_cfi import *\n"
00137         "process = cms.Process(\"IGUANA\")\n"
00138         "process.load(\"Configuration.StandardSequences.FakeConditions_cff\")\n"
00139         "process.load(\"Configuration.StandardSequences.Geometry_cff\")\n"
00140         "process.load(\"Configuration.StandardSequences.MagneticField_cff\")\n"
00141         "process.load(\"Configuration.StandardSequences.Reconstruction_cff\")\n\n"
00142         "process.load(\"VisFramework.VisFrameworkBase.VisConfigurationService_cff\")\n"
00143         "process.source = cms.Source(\"PoolSource\",\n"
00144         "    fileNames = cms.untracked.vstring('";
00145 
00146     if (rootFileName.compare (0, 7, "/castor") == 0)
00147         configstring += "rfio:";
00148     else if (rootFileName.compare (0, 6, "/store") == 0)
00149         configstring += "";
00150     else
00151     {
00152         struct stat stFileInfo;
00153         int intStat = stat (rootFileName.c_str (), &stFileInfo);
00154         if (intStat == 0)
00155             configstring += "file:";
00156     }
00157     
00158     configstring += rootFileName;
00159     configstring += "')\n)\n";
00160 
00161     configstring += "process.VisConfigurationService.EnabledTwigs = ('* Muon *',\n"
00162                     "                                                '* Track *',\n"
00163                     "                                                '*Segment*',\n"
00164                     "                                                '* Muon *',\n"
00165                     "                                                '* Tracking RecHit *',\n"
00166                     "                                                '/Objects/CMS Event and Detector/Magnet',\n"
00167                     "                                                '/Objects/Event Collections/Run and Event Number')\n\n";
00168     
00169     QDateTime dt = QDateTime::currentDateTime ();
00170     QString cfgFilename = "iguana-" + dt.toString ("hh:mm:ss.zzz-dd.MM.yyyy") + "_cfg.py";
00171     
00172     QFile iguanaConfigFile (cfgFilename);
00173     if (! iguanaConfigFile.exists ())
00174     {    
00175         if (iguanaConfigFile.open (IO_WriteOnly)) 
00176         {
00177             QTextStream cfgStream (&iguanaConfigFile);
00178             cfgStream << configstring;
00179             iguanaConfigFile.close ();
00180         }       
00181     }
00182 
00183     return cfgFilename.latin1 ();
00184 }

VisEventProcessorService::IG_DECLARE_STATE_ELEMENT ( VisEventProcessorService   )  [private]

void VisEventProcessorService::init ( void   )  [private]

Definition at line 58 of file VisEventProcessorService.cc.

References edmplugin::standard::config(), edmplugin::PluginManager::configure(), e, edm::PresenceFactory::get(), LFfwvis, LOG, m_messageServicePresence, m_onCmsException, m_onStatusMessage, and GsfMatrixTools::trace().

Referenced by VisEventProcessorService().

00059 {
00060     LOG (0, trace, LFfwvis, "VisEventProcessorService::init\n");
00061 
00062     if (this->m_onStatusMessage)
00063         this->m_onStatusMessage ("EventProcessor initialization...");
00064         
00065     // We must initialize the plug-in manager first
00066     try 
00067     {
00068         edmplugin::PluginManager::configure (edmplugin::standard::config ());
00069     } 
00070     catch (cms::Exception& e)
00071     {
00072         if (this->m_onCmsException)
00073             this->m_onCmsException (&e);
00074     }
00075    
00076     try 
00077     {
00078         m_messageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get ()->
00079                                                                     makePresence ("MessageServicePresence").release ());
00080     } 
00081     catch (cms::Exception& e) 
00082     {
00083         if (this->m_onCmsException)
00084             this->m_onCmsException (&e);
00085     }
00086 
00087     LOG (0, trace, LFfwvis, "VisEventProcessorService::init: Done.\n");
00088 }

void VisEventProcessorService::initEventProcessor ( void   ) 

Definition at line 187 of file VisEventProcessorService.cc.

References IgArgsElement::args(), IgArgsElement::argv(), configFile(), configRootFile(), edm::ServiceRegistry::createContaining(), e, error, exception, aod_PYTHIA_cfg::fileName, DBSPlugin::get(), edm::serviceregistry::kTokenOverrides, m_ep, m_onException, m_onFrameworkException, m_onProcessorStarted, m_onStartingProcessor, m_onStatusMessage, m_onUnhandledException, m_running, m_state, Config::options, p, and edm::readConfigFile().

Referenced by VisWebFrameworkService::doInitSession(), and VisMainProgram::init().

00188 {    
00189     IgArgsElement *args = IgArgsElement::get (m_state);
00190     m_running = true;
00191 
00192     char const* const kParameterSetOpt = "parameter-set";    
00193     char const* const kParameterSetCommandOpt = "parameter-set,p";
00194     char const* const kJobreportCommandOpt = "jobreport,j";
00195     char const* const kEnableJobreportCommandOpt = "enablejobreport,e";
00196     char const* const kJobModeCommandOpt = "mode,m";
00197     char const* const kHelpCommandOpt = "help,h";
00198     char const* const kStrictOpt = "strict";
00199 
00200     std::string descString (args->argv ()[0]);
00201     descString += " [options] [--";
00202     descString += kParameterSetOpt;
00203     descString += "] config_file \nAllowed options";
00204     boost::program_options::options_description desc (descString);
00205     
00206     desc.add_options ()
00207         (kHelpCommandOpt, "produce help message")
00208         (kParameterSetCommandOpt, boost::program_options::value<std::string> (), "configuration file")
00209         (kJobreportCommandOpt, boost::program_options::value<std::string> (),
00210          "file name to use for a job report file: default extension is .xml")
00211         (kEnableJobreportCommandOpt, 
00212          "enable job report files (if any) specified in configuration file")
00213         (kJobModeCommandOpt, boost::program_options::value<std::string> (),
00214          "Job Mode for MessageLogger defaults - default mode is grid")
00215         (kStrictOpt, "strict parsing");
00216 
00217     boost::program_options::positional_options_description p;
00218     p.add (kParameterSetOpt, -1);
00219 
00220     boost::program_options::options_description all_options ("All Options");
00221     all_options.add (desc);
00222     
00223     boost::program_options::variables_map vm;
00224     try 
00225     {
00226         store (boost::program_options::command_line_parser (args->args (),args->argv ()).options (all_options).positional (p).run (), vm);
00227         notify (vm);
00228     } 
00229     catch (boost::program_options::error const& iException) 
00230     {
00231         edm::LogError ("FwkJob") << "Exception from command line processing: " << iException.what ();
00232         edm::LogSystem ("CommandLineProcessing") << "Exception from command line processing: " << iException.what () << "\n";
00233         return;
00234     }    
00235     try 
00236     {
00237         //
00238         // Decide whether to enable creation of job report xml file 
00239         //  We do this first so any errors will be reported
00240         // 
00241         std::auto_ptr<std::ofstream> jobReportStreamPtr;
00242         if (vm.count ("jobreport")) 
00243         {
00244             std::string jobReportFile = vm ["jobreport"].as<std::string> ();
00245             jobReportStreamPtr = std::auto_ptr<std::ofstream> (new std::ofstream (jobReportFile.c_str ()));
00246         } 
00247         else if (vm.count ("enablejobreport")) 
00248         {
00249             jobReportStreamPtr = std::auto_ptr<std::ofstream> (new std::ofstream ("IguanaJobReport.xml"));
00250         } 
00251         //
00252         // Make JobReport Service up front
00253         // 
00254         //NOTE: JobReport must have a lifetime shorter than jobReportStreamPtr so that when the JobReport destructor
00255         // is called jobReportStreamPtr is still valid  
00256         // Make JobReport Service up front
00257         std::auto_ptr<edm::JobReport> jobRep (new edm::JobReport (jobReportStreamPtr.get ()));  
00258         edm::ServiceToken jobReportToken = 
00259             edm::ServiceRegistry::createContaining (jobRep);
00260         
00261         std::string fileName;
00262         
00263         if (vm.count (kParameterSetOpt)) 
00264             fileName = (vm [kParameterSetOpt].as<std::string> ());
00265 
00266         boost::shared_ptr<edm::ProcessDesc> processDesc;
00267         if (fileName.size() > 4 && fileName.substr (fileName.size () - 5) == ".root")
00268         {
00269             std::string configString = configRootFile (fileName);
00270             fileName = configString;
00271         }
00272         else if (fileName.empty ()) 
00273         {
00274             std::string configString = configFile ();
00275             fileName = configString;
00276         }
00277         processDesc = edm::readConfigFile (fileName);
00278 
00279         if (this->m_onStartingProcessor)
00280             this->m_onStartingProcessor ();
00281         
00282         // Specify default services to be enabled with their default parameters.
00283         // The parameters for these can be overridden from the configuration files.
00284         std::vector<std::string> defaultServices;
00285         defaultServices.reserve (5);
00286 
00287         // These cannot be overridden from the configuration files.
00288         // An exception will be thrown if any of these is specified there.
00289         std::vector<std::string> forcedServices;
00290         forcedServices.reserve(2);
00291 
00292         defaultServices.push_back ("MessageLogger");
00293         defaultServices.push_back ("InitRootHandlers");
00294         defaultServices.push_back ("AdaptorConfig");
00295         defaultServices.push_back ("EnableFloatingPointExceptions");
00296         defaultServices.push_back ("UnixSignalService");
00297 
00298         forcedServices.push_back ("JobReportService");
00299         forcedServices.push_back ("SiteLocalConfigService");
00300 
00301         processDesc->addServices(defaultServices, forcedServices);
00302 
00303         if (this->m_onStatusMessage)
00304             this->m_onStatusMessage ("Waiting for CMSSW to load EventProcessor and its services. Please, be patient, it takes a while.........");
00305 
00306         std::auto_ptr<edm::EventProcessor> procP (new edm::EventProcessor (processDesc, 
00307                                                                            jobReportToken, 
00308                                                                            edm::serviceregistry::kTokenOverrides));
00309         m_ep = procP;
00310             
00311         if (this->m_onProcessorStarted)
00312             this->m_onProcessorStarted ();          
00313     }
00314     catch (lat::Error &e)
00315     {
00316         if (this->m_onFrameworkException)
00317             this->m_onFrameworkException (&e);
00318     }
00319     catch (std::exception &e)
00320     {
00321         if (this->m_onException)
00322             this->m_onException (&e);
00323     }
00324     catch (...)
00325     {
00326         if (this->m_onUnhandledException)
00327             this->m_onUnhandledException ();
00328     }
00329 }

edm::JobReport* VisEventProcessorService::jobReport ( void   )  [inline]

Definition at line 49 of file VisEventProcessorService.h.

References m_jobRep.

00049                                    {
00050         return m_jobRep.get ();
00051     }

void VisEventProcessorService::off (  )  [inline]

Definition at line 42 of file VisEventProcessorService.h.

References m_callEndJob.

00042                 {
00043         m_callEndJob = false;
00044     }

void VisEventProcessorService::on (  )  [inline]

Definition at line 39 of file VisEventProcessorService.h.

References m_callEndJob.

00039                {
00040         m_callEndJob = true;
00041     }

void VisEventProcessorService::onCmsException ( lat::Callback1< cms::Exception * >  callback  ) 

Definition at line 406 of file VisEventProcessorService.cc.

References m_onCmsException.

Referenced by VisMainProgram::init().

00407 {
00408     m_onCmsException = callback;    
00409 }

void VisEventProcessorService::onConfigFailure ( lat::Callback1< cms::Exception * >  callback  ) 

Definition at line 424 of file VisEventProcessorService.cc.

References m_onConfigFailure.

Referenced by VisMainProgram::init().

00425 {
00426     m_onConfigFailure = callback;    
00427 }

void VisEventProcessorService::onException ( lat::Callback1< std::exception * >  callback  ) 

Definition at line 400 of file VisEventProcessorService.cc.

References m_onException.

Referenced by VisMainProgram::init().

00401 {
00402     m_onException = callback;    
00403 }

void VisEventProcessorService::onFrameworkException ( lat::Callback1< lat::Error * >  callback  ) 

Definition at line 418 of file VisEventProcessorService.cc.

References m_onFrameworkException.

Referenced by VisMainProgram::init().

00419 {
00420     m_onFrameworkException = callback;    
00421 }

void VisEventProcessorService::onProcessorStarted ( lat::Callback  callback  ) 

Definition at line 388 of file VisEventProcessorService.cc.

References m_onProcessorStarted.

Referenced by VisMainProgram::init().

00389 {
00390     m_onProcessorStarted = callback;    
00391 }

void VisEventProcessorService::onProcessorStopped ( lat::Callback  callback  ) 

Definition at line 394 of file VisEventProcessorService.cc.

References m_onProcessorStopped.

Referenced by VisMainProgram::init().

00395 {
00396     m_onProcessorStopped = callback;    
00397 }

void VisEventProcessorService::onStartingProcessor ( lat::Callback  callback  ) 

Definition at line 376 of file VisEventProcessorService.cc.

References m_onStartingProcessor.

Referenced by VisMainProgram::init().

00377 {
00378     m_onStartingProcessor = callback;    
00379 }

void VisEventProcessorService::onStatusMessage ( lat::Callback1< const std::string & >  callback  ) 

Definition at line 430 of file VisEventProcessorService.cc.

References m_onStatusMessage.

Referenced by VisMainProgram::init().

00431 {
00432     m_onStatusMessage = callback;    
00433 }

void VisEventProcessorService::onStoppingProcessor ( lat::Callback  callback  ) 

Definition at line 382 of file VisEventProcessorService.cc.

References m_onStoppingProcessor.

Referenced by VisMainProgram::init().

00383 {
00384     m_onStoppingProcessor = callback;    
00385 }

void VisEventProcessorService::onUnhandledException ( lat::Callback  callback  ) 

Definition at line 412 of file VisEventProcessorService.cc.

References m_onUnhandledException.

Referenced by VisWebFrameworkService::doInitSession(), and VisMainProgram::init().

00413 {
00414     m_onUnhandledException = callback;    
00415 }

edm::EventProcessor* VisEventProcessorService::operator-> ( void   )  [inline]

Definition at line 46 of file VisEventProcessorService.h.

References m_ep.

00046                                      {
00047         return m_ep.get ();
00048     }

void VisEventProcessorService::reInitEventProcessor ( const std::string &  parameterSet  ) 

Definition at line 332 of file VisEventProcessorService.cc.

References e, exception, m_ep, m_onConfigFailure, m_onException, m_onFrameworkException, m_onProcessorStarted, and m_onUnhandledException.

Referenced by VisWebFrameworkService::doReconfigure().

00333 {
00334     std::string configstring = configString;
00335     
00336     if (configstring.empty ()) 
00337     {
00338         configstring =
00339             "process IGUANA = {"
00340             "source = EmptySource {}"
00341             "untracked PSet maxEvents = {untracked int32 input = 1}}"
00342             "}";
00343     }
00344     try 
00345     {
00346         std::auto_ptr<edm::EventProcessor> procP (new edm::EventProcessor (configstring));
00347         m_ep.reset ();
00348         m_ep = procP;
00349 
00350         if (this->m_onProcessorStarted)
00351             this->m_onProcessorStarted ();
00352     }
00353     catch (cms::Exception& iException) 
00354     {
00355         if (this->m_onConfigFailure)
00356             this->m_onConfigFailure (&iException);
00357     }
00358     catch (lat::Error &e)
00359     {
00360         if (this->m_onFrameworkException)
00361             this->m_onFrameworkException (&e);
00362     }
00363     catch (std::exception &e)
00364     {
00365         if (this->m_onException)
00366             this->m_onException (&e);
00367     }
00368     catch (...)
00369     {
00370         if (this->m_onUnhandledException)
00371             this->m_onUnhandledException ();
00372     }
00373 }

bool VisEventProcessorService::running ( void   ) 

Definition at line 442 of file VisEventProcessorService.cc.

References m_running.

00443 {
00444     return m_running;
00445 }

void VisEventProcessorService::scheduleAbort ( void   ) 

Definition at line 436 of file VisEventProcessorService.cc.

References m_running.

00437 {
00438     m_running = false;
00439 }


Member Data Documentation

bool VisEventProcessorService::m_callEndJob [private]

Definition at line 75 of file VisEventProcessorService.h.

Referenced by off(), on(), and ~VisEventProcessorService().

std::auto_ptr<edm::EventProcessor> VisEventProcessorService::m_ep [private]

Definition at line 71 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), operator->(), reInitEventProcessor(), and ~VisEventProcessorService().

std::auto_ptr<edm::JobReport> VisEventProcessorService::m_jobRep [private]

Definition at line 73 of file VisEventProcessorService.h.

Referenced by jobReport().

boost::shared_ptr<edm::Presence> VisEventProcessorService::m_messageServicePresence [private]

Definition at line 72 of file VisEventProcessorService.h.

Referenced by init().

lat::Callback1<cms::Exception *> VisEventProcessorService::m_onCmsException [private]

Definition at line 82 of file VisEventProcessorService.h.

Referenced by init(), and onCmsException().

lat::Callback1<cms::Exception *> VisEventProcessorService::m_onConfigFailure [private]

Definition at line 86 of file VisEventProcessorService.h.

Referenced by onConfigFailure(), and reInitEventProcessor().

lat::Callback1<std::exception *> VisEventProcessorService::m_onException [private]

Definition at line 83 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), onException(), and reInitEventProcessor().

lat::Callback1<lat::Error *> VisEventProcessorService::m_onFrameworkException [private]

Definition at line 84 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), onFrameworkException(), and reInitEventProcessor().

lat::Callback VisEventProcessorService::m_onProcessorStarted [private]

Definition at line 80 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), onProcessorStarted(), and reInitEventProcessor().

lat::Callback VisEventProcessorService::m_onProcessorStopped [private]

Definition at line 81 of file VisEventProcessorService.h.

Referenced by onProcessorStopped().

lat::Callback VisEventProcessorService::m_onStartingProcessor [private]

Definition at line 78 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), and onStartingProcessor().

lat::Callback1<const std::string&> VisEventProcessorService::m_onStatusMessage [private]

Definition at line 87 of file VisEventProcessorService.h.

Referenced by configFile(), init(), initEventProcessor(), and onStatusMessage().

lat::Callback VisEventProcessorService::m_onStoppingProcessor [private]

Definition at line 79 of file VisEventProcessorService.h.

Referenced by onStoppingProcessor().

lat::Callback VisEventProcessorService::m_onUnhandledException [private]

Definition at line 85 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), onUnhandledException(), and reInitEventProcessor().

bool VisEventProcessorService::m_running [private]

Definition at line 76 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), running(), and scheduleAbort().

IgState* VisEventProcessorService::m_state [private]

Definition at line 77 of file VisEventProcessorService.h.

Referenced by initEventProcessor(), and ~VisEventProcessorService().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:35:21 2009 for CMSSW by  doxygen 1.5.4