CMS 3D CMS Logo

Phase2L1TGMTKMTFProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/Phase2L1GMT
4 // Class: Phase2L1TGMTSAMuonProducer
5 // Original Author: Michalis Bachtis
6 
7 #ifndef PHASE2GMT_KMTFPRODUCER
8 #define PHASE2GMT_KMTFPRODUCER
9 
10 // system include files
11 #include <memory>
12 #include <sstream>
13 
14 // user include files
17 
20 
23 
27 
31 
32 //
33 // class declaration
34 //
35 using namespace Phase2L1GMT;
36 using namespace l1t;
37 
39 public:
41  ~Phase2L1TGMTKMTFProducer() override = default;
42 
43 private:
44  void produce(edm::Event&, const edm::EventSetup&) override;
45 
46  // ----------member data ---------------------------
48  std::unique_ptr<KMTF> kmtf_;
49  unsigned int Nprompt;
50  unsigned int Ndisplaced;
51 };
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 //
62 // constructors and destructor
63 //
65  : stubToken_(consumes<l1t::MuonStubCollection>(iConfig.getParameter<edm::InputTag>("stubs"))),
66  kmtf_(new KMTF(iConfig.getParameter<int>("verbose"), iConfig.getParameter<edm::ParameterSet>("algo"))),
67  Nprompt(iConfig.getParameter<uint>("Nprompt")),
68  Ndisplaced(iConfig.getParameter<uint>("Ndisplaced")) {
69  produces<std::vector<l1t::SAMuon> >("prompt").setBranchAlias("prompt");
70  produces<std::vector<l1t::SAMuon> >("displaced").setBranchAlias("displaced");
71  produces<std::vector<l1t::KMTFTrack> >("kmtfTracks");
72 }
73 
74 //
75 // member functions
76 //
77 
78 // ------------ method called to produce the data ------------
80  using namespace edm;
82  iEvent.getByToken(stubToken_, stubHandle);
83 
85  for (uint i = 0; i < stubHandle->size(); ++i) {
86  l1t::MuonStubRef stub(stubHandle, i);
87  if (stub->bxNum() == 0)
88  stubs.push_back(stub);
89  }
90 
91  // KMTF
92  std::vector<SAMuon> prompt;
93  std::vector<SAMuon> displaced;
94  std::pair<std::vector<l1t::KMTFTrack>, std::vector<l1t::KMTFTrack> > kmtfOutput = kmtf_->process(stubs, 0, 32);
95  std::vector<l1t::KMTFTrack> kmtfTracks;
96  for (const auto& track : kmtfOutput.first) {
97  kmtfTracks.push_back(track);
98  l1t::SAMuon p(track.p4(),
99  (track.curvatureAtVertex() < 0),
100  track.ptPrompt(),
101  track.coarseEta(),
102  track.phiAtMuon() / (1 << 5),
103  0,
104  0,
105  track.stubs().size() - 1);
106  p.setTF(l1t::tftype::bmtf);
107  int bstart = 0;
108  wordtype word(0);
109  bstart = wordconcat<wordtype>(word, bstart, 1, 1);
110  bstart = wordconcat<wordtype>(word, bstart, p.hwCharge(), 1);
111  bstart = wordconcat<wordtype>(word, bstart, p.hwPt(), BITSPT);
112  bstart = wordconcat<wordtype>(word, bstart, p.hwPhi(), BITSPHI);
113  bstart = wordconcat<wordtype>(word, bstart, p.hwEta(), BITSETA);
114  bstart = wordconcat<wordtype>(word, bstart, p.hwD0(), BITSSAD0);
115  bstart = wordconcat<wordtype>(word, bstart, track.rankPrompt(), 8);
116 
117  for (const auto& stub : track.stubs())
118  p.addStub(stub);
119  p.setWord(word);
120  prompt.push_back(p);
121  }
122 
123  for (const auto& track : kmtfOutput.second) {
124  kmtfTracks.push_back(track);
125  ap_int<7> dxy = track.dxy() * ap_ufixed<8, 1>(1.606);
126  l1t::SAMuon p(track.displacedP4(),
127  (track.curvatureAtMuon() < 0),
128  track.ptDisplaced(),
129  track.coarseEta(),
130  track.phiAtMuon() / (1 << 5),
131  0,
132  dxy,
133  track.approxDispChi2());
134  p.setTF(l1t::tftype::bmtf);
135  int bstart = 0;
136  wordtype word(0);
137  bstart = wordconcat<wordtype>(word, bstart, 1, 1);
138  bstart = wordconcat<wordtype>(word, bstart, p.hwCharge(), 1);
139  bstart = wordconcat<wordtype>(word, bstart, p.hwPt(), BITSPT);
140  bstart = wordconcat<wordtype>(word, bstart, p.hwPhi(), BITSPHI);
141  bstart = wordconcat<wordtype>(word, bstart, p.hwEta(), BITSETA);
142  bstart = wordconcat<wordtype>(word, bstart, p.hwD0(), BITSSAD0);
143  bstart = wordconcat<wordtype>(word, bstart, track.rankDisp(), 8);
144 
145  for (const auto& stub : track.stubs()) {
146  p.addStub(stub);
147  }
148  p.setWord(word);
149  displaced.push_back(p);
150  }
151  std::unique_ptr<std::vector<l1t::SAMuon> > prompt_ptr = std::make_unique<std::vector<l1t::SAMuon> >(prompt);
152  std::unique_ptr<std::vector<l1t::SAMuon> > displaced_ptr = std::make_unique<std::vector<l1t::SAMuon> >(displaced);
153  std::unique_ptr<std::vector<l1t::KMTFTrack> > kmtf_ptr = std::make_unique<std::vector<l1t::KMTFTrack> >(kmtfTracks);
154  iEvent.put(std::move(prompt_ptr), "prompt");
155  iEvent.put(std::move(displaced_ptr), "displaced");
156  iEvent.put(std::move(kmtf_ptr), "kmtfTracks");
157 }
158 
159 //define this as a plug-in
161 #endif
const int BITSSAD0
Definition: Constants.h:56
delete x;
Definition: CaloConfig.h:22
Phase2L1TGMTKMTFProducer(const edm::ParameterSet &)
std::vector< edm::Ref< MuonStubCollection > > MuonStubRefVector
Definition: MuonStub.h:44
ap_uint< 64 > wordtype
Definition: Constants.h:101
uint64_t word
void produce(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
const int BITSETA
Definition: Constants.h:26
edm::EDGetTokenT< l1t::MuonStubCollection > stubToken_
const int BITSPT
Definition: Constants.h:24
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const int BITSPHI
Definition: Constants.h:25
std::vector< MuonStub > MuonStubCollection
Definition: MuonStub.h:40
HLT enums.
std::unique_ptr< KMTF > kmtf_
def move(src, dest)
Definition: eostools.py:511