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::stream::EDProducer<> TtFullHadHypGenMatch TtFullHadHypKinFit

Public Member Functions

 TtFullHadHypothesis (const edm::ParameterSet &cfg)
 default constructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 

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...
 
template<typename C >
std::unique_ptr< reco::ShallowClonePtrCandidatemakeCandidate (const edm::Handle< C > &handle, const int &idx)
 use one object in a collection to set a ShallowClonePtrCandidate More...
 
std::unique_ptr< reco::ShallowClonePtrCandidatemakeCandidate (const edm::Handle< std::vector< pat::Jet > > &handle, const int &idx, const std::string &correctionLevel)
 use one object in a jet collection to set a ShallowClonePtrCandidate with proper jet corrections 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...
 

Protected Attributes

std::unique_ptr< reco::ShallowClonePtrCandidateb_
 
std::unique_ptr< 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...
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightP_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightPBar_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightQ_
 
std::unique_ptr< reco::ShallowClonePtrCandidatelightQBar_
 
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDProducer<>
using CacheTypes = CacheContexts< T... >
 
using GlobalCache = typename CacheTypes::GlobalCache
 
using HasAbility = AbilityChecker< T... >
 
using InputProcessBlockCache = typename CacheTypes::InputProcessBlockCache
 
using LuminosityBlockCache = typename CacheTypes::LuminosityBlockCache
 
using LuminosityBlockContext = LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCache >
 
using LuminosityBlockSummaryCache = typename CacheTypes::LuminosityBlockSummaryCache
 
using RunCache = typename CacheTypes::RunCache
 
using RunContext = RunContextT< RunCache, GlobalCache >
 
using RunSummaryCache = typename CacheTypes::RunSummaryCache
 

Detailed Description

Definition at line 29 of file TtFullHadHypothesis.h.

Constructor & Destructor Documentation

◆ TtFullHadHypothesis()

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

default constructor

Definition at line 5 of file TtFullHadHypothesis.cc.

References looper::cfg, getMatch_, jetCorrectionLevel_, matchToken_, and AlCaHLTBitMon_QueryRunRegistry::string.

6  : jetsToken_(consumes<std::vector<pat::Jet> >(cfg.getParameter<edm::InputTag>("jets"))) {
7  getMatch_ = false;
8  if (cfg.exists("match")) {
9  getMatch_ = true;
10  matchToken_ = consumes<std::vector<std::vector<int> > >(cfg.getParameter<edm::InputTag>("match"));
11  }
12  if (cfg.exists("jetCorrectionLevel")) {
13  jetCorrectionLevel_ = cfg.getParameter<std::string>("jetCorrectionLevel");
14  }
15  produces<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > >();
16  produces<int>("Key");
17 }
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
std::string jetCorrectionLevel_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input label for all necessary collections

Member Function Documentation

◆ buildHypo()

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 TtFullHadHypGenMatch, and TtFullHadHypKinFit.

Referenced by produce().

◆ buildKey()

virtual void TtFullHadHypothesis::buildKey ( )
protectedpure virtual

build the event hypothesis key

Implemented in TtFullHadHypGenMatch, and TtFullHadHypKinFit.

Referenced by produce().

◆ hypo()

reco::CompositeCandidate TtFullHadHypothesis::hypo ( )
protected

return event hypothesis

Definition at line 71 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_, eostools::move(), AddFourMomenta::set(), TtFullHadDaughter::Top, TtFullHadDaughter::TopBar, w(), TtFullHadDaughter::WMinus, and TtFullHadDaughter::WPlus.

Referenced by produce().

71  {
72  // check for sanity of the hypothesis
73  if (!lightQ_ || !lightQBar_ || !b_ || !bBar_ || !lightP_ || !lightPBar_)
74  return reco::CompositeCandidate();
75 
76  // setup transient references
77  reco::CompositeCandidate hyp, top, w, topBar, wBar;
78 
79  AddFourMomenta addFourMomenta;
80  // build up the top bar branch
83  addFourMomenta.set(wBar);
86  addFourMomenta.set(topBar);
87 
88  // build up the top branch that decays hadronically
91  addFourMomenta.set(w);
94  addFourMomenta.set(top);
95 
96  // build ttbar hypotheses
99  addFourMomenta.set(hyp);
100 
101  return hyp;
102 }
void set(reco::Candidate &c) const
set up a candidate
T w() const
static const std::string LightPBar
static const std::string LightQ
std::unique_ptr< reco::ShallowClonePtrCandidate > b_
static const std::string Top
std::unique_ptr< reco::ShallowClonePtrCandidate > lightP_
static const std::string LightP
static const std::string WMinus
static const std::string B
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQ_
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
static const std::string WPlus
std::unique_ptr< reco::ShallowClonePtrCandidate > lightPBar_
static const std::string BBar
static const std::string TopBar
static const std::string LightQBar
def move(src, dest)
Definition: eostools.py:511
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQBar_

◆ isValid()

bool TtFullHadHypothesis::isValid ( const int &  idx,
const edm::Handle< std::vector< pat::Jet > > &  jets 
)
inlineprotected

◆ jetCorrectionLevel()

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 105 of file TtFullHadHypothesis.cc.

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

Referenced by TtFullHadHypGenMatch::buildHypo().

105  {
106  // jetCorrectionLevel was not configured
107  if (jetCorrectionLevel_.empty())
108  throw cms::Exception("Configuration")
109  << "Unconfigured jetCorrectionLevel. Please use an appropriate, non-empty string.\n";
110 
111  // quarkType is unknown
112  if (!(quarkType == "wQuarkMix" || quarkType == "udsQuark" || quarkType == "cQuark" || quarkType == "bQuark"))
113  throw cms::Exception("Configuration") << quarkType << " is unknown as a quarkType for the jetCorrectionLevel.\n";
114 
115  // combine correction level; start with a ':' even if
116  // there is no flavor tag to be added, as it is needed
117  // by makeCandidate to disentangle the correction tag
118  // from a potential flavor tag, which can be empty
120  if (level == "L5Flavor:" || level == "L6UE:" || level == "L7Parton:") {
121  if (quarkType == "wQuarkMix") {
122  level += "wMix";
123  }
124  if (quarkType == "udsQuark") {
125  level += "uds";
126  }
127  if (quarkType == "cQuark") {
128  level += "charm";
129  }
130  if (quarkType == "bQuark") {
131  level += "bottom";
132  }
133  } else {
134  level += "none";
135  }
136  return level;
137 }
std::string jetCorrectionLevel_

◆ key()

int TtFullHadHypothesis::key ( ) const
inlineprotected

return key

Definition at line 50 of file TtFullHadHypothesis.h.

References key_.

Referenced by produce().

50 { return key_; };
int key_
hypothesis key (to be set by the buildKey function)

◆ makeCandidate() [1/2]

template<typename C >
std::unique_ptr< reco::ShallowClonePtrCandidate > TtFullHadHypothesis::makeCandidate ( const edm::Handle< C > &  handle,
const int &  idx 
)
protected

use one object in a collection to set a ShallowClonePtrCandidate

Definition at line 96 of file TtFullHadHypothesis.h.

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

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

97  {
98  typedef typename C::value_type O;
100  return std::make_unique<reco::ShallowClonePtrCandidate>(ptr, ptr->charge(), ptr->p4(), ptr->vertex());
101 }

◆ makeCandidate() [2/2]

std::unique_ptr< reco::ShallowClonePtrCandidate > TtFullHadHypothesis::makeCandidate ( const edm::Handle< std::vector< pat::Jet > > &  handle,
const int &  idx,
const std::string &  correctionLevel 
)
protected

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

Definition at line 140 of file TtFullHadHypothesis.cc.

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

141  {
143  // disentangle the correction from the potential flavor tag
144  // by the separating ':'; the flavor tag can be empty though
145  std::string step = correctionLevel.substr(0, correctionLevel.find(':'));
146  std::string flavor = correctionLevel.substr(1 + correctionLevel.find(':'));
147  float corrFactor = 1.;
148  if (flavor == "wMix")
149  corrFactor = 0.75 * ptr->jecFactor(step, "uds") + 0.25 * ptr->jecFactor(step, "charm");
150  else
151  corrFactor = ptr->jecFactor(step, flavor);
152  return std::make_unique<reco::ShallowClonePtrCandidate>(ptr, ptr->charge(), ptr->p4() * corrFactor, ptr->vertex());
153 }
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
step
Definition: StallMonitor.cc:98
int charge() const final
electric charge

◆ produce()

void TtFullHadHypothesis::produce ( edm::Event evt,
const edm::EventSetup setup 
)
overrideprotected

produce the event hypothesis as CompositeCandidate and Key

Definition at line 20 of file TtFullHadHypothesis.cc.

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

20  {
23 
24  std::vector<std::vector<int> > matchVec;
25  if (getMatch_) {
27  evt.getByToken(matchToken_, matchHandle);
28  matchVec = *matchHandle;
29  } else {
30  std::vector<int> dummyMatch;
31  for (unsigned int i = 0; i < 4; ++i)
32  dummyMatch.push_back(-1);
33  matchVec.push_back(dummyMatch);
34  }
35 
36  // declare unique_ptr for products
37  std::unique_ptr<std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > > > pOut(
38  new std::vector<std::pair<reco::CompositeCandidate, std::vector<int> > >);
39  std::unique_ptr<int> pKey(new int);
40 
41  // go through given vector of jet combinations
42  unsigned int idMatch = 0;
43  typedef std::vector<std::vector<int> >::iterator MatchVecIterator;
44  for (MatchVecIterator match = matchVec.begin(); match != matchVec.end(); ++match) {
45  // reset pointers
47  // build hypothesis
48  buildHypo(evt, jets, *match, idMatch++);
49  pOut->push_back(std::make_pair(hypo(), *match));
50  }
51  // feed out hyps and matches
52  evt.put(std::move(pOut));
53 
54  // build and feed out key
55  buildKey();
56  *pKey = key();
57  evt.put(std::move(pKey), "Key");
58 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
int key() const
return key
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

◆ resetCandidates()

void TtFullHadHypothesis::resetCandidates ( )
protected

reset candidate pointers before hypo build process

Definition at line 61 of file TtFullHadHypothesis.cc.

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

Referenced by produce().

61  {
62  lightQ_.reset();
63  lightQBar_.reset();
64  b_.reset();
65  bBar_.reset();
66  lightP_.reset();
67  lightPBar_.reset();
68 }
std::unique_ptr< reco::ShallowClonePtrCandidate > b_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightP_
std::unique_ptr< reco::ShallowClonePtrCandidate > bBar_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQ_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightPBar_
std::unique_ptr< reco::ShallowClonePtrCandidate > lightQBar_

Member Data Documentation

◆ b_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::b_
protected

◆ bBar_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::bBar_
protected

◆ getMatch_

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 74 of file TtFullHadHypothesis.h.

Referenced by produce(), and TtFullHadHypothesis().

◆ jetCorrectionLevel_

std::string TtFullHadHypothesis::jetCorrectionLevel_
protected

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

Definition at line 80 of file TtFullHadHypothesis.h.

Referenced by jetCorrectionLevel(), and TtFullHadHypothesis().

◆ jetsToken_

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

input label for all necessary collections

Definition at line 76 of file TtFullHadHypothesis.h.

Referenced by produce().

◆ key_

int TtFullHadHypothesis::key_
protected

hypothesis key (to be set by the buildKey function)

Definition at line 82 of file TtFullHadHypothesis.h.

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

◆ lightP_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::lightP_
protected

◆ lightPBar_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::lightPBar_
protected

◆ lightQ_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::lightQ_
protected

candidates for internal use for the creation of the hypothesis candidate

Definition at line 85 of file TtFullHadHypothesis.h.

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

◆ lightQBar_

std::unique_ptr<reco::ShallowClonePtrCandidate> TtFullHadHypothesis::lightQBar_
protected

◆ matchToken_

edm::EDGetTokenT<std::vector<std::vector<int> > > TtFullHadHypothesis::matchToken_
protected

Definition at line 77 of file TtFullHadHypothesis.h.

Referenced by produce(), and TtFullHadHypothesis().