CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TtSemiEvtSolution.cc
Go to the documentation of this file.
1 //
2 //
3 
8 
10  : mcHyp_("ttSemiEvtMCHyp"), recoHyp_("ttSemiEvtRecoHyp"), fitHyp_("ttSemiEvtFitHyp") {
11  jetCorrScheme_ = 0;
12  sumAnglejp_ = -999.;
13  angleHadp_ = -999.;
14  angleHadq_ = -999.;
15  angleHadb_ = -999.;
16  angleLepb_ = -999.;
17  changeWQ_ = -999;
18  probChi2_ = -999.;
19  mcBestJetComb_ = -999;
20  simpleBestJetComb_ = -999;
21  lrBestJetComb_ = -999;
22  lrJetCombLRval_ = -999.;
23  lrJetCombProb_ = -999.;
24  lrSignalEvtLRval_ = -999.;
25  lrSignalEvtProb_ = -999.;
26 }
27 
29 
30 //-------------------------------------------
31 // get calibrated base objects
32 //-------------------------------------------
34  // WARNING this is obsolete and only
35  // kept for backwards compatibility
36  if (jetCorrScheme_ == 1)
37  return hadb_->correctedJet("HAD", "B"); // calibrate jets according to MC truth
38  else if (jetCorrScheme_ == 2)
39  return hadb_->correctedJet("HAD", "B");
40  else
41  return *hadb_;
42 }
43 
45  // WARNING this is obsolete and only
46  // kept for backwards compatibility
47  if (jetCorrScheme_ == 1)
48  return hadp_->correctedJet("HAD", "UDS"); // calibrate jets according to MC truth
49  else if (jetCorrScheme_ == 2)
50  return hadp_->correctedJet("HAD", "UDS");
51  else
52  return *hadp_;
53 }
54 
56  // WARNING this is obsolete and only
57  // kept for backwards compatibility
58  if (jetCorrScheme_ == 1)
59  return hadq_->correctedJet("HAD", "UDS"); // calibrate jets according to MC truth
60  else if (jetCorrScheme_ == 2)
61  return hadq_->correctedJet("HAD", "UDS");
62  else
63  return *hadq_;
64 }
65 
67  // WARNING this is obsolete and only
68  // kept for backwards compatibility
69  if (jetCorrScheme_ == 1)
70  return lepb_->correctedJet("HAD", "B"); // calibrate jets according to MC truth
71  else if (jetCorrScheme_ == 2)
72  return lepb_->correctedJet("HAD", "B");
73  else
74  return *lepb_;
75 }
76 
77 //-------------------------------------------
78 // get (un-)/calibrated reco objects
79 //-------------------------------------------
81  // FIXME: the charge from the genevent
82  return reco::Particle(0, this->getRecHadp().p4() + this->getRecHadq().p4() + this->getRecHadb().p4());
83 }
84 
86  // FIXME: the charge from the genevent
87  return reco::Particle(0, this->getRecHadp().p4() + this->getRecHadq().p4());
88 }
89 
91  // FIXME: the charge from the genevent
93  if (this->getDecay() == "muon")
94  p = reco::Particle(0, this->getRecLepm().p4() + this->getRecLepn().p4() + this->getRecLepb().p4());
95  if (this->getDecay() == "electron")
96  p = reco::Particle(0, this->getRecLepe().p4() + this->getRecLepn().p4() + this->getRecLepb().p4());
97  return p;
98 }
99 
101  // FIXME: the charge from the genevent
103  if (this->getDecay() == "muon")
104  p = reco::Particle(0, this->getRecLepm().p4() + this->getRecLepn().p4());
105  if (this->getDecay() == "electron")
106  p = reco::Particle(0, this->getRecLepe().p4() + this->getRecLepn().p4());
107  return p;
108 }
109 
110 // FIXME: Why these functions??? Not needed!
111 // methods to get calibrated objects
113  return reco::Particle(0, this->getCalHadp().p4() + this->getCalHadq().p4() + this->getCalHadb().p4());
114 }
115 
117  return reco::Particle(0, this->getCalHadp().p4() + this->getCalHadq().p4());
118 }
119 
122  if (this->getDecay() == "muon")
123  p = reco::Particle(0, this->getRecLepm().p4() + this->getRecLepn().p4() + this->getCalLepb().p4());
124  if (this->getDecay() == "electron")
125  p = reco::Particle(0, this->getRecLepe().p4() + this->getRecLepn().p4() + this->getCalLepb().p4());
126  return p;
127 }
128 
131  if (this->getDecay() == "muon")
132  p = reco::Particle(0, this->getRecLepm().p4() + this->getRecLepn().p4());
133  if (this->getDecay() == "electron")
134  p = reco::Particle(0, this->getRecLepe().p4() + this->getRecLepn().p4());
135  return p;
136 }
137 
138 //-------------------------------------------
139 // get objects from kinematic fit
140 //-------------------------------------------
142  // FIXME: provide the correct charge from generated event
143  return reco::Particle(0, this->getFitHadp().p4() + this->getFitHadq().p4() + this->getFitHadb().p4());
144 }
145 
147  // FIXME: provide the correct charge from generated event
148  return reco::Particle(0, this->getFitHadp().p4() + this->getFitHadq().p4());
149 }
150 
152  // FIXME: provide the correct charge from generated event
153  return reco::Particle(0, this->getFitLepl().p4() + this->getFitLepn().p4() + this->getFitLepb().p4());
154 }
155 
157  // FIXME: provide the correct charge from generated event
158  return reco::Particle(0, this->getFitLepl().p4() + this->getFitLepn().p4());
159 }
160 
161 //-------------------------------------------
162 // get info on the outcome of the signal
163 // selection LR
164 //-------------------------------------------
165 double TtSemiEvtSolution::getLRSignalEvtObsVal(unsigned int selObs) const {
166  double val = -999.;
167  for (size_t o = 0; o < lrSignalEvtVarVal_.size(); o++) {
168  if (lrSignalEvtVarVal_[o].first == selObs)
169  val = lrSignalEvtVarVal_[o].second;
170  }
171  return val;
172 }
173 
174 //-------------------------------------------
175 // get info on the outcome of the different
176 // jet combination methods
177 //-------------------------------------------
178 double TtSemiEvtSolution::getLRJetCombObsVal(unsigned int selObs) const {
179  double val = -999.;
180  for (size_t o = 0; o < lrJetCombVarVal_.size(); o++) {
181  if (lrJetCombVarVal_[o].first == selObs)
182  val = lrJetCombVarVal_[o].second;
183  }
184  return val;
185 }
186 
187 //-------------------------------------------
188 // set the generated event
189 //-------------------------------------------
191  if (!aGenEvt->isSemiLeptonic()) {
192  edm::LogWarning("TtGenEventNotFilled") << "genEvt is not semi-leptonic; TtGenEvent is not filled";
193  return;
194  }
196 }
197 
198 //-------------------------------------------
199 // set the outcome of the different jet
200 // combination methods
201 //-------------------------------------------
202 void TtSemiEvtSolution::setLRJetCombObservables(const std::vector<std::pair<unsigned int, double> >& varval) {
203  lrJetCombVarVal_.clear();
204  for (size_t ijc = 0; ijc < varval.size(); ijc++)
205  lrJetCombVarVal_.push_back(varval[ijc]);
206 }
207 
208 //-------------------------------------------
209 // set the outcome of the signal selection LR
210 //-------------------------------------------
211 void TtSemiEvtSolution::setLRSignalEvtObservables(const std::vector<std::pair<unsigned int, double> >& varval) {
212  lrSignalEvtVarVal_.clear();
213  for (size_t ise = 0; ise < varval.size(); ise++)
214  lrSignalEvtVarVal_.push_back(varval[ise]);
215 }
216 
218  AddFourMomenta addFourMomenta;
219 
222 
223  // Setup transient references
224  reco::CompositeCandidate recHadt;
225  reco::CompositeCandidate recLept;
226  reco::CompositeCandidate recHadW;
227  reco::CompositeCandidate recLepW;
228 
229  // Get refs to leaf nodes
230  reco::ShallowClonePtrCandidate hadp(hadp_, hadp_->charge(), hadp_->p4(), hadp_->vertex());
231  reco::ShallowClonePtrCandidate hadq(hadq_, hadq_->charge(), hadq_->p4(), hadq_->vertex());
232  reco::ShallowClonePtrCandidate hadb(hadb_, hadb_->charge(), hadb_->p4(), hadb_->vertex());
233  reco::ShallowClonePtrCandidate lepb(lepb_, lepb_->charge(), lepb_->p4(), lepb_->vertex());
234 
235  reco::ShallowClonePtrCandidate neutrino(neutrino_, neutrino_->charge(), neutrino_->p4(), neutrino_->vertex());
236 
237  // JetCandRef hadp( hadp_->p4(), hadp_->charge(), hadp_->vertex()); hadp.setRef( hadp_ );
238  // JetCandRef hadq( hadq_->p4(), hadq_->charge(), hadq_->vertex()); hadq.setRef( hadq_ );
239  // JetCandRef hadb( hadb_->p4(), hadb_->charge(), hadb_->vertex()); hadb.setRef( hadb_ );
240  // JetCandRef lepb( lepb_->p4(), lepb_->charge(), lepb_->vertex()); lepb.setRef( lepb_ );
241 
242  // METCandRef neutrino ( neutrino_->p4(), neutrino_->charge(), neutrino_->vertex() ); neutrino.setRef( neutrino_ );
243 
244  recHadW.addDaughter(hadp, "hadp");
245  recHadW.addDaughter(hadq, "hadq");
246 
247  addFourMomenta.set(recHadW);
248 
249  recHadt.addDaughter(hadb, "hadb");
250  recHadt.addDaughter(recHadW, "hadW");
251 
252  addFourMomenta.set(recHadt);
253 
254  recLepW.addDaughter(neutrino, "neutrino");
255  if (getDecay() == "electron") {
257  // ElectronCandRef electron ( electron_->p4(), electron_->charge(), electron_->vertex() ); electron.setRef( electron_ );
258  recLepW.addDaughter(electron, "electron");
259  } else if (getDecay() == "muon") {
260  reco::ShallowClonePtrCandidate muon(muon_, muon_->charge(), muon_->p4(), muon_->vertex());
261  // MuonCandRef muon ( muon_->p4(), muon_->charge(), muon_->vertex() ); muon.setRef( muon_ );
262  recLepW.addDaughter(muon, "muon");
263  }
264 
265  addFourMomenta.set(recLepW);
266 
267  recLept.addDaughter(lepb, "lepb");
268  recLept.addDaughter(recLepW, "lepW");
269 
270  addFourMomenta.set(recLept);
271 
272  recoHyp_.addDaughter(recHadt, "hadt");
273  recoHyp_.addDaughter(recLept, "lept");
274 
275  addFourMomenta.set(recoHyp_);
276 
277  // // Setup transient references
278  // reco::CompositeCandidate fitHadt;
279  // reco::CompositeCandidate fitLept;
280  // reco::CompositeCandidate fitHadW;
281  // reco::CompositeCandidate fitLepW;
282 
283  // // Get refs to leaf nodes
284  // pat::Particle afitHadp = getFitHadp();
285  // pat::Particle afitHadq = getFitHadq();
286  // pat::Particle afitHadb = getFitHadb();
287  // pat::Particle afitLepb = getFitLepb();
288  // reco::ShallowClonePtrCandidate fitHadp( hadp_, afitHadp.charge(), afitHadp.p4(), afitHadp.vertex());
289  // reco::ShallowClonePtrCandidate fitHadq( hadq_, afitHadq.charge(), afitHadq.p4(), afitHadq.vertex());
290  // reco::ShallowClonePtrCandidate fitHadb( hadb_, afitHadb.charge(), afitHadb.p4(), afitHadb.vertex());
291  // reco::ShallowClonePtrCandidate fitLepb( lepb_, afitLepb.charge(), afitLepb.p4(), afitLepb.vertex());
292 
293  // reco::ShallowClonePtrCandidate fitNeutrino ( neutrino_, fitLepn_.charge(), fitLepn_.p4(), fitLepn_.vertex() );
294 
295  // fitHadW.addDaughter( fitHadp, "hadp" );
296  // fitHadW.addDaughter( fitHadq, "hadq" );
297  // fitHadt.addDaughter( fitHadb, "hadb" );
298  // fitHadt.addDaughter( fitHadW, "hadW" );
299 
300  // fitLepW.addDaughter( fitNeutrino,"neutrino" );
301 
302  // if ( getDecay() == "electron" ) {
303  // reco::ShallowClonePtrCandidate fitElectron ( electron_, electron_.charge(), electron_.p4(), electron_.vertex() );
304  // fitLepW.addDaughter ( fitElectron, "electron" );
305  // } else if ( getDecay() == "muon" ) {
306  // reco::ShallowClonePtrCandidate fitMuon ( muon_, muon_.charge(), muon_.p4(), muon_.vertex() );
307  // fitLepW.addDaughter ( fitMuon, "muon" );
308  // }
309  // fitLept.addDaughter( fitLepb, "lepb" );
310  // fitLept.addDaughter( fitLepW, "lepW" );
311 
312  // fitHyp_.addDaughter( fitHadt, "hadt" );
313  // fitHyp_.addDaughter( fitLept, "lept" );
314 }
reco::Particle getCalHadW() const
pat::Jet getLepb() const
pat::Jet getRecLepb() const
void setLRSignalEvtObservables(const std::vector< std::pair< unsigned int, double > > &varval)
reco::Particle getRecLept() const
pat::Jet getHadq() const
pat::Jet getCalHadq() const
std::vector< std::pair< unsigned int, double > > lrJetCombVarVal_
pat::Particle getFitLepn() const
void setGenEvt(const edm::Handle< TtGenEvent > &aGenEvt)
pat::Particle getFitHadq() const
double getLRSignalEvtObsVal(unsigned int) const
reco::Particle getFitHadt() const
std::string getDecay() const
reco::Particle getRecHadW() const
pat::Jet getHadb() const
reco::Particle getRecHadt() const
edm::Ptr< pat::Jet > hadb_
pat::Electron getRecLepe() const
pat::Particle getFitHadp() const
reco::Particle getFitLepW() const
double getLRJetCombObsVal(unsigned int) const
edm::Ptr< pat::Jet > hadp_
std::vector< std::pair< unsigned int, double > > lrSignalEvtVarVal_
pat::Jet getRecHadp() const
pat::Jet getHadp() const
reco::Particle getCalLept() const
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
pat::Jet getRecHadb() const
reco::Particle getFitHadW() const
void setLRJetCombObservables(const std::vector< std::pair< unsigned int, double > > &varval)
pat::Jet getCalHadb() const
edm::Ptr< pat::Muon > muon_
edm::Ptr< pat::Electron > electron_
reco::CompositeCandidate recoHyp_
void clearDaughters()
clear daughters
edm::RefProd< TtGenEvent > theGenEvt_
edm::Ptr< pat::Jet > lepb_
pat::Particle getFitLepb() const
edm::Ptr< pat::MET > neutrino_
pat::Particle getFitHadb() const
pat::Jet getRecHadq() const
Analysis-level calorimeter jet class.
Definition: Jet.h:77
pat::Particle getFitLepl() const
pat::Muon getRecLepm() const
pat::Jet getCalLepb() const
edm::Ptr< pat::Jet > hadq_
void set(reco::Candidate &c) const
set up a candidate
pat::MET getRecLepn() const
Log< level::Warning, false > LogWarning
reco::Particle getCalHadt() const
virtual ~TtSemiEvtSolution()
reco::Particle getRecLepW() const
reco::Particle getCalLepW() const
reco::Particle getFitLept() const
pat::Jet getCalHadp() const