Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-08-09 23:47:33

0001 // -*- C++ -*-
0002 //
0003 // Package:    L1Trigger/VertexFinder
0004 // Class:      InputDataProducer
0005 //
0006 /**\class InputDataProducer InputDataProducer.cc L1Trigger/VertexFinder/plugins/InputDataProducer.cc
0007 
0008  Description: Produces an InputData object which stores generator level information for further analysis
0009 
0010  Implementation:
0011      [Notes on implementation]
0012 */
0013 //
0014 // Original Author:  Alexx Perloff
0015 //         Created:  Fri, 05 Feb 2021 23:42:17 GMT
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 #include <vector>
0022 
0023 // user include files
0024 #include "DataFormats/L1TrackTrigger/interface/TTTypes.h"
0025 #include "DataFormats/HepMCCandidate/interface/GenParticle.h"
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/global/EDProducer.h"
0028 #include "FWCore/Framework/interface/Event.h"
0029 #include "FWCore/Framework/interface/MakerMacros.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0032 #include "FWCore/Utilities/interface/InputTag.h"
0033 #include "FWCore/Utilities/interface/StreamID.h"
0034 #include "L1Trigger/VertexFinder/interface/AnalysisSettings.h"
0035 #include "L1Trigger/VertexFinder/interface/InputData.h"
0036 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0037 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0038 #include "SimDataFormats/Associations/interface/TTClusterAssociationMap.h"
0039 #include "SimDataFormats/Associations/interface/TTStubAssociationMap.h"
0040 
0041 //
0042 // class declaration
0043 //
0044 
0045 class InputDataProducer : public edm::global::EDProducer<> {
0046 public:
0047   explicit InputDataProducer(const edm::ParameterSet&);
0048   ~InputDataProducer() override;
0049 
0050   static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
0051 
0052 private:
0053   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0054 
0055   // ----------constants, enums and typedefs ---------
0056   typedef edmNew::DetSetVector<TTStub<Ref_Phase2TrackerDigi_>> DetSetVec;
0057 
0058   // ----------member data ---------------------------
0059   const std::string outputCollectionName_;
0060   l1tVertexFinder::AnalysisSettings settings_;
0061   const edm::EDGetTokenT<edm::HepMCProduct> hepMCToken_;
0062   const edm::EDGetTokenT<edm::View<reco::GenParticle>> genParticlesToken_;
0063   const edm::EDGetTokenT<edm::View<TrackingParticle>> tpToken_;
0064   const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::TP>> tpValueMapToken_;
0065   const edm::EDGetTokenT<DetSetVec> stubToken_;
0066   const edm::EDGetTokenT<edm::ValueMap<l1tVertexFinder::Stub>> stubValueMapToken_;
0067   const edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> tTopoToken_;
0068   const edm::ESGetToken<TrackerGeometry, TrackerDigiGeometryRecord> tGeomToken_;
0069 };
0070 
0071 //
0072 // constructors and destructor
0073 //
0074 InputDataProducer::InputDataProducer(const edm::ParameterSet& iConfig)
0075     : outputCollectionName_(iConfig.getParameter<std::string>("outputCollectionName")),
0076       settings_(iConfig),
0077       hepMCToken_(consumes<edm::HepMCProduct>(iConfig.getParameter<edm::InputTag>("hepMCInputTag"))),
0078       genParticlesToken_(
0079           consumes<edm::View<reco::GenParticle>>(iConfig.getParameter<edm::InputTag>("genParticleInputTag"))),
0080       tpToken_(consumes<edm::View<TrackingParticle>>(iConfig.getParameter<edm::InputTag>("tpInputTag"))),
0081       tpValueMapToken_(
0082           consumes<edm::ValueMap<l1tVertexFinder::TP>>(iConfig.getParameter<edm::InputTag>("tpValueMapInputTag"))),
0083       stubToken_(consumes<DetSetVec>(iConfig.getParameter<edm::InputTag>("stubInputTag"))),
0084       tTopoToken_(esConsumes<TrackerTopology, TrackerTopologyRcd>(edm::ESInputTag("", ""))),
0085       tGeomToken_(esConsumes<TrackerGeometry, TrackerDigiGeometryRecord>(edm::ESInputTag("", ""))) {
0086   // Define EDM output to be written to file (if required)
0087   produces<l1tVertexFinder::InputData>(outputCollectionName_);
0088 
0089   //now do what ever other initialization is needed
0090 }
0091 
0092 InputDataProducer::~InputDataProducer() {}
0093 
0094 //
0095 // member functions
0096 //
0097 
0098 // ------------ method called to produce the data  ------------
0099 void InputDataProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0100   std::unique_ptr<l1tVertexFinder::InputData> product = std::make_unique<l1tVertexFinder::InputData>(iEvent,
0101                                                                                                      iSetup,
0102                                                                                                      settings_,
0103                                                                                                      hepMCToken_,
0104                                                                                                      genParticlesToken_,
0105                                                                                                      tpToken_,
0106                                                                                                      tpValueMapToken_,
0107                                                                                                      stubToken_,
0108                                                                                                      tTopoToken_,
0109                                                                                                      tGeomToken_);
0110 
0111   iEvent.put(std::move(product), outputCollectionName_);
0112 }
0113 
0114 // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0115 void InputDataProducer::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0116   //The following says we do not know what parameters are allowed so do no validation
0117   // Please change this to state exactly what you do use, even if it is no parameters
0118   edm::ParameterSetDescription desc;
0119   desc.setUnknown();
0120   descriptions.addDefault(desc);
0121 }
0122 
0123 //define this as a plug-in
0124 DEFINE_FWK_MODULE(InputDataProducer);