BOSS 8.0.0
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 30 of file EvtMultiChannelParser.hh.

Constructor & Destructor Documentation

◆ EvtMultiChannelParser()

EvtMultiChannelParser::EvtMultiChannelParser ( )
inline

Definition at line 33 of file EvtMultiChannelParser.hh.

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

◆ ~EvtMultiChannelParser()

EvtMultiChannelParser::~EvtMultiChannelParser ( )
inline

Definition at line 34 of file EvtMultiChannelParser.hh.

34{}

Member Function Documentation

◆ amp()

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

Definition at line 50 of file EvtMultiChannelParser.hh.

50{ return _amp[i]; }

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

◆ ampCoef()

EvtComplex EvtMultiChannelParser::ampCoef ( int i) const
inline

Definition at line 52 of file EvtMultiChannelParser.hh.

52{ return _ampCoef[i]; }

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

◆ ampConj()

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

Definition at line 51 of file EvtMultiChannelParser.hh.

51{ return _ampConj[i]; }

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

◆ ampConjCoef()

EvtComplex EvtMultiChannelParser::ampConjCoef ( int i) const
inline

Definition at line 53 of file EvtMultiChannelParser.hh.

53{ return _ampConjCoef[i]; }

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

◆ coefConjFormat()

int EvtMultiChannelParser::coefConjFormat ( int i) const
inline

Definition at line 56 of file EvtMultiChannelParser.hh.

56{ return _coefConjFormat[i]; }

◆ coefFormat()

int EvtMultiChannelParser::coefFormat ( int i) const
inline

Definition at line 55 of file EvtMultiChannelParser.hh.

55{ return _coefFormat[i]; }

◆ dm()

double EvtMultiChannelParser::dm ( ) const
inline

Definition at line 48 of file EvtMultiChannelParser.hh.

48{ return _dm; }

◆ getDecayMode()

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

Definition at line 32 of file EvtMultiChannelParser.cc.

32 {
33 // Open file, read tokens
34
35 EvtParser parser;
36 parser.Read( file );
37
38 // Seek Decay
39
40 int i = 0;
41 int N = parser.getNToken();
42 while ( i < N )
43 {
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
60 std::string d = parser.getToken( i++ );
61
62 if ( EvtPDL::getStdHep( EvtPDL::getId( d.c_str() ) ) == 0 ) break;
63
64 dauV.push_back( string( d.c_str() ) );
65 }
66
67 EvtDecayMode mode( mother, dauV );
68 printf( "Decay File defines mode %s\n", mode.mode() );
69
70 return mode;
71}
char * file
Definition DQA_TO_DB.cxx:16
static int getStdHep(EvtId id)
Definition EvtPDL.hh:61
static EvtId getId(const std::string &name)
Definition EvtPDL.cc:272
int getNToken()
Definition EvtParser.cc:48
const std::string & getToken(int i)
Definition EvtParser.cc:50
int Read(const std::string filename)
Definition EvtParser.cc:54

◆ getNAmp()

int EvtMultiChannelParser::getNAmp ( ) const
inline

Definition at line 58 of file EvtMultiChannelParser.hh.

58{ return _amp.size(); }

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

◆ getNAmpConj()

int EvtMultiChannelParser::getNAmpConj ( ) const
inline

Definition at line 59 of file EvtMultiChannelParser.hh.

59{ return _ampConj.size(); }

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

◆ isKeyword()

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

Definition at line 263 of file EvtMultiChannelParser.cc.

263 {
264 if ( s == std::string( "AMPLITUDE" ) ) return true;
265 if ( s == std::string( "CONJUGATE" ) ) return true;
266 if ( s == std::string( "COEFFICIENT" ) ) return true;
267 return false;
268}
XmlRpcServer s

Referenced by parse().

◆ nScan()

int EvtMultiChannelParser::nScan ( ) const
inline

Definition at line 47 of file EvtMultiChannelParser.hh.

47{ return _nScan; }

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

◆ parse() [1/2]

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

Definition at line 73 of file EvtMultiChannelParser.cc.

73 {
74 // Open file, read tokens
75
76 EvtParser parser;
77 parser.Read( file );
78
79 // Get parameters (tokens between the model name and ;)
80
81 int i = 0;
82 int N = parser.getNToken();
83
84 // Seek the model name
85
86 while ( i < N )
87 {
88
89 std::string tok = parser.getToken( i++ );
90 if ( tok == std::string( model ) ) break;
91 }
92 if ( i == N )
93 {
94
95 printf( "No model %s found in decay file %s", model, file );
96 exit( 0 );
97 }
98
99 // Add all tokens up to a semicolon to vector
100
101 std::vector<std::string> v;
102 while ( i < N )
103 {
104
105 std::string tok = parser.getToken( i++ );
106 if ( tok == std::string( ";" ) ) break;
107 else v.push_back( tok );
108 }
109
110 if ( i == N )
111 {
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 120 of file EvtMultiChannelParser.cc.

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

◆ parseComplexCoef()

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

Definition at line 207 of file EvtMultiChannelParser.cc.

208 {
209 // place holder for strtod
210 char** tc = 0;
211
212 assert( v[i++] == std::string( "COEFFICIENT" ) );
213
214 if ( v[i] == std::string( "POLAR_DEG" ) )
215 {
216
217 double mag = strtod( v[i + 1].c_str(), tc );
218 double phaseRad = strtod( v[i + 2].c_str(), tc ) * EvtConst::pi / 180.0;
219 i += 3;
220 c = EvtComplex( mag * cos( phaseRad ), mag * sin( phaseRad ) );
221 format = POLAR_DEG;
222 }
223 else if ( v[i] == std::string( "POLAR_RAD" ) )
224 {
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
235 double re = strtod( v[i + 1].c_str(), tc );
236 double im = strtod( v[i + 2].c_str(), tc );
237 i += 3;
238 c = EvtComplex( re, im );
239 format = CARTESIAN;
240 }
241 else
242 {
243
244 printf( "Invalid format %s for complex coefficient\n", v[i].c_str() );
245 exit( 0 );
246 }
247}
static const double pi
Definition EvtConst.hh:27

Referenced by parse().

◆ parseRealCoef()

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

Definition at line 249 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" ) ) { value = strtod( v[i + 1].c_str(), tc ); }
255 else assert( 0 );
256
257 i += 2;
258
259 assert( value > 0. );
260 return value;
261}

◆ pdfMax()

double EvtMultiChannelParser::pdfMax ( ) const
inline

Definition at line 46 of file EvtMultiChannelParser.hh.

46{ return _pdfMax; }

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


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