CMS 3D CMS Logo

HLTL1MuonNoL2Selector.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
14 //
15 //--------------------------------------------------
16 
17 // Class Header
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 {
43  muCollToken_ = consumes<MuonBxCollection>(theL1Source_);
44 
45  produces<MuonBxCollection>();
46 }
47 
48 // destructor
50 
51 void
54  desc.add<edm::InputTag>("InputObjects",edm::InputTag(""));
55  desc.add<edm::InputTag>("L2CandTag",edm::InputTag("hltL2MuonCandidates"));
56  desc.add<edm::InputTag>("SeedMapTag",edm::InputTag("hltL2Muons"));
57  desc.add<double>("L1MinPt",-1.);
58  desc.add<double>("L1MaxEta",5.0);
59  desc.add<unsigned int>("L1MinQuality",0);
60  // # OBSOLETE - these parameters are ignored, they are left only not to break old configurations
61  // they will not be printed in the generated cfi.py file
62  desc.addOptionalNode(edm::ParameterDescription<edm::InputTag>("L1CandTag", edm::InputTag(""), false), false)->setComment("This parameter is obsolete and will be ignored.");
63  desc.add<bool>("CentralBxOnly", true);
64  descriptions.add("hltL1MuonNoL2Selector",desc);
65 }
66 
68 {
69  using namespace std;
70  using namespace reco;
71  using namespace trigger;
72 
73  const std::string metname = "Muon|RecoMuon|HLTL1MuonNoL2Selector";
74 
75  unique_ptr<MuonBxCollection> output(new MuonBxCollection());
76 
77  // Get hold of L2 trks
79  iEvent.getByToken(theL2CandToken_,L2cands);
80 
81  // Muon particles
83  iEvent.getByToken(muCollToken_, muColl);
84  LogTrace(metname) << "Number of muons " << muColl->size() << endl;
85 
86  edm::Handle<SeedMap> seedMapHandle;
87  iEvent.getByToken(seedMapToken_, seedMapHandle);
88 
89  for (int ibx = muColl->getFirstBX(); ibx <= muColl->getLastBX(); ++ibx) {
90  if (centralBxOnly_ && (ibx != 0)) continue;
91  for (auto it = muColl->begin(ibx); it != muColl->end(ibx); it++){
92  l1t::MuonRef l1muon(muColl, distance(muColl->begin(muColl->getFirstBX()),it) );
93 
94  unsigned int quality = it->hwQual();
95  float pt = it->pt();
96  float eta = it->eta();
97 
98  if ( pt < theL1MinPt_ || std::abs(eta) > theL1MaxEta_ || quality <= theL1MinQuality_) 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>();
104  const edm::RefVector<L2MuonTrajectorySeedCollection>& seeds = (*seedMapHandle)[l2muon->seedRef().castTo<edm::Ref<L2MuonTrajectorySeedCollection> >()];
105  for(auto const & seed : seeds){
106  // Check if the L2 was seeded by a triggered L1, in such case skip the loop.
107  if(seed->l1tParticle()==l1muon) {
108  isTriggeredByL1 = true;
109  break;
110  }
111  }
112  if (isTriggeredByL1) break; // if I found a L2 I do not need to loop on the rest.
113  }
114  // Once we loop on all L2 decide:
115  if (!isTriggeredByL1) {
116  output->push_back( ibx, *it);
117  }
118  }
119  } // loop over L1
120 
121  iEvent.put(std::move(output));
122 }
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:127
unsigned size(int bx) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:508
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:230
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:10
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:69
const_iterator begin(int bx) const
def move(src, dest)
Definition: eostools.py:510