Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:19

0001 #include <memory>
0002 
0003 #include "FWCore/Framework/interface/Frameworkfwd.h"
0004 #include "FWCore/Framework/interface/one/EDProducer.h"
0005 
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "FWCore/Framework/interface/MakerMacros.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0012 #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
0013 
0014 class EmptySimHits : public edm::one::EDProducer<> {
0015 public:
0016   explicit EmptySimHits(const edm::ParameterSet&);
0017   ~EmptySimHits() override {}
0018 
0019   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0020 
0021 private:
0022   void beginJob() override {}
0023   void produce(edm::Event&, const edm::EventSetup&) override;
0024   void endJob() override {}
0025 
0026   const std::vector<std::string> pSimHitInstanceLabels;
0027   const std::vector<std::string> pCaloHitInstanceLabels;
0028 };
0029 
0030 EmptySimHits::EmptySimHits(const edm::ParameterSet& iConfig)
0031     : pSimHitInstanceLabels(iConfig.getParameter<std::vector<std::string> >("pSimHitInstanceLabels")),
0032       pCaloHitInstanceLabels(iConfig.getParameter<std::vector<std::string> >("pCaloHitInstanceLabels")) {
0033   for (size_t i = 0; i < pSimHitInstanceLabels.size(); i++) {
0034     produces<edm::PSimHitContainer>(pSimHitInstanceLabels[i]);
0035   }
0036 
0037   for (size_t i = 0; i < pCaloHitInstanceLabels.size(); i++) {
0038     produces<edm::PCaloHitContainer>(pCaloHitInstanceLabels[i]);
0039   }
0040 }
0041 
0042 void EmptySimHits::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) {
0043   for (size_t i = 0; i < pSimHitInstanceLabels.size(); i++) {
0044     std::unique_ptr<edm::PSimHitContainer> pSimHitContainer(new edm::PSimHitContainer());
0045     iEvent.put(std::move(pSimHitContainer), pSimHitInstanceLabels[i]);
0046   }
0047 
0048   for (size_t i = 0; i < pCaloHitInstanceLabels.size(); i++) {
0049     std::unique_ptr<edm::PCaloHitContainer> pCaloHitContainer(new edm::PCaloHitContainer());
0050     iEvent.put(std::move(pCaloHitContainer), pCaloHitInstanceLabels[i]);
0051   }
0052 }
0053 
0054 void EmptySimHits::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0055   //The following says we do not know what parameters are allowed so do no validation
0056   // Please change this to state exactly what you do use, even if it is no parameters
0057   edm::ParameterSetDescription desc;
0058   desc.setUnknown();
0059   descriptions.addDefault(desc);
0060 }
0061 
0062 //define this as a plug-in
0063 DEFINE_FWK_MODULE(EmptySimHits);