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

#include <TtSemiLepJetCombGeom.h>

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

Public Member Functions

 TtSemiLepJetCombGeom (const edm::ParameterSet &)
 
 ~TtSemiLepJetCombGeom ()
 
- 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
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) 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 ()
 
double distance (const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
 
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_
 
bool useDeltaR_
 

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 TtSemiLepJetCombGeom.h.

Constructor & Destructor Documentation

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

Definition at line 9 of file TtSemiLepJetCombGeom.cc.

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

9  :
10  jetsToken_ (consumes< std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets" ))),
12  maxNJets_ (cfg.getParameter<int> ("maxNJets" )),
13  useDeltaR_ (cfg.getParameter<bool> ("useDeltaR" )),
14  useBTagging_ (cfg.getParameter<bool> ("useBTagging" )),
15  bTagAlgorithm_ (cfg.getParameter<std::string> ("bTagAlgorithm" )),
16  minBDiscBJets_ (cfg.getParameter<double> ("minBDiscBJets" )),
17  maxBDiscLightJets_(cfg.getParameter<double> ("maxBDiscLightJets"))
18 {
19  if(maxNJets_<4 && maxNJets_!=-1)
20  throw cms::Exception("WrongConfig")
21  << "Parameter maxNJets can not be set to " << maxNJets_ << ". \n"
22  << "It has to be larger than 4 or can be set to -1 to take all jets.";
23 
24  produces<std::vector<std::vector<int> > >();
25  produces<int>("NumberOfConsideredJets");
26 }
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_
TtSemiLepJetCombGeom::~TtSemiLepJetCombGeom ( )

Definition at line 28 of file TtSemiLepJetCombGeom.cc.

29 {
30 }

Member Function Documentation

virtual void TtSemiLepJetCombGeom::beginJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 19 of file TtSemiLepJetCombGeom.h.

19 {};
double TtSemiLepJetCombGeom::distance ( const math::XYZTLorentzVector v1,
const math::XYZTLorentzVector v2 
)
private

Definition at line 147 of file TtSemiLepJetCombGeom.cc.

References useDeltaR_.

Referenced by produce().

148 {
149  // calculate the distance between two lorentz vectors
150  // using DeltaR or DeltaTheta
151  if(useDeltaR_) return ROOT::Math::VectorUtil::DeltaR(v1, v2);
152  return fabs(v1.theta() - v2.theta());
153 }
virtual void TtSemiLepJetCombGeom::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDProducer.

Definition at line 21 of file TtSemiLepJetCombGeom.h.

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

Definition at line 23 of file TtSemiLepJetCombGeom.h.

References fwrapper::jets.

Referenced by produce().

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

Implements edm::EDProducer.

Definition at line 33 of file TtSemiLepJetCombGeom.cc.

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

34 {
35  std::auto_ptr<std::vector<std::vector<int> > > pOut(new std::vector<std::vector<int> >);
36  std::auto_ptr<int> pJetsConsidered(new int);
37 
38  std::vector<int> match;
39  for(unsigned int i = 0; i < 4; ++i)
40  match.push_back( -1 );
41 
42  // get jets
44  evt.getByToken(jetsToken_, jets);
45 
46  // get leptons
48  evt.getByToken(lepsToken_, leps);
49 
50  // skip events without lepton candidate or less than 4 jets
51  if(leps->empty() || jets->size() < 4){
52  pOut->push_back( match );
53  evt.put(pOut);
54  *pJetsConsidered = jets->size();
55  evt.put(pJetsConsidered, "NumberOfConsideredJets");
56  return;
57  }
58 
59  unsigned maxNJets = maxNJets_;
60  if(maxNJets_ == -1 || (int)jets->size() < maxNJets_) maxNJets = jets->size();
61  *pJetsConsidered = maxNJets;
62  evt.put(pJetsConsidered, "NumberOfConsideredJets");
63 
64  std::vector<bool> isBJet;
65  std::vector<bool> isLJet;
66  int cntBJets = 0;
67  if(useBTagging_) {
68  for(unsigned int idx=0; idx<maxNJets; ++idx) {
69  isBJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ ) );
70  isLJet.push_back( ((*jets)[idx].bDiscriminator(bTagAlgorithm_) < maxBDiscLightJets_) );
71  if((*jets)[idx].bDiscriminator(bTagAlgorithm_) > minBDiscBJets_ )cntBJets++;
72  }
73  }
74 
75  // -----------------------------------------------------
76  // associate those two jets to the hadronic W boson that
77  // have the smallest distance to each other
78  // -----------------------------------------------------
79  double minDist=-1.;
80  int lightQ =-1;
81  int lightQBar=-1;
82  for(unsigned int idx=0; idx<maxNJets; ++idx){
83  if(useBTagging_ && (!isLJet[idx] || (cntBJets<=2 && isBJet[idx]))) continue;
84  for(unsigned int jdx=(idx+1); jdx<maxNJets; ++jdx){
85  if(useBTagging_ && (!isLJet[jdx] || (cntBJets<=2 && isBJet[jdx]) || (cntBJets==3 && isBJet[idx] && isBJet[jdx]))) continue;
86  double dist = distance((*jets)[idx].p4(), (*jets)[jdx].p4());
87  if( minDist<0. || dist<minDist ){
88  minDist=dist;
89  lightQ =idx;
90  lightQBar=jdx;
91  }
92  }
93  }
94 
96  if( isValid(lightQ, jets) && isValid(lightQBar, jets) )
97  wHad = (*jets)[lightQ].p4() + (*jets)[lightQBar].p4();
98 
99  // -----------------------------------------------------
100  // associate to the hadronic b quark the remaining jet
101  // that has the smallest distance to the hadronic W
102  // -----------------------------------------------------
103  minDist=-1.;
104  int hadB=-1;
105  if( isValid(lightQ, jets) && isValid(lightQBar, jets) ) {
106  for(unsigned int idx=0; idx<maxNJets; ++idx){
107  if(useBTagging_ && !isBJet[idx]) continue;
108  // make sure it's not used up already from the hadronic W
109  if( (int)idx!=lightQ && (int)idx!=lightQBar ) {
110  double dist = distance((*jets)[idx].p4(), wHad);
111  if( minDist<0. || dist<minDist ){
112  minDist=dist;
113  hadB=idx;
114  }
115  }
116  }
117  }
118 
119  // -----------------------------------------------------
120  // associate to the leptonic b quark the remaining jet
121  // that has the smallest distance to the leading lepton
122  // -----------------------------------------------------
123  minDist=-1.;
124  int lepB=-1;
125  for(unsigned int idx=0; idx<maxNJets; ++idx){
126  if(useBTagging_ && !isBJet[idx]) continue;
127  // make sure it's not used up already from the hadronic decay chain
128  if( (int)idx!=lightQ && (int)idx!=lightQBar && (int)idx!=hadB ){
129  double dist = distance((*jets)[idx].p4(), (*leps)[0].p4());
130  if( minDist<0. || dist<minDist ){
131  minDist=dist;
132  lepB=idx;
133  }
134  }
135  }
136 
137  match[TtSemiLepEvtPartons::LightQ ] = lightQ;
138  match[TtSemiLepEvtPartons::LightQBar] = lightQBar;
139  match[TtSemiLepEvtPartons::HadB ] = hadB;
140  match[TtSemiLepEvtPartons::LepB ] = lepB;
141 
142  pOut->push_back( match );
143  evt.put(pOut);
144 }
edm::EDGetTokenT< edm::View< reco::RecoCandidate > > lepsToken_
int i
Definition: DBlmapReader.cc:9
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
bool isValid(const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
double p4[4]
Definition: TauolaWrapper.h:92
vector< PseudoJet > jets
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
double distance(const math::XYZTLorentzVector &, const math::XYZTLorentzVector &)
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:27

Member Data Documentation

std::string TtSemiLepJetCombGeom::bTagAlgorithm_
private

Definition at line 31 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

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

Definition at line 26 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

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

Definition at line 27 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

double TtSemiLepJetCombGeom::maxBDiscLightJets_
private

Definition at line 33 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

int TtSemiLepJetCombGeom::maxNJets_
private

Definition at line 28 of file TtSemiLepJetCombGeom.h.

Referenced by produce(), and TtSemiLepJetCombGeom().

double TtSemiLepJetCombGeom::minBDiscBJets_
private

Definition at line 32 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

bool TtSemiLepJetCombGeom::useBTagging_
private

Definition at line 30 of file TtSemiLepJetCombGeom.h.

Referenced by produce().

bool TtSemiLepJetCombGeom::useDeltaR_
private

Definition at line 29 of file TtSemiLepJetCombGeom.h.

Referenced by distance().