CMS 3D CMS Logo

MomentumConstraintProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: MomentumConstraintProducer
4 // Class: MomentumConstraintProducer
5 //
13 //
14 // Original Author: Giuseppe Cerati
15 // Created: Tue Jul 10 15:05:02 CEST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
33 
35 
36 //
37 // class declaration
38 //
39 
41 public:
43  ~MomentumConstraintProducer() override = default;
44 
45 private:
46  void produce(edm::StreamID streamid, edm::Event&, const edm::EventSetup&) const override;
47 
48  // ----------member data ---------------------------
50  const double fixedmom_;
51  const double fixedmomerr_;
53 };
54 
55 //
56 // constants, enums and typedefs
57 //
58 
59 //
60 // static data member definitions
61 //
62 
63 //
64 // constructors and destructor
65 //
67  : srcTag_(iConfig.getParameter<edm::InputTag>("src")),
68  fixedmom_(iConfig.getParameter<double>("fixedMomentum")),
69  fixedmomerr_(iConfig.getParameter<double>("fixedMomentumError"))
70 
71 {
72  //register your products
73  produces<std::vector<MomentumConstraint>>();
74  produces<TrackMomConstraintAssociationCollection>();
75 
76  //now do what ever other initialization is needed
78  srcToken_ = iC.consumes<reco::TrackCollection>(srcTag_);
79 }
80 
81 //
82 // member functions
83 //
84 
85 // ------------ method called to produce the data ------------
88  const edm::EventSetup& iSetup) const {
89  using namespace edm;
90 
91  Handle<reco::TrackCollection> theTCollection;
92  iEvent.getByToken(srcToken_, theTCollection);
93 
94  edm::RefProd<std::vector<MomentumConstraint>> rPairs = iEvent.getRefBeforePut<std::vector<MomentumConstraint>>();
95 
96  std::unique_ptr<std::vector<MomentumConstraint>> pairs(new std::vector<MomentumConstraint>);
97  std::unique_ptr<TrackMomConstraintAssociationCollection> output(
98  new TrackMomConstraintAssociationCollection(theTCollection, rPairs));
99 
100  int index = 0;
101  for (reco::TrackCollection::const_iterator i = theTCollection->begin(); i != theTCollection->end(); i++) {
102  // MomentumConstraint tmp(10.,0.01) ;
103 
105  if (fixedmom_ < 0.0) {
107  }
108  pairs->push_back(tmp);
109  output->insert(reco::TrackRef(theTCollection, index), edm::Ref<std::vector<MomentumConstraint>>(rPairs, index));
110  index++;
111  }
112 
113  iEvent.put(std::move(pairs));
114  iEvent.put(std::move(output));
115 }
116 
117 //define this as a plug-in
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
edm::EDGetTokenT< reco::TrackCollection > srcToken_
int iEvent
Definition: GenABIO.cc:224
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::AssociationMap< edm::OneToOne< reco::TrackCollection, std::vector< MomentumConstraint > > > TrackMomConstraintAssociationCollection
MomentumConstraintProducer(const edm::ParameterSet &)
HLT enums.
~MomentumConstraintProducer() override=default
Definition: output.py:1
tmp
align.sh
Definition: createJobs.py:716
void produce(edm::StreamID streamid, edm::Event &, const edm::EventSetup &) const override
def move(src, dest)
Definition: eostools.py:511