Coverity fixes
[u/mrichter/AliRoot.git] / TUHKMgen / UHKM / DecayChannel.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 decays 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#include <iostream>
13using std::cout;
14using std::endl;
15
03896fc4 16#include "DecayChannel.h"
17
18//_______________________________________________________________________________
786056a2 19DecayChannel::DecayChannel() :
20 fMotherPDG(kNonsensePDG),
21 fBranchingRatio(0.0),
22 fNDaughters(0)
23{
03896fc4 24 //
25 // default constructor
26 //
b1c2e580 27 for(Int_t i=0; i<kMaxDaughters; i++)
28 fDaughtersPDG[i] = kNonsensePDG;
29}
30
03896fc4 31//_______________________________________________________________________________
786056a2 32DecayChannel::DecayChannel(const DecayChannel &copy):
33 fMotherPDG(copy.fMotherPDG),
34 fBranchingRatio(copy.fBranchingRatio),
35 fNDaughters(copy.fNDaughters)
36{
03896fc4 37 //
38 // copy constructor
39 //
b7dbe0fd 40 for(Int_t i=0; i<kMaxDaughters; i++)
b1c2e580 41 fDaughtersPDG[i] = copy.fDaughtersPDG[i];
42}
43
03896fc4 44//_______________________________________________________________________________
45DecayChannel::DecayChannel(Int_t mother, Double_t branching, Int_t nDaughters, const Int_t *daughters):
786056a2 46 fMotherPDG(mother),
47 fBranchingRatio(branching),
48 fNDaughters(0)
49{
03896fc4 50 //
51 // constructor
52 //
b7dbe0fd 53 for(Int_t i=0; i<kMaxDaughters; i++) {
b7dbe0fd 54 if(i<nDaughters)
55 fDaughtersPDG[fNDaughters++] = *(daughters+i);
56 else
57 fDaughtersPDG[i] = kNonsensePDG;
b1c2e580 58 }
59}
60
03896fc4 61//_______________________________________________________________________________
62void DecayChannel::SetDaughters(const Int_t *daughters, Int_t n) {
63 //
64 // set the daughter PDGs
65 //
b1c2e580 66 for(Int_t i=0; i<n; i++) {
67 if(i >= kMaxDaughters) {
68 cout << "ERROR in DecayChannel::SetDaughters() :" << endl;
69 cout << "Number of daughters bigger than the maximum allowed one (" << kMaxDaughters << ") !!" << endl;
70 }
71 fDaughtersPDG[fNDaughters++] = *(daughters+i);
72 }
73}
74
03896fc4 75//_______________________________________________________________________________
b1c2e580 76void DecayChannel::AddDaughter(Int_t pdg) {
03896fc4 77 //
78 // add a daughter to this channel
79 //
b1c2e580 80 if(fNDaughters >= kMaxDaughters) {
81 cout << "ERROR in DecayChannel::AddDaughter() :" << endl;
82 cout << "Number of daughters is already >= than the maximum allowed one (" << kMaxDaughters << ") !!" << endl;
83 }
84 fDaughtersPDG[fNDaughters++] = pdg;
85}
86
03896fc4 87
88//_______________________________________________________________________________
b1c2e580 89Int_t DecayChannel::GetDaughterPDG(Int_t i) {
03896fc4 90 //
91 // get the PDG of the i'th daughter
92 //
b1c2e580 93 if((i >= fNDaughters) || (i<0)) {
94 cout << "ERROR in DecayChannel::GetDaughterPDG() :" << endl;
95 cout << "Daughter index required is too big or less than zero!! There are only " << fNDaughters << " secondaries in this channel !!" << endl;
96 return kNonsensePDG;
97 }
98 return fDaughtersPDG[i];
99}
100