File indexing completed on 2023-03-17 11:09:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #include "HLTL1MuonSelector.h"
0018
0019
0020 #include "FWCore/Framework/interface/EventSetup.h"
0021 #include "FWCore/Framework/interface/Event.h"
0022 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0023 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0024 #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
0025
0026 using namespace std;
0027 using namespace edm;
0028 using namespace l1extra;
0029
0030
0031 HLTL1MuonSelector::HLTL1MuonSelector(const edm::ParameterSet& iConfig)
0032 : theSource(iConfig.getParameter<InputTag>("InputObjects")),
0033 theL1MinPt(iConfig.getParameter<double>("L1MinPt")),
0034 theL1MaxEta(iConfig.getParameter<double>("L1MaxEta")),
0035 theL1MinQuality(iConfig.getParameter<unsigned int>("L1MinQuality")) {
0036 muCollToken_ = consumes<L1MuonParticleCollection>(theSource);
0037
0038 produces<L1MuonParticleCollection>();
0039 }
0040
0041
0042 HLTL1MuonSelector::~HLTL1MuonSelector() = default;
0043
0044 void HLTL1MuonSelector::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0045 edm::ParameterSetDescription desc;
0046 desc.add<edm::InputTag>("InputObjects", edm::InputTag(""));
0047 desc.add<double>("L1MinPt", -1.);
0048 desc.add<double>("L1MaxEta", 5.0);
0049 desc.add<unsigned int>("L1MinQuality", 0);
0050 descriptions.add("hltL1MuonSelector", desc);
0051 }
0052
0053 void HLTL1MuonSelector::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0054 const std::string metname = "Muon|RecoMuon|HLTL1MuonSelector";
0055
0056 unique_ptr<L1MuonParticleCollection> output(new L1MuonParticleCollection());
0057
0058
0059 edm::Handle<L1MuonParticleCollection> muColl;
0060 iEvent.getByToken(muCollToken_, muColl);
0061 LogTrace(metname) << "Number of muons " << muColl->size() << endl;
0062
0063 L1MuonParticleCollection::const_iterator it;
0064 L1MuonParticleRef::key_type l1ParticleIndex = 0;
0065
0066 for (it = muColl->begin(); it != muColl->end(); ++it, ++l1ParticleIndex) {
0067 const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand();
0068 unsigned int quality = 0;
0069 bool valid_charge = false;
0070 ;
0071
0072 if (muonCand.empty()) {
0073 LogWarning(metname) << "HLTL1MuonSelector: WARNING, no L1MuGMTCand! " << endl;
0074 LogWarning(metname) << "HLTL1MuonSelector: this should make sense only within MC tests" << endl;
0075
0076 quality = 7;
0077 valid_charge = true;
0078 } else {
0079 quality = muonCand.quality();
0080 valid_charge = muonCand.charge_valid();
0081 }
0082
0083 float pt = (*it).pt();
0084 float eta = (*it).eta();
0085 float theta = 2 * atan(exp(-eta));
0086 float phi = (*it).phi();
0087 int charge = (*it).charge();
0088
0089 if (!valid_charge)
0090 charge = 0;
0091 bool barrel = !(*it).isForward();
0092
0093 if (pt < theL1MinPt || fabs(eta) > theL1MaxEta)
0094 continue;
0095
0096 LogTrace(metname) << "L1 Muon Found";
0097 LogTrace(metname) << "Pt = " << pt << " GeV/c";
0098 LogTrace(metname) << "eta = " << eta;
0099 LogTrace(metname) << "theta = " << theta << " rad";
0100 LogTrace(metname) << "phi = " << phi << " rad";
0101 LogTrace(metname) << "charge = " << charge;
0102 LogTrace(metname) << "In Barrel? = " << barrel;
0103
0104 if (quality <= theL1MinQuality)
0105 continue;
0106 LogTrace(metname) << "quality = " << quality;
0107
0108 output->push_back(L1MuonParticle(*it));
0109
0110 }
0111
0112 iEvent.put(std::move(output));
0113 }
0114
0115
0116 #include "FWCore/Framework/interface/MakerMacros.h"
0117 DEFINE_FWK_MODULE(HLTL1MuonSelector);