CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
BTagSkimLeptonJet Class Reference

#include <BTagSkimLeptonJet.h>

Inheritance diagram for BTagSkimLeptonJet:
edm::EDFilter edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

class  PtSorter
 

Public Member Functions

 BTagSkimLeptonJet (const edm::ParameterSet &)
 
void endJob () override
 
bool filter (edm::Event &, const edm::EventSetup &) override
 
 ~BTagSkimLeptonJet () override
 
- Public Member Functions inherited from edm::EDFilter
 EDFilter ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDFilter () 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
 
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)
 
 ~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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
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

edm::InputTag CaloJetInput_
 
edm::InputTag LeptonInput_
 
std::string LeptonType_
 
double MaxCaloJetEta_
 
double MaxDeltaR_
 
double MaxLeptonEta_
 
double MinCaloJetPt_
 
double MinLeptonPt_
 
int MinNLeptonJet_
 
double MinPtRel_
 
unsigned int nAccepted_
 
unsigned int nEvents_
 

Additional Inherited Members

- Public Types inherited from edm::EDFilter
typedef EDFilter 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
 
- Static Public Member Functions inherited from edm::EDFilter
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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

Definition at line 20 of file BTagSkimLeptonJet.h.

Constructor & Destructor Documentation

BTagSkimLeptonJet::BTagSkimLeptonJet ( const edm::ParameterSet iConfig)
explicit

Definition at line 35 of file BTagSkimLeptonJet.cc.

References CaloJetInput_, edm::ParameterSet::getParameter(), LeptonInput_, LeptonType_, MaxCaloJetEta_, MaxDeltaR_, MaxLeptonEta_, MinCaloJetPt_, MinLeptonPt_, MinNLeptonJet_, MinPtRel_, and AlCaHLTBitMon_QueryRunRegistry::string.

35  :
36  nEvents_(0), nAccepted_(0)
37 {
38  CaloJetInput_ = iConfig.getParameter<InputTag>( "CaloJet" );
39  MinCaloJetPt_ = iConfig.getParameter<double>( "MinimumCaloJetPt" );
40  MaxCaloJetEta_ = iConfig.getParameter<double>( "MaximumCaloJetEta" );
41 
42  LeptonType_ = iConfig.getParameter<std::string>("LeptonType");
43  if ( LeptonType_ != "electron" && LeptonType_ != "muon" )
44  edm::LogError( "BTagSkimLeptonJet" )
45  << "unknown lepton type !!";
46  LeptonInput_ = iConfig.getParameter<InputTag>( "Lepton" );
47  MinLeptonPt_ = iConfig.getParameter<double>( "MinimumLeptonPt" );
48  MaxLeptonEta_ = iConfig.getParameter<double>( "MaximumLeptonEta" );
49  //MinNLepton_ = iConfig.getParameter<int>( "MinimumNLepton" );
50 
51  MaxDeltaR_ = iConfig.getParameter<double>( "MaximumDeltaR" );
52 
53  MinPtRel_ = iConfig.getParameter<double>("MinimumPtRel" );
54 
55  MinNLeptonJet_ = iConfig.getParameter<int>( "MinimumNLeptonJet" );
56  if ( MinNLeptonJet_ < 1 )
57  edm::LogError( "BTagSkimLeptonJet" )
58  << "MinimunNCaloJet < 1 !!";
59 }
T getParameter(std::string const &) const
std::string LeptonType_
edm::InputTag LeptonInput_
unsigned int nAccepted_
edm::InputTag CaloJetInput_
unsigned int nEvents_
BTagSkimLeptonJet::~BTagSkimLeptonJet ( )
override

Definition at line 63 of file BTagSkimLeptonJet.cc.

64 {}

Member Function Documentation

void BTagSkimLeptonJet::endJob ( void  )
overridevirtual

Reimplemented from edm::EDFilter.

Definition at line 184 of file BTagSkimLeptonJet.cc.

References DEFINE_FWK_MODULE, LeptonType_, nAccepted_, and nEvents_.

185 {
186  edm::LogVerbatim( "BTagSkimLeptonJet" )
187  << "=============================================================================\n"
188  << " Events read: " << nEvents_
189  << "\n Events accepted by (" << LeptonType_ << ") BTagSkimLeptonJet: " << nAccepted_
190  << "\n Efficiency: " << (double)(nAccepted_)/(double)(nEvents_)
191  << "\n==========================================================================="
192  << endl;
193 }
std::string LeptonType_
unsigned int nAccepted_
unsigned int nEvents_
bool BTagSkimLeptonJet::filter ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
override

Definition at line 68 of file BTagSkimLeptonJet.cc.

References CaloJetInput_, HiRegitMuonDetachedTripletStep_cff::DeltaR, edm::Event::getByLabel(), LeptonInput_, LeptonType_, MaxCaloJetEta_, MaxDeltaR_, MaxLeptonEta_, MinCaloJetPt_, MinLeptonPt_, MinNLeptonJet_, MinPtRel_, nAccepted_, and nEvents_.

70 {
71  nEvents_++;
72 
73  Handle<CaloJetCollection> CaloJetsHandle;
74  //try {
75  iEvent.getByLabel( CaloJetInput_, CaloJetsHandle );
76  //}
77  //catch ( cms::Exception& ex ) {
78  //edm::LogError( "BTagSkimLeptonJet" )
79  // << "Unable to get CaloJet collection "
80  // << CaloJetInput_.label();
81  //return false;
82  //}
83  if ( CaloJetsHandle->empty() ) return false;
84  CaloJetCollection TheCaloJets = *CaloJetsHandle;
85  std::stable_sort( TheCaloJets.begin(), TheCaloJets.end(), PtSorter() );
86 
87  //int nLepton = 0;
88 
89  Handle<MuonCollection> MuonHandle;
90  MuonCollection TheMuons;
91  if (LeptonType_ == "muon") {
92  //try{
93  iEvent.getByLabel( LeptonInput_, MuonHandle );
94  // }
95  // catch ( cms::Exception& ex ) {
96  //edm::LogError( "BTagSkimLeptonJet" )
97  // << "Unable to get muon collection "
98  // << LeptonInput_.label();
99  //return false;
100  //}
101  TheMuons = *MuonHandle;
102  std::stable_sort( TheMuons.begin(), TheMuons.end(), PtSorter() );
103  }
104 
105  Handle<GsfElectronCollection> ElectronHandle;
106  GsfElectronCollection TheElectrons;
107  if (LeptonType_ == "electron") {
108  //try{
109  iEvent.getByLabel( LeptonInput_, ElectronHandle );
110  // }
111  // catch ( cms::Exception& ex ) {
112  // edm::LogError( "BTagSkimLeptonJet" )
113  // << "Unable to get electron collection "
114  // << LeptonInput_.label();
115  // return false;
116  // }
117  TheElectrons = *ElectronHandle;
118  std::stable_sort( TheElectrons.begin(), TheElectrons.end(), PtSorter() );
119  }
120 
121  // Jet cuts
122  int nJet = 0;
123  for ( CaloJetCollection::const_iterator ajet = TheCaloJets.begin(); ajet != TheCaloJets.end(); ++ajet ) {
124 
125  if ( (fabs(ajet->eta()) < MaxCaloJetEta_) && (ajet->pt() > MinCaloJetPt_) ) {
126 
127  if (LeptonType_ == "muon" ) {
128  for ( MuonCollection::const_iterator amuon = TheMuons.begin(); amuon != TheMuons.end(); ++amuon ) {
129  // select good muon
130  if ( (amuon->pt() > MinLeptonPt_) && (fabs(amuon->eta()) < MaxLeptonEta_) ) {
131 
132  double deltar = ROOT::Math::VectorUtil::DeltaR(ajet->p4().Vect(),
133  amuon->momentum() );
134 
135  TVector3 jetvec(ajet->p4().Vect().X(),
136  ajet->p4().Vect().Y(),
137  ajet->p4().Vect().Z() );
138  TVector3 muvec( amuon->momentum().X(),
139  amuon->momentum().Y(),
140  amuon->momentum().Z() );
141  jetvec += muvec;
142  double ptrel = muvec.Perp(jetvec);
143 
144  if ( ( deltar < MaxDeltaR_ ) && (ptrel > MinPtRel_) ) nJet++;
145  if ( nJet >= MinNLeptonJet_ ) break;
146  }
147  }
148  }
149 
150  if (LeptonType_ == "electron") {
151  for ( GsfElectronCollection::const_iterator anelectron = TheElectrons.begin(); anelectron != TheElectrons.end(); anelectron++ ) {
152  if ( (anelectron->pt() > MinLeptonPt_) && (fabs(anelectron->eta()) < MaxLeptonEta_ ) ) {
153 
154  double deltar = ROOT::Math::VectorUtil::DeltaR(ajet->p4().Vect(),
155  anelectron->momentum() );
156 
157  TVector3 jetvec(ajet->p4().Vect().X(),
158  ajet->p4().Vect().Y(),
159  ajet->p4().Vect().Z() );
160  TVector3 evec( anelectron->momentum().X(),
161  anelectron->momentum().Y(),
162  anelectron->momentum().Z() );
163  jetvec += evec;
164  double ptrel = evec.Perp(jetvec);
165 
166  if ( ( deltar < MaxDeltaR_ ) && (ptrel > MinPtRel_) ) nJet++;
167  if ( nJet >= MinNLeptonJet_ ) break;
168  }
169  }
170  }
171 
172  }// close jet selection
173  }
174 
175  if ( nJet < MinNLeptonJet_ ) return false;
176 
177  nAccepted_++;
178 
179  return true;
180 }
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
std::string LeptonType_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
edm::InputTag LeptonInput_
Definition: deltar.py:1
unsigned int nAccepted_
edm::InputTag CaloJetInput_
unsigned int nEvents_
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects

Member Data Documentation

edm::InputTag BTagSkimLeptonJet::CaloJetInput_
private

Definition at line 29 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

edm::InputTag BTagSkimLeptonJet::LeptonInput_
private

Definition at line 34 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

std::string BTagSkimLeptonJet::LeptonType_
private

Definition at line 33 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), endJob(), and filter().

double BTagSkimLeptonJet::MaxCaloJetEta_
private

Definition at line 31 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

double BTagSkimLeptonJet::MaxDeltaR_
private

Definition at line 37 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

double BTagSkimLeptonJet::MaxLeptonEta_
private

Definition at line 36 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

double BTagSkimLeptonJet::MinCaloJetPt_
private

Definition at line 30 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

double BTagSkimLeptonJet::MinLeptonPt_
private

Definition at line 35 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

int BTagSkimLeptonJet::MinNLeptonJet_
private

Definition at line 32 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

double BTagSkimLeptonJet::MinPtRel_
private

Definition at line 38 of file BTagSkimLeptonJet.h.

Referenced by BTagSkimLeptonJet(), and filter().

unsigned int BTagSkimLeptonJet::nAccepted_
private

Definition at line 41 of file BTagSkimLeptonJet.h.

Referenced by endJob(), and filter().

unsigned int BTagSkimLeptonJet::nEvents_
private

Definition at line 40 of file BTagSkimLeptonJet.h.

Referenced by endJob(), and filter().