CMS 3D CMS Logo

HLTL1MuonSelector.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
13 //
14 //--------------------------------------------------
15 
16 // Class Header
17 #include "HLTL1MuonSelector.h"
18 
19 // Framework
25 
26 using namespace std;
27 using namespace edm;
28 using namespace l1extra;
29 
30 // constructors
32  : theSource(iConfig.getParameter<InputTag>("InputObjects")),
33  theL1MinPt(iConfig.getParameter<double>("L1MinPt")),
34  theL1MaxEta(iConfig.getParameter<double>("L1MaxEta")),
35  theL1MinQuality(iConfig.getParameter<unsigned int>("L1MinQuality")) {
36  muCollToken_ = consumes<L1MuonParticleCollection>(theSource);
37 
38  produces<L1MuonParticleCollection>();
39 }
40 
41 // destructor
43 
46  desc.add<edm::InputTag>("InputObjects", edm::InputTag(""));
47  desc.add<double>("L1MinPt", -1.);
48  desc.add<double>("L1MaxEta", 5.0);
49  desc.add<unsigned int>("L1MinQuality", 0);
50  descriptions.add("hltL1MuonSelector", desc);
51 }
52 
54  const std::string metname = "Muon|RecoMuon|HLTL1MuonSelector";
55 
56  unique_ptr<L1MuonParticleCollection> output(new L1MuonParticleCollection());
57 
58  // Muon particles
60  iEvent.getByToken(muCollToken_, muColl);
61  LogTrace(metname) << "Number of muons " << muColl->size() << endl;
62 
63  L1MuonParticleCollection::const_iterator it;
64  L1MuonParticleRef::key_type l1ParticleIndex = 0;
65 
66  for (it = muColl->begin(); it != muColl->end(); ++it, ++l1ParticleIndex) {
67  const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand();
68  unsigned int quality = 0;
69  bool valid_charge = false;
70  ;
71 
72  if (muonCand.empty()) {
73  LogWarning(metname) << "HLTL1MuonSelector: WARNING, no L1MuGMTCand! " << endl;
74  LogWarning(metname) << "HLTL1MuonSelector: this should make sense only within MC tests" << endl;
75  // FIXME! Temporary to handle the MC input
76  quality = 7;
77  valid_charge = true;
78  } else {
79  quality = muonCand.quality();
80  valid_charge = muonCand.charge_valid();
81  }
82 
83  float pt = (*it).pt();
84  float eta = (*it).eta();
85  float theta = 2 * atan(exp(-eta));
86  float phi = (*it).phi();
87  int charge = (*it).charge();
88  // Set charge=0 for the time being if the valid charge bit is zero
89  if (!valid_charge)
90  charge = 0;
91  bool barrel = !(*it).isForward();
92 
93  if (pt < theL1MinPt || fabs(eta) > theL1MaxEta)
94  continue;
95 
96  LogTrace(metname) << "L1 Muon Found";
97  LogTrace(metname) << "Pt = " << pt << " GeV/c";
98  LogTrace(metname) << "eta = " << eta;
99  LogTrace(metname) << "theta = " << theta << " rad";
100  LogTrace(metname) << "phi = " << phi << " rad";
101  LogTrace(metname) << "charge = " << charge;
102  LogTrace(metname) << "In Barrel? = " << barrel;
103 
104  if (quality <= theL1MinQuality)
105  continue;
106  LogTrace(metname) << "quality = " << quality;
107 
108  output->push_back(L1MuonParticle(*it));
109 
110  } // loop over L1MuonParticleCollection
111 
112  iEvent.put(std::move(output));
113 }
114 
115 // declare this class as a framework plugin
std::remove_cv< typename std::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:164
const std::string metname
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > muCollToken_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const unsigned theL1MinQuality
#define LogTrace(id)
unsigned int quality() const
get quality
Definition: L1MuGMTCand.h:90
~HLTL1MuonSelector() override
Destructor.
bool charge_valid() const
is the charge valid ?
Definition: L1MuGMTCand.h:135
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
int iEvent
Definition: GenABIO.cc:224
const double theL1MaxEta
std::vector< L1MuonParticle > L1MuonParticleCollection
bool empty() const
is it an empty muon candidate?
Definition: L1MuGMTCand.h:61
HLTL1MuonSelector(const edm::ParameterSet &)
Constructor.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
Log< level::Warning, false > LogWarning
string quality
Geom::Theta< T > theta() const
edm::InputTag theSource
def move(src, dest)
Definition: eostools.py:511
const double theL1MinPt