CMS 3D CMS Logo

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