00001 #include "kernel_chooser.h" 00002 #include "message.h" 00003 #include "constants.h" 00004 00005 bool pair_match(string p1a, string p2a, string p1b, string p2b){ 00006 string pairb(p1b+p2b); 00007 return (((p1a+p2a)==pairb)||((p2a+p1a)==pairb)); 00008 } 00009 00010 CKernel* chooseKernel(string particle1, string particle2, const parameterMap& m){ 00011 string kdatadirname; 00012 bool use_cache(false); 00013 bool read_cache(false); 00014 bool hbt_only(false); 00015 00016 string parsfilename = parameter::getS(m,"param_filename",""); 00017 if (m.find("use_cache")!=m.end()) { 00018 use_cache=parameter::getB(m,"use_cache"); 00019 read_cache = parameter::getB(m,"read_cache",read_cache); 00020 kdatadirname = parameter::getS(m,"kernel_cache","kernel_cache"); 00021 } 00022 hbt_only = parameter::getB(m,"hbt_only",hbt_only); 00023 00024 CWaveFunction *wf; 00025 00026 if (!hbt_only) { 00027 if (pair_match(particle1,particle2,"pi+","pi+")) {wf=new CWaveFunction_pipluspiplus_sqwell(parsfilename);} 00028 else if (pair_match(particle1,particle2,"pi-","pi-")) {wf=new CWaveFunction_pipluspiplus_sqwell(parsfilename);} 00029 else if (pair_match(particle1,particle2,"pi+","pi-")) {wf=new CWaveFunction_pipluspiminus_sqwell(parsfilename);} 00030 else if (pair_match(particle1,particle2,"p","K+")) {wf=new CWaveFunction_pkplus_sqwell(parsfilename);} 00031 else if (pair_match(particle1,particle2,"p","pi+")) {wf=new CWaveFunction_ppiplus_sqwell(parsfilename);} 00032 else if (pair_match(particle1,particle2,"p","p")) {wf=new CWaveFunction_pp_schrod(parsfilename);} 00033 else if (pair_match(particle1,particle2,"K+","K+")) {wf=new CWaveFunction_generic(parsfilename,1,KaonMass,KaonMass,1.0);} 00034 else {throw MESSAGE << "Cannot compute kernel for \""<<particle1<<"\" and \""<<particle2<<"\""<<ENDM_FATAL;} 00035 00036 /* 00037 if (pair_match(particle1,particle2,"Xi","pi")) { 00038 kdatadirname="parameters/wfparameters_Xipi.dat"; 00039 wf=new CWaveFunction_Xipi(const_cast<char*>(parsfilename.c_str())); 00040 } else if (pair_match(particle1,particle2,"K+","pi-")) { 00041 kdatadirname="parameters/wfparameters_kpluspiminus.dat"; 00042 wf=new CWaveFunction_kpluspiminus(const_cast<char*>(parsfilename.c_str())); 00043 } else if (pair_match(particle1,particle2,"Lambda","Lambda")) { 00044 kdatadirname="parameters/wfparameters_lambdalambda.dat"; 00045 wf=new CWaveFunction_lambdalambda(const_cast<char*>(parsfilename.c_str())); 00046 } else if (pair_match(particle1,particle2,"n","n")) { 00047 kdatadirname="parameters/wfparameters_nn.dat"; 00048 wf=new CWaveFunction_nn(const_cast<char*>(parsfilename.c_str())); 00049 } else if (pair_match(particle1,particle2,"pi+","pi-")) { 00050 kdatadirname="parameters/wfparameters_pipluspiminus.dat"; 00051 wf=new CWaveFunction_pipluspiminus(const_cast<char*>(parsfilename.c_str())); 00052 } else if (pair_match(particle1,particle2,"pi+","pi+")) { 00053 kdatadirname="parameters/wfparameters_pipluspiplus.dat"; 00054 wf=new CWaveFunction_pipluspiplus(const_cast<char*>(parsfilename.c_str())); 00055 } else if (pair_match(particle1,particle2,"pi-","pi-")) { 00056 kdatadirname="parameters/wfparameters_piminuspiminus.dat"; 00057 wf=new CWaveFunction_pipluspiplus(const_cast<char*>(parsfilename.c_str())); 00058 } else if (pair_match(particle1,particle2,"K+","K+")) { 00059 kdatadirname="parameters/wfparameters_.dat"; 00060 wf=new CWaveFunction_pp(const_cast<char*>(parsfilename.c_str())); 00061 } else if (pair_match(particle1,particle2,"K-","K-")) { 00062 kdatadirname="parameters/wfparameters_.dat"; 00063 wf=new CWaveFunction_pp(const_cast<char*>(parsfilename.c_str())); 00064 } else if (pair_match(particle1,particle2,"K+","K-")) { 00065 kdatadirname="parameters/wfparameters_.dat"; 00066 wf=new CWaveFunction_pp(const_cast<char*>(parsfilename.c_str())); 00067 } else if (pair_match(particle1,particle2,"p","K+")) { 00068 kdatadirname="parameters/wfparameters_pkplus.dat"; 00069 wf=new CWaveFunction_pkplus(const_cast<char*>(parsfilename.c_str())); 00070 } else if (pair_match(particle1,particle2,"p","Lambda")) { 00071 kdatadirname="parameters/wfparameters_plambda.dat"; 00072 wf=new CWaveFunction_plambda(const_cast<char*>(parsfilename.c_str())); 00073 } else if (pair_match(particle1,particle2,"p","n")) { 00074 string kdatadirname="parameters/wfparameters_pn.dat"; 00075 wf=new CWaveFunction_pn(const_cast<char*>(parsfilename.c_str())); 00076 } else if (pair_match(particle1,particle2,"p","p")) { 00077 string kdatadirname="parameters/wfparameters_pp.dat"; 00078 wf=new CWaveFunction_pp(const_cast<char*>(parsfilename.c_str())); 00079 } else if (pair_match(particle1,particle2,"p","pi+")) { 00080 string kdatadirname="parameters/wfparameters_ppiplus.dat"; 00081 wf=new CWaveFunction_ppiplus(const_cast<char*>(parsfilename.c_str())); 00082 } else if (pair_match(particle1,particle2,"pi0","pi0")) { 00083 hbt_only=true; 00084 kdatadirname="parameters/wfparameters_pipluspiplus.dat"; 00085 wf=new CWaveFunction_pipluspiplus(const_cast<char*>(parsfilename.c_str())); 00086 } else { 00087 throw MESSAGE << "Cannot compute kernel for "<<particle1<<" "<<particle2<<ENDM_FATAL; 00088 } 00089 */ 00090 } 00091 00092 CKernel* kernel; 00093 cout << endl; 00094 if (hbt_only) { 00095 cout << "Kernel for pure HBT" <<endl; 00096 kernel = new CKernelExactHBT(parsfilename); 00097 if (!kernel) throw MESSAGE << "Kernel creation failed!"<<ENDM_FATAL; 00098 } 00099 else { 00100 cout << "Kernel for particle1, particle2 = "<<particle1<<", "<<particle2<<endl; 00101 kernel = new CKernel(parsfilename); 00102 if (!kernel) throw MESSAGE << "Kernel creation failed!"<<ENDM_FATAL; 00103 if (read_cache) { 00104 cout << " Reading kernel cache... "<<endl; 00105 kernel->ReadData(kdatadirname); 00106 } 00107 else kernel->Calc(wf); 00108 if (!read_cache && use_cache) kernel->WriteData(kdatadirname); 00109 } 00110 cout << endl; 00111 00112 return kernel; 00113 }