test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes
HLTJetsCleanedFromLeadingLeptons< JetType > Class Template Reference

Produces a collection of jets cleaned against leading leptons. More...

#include <HLTJetsCleanedFromLeadingLeptons.h>

Inheritance diagram for HLTJetsCleanedFromLeadingLeptons< JetType >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  EtaPhiE
 An auxiliary class to store momentum parametrised in eta, phi, and energy. More...
 

Public Types

typedef std::vector< JetType > JetCollection
 
typedef std::vector
< edm::RefVector
< JetCollection, JetType,
edm::refhelper::FindUsingAdvance
< JetCollection, JetType > > > 
JetCollectionVector
 
typedef edm::Ref< JetCollectionJetRef
 
typedef edm::RefVector
< JetCollection
JetRefVector
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 HLTJetsCleanedFromLeadingLeptons (edm::ParameterSet const &iConfig)
 Constructor. More...
 
virtual void produce (edm::Event &iEvent, edm::EventSetup const &iSetup)
 Produces jets cleaned against leptons. More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 Describes configuration of the plugin. More...
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Private Attributes

edm::EDGetTokenT< std::vector
< JetType > > 
jetToken
 Token to access a collection of jets. More...
 
edm::EDGetTokenT
< trigger::TriggerFilterObjectWithRefs
leptonToken
 Token to identify a collection of leptons that pass an HLT filter. More...
 
double minDeltaR2
 A square of the minimal allowed angular separation between a lepton and a jet. More...
 
unsigned numLeptons
 Number of leading leptons against which the jets are cleaned. More...
 

Additional Inherited Members

- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

template<typename JetType>
class HLTJetsCleanedFromLeadingLeptons< JetType >

Produces a collection of jets cleaned against leading leptons.

Author
Andrey Popov, inspired by code by Lukasz Kreczko Leptons (muons or electrons) are read from results of a previous HLT filter. They are ordered in energy, and the user can configure how many leading leptons are used to clean jets. If the requested number is larger than the total number of leptons, all of them are used.

The plugin loops over the given collection of jets and exclude ones that are close to one of the leading leptons. References to surviving jets are stored in the same format as expected by the HLTJetCollectionsFilter plugin.

Definition at line 28 of file HLTJetsCleanedFromLeadingLeptons.h.

Member Typedef Documentation

template<typename JetType >
typedef std::vector<JetType> HLTJetsCleanedFromLeadingLeptons< JetType >::JetCollection

Definition at line 31 of file HLTJetsCleanedFromLeadingLeptons.h.

template<typename JetType >
typedef std::vector<edm::RefVector<JetCollection, JetType, edm::refhelper::FindUsingAdvance<JetCollection, JetType> > > HLTJetsCleanedFromLeadingLeptons< JetType >::JetCollectionVector

Definition at line 36 of file HLTJetsCleanedFromLeadingLeptons.h.

template<typename JetType >
typedef edm::Ref<JetCollection> HLTJetsCleanedFromLeadingLeptons< JetType >::JetRef

Definition at line 32 of file HLTJetsCleanedFromLeadingLeptons.h.

template<typename JetType >
typedef edm::RefVector<JetCollection> HLTJetsCleanedFromLeadingLeptons< JetType >::JetRefVector

Definition at line 33 of file HLTJetsCleanedFromLeadingLeptons.h.

Constructor & Destructor Documentation

template<typename JetType >
HLTJetsCleanedFromLeadingLeptons< JetType >::HLTJetsCleanedFromLeadingLeptons ( edm::ParameterSet const &  iConfig)

Constructor.

Definition at line 153 of file HLTJetsCleanedFromLeadingLeptons.h.

References edm::ParameterSet::getParameter(), HLTJetsCleanedFromLeadingLeptons< JetType >::jetToken, and HLTJetsCleanedFromLeadingLeptons< JetType >::leptonToken.

154  :
155  minDeltaR2(std::pow(iConfig.getParameter<double>("minDeltaR"), 2)),
156  numLeptons(iConfig.getParameter<unsigned>("numLeptons"))
157 {
158  leptonToken = consumes<trigger::TriggerFilterObjectWithRefs>(
159  iConfig.getParameter<edm::InputTag>("leptons"));
160  jetToken = consumes<std::vector<JetType>>(iConfig.getParameter<edm::InputTag>("jets"));
161 
162  produces<JetCollectionVector>();
163 }
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > leptonToken
Token to identify a collection of leptons that pass an HLT filter.
unsigned numLeptons
Number of leading leptons against which the jets are cleaned.
double minDeltaR2
A square of the minimal allowed angular separation between a lepton and a jet.
edm::EDGetTokenT< std::vector< JetType > > jetToken
Token to access a collection of jets.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40

Member Function Documentation

template<typename JetType >
void HLTJetsCleanedFromLeadingLeptons< JetType >::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Describes configuration of the plugin.

Definition at line 167 of file HLTJetsCleanedFromLeadingLeptons.h.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

169 {
171 
172  desc.add<edm::InputTag>("leptons", edm::InputTag("triggerFilterObjectWithRefs"))->
173  setComment("A collection of leptons that pass an HLT filter");
174  desc.add<edm::InputTag>("jets", edm::InputTag("jetCollection"))->
175  setComment("A collection of jets");
176  desc.add<double>("minDeltaR", 0.3)->
177  setComment("Minimal allowed angular separation between a jet and a lepton");
178  desc.add<unsigned>("numLeptons", 1)->
179  setComment("Number of leading leptons against which the jets are cleaned");
180 
181  descriptions.add(std::string("hlt") +
183 }
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Produces a collection of jets cleaned against leading leptons.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
template<typename JetType >
void HLTJetsCleanedFromLeadingLeptons< JetType >::produce ( edm::Event iEvent,
edm::EventSetup const &  iSetup 
)
virtual

Produces jets cleaned against leptons.

Implements edm::EDProducer.

Definition at line 187 of file HLTJetsCleanedFromLeadingLeptons.h.

References reco::deltaR2(), HI_PhotonSkim_cff::electrons, edm::Event::getByToken(), fwrapper::jets, patZpeak::muons, muon::overlap(), interactiveExample::photons, edm::RefVector< C, T, F >::push_back(), edm::Event::put(), python.multivaluedict::sort(), trigger::TriggerCluster, trigger::TriggerElectron, trigger::TriggerMuon, and trigger::TriggerPhoton.

189 {
190  // Read results of the lepton filter
192  iEvent.getByToken(leptonToken, filterOutput);
193 
194  // Momenta of the leptons that passed the filter will be pushed into a vector
195  std::vector<EtaPhiE> leptonMomenta;
196 
197 
198  // First, assume these are muons and try to store their momenta
200  filterOutput->getObjects(trigger::TriggerMuon, muons);
201 
202  for (auto const &muRef: muons) // the collection might be empty
203  leptonMomenta.emplace_back(muRef->eta(), muRef->phi(), muRef->energy());
204 
205 
206  // Then get the momenta as if these are electrons. Electrons are tricky because they can be
207  //stored with three types of trigger objects: TriggerElectron, TriggerPhoton, and
208  //TriggerCluster. Try them one by one.
210  filterOutput->getObjects(trigger::TriggerElectron, electrons);
211 
212  for (auto const &eRef: electrons) // the collection might be empty
213  {
214  auto const &sc = eRef->superCluster();
215  leptonMomenta.emplace_back(sc->eta(), sc->phi(), sc->energy());
216  }
217 
219  filterOutput->getObjects(trigger::TriggerPhoton, photons);
220 
221  for (auto const &eRef: photons) // the collection might be empty
222  {
223  auto const &sc = eRef->superCluster();
224  leptonMomenta.emplace_back(sc->eta(), sc->phi(), sc->energy());
225  }
226 
227  trigger::VRphoton clusters;
228  filterOutput->getObjects(trigger::TriggerCluster, clusters);
229 
230  for (auto const &eRef: clusters) // the collection might be empty
231  {
232  auto const &sc = eRef->superCluster();
233  leptonMomenta.emplace_back(sc->eta(), sc->phi(), sc->energy());
234  }
235 
236 
237  // Make sure the momenta are sorted
238  std::sort(leptonMomenta.rbegin(), leptonMomenta.rend());
239 
240 
241  // Read the source collection of jets
242  edm::Handle<JetCollection> jetHandle;
243  iEvent.getByToken(jetToken, jetHandle);
244  JetCollection const &jets = *jetHandle;
245 
246 
247  // Put references to jets that are not matched to leptons into a dedicated collection
248  JetRefVector cleanedJetRefs;
249  unsigned const numLeptonsToLoop = std::min<unsigned>(leptonMomenta.size(), numLeptons);
250 
251  for (unsigned iJet = 0; iJet < jets.size(); ++iJet)
252  {
253  bool overlap = false;
254 
255  for (unsigned iLepton = 0; iLepton < numLeptonsToLoop; ++iLepton)
256  if (reco::deltaR2(leptonMomenta.at(iLepton), jets.at(iJet)) < minDeltaR2)
257  {
258  overlap = true;
259  break;
260  }
261 
262  if (not overlap)
263  cleanedJetRefs.push_back(JetRef(jetHandle, iJet));
264  }
265 
266 
267  // Store the collection in the event
268  std::auto_ptr<JetCollectionVector> product(new JetCollectionVector);
269  //^ Have to use the depricated auto_ptr here because this is what edm::Event::put expects
270  product->emplace_back(cleanedJetRefs);
271  iEvent.put(product);
272 }
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > leptonToken
Token to identify a collection of leptons that pass an HLT filter.
unsigned numLeptons
Number of leading leptons against which the jets are cleaned.
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
edm::RefVector< JetCollection > JetRefVector
bool overlap(const reco::Muon &muon1, const reco::Muon &muon2, double pullX=1.0, double pullY=1.0, bool checkAdjacentChambers=false)
std::vector< edm::RefVector< JetCollection, JetType, edm::refhelper::FindUsingAdvance< JetCollection, JetType > > > JetCollectionVector
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
vector< PseudoJet > jets
double minDeltaR2
A square of the minimal allowed angular separation between a lepton and a jet.
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
std::vector< reco::RecoChargedCandidateRef > VRmuon
tuple muons
Definition: patZpeak.py:38
std::vector< reco::ElectronRef > VRelectron
edm::EDGetTokenT< std::vector< JetType > > jetToken
Token to access a collection of jets.
std::vector< reco::RecoEcalCandidateRef > VRphoton

Member Data Documentation

template<typename JetType >
edm::EDGetTokenT<std::vector<JetType> > HLTJetsCleanedFromLeadingLeptons< JetType >::jetToken
private

Token to access a collection of jets.

Definition at line 89 of file HLTJetsCleanedFromLeadingLeptons.h.

Referenced by HLTJetsCleanedFromLeadingLeptons< JetType >::HLTJetsCleanedFromLeadingLeptons().

template<typename JetType >
edm::EDGetTokenT<trigger::TriggerFilterObjectWithRefs> HLTJetsCleanedFromLeadingLeptons< JetType >::leptonToken
private

Token to identify a collection of leptons that pass an HLT filter.

Definition at line 86 of file HLTJetsCleanedFromLeadingLeptons.h.

Referenced by HLTJetsCleanedFromLeadingLeptons< JetType >::HLTJetsCleanedFromLeadingLeptons().

template<typename JetType >
double HLTJetsCleanedFromLeadingLeptons< JetType >::minDeltaR2
private

A square of the minimal allowed angular separation between a lepton and a jet.

Definition at line 92 of file HLTJetsCleanedFromLeadingLeptons.h.

template<typename JetType >
unsigned HLTJetsCleanedFromLeadingLeptons< JetType >::numLeptons
private

Number of leading leptons against which the jets are cleaned.

If the number is larger than the total number of leptons, the jets are cleaned against all leptons.

Definition at line 100 of file HLTJetsCleanedFromLeadingLeptons.h.