GENIEGenerator
Loading...
Searching...
No Matches
BaryonResList.cxx
Go to the documentation of this file.
1//____________________________________________________________________________
2/*
3 Copyright (c) 2003-2025, The GENIE Collaboration
4 For the full text of the license visit http://copyright.genie-mc.org
5
6 Costas Andreopoulos <c.andreopoulos \at cern.ch>
7 University of Liverpool
8*/
9//____________________________________________________________________________
10
11#include <algorithm>
12
17
18using std::endl;
19
20using namespace genie;
21
22//____________________________________________________________________________
23namespace genie
24{
25 ostream & operator<<(ostream & stream, const BaryonResList & res_list)
26 {
27 res_list.Print(stream);
28 return stream;
29 }
30}
31//____________________________________________________________________________
36//____________________________________________________________________________
38{
39 fResVec = 0;
40 this->Copy(res_list);
41}
42//____________________________________________________________________________
47//____________________________________________________________________________
48unsigned int BaryonResList::NResonances(void) const
49{
50 if(!fResVec) {
51 SLOG("BaryonResList", pERROR) << "Null Resonance List";
52 return 0;
53 }
54 return fResVec->size();
55}
56//____________________________________________________________________________
57string BaryonResList::ResonanceName(unsigned int ires) const
58{
59 if(!fResVec) {
60 SLOG("BaryonResList", pERROR) << "Null Resonance List";
61 return "-";
62 }
63 if(ires >= this->NResonances() ) {
64 SLOG("BaryonResList", pERROR) << "Resonance idx: " << ires
65 << " outside limits: [0, " << this->NResonances() << "]";
66 return "-";
67 }
68 return utils::res::AsString( (*fResVec)[ires] );
69}
70//____________________________________________________________________________
72{
73 if(!fResVec) {
74 SLOG("BaryonResList", pERROR) << "Null Resonance List";
75 return kNoResonance;
76 }
77 if(ires >= this->NResonances() ) {
78 SLOG("BaryonResList", pERROR) << "Resonance idx: " << ires
79 << " outside limits: [0, " << this->NResonances() << "]";
80 return kNoResonance;
81 }
82 return (*fResVec)[ires];
83}
84//____________________________________________________________________________
85int BaryonResList::ResonancePdgCode(unsigned int /*ires*/) const
86{
87 return 0;
88}
89//____________________________________________________________________________
91{
92 if(!fResVec) {
93 SLOG("BaryonResList", pWARN) << "NULL resonance list!";
94 return false;
95 }
96 int n = count(fResVec->begin(), fResVec->end(), res);
97 if(n!=0) return true;
98 return false;
99}
100//___________________________________________________________________________
101void BaryonResList::DecodeFromNameList(string input_list, string delimiter)
102{
103 //-- remove all spaces in the input string coming from the XML config file
104
105 string list = utils::str::FilterString(" ", input_list);
106
107 vector<string> resonances = utils::str::Split(list, delimiter);
108
109 SLOG("BaryonResList", pINFO) << list;
110 SLOG("BaryonResList", pINFO) << resonances.size();
111
112 if(fResVec) delete fResVec;
113 fResVec = new vector<Resonance_t> (resonances.size());
114
115 unsigned int ires = 0;
116 vector<string>::const_iterator riter;
117 for(riter = resonances.begin(); riter != resonances.end(); ++riter) {
118
119 Resonance_t res = utils::res::FromString( (*riter).c_str() );
120 if( res == kNoResonance ) {
121 SLOG("BaryonResList", pERROR) << "*** Unknown resonance: " << *riter;
122 } else (*fResVec)[ires++] = res;
123 }
124}
125//____________________________________________________________________________
127{
128 if(fResVec) fResVec->clear();
129}
130//____________________________________________________________________________
131void BaryonResList::Copy(const BaryonResList & res_list)
132{
133 if(fResVec) fResVec->clear();
134
135 unsigned int nres = res_list.NResonances();
136 if(nres==0) return;
137
138 if(!fResVec) fResVec = new vector<Resonance_t> (nres);
139
140 for(unsigned int ires = 0; ires < nres; ires++) {
141 (*fResVec)[ires] = res_list.ResonanceId(ires);
142 }
143}
144//____________________________________________________________________________
145void BaryonResList::Print(ostream & stream) const
146{
147 stream << "\n [-] Resonance List\n";
148
149 vector<Resonance_t>::const_iterator riter;
150 for(riter = fResVec->begin(); riter != fResVec->end(); ++riter) {
151 stream << " |--> RES: " << utils::res::AsString(*riter) << endl;
152 }
153}
154//____________________________________________________________________________
155auto BaryonResList::begin() noexcept -> typename vector<Resonance_t>::iterator
156{
157 return fResVec->begin();
158}
159//____________________________________________________________________________
160auto BaryonResList::end() noexcept -> typename vector<Resonance_t>::iterator
161{
162 return fResVec->end();
163}
164//____________________________________________________________________________
165auto BaryonResList::begin() const noexcept -> typename vector<Resonance_t>::const_iterator
166{
167 return fResVec->begin();
168}
169//____________________________________________________________________________
170auto BaryonResList::end() const noexcept -> typename vector<Resonance_t>::const_iterator
171{
172 return fResVec->end();
173}
174//____________________________________________________________________________
175auto BaryonResList::cbegin() const noexcept -> typename vector<Resonance_t>::const_iterator
176{
177 return fResVec->cbegin();
178}
179//____________________________________________________________________________
180auto BaryonResList::cend() const noexcept -> typename vector<Resonance_t>::const_iterator
181{
182 return fResVec->cend();
183}
184//____________________________________________________________________________
185
#define pINFO
Definition Messenger.h:62
#define pERROR
Definition Messenger.h:59
#define pWARN
Definition Messenger.h:60
#define SLOG(stream, priority)
A macro that returns the requested log4cpp::Category appending a short string (using the FUNCTION and...
Definition Messenger.h:84
void Print(ostream &stream) const
auto begin() noexcept -> typename vector< Resonance_t >::iterator
auto cend() const noexcept -> typename vector< Resonance_t >::const_iterator
bool Find(Resonance_t res) const
int ResonancePdgCode(unsigned int ires) const
void Copy(const BaryonResList &rl)
void DecodeFromNameList(string list, string delimiter=",")
Resonance_t ResonanceId(unsigned int ires) const
string ResonanceName(unsigned int ires) const
vector< Resonance_t > * fResVec
auto end() noexcept -> typename vector< Resonance_t >::iterator
auto cbegin() const noexcept -> typename vector< Resonance_t >::const_iterator
unsigned int NResonances(void) const
Resonance_t FromString(const char *res)
string -> resonance id
const char * AsString(Resonance_t res)
resonance id -> string
string FilterString(string filt, string input)
vector< string > Split(string input, string delim)
THE MAIN GENIE PROJECT NAMESPACE
Definition AlgCmp.h:25
enum genie::EResonance Resonance_t
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)