Index: /BAORadio/AmasNancay/anarawonoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/anarawonoffmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/anarawonoffmaker.sh	(revision 542)
@@ -82,4 +82,6 @@
     iojobpath="/sps/baoradio/AmasNancay/JEC"
     $MKDIR -p $iojobpath
+    $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
+    exit 0;
 elif [ ${ENVIRONMENT} = "BATCH" ] ; then
     iojobpath=${TMPBATCH}
Index: /BAORadio/AmasNancay/calibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/calibmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/calibmaker.sh	(revision 542)
@@ -84,4 +84,6 @@
     iojobpath="/sps/baoradio/AmasNancay/JEC"
     $MKDIR -p $iojobpath
+    $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
+    exit 0;
 elif [ ${ENVIRONMENT} = "BATCH" ] ; then
     iojobpath=${TMPBATCH}
@@ -140,4 +142,5 @@
   cd ${topDir}
   $LS | $XARGS -i $RM -rf {}
+
   
   $ECHO "DEBUG: (${scriptName}) irods root dir $i"
Index: /BAORadio/AmasNancay/gainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/gainmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/gainmaker.sh	(revision 542)
@@ -82,4 +82,6 @@
     iojobpath="/sps/baoradio/AmasNancay/JEC"
     $MKDIR -p $iojobpath
+    $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
+    exit 0;   
 elif [ ${ENVIRONMENT} = "BATCH" ] ; then
     iojobpath=${TMPBATCH}
Index: /BAORadio/AmasNancay/mergeRawOnOff.cc
===================================================================
--- /BAORadio/AmasNancay/mergeRawOnOff.cc	(revision 541)
+++ /BAORadio/AmasNancay/mergeRawOnOff.cc	(revision 542)
@@ -37,4 +37,9 @@
 #include "ppersist.h"
 
+//-----------------------------------------------
+const sa_size_t NUMBER_OF_CHANNELS = 2;
+const sa_size_t  NUMBER_OF_FREQ = 8192;
+const r_4    LOWER_FREQUENCY = 1250.0; //MHz
+const r_4    TOTAL_BANDWIDTH = 250.0; //MHz
 //-----------------------------------------------
 char *regexp (const char *string, const char *patrn, int *begin, int *end) {    
@@ -61,5 +66,5 @@
 
 struct Param {
-  string debuglev_;
+  int debuglev_;
   string inPath_;
   string outPath_;
@@ -154,4 +159,5 @@
   directoryName = para.inPath_ + "/" + para.sourceName_;
 
+  //Make the listing of the directory
   listOfFiles = ListOfFileInDir(directoryName,para.ppfFile_);
   
@@ -159,10 +165,16 @@
   iFileEnd = listOfFiles.end();
   
-  StringMatch match("specONOFFRaw[0-9]+");
+  StringMatch match("specONOFFRaw[0-9]+"); //Tag of the PPF objects
+  TMatrix<r_4> sumOfSpectra(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+  uint_4 nSpectra=0;
+  //Loop on files
   for (iFile = listOfFiles.begin(); iFile != iFileEnd; ++iFile) {
-    cout << "load file <" << *iFile << ">" << endl;
+    if (para.debuglev_>90){
+      cout << "load file <" << *iFile << ">" << endl;
+    }
     PInPersist fin(*iFile);
     vector<string> vec = fin.GetNameTags();
     list<string> listOfSpectra;
+    //Keep only required PPF objects
     std::remove_copy_if(
 			vec.begin(), vec.end(), back_inserter(listOfSpectra),
@@ -172,11 +184,29 @@
     iSpecEnd = listOfSpectra.end();
     listOfSpectra.sort(stringCompare);
-
+    //Loop of spectra matrix
     for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd;  ++iSpec){
-      cout << " spactra <" << *iSpec << ">" << endl;
-    }
-
-  }
-  
+      if (para.debuglev_>90){
+	cout << " spactra <" << *iSpec << ">" << endl;
+      }
+      TMatrix<r_4> aSpec(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+      fin.GetObject(aSpec,*iSpec);
+      //How to see if the GetObject is ok?? Ask Reza
+      nSpectra++;
+      sumOfSpectra+=aSpec;
+    }//eo loop on spectra in a file
+  }//eo loop on files
+  
+  //Normalisation
+  if(nSpectra>0)sumOfSpectra/=(r_4)(nSpectra);
+
+  {//Save the result
+    stringstream tmp;
+    tmp << nSpectra;
+    string fileName = para.outPath_+"/meanDiffOnOffRaw_"+StringToLower(para.sourceName_)+"-"+tmp.str()+"Cycles.ppf";
+    cout << "Save mean based on " <<  nSpectra << " cycles " << endl;
+    string tag = "mean";
+    POutPersist fos(fileName);
+    fos << PPFNameTag(tag) << sumOfSpectra;
+  }
 }
 //-------------------------------------------------------
@@ -226,5 +256,5 @@
   }//eo while
 
-  para.debuglev_ = debuglev;
+  para.debuglev_ = atoi(debuglev.c_str());
   para.inPath_   = inputPath;
   para.outPath_  = outputPath;
@@ -250,7 +280,7 @@
   try {
 
-    int b,e;
-    char *match=regexp("truc0machin","[a-z]+[0-9]*",&b,&e);
-    printf("->%s<-\n(b=%d e=%d)\n",match,b,e);
+//     int b,e;
+//     char *match=regexp("truc0machin","[a-z]+[0-9]*",&b,&e);
+//     printf("->%s<-\n(b=%d e=%d)\n",match,b,e);
 
     if ( action == "default" ) {
Index: /BAORadio/AmasNancay/onoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/onoffmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/onoffmaker.sh	(revision 542)
@@ -84,4 +84,6 @@
     iojobpath="/sps/baoradio/AmasNancay/JEC"
     $MKDIR -p $iojobpath
+    $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
+    exit 0;
 elif [ ${ENVIRONMENT} = "BATCH" ] ; then
     iojobpath=${TMPBATCH}
Index: /BAORadio/AmasNancay/rawonoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/rawonoffmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/rawonoffmaker.sh	(revision 542)
@@ -82,4 +82,6 @@
     iojobpath="/sps/baoradio/AmasNancay/JEC"
     $MKDIR -p $iojobpath
+    $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
+    exit 0;
 elif [ ${ENVIRONMENT} = "BATCH" ] ; then
     iojobpath=${TMPBATCH}
Index: /BAORadio/AmasNancay/submit2bqs-anarawonoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/submit2bqs-anarawonoffmaker.sh	(revision 541)
+++ /BAORadio/AmasNancay/submit2bqs-anarawonoffmaker.sh	(revision 542)
@@ -34,5 +34,5 @@
 
 
-jobBatchName="rawonoff-${sourceRadio}${dateJob}"
+jobBatchName="anarawonoff-${sourceRadio}${dateJob}"
 
 jobLogName="${jobBatchName}.log.$$"
