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
TtSemiLepJetCombWMassDeltaTopMass Class Reference

#include <TtSemiLepJetCombWMassDeltaTopMass.h>

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

Public Member Functions

 TtSemiLepJetCombWMassDeltaTopMass (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombWMassDeltaTopMass ()
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
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 ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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::InputTag jets_
 
edm::InputTag leps_
 
double maxBDiscLightJets_
 
int maxNJets_
 
edm::InputTag mets_
 
double minBDiscBJets_
 
int neutrinoSolutionType_
 
bool useBTagging_
 
double wMass_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
typedef WorkerT< EDProducerWorkerType
 
- 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::EDProducer
CurrentProcessingContext const * currentContext () const
 
- 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 9 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file TtSemiLepJetCombWMassDeltaTopMass.cc.

References edm::hlt::Exception, and maxNJets_.

9  :
10  jets_ (cfg.getParameter<edm::InputTag>("jets" )),
11  leps_ (cfg.getParameter<edm::InputTag>("leps" )),
12  mets_ (cfg.getParameter<edm::InputTag>("mets" )),
13  maxNJets_ (cfg.getParameter<int> ("maxNJets" )),
14  wMass_ (cfg.getParameter<double> ("wMass" )),
15  useBTagging_ (cfg.getParameter<bool> ("useBTagging" )),
16  bTagAlgorithm_ (cfg.getParameter<std::string> ("bTagAlgorithm" )),
17  minBDiscBJets_ (cfg.getParameter<double> ("minBDiscBJets" )),
18  maxBDiscLightJets_(cfg.getParameter<double> ("maxBDiscLightJets")),
19  neutrinoSolutionType_(cfg.getParameter<int> ("neutrinoSolutionType"))
20 {
21  if(maxNJets_<4 && maxNJets_!=-1)
22  throw cms::Exception("WrongConfig")
23  << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
24  << "It has to be larger than 4 or can be set to -1 to take all jets.";
25 
26  produces<std::vector<std::vector<int> > >();
27  produces<int>("NumberOfConsideredJets");
28 }
T getParameter(std::string const &) const
TtSemiLepJetCombWMassDeltaTopMass::~TtSemiLepJetCombWMassDeltaTopMass ( )

Definition at line 30 of file TtSemiLepJetCombWMassDeltaTopMass.cc.

31 {
32 }

Member Function Documentation

virtual void TtSemiLepJetCombWMassDeltaTopMass::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 18 of file TtSemiLepJetCombWMassDeltaTopMass.h.

18 {};
virtual void TtSemiLepJetCombWMassDeltaTopMass::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 20 of file TtSemiLepJetCombWMassDeltaTopMass.h.

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

Definition at line 22 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

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

Implements edm::EDProducer.

Definition at line 35 of file TtSemiLepJetCombWMassDeltaTopMass.cc.

References bTagAlgorithm_, MEzCalculator::Calculate(), edm::hlt::Exception, edm::Event::getByLabel(), TtSemiLepEvtPartons::HadB, i, customizeTrackingMonitorSeedNumber::idx, isValid(), fwrapper::jets, jets_, TtSemiLepEvtPartons::LepB, leps_, TtSemiLepEvtPartons::LightQ, TtSemiLepEvtPartons::LightQBar, match(), maxBDiscLightJets_, maxNJets_, mets_, minBDiscBJets_, neutrinoSolutionType_, edm::Event::put(), MEzCalculator::SetLepton(), MEzCalculator::SetMET(), mathSSE::sqrt(), useBTagging_, and wMass_.

36 {
37  std::auto_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
38  std::auto_ptr<int> pJetsConsidered(new int);
39 
40  std::vector<int> match;
41  for(unsigned int i = 0; i < 4; ++i)
42  match.push_back( -1 );
43 
44  // get jets
46  evt.getByLabel(jets_, jets);
47 
48  // get leptons
50  evt.getByLabel(leps_, leps);
51 
52  // get MET
54  evt.getByLabel(mets_, mets);
55 
56  // skip events without lepton candidate or less than 4 jets or no MET
57  if(leps->empty() || jets->size() < 4 || mets->empty()){
58  pOut->push_back( match );
59  evt.put(pOut);
60  *pJetsConsidered = jets->size();
61  evt.put(pJetsConsidered, "NumberOfConsideredJets");
62  return;
63  }
64 
65  unsigned maxNJets = maxNJets_;
66  if(maxNJets_ == -1 || (int)jets->size() < maxNJets_) maxNJets = jets->size();
67  *pJetsConsidered = maxNJets;
68  evt.put(pJetsConsidered, "NumberOfConsideredJets");
69 
70  std::vector<bool> isBJet;
71  std::vector<bool> isLJet;
72  int cntBJets = 0;
73  if(useBTagging_) {
74  for(unsigned int idx=0; idx<maxNJets; ++idx) {
75  isBJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ ) );
76  isLJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_) );
77  if((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ )cntBJets++;
78  }
79  }
80 
81  // -----------------------------------------------------
82  // associate those jets that get closest to the W mass
83  // with their invariant mass to the hadronic W boson
84  // -----------------------------------------------------
85  double wDist =-1.;
86  std::vector<int> closestToWMassIndices;
87  closestToWMassIndices.push_back(-1);
88  closestToWMassIndices.push_back(-1);
89  for(unsigned idx=0; idx<maxNJets; ++idx){
90  if(useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx]))) continue;
91  for(unsigned jdx=(idx+1); jdx<maxNJets; ++jdx){
92  if(useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx]))) continue;
94  (*jets)[idx].p4()+
95  (*jets)[jdx].p4();
96  if( wDist<0. || wDist>fabs(sum.mass()-wMass_) ){
97  wDist=fabs(sum.mass()-wMass_);
98  closestToWMassIndices.clear();
99  closestToWMassIndices.push_back(idx);
100  closestToWMassIndices.push_back(jdx);
101  }
102  }
103  }
104 
105  // -----------------------------------------------------
106  // build a leptonic W boson from the lepton and the MET
107  // -----------------------------------------------------
108  double neutrino_pz = 0.;
109  if(neutrinoSolutionType_!=-1) {
110  MEzCalculator mez;
111  mez.SetMET( *mets->begin() );
112  if( dynamic_cast<const reco::Muon*>(&(leps->front())) )
113  mez.SetLepton( (*leps)[0], true );
114  else if( dynamic_cast<const reco::GsfElectron*>(&(leps->front())) )
115  mez.SetLepton( (*leps)[0], false );
116  else
117  throw cms::Exception("UnimplementedFeature") << "Type of lepton given together with MET for solving neutrino kinematics is neither muon nor electron.\n";
118  neutrino_pz = mez.Calculate(neutrinoSolutionType_);
119  }
120  const math::XYZTLorentzVector neutrino( mets->begin()->px(), mets->begin()->py(), neutrino_pz, sqrt(mets->begin()->px()*mets->begin()->px()
121  + mets->begin()->py()*mets->begin()->py()
122  + neutrino_pz*neutrino_pz) );
123  const reco::Particle::LorentzVector lepW = neutrino + leps->front().p4();
124 
125  // -----------------------------------------------------
126  // associate those jets to the hadronic and the leptonic
127  // b quark that minimize the difference between
128  // hadronic and leptonic top mass
129  // -----------------------------------------------------
130  double deltaTop=-1.;
131  int hadB=-1;
132  int lepB=-1;
133  if( isValid(closestToWMassIndices[0], jets) && isValid(closestToWMassIndices[1], jets)) {
134  const reco::Particle::LorentzVector hadW =
135  (*jets)[closestToWMassIndices[0]].p4()+
136  (*jets)[closestToWMassIndices[1]].p4();
137  // find hadronic b candidate
138  for(unsigned idx=0; idx<maxNJets; ++idx){
139  if(useBTagging_ && !isBJet[idx]) continue;
140  // make sure it's not used up already from the hadronic W
141  if( (int)idx!=closestToWMassIndices[0] && (int)idx!=closestToWMassIndices[1] ){
142  reco::Particle::LorentzVector hadTop = hadW + (*jets)[idx].p4();
143  // find leptonic b candidate
144  for(unsigned jdx=0; jdx<maxNJets; ++jdx){
145  if(useBTagging_ && !isBJet[jdx]) continue;
146  // make sure it's not used up already from the hadronic branch
147  if( (int)jdx!=closestToWMassIndices[0] && (int)jdx!=closestToWMassIndices[1] && jdx!=idx ){
148  reco::Particle::LorentzVector lepTop = lepW + (*jets)[jdx].p4();
149  if( deltaTop<0. || deltaTop>fabs(hadTop.mass()-lepTop.mass()) ){
150  deltaTop=fabs(hadTop.mass()-lepTop.mass());
151  hadB=idx;
152  lepB=jdx;
153  }
154  }
155  }
156  }
157  }
158  }
159 
160  match[TtSemiLepEvtPartons::LightQ ] = closestToWMassIndices[0];
161  match[TtSemiLepEvtPartons::LightQBar] = closestToWMassIndices[1];
162  match[TtSemiLepEvtPartons::HadB ] = hadB;
163  match[TtSemiLepEvtPartons::LepB ] = lepB;
164 
165  pOut->push_back( match );
166  evt.put(pOut);
167 }
void SetLepton(const pat::Particle &lepton, bool isMuon=true)
Set lepton.
Definition: MEzCalculator.h:32
int i
Definition: DBlmapReader.cc:9
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
void SetMET(const pat::MET &MET)
Set MET.
Definition: MEzCalculator.h:26
double Calculate(int type=1)
member functions
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
T sqrt(T t)
Definition: SSEVec.h:48
vector< PseudoJet > jets
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:6
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Particle.h:25

Member Data Documentation

std::string TtSemiLepJetCombWMassDeltaTopMass::bTagAlgorithm_
private

Definition at line 30 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

edm::InputTag TtSemiLepJetCombWMassDeltaTopMass::jets_
private

Definition at line 22 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

edm::InputTag TtSemiLepJetCombWMassDeltaTopMass::leps_
private

Definition at line 25 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

double TtSemiLepJetCombWMassDeltaTopMass::maxBDiscLightJets_
private

Definition at line 32 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

int TtSemiLepJetCombWMassDeltaTopMass::maxNJets_
private
edm::InputTag TtSemiLepJetCombWMassDeltaTopMass::mets_
private

Definition at line 26 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

double TtSemiLepJetCombWMassDeltaTopMass::minBDiscBJets_
private

Definition at line 31 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

int TtSemiLepJetCombWMassDeltaTopMass::neutrinoSolutionType_
private

Definition at line 33 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

bool TtSemiLepJetCombWMassDeltaTopMass::useBTagging_
private

Definition at line 29 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().

double TtSemiLepJetCombWMassDeltaTopMass::wMass_
private

Definition at line 28 of file TtSemiLepJetCombWMassDeltaTopMass.h.

Referenced by produce().