JHUGen MELA  JHUGen v7.5.6, MELA v2.4.2
Matrix element calculations as used in JHUGen.
PDGHelpers Namespace Reference

Functions

bool isALepton (const int id)
 
bool isANeutrino (const int id)
 
bool isAnUnknownJet (const int id)
 
bool isAKnownJet (const int id)
 
bool isAJet (const int id)
 
bool isInvalid (const int id)
 
bool isAQuark (const int id)
 
bool isALightQuark (const int id)
 
bool isUpTypeQuark (const int id)
 
bool isDownTypeQuark (const int id)
 
bool isATopQuark (const int id)
 
bool isATauLepton (const int id)
 
bool isAGluon (const int id)
 
bool isAPhoton (const int id)
 
bool isAZBoson (const int id)
 
bool isAWBoson (const int id)
 
bool isAHiggs (const int id)
 
void orderParticles (const std::vector< int > &idlist, const std::vector< bool(*)(const int)> &testlist, std::vector< int > &ordering, bool allowUnknown=false)
 
void groupIdenticalParticles (const std::vector< int > &ids, std::vector< std::vector< int >> &ordering, bool *hasUnknownParticles=0)
 
void pairIdenticalParticles (const std::vector< int > &ids, std::vector< std::pair< int, int >> &ordering, bool allowUnknown=false)
 
bool allEquivalent (std::vector< int > const &ids, bool allowUnknown=false)
 
void setCandidateDecayMode (TVar::CandidateDecayMode mode)
 
int getCoupledVertex (const int idfirst, const int idsecond, int *hel=0, int *useAHcoupl=0)
 
int convertPythiaStatus (int pSt)
 

Variables

const double Wmass = 80.399
 
const double Zmass = 91.1876
 
const double Topmass = 173.2
 
const double Bottommass = 4.75
 
const double Zeromass = 0
 
const double m_el = 0.00051100
 
const double m_mu = 0.10566
 
const double m_tau = 1.7768
 
const double Wwidth = 2.085
 
const double Zwidth = 2.4952
 
const double Topwidth = 2.
 
TVar::CandidateDecayMode HDecayMode = TVar::CandidateDecay_ZZ
 

Function Documentation

◆ allEquivalent()

bool PDGHelpers::allEquivalent ( std::vector< int > const &  ids,
bool  allowUnknown = false 
)

Definition at line 208 of file PDGHelpers.cc.

208  {
209  bool result=true;
210  bool hasNonJet=false;
211  for (std::vector<int>::const_iterator it_first=ids.cbegin(); it_first!=ids.cend(); it_first++){
212  int const& id_first = *it_first;
213  if (!PDGHelpers::isAJet(id_first)) hasNonJet=true;
214  if (allowUnknown && PDGHelpers::isAnUnknownJet(id_first)){
215  if (hasNonJet){ result = false; break; }
216  else continue;
217  }
218  for (std::vector<int>::const_iterator it_second=it_first; it_second!=ids.cend(); it_second++){
219  int const& id_second = *it_second;
220  if (allowUnknown && PDGHelpers::isAnUnknownJet(id_second)){
221  if (hasNonJet){ result = false; break; }
222  else continue;
223  }
224  if (id_first!=id_second){ result = false; break; }
225  }
226  if (!result) break;
227  }
228  return result;
229 }

◆ convertPythiaStatus()

int PDGHelpers::convertPythiaStatus ( int  pSt)

Definition at line 248 of file PDGHelpers.cc.

248  {
249  if (pSt==0) return 1;
250  else if (pSt==1 || pSt==23) return 1;
251  else if (pSt==21) return -1;
252  else if (pSt==22 || pSt==62) return 2;
253  else{
254  MELAerr << "Unknown Pythia particle status: " << pSt << std::endl;
255  return -99;
256  }
257 }

◆ getCoupledVertex()

int PDGHelpers::getCoupledVertex ( const int  idfirst,
const int  idsecond,
int *  hel = 0,
int *  useAHcoupl = 0 
)

Definition at line 235 of file PDGHelpers.cc.

235  {
236  int ids[2]={ idfirst, idsecond };
237  int ids_jhu[2]={ -9000, -9000 };
238  for (unsigned int ip=0; ip<2; ip++){ if (!PDGHelpers::isInvalid(ids[ip])) ids_jhu[ip] = convertLHEreverse(&(ids[ip])); }
239  int zahswitch=0;
240  if (useAHcoupl) zahswitch = *useAHcoupl;
241  // Left-handed couplings always exist; right handed ones may or may not exist. This is why the default below is -1 for left-handed.
242  // Example: Z->nu nub does not have Z->nu_R nub_L counterpart because nu_R or nub_L do not exist!
243  int heleff=-1;
244  if (hel) heleff = *hel;
245  int Vid_jhu = CoupledVertex(ids_jhu, &heleff, &zahswitch);
246  return convertLHE(&Vid_jhu);
247 }

◆ groupIdenticalParticles()

void PDGHelpers::groupIdenticalParticles ( const std::vector< int > &  ids,
std::vector< std::vector< int >> &  ordering,
bool *  hasUnknownParticles = 0 
)

Definition at line 130 of file PDGHelpers.cc.

134  {
135  ordering.clear();
136  if (hasUnknownParticles) *hasUnknownParticles=false;
137 
138  for (unsigned int ipart=0; ipart<ids.size(); ipart++){
139  int const& id_part = ids.at(ipart);
140  if (PDGHelpers::isAnUnknownJet(id_part)) continue; // Group them the last
141  bool grouped=false;
142  for (auto& ord:ordering){
143  if (ord.at(0)==id_part){ ord.push_back(ipart); grouped=true; break; }
144  }
145  if (!grouped){ std::vector<int> newgroup; newgroup.push_back(ipart); ordering.push_back(newgroup); }
146  }
147  bool firstUnknown=true;
148  for (unsigned int ipart=0; ipart<ids.size(); ipart++){
149  int const& id_part = ids.at(ipart);
150  if (!PDGHelpers::isAnUnknownJet(id_part)) continue; // Unknwon parton group
151  if (hasUnknownParticles!=0) *hasUnknownParticles=true;
152  if (firstUnknown){
153  std::vector<int> newgroup; newgroup.push_back(ipart); ordering.push_back(newgroup);
154  firstUnknown=false;
155  }
156  else ordering.at(ordering.size()-1).push_back(id_part);
157  }
158 }

◆ isAGluon()

bool PDGHelpers::isAGluon ( const int  id)

Definition at line 58 of file PDGHelpers.cc.

58  {
59  if (std::abs(id)==21) return true;
60  else return false;
61 }

◆ isAHiggs()

bool PDGHelpers::isAHiggs ( const int  id)

Definition at line 84 of file PDGHelpers.cc.

84  {
85  if (std::abs(id)==25) return true;
86  else return false;
87 }

◆ isAJet()

bool PDGHelpers::isAJet ( const int  id)

Definition at line 18 of file PDGHelpers.cc.

18  {
19  if (PDGHelpers::isAnUnknownJet(id) || PDGHelpers::isAQuark(id) || PDGHelpers::isAGluon(id)) return true;
20  else return false;
21 }

◆ isAKnownJet()

bool PDGHelpers::isAKnownJet ( const int  id)

Definition at line 14 of file PDGHelpers.cc.

14  {
15  if (PDGHelpers::isAQuark(id) || PDGHelpers::isAGluon(id)) return true;
16  else return false;
17 }

◆ isALepton()

bool PDGHelpers::isALepton ( const int  id)

Definition at line 62 of file PDGHelpers.cc.

62  {
63  const int abs_id = std::abs(id);
64  if (abs_id==11 || abs_id==13 || abs_id==15) return true;
65  else return false;
66 }

◆ isALightQuark()

bool PDGHelpers::isALightQuark ( const int  id)

Definition at line 30 of file PDGHelpers.cc.

30  {
31  const int abs_id = std::abs(id);
32  if (abs_id<=5 && abs_id>0) return true;
33  else return false;
34 }

◆ isANeutrino()

bool PDGHelpers::isANeutrino ( const int  id)

Definition at line 67 of file PDGHelpers.cc.

67  {
68  const int abs_id = std::abs(id);
69  if (abs_id==12 || abs_id==14 || abs_id==16) return true;
70  else return false;
71 }

◆ isAnUnknownJet()

bool PDGHelpers::isAnUnknownJet ( const int  id)

Definition at line 22 of file PDGHelpers.cc.

22  {
23  if (id==0) return true;
24  else return false;
25 }

◆ isAPhoton()

bool PDGHelpers::isAPhoton ( const int  id)

Definition at line 72 of file PDGHelpers.cc.

72  {
73  if (std::abs(id)==22) return true;
74  else return false;
75 }

◆ isAQuark()

bool PDGHelpers::isAQuark ( const int  id)

Definition at line 35 of file PDGHelpers.cc.

35  {
36  const int abs_id = std::abs(id);
37  if (abs_id<=6 && abs_id>0) return true;
38  else return false;
39 }

◆ isATauLepton()

bool PDGHelpers::isATauLepton ( const int  id)

Definition at line 54 of file PDGHelpers.cc.

54  {
55  if (std::abs(id)==15) return true;
56  else return false;
57 }

◆ isATopQuark()

bool PDGHelpers::isATopQuark ( const int  id)

Definition at line 50 of file PDGHelpers.cc.

50  {
51  if (std::abs(id)==6) return true;
52  else return false;
53 }

◆ isAWBoson()

bool PDGHelpers::isAWBoson ( const int  id)

Definition at line 80 of file PDGHelpers.cc.

80  {
81  if (std::abs(id)==24) return true;
82  else return false;
83 }

◆ isAZBoson()

bool PDGHelpers::isAZBoson ( const int  id)

Definition at line 76 of file PDGHelpers.cc.

76  {
77  if (std::abs(id)==23) return true;
78  else return false;
79 }

◆ isDownTypeQuark()

bool PDGHelpers::isDownTypeQuark ( const int  id)

Definition at line 45 of file PDGHelpers.cc.

45  {
46  const int abs_id = std::abs(id);
47  if (abs_id==1 || abs_id==3 || abs_id==5) return true;
48  else return false;
49 }

◆ isInvalid()

bool PDGHelpers::isInvalid ( const int  id)

Definition at line 26 of file PDGHelpers.cc.

26  {
27  if (id==-9000) return true;
28  else return false;
29 }

◆ isUpTypeQuark()

bool PDGHelpers::isUpTypeQuark ( const int  id)

Definition at line 40 of file PDGHelpers.cc.

40  {
41  const int abs_id = std::abs(id);
42  if (abs_id==2 || abs_id==4 || abs_id==6) return true;
43  else return false;
44 }

◆ orderParticles()

void PDGHelpers::orderParticles ( const std::vector< int > &  idlist,
const std::vector< bool(*)(const int)> &  testlist,
std::vector< int > &  ordering,
bool  allowUnknown = false 
)

Definition at line 88 of file PDGHelpers.cc.

93  {
94  ordering.clear();
95  if (testlist.size() != idlist.size()){ MELAerr << "PDGHelpers::orderParticles: List of ids and list of their tests do not have the same size!" << std::endl; return; }
96  for (std::vector<bool(*)(const int)>::const_iterator it_test=testlist.cbegin(); it_test!=testlist.cend(); it_test++){
97  bool testFilled=false;
98  for (unsigned int ipart=0; ipart<idlist.size(); ipart++){
99  bool isAvailable=true;
100  for (int const& ord:ordering){
101  if (ord==(int)ipart){ isAvailable=false; break; }
102  }
103  if (!isAvailable) continue;
104  int tested = idlist.at(ipart);
105  if (PDGHelpers::isAnUnknownJet(tested)) continue;
106  if ((*it_test)(tested)){
107  ordering.push_back(tested);
108  testFilled=true;
109  }
110  }
111  if (!testFilled && allowUnknown){
112  for (unsigned int ipart=0; ipart<idlist.size(); ipart++){
113  bool isAvailable=true;
114  for (int const& ord:ordering){
115  if (ord==(int) ipart){ isAvailable=false; break; }
116  }
117  if (!isAvailable) continue;
118  int tested = idlist.at(ipart);
119  if (!PDGHelpers::isAnUnknownJet(tested)) continue;
120  if ((*it_test)(tested)){
121  ordering.push_back(tested);
122  testFilled=true;
123  }
124  }
125  }
126  if (!testFilled) break; // No need to try to order further, ordering is unsuccessful
127  }
128  if (idlist.size()!=ordering.size()) ordering.clear(); // This means not all particles were matched
129 }

◆ pairIdenticalParticles()

void PDGHelpers::pairIdenticalParticles ( const std::vector< int > &  ids,
std::vector< std::pair< int, int >> &  ordering,
bool  allowUnknown = false 
)

Definition at line 159 of file PDGHelpers.cc.

163  {
164  ordering.clear();
165 
166  std::vector<std::vector<int>> grouping;
167  bool hasUnknown=false;
168  PDGHelpers::groupIdenticalParticles(ids, grouping, &hasUnknown);
169 
170  for (auto const& group:grouping){
171  unsigned int group_rep = group.at(0);
172  if (group_rep>=ids.size()){ MELAerr << "PDGHelpers::pairIdenticalParticles: Group " << group << " has a representative location >=ids.size (" << ids.size() << ")!" << std::endl; continue; }
173  int group_flag = ids.at(group_rep);
174  if (!PDGHelpers::isAnUnknownJet(group_flag)){ // Known particles first!
175  unsigned int npairs = group.size()/2;
176  bool isOdd=(group.size() % 2 == 1);
177  if (isOdd) npairs++;
178  for (unsigned int ip=0; ip<npairs; ip++){
179  if (isOdd && ip==npairs-1) ordering.push_back(std::pair<int, int>(group.at(2*ip), -1));
180  else ordering.push_back(std::pair<int, int>(group.at(2*ip), group.at(2*ip+1)));
181  }
182  }
183  }
184  if (allowUnknown){
185  for (auto const& group:grouping){
186  unsigned int group_rep = group.at(0);
187  if (group_rep>=ids.size()){ MELAerr << "PDGHelpers::pairIdenticalParticles: Group " << group << " has a representative location >=ids.size (" << ids.size() << ")!" << std::endl; continue; }
188  int group_flag = ids.at(group_rep);
189  if (!PDGHelpers::isAnUnknownJet(group_flag)) continue; // Unknown particles
190  // Now that we found the unknown particles group, loop over it
191  for (int const& pos:group){
192  bool paired=false;
193  // Check if there are unpaired particles left
194  for (auto& order:ordering){
195  if (order.second==-1 && PDGHelpers::isAJet(ids.at(order.first))){
196  order.second = pos;
197  paired=true;
198  break;
199  }
200  }
201  if (paired) continue;
202  // All pairs are filled, create a new pair
203  ordering.push_back(std::pair<int, int>(pos, -1)); // Since this is a new pair, the second position is yet to be filled.
204  }
205  }
206  }
207 }

◆ setCandidateDecayMode()

void PDGHelpers::setCandidateDecayMode ( TVar::CandidateDecayMode  mode)

Definition at line 232 of file PDGHelpers.cc.

232 { PDGHelpers::HDecayMode=mode; }

Variable Documentation

◆ Bottommass

const double PDGHelpers::Bottommass = 4.75

Definition at line 16 of file PDGHelpers.h.

◆ HDecayMode

Definition at line 11 of file PDGHelpers.cc.

◆ m_el

const double PDGHelpers::m_el = 0.00051100

Definition at line 18 of file PDGHelpers.h.

◆ m_mu

const double PDGHelpers::m_mu = 0.10566

Definition at line 19 of file PDGHelpers.h.

◆ m_tau

const double PDGHelpers::m_tau = 1.7768

Definition at line 20 of file PDGHelpers.h.

◆ Topmass

const double PDGHelpers::Topmass = 173.2

Definition at line 15 of file PDGHelpers.h.

◆ Topwidth

const double PDGHelpers::Topwidth = 2.

Definition at line 23 of file PDGHelpers.h.

◆ Wmass

const double PDGHelpers::Wmass = 80.399

Definition at line 13 of file PDGHelpers.h.

◆ Wwidth

const double PDGHelpers::Wwidth = 2.085

Definition at line 21 of file PDGHelpers.h.

◆ Zeromass

const double PDGHelpers::Zeromass = 0

Definition at line 17 of file PDGHelpers.h.

◆ Zmass

const double PDGHelpers::Zmass = 91.1876

Definition at line 14 of file PDGHelpers.h.

◆ Zwidth

const double PDGHelpers::Zwidth = 2.4952

Definition at line 22 of file PDGHelpers.h.

PDGHelpers::HDecayMode
TVar::CandidateDecayMode HDecayMode
Definition: PDGHelpers.cc:11
convertLHE
#define convertLHE
Definition: TModParameters.hh:16
PDGHelpers::isInvalid
bool isInvalid(const int id)
Definition: PDGHelpers.cc:26
PDGHelpers::isAnUnknownJet
bool isAnUnknownJet(const int id)
Definition: PDGHelpers.cc:22
PDGHelpers::isAQuark
bool isAQuark(const int id)
Definition: PDGHelpers.cc:35
PDGHelpers::groupIdenticalParticles
void groupIdenticalParticles(const std::vector< int > &ids, std::vector< std::vector< int >> &ordering, bool *hasUnknownParticles=0)
Definition: PDGHelpers.cc:130
MELAStreamHelpers::MELAerr
MELAOutputStreamer MELAerr
convertLHEreverse
#define convertLHEreverse
Definition: TModParameters.hh:12
PDGHelpers::isAGluon
bool isAGluon(const int id)
Definition: PDGHelpers.cc:58
CoupledVertex
#define CoupledVertex
Definition: TModParameters.hh:19
PDGHelpers::isAJet
bool isAJet(const int id)
Definition: PDGHelpers.cc:18