CMS 3D CMS Logo

Phase2L1TGMTProducer.cc
Go to the documentation of this file.
1 #include <memory>
4 
7 
11 #include "Node.h"
12 
13 //
14 // class declaration
15 //
16 using namespace Phase2L1GMT;
17 using namespace l1t;
18 
20 public:
21  explicit Phase2L1TGMTProducer(const edm::ParameterSet&);
22  ~Phase2L1TGMTProducer() 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<Node> node_;
37  int bxMin_;
38  int bxMax_;
39 };
40 
42  : node_(new Node(iConfig)),
43  srcTracks_(consumes<l1t::TrackerMuon::L1TTTrackCollection>(iConfig.getParameter<edm::InputTag>("srcTracks"))),
44  srcStubs_(consumes<std::vector<l1t::MuonStub> >(iConfig.getParameter<edm::InputTag>("srcStubs"))),
45  bmtfTracks_(consumes<BXVector<RegionalMuonCand> >(iConfig.getParameter<edm::InputTag>("srcBMTF"))),
46  emtfTracks_(consumes<BXVector<RegionalMuonCand> >(iConfig.getParameter<edm::InputTag>("srcEMTF"))),
47  omtfTracks_(consumes<BXVector<RegionalMuonCand> >(iConfig.getParameter<edm::InputTag>("srcOMTF"))),
48  minTrackStubs_(iConfig.getParameter<int>("minTrackStubs")),
49  bxMin_(iConfig.getParameter<int>("muonBXMin")),
50  bxMax_(iConfig.getParameter<int>("muonBXMax"))
51 
52 {
53  produces<std::vector<l1t::TrackerMuon> >();
54 }
55 
57  // do anything here that needs to be done at destruction time
58  // (e.g. close files, deallocate resources etc.)
59 }
60 
61 //
62 // member functions
63 //
64 
65 // ------------ method called to produce the data ------------
67  using namespace edm;
69  iEvent.getByToken(srcTracks_, trackHandle);
70  std::vector<edm::Ptr<l1t::TrackerMuon::L1TTTrackType> > tracks;
71  for (uint i = 0; i < trackHandle->size(); ++i) {
73  if (track->momentum().transverse() < 2.0)
74  continue;
75  if (track->getStubRefs().size() >= (unsigned int)(minTrackStubs_))
76  tracks.push_back(track);
77  }
78 
80  iEvent.getByToken(srcStubs_, stubHandle);
82  for (uint i = 0; i < stubHandle->size(); ++i) {
83  l1t::MuonStubRef stub(stubHandle, i);
84  if (stub->bxNum() >= bxMin_ && stub->bxNum() <= bxMax_)
85  stubs.push_back(stub);
86  }
87 
89  // BXVector<RegionalMuonCand> muonTracks;
90 
92  iEvent.getByToken(bmtfTracks_, bmtfHandle);
94  iEvent.getByToken(emtfTracks_, emtfHandle);
96  iEvent.getByToken(omtfTracks_, omtfHandle);
97 
98  for (int bx = bxMin_; bx <= bxMax_; ++bx) {
99  if (bx >= bmtfHandle->getFirstBX() && bx <= bmtfHandle->getLastBX())
100  for (size_t i = 0; i < bmtfHandle->size(bx); ++i) {
101  RegionalMuonCandRef muon(bmtfHandle, i);
102  muonTracks.push_back(bx, muon);
103  }
104  if (bx >= omtfHandle->getFirstBX() && bx <= omtfHandle->getLastBX())
105  for (size_t i = 0; i < omtfHandle->size(bx); ++i) {
106  RegionalMuonCandRef muon(omtfHandle, i);
107  muonTracks.push_back(bx, muon);
108  }
109  if (bx >= emtfHandle->getFirstBX() && bx <= emtfHandle->getLastBX())
110  for (size_t i = 0; i < emtfHandle->size(bx); ++i) {
111  RegionalMuonCandRef muon(emtfHandle, i);
112  muonTracks.push_back(bx, muon);
113  }
114  }
115 
116  std::vector<l1t::TrackerMuon> out = node_->processEvent(tracks, muonTracks, stubs);
117  std::unique_ptr<std::vector<l1t::TrackerMuon> > out1 = std::make_unique<std::vector<l1t::TrackerMuon> >(out);
118  iEvent.put(std::move(out1));
119 }
120 
121 // ------------ method called once each stream before processing any runs, lumis or events ------------
123 
124 // ------------ method called once each stream after processing all runs, lumis and events ------------
126 
128  //The following says we do not know what parameters are allowed so do no validation
129  // Please change this to state exactly what you do use, even if it is no parameters
131  desc.setUnknown();
132  descriptions.addDefault(desc);
133 }
134 
135 //define this as a plug-in
void beginStream(edm::StreamID) override
edm::EDGetTokenT< BXVector< RegionalMuonCand > > omtfTracks_
Phase2L1TGMTProducer(const edm::ParameterSet &)
void produce(edm::Event &, const edm::EventSetup &) override
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
delete x;
Definition: CaloConfig.h:22
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)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLT enums.
edm::EDGetTokenT< std::vector< l1t::MuonStub > > srcStubs_
edm::EDGetTokenT< l1t::TrackerMuon::L1TTTrackCollection > srcTracks_
edm::EDGetTokenT< BXVector< RegionalMuonCand > > emtfTracks_
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< Node > node_
edm::EDGetTokenT< BXVector< RegionalMuonCand > > bmtfTracks_