CMS 3D CMS Logo

TtFullHadHypothesis.cc
Go to the documentation of this file.
3 
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 }
24 
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 }
40 
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 }
81 
84  lightQ_ = nullptr;
85  lightQBar_ = nullptr;
86  b_ = nullptr;
87  bBar_ = nullptr;
88  lightP_ = nullptr;
89  lightPBar_ = nullptr;
90 }
91 
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
111  w.addDaughter(*lightQ_, TtFullHadDaughter::LightQ);
113  addFourMomenta.set(w);
116  addFourMomenta.set(top);
117 
118  // build ttbar hypotheses
121  addFourMomenta.set(hyp);
122 
123  return hyp;
124 }
125 
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 }
160 
162 void TtFullHadHypothesis::setCandidate(const edm::Handle<std::vector<pat::Jet> >& handle,
163  const int& idx,
165  const std::string& correctionLevel) {
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 }
personalPlayback.level
level
Definition: personalPlayback.py:22
mps_fire.i
i
Definition: mps_fire.py:355
TtFullHadHypothesis::lightP_
reco::ShallowClonePtrCandidate * lightP_
Definition: TtFullHadHypothesis.h:92
step
step
Definition: StallMonitor.cc:94
patZpeak.handle
handle
Definition: patZpeak.py:23
edm
HLT enums.
Definition: AlignableModifier.h:19
TtFullHadHypothesis::buildKey
virtual void buildKey()=0
build the event hypothesis key
TtFullHadHypothesis::jetsToken_
edm::EDGetTokenT< std::vector< pat::Jet > > jetsToken_
input label for all necessary collections
Definition: TtFullHadHypothesis.h:79
TtFullHadHypothesis::setCandidate
void setCandidate(const edm::Handle< C > &handle, const int &idx, reco::ShallowClonePtrCandidate *&clone)
use one object in a collection to set a ShallowClonePtrCandidate
Definition: TtFullHadHypothesis.h:99
TtFullHadDaughter::WMinus
static const std::string WMinus
Definition: TtFullHadronicEvent.h:10
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
TtFullHadHypothesis::buildHypo
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
TtFullHadHypothesis::bBar_
reco::ShallowClonePtrCandidate * bBar_
Definition: TtFullHadHypothesis.h:91
edm::Handle
Definition: AssociativeIterator.h:50
training_settings.idx
idx
Definition: training_settings.py:16
TtFullHadHypothesis::lightPBar_
reco::ShallowClonePtrCandidate * lightPBar_
Definition: TtFullHadHypothesis.h:93
TtFullHadHypothesis::produce
void produce(edm::Event &, const edm::EventSetup &) override
produce the event hypothesis as CompositeCandidate and Key
Definition: TtFullHadHypothesis.cc:42
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
TtFullHadHypothesis::b_
reco::ShallowClonePtrCandidate * b_
Definition: TtFullHadHypothesis.h:90
Jet
Definition: Jet.py:1
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
w
const double w
Definition: UKUtility.cc:23
TtFullHadDaughter::LightQ
static const std::string LightQ
Definition: TtFullHadronicEvent.h:9
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:528
TtFullHadDaughter::Top
static const std::string Top
Definition: TtFullHadronicEvent.h:9
reco::CompositeCandidate::addDaughter
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
Definition: CompositeCandidate.cc:108
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
TtFullHadHypothesis::TtFullHadHypothesis
TtFullHadHypothesis(const edm::ParameterSet &cfg)
default constructor
Definition: TtFullHadHypothesis.cc:5
TtFullHadHypothesis::hypo
reco::CompositeCandidate hypo()
return event hypothesis
Definition: TtFullHadHypothesis.cc:93
TtFullHadDaughter::LightP
static const std::string LightP
Definition: TtFullHadronicEvent.h:9
TtFullHadDaughter::WPlus
static const std::string WPlus
Definition: TtFullHadronicEvent.h:9
match
std::pair< typename Association::data_type::first_type, double > match(Reference key, Association association, bool bestMatchByMaxValue)
Generic matching function.
Definition: Utils.h:10
AddFourMomenta.h
reco::LeafCandidate::p4
const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:114
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:132
TtFullHadDaughter::BBar
static const std::string BBar
Definition: TtFullHadronicEvent.h:10
reco::LeafCandidate::charge
int charge() const final
electric charge
Definition: LeafCandidate.h:106
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
TtFullHadHypothesis::~TtFullHadHypothesis
~TtFullHadHypothesis() override
default destructor
Definition: TtFullHadHypothesis.cc:26
reco::LeafCandidate::vertex
const Point & vertex() const override
vertex position (overwritten by PF...)
Definition: LeafCandidate.h:165
TtFullHadHypothesis::getMatch_
bool getMatch_
Definition: TtFullHadHypothesis.h:77
edm::Ptr< pat::Jet >
looper.cfg
cfg
Definition: looper.py:297
TtFullHadHypothesis::key
int key() const
return key
Definition: TtFullHadHypothesis.h:53
TtFullHadDaughter::B
static const std::string B
Definition: TtFullHadronicEvent.h:9
TtFullHadHypothesis::matchToken_
edm::EDGetTokenT< std::vector< std::vector< int > > > matchToken_
Definition: TtFullHadHypothesis.h:80
TtFullHadDaughter::TopBar
static const std::string TopBar
Definition: TtFullHadronicEvent.h:11
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
TtFullHadHypothesis.h
AddFourMomenta::set
void set(reco::Candidate &c) const
set up a candidate
Definition: AddFourMomenta.cc:6
TtFullHadHypothesis::lightQ_
reco::ShallowClonePtrCandidate * lightQ_
Definition: TtFullHadHypothesis.h:88
cms::Exception
Definition: Exception.h:70
AddFourMomenta
Definition: AddFourMomenta.h:18
TtFullHadHypothesis::resetCandidates
void resetCandidates()
reset candidate pointers before hypo build process
Definition: TtFullHadHypothesis.cc:83
reco::ShallowClonePtrCandidate
Definition: ShallowClonePtrCandidate.h:15
TtFullHadHypothesis::jetCorrectionLevel
std::string jetCorrectionLevel(const std::string &quarkType)
helper function to construct the proper correction level string for corresponding quarkType
Definition: TtFullHadHypothesis.cc:127
edm::Event
Definition: Event.h:73
TtFullHadDaughter::LightQBar
static const std::string LightQBar
Definition: TtFullHadronicEvent.h:10
TtFullHadHypothesis::jetCorrectionLevel_
std::string jetCorrectionLevel_
Definition: TtFullHadHypothesis.h:83
edm::InputTag
Definition: InputTag.h:15
pat::Jet::jecFactor
float jecFactor(const std::string &level, const std::string &flavor="none", const std::string &set="") const
TtFullHadDaughter::LightPBar
static const std::string LightPBar
Definition: TtFullHadronicEvent.h:10
reco::CompositeCandidate
Definition: CompositeCandidate.h:21
TtFullHadHypothesis::lightQBar_
reco::ShallowClonePtrCandidate * lightQBar_
Definition: TtFullHadHypothesis.h:89