CMS 3D CMS Logo

HLTL1MuonNoL2Selector.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
14 //
15 //--------------------------------------------------
16 
17 // Class Header
18 #include "HLTL1MuonNoL2Selector.h"
19 
20 // Framework
26 
27 using namespace std;
28 using namespace edm;
29 using namespace l1t;
30 
31 // constructors
33  : theL1Source_(iConfig.getParameter<InputTag>("InputObjects")),
34  theL1MinPt_(iConfig.getParameter<double>("L1MinPt")),
35  theL1MaxEta_(iConfig.getParameter<double>("L1MaxEta")),
36  theL1MinQuality_(iConfig.getParameter<unsigned int>("L1MinQuality")),
37  centralBxOnly_(iConfig.getParameter<bool>("CentralBxOnly")),
38  theL2CandTag_(iConfig.getParameter<edm::InputTag>("L2CandTag")),
39  theL2CandToken_(consumes<reco::RecoChargedCandidateCollection>(theL2CandTag_)),
40  seedMapTag_(iConfig.getParameter<InputTag>("SeedMapTag")),
41  seedMapToken_(consumes<SeedMap>(seedMapTag_)) {
42  muCollToken_ = consumes<MuonBxCollection>(theL1Source_);
43 
44  produces<MuonBxCollection>();
45 }
46 
47 // destructor
49 
52  desc.add<edm::InputTag>("InputObjects", edm::InputTag(""));
53  desc.add<edm::InputTag>("L2CandTag", edm::InputTag("hltL2MuonCandidates"));
54  desc.add<edm::InputTag>("SeedMapTag", edm::InputTag("hltL2Muons"));
55  desc.add<double>("L1MinPt", -1.);
56  desc.add<double>("L1MaxEta", 5.0);
57  desc.add<unsigned int>("L1MinQuality", 0);
58  // # OBSOLETE - these parameters are ignored, they are left only not to break old configurations
59  // they will not be printed in the generated cfi.py file
60  desc.addOptionalNode(edm::ParameterDescription<edm::InputTag>("L1CandTag", edm::InputTag(""), false), false)
61  ->setComment("This parameter is obsolete and will be ignored.");
62  desc.add<bool>("CentralBxOnly", true);
63  descriptions.add("hltL1MuonNoL2Selector", desc);
64 }
65 
67  using namespace std;
68  using namespace reco;
69  using namespace trigger;
70 
71  const std::string metname = "Muon|RecoMuon|HLTL1MuonNoL2Selector";
72 
73  unique_ptr<MuonBxCollection> output(new MuonBxCollection());
74 
75  // Get hold of L2 trks
77  iEvent.getByToken(theL2CandToken_, L2cands);
78 
79  // Muon particles
81  iEvent.getByToken(muCollToken_, muColl);
82  LogTrace(metname) << "Number of muons " << muColl->size() << endl;
83 
84  edm::Handle<SeedMap> seedMapHandle;
85  iEvent.getByToken(seedMapToken_, seedMapHandle);
86 
87  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
88  if (centralBxOnly_ && (ibx != 0))
89  continue;
90  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++) {
91  l1t::MuonRef l1muon(muColl, distance(muColl->begin(muColl->getFirstBX()), it));
92 
93  unsigned int quality = it->hwQual();
94  float pt = it->pt();
95  float eta = it->eta();
96 
97  if (pt < theL1MinPt_ || std::abs(eta) > theL1MaxEta_ || quality <= theL1MinQuality_)
98  continue;
99 
100  // Loop over L2's to find whether the L1 fired this L2.
101  bool isTriggeredByL1 = false;
102  for (auto const& cand : *L2cands) {
103  TrackRef l2muon = cand.get<TrackRef>();
105  (*seedMapHandle)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
106  for (auto const& seed : seeds) {
107  // Check if the L2 was seeded by a triggered L1, in such case skip the loop.
108  if (seed->l1tParticle() == l1muon) {
109  isTriggeredByL1 = true;
110  break;
111  }
112  }
113  if (isTriggeredByL1)
114  break; // if I found a L2 I do not need to loop on the rest.
115  }
116  // Once we loop on all L2 decide:
117  if (!isTriggeredByL1) {
118  output->push_back(ibx, *it);
119  }
120  }
121  } // loop over L1
122 
123  iEvent.put(std::move(output));
124 }
125 
126 // declare this class as a framework plugin
const_iterator end(int bx) const
~HLTL1MuonNoL2Selector() override
Destructor.
void setComment(std::string const &value)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
unsigned size(int bx) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
const std::string metname
HLTL1MuonNoL2Selector(const edm::ParameterSet &)
Constructor.
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
delete x;
Definition: CaloConfig.h:22
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< l1t::MuonBxCollection > muCollToken_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::RecoChargedCandidateCollection > theL2CandToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define LogTrace(id)
BXVector< Muon > MuonBxCollection
Definition: Muon.h:11
std::vector< RecoChargedCandidate > RecoChargedCandidateCollection
collectin of RecoChargedCandidate objects
int getFirstBX() const
edm::EDGetTokenT< SeedMap > seedMapToken_
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
int getLastBX() const
void push_back(value_type const &ref)
Add a Ref<C, T> to the RefVector.
Definition: RefVector.h:67
const_iterator begin(int bx) const
def move(src, dest)
Definition: eostools.py:511