Index: /BAORadio/AmasNancay/trunk/analysis-scriptsAndprg-description.txt
===================================================================
--- /BAORadio/AmasNancay/trunk/analysis-scriptsAndprg-description.txt	(revision 609)
+++ /BAORadio/AmasNancay/trunk/analysis-scriptsAndprg-description.txt	(revision 610)
@@ -1,4 +1,4 @@
 Title: Status of the programs and scripts used for Amas@Nancay analysis at CCIN2P3
-Revision: 11/10/11 (JEC)
+Revision: 28/11/11 (JEC+AST)
 Author: J.E Campagne 22/7/11
 ----------------------------
@@ -21,4 +21,7 @@
 	- comments
 		. the STANDARD usage since end september 11 is GAIN + ON-OFF wo calibration
+
+
+
 		
 -----------------------------------------------------------
@@ -71,76 +74,39 @@
 		. scan Irods directories to look at sca<>.sum files to count the number of cycles per run
 
-B) Utilitary scripts to send to BQS system high level task
+B) Utilitary scripts to send to GE system high level task (note old BQS batch is obsolete now)
 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++		
-o submit2bqs-hdrfitsextractor.sh
+o submit2ge-hdrfitsextractor.sh
 --------------------------------
         - SHOULD BE DONE BEFORE gain/calib/analysis
-	- send the hdrfitsextractor.sh script to BQS system	
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
-o submit2bqs-scaextractor.sh
---------------------------------
-        - SHOULD BE DONE BEFORE gain/calib/analysis
-	- send the scaextractor.sh script to BQS system
-		although this script is called by getscafiles lower level script
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
-o submit2bqs-procspecmfib.sh
+	- send the hdrfitsextractor.sh script to GE system	
+
+
+o submit2ge-procspecmfib.sh
 -----------------------------
 	- SHOULD BE DONE for processing signals for FFT/paquet median filtering
 	- GAIN/CALIB/ON, OFF... 
-	- prepare and send in batch the proc_specmfib.sh to BQS
+	- prepare and send in batch the proc_specmfib.sh to GE
 	- exemple
-        ./submit2bqs-procspecmfib.sh -src Abell85 -date 20110422 -type CALIBOFF -fcycle 8 -lcycle 14
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
-o submit2bqs-anagainmaker.sh
+        ./submit2ge-procspecmfib.sh -src Abell85 -date 20110422 -type CALIBOFF -fcycle 8 -lcycle 14
+
+o submit2ge-anagainmaker.sh
 ----------------------------
 	- done after proc_specmfib
 	- prepare and send the analyse.cc prg for gain computation
 	- exemple
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
-o submit2bqs-anacalibmaker.sh
+
+o submit2ge-anacalibmaker.sh
 ----------------------------
 	- done after proc_specmfib
 	- prepare and send the analyse.cc prg for calibration computation
 	- exemples: 
-	> $./submit2bqs-anacalibmaker.sh -src Abell85 -date 20110410
-
+	> $./submit2ge-anacalibmaker.sh -src Abell85 -date 20110410
+
+o submit2ge-scaextractor.sh
+--------------------------------
+        - SHOULD BE DONE BEFORE gain/calib/analysis
+	- send the scaextractor.sh script to GE system
+		although this script is called by getscafiles lower level script
 	
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-	
-o submit2qs-onoffmaker.sh (OBSOLETE ???)
---------------------------
-	- send the onoffmaker.sh script to BQS system
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
-o submit2bqs-rawonoffmaker.sh (OBSOLETE ???) 
------------------------------
-	- used after the anagainmaker 
-	- prepare and send in batch the proc_rawonoff.sh to BQS system
-	- exemple submit2bqs-rawonoffmaker.sh -src Abell85 -date 20110417 -fcycle 8 -lcycle 23 -type ON	
-	- Todo list
-		- TO MIGRATE TO NEW BATCH
-
-o submit2qs-gainmaker.sh (OBSOLETE)
--------------------------
-	- send the gainmaker.sh script to BQS system 
-	- Todo list
-		- TO MIGRATE TO NEW BATCH
-
-o submit2qs-calibmaker.sh (OBSOLETE)
---------------------------
-	- send the calibmaker.sh script to BQS system
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-
 		
 C) High level scripts 
@@ -158,5 +124,5 @@
 -----------------
 	- perform 
-	  . the analysis of the above fits files to determine the 
+	  . the analysis to determine the 
 			gains of each channel: produce gain_* files (monitoring + gain files)
 	  . put the results into Irods
@@ -168,5 +134,5 @@
 ------------------
 	- perfom
-	  . prepare the analysis of the above fits files
+	  . prepare the analysis
 	  . put calib_* files (monitoring +  calibration files) into Irods
 	- use 
@@ -175,38 +141,11 @@
 
 
-o gainmaker.sh (OBOLETE)
----------------
-	- perform 
-		1) the extraction of signalXYZ.fits files 
-			concerned by the OFF-calibration time window
-			of the cycle located at the middle of the run
-		2) . the analysis of the above fits files to determine the 
-			gains of each channel: produce gain_* files (monitoring + gain files)
-			. put the results into Irods
-	- use 
-		- statusdaq.sh, proc_script.sh, getscafiles.sh
-		- analysis.cc	
-	
-o calibmaker.sh (OBSOLETE)
----------------
-	- perfom
-		1) several x-checks to see at which stage of the analysis process we are
-		2) trig the proc_script.sh script if necessary to create the spectra fits files via specmfib.cc prg 
-		3) . prepare the analysis of the above fits files
-		   . put calib_* files (monitoring +  calibration files) into Irods
-	- use 
-		- statusdaq.sh, proc_script.sh, getscafiles.sh
-		- analysis.cc	
-
-o onoffmaker.sh (preliminary)
-----------------------------
-	- perform
-		1) several x-checks to see at which stage of the analysis process we are
-		2) trig the proc_script.sh script if necessary to create the spectra fits files via specmfib.cc prg 
-		3) prepare the analysis of the above fits files
-		4) put dataRaw_*        (raw spectra), 
-		       dataBAOCalib_*   (after BAO calibration), 
-		       dataBAORTCalib_* (after BAO & RT calibration), 
-		       diffOnOff_*      (ON-OFF spectra) 
+
+o anarawonoffmaker.sh
+---------------------
+	- perform
+		. prepare the analysis
+		. put dataRaw_*        (raw spectra), 
+		      diffOnOffRaw_*   (ON-OFF spectra although not used by final analysis) 
 
 D) Lower level scripts
@@ -225,27 +164,4 @@
 
 
-o proc_rawonoff.sh (OBSOLETE)
-------------------
-	- this is the script to use to perform the "datacycle" contents
-	- perform all the preparation work to send in batch the "specmfib" program 
-			which perform the FFT and median/mean spectra for the ON-OFF task
-	- use
-	  - getscafiles.sh, select.sh, statusdaq.sh, getsignalfiles.sh
-	- comments
-	  - contrary to proc_script (below) specmfib is activated in the same thread
-
-o proc_script.sh (OBSOLETE)
------------------
-	- VERY BUSY script
-	- perform 
-		1) all the preparation work to send in batch the "specmfib" program 
-			which perform the FFT and median/mean spectra for GAIN, CALIBRATION, ON-OFF task
-		2) the script that is sent in batch put the results into Irods	
-	- use
-		- getscafiles.sh, select.sh, getsignalfiles.sh
-	- Todo list
-		- TO MIGRATE TO NEW BATCH 
-		
-
 o scaextractor.sh
 -----------------
Index: ORadio/AmasNancay/trunk/etude_data.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/etude_data.pic	(revision 609)
+++ 	(revision )
@@ -1,227 +1,0 @@
-echo ".... execute ON"
-exec analdata 20110416abell85 151300 On datacycle 1
-echo ".... execute OFF"
-exec analdata 20110416abell85 151300 Off datacycle 1
-
-echo ".... execute Merging"
-
-c++compile offset
-
-
-#
-#follow cycle to cycle variation of calibration coeff
-#
-vecfrascii calibOnCh0   20110416abell85-On-1346MHz-Ch0Cycles.txt
-vecfrascii calibOnCh1   20110416abell85-On-1346MHz-Ch1Cycles.txt
-vecfrascii calibOffCh0  20110416abell85-Off-1346MHz-Ch0Cycles.txt
-vecfrascii calibOffCh1  20110416abell85-Off-1346MHz-Ch1Cycles.txt
-
-del diff0
-del diff1
-
-set ncount 0
-set first 1
-
-for ic ${firstcycle}:${ncycles}
-  echo "...... cycle $ic"
-  ncount = $ncount + 1
-  k = ${ic} -1
-  del diffcycle${ic}v0 diffcycle${ic}v1
-  if ( $first == 1 ) then
-     set first 0
-     c++exec \
-        TVector<r_4> sigcalOnv0(sumc${ic}mOnv0,false); sigcalOnv0/=calibOnCh0[$k]; \
-        TVector<r_4> sigcalOnv1(sumc${ic}mOnv1,false); sigcalOnv1/=calibOnCh1[$k]; \
-        TVector<r_4> sigcalOffv0(sumc${ic}mOffv0,false); sigcalOffv0/=calibOffCh0[$k]; \
-        TVector<r_4> sigcalOffv1(sumc${ic}mOffv1,false); sigcalOffv1/=calibOffCh1[$k]; \
-        TVector<r_4> diffcycle${ic}v0 = sigcalOnv0-sigcalOffv0; \
-        TVector<r_4> diffcycle${ic}v1 = sigcalOnv1-sigcalOffv1; \
-	TVector<r_4> diff0(diffcycle${ic}v0,false); \
-	TVector<r_4> diff1(diffcycle${ic}v1,false); \
-        KeepObj(diff0);KeepObj(diff1); \
-	KeepObj(diffcycle${ic}v0); KeepObj(diffcycle${ic}v1);
-  else
-     c++exec \
-        TVector<r_4> sigcalOnv0(sumc${ic}mOnv0,false); sigcalOnv0/=calibOnCh0[$k]; \
-        TVector<r_4> sigcalOnv1(sumc${ic}mOnv1,false); sigcalOnv1/=calibOnCh1[$k]; \
-        TVector<r_4> sigcalOffv0(sumc${ic}mOffv0,false); sigcalOffv0/=calibOffCh0[$k]; \
-        TVector<r_4> sigcalOffv1(sumc${ic}mOffv1,false); sigcalOffv1/=calibOffCh1[$k]; \
-        TVector<r_4> diffcycle${ic}v0 = sigcalOnv0-sigcalOffv0; \
-        TVector<r_4> diffcycle${ic}v1 = sigcalOnv1-sigcalOffv1; \
-	diff0+=diffcycle${ic}v0; \
-	diff1+=diffcycle${ic}v1; \
-	KeepObj(diffcycle${ic}v0); KeepObj(diffcycle${ic}v1);
-  endif
-end
-
-
-newvec nmean 1 $ncount nodisp
-#coef RT @ 1346MHz Ouest - Est associees a Ch 0 et 1
-set xcal ( 27.724 22.543 )
-line2vec calib $xcal
-del difftot
-c++exec diff0/=nmean[0]; diff1/=nmean[0]; \
-        diff0*=calib[0];diff1*=calib[1]; \
-        TVector<r_4> difftot(diff0,false);difftot+=diff1;difftot/=2.; \
-        KeepObj(difftot);
-
-
-#
-#Calibrate and Offset Correction
-#
-for ic ${firstcycle}:${ncycles}
-  c++exec diffcycle${ic}v0*=calib[0];diffcycle${ic}v1*=calib[1]; 
-end
-
-del modiff0 moddiff1
-set first 1
-for ic ${firstcycle}:${ncycles}
-  echo "modif ...... cycle $ic"
-  
-  del inarr outarr  modiffc${ic}v0
-  cp  diffcycle${ic}v0 inarr
-  c++link offset.so meanoffset
-  call meanoffset 1285 1335 1355 1450
-  cp outarr modiffc${ic}v0
-
-  del inarr outarr modiffc${ic}v1
-  cp  diffcycle${ic}v1 inarr
-  c++link offset.so meanoffset
-  call meanoffset 1285 1335 1355 1450
-  cp outarr modiffc${ic}v1
-
-  if ( $first == 1 ) then
-     set first 0
-     c++exec \ 
-       TVector<r_4> modiff0(modiffc${ic}v0,false); \ 
-       TVector<r_4> modiff1(modiffc${ic}v1,false); \ 
-       KeepObj(modiff0);KeepObj(modiff1);
-  else
-     c++exec modiff0+=modiffc${ic}v0;  modiff1+=modiffc${ic}v1;
-  endif
-end  
-
-
-newwin 1 1
-setaxesatt $defatt
-graphicatt "$defatt xylimits=1250,1500,-1.,1."
-set first 1
-for ic ${firstcycle}:${ncycles}
-  echo "...... cycle $ic"
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}
-  if ( $first == 1 ) then
-     set first 0
-     plot2d  diffcycle${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-  else
-     plot2d  diffcycle${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-  endif
-end
-settitle "Diff. On-Off No Corr. $source Ch 0 cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-
-newwin 1 1
-setaxesatt $defatt
-graphicatt "$defatt xylimits=1250,1500,-1.,1."
-set first 1
-for ic ${firstcycle}:${ncycles}
-  echo "...... cycle $ic"
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}
-  if ( $first == 1 ) then
-     set first 0
-     plot2d  diffcycle${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-  else
-     plot2d  diffcycle${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-  endif
-end
-settitle "Diff. On-Off No Corr. $source Ch 1 cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-
-newwin 1 1
-setaxesatt $defatt
-graphicatt "$defatt xylimits=1250,1500,-50.,50."
-plot2d diff0  (n/8192)*250+1250 val*1000 n>0 "blue cpts nsta notit"
-plot2d diff1  (n/8192)*250+1250 val*1000 n>0 "red same cpts nsta notit"
-plot2d difftot  (n/8192)*250+1250 val*1000 n>0 "black same cpts nsta notit"
-settitle "Mean diff calib No Corr. per cycle ON-OFF Int.  $source cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "Int. (mJy)"
-
-newwin 1 1
-graphicatt "$defatt"
-n/plot difftot.val*1000 n>1090&&n<4000 ! ! "black  notit"
-n/plot diff0.val*1000 n>1090&&n<4000 ! ! "blue same notit"
-n/plot diff1.val*1000 n>1090&&n<4000 ! ! "red same notit"
-settitle "Diff ON-OFF No Corr. $source [$firstcycle,$lastcycle] 1280MHz - 1370MHz"
-setaxelabels "mJy" " "
-
-
-
-newwin 1 1
-setaxesatt $defatt
-graphicatt "$defatt xylimits=1250,1500,-1.,1."
-set first 1
-for ic ${firstcycle}:${ncycles}
-  echo "...... cycle $ic"
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}
-  if ( $first == 1 ) then
-     set first 0
-     plot2d  modiffc${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-  else
-     plot2d  modiffc${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-  endif
-end
-settitle "Diff. On-Off With Corr. $source Ch 0 cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-newwin 1 1
-setaxesatt $defatt
-graphicatt "$defatt xylimits=1250,1500,-1.,1."
-set first 1
-for ic ${firstcycle}:${ncycles}
-  echo "...... cycle $ic"
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}
-  if ( $first == 1 ) then
-     set first 0
-     plot2d  modiffc${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-  else
-     plot2d  modiffc${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-  endif
-end
-settitle "Diff. On-Off With Corr. $source Ch 1 cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-
-
-
-  
-del modifftot
-c++exec modiff0/=nmean[0]; modiff1/=nmean[0]; \
-        TVector<r_4> modifftot(modiff0,false);modifftot+=modiff1;modifftot/=2.; \
-        KeepObj(modifftot);
-
-newwin 1 1
-setaxesatt $defatt"
-graphicatt "$defatt xylimits=1250,1500,-50.,50."
-plot2d modiff0  (n/8192)*250+1250 val*1000 n>0 "blue cpts nsta notit"
-plot2d modiff1  (n/8192)*250+1250 val*1000 n>0 "red same cpts nsta notit"
-plot2d modifftot  (n/8192)*250+1250 val*1000 n>0 "black same cpts nsta notit"
-settitle "Mean diff ON-OFF With Corr.  $source cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "Int. (mJy)"
-
-newwin 1 1
-graphicatt "$defatt"
-n/plot modifftot.val*1000 n>1090&&n<4000 ! ! "black  notit"
-n/plot modiff0.val*1000 n>1090&&n<4000 ! ! "blue same notit"
-n/plot modiff1.val*1000 n>1090&&n<4000 ! ! "red same notit"
-settitle "Diff ON-OFF With Corr. $source [$firstcycle,$lastcycle] 1280MHz - 1370MHz"
-setaxelabels "mJy" " "
-
-
-newwin 1 1
-setaxesatt $defatt"
-graphicatt "$defatt xylimits=1250,1500,-50.,50."
-plot2d difftot  (n/8192)*250+1250 val*1000 n>0 "blue  cpts nsta notit"
-plot2d modifftot  (n/8192)*250+1250 val*1000 n>0 "red same  cpts nsta notit"
-settitle "Mean diff ON-OFF NO Corr (blue) With Corr (red)  $source cycles [$firstcycle,$lastcycle]"
-setaxelabels "Freq. (MHz)" "Int. (mJy)"
Index: ORadio/AmasNancay/trunk/etude_onoff.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/etude_onoff.pic	(revision 609)
+++ 	(revision )
@@ -1,317 +1,0 @@
-
-set cols ( blue red black green purple orange cyan violet yellow )
-
-set toppath "/sps/baoradio/AmasNancay/JEC"
-set source "Abell${1}"
-set srclower "abell${1}"
-set date   "${2}"
-
-
-#####################################
-#Plots ON-OFF with all calibrations 
-#####################################
-openppf ${toppath}/${source}/diffOnOff_${date}_${srclower}.ppf
-
-
-#specONOFF<i>       Matrix 2 x 8192 : i=0...
-#specONOFFMean      Matrix 2 x 8192
-#specONOFF2ChanMean Vector 8192 x 1
-
-
-#####################################
-#Plots with different Means: per channel and all 
-#####################################
-del sallcyclev0
-objaoper specONOFFMean row 0 sallcyclev0
-del sallcyclev1
-objaoper specONOFFMean row 1 sallcyclev1
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.5,0.5"
-plot2d specONOFF2ChanMean (n/8192)*250+1250 val n>0 "black cpts nsta notit"
-plot2d sallcyclev0        (n/8192)*250+1250 val n>0 "same blue cpts nsta notit"
-plot2d sallcyclev1        (n/8192)*250+1250 val n>0 "same red cpts nsta notit"
-settitle "ON-OFF  ${source}/${date} Ch 0 (blue) Ch 1 (red) Mean (black)  All cycles"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-#####################################
-#Examine fluctuations sigma for the combination of all cycles
-#####################################
-cp sallcyclev0 specv0
-cp sallcyclev1 specv1
-c++compile reducing        
-c++link reducing.so doreduc
-call doreduc
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
- del redMeanv0                                                                      
- del redMeanv1                                                                      
- objaoper reducedMeanDiffOnOff row 0 redMeanv0                                      
- objaoper reducedMeanDiffOnOff row 1 redMeanv1                                      
- plot2d redMeanv0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7 nsta notit"        
- plot2d redMeanv1 (n/32)*250+1250 val n>0 "same red marker=fcircle,7 nsta notit"
-settitle "Red Mean ON-OFF  ${source} Ch 0 (blue) Ch 1 (red) ${tmpvec.sum} cycles"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,0,0.001"
- del redSigmav0                                                                      
- del redSigmav1                                                                      
- objaoper reducedSigmaDiffOnOff row 0 redSigmav0                                      
- objaoper reducedSigmaDiffOnOff row 1 redSigmav1                                      
- plot2d redSigmav0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7 nsta notit"        
- plot2d redSigmav1 (n/32)*250+1250 val n>0 "same red marker=fcircle,7 nsta notit"
-settitle "ON-OFF  ${source} Ch 0 (blue) Ch 1 (red) ${tmpvec.sum} cycles"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-
-#####################################
-#Plots ON-OFF with all calibrations: chan 0 & 1 separaed and cycle per cycle 
-#####################################
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.5,0.5"
-del sc1v0
-objaoper specONOFF1 row 0 sc1v0
-plot2d sc1v0 (n/8192)*250+1250 val n>0 "$cols[0] cpts nsta notit"
-for ic 2:13
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v0
-    objaoper specONOFF${ic} row 0 sc${ic}v0	
-    plot2d sc${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-end
-settitle "ON-OFF  ${source}/${date} Ch 0 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.5,0.5"
-del sc1v1
-objaoper specONOFF1 row 1 sc1v1
-plot2d sc1v1 (n/8192)*250+1250 val n>0 "$cols[0] cpts nsta notit"
-for ic 2:13
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v1
-    objaoper specONOFF${ic} row 1 sc${ic}v1	
-    plot2d sc${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-end
-settitle "ON-OFF  ${source}/${date} Ch 1 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (Jy)"
-
-
-#####################################
-# Plots RAW no calibration at all
-#####################################
-openppf ${toppath}/${source}/dataRaw_${date}_${srclower}.ppf
-newwin 2 2
-graphicatt "xylimits=1250,1500,0.95,1.05"
-
-###         #
-### On Ch 0 # On Ch 1 
-######################
-### Off Ch 0# Off Ch 1
-###         #
-
-set mode On	
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specRaw${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: On Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specRaw${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: On Ch 1"
-
-set mode Off
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specRaw${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: Off Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specRaw${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: Off Ch 1"
-
-#####################################
-# Plots BAO calibration included
-#####################################
-openppf ${toppath}/${source}/dataBAOCalib_${date}_${srclower}.ppf
-newwin 2 2
-#graphicatt "xylimits=1250,1500,0.95,1.05"
-graphicatt ""
-
-
-###         #
-### On Ch 0 # On Ch 1 
-######################
-### Off Ch 0# Off Ch 1
-###         #
-
-set mode On	
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specBAOCalib${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAOCalib: On Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specBAOCalib${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAOCalib: On Ch 1"
-
-set mode Off
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specBAOCalib${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAOCalib: Off Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specBAOCalib${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAOCalib: Off Ch 1"
-
-#####################################
-# Plots BAO+RT calibration included
-#####################################
-openppf ${toppath}/${source}/dataBAORTCalib_${date}_${srclower}.ppf
-newwin 2 2
-#graphicatt "xylimits=1250,1500,0.95,1.05"
-graphicatt ""
-
-
-###         #
-### On Ch 0 # On Ch 1 
-######################
-### Off Ch 0# Off Ch 1
-###         #
-
-set mode On	
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specBAORTCalib${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAORTCalib: On Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specBAORTCalib${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAORTCalib: On Ch 1"
-
-set mode Off
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specBAORTCalib${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAORTCalib: Off Ch 0"
-
-set first 1
-for ic 1:13
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specBAORTCalib${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} BAORTCalib: Off Ch 1"
-
Index: ORadio/AmasNancay/trunk/etude_rawonoff.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/etude_rawonoff.pic	(revision 609)
+++ 	(revision )
@@ -1,307 +1,0 @@
-
-set cols ( blue red black green purple orange cyan violet yellow )
-
-set toppath "/sps/baoradio/AmasNancay/JEC"
-set source "${1}"
-set srclower "${2}"
-set date   "${3}"
-# implicitement firstcycle =1
-set lastcycle $3
-lastP1cycle = ${lastcycle}+1
-
-echo Analyse ${source}/${data} from cycles 1-${lastcycle} (${lastP1cycle})
-
-pssetfilename rawonoff-${source}-${date}.ps
-
-
-
-
-#set showFigs ( 0 0 0 0 0 0 0 )
-
-
-
-#####################################
-#Plots RAW ON-OFF (RAW = WO calibrations) 
-#####################################
-openppf ${toppath}/${source}/${date}${srclower}/diffOnOffRaw_${date}_${srclower}.ppf
-
-
-#specONOFFRaw<i>       Matrix 2 x 8192 : i=0...
-#specONOFFRawMean      Matrix 2 x 8192
-#specONOFFRaw2ChanMean Vector 8192 x 1
-
-
-#####################################
-#Plots RAW ON-OFF with mean computed among the cycles AND(or NOT) the Channels
-#####################################
-
-#if ( $showFigs[0] == 1 ) then
-echo "Figure 1.........."
-
-del sallcyclev0
-objaoper specONOFFRawMean row 0 sallcyclev0
-del sallcyclev1
-objaoper specONOFFRawMean row 1 sallcyclev1
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-plot2d specONOFFRaw2ChanMean (n/8192)*250+1250 val n>0 "black cpts nsta notit"
-plot2d sallcyclev0        (n/8192)*250+1250 val n>0 "same blue cpts nsta notit"
-plot2d sallcyclev1        (n/8192)*250+1250 val n>0 "same red cpts nsta notit"
-settitle "ON-OFF  ${source}/${date} Ch 0 (blue) Ch 1 (red) Mean (black)  All cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-
-w2ps
-
-#endif
-
-#####################################
-#Plots RAW ON-OFF  chan 0 & 1 separaed and cycle per cycle 
-#####################################
-
-
-#if ( $showFigs[1] == 1 ) then
-echo "Figure 2.........."
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-del sc1v0
-objaoper specONOFFRaw1 row 0 sc1v0
-plot2d sc1v0 (n/8192)*250+1250 val n>0 "$cols[0] cpts nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v0
-    objaoper specONOFFRaw${ic} row 0 sc${ic}v0	
-    plot2d sc${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-end
-settitle "ON-OFF  ${source}/${date} Ch 0 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-del sc1v1
-objaoper specONOFFRaw1 row 1 sc1v1
-plot2d sc1v1 (n/8192)*250+1250 val n>0 "$cols[0] cpts nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v1
-    objaoper specONOFFRaw${ic} row 1 sc${ic}v1	
-    plot2d sc${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-end
-settitle "ON-OFF  ${source}/${date} Ch 1 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-
-
-#endif
-
-#####################################
-# Plots RAW no calibration at all and no Diff ON-OFF
-#####################################
-openppf ${toppath}/${source}/${date}${srclower}/dataRaw_${date}_${srclower}.ppf
-
-#if ( $showFigs[2] == 1 ) then
-echo "Figure 3........."
-
-newwin 2 2
-graphicatt "xylimits=1250,1500,0.95,1.05"
-
-###         #
-### On Ch 0 # On Ch 1 
-######################
-### Off Ch 0# Off Ch 1
-###         #
-
-set mode On	
-set first 1
-for ic 1:${lastP1cycle}
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specRaw${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: On Ch 0"
-
-set first 1
-for ic 1:${lastP1cycle}
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specRaw${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: On Ch 1"
-
-set mode Off
-set first 1
-for ic 1:${lastP1cycle}
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v0
-    objaoper specRaw${mode}${ic} row 0 sm${mode}c${ic}v0
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v0 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: Off Ch 0"
-
-set first 1
-for ic 1:${lastP1cycle}
-  k = ${ic}-floor(${ic}/${#cols})*${#cols}	
-    del sm${mode}c${ic}v1
-    objaoper specRaw${mode}${ic} row 1 sm${mode}c${ic}v1
-    if ( ${first} == 1 ) then
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "$cols[k] cpts nsta notit"
-    else
-      plot2d sm${mode}c${ic}v1 (n/8192)*250+1250 val n>0 "same $cols[k] cpts nsta notit"
-    endif
-  set first 0
-end
-settitle "${source}/${date} Raw: Off Ch 1"
-
-w2ps
-
-#endif
-
-#####################################
-#Plots RAW ON-OFF  MEAN REDUCED  chan 0 & 1 separaed and cycle per cycle 
-#####################################
-
-#if ( $showFigs[3] == 1 ) then
-echo "Figure 4.........."
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-del sc1v0
-objaoper redMeanONOFFRaw1 row 0 sc1v0
-plot2d sc1v0 (n/32)*250+1250 val n>0 "$cols[0] marker=fcircle,7  nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v0
-    objaoper redMeanONOFFRaw${ic} row 0 sc${ic}v0	
-    plot2d sc${ic}v0 (n/32)*250+1250 val n>0 "same $cols[k] marker=fcircle,7 nsta notit"
-end
-settitle "ON-OFF Mean 32bins ${source}/${date} Ch 0 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-del sc1v1
-objaoper redMeanONOFFRaw1 row 1 sc1v1
-plot2d sc1v1 (n/32)*250+1250 val n>0 "$cols[0] marker=fcircle,7 nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v1
-    objaoper redMeanONOFFRaw${ic} row 1 sc${ic}v1	
-    plot2d sc${ic}v1 (n/32)*250+1250 val n>0 "same $cols[k] marker=fcircle,7 nsta notit"
-end
-settitle "ON-OFF Mean 32bins ${source}/${date} Ch 1 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-
-#endif
-
-#####################################
-#Plots RAW ON-OFF  SIGMA REDUCED  chan 0 & 1 separaed and cycle per cycle 
-#####################################
-
-
-#if ( $showFigs[4] == 1 ) then
-echo "Figure 5.........."
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,0,0.01"
-del sc1v0
-objaoper redSigmaONOFFRaw1 row 0 sc1v0
-plot2d sc1v0 (n/32)*250+1250 val n>0 "$cols[0] marker=fcircle,7  nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v0
-    objaoper redSigmaONOFFRaw${ic} row 0 sc${ic}v0	
-    plot2d sc${ic}v0 (n/32)*250+1250 val n>0 "same $cols[k] marker=fcircle,7 nsta notit"
-end
-settitle "ON-OFF Sigma over 32bins ${source}/${date} Ch 0 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,0,0.01"
-del sc1v1
-objaoper redSigmaONOFFRaw1 row 1 sc1v1
-plot2d sc1v1 (n/32)*250+1250 val n>0 "$cols[0] marker=fcircle,7 nsta notit"
-for ic 2:${lastP1cycle}
-    k = ${ic}-floor(${ic}/${#cols})*${#cols}
-    del sc${ic}v1
-    objaoper redSigmaONOFFRaw${ic} row 1 sc${ic}v1	
-    plot2d sc${ic}v1 (n/32)*250+1250 val n>0 "same $cols[k] marker=fcircle,7 nsta notit"
-end
-settitle "ON-OFF Sigma over 32bins ${source}/${date} Ch 1 cycle per cycle"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-#endif
-
-#####################################
-#Plots RAW ON-OFF  MEAN REDUCED  chan 0 & 1 separaed ALL cycles 
-#####################################
-
-#if ( $showFigs[5] == 1 ) then
-echo "Figure 6.........."
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-del scallv0
-del scallv1
-
-objaoper redMeanONOFFRawAll row 0 scallv0
-objaoper redMeanONOFFRawAll row 1 scallv1
-plot2d scallv0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7  nsta notit"
-plot2d scallv1 (n/32)*250+1250 val n>0 "red same marker=fcircle,7  nsta notit"
-settitle "ON-OFF Mean 32bins ${source}/${date} Ch 0 (blue) Ch 1 (red) All cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-#endif
-
-#####################################
-#Plots RAW ON-OFF  SIGMA REDUCED  chan 0 & 1 separaed and cycle per cycle 
-#####################################
-
-
-#if ( $showFigs[5] == 1 ) then
-echo "Figure 6.........."
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,0,0.001"
-del scallv0
-del scallv1
-objaoper redSigmaONOFFRawAll row 0 scallv0
-objaoper redSigmaONOFFRawAll row 1 scallv1
-plot2d scallv0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7  nsta notit"
-plot2d scallv1 (n/32)*250+1250 val n>0 "red same marker=fcircle,7  nsta notit"
-settitle "ON-OFF Sigma over 32bins ${source}/${date} Ch 0 (blue) Ch 1 (red) All cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-w2ps
-
-#endif
-
-######################
-psclosefile
Index: /BAORadio/AmasNancay/trunk/mergeAnaFiles.cc
===================================================================
--- /BAORadio/AmasNancay/trunk/mergeAnaFiles.cc	(revision 609)
+++ /BAORadio/AmasNancay/trunk/mergeAnaFiles.cc	(revision 610)
@@ -63,4 +63,45 @@
 //--------------------------------------------------------------
 //Utility functions
+// template <class T>
+// void MeanSigma(TArray<T> const & a, T & mean, T & sig){
+//   if (a.NbDimensions() < 1) 
+//     throw RangeCheckError("MathArray<T>::MeanSigma(TArray<T> const & a..) Not Allocated Array a !");
+//   const T * pe;
+//   sa_size_t j,k;
+//   mean=0.;
+//   sig = 0.;
+//   T valok;
+//   if (a.AvgStep() > 0)   {  // regularly spaced elements
+//     sa_size_t step = a.AvgStep(); 
+//     sa_size_t maxx = a.Size()*step;
+//     pe = a.Data();
+//     for(k=0; k<maxx; k+=step )  { 
+//       valok = pe[k]; 
+//       mean += valok;  sig += valok*valok;
+//     }
+//   }
+//   else {    // Non regular data spacing ...
+//     int_4 ka = a.MaxSizeKA();
+//     sa_size_t step = a.Step(ka);
+//     sa_size_t gpas = a.Size(ka)*step;
+//     sa_size_t naxa = a.Size()/a.Size(ka);
+//     for(j=0; j<naxa; j++)  {
+//       pe = a.DataBlock().Begin()+a.Offset(ka,j);
+//       for(k=0; k<gpas; k+=step) { 
+// 	valok = pe[k]; 
+// 	mean += valok;  sig += valok*valok;
+//       }
+//     }
+//   }
+//   T dsz = (T)(a.Size());
+//   mean /= dsz;
+//   if (dsz > 1.5) {
+//     sig = sig/dsz - mean*mean;
+//     sig *= (dsz/(dsz-1));
+//     if (sig >= 0.) sig = sqrt(sig);
+//   }
+//   else sig = 0.;
+// }
+
 
 sa_size_t freqToChan(r_4 f){
@@ -79,5 +120,5 @@
   for (sa_size_t ir=0; ir<nr; ir++){
     TVector<r_4> tmp(mtx(Range(ir),Range(chLow,chHigh)),false);
-    double mean, sigma;
+    r_8 mean, sigma;
     MeanSigma(tmp,mean,sigma);
     vec(ir) = mean;
@@ -573,6 +614,6 @@
     nr = calibBAOfactors_Off_Run_Ch0.NRows();
     for (sa_size_t ir=0; ir<nr; ++ir){
-//       cout << "Calib. Off Run Ch0 cycle ["<< calibBAOfactors_Off_Run_Ch0(ir,0)<<"], val "
-// 	   << calibBAOfactors_Off_Run_Ch0(ir,1) << endl;
+      cout << "Calib. Off Run Ch0 cycle ["<< calibBAOfactors_Off_Run_Ch0(ir,0)<<"], val "
+	   << calibBAOfactors_Off_Run_Ch0(ir,1) << endl;
 
       calibBAO_Off_Run_Ch0[(int)calibBAOfactors_Off_Run_Ch0(ir,0)]
@@ -625,5 +666,5 @@
 	       << "Ch1 " << calibBAO_On_Cycle_Ch1[*ic] << endl;
 	} else {
-	  cout << "Cycle NOT calibrated " << endl;
+	  cout << "Cycle << " << *ic <<" NOT calibrated for file " << *iFile << endl;
 	}
       }//debug
@@ -760,4 +801,5 @@
 
       TVector<r_4> meanInRange_1410a1415Freq_OFF_noCalib(NUMBER_OF_CHANNELS);
+      //      meanInRange(aSpecOff,ch1410,ch1415,meanInRange_1410a1415Freq_OFF_noCalib);
       meanInRange(aSpecOffovOff,ch1410,ch1415,meanInRange_1410a1415Freq_OFF_noCalib);
 
@@ -769,4 +811,5 @@
 
       TVector<r_4> meanInRange_1410a1415Freq_ON_noCalib(NUMBER_OF_CHANNELS);
+      //meanInRange(aSpecOn,ch1410,ch1415,meanInRange_1410a1415Freq_ON_noCalib);
       meanInRange(aSpecOnovOff,ch1410,ch1415,meanInRange_1410a1415Freq_ON_noCalib);
 
@@ -845,4 +888,6 @@
     fos << PPFNameTag(tag) << onoffevolution;    
   }//end of save
+
+
 }
 //JEC 14/11/11 New meanRawDiffOnOffCycles START
@@ -851,6 +896,5 @@
 //Used like:
 //
-void 
-meanRawDiffOnOffCycles() throw(string) {
+void meanRawDiffOnOffCycles() throw(string) {
   list<string> listOfFiles;
   string directoryName;
@@ -1095,4 +1139,6 @@
 
   }//end save
+
+
 }
 //JEC 14/11/11 New meanRawDiffOnOffCycles END
Index: ORadio/AmasNancay/trunk/mergeRawOnOff.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/mergeRawOnOff.pic	(revision 609)
+++ 	(revision )
@@ -1,93 +1,0 @@
-defscript sumSpec
-
-set source "Abell${1}"
-set srclower "abell${1}"
-set date $2
-# implicitement firstcycle =1
-set lastcycle $3
-lastP1cycle = ${lastcycle}+1
-
-openppf ${toppath}/${source}/${date}${srclower}/diffOnOffRaw_${date}_${srclower}.ppf
-
-#specONOFFRaw<i>       Matrix 2 x 8192 : i=0...
-
-for ic 1:${lastP1cycle}
-    del sOnOffv0
-    del sOnOffv1
-    objaoper specONOFFRaw${ic} row 0 sOnOffv0	
-    objaoper specONOFFRaw${ic} row 1 sOnOffv1	
-    c++exec specONOFFv0+=sOnOffv0; specONOFFv1+=sOnOffv1;
-end
-
-
-endscript
-
-
-########################################################################
-#MAIN
-########################################################################
-set cols ( blue red black green purple orange cyan violet yellow )
-
-set toppath "."
-set source "Abell${1}"
-set srclower "abell${1}"
-
-#The output spectra 
-#newvec specONOFFv0 8192
-#newvec specONOFFv1 8192
-
-c++exec TVector<r_4> specONOFFv0(8192,2); TVector<r_4> specONOFFv1(8192,2); \
-	KeepObj(specONOFFv0);KeepObj(specONOFFv1);
-
-#set the runs to merge
-
-set dateTag ( 20110507 20110602 20110729 20110806 )
-set nCycles ( 24 14 27 26 )
-line2vec tmpvec $nCycles
-
-#do It
-for i 0:${tmpvec.size}
-  sumSpec 85 $dateTag[i] $nCycles[i]
-end
-c++exec specONOFFv0/=tmpvec.Sum(); specONOFFv1/=tmpvec.Sum();
-
-
-#########
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-plot2d   specONOFFv0    (n/8192)*250+1250 val n>0 "same blue cpts nsta notit"
-plot2d   specONOFFv1    (n/8192)*250+1250 val n>0 "same red cpts nsta notit"
-settitle "ON-OFF  ${source} Ch 0 (blue) Ch 1 (red) ${tmpvec.sum} cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-
-#########
-#Perform the frequancy rebinning to compute MEAN & SIGMA
-#########
-c++compile reducing        
-c++link reducing.so doreduc
-
-cp specONOFFv0 specv0
-cp specONOFFv1 specv1
-call doreduc
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
- del redMeanv0                                                                      
- del redMeanv1                                                                      
- objaoper reducedMeanDiffOnOff row 0 redMeanv0                                      
- objaoper reducedMeanDiffOnOff row 1 redMeanv1                                      
- plot2d redMeanv0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7 nsta notit"        
- plot2d redMeanv1 (n/32)*250+1250 val n>0 "same red marker=fcircle,7 nsta notit"
-settitle "ON-OFF  ${source} Ch 0 (blue) Ch 1 (red) ${tmpvec.sum} cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
-
-newwin 1 1
-graphicatt "xylimits=1250,1500,0,0.001"
- del redSigmav0                                                                      
- del redSigmav1                                                                      
- objaoper reducedSigmaDiffOnOff row 0 redSigmav0                                      
- objaoper reducedSigmaDiffOnOff row 1 redSigmav1                                      
- plot2d redSigmav0 (n/32)*250+1250 val n>0 "blue marker=fcircle,7 nsta notit"        
- plot2d redSigmav1 (n/32)*250+1250 val n>0 "same red marker=fcircle,7 nsta notit"
-settitle "ON-OFF  ${source} Ch 0 (blue) Ch 1 (red) ${tmpvec.sum} cycles"
-setaxelabels "Freq. (MHz)" "I (a.u)"
Index: ORadio/AmasNancay/trunk/plotDiffOnOff.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/plotDiffOnOff.pic	(revision 609)
+++ 	(revision )
@@ -1,116 +1,0 @@
-#$1: source
-#$2: nber of cycles
-#$3: number of freq. combined for reducing mean/sigma
-
-set source $1
-set ncycles $2
-set nFreqBin $3
-set action $4
-
-set defatt "font=helvetica,bold,20 fixedfontsize"
-
-
-
-if ( ${action} == "mean" ) then
-
-openppf meanDiffOnOffRaw_${source}-${ncycles}Cycles.ppf
-
-
-##General Mean
-del s0 s1
-objaoper mean row 0 s0
-objaoper mean row 1 s1
-graphicatt "${defatt} xylimits=1250,1500,-0.01,0.01"
-newwin 1 1
-plot2d s0 (n/8192)*250+1250 val n>0 "cpts blue nsta notit"
-plot2d s1 (n/8192)*250+1250 val n>0 "same cpts red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "<(ON-OFF)[r,c]/Gain[r]>_{r,c}" $defatt
-
-
-
-##Reduced Mean
-newwin 1 1
-del rs0 rs1
-objaoper meanred row 0 rs0
-objaoper meanred row 1 rs1
-plot2d rs0 (n/${nFreqBin})*250+1250 val n>0 "marker=fcircle,5 blue nsta notit"
-plot2d rs1 (n/${nFreqBin})*250+1250 val n>0 "same marker=fcircle,5 red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "<(ON-OFF)[r,c]/Gain[r]>_{r,c} Rebin(${nFreqBin})" $defatt
-
-
-##Reduced Mean
-newwin 1 1
-del rss0 rss1
-objaoper sigmared row 0 rss0
-objaoper sigmared row 1 rss1
-plot2d rss0 (n/${nFreqBin})*250+1250 val n>0 "marker=fcircle,5 blue nsta notit"
-plot2d rss1 (n/${nFreqBin})*250+1250 val n>0 "same marker=fcircle,5 red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt 
-setaxelabels "Freq. (MHz)" "Sigma[(ON-OFF)[r,c]/Gain[r]] Rebin(${nFreqBin})" $defatt
-
-######
-else
-######
-
-openppf medianDiffOnOffRaw_${source}-${ncycles}Cycles.ppf
-
-
-##General Median
-del s0 s1
-objaoper median row 0 s0
-objaoper median row 1 s1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-newwin 1 1
-plot2d s0 (n/8192)*250+1250 val n>0 "cpts blue nsta notit"
-plot2d s1 (n/8192)*250+1250 val n>0 "same cpts red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "Median[(ON-OFF)[r,c]/Gain[r]]"  $defatt
-
-
-##Reduced Mean of the median
-newwin 1 1
-del rs0 rs1
-objaoper meanmedred row 0 rs0
-objaoper meanmedred row 1 rs1
-graphicatt "xylimits=1250,1500,-0.01,0.01"
-plot2d rs0 (n/${nFreqBin})*250+1250 val n>0 "marker=fcircle,5 blue nsta notit"
-plot2d rs1 (n/${nFreqBin})*250+1250 val n>0 "same marker=fcircle,5 red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "Mean Median[(ON-OFF)[r,c]/Gain[r]] Rebin(${nFreqBin})" $defatt
-
-
-##Reduced Sigma of the median
-newwin 1 1
-del rss0 rss1
-objaoper sigmamedred row 0 rss0
-objaoper sigmamedred row 1 rss1
-graphicatt "xylimits=1250,1500,0,0.01"
-plot2d rss0 (n/${nFreqBin})*250+1250 val n>0 "marker=fcircle,5 blue nsta notit"
-plot2d rss1 (n/${nFreqBin})*250+1250 val n>0 "same marker=fcircle,5 red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "Sigma Median[(ON-OFF)[r,c]/Gain[r]] Rebin(${nFreqBin})" $defatt
-
-
-##Normalized General Median
-del ngms0 ngms1
-objaoper medianNorm row 0 ngms0
-objaoper medianNorm row 1 ngms1
-graphicatt "xylimits=1250,1500,-2,2"
-newwin 1 1
-plot2d ngms0 (n/8192)*250+1250 val n>0 "cpts blue nsta notit"
-plot2d ngms1 (n/8192)*250+1250 val n>0 "same cpts red nsta notit"
-settitle "$source (${ncycles} cycles) Ch 0 (blue) Ch 1 (red)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "Norm Median[(ON-OFF)[r,c]/Gain[r]]"  $defatt
-
-del prod
-c++exec TVector<r_4>prod(ngms0.NElts(),BaseArray::RowVector); prod=ngms0&&ngms1;KeepObj(prod);
-newwin 1 1
-plot2d prod (n/8192)*250+1250 val n>0 "cpts blue nsta notit"
-settitle "$source (${ncycles} cycles)" ' ' $defatt
-setaxelabels "Freq. (MHz)" "Product Norm Median[(ON-OFF)[r,c]/Gain[r]]"  $defatt
- 
-
-endif
-
Index: /BAORadio/AmasNancay/trunk/plotRawDiffOnOff.pic
===================================================================
--- /BAORadio/AmasNancay/trunk/plotRawDiffOnOff.pic	(revision 609)
+++ /BAORadio/AmasNancay/trunk/plotRawDiffOnOff.pic	(revision 610)
@@ -22,4 +22,5 @@
 
 openppf rawOnOffDiff_${source}-${ncycles}Cycles.ppf
+
 
 clearscript evolAt1420Freq
Index: ORadio/AmasNancay/trunk/proc_script.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/proc_script.sh	(revision 609)
+++ 	(revision )
@@ -1,498 +1,0 @@
-#!/bin/sh -xvf
-#Basic tuning of system fuction used.
-AWK=/bin/awk
-SED=/bin/sed
-GREP=/bin/grep
-WC=/usr/bin/wc
-RM=/bin/rm
-CAT=/bin/cat
-TOUCH=/bin/touch
-DATE=/bin/date
-ECHO=/bin/echo
-LS=/bin/ls
-MKDIR=/bin/mkdir
-TR=/usr/bin/tr
-FIND=/usr/bin/find
-PRINTF=/usr/bin/printf
-XARGS=/usr/bin/xargs
-SORT=/bin/sort
-QSUB=qsub
-
-DefaultIFS=$' \t\n'
-IFS=$DefaultIFS
-
-
-scriptName="`basename $0`"
-$ECHO "Processing script ${scriptName} at `date`"
-######
-# Local functions
-######
-usage() {
-  echo "usage: $scriptName <source> <YYYYMMDD-directory> <type of process>"
-  echo "      -<source> as Abell85"
-  echo "      -<YYYYMMDD-directory> as 20110428"
-  echo "      -<type of process> as GAIN|CALIBON|CALIBOFF|ON|OFF"
-}
-######
-# argument test
-######
-if [ ! $# = 3 ]; then
-  usage
-  exit 1
-fi
-sourceRadio=$1
-srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
-dateDAQ=$2
-typeofproc=$3
-
-#Path to public backupable path
-publicpath="/afs/in2p3.fr/home/c/campagne/public"
-
-#temporary files to synchronize scripts
-tmppublicpath=${TMPPUBLICPATH}
-$LS -l ${tmppublicpath} > /dev/null
-
-
-#Path where the job will do temporary IO
-. ${SCRIPTPATH}/set_iojobpath.sh
-iojobpath=$(set_iojobpath)
-cd ${iojobpath}
-
-localpath="${sourceRadio}/${dateDAQ}${srclower}"
-$MKDIR -p ./${localpath}
-cd ./${localpath}
-mainDirectory=`pwd`
-
-
-#Path of the utility scripts
-scriptpath=${SCRIPTPATH}
-
-
-#select file per cycle
-#$ECHO "Select files process..."
-#keep only lines with structure: cycle_number first,last,step
-#Get sca files
-$ECHO "DEBUG (${scriptName}): START call getscafiles.sh ${sourceRadio} ${dateDAQ}"
-OUT1=./getScaStatus.$$
-$RM -f ${tmppublicpath}/getscafiles.finished
-${scriptpath}/getscafiles.sh ${sourceRadio} ${dateDAQ} > ${OUT1} 2>&1
-while [ ! -f "${tmppublicpath}/getscafiles.finished" ]; do
-    $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/getscafiles.finished"
-    date +%T
-    sleep 30
-done
-$RM ${tmppublicpath}/getscafiles.finished
-$ECHO "DEBUG (${scriptName}): END"
-
-
-getScaStatus=`$GREP "^\(FATAL\|ERROR\)" ${OUT1}`
-
-if [ "<${getScaStatus}>" != "<>" ]; then
-  $ECHO "FATAL (${scriptName}): error to get sca file for $sourceRadio $dateDAQ"
-  $ECHO "DEBUG (${scriptName}): START with cat ${OUT1}"
-  $CAT ${OUT1}
-  $ECHO "DEBUG (${scriptName}): END"
-  exit 1
-fi
-
-
-scaFileSummarized=`$FIND . -name "sca*.sum" -print`
-if [ "<${scaFileSummarized}>" = "<>" ]; then
-  $ECHO "FATAL (${scriptName}): strange sca file summarized not available: $sourceRadio $dateDAQ"
-  $ECHO "DEBUG (${scriptName}): START with cat ${OUT1}"
-  $CAT ${OUT1}
-  $ECHO "DEBUG (${scriptName}): END"
-  exit 1
-fi
-$RM ${OUT1}
-
-scaFileSummarized=`basename $scaFileSummarized`
-
-#set Irods environment
-. /usr/local/shared/bin/irods_env.sh -noverbose
-#download header files to be used for signal files selction
-$MKDIR -p ./Fiber1
-dirFiberfile=`pwd`/Fiber1
-
-dirIrods="/baoradio/data/AmasNancay/${sourceRadio}/${dateDAQ}${srclower}/Fiber1"
-
-listOfFiles=( `ils ${dirIrods} | $GREP -i "header" | $XARGS -i basename {} | $SORT -k1.7n` )
-IFS='
-'
-listOfFiles=( $( $PRINTF "%s\n" "${listOfFiles[@]}" | $AWK 'x[$0]++ == 0' ) )
-IFS=$DefaultIFS
-
-#
-$ECHO "DEBUG (${scriptName}): Download if necessary the headers"
-#
-for ifile in ${listOfFiles[@]}
-do
-#test if the headers have not yet been downloaded
-  if [ ! -e ${dirFiberfile}/${ifile} ]; then
-      OUT2=./getheaders.$$
-      iget -f -K ${dirIrods}/${ifile} ${dirFiberfile} >${OUT2} 2>&1
-      igetStatus=`$GREP "^ERROR" ${OUT2}`
-      if [ "<$igetStatus>" != "<>" ]; then
-	  $ECHO "FATAL (${scriptName}): error while iget:"
-	  $ECHO $igetStatus
-	  exit 1
-      fi
-      $RM -f $OUT2
-  fi
-done
-#
-$ECHO "DEBUG (${scriptName}): START call select.sh ${scaFileSummarized} ${dirFiberfile} ${typeofproc}"
-#
-#Get list of file to process
-headerFileSelected=./selectSignal.$$
-$RM -f ${tmppublicpath}/select.finished
-${scriptpath}/select.sh ${scaFileSummarized} ${dirFiberfile} ${typeofproc} | $GREP "^#[0-9]" | $SED "s/^#//" > $headerFileSelected
-while [ ! -f "${tmppublicpath}/select.finished" ]; do
-    $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/select.finished"
-    date +%T
-    sleep 30
-done
-$RM ${tmppublicpath}/select.finished
-#
-$ECHO "DEBUG (${scriptName}): END"
-#
-$ECHO "DEBUG (${scriptName}): START filling cycleArray, filesArray"
-#
-declare -a cycleArray
-declare -a filesArray
-$ECHO "DEBUG (${scriptName}): IFS value between<>: <$IFS>"
-IFS=$DefaultIFS
-$ECHO "DEBUG (${scriptName}): START cat $headerFileSelected"
-$CAT $headerFileSelected
-$ECHO "DEBUG (${scriptName}): END cat $headerFileSelected"
-
-while read v1 v2
-do
- cycleArray[${#cycleArray[*]}]=$v1
- filesArray[${#filesArray[*]}]=$v2
-done < $headerFileSelected
-
-if [ ${#cycleArray[*]} -eq 0 -o ${#filesArray[*]} -eq 0 ]; then
-   $ECHO "FATAL (${scriptName}): no header file selected (${#cycleArray[*]}, ${#filesArray[*]})"
-   exit 1
-else
-   $ECHO "DEBUG (${scriptName}): non zero elements found for cycleArray and filesArray" 
-fi
-
-#
-$ECHO "DEBUG (${scriptName}): number of elements <${#cycleArray[*]}> <${#filesArray[*]}>"
-$ECHO "DEBUG (${scriptName}): END"
-#
-# (timeShift)
-#Add 3sec to start ON / OFF
-#Substract 4sec to start DAB ON / OFF
-#
-#Take care: Cycle numbering starts at 1 in SCAFiles while Arrays index start at 0
-#
-#for GAIN the reference cycle takes the middle of the run
-#
-#nwinmean donne le nombre de fenetre tspwin utilise pour faire calculer la moyenne des medianes de chaque fenetre
-#This is the nimber of paquets of the time window which change according to processing type
-$ECHO "DEBUG (${scriptName}): START switch on $typeofproc"
-#
-case "$typeofproc" in
-    GAIN)
-      $ECHO "process signal files for GAIN phase"
-      ingain=""
-      freqfilter="-freqfilter -"
-      nwinmean="1"
-      tspwin="5120"
-      dirName="Off"
-      cyclebasename="gaincycle"
-      indexStartHour="6"
-      timeShift="-4"
-      timeDuration="14"
-      firstCycleId=`expr  ${#cycleArray[*]} / 2`
-      firstCycleId=`expr ${firstCycleId} - 1`
-      lastp1CycleId=`expr ${firstCycleId} + 1`
-      ;;
-    ON)
-      $ECHO "process signal files for ON phases"
-      ingain="-gain gain_${dateDAQ}_${srclower}.fits"
-      freqfilter="-freqfilter 16"
-      nwinmean="5"
-      tspwin="5120"
-      dirName="On"
-      cyclebasename="datacycle"
-      indexStartHour="4"
-      timeShift="3"
-      timeDuration="30"
-      firstCycleId="0"
-      lastp1CycleId="${#cycleArray[@]}"
-      ;;
-    OFF)
-      $ECHO "process signal files for OFF phases"
-      ingain="-gain gain_${dateDAQ}_${srclower}.fits"
-      freqfilter="-freqfilter 16"
-      nwinmean="5"
-      tspwin="5120"
-      dirName="Off"
-      cyclebasename="datacycle"
-      indexStartHour="8"
-      timeShift="3"
-      timeDuration="30"
-      firstCycleId="0"
-      lastp1CycleId="${#cycleArray[@]}"
-      ;;
-    CALIBON)
-      $ECHO "process signal files for CALIBRATION ON phases"
-      ingain="-gain gain_${dateDAQ}_${srclower}.fits"
-      freqfilter="-freqfilter 16"
-      nwinmean="1"
-      tspwin="1024"
-      dirName="On"
-      cyclebasename="calibcycle"
-      indexStartHour="2"
-      timeShift="-4"
-      timeDuration="14"
-      firstCycleId="0"
-      lastp1CycleId="${#cycleArray[@]}"
-      ;;
-    CALIBOFF)
-      $ECHO "process signal files for CALIBRATION OFF phases"
-      ingain="-gain gain_${dateDAQ}_${srclower}.fits"
-      freqfilter="-freqfilter 16"
-      nwinmean="1"
-      tspwin="1024"
-      dirName="Off"
-      cyclebasename="calibcycle"
-      indexStartHour="6"
-      timeShift="-4"
-      timeDuration="14"
-      firstCycleId="0"
-      lastp1CycleId="${#cycleArray[@]}"
-      ;;
-    *)
-    $ECHO "FATAL (${scriptName}): type of processing"
-    usage
-    exit 1
-    ;;
-esac
-#
-$ECHO "DEBUG (${scriptName}): END"
-#
-#
-#Compute time windows (Warning usage of GMT date)
-#
-$ECHO "DEBUG (${scriptName}): START compute time windows"
-OUT=./baotiming.$$
-${AWK} -v datesys=${DATE} -v type=${indexStartHour} -v shift=${timeShift} '
-BEGIN {FS=","}
-{
-  phaseStart=$type
-  cmd=sprintf("%s +%%s -d  \"%s\" ",datesys,phaseStart);
-  (cmd | getline phstart);
-  close(cmd);
-  newstart = phstart+shift;
-  cmd=sprintf("%s +%%T -d \"1970-01-01 %s sec GMT\"",datesys,newstart);
-  (cmd | getline newStart);
-  close(cmd);
-  print $1,newStart,phaseStart;
-}
-'  ${scaFileSummarized} > ${OUT}
-#
-$ECHO "DEBUG (${scriptName}): END"
-#
-$ECHO "DEBUG (${scriptName}): START cat ${OUT}"
-$CAT ${OUT}
-$ECHO "DEBUG (${scriptName}): END cat ${OUT}"
-#
-$ECHO "DEBUG (${scriptName}): START filling cylceArrayBis timeArray"
-#
-declare -a cycleArrayBis
-declare -a timeArray
-$ECHO "DEBUG (${scriptName}): IFS value between<>: <$IFS>"
-IFS=$DefaultIFS
-#select the selected cycles
-idtofind="0"
-while read v1 v2 v3
-do
- if [ ${idtofind} -lt ${#cycleArray[*]} ]; then
-    if [ ${v1} = ${cycleArray[${idtofind}]} ]; then
-	cycleArrayBis[${#cycleArrayBis[*]}]=$v1
-	timeArray[${#timeArray[*]}]=$v2
-	idtofind=`expr ${idtofind} + 1`
-    fi
- fi
-done < ${OUT}
-$ECHO "DEBUG (${scriptName}): number of elements ${#cycleArrayBis[*]} ${#timeArray[*]}"
-$ECHO "DEBUG (${scriptName}): END"
-
-
-#########################
-# specmfib exe
-#########################
-prg="/afs/in2p3.fr/throng/baoradio/Library/Progs/TAcq/Objs/specmfib"
-if [ ! -e $prg ]; then
-    $ECHO "FATAL (${scriptName}): $prg not found"
-    exit 1
-fi
-
-
-dirFiberfile=${iojobpath}/${localpath}
-
-curDir=`pwd`
-#
-$ECHO "DEBUG (${scriptName}): in principle $dirFiberfile == $curDir "
-#
-#force single channel
-forceSingle="-singlechan"
-#debug
-prtlevel="1"
-
-
-#Loop on cycles to write batch script and send to batch queue
-##
-$ECHO "DEBUG (${scriptName}): START loop on cycles ${firstCycleId} to ${lastp1CycleId}"
-
-for ((i=${firstCycleId};i<${lastp1CycleId};i++)); do
-#
-$ECHO "DEBUG (${scriptName}): process cycle $i"
-#time window selection
-    tmproc="-tmproc ${timeArray[${i}]},${timeDuration}"
-#cycle <name><number>
-    cycle="${cyclebasename}${cycleArray[${i}]}"
-#signal files selection
-    infiles="${filesArray[${i}]}"
-#
-#Prepare BQS parameters: MEMORY, CPU...#
-    infilesArray=( `$ECHO $infiles | $AWK 'BEGIN {FS=","} {for(i=1;i<NF;i++)print $i;}'` )
-    IFS='
-    '
-    infilesArray=( $( printf "%s\n" "${infilesArray[@]}" | awk 'x[$0]++ == 0' ) )
-    IFS=$DefaultIFS
-    firstFile=${infilesArray[0]}
-    lastFile=${infilesArray[1]}
-#compute Scratch Size MB (400MB per signal files), CPU Time
-    nFiles=`expr ${lastFile} - ${firstFile} + 1`
-# Fiber 1 & Fiber 2 => double the number of files
-    nFiles=`expr ${nFiles} \* 2`
-#add number of spectra generated (cf. (Nbrepaquets_per_files * nFiles /tspwin) * 100KB
-    nSpectra=`expr ${nFiles} \* 25600 /  ${tspwin}`
-#Guess formula to reserved the amount of space needed in scratch
-    scratchSize=`expr ${nFiles} \* 500 + ${nSpectra} \* 200 / 1000 + 5`
-# 60sec/signal_file * empirical_conversion_factor (=50)
-    cpu=`expr ${nFiles} \* 60 \* 50`
-#Virtual Memory (MB) Nb: at CCIN2P3 the reasonable max is 1GB
-    virtualmem=1000
-#Job and batch names
-    jobBatchName="${sourceRadio}-${dateDAQ}-${typeofproc}-cycle${cycleArray[${i}]}"
-    jobScriptName="${jobBatchName}.sh"
-    jobLogName="${jobBatchName}.log"
-#
-$ECHO "DEBUG (${scriptName}): start writing ${jobScriptName}"
-#
-#
-#write the script to be send to Batch
-#
-    $CAT > ${jobScriptName} <<EOF
-#!/bin/sh -xvf
-#    jobBatchName=$jobBatchName
-#    jobScriptName=$jobScriptName
-#    jobLogName=$jobLogName
-    scriptName=$jobScriptName
-
-    . /afs/in2p3.fr/home/throng/baoradio/setup.sh
-    . /usr/local/shared/bin/irods_env.sh -noverbose
-
-    iojobpath=\${TMPBATCH}
-    cd \${iojobpath}
-    localpath=${sourceRadio}/${dateDAQ}${srclower}
-    $MKDIR -p ./\${localpath}
-    cd ./\${localpath}
-
-    curDir=\`pwd\`
-#get gain file if necessary
-    if [ ${typeofproc} != "GAIN" ]; then
-	OUT2=./igetStatus.$$
-	iget /baoradio/data/AmasNancay/${localpath}/gain_${dateDAQ}_${srclower}.fits >\${OUT2} 2>&1
-	igetStatus=\`$GREP "^ERROR" \${OUT2}\`
-	if [ "<\${igetStatus}>" != "<>" ]; then
-	    $ECHO "FATAL (\${scriptName}): error while iget:"
-	    $ECHO \$igetStatus
-	    exit 1
-	fi
-        $RM \${OUT2}
-    fi    
-#get signals files
-    OUT3=./getsignals.$$
-    $RM -f ${tmppublicpath}/getsignalfiles.finished
-    ${scriptpath}/getsignalfiles.sh ${sourceRadio} ${dateDAQ} ${firstFile}  ${lastFile} > \${OUT3} 2>&1
-    while [ ! -f "${tmppublicpath}/getsignalfiles.finished" ]; do
-	$ECHO "INFO (\${scriptName}): waiting for ${tmppublicpath}/getsignalfiles.finished"
-	date +%T
-	sleep 30
-    done
-    $RM ${tmppublicpath}/getsignalfiles.finished
-
-    getSignals=\`$GREP "^FATAL" \${OUT3}\`
-    if [ "<\$getSignals>" != "<>" ]; then
-	$ECHO "FATAL (\${scriptName}): error while get signals"
-	$ECHO \$getSignals
-	exit 1
-    fi
-    $RM \${OUT3}
-#location of the signal file
-    fibfile="\${curDir} 1,2"
-#
-    outDir=\${curDir}/${dirName}/${cycle}
-    $MKDIR -p \${outDir}
-
-#
-# where ami...
-#
-    $ECHO "We are here \`pwd\` to send the batch"
-    $LS -lrth
-    $FIND . -name "igetStatus.*" | $XARGS -i  $CAT {}
-    $LS ./Fiber1 | $WC -l
-    $LS ./Fiber2 | $WC -l
-    $LS -lR \${outDir}
-
-#Note: here act=gain means only that specmfib will use median-like algorithms (not only for gains...)
-    $prg -act gain $forceSingle $freqfilter  -prt $prtlevel -out \${outDir} -nmean $nwinmean $ingain $tmproc -tspwin ${tspwin},0,0 -in $infiles \${fibfile}
-
-    $ECHO    \${outDir}
-    $LS -lrt \${outDir}
-
-#save results to Irods (use option -f ONLY to force override)
-    iput -v -K -r \${curDir}/${dirName} /baoradio/data/AmasNancay/\${localpath}
-#
-#clean the signal files which can at the end of the day fill completly the scratch directory of the batch work/AmasNancayer
-    $RM -f \${iojobpath}/\${localpath}/Fiber1/signal*.fits
-    $RM -f \${iojobpath}/\${localpath}/Fiber2/signal*.fits
-    exit 0
-EOF
-#
-#The EOF tag MUST BEGIN the line, this is the end of the script
-#
-    $ECHO "DEBUG (${scriptName}); START listing of script to be send to batch queue"
-    $CAT -v ${jobScriptName}
-    $ECHO "DEBUG (${scriptName}): END listing"
-#
-#send to BATCH
-#
-    $ECHO "DEBUG (${scriptName}): START send to batch listing"
-#
-    $RM -f ${tmppublicpath}/${jobBatchName}.finished
-
-##26/9/11 JEC use option -h to trig manualy the job on the queue...
-    qsub -h -l u_sps_baoradio,u_irods,u_irods_baoradio,T=${cpu},M=${virtualmem}MB,scratch=${scratchSize}MB,platform=LINUX -eo -o ${tmppublicpath}/${jobLogName} -N ${jobBatchName}  ${jobScriptName}
-
-#    while [ ! -f "${tmppublicpath}/${jobBatchName}.finished" ]; do
-#	$ECHO "INFO (${scriptName}); waiting for ${tmppublicpath}/${jobBatchName}.finished"
-#	date +%T
-#	sleep 600
-#    done
-#    $RM ${tmppublicpath}/${jobBatchName}.finished
-    $ECHO "DEBUG (${scriptName}): end send to batch listing"
-#end loop on cycles
-done
-#
-$ECHO "DEBUG (${scriptName}): END loop on cycles"
-#
-exit 0
