CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
TtFullHadHypothesis Class Referenceabstract

#include <TtFullHadHypothesis.h>

Inheritance diagram for TtFullHadHypothesis:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper TtFullHadHypGenMatch TtFullHadHypKinFit

Public Member Functions

 TtFullHadHypothesis (const edm::ParameterSet &cfg)
 default constructor More...
 
 ~TtFullHadHypothesis ()
 default destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- 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 ()
 
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, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies, std::string const &moduleLabel)
 
virtual ~ProducerBase () noexcept(false)
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
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 & itemsToGetFromEvent () 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
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

virtual void buildHypo (edm::Event &event, const edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &jetPartonAssociation, const unsigned int iComb)=0
 build event hypothesis from the reco objects of a full-hadronic event More...
 
virtual void buildKey ()=0
 build the event hypothesis key More...
 
reco::CompositeCandidate hypo ()
 return event hypothesis More...
 
bool isValid (const int &idx, const edm::Handle< std::vector< pat::Jet > > &jets)
 check if index is in valid range of selected jets More...
 
std::string jetCorrectionLevel (const std::string &quarkType)
 helper function to construct the proper correction level string for corresponding quarkType More...
 
int key () const
 return key More...
 
virtual void produce (edm::Event &, const edm::EventSetup &)
 produce the event hypothesis as CompositeCandidate and Key More...
 
void resetCandidates ()
 reset candidate pointers before hypo build process More...
 
template<typename C >
void setCandidate (const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
void setCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections More...
 
- 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)
 

Protected Attributes

reco::ShallowClonePtrCandidateb_
 
reco::ShallowClonePtrCandidatebBar_
 
bool getMatch_
 
std::string jetCorrectionLevel_
 
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
 input label for all necessary collections More...
 
int key_
 hypothesis key (to be set by the buildKey function) More...
 
reco::ShallowClonePtrCandidatelightP_
 
reco::ShallowClonePtrCandidatelightPBar_
 
reco::ShallowClonePtrCandidatelightQ_
 
reco::ShallowClonePtrCandidatelightQBar_
 
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
 

Additional Inherited Members

- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 29 of file TtFullHadHypothesis.h.

Constructor & Destructor Documentation

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

default constructor

Definition at line 5 of file TtFullHadHypothesis.cc.

References edm::ParameterSet::exists(), getMatch_, edm::ParameterSet::getParameter(), jetCorrectionLevel_, matchToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

5  :
6  jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
7  lightQ_(0), lightQBar_(0), b_(0), bBar_(0), lightP_(0), lightPBar_(0)
8 {
9  getMatch_ = false;
10  if( cfg.exists("match") ) {
11  getMatch_ = true;
12  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
13  }
14  if( cfg.exists("jetCorrectionLevel") ) {
15  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
16  }
17  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
18  produces<int>("Key");
19 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
reco::ShallowClonePtrCandidate * lightPBar_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
reco::ShallowClonePtrCandidate * lightQBar_
reco::ShallowClonePtrCandidate * lightP_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
std::string jetCorrectionLevel_
reco::ShallowClonePtrCandidate * bBar_
reco::ShallowClonePtrCandidate * b_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input label for all necessary collections
reco::ShallowClonePtrCandidate * lightQ_
TtFullHadHypothesis::~TtFullHadHypothesis ( )

default destructor

Definition at line 22 of file TtFullHadHypothesis.cc.

References b_, bBar_, lightP_, lightPBar_, lightQ_, and lightQBar_.

23 {
24  if( lightQ_ ) delete lightQ_;
25  if( lightQBar_ ) delete lightQBar_;
26  if( b_ ) delete b_;
27  if( bBar_ ) delete bBar_;
28  if( lightP_ ) delete lightP_;
29  if( lightPBar_ ) delete lightPBar_;
30 }
reco::ShallowClonePtrCandidate * lightPBar_
reco::ShallowClonePtrCandidate * lightQBar_
reco::ShallowClonePtrCandidate * lightP_
reco::ShallowClonePtrCandidate * bBar_
reco::ShallowClonePtrCandidate * b_
reco::ShallowClonePtrCandidate * lightQ_

Member Function Documentation

virtual void TtFullHadHypothesis::buildHypo ( edm::Event event,
const edm::Handle< std::vector< pat::Jet > > &  jets,
std::vector< int > &  jetPartonAssociation,
const unsigned int  iComb 
)
protectedpure virtual

build event hypothesis from the reco objects of a full-hadronic event

Implemented in TtFullHadHypKinFit, and TtFullHadHypGenMatch.

Referenced by isValid(), and produce().

virtual void TtFullHadHypothesis::buildKey ( )
protectedpure virtual

build the event hypothesis key

Implemented in TtFullHadHypKinFit, and TtFullHadHypGenMatch.

Referenced by isValid(), and produce().

reco::CompositeCandidate TtFullHadHypothesis::hypo ( )
protected

return event hypothesis

Definition at line 90 of file TtFullHadHypothesis.cc.

References reco::CompositeCandidate::addDaughter(), TtFullHadDaughter::B, b_, TtFullHadDaughter::BBar, bBar_, TtFullHadDaughter::LightP, lightP_, TtFullHadDaughter::LightPBar, lightPBar_, TtFullHadDaughter::LightQ, lightQ_, TtFullHadDaughter::LightQBar, lightQBar_, AddFourMomenta::set(), AlCaHLTBitMon_QueryRunRegistry::string, TtFullHadDaughter::Top, TtFullHadDaughter::TopBar, w, TtFullHadDaughter::WMinus, and TtFullHadDaughter::WPlus.

Referenced by key(), and produce().

91 {
92  // check for sanity of the hypothesis
93  if( !lightQ_ || !lightQBar_ || !b_ ||
94  !bBar_ || !lightP_ || !lightPBar_ )
95  return reco::CompositeCandidate();
96 
97  // setup transient references
98  reco::CompositeCandidate hyp, top, w, topBar, wBar;
99 
100  AddFourMomenta addFourMomenta;
101  // build up the top bar branch
104  addFourMomenta.set( wBar );
105  topBar.addDaughter( wBar, TtFullHadDaughter::WMinus );
107  addFourMomenta.set( topBar );
108 
109  // build up the top branch that decays hadronically
112  addFourMomenta.set( w );
115  addFourMomenta.set( top );
116 
117  // build ttbar hypotheses
118  hyp.addDaughter( topBar, TtFullHadDaughter::TopBar );
120  addFourMomenta.set( hyp );
121 
122  return hyp;
123 }
const double w
Definition: UKUtility.cc:23
static const std::string LightPBar
static const std::string LightQ
reco::ShallowClonePtrCandidate * lightPBar_
static const std::string Top
static const std::string LightP
reco::ShallowClonePtrCandidate * lightQBar_
static const std::string WMinus
reco::ShallowClonePtrCandidate * lightP_
static const std::string B
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
static const std::string WPlus
static const std::string BBar
static const std::string TopBar
reco::ShallowClonePtrCandidate * bBar_
reco::ShallowClonePtrCandidate * b_
void set(reco::Candidate &c) const
set up a candidate
static const std::string LightQBar
reco::ShallowClonePtrCandidate * lightQ_
bool TtFullHadHypothesis::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprotected

check if index is in valid range of selected jets

Definition at line 55 of file TtFullHadHypothesis.h.

References buildHypo(), buildKey(), and fwrapper::jets.

Referenced by ntupleDataFormat._Object::_checkIsValid(), TtFullHadHypGenMatch::buildHypo(), and core.AutoHandle.AutoHandle::ReallyLoad().

55 { return (0<=idx && idx<(int)jets->size()); };
std::string TtFullHadHypothesis::jetCorrectionLevel ( const std::string &  quarkType)
protected

helper function to construct the proper correction level string for corresponding quarkType

helper function to construct the proper correction level string for corresponding quarkType, for unknown quarkTypes an empty string is returned

Definition at line 127 of file TtFullHadHypothesis.cc.

References jetCorrectionLevel_, hcalDigis_cfi::level, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TtFullHadHypGenMatch::buildHypo().

128 {
129  // jetCorrectionLevel was not configured
130  if(jetCorrectionLevel_.empty())
131  throw cms::Exception("Configuration")
132  << "Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
133 
134  // quarkType is unknown
135  if( !(quarkType=="wQuarkMix" ||
136  quarkType=="udsQuark" ||
137  quarkType=="cQuark" ||
138  quarkType=="bQuark") )
139  throw cms::Exception("Configuration")
140  << quarkType << " is unknown as a quarkType for the jetCorrectionLevel.\n";
141 
142  // combine correction level; start with a ':' even if
143  // there is no flavor tag to be added, as it is needed
144  // by setCandidate to disentangle the correction tag
145  // from a potential flavor tag, which can be empty
147  if( level=="L5Flavor:" || level=="L6UE:" || level=="L7Parton:" ){
148  if(quarkType=="wQuarkMix"){level+="wMix";}
149  if(quarkType=="udsQuark" ){level+="uds";}
150  if(quarkType=="cQuark" ){level+="charm";}
151  if(quarkType=="bQuark" ){level+="bottom";}
152  }
153  else{
154  level+="none";
155  }
156  return level;
157 }
std::string jetCorrectionLevel_
int TtFullHadHypothesis::key ( ) const
inlineprotected

return key

Definition at line 51 of file TtFullHadHypothesis.h.

References hypo(), and key_.

Referenced by produce().

51 { return key_; };
int key_
hypothesis key (to be set by the buildKey function)
void TtFullHadHypothesis::produce ( edm::Event evt,
const edm::EventSetup setup 
)
protectedvirtual

produce the event hypothesis as CompositeCandidate and Key

Definition at line 34 of file TtFullHadHypothesis.cc.

References buildHypo(), buildKey(), edm::Event::getByToken(), getMatch_, hypo(), mps_fire::i, fwrapper::jets, jetsToken_, key(), match(), matchToken_, eostools::move(), edm::Event::put(), and resetCandidates().

35 {
37  evt.getByToken(jetsToken_, jets);
38 
39  std::vector<std::vector<int> > matchVec;
40  if( getMatch_ ) {
42  evt.getByToken(matchToken_, matchHandle);
43  matchVec = *matchHandle;
44  }
45  else {
46  std::vector<int> dummyMatch;
47  for(unsigned int i = 0; i < 4; ++i)
48  dummyMatch.push_back( -1 );
49  matchVec.push_back( dummyMatch );
50  }
51 
52  // declare unique_ptr for products
53  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >
54  pOut( new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > );
55  std::unique_ptr<int> pKey(new int);
56 
57  // go through given vector of jet combinations
58  unsigned int idMatch = 0;
59  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
60  for(MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
61  // reset pointers
63  // build hypothesis
64  buildHypo(evt, jets, *match, idMatch++);
65  pOut->push_back( std::make_pair(hypo(), *match) );
66  }
67  // feed out hyps and matches
68  evt.put(std::move(pOut));
69 
70  // build and feed out key
71  buildKey();
72  *pKey=key();
73  evt.put(std::move(pKey), "Key");
74 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
int key() const
return key
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
vector< PseudoJet > jets
virtual void buildHypo(edm::Event &event, const edm::Handle< std::vector< pat::Jet > > &jets, std::vector< int > &jetPartonAssociation, const unsigned int iComb)=0
build event hypothesis from the reco objects of a full-hadronic event
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
virtual void buildKey()=0
build the event hypothesis key
void resetCandidates()
reset candidate pointers before hypo build process
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
reco::CompositeCandidate hypo()
return event hypothesis
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input label for all necessary collections
def move(src, dest)
Definition: eostools.py:510
void TtFullHadHypothesis::resetCandidates ( )
protected

reset candidate pointers before hypo build process

Definition at line 78 of file TtFullHadHypothesis.cc.

References b_, bBar_, lightP_, lightPBar_, lightQ_, and lightQBar_.

Referenced by produce().

79 {
80  lightQ_ = 0;
81  lightQBar_ = 0;
82  b_ = 0;
83  bBar_ = 0;
84  lightP_ = 0;
85  lightPBar_ = 0;
86 }
reco::ShallowClonePtrCandidate * lightPBar_
reco::ShallowClonePtrCandidate * lightQBar_
reco::ShallowClonePtrCandidate * lightP_
reco::ShallowClonePtrCandidate * bBar_
reco::ShallowClonePtrCandidate * b_
reco::ShallowClonePtrCandidate * lightQ_
template<typename C >
void TtFullHadHypothesis::setCandidate ( const edm::Handle< C > &  handle,
const int &  idx,
reco::ShallowClonePtrCandidate *&  clone 
)
protected

use one object in a collection to set a ShallowClonePtrCandidate

Definition at line 96 of file TtFullHadHypothesis.h.

References cmsBatch::handle, and training_settings::idx.

Referenced by TtFullHadHypGenMatch::buildHypo(), and TtFullHadHypKinFit::buildHypo().

96  {
97  typedef typename C::value_type O;
99  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->p4(), ptr->vertex() );
100 }
void TtFullHadHypothesis::setCandidate ( const edm::Handle< std::vector< pat::Jet > > &  handle,
const int &  idx,
reco::ShallowClonePtrCandidate *&  clone,
const std::string &  correctionLevel 
)
protected

use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections

Definition at line 161 of file TtFullHadHypothesis.cc.

References reco::LeafCandidate::charge(), cmsBatch::handle, training_settings::idx, pat::Jet::jecFactor(), reco::LeafCandidate::p4(), AlCaHLTBitMon_QueryRunRegistry::string, and reco::LeafCandidate::vertex().

163 {
165  // disentangle the correction from the potential flavor tag
166  // by the separating ':'; the flavor tag can be empty though
167  std::string step = correctionLevel.substr(0,correctionLevel.find(":"));
168  std::string flavor = correctionLevel.substr(1+correctionLevel.find(":"));
169  float corrFactor = 1.;
170  if(flavor=="wMix")
171  corrFactor = 0.75*ptr->jecFactor(step, "uds") + 0.25*ptr->jecFactor(step, "charm");
172  else
173  corrFactor = ptr->jecFactor(step, flavor);
174  clone = new reco::ShallowClonePtrCandidate( ptr, ptr->charge(), ptr->p4()*corrFactor, ptr->vertex() );
175 }
virtual const Point & vertex() const
vertex position (overwritten by PF...)
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
step
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99

Member Data Documentation

reco::ShallowClonePtrCandidate* TtFullHadHypothesis::b_
protected
reco::ShallowClonePtrCandidate* TtFullHadHypothesis::bBar_
protected
bool TtFullHadHypothesis::getMatch_
protected

internal check whether the match information exists or not, if false a blind dummy match vector will be used internally

Definition at line 73 of file TtFullHadHypothesis.h.

Referenced by produce(), and TtFullHadHypothesis().

std::string TtFullHadHypothesis::jetCorrectionLevel_
protected

specify the desired jet correction level (the default should be L3Absolute-'abs')

Definition at line 79 of file TtFullHadHypothesis.h.

Referenced by jetCorrectionLevel(), and TtFullHadHypothesis().

edm::EDGetTokenT<std::vector<pat::Jet> > TtFullHadHypothesis::jetsToken_
protected

input label for all necessary collections

Definition at line 75 of file TtFullHadHypothesis.h.

Referenced by produce().

int TtFullHadHypothesis::key_
protected

hypothesis key (to be set by the buildKey function)

Definition at line 81 of file TtFullHadHypothesis.h.

Referenced by TtFullHadHypGenMatch::buildKey(), TtFullHadHypKinFit::buildKey(), and key().

reco::ShallowClonePtrCandidate* TtFullHadHypothesis::lightP_
protected
reco::ShallowClonePtrCandidate* TtFullHadHypothesis::lightPBar_
protected
reco::ShallowClonePtrCandidate* TtFullHadHypothesis::lightQ_
protected

candidates for internal use for the creation of the hypothesis candidate

Definition at line 84 of file TtFullHadHypothesis.h.

Referenced by TtFullHadHypGenMatch::buildHypo(), TtFullHadHypKinFit::buildHypo(), hypo(), resetCandidates(), and ~TtFullHadHypothesis().

reco::ShallowClonePtrCandidate* TtFullHadHypothesis::lightQBar_
protected
edm::EDGetTokenT<std::vector<std::vector<int> > > TtFullHadHypothesis::matchToken_
protected

Definition at line 76 of file TtFullHadHypothesis.h.

Referenced by produce(), and TtFullHadHypothesis().