CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
47 void
50  desc.add<edm::InputTag>("InputObjects",edm::InputTag(""));
51  desc.add<double>("L1MinPt",-1.);
52  desc.add<double>("L1MaxEta",5.0);
53  desc.add<unsigned int>("L1MinQuality",0);
54  descriptions.add("hltL1MuonSelector",desc);
55 }
56 
58 {
59  const std::string metname = "Muon|RecoMuon|HLTL1MuonSelector";
60 
61  auto_ptr<L1MuonParticleCollection> output(new L1MuonParticleCollection());
62 
63  // Muon particles
65  iEvent.getByToken(muCollToken_, muColl);
66  LogTrace(metname) << "Number of muons " << muColl->size() << endl;
67 
68  L1MuonParticleCollection::const_iterator it;
69  L1MuonParticleRef::key_type l1ParticleIndex = 0;
70 
71  for(it = muColl->begin(); it != muColl->end(); ++it,++l1ParticleIndex) {
72 
73  const L1MuGMTExtendedCand muonCand = (*it).gmtMuonCand();
74  unsigned int quality = 0;
75  bool valid_charge = false;;
76 
77  if ( muonCand.empty() ) {
78  LogWarning(metname) << "HLTL1MuonSelector: WARNING, no L1MuGMTCand! " << endl;
79  LogWarning(metname) << "HLTL1MuonSelector: this should make sense only within MC tests" << endl;
80  // FIXME! Temporary to handle the MC input
81  quality = 7;
82  valid_charge = true;
83  }
84  else {
85  quality = muonCand.quality();
86  valid_charge = muonCand.charge_valid();
87  }
88 
89  float pt = (*it).pt();
90  float eta = (*it).eta();
91  float theta = 2*atan(exp(-eta));
92  float phi = (*it).phi();
93  int charge = (*it).charge();
94  // Set charge=0 for the time being if the valid charge bit is zero
95  if (!valid_charge) charge = 0;
96  bool barrel = !(*it).isForward();
97 
98  if ( pt < theL1MinPt || fabs(eta) > theL1MaxEta ) continue;
99 
100  LogTrace(metname) << "L1 Muon Found";
101  LogTrace(metname) << "Pt = " << pt << " GeV/c";
102  LogTrace(metname) << "eta = " << eta;
103  LogTrace(metname) << "theta = " << theta << " rad";
104  LogTrace(metname) << "phi = " << phi << " rad";
105  LogTrace(metname) << "charge = "<< charge;
106  LogTrace(metname) << "In Barrel? = "<< barrel;
107 
108  if ( quality <= theL1MinQuality ) continue;
109  LogTrace(metname) << "quality = "<< quality;
110 
111  output->push_back( L1MuonParticle(*it) );
112 
113  } // loop over L1MuonParticleCollection
114 
115  iEvent.put(output);
116 }
117 
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
const std::string metname
edm::EDGetTokenT< l1extra::L1MuonParticleCollection > muCollToken_
Geom::Theta< T > theta() const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const unsigned theL1MinQuality
T eta() const
virtual void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
bool empty() const
is it an empty muon candidate?
Definition: L1MuGMTCand.h:64
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
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)
edm::InputTag theSource
std::vector< L1MuonParticle > L1MuonParticleCollection
const double theL1MinPt
boost::remove_cv< typename boost::remove_reference< argument_type >::type >::type key_type
Definition: Ref.h:170
Definition: DDAxes.h:10