Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:27:59

0001 // system include files
0002 #include <memory>
0003 
0004 // user include files
0005 #include "FWCore/Framework/interface/Frameworkfwd.h"
0006 #include "FWCore/Framework/interface/global/EDProducer.h"
0007 
0008 #include "FWCore/Framework/interface/Event.h"
0009 #include "FWCore/Framework/interface/MakerMacros.h"
0010 
0011 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0012 #include "FWCore/Utilities/interface/InputTag.h"
0013 #include "DataFormats/GsfTrackReco/interface/GsfTrack.h"
0014 #include "DataFormats/GsfTrackReco/interface/GsfTrackFwd.h"
0015 #include "TrackingTools/GsfTracking/interface/GsfTrackConstraintAssociation.h"
0016 
0017 //
0018 // class decleration
0019 //
0020 
0021 class GsfVertexConstraintProducer : public edm::global::EDProducer<> {
0022 public:
0023   explicit GsfVertexConstraintProducer(const edm::ParameterSet&);
0024   ~GsfVertexConstraintProducer() override = default;
0025 
0026 private:
0027   void produce(edm::StreamID streamid, edm::Event&, const edm::EventSetup&) const override;
0028 
0029   // ----------member data ---------------------------
0030   const edm::InputTag srcTrkTag_;
0031   edm::EDGetTokenT<reco::GsfTrackCollection> trkToken_;
0032 };
0033 
0034 //
0035 // constants, enums and typedefs
0036 //
0037 
0038 //
0039 // static data member definitions
0040 //
0041 
0042 //
0043 // constructors and destructor
0044 //
0045 GsfVertexConstraintProducer::GsfVertexConstraintProducer(const edm::ParameterSet& iConfig)
0046     : srcTrkTag_(iConfig.getParameter<edm::InputTag>("src")) {
0047   //declare the consumes
0048   trkToken_ = consumes<reco::GsfTrackCollection>(edm::InputTag(srcTrkTag_));
0049 
0050   //register your products
0051   produces<std::vector<VertexConstraint> >();
0052   produces<GsfTrackVtxConstraintAssociationCollection>();
0053 
0054   //now do what ever other initialization is needed
0055 }
0056 
0057 //
0058 // member functions
0059 //
0060 
0061 // ------------ method called to produce the data  ------------
0062 void GsfVertexConstraintProducer::produce(edm::StreamID streamid,
0063                                           edm::Event& iEvent,
0064                                           const edm::EventSetup& iSetup) const {
0065   using namespace edm;
0066 
0067   Handle<reco::GsfTrackCollection> theTCollection;
0068   iEvent.getByToken(trkToken_, theTCollection);
0069 
0070   edm::RefProd<std::vector<VertexConstraint> > rPairs = iEvent.getRefBeforePut<std::vector<VertexConstraint> >();
0071   std::unique_ptr<std::vector<VertexConstraint> > pairs(new std::vector<VertexConstraint>);
0072   std::unique_ptr<GsfTrackVtxConstraintAssociationCollection> output(
0073       new GsfTrackVtxConstraintAssociationCollection(theTCollection, rPairs));
0074 
0075   int index = 0;
0076   for (reco::GsfTrackCollection::const_iterator i = theTCollection->begin(); i != theTCollection->end(); i++) {
0077     VertexConstraint tmp(GlobalPoint(0, 0, 0), GlobalError(0.01, 0, 0.01, 0, 0, 0.001));
0078     pairs->push_back(tmp);
0079     output->insert(reco::GsfTrackRef(theTCollection, index), edm::Ref<std::vector<VertexConstraint> >(rPairs, index));
0080     index++;
0081   }
0082 
0083   iEvent.put(std::move(pairs));
0084   iEvent.put(std::move(output));
0085 }
0086 
0087 //define this as a plug-in
0088 DEFINE_FWK_MODULE(GsfVertexConstraintProducer);