Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

w_ext_mesonBE.C

Go to the documentation of this file.
00001 #include<config.h>
00002 CPS_START_NAMESPACE
00008 /*w_ext_mesonBE.C
00009  *
00010  */
00011 
00012 CPS_END_NAMESPACE
00013 #include <alg/w_all.h>
00014 #include <alg/w_gamma_mat.h>
00015 #ifdef PARALLEL
00016 #include <comms/sysfunc_cps.h>
00017 #endif
00018 #include <util/error.h>                // ERR
00019 #include <util/qcdio.h>                // ERR
00020 #include <util/verbose.h>              // VRB
00021 #include <util/vector.h>               // dotProduct
00022 #include <comms/glb.h>                   // glb_sum
00023 #include <alg/alg_w_spect.h>          // AlgWspect::GetCounter()
00024 #include <comms/cbuf.h> 
00025 
00026 CPS_START_NAMESPACE
00027 
00028 //for debugging
00029 #define DEBUG_W_EXT_MESON_BE
00030 
00031 #define MATRIX_SIZE 18
00032 
00033 
00034 
00035 //+++++++++++++++++++++++++++Major Functions++++++++++++++++++++++
00036 
00037 //======================================================================
00038 //Static Member Declarations
00039 //======================================================================
00040 char *WspectExtendedMesonsBE::d_class_name="WspectExtendedMesonsBE";   
00041 int WspectExtendedMesonsBE::tableInitialized=0;
00042 struct WMesonBEOpInfo
00043       WspectExtendedMesonsBE::WMesonOpTable[NUM_WEXTMESON_BE_OPS];
00044 struct WMesonBEStateInfo
00045       WspectExtendedMesonsBE::WMesonStateTable[NUM_WEXTMESON_BE_STATES];
00046 
00047 //-------------------
00048 // CTOR
00049 //-------------------
00050 WspectExtendedMesonsBE::WspectExtendedMesonsBE(WspectArg *w_arg_p,
00051                                                const WspectHyperRectangle & whr, 
00052                                                const int fuzzing_id,
00053                                                const WspectField *field_ptr)
00054   : WspectExtendedMesons(w_arg_p,whr,fuzzing_id),field_p(field_ptr){
00055 
00056   //-----------------------------------
00057   //allocate memory for correlators
00058   //-----------------------------------
00059   d_size   = d_glb_walls* NUM_WEXTMESON_BE_STATES * COMPLEXs; //correlator array in Float
00060   d_output_size   = d_glb_walls* NUM_WEXTMESON_BE_OUTPUT * COMPLEXs; //corrlator(polarisation average)in Float
00061   
00062    coor_data_p = (Complex *) smalloc(d_size * sizeof(Float));
00063   if (!coor_data_p) 
00064     ERR.Pointer(d_class_name, ctor_str, "coor_data_p");
00065   VRB.Smalloc(d_class_name, ctor_str, 
00066               "coor_data_p", coor_data_p, d_size * sizeof(Float));
00067   {
00068     //zero out correlators
00069     Float *flt_p = (Float *)coor_data_p;
00070     for (int i = 0; i < d_size; ++i)
00071       *flt_p++ = 0.0;
00072   }
00073 
00074   coor_output_p = (Complex *) smalloc(d_output_size * sizeof(Float));
00075   if (!coor_output_p) 
00076     ERR.Pointer(d_class_name, ctor_str, "coor_output_p");
00077   VRB.Smalloc(d_class_name, ctor_str, 
00078               "coor_output_p", coor_output_p, d_output_size * sizeof(Float));
00079   {
00080     //zero out correlators
00081     Float *flt_p = (Float *)coor_output_p;
00082     for (int i = 0; i < d_output_size; ++i)
00083       *flt_p++ = 0.0;
00084   }
00085 
00086  
00087   
00088 
00089   {
00090     //initialize map
00092     //for now assume prop_dir==3 only
00093     //should do manually mapping from coor_data_p (calculated aussuming prop==3)
00094     //to output data files later
00095     for(int i=0;i<NUM_WEXTMESON_BE_STATES;i++){
00096       map[i]=i; //if prop_dir=3(T)
00097     }
00098   }
00099   
00100   //initialize the stateTable according to spect argument
00101   if(!tableInitialized){
00102     initWMesonOpTable();
00103     initWMesonStateTable(arg_p);
00104     tableInitialized=1;
00105   }
00106   
00107 }
00108 
00109 //--------------------
00110 // DTOR
00111 //--------------------
00112 WspectExtendedMesonsBE::~WspectExtendedMesonsBE(){
00113 //deallocate memory
00114   VRB.Func(d_class_name, dtor_str);
00115 
00116   VRB.Sfree(d_class_name, dtor_str, empty_str, coor_data_p);
00117   sfree(coor_data_p);
00118   
00119   
00120   VRB.Sfree(d_class_name, dtor_str, empty_str, coor_output_p);
00121   sfree(coor_output_p);
00122   
00123 
00124   
00125 }
00126 
00127 
00128 
00129 //-----------------
00130 // collect
00131 //-----------------
00132 void WspectExtendedMesonsBE::collect(const WspectQuark &q_l, WspectQuark &q_nl){
00133     
00134   char *fname="collect";
00135   VRB.Func(d_class_name, fname);
00136   
00137   DEVOperatorKind sour_op;
00138   sour_op=q_nl.srcOpKind();
00139  
00140 #ifdef  DEBUG_W_EXT_MESON_BE
00141   printf("colleting BE extmesons - source operator = %d \n", sour_op);
00142 #endif
00143  
00144   const Float *ql_p=(Float *)q_l.Data(); //local propagator
00145   const Float *qnl_p=(Float *)q_nl.Data(); //non_local propagator
00146 
00147   for(int sink_op=BEGIN_BE_OP+1; sink_op < END_BE_OP; sink_op++){ 
00148     //check 
00149     Float weight_test=0.;
00150     int state=0;
00151 
00152     while (weight_test==0. && state <NUM_WEXTMESON_BE_STATES ){
00153       weight_test = table(state, -1, sour_op, -1, sink_op);
00154       state += 1; // test next state
00155     } // endwhile (weight_test != 0)
00156     
00157     if (weight_test == 0.) continue; 
00158 
00159     int lclWalls=lcl_sites[d_prop_dir];
00160     for(int lclW=0;lclW<lclWalls;lclW++){
00161       DiracAlgebra(ql_p,qnl_p,lclW, sour_op, sink_op); 
00162     }
00163   }
00164   return;
00165   
00166 }
00167 
00168 //-------------------
00169 // doAllAlgebra
00170 //--------------------
00171 
00172 
00173 //-------------------
00174 // DiracAlgebra
00175 //--------------------
00176 
00177 
00178 //---------------------
00179 // finish
00180 //--------------------
00181 void WspectExtendedMesonsBE::finish(){
00182   //do global sum of Complex coor_data_p[glbwall][meson]
00183 #ifdef DEBUG_W_EXT_MESON_BE
00184   printf("finish().Do global sum.\n");
00185 #endif
00186   Float *Flt_p = (Float *)coor_data_p;
00187   for (int i = 0; i < d_size; ++i)    glb_sum(Flt_p++);
00188   
00189 }
00190 
00191 //--------------------
00192 // print
00193 //--------------------
00194 void WspectExtendedMesonsBE::print()const{
00195 
00196 #if TARGET==cpsMPI
00197     using MPISCU::fprintf;
00198 #endif
00199   char *fname = "print";
00200   char outputfilename[100];//generated according to WpsectArg.filetail and stateName
00201   VRB.Func(d_class_name, fname);
00202   
00203   //caluculate average of x,y,z, polarizations
00204   //store average in coor_data_p's x polarization entry
00205   {
00206     for(int wall=0;wall< d_glb_walls;wall++){
00207       int offset_data_wall=wall*NUM_WEXTMESON_BE_STATES;
00208       int offset_output_wall=wall*NUM_WEXTMESON_BE_OUTPUT;
00209       int num_pol; //count number of polarization
00210 
00211 
00212       //meason is real name, must use map
00213       for(int mesonId=0;mesonId<NUM_WEXTMESON_BE_OUTPUT;mesonId++){
00214         //loop over all states to find all polarizations of the same
00215         //meson
00216         num_pol=0;
00217         int output_offset=offset_output_wall+mesonId;
00218         for(int mesonState=0;mesonState<NUM_WEXTMESON_BE_STATES;mesonState++){
00219 
00220           if(WMesonStateTable[mesonState].mesonId!=mesonId){
00221             continue;
00222           }
00223 
00224           num_pol++;
00225           //check whether the meson is measured
00226           if(WMesonStateTable[mesonState].measure==0) {
00227             //measured[mesonId]=0;
00228             break;
00229           }
00230 
00231           //printf("Averaging meson#%d...\n",meson);
00232           int data_offset=offset_data_wall+map[mesonState];
00233           coor_output_p[output_offset]+=coor_data_p[data_offset];
00234         }//mesonState
00235 
00236         //divide
00237         if(num_pol!=0) coor_output_p[output_offset]/=num_pol;
00238       }//mesonId
00239     }//wall
00240   }
00241 
00242   // Print out mesons
00243   //------------------------------------------------------------------
00244   FILE *fp;
00245   for (int meson = 0; meson < NUM_WEXTMESON_BE_OUTPUT; ++meson) {
00246     
00247     //    if(measured[meson]){
00248     int measure_flag=0;
00249     //generate the output filename
00250     //get statename from WMesonStateTable
00251     for(int state=0;state<NUM_WEXTMESON_BE_STATES;state++){
00252       if(WMesonStateTable[state].mesonId==meson){
00253         if(WMesonStateTable[state].measure) {
00254           measure_flag=1;
00255           if(!arg_p->fuzzing_on){
00256             //      sprintf(outputfilename,"%s.%s",WMesonStateTable[state].stateName,arg_p->filetail);
00257             sprintf(outputfilename,"%s",WMesonStateTable[state].stateName);
00258           }else{
00259             //fuzzing is on
00260             // sprintf(outputfilename,"%s.%sF%.1f",WMesonStateTable[state].stateName,arg_p->filetail,arg_p->fuzzing_c[fuzzing_c_index]);
00261             sprintf(outputfilename,"%sF%.1f",WMesonStateTable[state].stateName,arg_p->fuzzing_c[fuzzing_c_index]);
00262           }
00263           break;
00264         }
00265       }
00266     }
00267 
00268     if(measure_flag){
00269 #ifdef DEBUG_W_EXT_MESON
00270       printf("Writing extended meson#%d data to file %s\n",meson,outputfilename);   
00271 #endif
00272       
00273       if ( !(fp = Fopen(outputfilename, "a")) )
00274         ERR.FileA(d_class_name,fname, outputfilename);
00275 
00276       for (int wall = 0; wall <= d_glb_walls/2; ++wall) {
00277         
00278         Complex tmp = coor_output_p[meson + NUM_WEXTMESON_BE_OUTPUT*
00279                                  ((d_whr.glbCoord() + wall)%d_glb_walls)];
00280         tmp += coor_output_p[meson +  NUM_WEXTMESON_BE_OUTPUT*
00281                           ((d_whr.glbCoord() + d_glb_walls - wall)%d_glb_walls)];
00282         tmp /= 2.0; //average of t and N-t
00283         // only print out the imaginary parts
00284         //mom=0
00285         Fprintf(fp, "%d %d %d %.10e\n", 
00286                 AlgWspect::GetCounter(), wall, 0, tmp.real());
00287       }
00288       Fclose(fp);
00289     }//if(measur_flag)
00290   }//for meson
00291   
00292 }
00293 
00294 //++++++++++++++++++++End of Major Functions+++++++++++++++++
00295 
00296 //++++++++++++++++++++Beginning of Utility Functions+++++++++
00297 
00298 Float WspectExtendedMesonsBE::table(int state, int sour_gamma, int sour_op, int sink_gamma, int sink_int) const{
00299   return 0;
00300 
00301 }
00302 
00303 int WspectExtendedMesonsBE::isInOpGroup(int op, int groupId) const{
00304    char *fname="isInOpGroup";
00305    int result=0;
00306    switch(groupId){
00307    case 0:
00308      if(op>=FB1_OP && op<=FUNIT_OP) result=1;
00309      break;
00310    case 1:
00311      if(op==SUM_MAGN_OP || op==SUM_ELEC_OP || op == FUNIT) result=1;
00312      break;
00313    case 2:
00314      if(op==SUM_MAGN_ELEC_OP ||
00315         op==SUM_S_SYM || op==SUM_S_DIAG) result= 1;
00316      break;
00317    case 3:
00318      if(op==UNIT || op==SUM_F_S_ANTISYM || 
00319         op==SUM_S_SYM_DIAG) result=1;
00320      break;
00321   case 4:
00322     if(op==SUM_UNIT_F_S_ANTISYM || 
00323        op==SUM_S_SYM_DIAG) result= 1;
00324     break;
00325     
00326    default:
00327      ERR.General(d_class_name, fname, "invalid grpId");
00328    }
00329 
00330   return result;
00331 }
00332 
00333 int WspectExtendedMesonsBE::matchSUMOp(int op, int sum_op) const{
00334 
00335   return 0;
00336 }
00337 
00338 
00339 //--------------------
00340 // initStateTable
00341 //--------------------
00342 void WspectExtendedMesonsBE::initWMesonStateTable(WspectArg *arg){
00343   //pionxB
00344   WMesonStateTable[BE_MS_pionxB_x].stateName="BEpionxB";
00345   WMesonStateTable[BE_MS_pionxB_x].mesonId=BE_pionxB;
00346   WMesonStateTable[BE_MS_pionxB_x].category=MAG_HYBRID_BE;
00347   WMesonStateTable[BE_MS_pionxB_x].polarization=0;
00348   WMesonStateTable[BE_MS_pionxB_x].measure=0;
00349   WMesonStateTable[BE_MS_pionxB_x].srcOp=BE_MO_pionxB_x;
00350   WMesonStateTable[BE_MS_pionxB_x].sinkOp=BE_MO_pionxB_x;
00351   
00352   WMesonStateTable[BE_MS_pionxB_y]=WMesonStateTable[BE_MS_pionxB_x];
00353   WMesonStateTable[BE_MS_pionxB_y].polarization=1;
00354   WMesonStateTable[BE_MS_pionxB_y].srcOp=BE_MO_pionxB_y;
00355   WMesonStateTable[BE_MS_pionxB_y].sinkOp=BE_MO_pionxB_y;
00356   
00357   WMesonStateTable[BE_MS_pionxB_z]=WMesonStateTable[BE_MS_pionxB_x];
00358   WMesonStateTable[BE_MS_pionxB_z].polarization=1;
00359   WMesonStateTable[BE_MS_pionxB_z].srcOp=BE_MO_pionxB_z;
00360   WMesonStateTable[BE_MS_pionxB_z].sinkOp=BE_MO_pionxB_z;
00361 
00362   //rhoxB_T1
00363   WMesonStateTable[BE_MS_rhoxB_T1_x].stateName="BErhoxB_T1";
00364   WMesonStateTable[BE_MS_rhoxB_T1_x].mesonId=BE_rhoxB_T1;
00365   WMesonStateTable[BE_MS_rhoxB_T1_x].category=MAG_HYBRID_BE;
00366   WMesonStateTable[BE_MS_rhoxB_T1_x].polarization=0;
00367   WMesonStateTable[BE_MS_rhoxB_T1_x].measure=0;
00368   WMesonStateTable[BE_MS_rhoxB_T1_x].srcOp=BE_MO_rhoxB_T1_x;
00369   WMesonStateTable[BE_MS_rhoxB_T1_x].sinkOp=BE_MO_rhoxB_T1_x;
00370   
00371   WMesonStateTable[BE_MS_rhoxB_T1_y]=WMesonStateTable[BE_MS_rhoxB_T1_x];
00372   WMesonStateTable[BE_MS_rhoxB_T1_y].polarization=1;
00373   WMesonStateTable[BE_MS_rhoxB_T1_y].srcOp=BE_MO_rhoxB_T1_y;
00374   WMesonStateTable[BE_MS_rhoxB_T1_y].sinkOp=BE_MO_rhoxB_T1_y;
00375   
00376   WMesonStateTable[BE_MS_rhoxB_T1_z]=WMesonStateTable[BE_MS_rhoxB_T1_x];
00377   WMesonStateTable[BE_MS_rhoxB_T1_z].polarization=1;
00378   WMesonStateTable[BE_MS_rhoxB_T1_z].srcOp=BE_MO_rhoxB_T1_z;
00379   WMesonStateTable[BE_MS_rhoxB_T1_z].sinkOp=BE_MO_rhoxB_T1_z;
00380 
00381   //change measure property according to argument
00383   for(int stateId=0;stateId<NUM_WEXTMESON_BE_STATES;stateId++){
00384     int cat=WMesonStateTable[stateId].category;
00385     WMesonStateTable[stateId].measure=1;
00386   }
00387 }
00388 
00389 //--------------------
00390 // initOpTable
00391 //--------------------
00392 void WspectExtendedMesonsBE::initWMesonOpTable(){
00393 
00394   //pionxB
00395   WMesonOpTable[BE_MO_pionxB_x].num_terms=1;
00396   setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_x].terms[0][0]),1,WGAM_5,FB1);
00397   
00398   WMesonOpTable[BE_MO_pionxB_y].num_terms=1;
00399   setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_y].terms[0][0]),1,WGAM_5,FB2);
00400   
00401   WMesonOpTable[BE_MO_pionxB_z].num_terms=1;
00402   setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_z].terms[0][0]),1,WGAM_5,FB3);
00403   
00404   //rhoxB_T1
00405   WMesonOpTable[BE_MO_rhoxB_T1_x].num_terms=2;
00406   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_x].terms[0][0]),1,WGAM_2,FB3);
00407   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_x].terms[1][0]),-1,WGAM_3,FB2);
00408 
00409   WMesonOpTable[BE_MO_rhoxB_T1_y].num_terms=2;
00410   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_y].terms[0][0]),1,WGAM_3,FB1);
00411   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_y].terms[1][0]),-1,WGAM_1,FB3);
00412   
00413   WMesonOpTable[BE_MO_rhoxB_T1_z].num_terms=2;
00414   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_z].terms[0][0]),1,WGAM_1,FB2);
00415   setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_z].terms[1][0]),-1,WGAM_2,FB1);
00416   
00417  
00418 }
00419 
00420 //---------------------
00421 //setWMesonOpTerm
00422 //---------------------
00423 void WspectExtendedMesonsBE::setWMesonOpTerm(int *term_p, int weight, WGammaMatrix gammaMat, FieldTensorId fieldId){
00424   term_p[0]=weight;
00425   term_p[1]=gammaMat;
00426   term_p[2]=fieldId;
00427 }
00428 
00429 
00430 
00431 CPS_END_NAMESPACE

Generated on Sat Oct 10 14:11:20 2009 for Columbia Physics System by  doxygen 1.3.9.1