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 () override
 default destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
 ~EDProducer () 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)
 

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...
 
void produce (edm::Event &, const edm::EventSetup &) override
 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::ProducerBase
ProducesCollector producesCollector ()
 
- 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)
 

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
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::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 

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.

6  : jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))),
7  lightQ_(nullptr),
8  lightQBar_(nullptr),
9  b_(nullptr),
10  bBar_(nullptr),
11  lightP_(nullptr),
12  lightPBar_(nullptr) {
13  getMatch_ = false;
14  if (cfg.exists("match")) {
15  getMatch_ = true;
16  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
17  }
18  if (cfg.exists("jetCorrectionLevel")) {
19  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
20  }
21  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
22  produces<int>("Key");
23 }
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 ( )
override

default destructor

Definition at line 26 of file TtFullHadHypothesis.cc.

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

26  {
27  if (lightQ_)
28  delete lightQ_;
29  if (lightQBar_)
30  delete lightQBar_;
31  if (b_)
32  delete b_;
33  if (bBar_)
34  delete bBar_;
35  if (lightP_)
36  delete lightP_;
37  if (lightPBar_)
38  delete lightPBar_;
39 }
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 93 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(), TtFullHadDaughter::Top, TtFullHadDaughter::TopBar, w, TtFullHadDaughter::WMinus, and TtFullHadDaughter::WPlus.

Referenced by key(), and produce().

93  {
94  // check for sanity of the hypothesis
95  if (!lightQ_ || !lightQBar_ || !b_ || !bBar_ || !lightP_ || !lightPBar_)
96  return reco::CompositeCandidate();
97 
98  // setup transient references
99  reco::CompositeCandidate hyp, top, w, topBar, wBar;
100 
101  AddFourMomenta addFourMomenta;
102  // build up the top bar branch
105  addFourMomenta.set(wBar);
108  addFourMomenta.set(topBar);
109 
110  // build up the top branch that decays hadronically
113  addFourMomenta.set(w);
116  addFourMomenta.set(top);
117 
118  // build ttbar hypotheses
121  addFourMomenta.set(hyp);
122 
123  return hyp;
124 }
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 57 of file TtFullHadHypothesis.h.

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

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

57  {
58  return (0 <= idx && idx < (int)jets->size());
59  };
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_, personalPlayback::level, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TtFullHadHypGenMatch::buildHypo().

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

return key

Definition at line 53 of file TtFullHadHypothesis.h.

References hypo(), and key_.

Referenced by produce().

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

produce the event hypothesis as CompositeCandidate and Key

Definition at line 42 of file TtFullHadHypothesis.cc.

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

42  {
44  evt.getByToken(jetsToken_, jets);
45 
46  std::vector<std::vector<int> > matchVec;
47  if (getMatch_) {
49  evt.getByToken(matchToken_, matchHandle);
50  matchVec = *matchHandle;
51  } else {
52  std::vector<int> dummyMatch;
53  for (unsigned int i = 0; i < 4; ++i)
54  dummyMatch.push_back(-1);
55  matchVec.push_back(dummyMatch);
56  }
57 
58  // declare unique_ptr for products
59  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > > pOut(
60  new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > >);
61  std::unique_ptr<int> pKey(new int);
62 
63  // go through given vector of jet combinations
64  unsigned int idMatch = 0;
65  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
66  for (MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
67  // reset pointers
69  // build hypothesis
70  buildHypo(evt, jets, *match, idMatch++);
71  pOut->push_back(std::make_pair(hypo(), *match));
72  }
73  // feed out hyps and matches
74  evt.put(std::move(pOut));
75 
76  // build and feed out key
77  buildKey();
78  *pKey = key();
79  evt.put(std::move(pKey), "Key");
80 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
int key() const
return key
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
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:511
void TtFullHadHypothesis::resetCandidates ( )
protected

reset candidate pointers before hypo build process

Definition at line 83 of file TtFullHadHypothesis.cc.

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

Referenced by produce().

83  {
84  lightQ_ = nullptr;
85  lightQBar_ = nullptr;
86  b_ = nullptr;
87  bBar_ = nullptr;
88  lightP_ = nullptr;
89  lightPBar_ = nullptr;
90 }
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 99 of file TtFullHadHypothesis.h.

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

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

101  {
102  typedef typename C::value_type O;
104  clone = new reco::ShallowClonePtrCandidate(ptr, ptr->charge(), ptr->p4(), ptr->vertex());
105 }
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 162 of file TtFullHadHypothesis.cc.

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

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

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 77 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 83 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 79 of file TtFullHadHypothesis.h.

Referenced by produce().

int TtFullHadHypothesis::key_
protected

hypothesis key (to be set by the buildKey function)

Definition at line 85 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 88 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 80 of file TtFullHadHypothesis.h.

Referenced by produce(), and TtFullHadHypothesis().