Index: trunk/Cosmo/RadioBeam/calcpk2.cc
===================================================================
--- trunk/Cosmo/RadioBeam/calcpk2.cc	(revision 3830)
+++ trunk/Cosmo/RadioBeam/calcpk2.cc	(revision 3973)
@@ -7,5 +7,5 @@
     R. Ansari , C. Magneville - Juin 2010 
 
-Usage: calcpk2 InMapLSS convFacLSS InMapSync convFacSync InMapRadioSource convFacRsc OutPkFile 
+Usage: calcpk2 [-t -g] InMapLSS convFacLSS InMapSync convFacSync InMapRadioSource convFacRsc OutPkFile 
                [PixNoiseLevel] [Diameter/Four2DRespTableFile] [TargetBeamArcmin] [NSigSrcThr]
 ---------------------------------------------------------------  */
@@ -44,9 +44,10 @@
 {
   if ( (narg<6)||((narg>1)&&(strcmp(arg[1],"-h")==0)) ) {
-    cout << " Usage: calcpk2 InMapLSS convFacLSS InMapFgnd convFacFgnd OutPkFile \n" 
-         << "        [PixNoiseLevel] [D_Dish/Four2DRespTableFile CorBeamDoL] \n"
+    cout << " Usage: [-t -g] calcpk2 InMapLSS convFacLSS InMapFgnd convFacFgnd OutPkFile \n" 
+         << "        [PixNoiseLevel] [D_Dish/Four2DRespTableFile CorBeamDiam] \n"
 	 << "        [NSigSrcThr] [P2/P1] [RecMapFile] " << endl;
     if ((narg>1)&&(strcmp(arg[1],"-h")==0)) {
-      cout << "- InMapLSS: Input 3D LSS cube (PPF file name) \n "
+      cout << "-t -g : Triangular / gaussian beam shape (def=gaussian) \n" 
+	   << "- InMapLSS: Input 3D LSS cube (PPF file name) \n "
 	   << "- convFacLSS: LSS cube conversion factor to mK (milliKelvin) \n"
 	   << "- InMapFgnd: Input 3D foreground cube (PPF file name) \n"
@@ -54,11 +55,11 @@
 	   << "- PixNoiseLevel: White noise level per pixel (mK) (default=0.) \n" 
 	   << "- D_Dish/Four2DRespTableFile: Dish diameter or 2D (u,v) plane response (PPF file name) \n"
-	   << "- CorBeamDoL: Beam correction target Diameter/Lambda \n" 
+	   << "- CorBeamDiam: Beam correction target dish diameter  \n" 
 	   << "    These two parameters are used to correct for beam effect for a \n"
 	   << "    target beam (independent of frequency) defined by D/Lambda \n"
-	   << "    DoL = 100 --> beam ~ 35 arcmin (D=30m @ z~0.5) \n" 
+	   << "    DoL = 100 --> beam ~ 35 arcmin (D=30m @ z~0.5 Lambda~30cm) \n" 
 	   << "    default : no beam correction applied \n " 
 	   << " - NSigSrcThr: Point source cleaning, Nb_Sigmas on stacked 2D temperature \n" 
-	   << "    default : no point source cleaning, use NSigSrcThr ~ 3..5 \n"
+	   << "    default (0.) : no point source cleaning, use NSigSrcThr ~ 3..5 \n"
 	   << " - P2/P1: 2nd/first degree polynomial fit on ln(Temp) = f(ln(freq)) \n "
 	   << "    foreground subtraction. default is P2 \n" 
@@ -74,4 +75,18 @@
   int rc = 0;
   try {
+    bool fggaussian=true;  // true -> gaussian beam 
+    // decodage argument optionnel 
+    bool fgoptarg=true;
+    while (fgoptarg) {
+      string fbo = arg[1];
+      if (fbo=="-t")  { fggaussian=false; arg++; narg--; }
+      else if (fbo=="-g")  { fggaussian=true; arg++; narg--; }
+      else fgoptarg=false;
+    }
+    if (narg < 6) {
+      cout << " calcpk2/error arguments , applobe -h for help " << endl;
+      return 2;
+    }
+
     string inppflss = arg[1];
     r_4 rfaclss = atof(arg[2]);
@@ -102,8 +117,8 @@
       }
     }
-    double tbeamDoL=0.;
+    double tbeamDiam=0.;
     if (narg>8) {
-      tbeamDoL=atof(arg[8]);
-      if (tbeamDoL<1.)  fgcorrbeam=false;
+      tbeamDiam=atof(arg[8]);
+      if (tbeamDiam<1.)  fgcorrbeam=false;
     }
     bool fgclnsrc=true;
@@ -170,4 +185,5 @@
       cout << "calcpk2[3.a]: initializing Four2DRespTable from file" << resptblname << endl;
       resptbl.readFromPPF(resptblname);
+      resptbl.renormalize(1.);
       arep_p=&resptbl;
     }
@@ -175,7 +191,7 @@
 	      << " DoL=" << DIAMETRE/lambda << " ) " << endl;
 
-    double DoL = tbeamDoL;
+    double DoL = tbeamDiam/lambda;
     double tbeamarcmin = RadianToDegree(1.22/DoL)*60.;
-    int typcb = 2;
+    int typcb = (fggaussian)?1:2;
     //    if (fgresptbl) typcb=22;
     Four2DResponse tbeam(typcb, DoL, DoL );
@@ -183,6 +199,6 @@
     ForegroundCleaner  cleaner(*arep_p, tbeam, skycube); 
     if (fgcorrbeam) {
-      cout << "calcpk2[3.b] : calling cleaner.BeamCorrections() for target beam D/Lambda=" << DoL 
-	   << "  -> arcmin " << tbeamarcmin << " TypDishResp=" << typcb << endl;
+      cout << "calcpk2[3.b] : calling cleaner.BeamCorrections() for target beam Diameter=" << tbeamDiam  
+	   << " D/Lambda=" << DoL  << "  -> arcmin " << tbeamarcmin << " TypDishResp=" << typcb << endl;
       cleaner.BeamCorrections();
     }
@@ -218,5 +234,5 @@
     pkc.SetCellSize(dkxmpc, dkympc, dkzmpc);
     
-    HProf hp = pkc.ComputePk(0.,256);
+    HProf hp = pkc.ComputePk(0.,HPk_NBin);
 
     tm.Split(" Done ComputePk ");    
