Coverity fixes
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / ParticlePDG.cxx
CommitLineData
03896fc4 1//
2// Copyright : The FASTMC and SPHMC Collaboration
3// Author : Ionut Cristian Arsene
4// Affiliation : Oslo University, Norway & Institute for Space Sciences, Bucharest, Romania
5// e-mail : i.c.arsene@fys.uio.no
6// Date : 2007/05/30
7//
8// This class is using the particle and decay lists provided by the
9// THERMINATOR (Computer Physics Communications 174 669 (2006)) and
10// SHARE (Computer Physics Communications 167 229 (2005)) collaborations.
11//
b1c2e580 12
13#include <iostream>
b7dbe0fd 14#include <string>
15using namespace std;
03896fc4 16#include "ParticlePDG.h"
b1c2e580 17
03896fc4 18//________________________________________________________________________
7b7936e9 19ParticlePDG::ParticlePDG() :
20 fPDG(kNonsensePDG),
21 fMass(-1.0),
22 fWidth(0.0),
23 fSpin(0.0),
24 fIsospin(0.0),
25 fIsospinZ(0.0),
26 fLightQuarkNumber(0.0),
27 fAntiLightQuarkNumber(0.0),
28 fStrangeQuarkNumber(0.0),
29 fAntiStrangeQuarkNumber(0.0),
30 fCharmQuarkNumber(0.0),
31 fAntiCharmQuarkNumber(0.0),
32 fNDecayChannels(0),
33 fStable(0.0)
34{
03896fc4 35//
36// default constructor
37//
00a8be7b 38 memset(fName,'a',9);
b1c2e580 39 for(Int_t i=0; i<kMaxDecayChannels; i++)
40 fDecayChannels[i] = new DecayChannel();
41}
42
03896fc4 43//________________________________________________________________________
8bf1c965 44ParticlePDG::ParticlePDG(const Char_t * const name, Int_t pdg, Double_t mass, Double_t width) :
7b7936e9 45 fPDG(pdg),
46 fMass(mass),
47 fWidth(width),
48 fSpin(0.0),
49 fIsospin(0.0),
50 fIsospinZ(0.0),
51 fLightQuarkNumber(0.0),
52 fAntiLightQuarkNumber(0.0),
53 fStrangeQuarkNumber(0.0),
54 fAntiStrangeQuarkNumber(0.0),
55 fCharmQuarkNumber(0.0),
56 fAntiCharmQuarkNumber(0.0),
57 fNDecayChannels(0),
58 fStable(0.0)
59{
03896fc4 60 //
61 // constructor
62 //
b1c2e580 63 for(Int_t i=0; i<9; i++)
64 if(*(name+i) != '\0') fName[i] = *(name+i);
65 else break;
b1c2e580 66 for(Int_t i=0; i<kMaxDecayChannels; i++)
67 fDecayChannels[i] = new DecayChannel();
68}
69
03896fc4 70//________________________________________________________________________
b1c2e580 71ParticlePDG::~ParticlePDG() {
03896fc4 72 //
73 // destructor
74 //
b1c2e580 75 for(Int_t i=0; i<kMaxDecayChannels; i++)
76 delete fDecayChannels[i];
77}
78
03896fc4 79//________________________________________________________________________
b1c2e580 80Double_t ParticlePDG::GetFullBranching() {
03896fc4 81 //
82 // calculate the sum of branching ratios from all decay channels (should add up to 1)
83 //
b1c2e580 84 Double_t fullBranching = 0.0;
85 for(Int_t i=0; i<fNDecayChannels; i++)
86 fullBranching += fDecayChannels[i]->GetBranching();
87 return fullBranching;
88}
89
03896fc4 90//________________________________________________________________________
b1c2e580 91void ParticlePDG::AddChannel(DecayChannel* channel) {
03896fc4 92 //
93 // add a decay channel
94 //
b1c2e580 95 if(channel->GetMotherPDG() != fPDG) {
96 cout << "ERROR in ParticlePDG::AddChannel() : You try to add a channel which has a different mother PDG" << endl;
97 return;
98 }
99 fDecayChannels[fNDecayChannels]->SetMotherPDG(channel->GetMotherPDG());
100 fDecayChannels[fNDecayChannels]->SetBranching(channel->GetBranching());
101 fDecayChannels[fNDecayChannels]->SetDaughters(channel->GetDaughters(), channel->GetNDaughters());
102 fNDecayChannels++;
103}