Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:31

0001 #ifndef Watcher_SimWatcherMaker_h
0002 #define Watcher_SimWatcherMaker_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Watcher
0006 // Class  :     SimWatcherMaker
0007 //
0008 /**\class SimWatcherMaker SimWatcherMaker.h
0009  SimG4Core/Watcher/interface/SimWatcherMaker.h
0010 
0011  Description: Makes a particular type of SimWatcher
0012 
0013  Usage:
0014     <usage>
0015 
0016 */
0017 //
0018 // Original Author:
0019 //         Created:  Tue Nov 22 13:03:44 EST 2005
0020 //
0021 
0022 // system include files
0023 #include <memory>
0024 
0025 // user include files
0026 #include "SimG4Core/Notification/interface/SimActivityRegistryEnroller.h"
0027 #include "SimG4Core/Watcher/interface/SimWatcherMakerBase.h"
0028 
0029 // forward declarations
0030 
0031 template <class T>
0032 class SimWatcherMaker : public SimWatcherMakerBase {
0033 public:
0034   SimWatcherMaker() {}
0035 
0036   // ---------- const member functions ---------------------
0037   void make(const edm::ParameterSet &p,
0038             SimActivityRegistry &reg,
0039             std::shared_ptr<SimWatcher> &oWatcher,
0040             std::shared_ptr<SimProducer> &oProd) const override {
0041     auto returnValue = std::make_shared<T>(p);
0042     SimActivityRegistryEnroller::enroll(reg, returnValue.get());
0043     oWatcher = returnValue;
0044 
0045     // If this is also a SimProducer, set the value
0046     oProd = this->getSimProducer(returnValue.get(), returnValue);
0047   }
0048 
0049 private:
0050   std::shared_ptr<SimProducer> getSimProducer(SimProducer *, std::shared_ptr<T> &iProd) const {
0051     return std::shared_ptr<SimProducer>(iProd);
0052   }
0053   std::shared_ptr<SimProducer> getSimProducer(void *, std::shared_ptr<T> &iProd) const {
0054     return std::shared_ptr<SimProducer>();
0055   }
0056 };
0057 
0058 #endif