CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
TtSemiLepJetCombWMassMaxSumPt Class Reference

#include <TtSemiLepJetCombWMassMaxSumPt.h>

Inheritance diagram for TtSemiLepJetCombWMassMaxSumPt:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 TtSemiLepJetCombWMassMaxSumPt (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombWMassMaxSumPt ()
 
- 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
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

virtual void beginJob ()
 
virtual void endJob ()
 
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 
virtual void produce (edm::Event &evt, const edm::EventSetup &setup)
 

Private Attributes

std::string bTagAlgorithm_
 
edm::EDGetTokenT< std::vector
< pat::Jet > > 
jetsToken_
 
edm::EDGetTokenT< edm::View
< reco::RecoCandidate > > 
lepsToken_
 
double maxBDiscLightJets_
 
int maxNJets_
 
double minBDiscBJets_
 
bool useBTagging_
 
double wMass_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- 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

Definition at line 10 of file TtSemiLepJetCombWMassMaxSumPt.h.

Constructor & Destructor Documentation

TtSemiLepJetCombWMassMaxSumPt::TtSemiLepJetCombWMassMaxSumPt ( const edm::ParameterSet cfg)
explicit

Definition at line 5 of file TtSemiLepJetCombWMassMaxSumPt.cc.

References Exception, and maxNJets_.

5  :
6  jetsToken_ (consumes< std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets" ))),
8  maxNJets_ (cfg.getParameter<int> ("maxNJets" )),
9  wMass_ (cfg.getParameter<double> ("wMass" )),
10  useBTagging_ (cfg.getParameter<bool> ("useBTagging" )),
11  bTagAlgorithm_ (cfg.getParameter<std::string> ("bTagAlgorithm" )),
12  minBDiscBJets_ (cfg.getParameter<double> ("minBDiscBJets" )),
13  maxBDiscLightJets_(cfg.getParameter<double> ("maxBDiscLightJets"))
14 {
15  if(maxNJets_<4 && maxNJets_!=-1)
16  throw cms::Exception("WrongConfig")
17  << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
18  << "It has to be larger than 4 or can be set to -1 to take all jets.";
19 
20  produces<std::vector<std::vector<int> > >();
21  produces<int>("NumberOfConsideredJets");
22 }
T getParameter(std::string const &) const
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
TtSemiLepJetCombWMassMaxSumPt::~TtSemiLepJetCombWMassMaxSumPt ( )

Definition at line 24 of file TtSemiLepJetCombWMassMaxSumPt.cc.

25 {
26 }

Member Function Documentation

virtual void TtSemiLepJetCombWMassMaxSumPt::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 19 of file TtSemiLepJetCombWMassMaxSumPt.h.

19 {};
virtual void TtSemiLepJetCombWMassMaxSumPt::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 21 of file TtSemiLepJetCombWMassMaxSumPt.h.

21 {};
bool TtSemiLepJetCombWMassMaxSumPt::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprivate

Definition at line 23 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce(), and core.AutoHandle.AutoHandle::ReallyLoad().

23 { return (0<=idx && idx<(int)jets->size()); };
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
void TtSemiLepJetCombWMassMaxSumPt::produce ( edm::Event evt,
const edm::EventSetup setup 
)
privatevirtual

Implements edm::EDProducer.

Definition at line 29 of file TtSemiLepJetCombWMassMaxSumPt.cc.

References bTagAlgorithm_, edm::Event::getByToken(), TtSemiLepEvtPartons::HadB, i, customizeTrackingMonitorSeedNumber::idx, isValid(), fwrapper::jets, jetsToken_, TtSemiLepEvtPartons::LepB, lepsToken_, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, match(), maxBDiscLightJets_, HLT_25ns14e33_v1_cff::maxNJets, maxNJets_, minBDiscBJets_, edm::Event::put(), useBTagging_, and wMass_.

30 {
31  std::auto_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
32  std::auto_ptr<int> pJetsConsidered(new int);
33 
34  std::vector<int> match;
35  for(unsigned int i = 0; i < 4; ++i)
36  match.push_back( -1 );
37 
38  // get jets
40  evt.getByToken(jetsToken_, jets);
41 
42  // get leptons
44  evt.getByToken(lepsToken_, leps);
45 
46 
47  // skip events without lepton candidate or less than 4 jets or no MET
48  if(leps->empty() || jets->size() < 4){
49  pOut->push_back( match );
50  evt.put(pOut);
51  *pJetsConsidered = jets->size();
52  evt.put(pJetsConsidered, "NumberOfConsideredJets");
53  return;
54  }
55 
56  unsigned maxNJets = maxNJets_;
57  if(maxNJets_ == -1 || (int)jets->size() < maxNJets_) maxNJets = jets->size();
58  *pJetsConsidered = maxNJets;
59  evt.put(pJetsConsidered, "NumberOfConsideredJets");
60 
61  std::vector<bool> isBJet;
62  std::vector<bool> isLJet;
63  int cntBJets = 0;
64  if(useBTagging_) {
65  for(unsigned int idx=0; idx<maxNJets; ++idx) {
66  isBJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ ) );
67  isLJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_) );
68  if((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ )cntBJets++;
69  }
70  }
71 
72  // -----------------------------------------------------
73  // associate those jets that get closest to the W mass
74  // with their invariant mass to the hadronic W boson
75  // -----------------------------------------------------
76  double wDist =-1.;
77  std::vector<int> closestToWMassIndices;
78  closestToWMassIndices.push_back(-1);
79  closestToWMassIndices.push_back(-1);
80  for(unsigned idx=0; idx<maxNJets; ++idx){
81  if(useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx]))) continue;
82  for(unsigned jdx=(idx+1); jdx<maxNJets; ++jdx){
83  if(useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx]))) continue;
85  (*jets)[idx].p4()+
86  (*jets)[jdx].p4();
87  if( wDist<0. || wDist>fabs(sum.mass()-wMass_) ){
88  wDist=fabs(sum.mass()-wMass_);
89  closestToWMassIndices.clear();
90  closestToWMassIndices.push_back(idx);
91  closestToWMassIndices.push_back(jdx);
92  }
93  }
94  }
95 
96  // -----------------------------------------------------
97  // associate those jets with maximum pt of the vectorial
98  // sum to the hadronic decay chain
99  // -----------------------------------------------------
100  double maxPt=-1.;
101  int hadB=-1;
102  if( isValid(closestToWMassIndices[0], jets) && isValid(closestToWMassIndices[1], jets)) {
103  for(unsigned idx=0; idx<maxNJets; ++idx){
104  if(useBTagging_ && !isBJet[idx]) continue;
105  // make sure it's not used up already from the hadronic W
106  if( (int)idx!=closestToWMassIndices[0] && (int)idx!=closestToWMassIndices[1] ){
108  (*jets)[closestToWMassIndices[0]].p4()+
109  (*jets)[closestToWMassIndices[1]].p4()+
110  (*jets)[idx].p4();
111  if( maxPt<0. || maxPt<sum.pt() ){
112  maxPt=sum.pt();
113  hadB=idx;
114  }
115  }
116  }
117  }
118 
119  // -----------------------------------------------------
120  // associate the remaining jet with maximum pt of the
121  // vectorial sum with the leading lepton with the
122  // leptonic b quark
123  // -----------------------------------------------------
124  maxPt=-1.;
125  int lepB=-1;
126  for(unsigned idx=0; idx<maxNJets; ++idx){
127  if(useBTagging_ && !isBJet[idx]) continue;
128  // make sure it's not used up already from the hadronic decay chain
129  if( (int)idx!=closestToWMassIndices[0] && (int)idx!=closestToWMassIndices[1] && (int)idx!=hadB) {
131  (*jets)[idx].p4()+(*leps)[ 0 ].p4();
132  if( maxPt<0. || maxPt<sum.pt() ){
133  maxPt=sum.pt();
134  lepB=idx;
135  }
136  }
137  }
138 
139  match[TtSemiLepEvtPartons::LightQ ] = closestToWMassIndices[0];
140  match[TtSemiLepEvtPartons::LightQBar] = closestToWMassIndices[1];
141  match[TtSemiLepEvtPartons::HadB ] = hadB;
142  match[TtSemiLepEvtPartons::LepB ] = lepB;
143 
144  pOut->push_back( match );
145  evt.put(pOut);
146 }
int i
Definition: DBlmapReader.cc:9
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:449
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
vector< PseudoJet > jets
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:21

Member Data Documentation

std::string TtSemiLepJetCombWMassMaxSumPt::bTagAlgorithm_
private

Definition at line 30 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

edm::EDGetTokenT< std::vector<pat::Jet> > TtSemiLepJetCombWMassMaxSumPt::jetsToken_
private

Definition at line 23 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

edm::EDGetTokenT< edm::View<reco::RecoCandidate> > TtSemiLepJetCombWMassMaxSumPt::lepsToken_
private

Definition at line 26 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

double TtSemiLepJetCombWMassMaxSumPt::maxBDiscLightJets_
private

Definition at line 32 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

int TtSemiLepJetCombWMassMaxSumPt::maxNJets_
private

Definition at line 27 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce(), and TtSemiLepJetCombWMassMaxSumPt().

double TtSemiLepJetCombWMassMaxSumPt::minBDiscBJets_
private

Definition at line 31 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

bool TtSemiLepJetCombWMassMaxSumPt::useBTagging_
private

Definition at line 29 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().

double TtSemiLepJetCombWMassMaxSumPt::wMass_
private

Definition at line 28 of file TtSemiLepJetCombWMassMaxSumPt.h.

Referenced by produce().