CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
JetIdSelector< T > Class Template Reference
Inheritance diagram for JetIdSelector< T >:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector< TJetCollection
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void endJob () override
 
 JetIdSelector (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
 ~JetIdSelector () override
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

JetIDSelectionFunctorjetIDFunctor
 
edm::InputTag jetIDMap_
 
std::string moduleLabel_
 
unsigned int nJetsPassed_
 
unsigned int nJetsTot_
 
std::string qualityStr
 
edm::InputTag src_
 
bool use_pfloose
 
bool use_pfmedium
 
bool use_pftight
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::ProducerBase
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 declare what type of product will make and with which optional label More...
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< B > consumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes () noexcept
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag) noexcept
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 

Detailed Description

template<typename T>
class JetIdSelector< T >

Definition at line 59 of file JetIdSelector.cc.

Member Typedef Documentation

◆ JetCollection

template<typename T >
typedef std::vector<T> JetIdSelector< T >::JetCollection

Definition at line 61 of file JetIdSelector.cc.

Constructor & Destructor Documentation

◆ JetIdSelector()

template<typename T >
JetIdSelector< T >::JetIdSelector ( const edm::ParameterSet iConfig)
explicit

Definition at line 92 of file JetIdSelector.cc.

93  : src_(iConfig.getParameter<edm::InputTag>("src")),
94  qualityStr(iConfig.getParameter<string>("idLevel")),
95  jetIDMap_(iConfig.getUntrackedParameter<edm::InputTag>("jetIDMap", edm::InputTag("ak5JetID"))),
96  moduleLabel_(iConfig.getParameter<string>("@module_label")),
97  nJetsTot_(0),
98  nJetsPassed_(0) {
99  produces<JetCollection>();
100 
101  use_pfloose = false;
102  use_pfmedium = false;
103  use_pftight = false;
104 
105  if (qualityStr == "MINIMAL") {
107  use_pfloose = true;
108  } else if (qualityStr == "LOOSE_AOD") {
110  use_pfloose = true;
111  } else if (qualityStr == "LOOSE") {
113  use_pfloose = true;
114  } else if (qualityStr == "MEDIUM") {
116  // There is no medium quality for CaloJet !!
117  use_pfmedium = true;
118  } else if (qualityStr == "TIGHT") {
120  use_pftight = true;
121  } else
122  throw cms::Exception("InvalidInput") << "Expect quality to be one of MINIMAL, LOOSE_AOD, LOOSE, MEDIUM, TIGHT"
123  << std::endl;
124 }

References Exception, JetIdSelector< T >::jetIDFunctor, JetIDSelectionFunctor::LOOSE, JetIDSelectionFunctor::LOOSE_AOD, JetIDSelectionFunctor::MINIMAL, JetIDSelectionFunctor::PURE09, JetIdSelector< T >::qualityStr, JetIDSelectionFunctor::TIGHT, JetIdSelector< T >::use_pfloose, JetIdSelector< T >::use_pfmedium, and JetIdSelector< T >::use_pftight.

◆ ~JetIdSelector()

template<typename T >
JetIdSelector< T >::~JetIdSelector ( )
override

Definition at line 128 of file JetIdSelector.cc.

128  {
129  if (jetIDFunctor)
130  delete jetIDFunctor;
131 }

Member Function Documentation

◆ endJob()

template<typename T >
void JetIdSelector< T >::endJob ( void  )
overridevirtual

Reimplemented from edm::EDProducer.

Definition at line 226 of file JetIdSelector.cc.

226  {
227  stringstream ss;
228  ss << "nJetsTot=" << nJetsTot_ << " nJetsPassed=" << nJetsPassed_
229  << " fJetsPassed=" << 100. * (nJetsPassed_ / (double)nJetsTot_) << "%\n";
230  cout << "++++++++++++++++++++++++++++++++++++++++++++++++++"
231  << "\n"
232  << moduleLabel_ << "(JetIdSelector) SUMMARY:\n"
233  << ss.str() << "++++++++++++++++++++++++++++++++++++++++++++++++++" << endl;
234 }

References gather_cfg::cout, and contentValuesCheck::ss.

◆ produce()

template<typename T >
void JetIdSelector< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 139 of file JetIdSelector.cc.

139  {
140  auto selectedJets = std::make_unique<JetCollection>();
141  edm::Handle<reco::JetView> hjets; // uncorrected jets!
142  iEvent.getByLabel(src_, hjets);
143  auto const& jets = *hjets;
144 
145  // handle to the jet ID variables, filled in the loop
147  unsigned int idx = 0;
148  bool passed = false;
149 
150  for (edm::View<reco::Jet>::const_iterator ibegin = jets.begin(), iend = jets.end(), iJet = ibegin; iJet != iend;
151  ++iJet) {
152  // initialize the boolean flag to false
153  passed = false;
154 
155  //calculate the Calo jetID
156  auto const& jet = *iJet;
157  const std::type_info& type = typeid(jet);
158  if (type == typeid(reco::CaloJet)) {
159  const reco::CaloJet& calojet = static_cast<const reco::CaloJet&>(jet);
160  edm::RefToBase<reco::Jet> jetRef = jets.refAt(idx);
161  if (not hJetIDMap.isValid()) {
162  iEvent.getByLabel(jetIDMap_, hJetIDMap);
163  }
164  reco::JetID const& jetId = (*hJetIDMap)[jetRef];
165  passed = (*jetIDFunctor)(calojet, jetId);
166  }
167 
168  //calculate the PF jetID
169  if (type == typeid(reco::PFJet)) {
170  const reco::PFJet& pfjet = static_cast<const reco::PFJet&>(jet);
171  bool passingLoose = false;
172  bool passingMedium = false;
173  bool passingTight = false;
174  bool ThisIsClean = true;
175  //apply following only if |eta|<2.4: CHF>0, CEMF<0.99, chargedMultiplicity>0
176  if ((pfjet.chargedHadronEnergy() / pfjet.energy()) <= 0.0 && fabs(pfjet.eta()) < 2.4)
177  ThisIsClean = false;
178  if ((pfjet.chargedEmEnergy() / pfjet.energy()) >= 0.99 && fabs(pfjet.eta()) < 2.4)
179  ThisIsClean = false;
180  if (pfjet.chargedMultiplicity() <= 0 && fabs(pfjet.eta()) < 2.4)
181  ThisIsClean = false;
182 
183  // always require #Constituents > 1
184  if (pfjet.nConstituents() <= 1)
185  ThisIsClean = false;
186 
187  if (ThisIsClean && (pfjet.neutralHadronEnergy() / pfjet.energy()) < 0.99 &&
188  (pfjet.neutralEmEnergy() / pfjet.energy()) < 0.99)
189  passingLoose = true;
190 
191  if (ThisIsClean && (pfjet.neutralHadronEnergy() / pfjet.energy()) < 0.95 &&
192  (pfjet.neutralEmEnergy() / pfjet.energy()) < 0.95)
193  passingMedium = true;
194 
195  if (ThisIsClean && (pfjet.neutralHadronEnergy() / pfjet.energy()) < 0.90 &&
196  (pfjet.neutralEmEnergy() / pfjet.energy()) < 0.90)
197  passingTight = true;
198 
199  if (use_pfloose && passingLoose)
200  passed = true;
201  if (use_pfmedium && passingMedium)
202  passed = true;
203  if (use_pftight && passingTight)
204  passed = true;
205  }
206 
207  if (type == typeid(reco::GenJet) || type == typeid(reco::JPTJet)) {
208  edm::LogWarning("JetId") << "Criteria for jets other than CaloJets and PFJets are not yet implemented";
209  passed = true;
210  } // close GenJet, JPT jet
211 
212  const T& goodJet = static_cast<const T&>(jet);
213  if (passed)
214  selectedJets->push_back(goodJet);
215 
216  idx++;
217  } // close jet iterator
218 
219  nJetsTot_ += jets.size();
220  nJetsPassed_ += selectedJets->size();
222 }

References reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), heavyIonCSV_trainingSettings::idx, iEvent, edm::HandleBase::isValid(), metsig::jet, PhotonMonitor_cff::jetId, singleTopDQM_cfi::jets, eostools::move(), reco::Jet::nConstituents(), reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralHadronEnergy(), TriggerAnalyzer::passed, and objectSelection_cff::selectedJets.

Member Data Documentation

◆ jetIDFunctor

template<typename T >
JetIDSelectionFunctor* JetIdSelector< T >::jetIDFunctor
private

Definition at line 79 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

◆ jetIDMap_

template<typename T >
edm::InputTag JetIdSelector< T >::jetIDMap_
private

Definition at line 74 of file JetIdSelector.cc.

◆ moduleLabel_

template<typename T >
std::string JetIdSelector< T >::moduleLabel_
private

◆ nJetsPassed_

template<typename T >
unsigned int JetIdSelector< T >::nJetsPassed_
private

Definition at line 78 of file JetIdSelector.cc.

◆ nJetsTot_

template<typename T >
unsigned int JetIdSelector< T >::nJetsTot_
private

Definition at line 77 of file JetIdSelector.cc.

◆ qualityStr

template<typename T >
std::string JetIdSelector< T >::qualityStr
private

Definition at line 73 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

◆ src_

template<typename T >
edm::InputTag JetIdSelector< T >::src_
private

Definition at line 72 of file JetIdSelector.cc.

◆ use_pfloose

template<typename T >
bool JetIdSelector< T >::use_pfloose
private

Definition at line 80 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

◆ use_pfmedium

template<typename T >
bool JetIdSelector< T >::use_pfmedium
private

Definition at line 81 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

◆ use_pftight

template<typename T >
bool JetIdSelector< T >::use_pftight
private

Definition at line 82 of file JetIdSelector.cc.

Referenced by JetIdSelector< T >::JetIdSelector().

reco::JPTJet
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:28
JetIdSelector::jetIDFunctor
JetIDSelectionFunctor * jetIDFunctor
Definition: JetIdSelector.cc:79
reco::JetID
Jet ID object.
Definition: JetID.h:16
JetIdSelector::jetIDMap_
edm::InputTag jetIDMap_
Definition: JetIdSelector.cc:74
reco::CaloJet
Jets made from CaloTowers.
Definition: CaloJet.h:27
JetIdSelector::use_pftight
bool use_pftight
Definition: JetIdSelector.cc:82
reco::GenJet
Jets made from MC generator particles.
Definition: GenJet.h:23
JetIdSelector::src_
edm::InputTag src_
Definition: JetIdSelector.cc:72
gather_cfg.cout
cout
Definition: gather_cfg.py:144
JetIdSelector::qualityStr
std::string qualityStr
Definition: JetIdSelector.cc:73
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
edm::Handle
Definition: AssociativeIterator.h:50
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
JetIdSelector::use_pfmedium
bool use_pfmedium
Definition: JetIdSelector.cc:81
reco::PFJet::chargedHadronEnergy
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
JetIDSelectionFunctor
Jet selector for pat::Jets and for CaloJets.
Definition: JetIDSelectionFunctor.h:28
reco::PFJet::chargedMultiplicity
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
reco::Jet::nConstituents
virtual int nConstituents() const
Definition: Jet.h:65
JetIDSelectionFunctor::LOOSE
Definition: JetIDSelectionFunctor.h:31
reco::PFJet::chargedEmEnergy
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
JetIdSelector::nJetsTot_
unsigned int nJetsTot_
Definition: JetIdSelector.cc:77
reco::LeafCandidate::eta
double eta() const final
momentum pseudorapidity
Definition: LeafCandidate.h:152
JetIDSelectionFunctor::PURE09
Definition: JetIDSelectionFunctor.h:30
type
type
Definition: SiPixelVCal_PayloadInspector.cc:37
JetIdSelector::use_pfloose
bool use_pfloose
Definition: JetIdSelector.cc:80
JetIdSelector::nJetsPassed_
unsigned int nJetsPassed_
Definition: JetIdSelector.cc:78
iEvent
int iEvent
Definition: GenABIO.cc:224
JetIdSelector::moduleLabel_
std::string moduleLabel_
Definition: JetIdSelector.cc:75
JetIDSelectionFunctor::MINIMAL
Definition: JetIDSelectionFunctor.h:31
eostools.move
def move(src, dest)
Definition: eostools.py:511
T
long double T
Definition: Basic3DVectorLD.h:48
reco::PFJet::neutralHadronEnergy
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:246
TriggerAnalyzer.passed
passed
Definition: TriggerAnalyzer.py:62
reco::PFJet
Jets made from PFObjects.
Definition: PFJet.h:20
reco::PFJet::neutralEmEnergy
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Jet >
reco::LeafCandidate::energy
double energy() const final
energy
Definition: LeafCandidate.h:125
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
JetIDSelectionFunctor::TIGHT
Definition: JetIDSelectionFunctor.h:31
objectSelection_cff.selectedJets
selectedJets
Definition: objectSelection_cff.py:99
PhotonMonitor_cff.jetId
jetId
Definition: PhotonMonitor_cff.py:70
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
JetIDSelectionFunctor::LOOSE_AOD
Definition: JetIDSelectionFunctor.h:31
edm::InputTag
Definition: InputTag.h:15