#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) |
Private Attributes | |
double | _pdfMax |
int | _nScan |
double | _dm |
std::vector< std::vector< std::string > > | _amp |
std::vector< std::vector< std::string > > | _ampConj |
std::vector< EvtComplex > | _ampCoef |
std::vector< int > | _coefFormat |
std::vector< EvtComplex > | _ampConjCoef |
std::vector< int > | _coefConjFormat |
Definition at line 31 of file EvtMultiChannelParser.hh.
EvtMultiChannelParser::EvtMultiChannelParser | ( | ) | [inline] |
EvtMultiChannelParser::~EvtMultiChannelParser | ( | ) | [inline] |
std::vector<std::string> EvtMultiChannelParser::amp | ( | int | i | ) | const [inline] |
Definition at line 52 of file EvtMultiChannelParser.hh.
References _amp.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
EvtComplex EvtMultiChannelParser::ampCoef | ( | int | i | ) | const [inline] |
Definition at line 54 of file EvtMultiChannelParser.hh.
References _ampCoef.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
std::vector<std::string> EvtMultiChannelParser::ampConj | ( | int | i | ) | const [inline] |
Definition at line 53 of file EvtMultiChannelParser.hh.
References _ampConj.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
EvtComplex EvtMultiChannelParser::ampConjCoef | ( | int | i | ) | const [inline] |
Definition at line 55 of file EvtMultiChannelParser.hh.
References _ampConjCoef.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
00055 { return _ampConjCoef[i]; }
int EvtMultiChannelParser::coefConjFormat | ( | int | i | ) | const [inline] |
Definition at line 58 of file EvtMultiChannelParser.hh.
References _coefConjFormat.
00058 { return _coefConjFormat[i]; }
int EvtMultiChannelParser::coefFormat | ( | int | i | ) | const [inline] |
Definition at line 57 of file EvtMultiChannelParser.hh.
References _coefFormat.
00057 { return _coefFormat[i]; }
double EvtMultiChannelParser::dm | ( | ) | const [inline] |
EvtDecayMode EvtMultiChannelParser::getDecayMode | ( | const char * | file | ) | [static] |
Definition at line 32 of file EvtMultiChannelParser.cc.
References EvtPDL::getId(), EvtParser::getNToken(), EvtPDL::getStdHep(), EvtParser::getToken(), genRecEmupikp::i, EvtDecayMode::mode(), TrigConf::N, EvtParser::Read(), and deljobs::string.
00033 { 00034 // Open file, read tokens 00035 00036 EvtParser parser; 00037 parser.Read(file); 00038 00039 // Seek Decay 00040 00041 int i = 0; 00042 int N = parser.getNToken(); 00043 while(i<N) { 00044 00045 std::string tok = parser.getToken(i++); 00046 if(tok == std::string("Decay")) break; 00047 } 00048 00049 // Get mother 00050 00051 string mother = string(parser.getToken(i++).c_str()); 00052 std::string bf = parser.getToken(i++); 00053 00054 vector<string> dauV; 00055 // Get daughters 00056 00057 while(1) { 00058 00059 std::string d = parser.getToken(i++); 00060 00061 if(EvtPDL::getStdHep(EvtPDL::getId(d.c_str())) == 0) break; 00062 00063 dauV.push_back(string(d.c_str())); 00064 } 00065 00066 EvtDecayMode mode(mother,dauV); 00067 printf("Decay File defines mode %s\n",mode.mode()); 00068 00069 return mode; 00070 }
int EvtMultiChannelParser::getNAmp | ( | ) | const [inline] |
Definition at line 60 of file EvtMultiChannelParser.hh.
References _amp.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
00060 { return _amp.size(); }
int EvtMultiChannelParser::getNAmpConj | ( | ) | const [inline] |
Definition at line 61 of file EvtMultiChannelParser.hh.
References _ampConj.
Referenced by EvtAmpFactory< EvtDalitzPoint >::build().
00061 { return _ampConj.size(); }
bool EvtMultiChannelParser::isKeyword | ( | const std::string & | s | ) | [static] |
Definition at line 267 of file EvtMultiChannelParser.cc.
References deljobs::string.
Referenced by parse().
00268 { 00269 if(s == std::string("AMPLITUDE")) return true; 00270 if(s == std::string("CONJUGATE")) return true; 00271 if(s == std::string("COEFFICIENT")) return true; 00272 return false; 00273 }
int EvtMultiChannelParser::nScan | ( | ) | const [inline] |
Definition at line 49 of file EvtMultiChannelParser.hh.
References _nScan.
Referenced by EvtIntervalDecayAmp< EvtDalitzPoint >::init().
00049 { return _nScan; }
void EvtMultiChannelParser::parse | ( | const std::vector< std::string > & | v | ) |
Definition at line 121 of file EvtMultiChannelParser.cc.
References _amp, _ampCoef, _ampConj, _ampConjCoef, _coefConjFormat, _coefFormat, _dm, _nScan, _pdfMax, EvtCyclic3::c_str(), genRecEmupikp::i, isKeyword(), parseComplexCoef(), and deljobs::string.
00122 { 00123 // place holder for strtod 00124 char** tc = 0; 00125 00126 00127 // Get PDF maximum or number of points to 00128 // use in the scan. 00129 00130 if(v[0] == std::string("MAXPDF")) { 00131 00132 _pdfMax = strtod(v[1].c_str(),tc); 00133 if(_pdfMax <= 0) { printf("Bad pdfMax=%f\n",_pdfMax); assert(0); } 00134 } 00135 else 00136 if(v[0] == std::string("SCANPDF")) { 00137 00138 _nScan = atoi(v[1].c_str()); 00139 } 00140 else { 00141 00142 printf("Error parsing decay file\n"); 00143 assert(0); 00144 } 00145 00146 00147 // Now parse the rest of file for amplitude specifications. 00148 00149 bool conjugate = false; 00150 int i = 2; 00151 assert(isKeyword(v[2])); 00152 00153 while(i < v.size()) { 00154 00155 int i0 = i; 00156 00157 // Switch to conjugate amplitudes after keyword 00158 if(v[i] == std::string("CONJUGATE")) { 00159 00160 assert(conjugate == false); 00161 conjugate = true; 00162 assert(!isKeyword(v[++i])); 00163 _dm = strtod(v[i].c_str(),tc); 00164 i++; 00165 } 00166 00167 std::vector<std::string> params; 00168 EvtComplex c; 00169 int format; 00170 00171 if(!conjugate && v[i] == std::string("AMPLITUDE")) { 00172 00173 while(!isKeyword(v[++i])) params.push_back(v[i]); 00174 _amp.push_back(params); 00175 00176 parseComplexCoef(i,v,c,format); 00177 _ampCoef.push_back(c); 00178 _coefFormat.push_back(format); 00179 continue; 00180 } 00181 else 00182 if(conjugate && v[i] == std::string("AMPLITUDE")) { 00183 00184 while(!isKeyword(v[++i])) params.push_back(v[i]); 00185 _ampConj.push_back(params); 00186 parseComplexCoef(i,v,c,format); 00187 _ampConjCoef.push_back(c); 00188 _coefConjFormat.push_back(format); 00189 continue; 00190 } 00191 else { 00192 00193 printf("Expect keyword, found parameter %s\n",v[i].c_str()); 00194 assert(0); 00195 } 00196 00197 00198 assert(i > i0); 00199 } 00200 00201 printf("PARSING SUCCESSFUL\n"); 00202 printf("%d amplitude terms\n",_amp.size()); 00203 printf("%d conj amplitude terms\n",_ampConj.size()); 00204 }
void EvtMultiChannelParser::parse | ( | const char * | file, | |
const char * | model | |||
) |
Definition at line 74 of file EvtMultiChannelParser.cc.
References EvtParser::getNToken(), EvtParser::getToken(), genRecEmupikp::i, TrigConf::N, EvtParser::Read(), deljobs::string, and v.
Referenced by EvtIntervalDecayAmp< EvtDalitzPoint >::init().
00075 { 00076 // Open file, read tokens 00077 00078 EvtParser parser; 00079 parser.Read(file); 00080 00081 00082 // Get parameters (tokens between the model name and ;) 00083 00084 int i = 0; 00085 int N = parser.getNToken(); 00086 00087 // Seek the model name 00088 00089 while(i<N) { 00090 00091 std::string tok = parser.getToken(i++); 00092 if(tok == std::string(model)) break; 00093 } 00094 if(i == N) { 00095 00096 printf("No model %s found in decay file %s",model,file); 00097 exit(0); 00098 } 00099 00100 00101 // Add all tokens up to a semicolon to vector 00102 00103 std::vector<std::string> v; 00104 while(i<N) { 00105 00106 std::string tok = parser.getToken(i++); 00107 if(tok == std::string(";")) break; 00108 else v.push_back(tok); 00109 } 00110 00111 if(i == N) { 00112 00113 printf("No terminating ; found in decay file %s",file); 00114 assert(0); 00115 } 00116 00117 parse(v); 00118 }
void EvtMultiChannelParser::parseComplexCoef | ( | int & | i, | |
const std::vector< std::string > & | v, | |||
EvtComplex & | c, | |||
int & | format | |||
) | [static] |
Definition at line 208 of file EvtMultiChannelParser.cc.
References EvtCyclic3::c_str(), CARTESIAN, cos(), EvtConst::pi, POLAR_DEG, POLAR_RAD, sin(), and deljobs::string.
Referenced by parse().
00210 { 00211 // place holder for strtod 00212 char** tc = 0; 00213 00214 assert(v[i++] == std::string("COEFFICIENT")); 00215 00216 if(v[i] == std::string("POLAR_DEG")) { 00217 00218 double mag = strtod(v[i+1].c_str(),tc); 00219 double phaseRad = strtod(v[i+2].c_str(),tc)*EvtConst::pi/180.0; 00220 i += 3; 00221 c = EvtComplex(mag*cos(phaseRad),mag*sin(phaseRad)); 00222 format = POLAR_DEG; 00223 } 00224 else if(v[i] == std::string("POLAR_RAD")) { 00225 00226 double mag = strtod(v[i+1].c_str(),tc); 00227 double phaseRad = strtod(v[i+2].c_str(),tc); 00228 i += 3; 00229 c = EvtComplex(mag*cos(phaseRad),mag*sin(phaseRad)); 00230 format = POLAR_RAD; 00231 } 00232 else if(v[i] == std::string("CARTESIAN")) { 00233 00234 double re = strtod(v[i+1].c_str(),tc); 00235 double im = strtod(v[i+2].c_str(),tc); 00236 i += 3; 00237 c = EvtComplex(re,im); 00238 format = CARTESIAN; 00239 } 00240 else { 00241 00242 printf("Invalid format %s for complex coefficient\n",v[i].c_str()); 00243 exit(0); 00244 } 00245 }
double EvtMultiChannelParser::parseRealCoef | ( | int & | i, | |
const std::vector< std::string > & | v | |||
) | [static] |
Definition at line 248 of file EvtMultiChannelParser.cc.
References EvtCyclic3::c_str(), and deljobs::string.
00249 { 00250 // place holder for strtod 00251 char** tc = 0; 00252 double value = 0; 00253 00254 if(v[i] == std::string("COEFFICIENT")) { 00255 00256 value = strtod(v[i+1].c_str(),tc); 00257 } 00258 else assert(0); 00259 00260 i += 2; 00261 00262 assert(value > 0.); 00263 return value; 00264 }
double EvtMultiChannelParser::pdfMax | ( | ) | const [inline] |
Definition at line 48 of file EvtMultiChannelParser.hh.
References _pdfMax.
Referenced by EvtIntervalDecayAmp< EvtDalitzPoint >::init().
00048 { return _pdfMax; }
std::vector<std::vector<std::string> > EvtMultiChannelParser::_amp [private] |
Definition at line 69 of file EvtMultiChannelParser.hh.
std::vector<EvtComplex> EvtMultiChannelParser::_ampCoef [private] |
std::vector<std::vector<std::string> > EvtMultiChannelParser::_ampConj [private] |
Definition at line 70 of file EvtMultiChannelParser.hh.
Referenced by ampConj(), getNAmpConj(), and parse().
std::vector<EvtComplex> EvtMultiChannelParser::_ampConjCoef [private] |
std::vector<int> EvtMultiChannelParser::_coefConjFormat [private] |
Definition at line 74 of file EvtMultiChannelParser.hh.
Referenced by coefConjFormat(), and parse().
std::vector<int> EvtMultiChannelParser::_coefFormat [private] |
double EvtMultiChannelParser::_dm [private] |
int EvtMultiChannelParser::_nScan [private] |
double EvtMultiChannelParser::_pdfMax [private] |