CMS 3D CMS Logo

Phase2L1TGMTTkMuonProducer.cc
Go to the documentation of this file.
1 #include <memory>
4 
7 
12 
13 //
14 // class declaration
15 //
16 using namespace Phase2L1GMT;
17 using namespace l1t;
18 
20 public:
22  ~Phase2L1TGMTTkMuonProducer() override;
23 
24  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
25 
26 private:
27  void beginStream(edm::StreamID) override;
28  void produce(edm::Event&, const edm::EventSetup&) override;
29  void endStream() override;
30  std::unique_ptr<TPS> tps_;
34  int bxMin_;
35  int bxMax_;
36 };
37 
39  : tps_(new TPS(iConfig)),
40  srcTracks_(consumes<l1t::TrackerMuon::L1TTTrackCollection>(iConfig.getParameter<edm::InputTag>("srcTracks"))),
41  srcStubs_(consumes<std::vector<l1t::MuonStub> >(iConfig.getParameter<edm::InputTag>("srcStubs"))),
42  minTrackStubs_(iConfig.getParameter<int>("minTrackStubs")),
43  bxMin_(iConfig.getParameter<int>("muonBXMin")),
44  bxMax_(iConfig.getParameter<int>("muonBXMax"))
45 
46 {
47  produces<std::vector<l1t::TrackerMuon> >();
48 }
49 
51  // do anything here that needs to be done at destruction time
52  // (e.g. close files, deallocate resources etc.)
53 }
54 
55 //
56 // member functions
57 //
58 
59 // ------------ method called to produce the data ------------
61  using namespace edm;
63  iEvent.getByToken(srcTracks_, trackHandle);
64  std::vector<edm::Ptr<l1t::TrackerMuon::L1TTTrackType> > tracks;
65  for (uint i = 0; i < trackHandle->size(); ++i) {
67  if (track->momentum().transverse() < 2.0)
68  continue;
69  if (track->getStubRefs().size() >= (unsigned int)(minTrackStubs_))
70  tracks.push_back(track);
71  }
72 
73  l1t::MuonStubRefVector muonStubs;
75  iEvent.getByToken(srcStubs_, stubHandle);
76  for (size_t i = 0; i < stubHandle->size(); ++i) {
77  MuonStubRef stub(stubHandle, i);
78  muonStubs.push_back(stub);
79  }
80 
81  std::vector<l1t::TrackerMuon> out = tps_->processEvent(tracks, muonStubs);
82  std::unique_ptr<std::vector<l1t::TrackerMuon> > out1 = std::make_unique<std::vector<l1t::TrackerMuon> >(out);
83  iEvent.put(std::move(out1));
84 }
85 
86 // ------------ method called once each stream before processing any runs, lumis or events ------------
88 
89 // ------------ method called once each stream after processing all runs, lumis and events ------------
91 
93  //The following says we do not know what parameters are allowed so do no validation
94  // Please change this to state exactly what you do use, even if it is no parameters
96  desc.setUnknown();
97  descriptions.addDefault(desc);
98 }
99 
100 //define this as a plug-in
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void beginStream(edm::StreamID) override
delete x;
Definition: CaloConfig.h:22
Phase2L1TGMTTkMuonProducer(const edm::ParameterSet &)
std::vector< L1TTTrackType > L1TTTrackCollection
Definition: L1CaloTkTau.h:32
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
edm::EDGetTokenT< std::vector< l1t::MuonStub > > srcStubs_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< l1t::TrackerMuon::L1TTTrackCollection > srcTracks_
HLT enums.
def move(src, dest)
Definition: eostools.py:511