Skip to content

Commit

Permalink
Merge pull request #84 from OlivierBondu/gen_ttbar
Browse files Browse the repository at this point in the history
Gen ttbar
  • Loading branch information
BrieucF committed Feb 12, 2016
2 parents b152267 + cdd932b commit f8350d2
Show file tree
Hide file tree
Showing 5 changed files with 514 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,7 @@

# vim
*.sw*

# plotIt
plugins/Indices_cc.d
plugins/Indices_cc_ACLiC_dict_rdict.pcm
122 changes: 122 additions & 0 deletions interface/GenStatusFlags.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#pragma once

// Code from https://raw.githubusercontent.com/cms-sw/cmssw/CMSSW_7_4_X/DataFormats/HepMCCandidate/interface/GenStatusFlags.h

#include <bitset>

struct GenStatusFlags {

public:

enum StatusBits {
kIsPrompt = 0,
kIsDecayedLeptonHadron,
kIsTauDecayProduct,
kIsPromptTauDecayProduct,
kIsDirectTauDecayProduct,
kIsDirectPromptTauDecayProduct,
kIsDirectHadronDecayProduct,
kIsHardProcess,
kFromHardProcess,
kIsHardProcessTauDecayProduct,
kIsDirectHardProcessTauDecayProduct,
kFromHardProcessBeforeFSR,
kIsFirstCopy,
kIsLastCopy,
kIsLastCopyBeforeFSR
};

GenStatusFlags(int16_t flags):
flags_(flags) {
// Empty
}

/////////////////////////////////////////////////////////////////////////////
//these are robust, generator-independent functions for categorizing
//mainly final state particles, but also intermediate hadrons/taus

//is particle prompt (not from hadron, muon, or tau decay)
bool isPrompt() const { return flags_[kIsPrompt]; }

//is particle a decayed hadron, muon, or tau (does not include resonance decays like W,Z,Higgs,top,etc)
//This flag is equivalent to status 2 in the current HepMC standard
//but older generators (pythia6, herwig6) predate this and use status 2 also for other intermediate
//particles/states
bool isDecayedLeptonHadron() const { return flags_[kIsDecayedLeptonHadron]; }

//this particle is a direct or indirect tau decay product
bool isTauDecayProduct() const { return flags_[kIsTauDecayProduct]; }

//this particle is a direct or indirect decay product of a prompt tau
bool isPromptTauDecayProduct() const { return flags_[kIsPromptTauDecayProduct]; }

//this particle is a direct tau decay product
bool isDirectTauDecayProduct() const { return flags_[kIsDirectTauDecayProduct]; }

//this particle is a direct decay product from a prompt tau
bool isDirectPromptTauDecayProduct() const { return flags_[kIsDirectPromptTauDecayProduct]; }

//this particle is a direct decay product from a hadron
bool isDirectHadronDecayProduct() const { return flags_[kIsDirectHadronDecayProduct]; }

/////////////////////////////////////////////////////////////////////////////
//these are generator history-dependent functions for tagging particles
//associated with the hard process
//Currently implemented for Pythia 6 and Pythia 8 status codes and history
//and may not have 100% consistent meaning across all types of processes
//Users are strongly encouraged to stick to the more robust flags above

//this particle is part of the hard process
bool isHardProcess() const { return flags_[kIsHardProcess]; }

//this particle is the direct descendant of a hard process particle of the same pdg id
bool fromHardProcess() const { return flags_[kFromHardProcess]; }

//this particle is a direct or indirect decay product of a tau
//from the hard process
bool isHardProcessTauDecayProduct() const { return flags_[kIsHardProcessTauDecayProduct]; }

//this particle is a direct decay product of a tau
//from the hard process
bool isDirectHardProcessTauDecayProduct() const { return flags_[kIsDirectHardProcessTauDecayProduct]; }

//this particle is the direct descendant of a hard process particle of the same pdg id
//For outgoing particles the kinematics are those before QCD or QED FSR
//This corresponds roughly to status code 3 in pythia 6
bool fromHardProcessBeforeFSR() const { return flags_[kFromHardProcessBeforeFSR]; }

//this particle is the first copy of the particle in the chain with the same pdg id
bool isFirstCopy() const { return flags_[kIsFirstCopy]; }

//this particle is the last copy of the particle in the chain with the same pdg id
//(and therefore is more likely, but not guaranteed, to carry the final physical momentum)
bool isLastCopy() const { return flags_[kIsLastCopy]; }

//this particle is the last copy of the particle in the chain with the same pdg id
//before QED or QCD FSR
//(and therefore is more likely, but not guaranteed, to carry the momentum after ISR)
bool isLastCopyBeforeFSR() const { return flags_[kIsLastCopyBeforeFSR]; }

void dump() const {
std::cout << "Generator status flags:" << std::endl;
std::cout << "\tisPrompt: " << isPrompt() << std::endl;
std::cout << "\tisDecayedLeptonHadron: " << isDecayedLeptonHadron() << std::endl;
std::cout << "\tisTauDecayProduct: " << isTauDecayProduct() << std::endl;
std::cout << "\tisPromptTauDecayProduct: " << isPromptTauDecayProduct() << std::endl;
std::cout << "\tisDirectTauDecayProduct: " << isDirectTauDecayProduct() << std::endl;
std::cout << "\tisDirectPromptTauDecayProduct: " << isDirectPromptTauDecayProduct() << std::endl;
std::cout << "\tisDirectHadronDecayProduct: " << isDirectHadronDecayProduct() << std::endl;
std::cout << "\tisHardProcess: " << isHardProcess() << std::endl;
std::cout << "\tfromHardProcess: " << fromHardProcess() << std::endl;
std::cout << "\tisHardProcessTauDecayProduct: " << isHardProcessTauDecayProduct() << std::endl;
std::cout << "\tisDirectHardProcessTauDecayProduct: " << isDirectHardProcessTauDecayProduct() << std::endl;
std::cout << "\tfromHardProcessBeforeFSR: " << fromHardProcessBeforeFSR() << std::endl;
std::cout << "\tisFirstCopy: " << isFirstCopy() << std::endl;
std::cout << "\tisLastCopy: " << isLastCopy() << std::endl;
std::cout << "\tisLastCopyBeforeFSR: " << isLastCopyBeforeFSR() << std::endl;
}


private:
std::bitset<15> flags_;
};
34 changes: 34 additions & 0 deletions interface/HHAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,40 @@ class HHAnalyzer: public Framework::Analyzer {
float count_has2leptons_muel_1llmetjj_2btagM = 0.;
float count_has2leptons_mumu_1llmetjj_2btagM = 0.;

// ttbar system mc truth
// Gen matching. All indexes are from the `pruned` collection
uint16_t gen_t; // Index of the top quark
uint16_t gen_t_beforeFSR; // Index of the top quark, before any FSR
uint16_t gen_tbar; // Index of the anti-top quark
uint16_t gen_tbar_beforeFSR; // Index of the anti-top quark, before any FSR

uint16_t gen_b; // Index of the b quark coming from the top decay
uint16_t gen_b_beforeFSR; // Index of the b quark coming from the top decay, before any FSR
uint16_t gen_bbar; // Index of the anti-b quark coming from the anti-top decay
uint16_t gen_bbar_beforeFSR; // Index of the anti-b quark coming from the anti-top decay, before any FSR

uint16_t gen_jet1_t; // Index of the first jet from the top decay chain
uint16_t gen_jet1_t_beforeFSR; // Index of the first jet from the top decay chain, before any FSR
uint16_t gen_jet2_t; // Index of the second jet from the top decay chain
uint16_t gen_jet2_t_beforeFSR; // Index of the second jet from the top decay chain, before any FSR

uint16_t gen_jet1_tbar; // Index of the first jet from the anti-top decay chain
uint16_t gen_jet1_tbar_beforeFSR; // Index of the first jet from the anti-top decay chain, before any FSR
uint16_t gen_jet2_tbar; // Index of the second jet from the anti-top decay chain
uint16_t gen_jet2_tbar_beforeFSR; // Index of the second jet from the anti-top decay chain, before any FSR

uint16_t gen_lepton_t; // Index of the lepton from the top decay chain
uint16_t gen_lepton_t_beforeFSR; // Index of the lepton from the top decay chain, before any FSR
uint16_t gen_neutrino_t; // Index of the neutrino from the top decay chain
uint16_t gen_neutrino_t_beforeFSR; // Index of the neutrino from the top decay chain, before any FSR

uint16_t gen_lepton_tbar; // Index of the lepton from the anti-top decay chain
uint16_t gen_lepton_tbar_beforeFSR; // Index of the lepton from the anti-top decay chain, before any FSR
uint16_t gen_neutrino_tbar; // Index of the neutrino from the anti-top decay chain
uint16_t gen_neutrino_tbar_beforeFSR; // Index of the neutrino from the anti-top decay chain, before any FSR

BRANCH(gen_ttbar_decay_type, char); // Type of ttbar decay. Can take any values from TTDecayType enum

private:
// Producers name
std::string m_electrons_producer;
Expand Down
17 changes: 17 additions & 0 deletions interface/Indices.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,21 @@ namespace HHAnalysis {
uint16_t leplepIDIsojetjetIDbtagWPPair(const lepID::lepID& id1, const lepIso::lepIso& iso1, const lepID::lepID& id2, const lepIso::lepIso& iso2, const jetID::jetID& jetid1, const btagWP::btagWP& wp1, const jetID::jetID& jetid2, const btagWP::btagWP& wp2, const jetPair::jetPair& jetpair);
std::string leplepIDIsojetjetIDbtagWPPairStr(const lepID::lepID& id1, const lepIso::lepIso& iso1, const lepID::lepID& id2, const lepIso::lepIso& iso2, const jetID::jetID& jetid1, const btagWP::btagWP& wp1, const jetID::jetID& jetid2, const btagWP::btagWP& wp2, const jetPair::jetPair& jetpair);

enum TTDecayType {
UnknownTT = -1,
NotTT = 0,
Hadronic,
Semileptonic_e,
Semileptonic_mu,
Dileptonic_mumu,
Dileptonic_ee,
Dileptonic_mue,

// With tau
Semileptonic_tau,
Dileptonic_tautau,
Dileptonic_mutau,
Dileptonic_etau
};

}
Loading

0 comments on commit f8350d2

Please sign in to comment.