CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

void endJob () override
 
 JetIdSelector (const edm::ParameterSet &iConfig)
 
void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 
virtual ~JetIdSelector ()
 
- 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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)
 
- 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 T>
class JetIdSelector< T >

Definition at line 59 of file JetIdSelector.cc.

Member Typedef Documentation

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

Definition at line 62 of file JetIdSelector.cc.

Constructor & Destructor Documentation

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

Definition at line 96 of file JetIdSelector.cc.

References edm::hlt::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.

97  : src_ (iConfig.getParameter<edm::InputTag> ("src"))
98  , qualityStr (iConfig.getParameter<string> ("idLevel"))
99  , jetIDMap_(iConfig.getUntrackedParameter<edm::InputTag> ("jetIDMap", edm::InputTag("ak5JetID")))
100  , moduleLabel_(iConfig.getParameter<string> ("@module_label"))
101  , nJetsTot_(0)
102  , nJetsPassed_(0)
103 {
104  produces<JetCollection>();
105 
106  use_pfloose = false;
107  use_pfmedium = false;
108  use_pftight = false;
109 
110  if ( qualityStr == "MINIMAL" ) {
111  jetIDFunctor
113  use_pfloose = true;
114  }
115  else if ( qualityStr == "LOOSE_AOD" ) {
116  jetIDFunctor
118  use_pfloose = true;
119  }
120  else if ( qualityStr == "LOOSE" ) {
121  jetIDFunctor
123  use_pfloose = true;
124  }
125  else if ( qualityStr == "MEDIUM" ) {
126  jetIDFunctor
128  // There is no medium quality for CaloJet !!
129  use_pfmedium = true;
130  }
131  else if ( qualityStr == "TIGHT" ) {
132  jetIDFunctor
134  use_pftight = true;
135  }
136  else
137  throw cms::Exception("InvalidInput")
138  << "Expect quality to be one of MINIMAL, LOOSE_AOD, LOOSE, MEDIUM, TIGHT" << std::endl;
139 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::string qualityStr
JetIDSelectionFunctor * jetIDFunctor
edm::InputTag src_
unsigned int nJetsPassed_
std::string moduleLabel_
unsigned int nJetsTot_
Jet selector for pat::Jets and for CaloJets.
edm::InputTag jetIDMap_
template<typename T >
JetIdSelector< T >::~JetIdSelector ( )
virtual

Definition at line 144 of file JetIdSelector.cc.

144  {
145  if(jetIDFunctor) delete jetIDFunctor;
146 }
JetIDSelectionFunctor * jetIDFunctor

Member Function Documentation

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

Reimplemented from edm::EDProducer.

Definition at line 251 of file JetIdSelector.cc.

References gather_cfg::cout, and moduleLabel_().

252 {
253  stringstream ss;
254  ss<<"nJetsTot="<<nJetsTot_<<" nJetsPassed="<<nJetsPassed_
255  <<" fJetsPassed="<<100.*(nJetsPassed_/(double)nJetsTot_)<<"%\n";
256  cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++"
257  <<"\n"<< moduleLabel_ << "(JetIdSelector) SUMMARY:\n"<<ss.str()
258  <<"++++++++++++++++++++++++++++++++++++++++++++++++++"
259  <<endl;
260 }
unsigned int nJetsPassed_
std::string moduleLabel_
unsigned int nJetsTot_
tuple cout
Definition: gather_cfg.py:121
template<typename T >
void JetIdSelector< T >::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

Implements edm::EDProducer.

Definition at line 156 of file JetIdSelector.cc.

References reco::PFJet::chargedEmEnergy(), reco::PFJet::chargedHadronEnergy(), reco::PFJet::chargedMultiplicity(), reco::LeafCandidate::energy(), reco::LeafCandidate::eta(), edm::Event::getByLabel(), customizeTrackingMonitorSeedNumber::idx, fwrapper::jets, reco::Jet::nConstituents(), reco::PFJet::neutralEmEnergy(), reco::PFJet::neutralHadronEnergy(), and edm::Event::put().

157 {
158  auto_ptr<JetCollection> selectedJets(new JetCollection);
159  edm::Handle<reco::JetView> jets; // uncorrected jets!
160  iEvent.getByLabel(src_,jets);
161 
162 
163  // handle to the jet ID variables
165 
166  if(typeid((*jets)[0]) == typeid(reco::CaloJet))
167  iEvent.getByLabel( jetIDMap_, hJetIDMap );
168 
169  unsigned int idx=0;
170  bool passed = false;
171 
172  for ( edm::View<reco::Jet>::const_iterator ibegin = jets->begin(),
173  iend = jets->end(), iJet = ibegin;
174  iJet != iend; ++iJet ) {
175 
176  // initialize the boolean flag to false
177  passed = false;
178 
179  //calculate the Calo jetID
180  const std::type_info & type = typeid((*jets)[idx]);
181  if( type == typeid(reco::CaloJet) ) {
182  const reco::CaloJet calojet = static_cast<const reco::CaloJet &>((*jets)[idx]);
183  edm::RefToBase<reco::Jet> jetRef = jets->refAt(idx);
184  reco::JetID const & jetId = (*hJetIDMap)[ jetRef ];
185  passed = (*jetIDFunctor)( calojet, jetId);
186  }
187 
188  //calculate the PF jetID
189  if ( type == typeid(reco::PFJet) ) {
190  const reco::PFJet pfjet = static_cast<const reco::PFJet &>((*jets)[idx]);
191  bool passingLoose=false;
192  bool passingMedium=false;
193  bool passingTight=false;
194  bool ThisIsClean=true;
195  //apply following only if |eta|<2.4: CHF>0, CEMF<0.99, chargedMultiplicity>0
196  if(( pfjet.chargedHadronEnergy()/ pfjet.energy())<= 0.0
197  && fabs(pfjet.eta())<2.4) ThisIsClean=false;
198  if( (pfjet.chargedEmEnergy()/pfjet.energy())>= 0.99
199  && fabs(pfjet.eta())<2.4 ) ThisIsClean=false;
200  if( pfjet.chargedMultiplicity()<=0 && fabs(pfjet.eta())<2.4 )
201  ThisIsClean=false;
202 
203  // always require #Constituents > 1
204  if( pfjet.nConstituents() <=1 ) ThisIsClean=false;
205 
206  if(ThisIsClean &&
207  (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.99
208  && (pfjet.neutralEmEnergy()/pfjet.energy())<0.99)
209  passingLoose=true;
210 
211  if(ThisIsClean &&
212  (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.95
213  && (pfjet.neutralEmEnergy()/pfjet.energy())<0.95)
214  passingMedium=true;
215 
216  if(ThisIsClean &&
217  (pfjet.neutralHadronEnergy()/pfjet.energy())< 0.90
218  && (pfjet.neutralEmEnergy()/pfjet.energy())<0.90)
219  passingTight=true;
220 
221 
222  if ( use_pfloose && passingLoose) passed = true;
223  if ( use_pfmedium && passingMedium) passed = true;
224  if ( use_pftight && passingTight) passed = true;
225  }
226 
227  if ( type == typeid(reco::GenJet) || type == typeid(reco::JPTJet)) {
228  edm::LogWarning( "JetId" )<<
229  "Criteria for jets other than CaloJets and PFJets are not yet implemented";
230  passed = true;
231  } // close GenJet, JPT jet
232 
233 
234  const T& goodJet = static_cast<const T&>((*jets)[idx]);
235  if(passed) selectedJets->push_back( goodJet );
236 
237  idx++;
238  } // close jet iterator
239 
240 
241 
242  nJetsTot_ +=jets->size();
243  nJetsPassed_+=selectedJets->size();
244  iEvent.put(selectedJets);
245 }
type
Definition: HCALResponse.h:21
virtual double energy() const GCC11_FINAL
energy
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
Jets made from CaloTowers.
Definition: CaloJet.h:29
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:138
edm::InputTag src_
Jet ID object.
Definition: JetID.h:16
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:151
unsigned int nJetsPassed_
Jets made from PFObjects.
Definition: PFJet.h:21
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:146
unsigned int nJetsTot_
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
Jets made from CaloJets corrected for ZSP and tracks.
Definition: JPTJet.h:29
vector< PseudoJet > jets
Jets made from MC generator particles.
Definition: GenJet.h:24
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
virtual int nConstituents() const
of constituents
Definition: Jet.h:65
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:98
std::vector< T > JetCollection
long double T
edm::InputTag jetIDMap_
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:94

Member Data Documentation

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

Definition at line 81 of file JetIdSelector.cc.

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

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

Definition at line 75 of file JetIdSelector.cc.

template<typename T >
std::string JetIdSelector< T >::moduleLabel_
private
template<typename T >
unsigned int JetIdSelector< T >::nJetsPassed_
private

Definition at line 80 of file JetIdSelector.cc.

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

Definition at line 79 of file JetIdSelector.cc.

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

Definition at line 74 of file JetIdSelector.cc.

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

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

Definition at line 73 of file JetIdSelector.cc.

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

Definition at line 82 of file JetIdSelector.cc.

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

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

Definition at line 83 of file JetIdSelector.cc.

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

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

Definition at line 84 of file JetIdSelector.cc.

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