CGEM BOSS 6.6.5.g
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtMultiChannelParser Class Reference

#include <EvtMultiChannelParser.hh>

Public Member Functions

 EvtMultiChannelParser ()
 
 ~EvtMultiChannelParser ()
 
void parse (const char *file, const char *model)
 
void parse (const std::vector< std::string > &v)
 
double pdfMax () const
 
int nScan () const
 
double dm () const
 
std::vector< std::string > amp (int i) const
 
std::vector< std::string > ampConj (int i) const
 
EvtComplex ampCoef (int i) const
 
EvtComplex ampConjCoef (int i) const
 
int coefFormat (int i) const
 
int coefConjFormat (int i) const
 
int getNAmp () const
 
int getNAmpConj () const
 

Static Public Member Functions

static EvtDecayMode getDecayMode (const char *file)
 
static void parseComplexCoef (int &i, const std::vector< std::string > &v, EvtComplex &c, int &format)
 
static double parseRealCoef (int &i, const std::vector< std::string > &v)
 
static bool isKeyword (const std::string &s)
 

Detailed Description

Definition at line 31 of file EvtMultiChannelParser.hh.

Constructor & Destructor Documentation

◆ EvtMultiChannelParser()

EvtMultiChannelParser::EvtMultiChannelParser ( )
inline

Definition at line 35 of file EvtMultiChannelParser.hh.

35: _pdfMax(-1.), _nScan(0), _dm(0.) {}

◆ ~EvtMultiChannelParser()

EvtMultiChannelParser::~EvtMultiChannelParser ( )
inline

Definition at line 36 of file EvtMultiChannelParser.hh.

36{}

Member Function Documentation

◆ amp()

std::vector< std::string > EvtMultiChannelParser::amp ( int  i) const
inline

Definition at line 52 of file EvtMultiChannelParser.hh.

52{ return _amp[i]; }

Referenced by EvtAmpFactory< T >::build().

◆ ampCoef()

EvtComplex EvtMultiChannelParser::ampCoef ( int  i) const
inline

Definition at line 54 of file EvtMultiChannelParser.hh.

54{ return _ampCoef[i]; }

Referenced by EvtAmpFactory< T >::build().

◆ ampConj()

std::vector< std::string > EvtMultiChannelParser::ampConj ( int  i) const
inline

Definition at line 53 of file EvtMultiChannelParser.hh.

53{ return _ampConj[i]; }

Referenced by EvtAmpFactory< T >::build().

◆ ampConjCoef()

EvtComplex EvtMultiChannelParser::ampConjCoef ( int  i) const
inline

Definition at line 55 of file EvtMultiChannelParser.hh.

55{ return _ampConjCoef[i]; }

Referenced by EvtAmpFactory< T >::build().

◆ coefConjFormat()

int EvtMultiChannelParser::coefConjFormat ( int  i) const
inline

Definition at line 58 of file EvtMultiChannelParser.hh.

58{ return _coefConjFormat[i]; }

◆ coefFormat()

int EvtMultiChannelParser::coefFormat ( int  i) const
inline

Definition at line 57 of file EvtMultiChannelParser.hh.

57{ return _coefFormat[i]; }

◆ dm()

double EvtMultiChannelParser::dm ( ) const
inline

Definition at line 50 of file EvtMultiChannelParser.hh.

50{ return _dm; }

◆ getDecayMode()

EvtDecayMode EvtMultiChannelParser::getDecayMode ( const char *  file)
static

Definition at line 32 of file EvtMultiChannelParser.cc.

33{
34 // Open file, read tokens
35
36 EvtParser parser;
37 parser.Read(file);
38
39 // Seek Decay
40
41 int i = 0;
42 int N = parser.getNToken();
43 while(i<N) {
44
45 std::string tok = parser.getToken(i++);
46 if(tok == std::string("Decay")) break;
47 }
48
49 // Get mother
50
51 string mother = string(parser.getToken(i++).c_str());
52 std::string bf = parser.getToken(i++);
53
54 vector<string> dauV;
55 // Get daughters
56
57 while(1) {
58
59 std::string d = parser.getToken(i++);
60
61 if(EvtPDL::getStdHep(EvtPDL::getId(d.c_str())) == 0) break;
62
63 dauV.push_back(string(d.c_str()));
64 }
65
66 EvtDecayMode mode(mother,dauV);
67 printf("Decay File defines mode %s\n",mode.mode());
68
69 return mode;
70}
static int getStdHep(EvtId id)
Definition: EvtPDL.hh:56
static EvtId getId(const std::string &name)
Definition: EvtPDL.cc:287
int getNToken()
Definition: EvtParser.cc:51
const std::string & getToken(int i)
Definition: EvtParser.cc:57
int Read(const std::string filename)
Definition: EvtParser.cc:69

◆ getNAmp()

int EvtMultiChannelParser::getNAmp ( ) const
inline

Definition at line 60 of file EvtMultiChannelParser.hh.

60{ return _amp.size(); }

Referenced by EvtAmpFactory< T >::build().

◆ getNAmpConj()

int EvtMultiChannelParser::getNAmpConj ( ) const
inline

Definition at line 61 of file EvtMultiChannelParser.hh.

61{ return _ampConj.size(); }

Referenced by EvtAmpFactory< T >::build().

◆ isKeyword()

bool EvtMultiChannelParser::isKeyword ( const std::string &  s)
static

Definition at line 267 of file EvtMultiChannelParser.cc.

268{
269 if(s == std::string("AMPLITUDE")) return true;
270 if(s == std::string("CONJUGATE")) return true;
271 if(s == std::string("COEFFICIENT")) return true;
272 return false;
273}
XmlRpcServer s
Definition: HelloServer.cpp:11

Referenced by parse().

◆ nScan()

int EvtMultiChannelParser::nScan ( ) const
inline

Definition at line 49 of file EvtMultiChannelParser.hh.

49{ return _nScan; }

Referenced by EvtIntervalDecayAmp< T >::init().

◆ parse() [1/2]

void EvtMultiChannelParser::parse ( const char *  file,
const char *  model 
)

Definition at line 74 of file EvtMultiChannelParser.cc.

75{
76 // Open file, read tokens
77
78 EvtParser parser;
79 parser.Read(file);
80
81
82 // Get parameters (tokens between the model name and ;)
83
84 int i = 0;
85 int N = parser.getNToken();
86
87 // Seek the model name
88
89 while(i<N) {
90
91 std::string tok = parser.getToken(i++);
92 if(tok == std::string(model)) break;
93 }
94 if(i == N) {
95
96 printf("No model %s found in decay file %s",model,file);
97 exit(0);
98 }
99
100
101 // Add all tokens up to a semicolon to vector
102
103 std::vector<std::string> v;
104 while(i<N) {
105
106 std::string tok = parser.getToken(i++);
107 if(tok == std::string(";")) break;
108 else v.push_back(tok);
109 }
110
111 if(i == N) {
112
113 printf("No terminating ; found in decay file %s",file);
114 assert(0);
115 }
116
117 parse(v);
118}
**********Class see also m_nmax DOUBLE PRECISION m_amel DOUBLE PRECISION m_x2 DOUBLE PRECISION m_alfinv DOUBLE PRECISION m_Xenph INTEGER m_KeyWtm INTEGER m_idyfs DOUBLE PRECISION m_zini DOUBLE PRECISION m_q2 DOUBLE PRECISION m_Wt_KF DOUBLE PRECISION m_WtCut INTEGER m_KFfin *COMMON c_KarLud $ !Input CMS energy[GeV] $ !CMS energy after beam spread beam strahlung[GeV] $ !Beam energy spread[GeV] $ !z boost due to beam spread $ !electron beam mass *ff pair spectrum $ !minimum v
Definition: KarLud.h:35
void parse(const char *file, const char *model)

Referenced by EvtIntervalDecayAmp< T >::init(), and parse().

◆ parse() [2/2]

void EvtMultiChannelParser::parse ( const std::vector< std::string > &  v)

Definition at line 121 of file EvtMultiChannelParser.cc.

122{
123 // place holder for strtod
124 char** tc = 0;
125
126
127 // Get PDF maximum or number of points to
128 // use in the scan.
129
130 if(v[0] == std::string("MAXPDF")) {
131
132 _pdfMax = strtod(v[1].c_str(),tc);
133 if(_pdfMax <= 0) { printf("Bad pdfMax=%f\n",_pdfMax); assert(0); }
134 }
135 else
136 if(v[0] == std::string("SCANPDF")) {
137
138 _nScan = atoi(v[1].c_str());
139 }
140 else {
141
142 printf("Error parsing decay file\n");
143 assert(0);
144 }
145
146
147 // Now parse the rest of file for amplitude specifications.
148
149 bool conjugate = false;
150 int i = 2;
151 assert(isKeyword(v[2]));
152
153 while(i < v.size()) {
154
155 int i0 = i;
156
157 // Switch to conjugate amplitudes after keyword
158 if(v[i] == std::string("CONJUGATE")) {
159
160 assert(conjugate == false);
161 conjugate = true;
162 assert(!isKeyword(v[++i]));
163 _dm = strtod(v[i].c_str(),tc);
164 i++;
165 }
166
167 std::vector<std::string> params;
168 EvtComplex c;
169 int format;
170
171 if(!conjugate && v[i] == std::string("AMPLITUDE")) {
172
173 while(!isKeyword(v[++i])) params.push_back(v[i]);
174 _amp.push_back(params);
175
176 parseComplexCoef(i,v,c,format);
177 _ampCoef.push_back(c);
178 _coefFormat.push_back(format);
179 continue;
180 }
181 else
182 if(conjugate && v[i] == std::string("AMPLITUDE")) {
183
184 while(!isKeyword(v[++i])) params.push_back(v[i]);
185 _ampConj.push_back(params);
186 parseComplexCoef(i,v,c,format);
187 _ampConjCoef.push_back(c);
188 _coefConjFormat.push_back(format);
189 continue;
190 }
191 else {
192
193 printf("Expect keyword, found parameter %s\n",v[i].c_str());
194 assert(0);
195 }
196
197
198 assert(i > i0);
199 }
200
201 printf("PARSING SUCCESSFUL\n");
202 printf("%d amplitude terms\n",_amp.size());
203 printf("%d conj amplitude terms\n",_ampConj.size());
204}
static void parseComplexCoef(int &i, const std::vector< std::string > &v, EvtComplex &c, int &format)
static bool isKeyword(const std::string &s)
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ parseComplexCoef()

void EvtMultiChannelParser::parseComplexCoef ( int &  i,
const std::vector< std::string > &  v,
EvtComplex c,
int &  format 
)
static

Definition at line 208 of file EvtMultiChannelParser.cc.

210{
211 // place holder for strtod
212 char** tc = 0;
213
214 assert(v[i++] == std::string("COEFFICIENT"));
215
216 if(v[i] == std::string("POLAR_DEG")) {
217
218 double mag = strtod(v[i+1].c_str(),tc);
219 double phaseRad = strtod(v[i+2].c_str(),tc)*EvtConst::pi/180.0;
220 i += 3;
221 c = EvtComplex(mag*cos(phaseRad),mag*sin(phaseRad));
222 format = POLAR_DEG;
223 }
224 else if(v[i] == std::string("POLAR_RAD")) {
225
226 double mag = strtod(v[i+1].c_str(),tc);
227 double phaseRad = strtod(v[i+2].c_str(),tc);
228 i += 3;
229 c = EvtComplex(mag*cos(phaseRad),mag*sin(phaseRad));
230 format = POLAR_RAD;
231 }
232 else if(v[i] == std::string("CARTESIAN")) {
233
234 double re = strtod(v[i+1].c_str(),tc);
235 double im = strtod(v[i+2].c_str(),tc);
236 i += 3;
237 c = EvtComplex(re,im);
238 format = CARTESIAN;
239 }
240 else {
241
242 printf("Invalid format %s for complex coefficient\n",v[i].c_str());
243 exit(0);
244 }
245}
double sin(const BesAngle a)
Definition: BesAngle.h:210
double cos(const BesAngle a)
Definition: BesAngle.h:213
static const double pi
Definition: EvtConst.hh:28

Referenced by parse().

◆ parseRealCoef()

double EvtMultiChannelParser::parseRealCoef ( int &  i,
const std::vector< std::string > &  v 
)
static

Definition at line 248 of file EvtMultiChannelParser.cc.

249{
250 // place holder for strtod
251 char** tc = 0;
252 double value = 0;
253
254 if(v[i] == std::string("COEFFICIENT")) {
255
256 value = strtod(v[i+1].c_str(),tc);
257 }
258 else assert(0);
259
260 i += 2;
261
262 assert(value > 0.);
263 return value;
264}

◆ pdfMax()

double EvtMultiChannelParser::pdfMax ( ) const
inline

Definition at line 48 of file EvtMultiChannelParser.hh.

48{ return _pdfMax; }

Referenced by EvtIntervalDecayAmp< T >::init().


The documentation for this class was generated from the following files: