CMS 3D CMS Logo

GsfVertexConstraintProducer.cc
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 
4 // user include files
7 
10 
16 
17 //
18 // class decleration
19 //
20 
22 public:
24  ~GsfVertexConstraintProducer() override = default;
25 
26 private:
27  void produce(edm::StreamID streamid, edm::Event&, const edm::EventSetup&) const override;
28 
29  // ----------member data ---------------------------
32 
33 };
34 
35 //
36 // constants, enums and typedefs
37 //
38 
39 //
40 // static data member definitions
41 //
42 
43 //
44 // constructors and destructor
45 //
47 srcTrkTag_(iConfig.getParameter<edm::InputTag>("src"))
48 {
49  //declare the consumes
50  trkToken_ = consumes<reco::GsfTrackCollection>(edm::InputTag(srcTrkTag_));
51 
52  //register your products
53  produces<std::vector<VertexConstraint> >();
54  produces<GsfTrackVtxConstraintAssociationCollection>();
55 
56  //now do what ever other initialization is needed
57 }
58 
59 
60 //
61 // member functions
62 //
63 
64 // ------------ method called to produce the data ------------
66 {
67  using namespace edm;
68 
69  Handle<reco::GsfTrackCollection> theTCollection;
70  iEvent.getByToken(trkToken_, theTCollection);
71 
72  edm::RefProd<std::vector<VertexConstraint> > rPairs = iEvent.getRefBeforePut<std::vector<VertexConstraint> >();
73  std::unique_ptr<std::vector<VertexConstraint> > pairs(new std::vector<VertexConstraint>);
74  std::unique_ptr<GsfTrackVtxConstraintAssociationCollection> output(new GsfTrackVtxConstraintAssociationCollection(theTCollection, rPairs));
75 
76  int index = 0;
77  for (reco::GsfTrackCollection::const_iterator i=theTCollection->begin(); i!=theTCollection->end();i++) {
78  VertexConstraint tmp(GlobalPoint(0,0,0),GlobalError(0.01,0,0.01,0,0,0.001));
79  pairs->push_back(tmp);
80  output->insert(reco::GsfTrackRef(theTCollection,index), edm::Ref<std::vector<VertexConstraint> >(rPairs,index) );
81  index++;
82  }
83 
84  iEvent.put(std::move(pairs));
85  iEvent.put(std::move(output));
86 }
87 
88 //define this as a plug-in
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
GlobalErrorBase< double, ErrorMatrixTag > GlobalError
Definition: GlobalError.h:13
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::GsfTrackCollection > trkToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::pair< GlobalPoint, GlobalError > VertexConstraint
edm::AssociationMap< edm::OneToOne< reco::GsfTrackCollection, std::vector< VertexConstraint > > > GsfTrackVtxConstraintAssociationCollection
void produce(edm::StreamID streamid, edm::Event &, const edm::EventSetup &) const override
RefProd< PROD > getRefBeforePut()
Definition: Event.h:150
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
GsfVertexConstraintProducer(const edm::ParameterSet &)
def move(src, dest)
Definition: eostools.py:511
~GsfVertexConstraintProducer() override=default