TtSemiEvtSolution

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
//
//

#ifndef TopObjects_TtSemiEvtSolution_h
#define TopObjects_TtSemiEvtSolution_h

#include <vector>
#include <string>

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Common/interface/RefProd.h"
#include "DataFormats/Common/interface/Ref.h"

#include "DataFormats/Candidate/interface/Particle.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "AnalysisDataFormats/TopObjects/interface/TtGenEvent.h"

#include "DataFormats/PatCandidates/interface/Particle.h"
#include "DataFormats/PatCandidates/interface/Electron.h"
#include "DataFormats/PatCandidates/interface/Muon.h"
#include "DataFormats/PatCandidates/interface/Tau.h"
#include "DataFormats/PatCandidates/interface/Jet.h"
#include "DataFormats/PatCandidates/interface/MET.h"

#include "DataFormats/Candidate/interface/ShallowClonePtrCandidate.h"
#include "DataFormats/Candidate/interface/CompositeCandidate.h"

// FIXME: make the decay member an enumerable
// FIXME: Can we generalize all the muon and electron to lepton?

class TtSemiEvtSolution {
  friend class TtSemiEvtSolutionMaker;
  friend class TtSemiLepKinFitter;
  friend class TtSemiLepHitFit;
  friend class TtSemiLRSignalSelObservables;
  friend class TtSemiLRSignalSelCalc;
  friend class TtSemiLRJetCombObservables;
  friend class TtSemiLRJetCombCalc;

public:
  TtSemiEvtSolution();
  virtual ~TtSemiEvtSolution();

  //-------------------------------------------
  // get calibrated base objects
  //-------------------------------------------
  pat::Jet getHadb() const;
  pat::Jet getHadp() const;
  pat::Jet getHadq() const;
  pat::Jet getLepb() const;
  pat::Muon getMuon() const { return *muon_; };
  pat::Electron getElectron() const { return *electron_; };
  pat::MET getNeutrino() const { return *neutrino_; };

  //-------------------------------------------
  // get the matched gen particles
  //-------------------------------------------
  const edm::RefProd<TtGenEvent>& getGenEvent() const { return theGenEvt_; };
  const reco::GenParticle* getGenHadt() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->hadronicDecayTop();
  };
  const reco::GenParticle* getGenHadW() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->hadronicDecayW();
  };
  const reco::GenParticle* getGenHadb() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->hadronicDecayB();
  };
  const reco::GenParticle* getGenHadp() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->hadronicDecayQuark();
  };
  const reco::GenParticle* getGenHadq() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->hadronicDecayQuarkBar();
  };
  const reco::GenParticle* getGenLept() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->leptonicDecayTop();
  };
  const reco::GenParticle* getGenLepW() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->leptonicDecayW();
  };
  const reco::GenParticle* getGenLepb() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->leptonicDecayB();
  };
  const reco::GenParticle* getGenLepl() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->singleLepton();
  };
  const reco::GenParticle* getGenLepn() const {
    if (!theGenEvt_)
      return nullptr;
    else
      return this->getGenEvent()->singleNeutrino();
  };

  //-------------------------------------------
  // get (un-)/calibrated reco objects
  //-------------------------------------------
  reco::Particle getRecHadt() const;
  reco::Particle getRecHadW() const;
  pat::Jet getRecHadb() const { return this->getHadb().correctedJet("RAW"); };
  pat::Jet getRecHadp() const { return this->getHadp().correctedJet("RAW"); };
  pat::Jet getRecHadq() const { return this->getHadq().correctedJet("RAW"); };
  reco::Particle getRecLept() const;
  reco::Particle getRecLepW() const;
  pat::Jet getRecLepb() const { return this->getLepb().correctedJet("RAW"); };
  pat::Muon getRecLepm() const { return this->getMuon(); };
  pat::Electron getRecLepe() const { return this->getElectron(); };
  pat::MET getRecLepn() const { return this->getNeutrino(); };
  // FIXME: Why these functions??? Not needed!
  // methods to get calibrated objects
  reco::Particle getCalHadt() const;
  reco::Particle getCalHadW() const;
  pat::Jet getCalHadb() const { return this->getHadb(); };
  pat::Jet getCalHadp() const { return this->getHadp(); };
  pat::Jet getCalHadq() const { return this->getHadq(); };
  reco::Particle getCalLept() const;
  reco::Particle getCalLepW() const;
  pat::Jet getCalLepb() const { return this->getLepb(); };
  pat::Muon getCalLepm() const { return this->getMuon(); };
  pat::Electron getCalLepe() const { return this->getElectron(); };
  pat::MET getCalLepn() const { return this->getNeutrino(); };

  //-------------------------------------------
  // get objects from kinematic fit
  //-------------------------------------------
  reco::Particle getFitHadt() const;
  reco::Particle getFitHadW() const;
  pat::Particle getFitHadb() const { return (!fitHadb_.empty() ? fitHadb_.front() : pat::Particle()); };
  pat::Particle getFitHadp() const { return (!fitHadp_.empty() ? fitHadp_.front() : pat::Particle()); };
  pat::Particle getFitHadq() const { return (!fitHadq_.empty() ? fitHadq_.front() : pat::Particle()); };
  reco::Particle getFitLept() const;
  reco::Particle getFitLepW() const;
  pat::Particle getFitLepb() const { return (!fitLepb_.empty() ? fitLepb_.front() : pat::Particle()); };
  pat::Particle getFitLepl() const { return (!fitLepl_.empty() ? fitLepl_.front() : pat::Particle()); };
  pat::Particle getFitLepn() const { return (!fitLepn_.empty() ? fitLepn_.front() : pat::Particle()); };

  //-------------------------------------------
  // get the selected semileptonic decay chain
  //-------------------------------------------
  std::string getDecay() const { return decay_; }

  //-------------------------------------------
  // get info on the matching
  //-------------------------------------------
  double getMCBestSumAngles() const { return sumAnglejp_; };
  double getMCBestAngleHadp() const { return angleHadp_; };
  double getMCBestAngleHadq() const { return angleHadq_; };
  double getMCBestAngleHadb() const { return angleHadb_; };
  double getMCBestAngleLepb() const { return angleLepb_; };
  int getMCChangeWQ() const { return changeWQ_; };

  //-------------------------------------------
  // get the selected kinfit parametrisations
  // of each type of object
  //-------------------------------------------
  int getJetParametrisation() const { return jetParam_; }
  int getLeptonParametrisation() const { return leptonParam_; }
  int getNeutrinoParametrisation() const { return neutrinoParam_; }

  //-------------------------------------------
  // get the prob of the chi2 value resulting
  // from the kinematic fit
  //-------------------------------------------
  double getProbChi2() const { return probChi2_; }

  //-------------------------------------------
  // get info on the outcome of the signal
  // selection LR
  //-------------------------------------------
  double getLRSignalEvtObsVal(unsigned int) const;
  double getLRSignalEvtLRval() const { return lrSignalEvtLRval_; }
  double getLRSignalEvtProb() const { return lrSignalEvtProb_; }

  //-------------------------------------------
  // get info on the outcome of the different
  // jet combination methods
  //-------------------------------------------
  int getMCBestJetComb() const { return mcBestJetComb_; }
  int getSimpleBestJetComb() const { return simpleBestJetComb_; }
  int getLRBestJetComb() const { return lrBestJetComb_; }
  double getLRJetCombObsVal(unsigned int) const;
  double getLRJetCombLRval() const { return lrJetCombLRval_; }
  double getLRJetCombProb() const { return lrJetCombProb_; }

  //-------------------------------------------
  // get the various event hypotheses
  //-------------------------------------------
  const reco::CompositeCandidate& getRecoHyp() const { return recoHyp_; }
  const reco::CompositeCandidate& getFitHyp() const { return fitHyp_; }
  const reco::CompositeCandidate& getMCHyp() const { return mcHyp_; }

protected:
  //-------------------------------------------
  // set the generated event
  //-------------------------------------------
  void setGenEvt(const edm::Handle<TtGenEvent>& aGenEvt);

  //-------------------------------------------
  // set the basic objects
  //-------------------------------------------
  void setJetCorrectionScheme(int scheme) { jetCorrScheme_ = scheme; };
  void setHadp(const edm::Handle<std::vector<pat::Jet> >& jet, int i) { hadp_ = edm::Ptr<pat::Jet>(jet, i); };
  void setHadq(const edm::Handle<std::vector<pat::Jet> >& jet, int i) { hadq_ = edm::Ptr<pat::Jet>(jet, i); };
  void setHadb(const edm::Handle<std::vector<pat::Jet> >& jet, int i) { hadb_ = edm::Ptr<pat::Jet>(jet, i); };
  void setLepb(const edm::Handle<std::vector<pat::Jet> >& jet, int i) { lepb_ = edm::Ptr<pat::Jet>(jet, i); };
  void setMuon(const edm::Handle<std::vector<pat::Muon> >& muon, int i) {
    muon_ = edm::Ptr<pat::Muon>(muon, i);
    decay_ = "muon";
  };
  void setElectron(const edm::Handle<std::vector<pat::Electron> >& elec, int i) {
    electron_ = edm::Ptr<pat::Electron>(elec, i);
    decay_ = "electron";
  };
  void setNeutrino(const edm::Handle<std::vector<pat::MET> >& met, int i) { neutrino_ = edm::Ptr<pat::MET>(met, i); };

  //-------------------------------------------
  // set the fitted objects
  //-------------------------------------------
  void setFitHadb(const pat::Particle& aFitHadb) {
    fitHadb_.clear();
    fitHadb_.push_back(aFitHadb);
  };
  void setFitHadp(const pat::Particle& aFitHadp) {
    fitHadp_.clear();
    fitHadp_.push_back(aFitHadp);
  };
  void setFitHadq(const pat::Particle& aFitHadq) {
    fitHadq_.clear();
    fitHadq_.push_back(aFitHadq);
  };
  void setFitLepb(const pat::Particle& aFitLepb) {
    fitLepb_.clear();
    fitLepb_.push_back(aFitLepb);
  };
  void setFitLepl(const pat::Particle& aFitLepl) {
    fitLepl_.clear();
    fitLepl_.push_back(aFitLepl);
  };
  void setFitLepn(const pat::Particle& aFitLepn) {
    fitLepn_.clear();
    fitLepn_.push_back(aFitLepn);
  };

  //-------------------------------------------
  // set the info on the matching
  //-------------------------------------------
  void setMCBestSumAngles(double sdr) { sumAnglejp_ = sdr; };
  void setMCBestAngleHadp(double adr) { angleHadp_ = adr; };
  void setMCBestAngleHadq(double adr) { angleHadq_ = adr; };
  void setMCBestAngleHadb(double adr) { angleHadb_ = adr; };
  void setMCBestAngleLepb(double adr) { angleLepb_ = adr; };
  void setMCChangeWQ(int wq) { changeWQ_ = wq; };

  //-------------------------------------------
  // set the kinfit parametrisations of each
  // type of object
  //-------------------------------------------
  void setJetParametrisation(int jp) { jetParam_ = jp; };
  void setLeptonParametrisation(int lp) { leptonParam_ = lp; };
  void setNeutrinoParametrisation(int mp) { neutrinoParam_ = mp; };

  //-------------------------------------------
  // set the prob. of the chi2 value resulting
  // from the kinematic fit
  //-------------------------------------------
  void setProbChi2(double c) { probChi2_ = c; };

  //-------------------------------------------
  // set the outcome of the different jet
  // combination methods
  //-------------------------------------------
  void setMCBestJetComb(int mcbs) { mcBestJetComb_ = mcbs; };
  void setSimpleBestJetComb(int sbs) { simpleBestJetComb_ = sbs; };
  void setLRBestJetComb(int lrbs) { lrBestJetComb_ = lrbs; };
  void setLRJetCombObservables(const std::vector<std::pair<unsigned int, double> >& varval);
  void setLRJetCombLRval(double clr) { lrJetCombLRval_ = clr; };
  void setLRJetCombProb(double plr) { lrJetCombProb_ = plr; };

  //-------------------------------------------
  // set the outcome of the signal selection LR
  //-------------------------------------------
  void setLRSignalEvtObservables(const std::vector<std::pair<unsigned int, double> >& varval);
  void setLRSignalEvtLRval(double clr) { lrSignalEvtLRval_ = clr; };
  void setLRSignalEvtProb(double plr) { lrSignalEvtProb_ = plr; };

private:
  //-------------------------------------------
  // particle content
  //-------------------------------------------
  edm::RefProd<TtGenEvent> theGenEvt_;
  edm::Ptr<pat::Jet> hadb_, hadp_, hadq_, lepb_;
  edm::Ptr<pat::Muon> muon_;
  edm::Ptr<pat::Electron> electron_;
  edm::Ptr<pat::MET> neutrino_;
  std::vector<pat::Particle> fitHadb_, fitHadp_, fitHadq_;
  std::vector<pat::Particle> fitLepb_, fitLepl_, fitLepn_;

  reco::CompositeCandidate mcHyp_;
  reco::CompositeCandidate recoHyp_;
  reco::CompositeCandidate fitHyp_;

  void setupHyp();

  std::string decay_;
  int jetCorrScheme_;
  double sumAnglejp_, angleHadp_, angleHadq_, angleHadb_, angleLepb_;
  int changeWQ_;
  int jetParam_, leptonParam_, neutrinoParam_;
  double probChi2_;
  int mcBestJetComb_, simpleBestJetComb_, lrBestJetComb_;
  double lrJetCombLRval_, lrJetCombProb_;
  double lrSignalEvtLRval_, lrSignalEvtProb_;
  std::vector<std::pair<unsigned int, double> > lrJetCombVarVal_;
  std::vector<std::pair<unsigned int, double> > lrSignalEvtVarVal_;
};

#endif