CMS 3D CMS Logo

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