CMS 3D CMS Logo

Phase2L1TGMTSAMuonGhostCleaner.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 #ifndef PHASE2GMT_SAMUONGHOSTCLEANER
3 #define PHASE2GMT_SAMUONGHOSTCLEANER
4 
5 // system include files
6 #include <memory>
7 #include <sstream>
8 
9 // user include files
19 //
20 // class declaration
21 //
22 using namespace Phase2L1GMT;
23 using namespace l1t;
24 
26 public:
28  ~Phase2L1TGMTSAMuonGhostCleaner() override = default;
29 
30 private:
31  void produce(edm::Event&, const edm::EventSetup&) override;
32 
33  std::vector<l1t::SAMuon> prodMuons(std::vector<l1t::SAMuon>& muons);
34 
35  // ----------member data ---------------------------
40 
42 };
43 //
44 // constants, enums and typedefs
45 //
46 
47 //
48 // static data member definitions
49 //
50 
51 //
52 // constructors and destructor
53 //
55  : barrelTokenPrompt_(consumes<std::vector<l1t::SAMuon> >(iConfig.getParameter<edm::InputTag>("barrelPrompt"))),
56  barrelTokenDisp_(consumes<std::vector<l1t::SAMuon> >(iConfig.getParameter<edm::InputTag>("barrelDisp"))),
57  fwdTokenPrompt_(consumes<std::vector<l1t::SAMuon> >(iConfig.getParameter<edm::InputTag>("forwardPrompt"))),
58  fwdTokenDisp_(consumes<std::vector<l1t::SAMuon> >(iConfig.getParameter<edm::InputTag>("forwardDisp"))) {
59  produces<std::vector<l1t::SAMuon> >("prompt");
60  produces<std::vector<l1t::SAMuon> >("displaced");
61 }
62 
63 // === FUNCTION ============================================================
64 // Name: Phase2L1TGMTSAMuonGhostCleaner::prodMuons
65 // Description:
66 // ===========================================================================
67 std::vector<l1t::SAMuon> Phase2L1TGMTSAMuonGhostCleaner::prodMuons(std::vector<l1t::SAMuon>& muons) {
68  std::vector<l1t::SAMuon> cleanedMuons = ghostCleaner.cleanTFMuons(muons);
69  //here switch to the offical word required by the GT
70  std::vector<l1t::SAMuon> finalMuons;
71  for (const auto& mu : cleanedMuons) {
72  l1t::SAMuon m = mu;
73  if (m.tfType() == l1t::tftype::bmtf)
74  m.setHwQual(m.hwQual() >> 4);
75  int bstart = 0;
76  wordtype word(0);
77  bstart = wordconcat<wordtype>(word, bstart, m.hwPt() > 0, 1);
78  bstart = wordconcat<wordtype>(word, bstart, m.hwPt(), BITSGTPT);
79  bstart = wordconcat<wordtype>(word, bstart, m.hwPhi(), BITSGTPHI);
80  bstart = wordconcat<wordtype>(word, bstart, m.hwEta(), BITSGTETA);
81  bstart = wordconcat<wordtype>(word, bstart, m.hwZ0(), BITSSAZ0);
82  bstart = wordconcat<wordtype>(word, bstart, m.hwD0(), BITSSAD0);
83  bstart = wordconcat<wordtype>(word, bstart, m.hwCharge(), 1);
84  bstart = wordconcat<wordtype>(word, bstart, m.hwQual(), BITSSAQUAL);
85  m.setWord(word);
86  finalMuons.push_back(m);
87  }
88  return finalMuons;
89 } // ----- end of function Phase2L1TGMTSAMuonGhostCleaner::prodMuons -----
90 
91 // ------------ method called to produce the data ------------
93  using namespace edm;
94 
97 
99  iEvent.getByToken(barrelTokenDisp_, barrelDisp);
100 
102  iEvent.getByToken(fwdTokenPrompt_, forwardPrompt);
103 
105  iEvent.getByToken(fwdTokenDisp_, forwardDisp);
106 
107  // Prompt muons
108  std::vector<l1t::SAMuon> muons = *barrelPrompt.product();
109  muons.insert(muons.end(), forwardPrompt->begin(), forwardPrompt->end());
110  std::vector<l1t::SAMuon> finalPrompt = prodMuons(muons);
111 
112  // Displace muons
113  muons.clear();
114  muons = *barrelDisp.product();
115  muons.insert(muons.end(), forwardDisp->begin(), forwardDisp->end());
116  std::vector<l1t::SAMuon> finalDisp = prodMuons(muons);
117 
118  std::unique_ptr<std::vector<l1t::SAMuon> > prompt_ptr = std::make_unique<std::vector<l1t::SAMuon> >(finalPrompt);
119  std::unique_ptr<std::vector<l1t::SAMuon> > disp_ptr = std::make_unique<std::vector<l1t::SAMuon> >(finalDisp);
120  iEvent.put(std::move(prompt_ptr), "prompt");
121  iEvent.put(std::move(disp_ptr), "displaced");
122 }
123 
125 
126 #endif
edm::EDGetTokenT< std::vector< l1t::SAMuon > > barrelTokenPrompt_
const int BITSGTETA
Definition: Constants.h:62
const int BITSSAD0
Definition: Constants.h:56
const int BITSGTPHI
Definition: Constants.h:61
edm::EDGetTokenT< std::vector< l1t::SAMuon > > fwdTokenPrompt_
const int BITSSAQUAL
Definition: Constants.h:57
delete x;
Definition: CaloConfig.h:22
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
ap_uint< 64 > wordtype
Definition: Constants.h:101
edm::EDGetTokenT< std::vector< l1t::SAMuon > > barrelTokenDisp_
uint64_t word
int iEvent
Definition: GenABIO.cc:224
Phase2L1TGMTSAMuonGhostCleaner(const edm::ParameterSet &)
std::vector< l1t::SAMuon > prodMuons(std::vector< l1t::SAMuon > &muons)
void produce(edm::Event &, const edm::EventSetup &) override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const int BITSGTPT
Definition: Constants.h:60
std::vector< l1t::SAMuon > cleanTFMuons(const std::vector< l1t::SAMuon > &muons)
HLT enums.
def move(src, dest)
Definition: eostools.py:511
const int BITSSAZ0
Definition: Constants.h:55
edm::EDGetTokenT< std::vector< l1t::SAMuon > > fwdTokenDisp_