SusyNtuple
|
00001 // Dear emacs, this is -*- c++ -*- 00002 #ifndef SUSY_MC_TRUTH_UTILS_H 00003 #define SUSY_MC_TRUTH_UTILS_H 00004 00005 /* 00006 MonteCarlo truth utilities 00007 00008 00009 davide.gerbaudo@gmail.com 00010 April 2014 00011 */ 00012 00013 #include <functional> 00014 #include <string> 00015 #include <vector> 00016 00017 namespace Susy{ 00018 namespace mc{ 00019 00020 typedef std::vector< int > vint_t; 00021 typedef std::vector< vint_t > vvint_t; 00022 00023 // 2014-01-17: Order of enum changed so that kUnknown is zero 00024 enum Hdecays { 00025 kUnknown = 0, 00026 kPwAw, 00027 kZZ, 00028 kPtauAtau, 00029 kPbAb, 00030 kPmuAmu, 00031 }; 00032 00033 enum PdgIds{ 00034 kPd=+1, kAd=-1, 00035 kPu=+2, kAu=-2, 00036 kPs=+3, kAs=-3, 00037 kPc=+4, kAc=-4, 00038 kPb=+5, kAb=-5, 00039 kPt=+6, kAt=-6, 00040 kPel=+11, kAel=-11, 00041 kPve=+12, kAve=-12, 00042 kPmu=+13, kAmu=-13, 00043 kPvm=+14, kAvm=-14, 00044 kPtau=+15, kAtau=-15, 00045 kPvt=+16, kAvt=-16, 00046 kPglu=21, 00047 kPgam=22, 00048 kPz=+23, 00049 kPw=+24, kAw=-24, 00050 kPh=+25 00051 }; 00052 00054 std::string decayToString(const Hdecays &d); 00056 00059 int determineParentPdg(const vint_t *pdgs, const vvint_t *parentsIndices, const int &particleIndex); 00061 struct IntermediateParentWalker { 00062 const vint_t &pdgs_; 00063 const vvint_t &parsIdxs_; 00064 size_t i_; 00065 int pdg_; 00066 vint_t parIndices_; 00067 vint_t parPdgs_; 00068 IntermediateParentWalker(const vint_t *pdgs, const vvint_t *parentsIndices, const int &particleIndex); 00069 int defaultParentPdg() const { return -999; } 00071 int parentPdg() const { return parPdgs_.size()>0 ? parPdgs_[0] : defaultParentPdg(); } 00072 void setIndexCurrentParticle(const int &i); 00073 bool hasParent() { return parIndices_.size()>0; } 00074 bool hasSelfParent(); 00075 size_t indexSelfParent(); 00076 void walkUp(); 00077 }; 00078 00080 struct IsHiggsIndices: 00081 public std::unary_function<const int&, void> { 00082 IsHiggsIndices(): counter_(0) { } 00083 void operator()(const int &p) { if(p==kPh) higgsIndices_.push_back(counter_); counter_++; } 00084 vint_t higgsIndices_; 00085 size_t counter_; 00086 }; 00087 00089 struct IndexToPdg { 00090 const vint_t &pdgs_; 00091 IndexToPdg(const vint_t &pdgs) : pdgs_(pdgs) {} 00092 int operator()(const int &e) const { return pdgs_[e]; } 00093 }; 00094 00096 struct IsBIndex : public std::unary_function<int, bool> { 00097 IsBIndex(const std::vector<int> *pdgs) : pdgs_(*pdgs) {} 00098 const std::vector<int> &pdgs_; 00099 bool operator() (int i) const { return (pdgs_[i]==kPb || pdgs_[i]==kAb); } 00100 }; 00101 00103 struct PdgGetter{ 00104 const std::vector<int> &pdgs_; 00105 PdgGetter(const std::vector<int> *pdgs) : pdgs_(*pdgs) {} 00106 int operator() (const int &i) const { return pdgs_[i]; } 00107 }; 00108 00110 struct IsSmTopIndex { 00111 const vint_t &pdgs_; 00112 const vvint_t &chIdxs_; 00113 IsSmTopIndex(const vint_t *pdgs, const vvint_t *childrenIndices); 00114 bool isTop(const int &i); 00115 bool isTopChild(const int &i); 00116 bool areAllTopChildren(const int &itop); 00117 bool operator() (const int & i); 00118 }; // end isSmTop 00119 00121 struct IsDecayingWIndex { 00122 const vint_t &pdgs_; 00123 const vvint_t &chIdxs_; 00124 IsDecayingWIndex(const vint_t *pdgs, const vvint_t *childrenIndices); 00125 bool isW(const int &i); 00126 bool isWintermediate(const int &iW); 00127 bool isWChild(const int &i); 00128 bool areAllWChildren(const int &iW); 00129 bool operator() (const int & i); 00130 }; // end isDecayingW 00131 00132 00133 } // utils 00134 } // susy 00135 #endif