Index: /BAORadio/AmasNancay/trunk/anagainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/anagainmaker.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/anagainmaker.sh	(revision 598)
@@ -64,4 +64,5 @@
     Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
     Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
+    NGC4383) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
     *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
     exit 1;;
Index: /BAORadio/AmasNancay/trunk/analyse.cc
===================================================================
--- /BAORadio/AmasNancay/trunk/analyse.cc	(revision 597)
+++ /BAORadio/AmasNancay/trunk/analyse.cc	(revision 598)
@@ -37,4 +37,8 @@
 #include "fiosinit.h"
 #include "ppersist.h"
+
+
+//~/private/work/AmasNancay/Objs/analyse -act redMeanONOFF -source Abell85 -date 20110428 -sca sca151675.sum.trans -specdir meancycle -specname mspecmtx -sigmaname sigspecmtx -npaq 25000 -numcycle 1,11 -debug 100 > & redMean.log
+
 
 
@@ -256,4 +260,47 @@
 };
 
+//------------
+//Process ON/OFF data treated with the mspec (specmfib) => no filtering at all: paquets & freq.
+//------------
+class ProcessONOFFReducedMeanData : public ProcessBase {
+protected:
+  string sigma2FileName_; //name of the file which contains the sigma2
+  string nPaqPerWin_; // number of paquets used for mean and sigma2 computations 'cf. proc_specmfib'
+  r_4 valNPaqPerWin_; // value
+
+public:
+  ProcessONOFFReducedMeanData(){}
+  virtual ~ProcessONOFFReducedMeanData(){}
+  
+  void SetSigma2FileName(const string& val) {sigma2FileName_ = val;}
+  void SetNPaqPerWin(const string& val) {
+    nPaqPerWin_    = val;
+    valNPaqPerWin_ = atof(val.c_str());
+  }
+
+  virtual int processCmd() throw(string);
+};
+
+
+//------------
+//Process ON/OFF data treated with the gain (specmfib) => filtering paquets only by default
+//------------
+class ProcessONOFFReducedMedianData : public ProcessBase {
+protected:
+  string nPaqPerWin_; // number of paquets used for mean and sigma2 computations 'cf. proc_specmfib'
+  r_4 valNPaqPerWin_; // value
+
+public:
+  ProcessONOFFReducedMedianData(){}
+  virtual ~ProcessONOFFReducedMedianData(){}
+  
+  void SetNPaqPerWin(const string& val) {
+    nPaqPerWin_    = val;
+    valNPaqPerWin_ = atof(val.c_str());
+  }
+
+  virtual int processCmd() throw(string);
+};
+
 
 //------------
@@ -309,7 +356,4 @@
   upperFreqBin_ = c0+dc/2;
 }
-
-
-//----------------------------------------------------
 //----------------------------------------------------
 int main(int narg, char* arg[])
@@ -318,4 +362,6 @@
   //Init process types
   map<string,IProcess*> process;
+  process["redMedianONOFF"] = new ProcessONOFFReducedMedianData(); //JEC  8/11/11
+  process["redMeanONOFF"] = new ProcessONOFFReducedMeanData(); //JEC  8/11/11
   process["meanONOFF"] = new ProcessONOFFMeanData(); //JEC 27/10/11
   process["rawOnOff"]  = new ProcessONOFFRawData();  
@@ -352,7 +398,8 @@
   string numcycle;
   string calibrationOpt = "";  
+  string nPaqPerWin = "";
 
   string typeOfFile="medfiltmtx";
-  
+  string secondTypeOfFile=""; //valid for ProcessONOFFReducedMeanData JEC 8/11/11
 
   //  bool okarg=false;
@@ -396,4 +443,12 @@
       ka+=2;
     }    
+    else if (strcmp(arg[ka],"-sigmaname")==0) {
+      secondTypeOfFile=arg[ka+1];
+      ka+=2;
+    }    
+    else if (strcmp(arg[ka],"-npaq")==0) {
+      nPaqPerWin=arg[ka+1];
+      ka+=2;
+    } 
     else if (strcmp(arg[ka],"-freqBAOCalib")==0) {
       freqBAOCalib = arg[ka+1];
@@ -430,7 +485,9 @@
        << " spectraDirectory = " << spectraDirectory << "\n"
        << " spectraName = " << typeOfFile << "\n"
+       << " sigmaName = " << secondTypeOfFile << "\n"
+       << " nPaqPerWin = " << nPaqPerWin << "\n"
        << " freqBAOCalib = " << freqBAOCalib  << "\n"
        << " bandWidthBAOCalib = " << bandWidthBAOCalib << "\n"
-       << " debuglev = "  << debuglev  << "\n"
+       << " debug = "  << debuglev  << "\n"
        << " mode = " << mode << "\n"
        << " numcycle = " << numcycle << "\n"
@@ -517,4 +574,45 @@
 //     }
     //JEC 22/9/11 Make ON-OFF analysis WO any calibration END
+
+    //JEC 8/11/11 Start
+    try {
+      ProcessONOFFReducedMeanData* procdata=dynamic_cast<ProcessONOFFReducedMeanData*>(process[action]);
+      if (procdata) {
+	if (secondTypeOfFile == ""){
+	  msg = "(FATAL) missing file of the sigmas for action " + action;
+	  Usage(true);
+	  throw msg;	  
+	}
+	if (nPaqPerWin == ""){
+	  msg = "(FATAL) missing number of paquets per window for action " + action;
+	  Usage(true);
+	  throw msg;	  
+	}
+	procdata->SetSigma2FileName(secondTypeOfFile);
+	procdata->SetNPaqPerWin(nPaqPerWin);
+      }
+    }
+    catch(exception& e){
+      throw e.what();
+    }
+    //JEC 8/11/11 End
+
+    //JEC 8/11/11 Start
+    try {
+      ProcessONOFFReducedMedianData* procdata=dynamic_cast<ProcessONOFFReducedMedianData*>(process[action]);
+      if (procdata) {
+	if (nPaqPerWin == ""){
+	  msg = "(FATAL) missing number of paquets per window for action " + action;
+	  Usage(true);
+	  throw msg;	  
+	}
+	procdata->SetNPaqPerWin(nPaqPerWin);
+      }
+    }
+    catch(exception& e){
+      throw e.what();
+    }
+    //JEC 8/11/11 End
+    
 
 
@@ -611,5 +709,5 @@
 int Usage(bool flag) {
   cout << "Analyse.cc usage...." << endl;
-  cout << "analyse  -act <action_type>: meanONOFF,dataOnOff, rawOnOff, gain, calib\n"
+  cout << "analyse  -act <action_type>: redMeanONOFF, meanONOFF,dataOnOff, rawOnOff, gain, calib\n"
        << "         -inPath <path for input files: default='.'>\n"
        << "         -outPath <path for output files: default='.'>\n"
@@ -619,4 +717,8 @@
        << "         -specdir <generic directory name of spectra fits files>\n"
        << "         -specname <generic name of spectra fits files>\n"
+       << "         -sigmaname <generic name of the sigma2 fits files>\n"
+       << "            valid for redMeanONOFF\n"
+       << "         -npaq <number of paquest per windows for mean&sigma2 computaion (brproc)>\n"
+       << "            valid for redMeanONOFF\n"
        << "         -freqBAOCalib <freq in MHZ> freq. of calibration BAO\n"
        << "            valid for act=dataOnOff\n"
@@ -710,5 +812,6 @@
   string tag;
 
-  map< pair<string, sa_size_t>, TMatrix<r_4> > spectreCollect;
+  map< pair<string, sa_size_t>, TMatrix<r_4> > meanCollect;
+  map< pair<string, sa_size_t>, TMatrix<r_4> > sigma2Collect;
   map< pair<string, sa_size_t>, TMatrix<r_4> >::iterator iSpectre, iSpectreEnd;
   
@@ -744,4 +847,5 @@
       if(debuglev_>0)cout << "compute mean for cycle " << icycle << endl;
       TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
+      TMatrix<r_4> spectreSigma2(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
       iFileEnd = listOfSpecFiles.end();
       r_4 nSpectres  = 0;
@@ -750,11 +854,17 @@
 	TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
 	aSpectrum >> spectre;
-	spectreMean += spectre;
+	spectreMean   += spectre;
+	spectreSigma2 += spectre && spectre;
 	nSpectres++;
       }// end of for files 
-      if(nSpectres>0) spectreMean /= nSpectres;
+      if(nSpectres>0) {
+	spectreMean /= nSpectres;
+	spectreSigma2 /= nSpectres;
+	spectreSigma2 -= spectreMean && spectreMean;
+      }
       
       //save mean spectrum
-      spectreCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,icycle),TMatrix<r_4>(spectreMean,false) ));
+      meanCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,icycle),TMatrix<r_4>(spectreMean,false) ));
+      sigma2Collect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,icycle),TMatrix<r_4>(spectreSigma2,false) ));
     }//end of for cycles
   }//end loop on mode for raw preocess
@@ -764,10 +874,10 @@
     string fileName;
 
-    fileName = "./dataMean_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
+    fileName = "./dataMeanSigma2_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
 
     POutPersist fos(fileName);
     id=0;
-    iSpectreEnd = spectreCollect.end();
-    for (iSpectre = spectreCollect.begin();
+    iSpectreEnd = meanCollect.end();
+    for (iSpectre = meanCollect.begin();
 	 iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
       tag = "specMean";
@@ -780,7 +890,24 @@
  	cout << "save tag<" << tag << ">" << endl;
       }
-
       fos << PPFNameTag(tag) << iSpectre->second;
     }
+
+
+    id=0;
+    iSpectreEnd = sigma2Collect.end();
+    for (iSpectre = sigma2Collect.begin();
+	 iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
+      tag = "specSigma2";
+
+      tag += (iSpectre->first).first;
+      stringstream sid;
+      sid << (iSpectre->first).second;
+      tag += sid.str();
+      if(debuglev_>9) {
+ 	cout << "save tag<" << tag << ">" << endl;
+      }
+      fos << PPFNameTag(tag) << iSpectre->second;
+    }
+
   }//end of save fits
   
@@ -790,4 +917,400 @@
 
   cout << "OK ProcessONOFFMeanData finished" <<endl;
+  return rc;
+}
+//----------------------------------------------
+//----------------------------------------------
+//JEC 8/11/11
+//Process the files that are output of the specmfib -act = mspec (mean+sigma of signal files)
+//Compute the reduced variables r_i = (m_i - <m_i>)/(sig_i/sqrt(Npaq.))
+//----------------------------------------------
+int ProcessONOFFReducedMeanData::processCmd() throw(string) {
+  int rc = 0;
+  try {
+    rc = ProcessBase::processCmd();
+  } 
+  catch (string s) {
+    throw s;
+  }
+
+  if(debuglev_>0)cout << "Process Data" << endl;
+  vector<string> modeList;
+  modeList.push_back("On");
+  modeList.push_back("Off");
+  vector<string>::const_iterator iMode;
+  
+  uint_4 id; 
+  string tag;
+
+  map<string,  TMatrix<r_4> > meanSigmaRedRatioCollect;
+  map<string,  TMatrix<r_4> >::iterator iMeanSigmaRed, iMeanSigmaRedEnd;
+
+  map< pair<string, sa_size_t>, TMatrix<r_4> > reducedRatioCollect;
+  map< pair<string, sa_size_t>, TMatrix<r_4> >::iterator iReduced, iReducedEnd;
+
+  map< sa_size_t, TMatrix<r_4> > meanCollect;
+  map< sa_size_t, TMatrix<r_4> >::iterator iMean, iMeanEnd;
+
+  map< sa_size_t, TMatrix<r_4> > sigmaCollect;
+  map< sa_size_t, TMatrix<r_4> >::iterator iSigma, iSigmaEnd;
+  
+  //
+  //loop on modes
+  //
+  for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
+    string mode = *iMode;
+    if(debuglev_>0)cout << "Process Mean-mspec Mode " << mode << endl;
+
+
+    string directoryName;
+    list<string> listOfMeanFiles;
+    list<string> listOfSigma2Files;
+    
+    if (listOfMeanFiles.size() != listOfSigma2Files.size()) {
+      throw "ProcessONOFFReducedMeanData: FATAL: length (1) missmatch";
+    }
+    
+    list<string>::const_iterator iFile, iFileEnd;           
+    //Mean of all Means (one per Mode)
+    TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
+    uint_4 nMeans  = 0;
+    uint_4 nSigma2s  = 0;
+    //
+    //loop on cycles
+    //
+    for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
+      directoryName = inputPath_ + "/" 
+	+ sourceName_ + "/" + dateOfRun_ + StringToLower(sourceName_) + "/"
+	+ mode + "/";
+      stringstream sicycle;
+      sicycle << icycle;
+      directoryName += spectraDirectory_ + sicycle.str() + "/";
+
+      //read directory
+      listOfMeanFiles   = ListOfFileInDir(directoryName,typeOfFile_); //the means
+      listOfSigma2Files = ListOfFileInDir(directoryName,sigma2FileName_); //the sigma2s
+      
+      //get a mean spectra per file
+      iFileEnd = listOfMeanFiles.end();
+      for (iFile = listOfMeanFiles.begin(); iFile != iFileEnd; ++iFile) {
+// 	if(debuglev_>10){
+// 	  cout << "read file <" << *iFile << ">:";
+// 	}
+	FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
+	TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+	aSpectrum >> spectre;
+// 	if(debuglev_>10){
+// 	  cout << " mean of spectre = " << Mean(spectre) << endl;
+// 	}
+	//update mean
+	spectreMean   += spectre;
+	//save spectrum
+	meanCollect.insert( pair< sa_size_t, TMatrix<r_4> >(nMeans,TMatrix<r_4>(spectre,false) ));
+
+	nMeans++;
+      }// end of for files 
+
+      //get a sigma2 spectra per file and store the sigma
+      iFileEnd = listOfSigma2Files.end();
+      for (iFile = listOfSigma2Files.begin(); iFile != iFileEnd; ++iFile) {
+// 	if(debuglev_>10){
+// 	  cout << "read file <" << *iFile << ">:";
+// 	}
+	FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
+	TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+	aSpectrum >> spectre;
+// 	if(debuglev_>10){
+// 	  cout << " mean of spectre = " << Mean(Sqrt(spectre)) << endl;
+// 	}
+	//save sigma = Sqrt(sigma2)
+	sigmaCollect.insert( pair< sa_size_t, TMatrix<r_4> >(nSigma2s,TMatrix<r_4>(Sqrt(spectre),false) ));
+
+	nSigma2s++;
+      }// end of for files 
+
+    }//end of for cycles
+
+    
+    //finalize mean of means
+    if(nMeans>0) {
+      spectreMean /= (r_4)nMeans;
+//       if(debuglev_>10){
+// 	cout << "Mean mode [" << mode << "]: " << Mean(spectreMean) <<endl;
+//       }
+    } else {
+      throw "ProcessONOFFReducedMeanData: FATAL: nMeans=0 !!!";
+    }
+
+    if ( nMeans != nSigma2s ) {
+      cout << "ProcessONOFFReducedMeanData: nMeans, nSigma2s " 
+	   <<  nMeans << " " <<nSigma2s  
+	   << endl;
+      throw "ProcessONOFFReducedMeanData: FATAL: nMeans <> nSigma2s !!!";
+    }
+    
+    //from here nMeans == nSigma2s
+    iMeanEnd   = meanCollect.end();
+    iSigmaEnd  = sigmaCollect.end();
+    TMatrix<r_4> meanReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);   //implicit init to 0
+    TMatrix<r_4> sigma2ReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
+    for (id=0,iMean = meanCollect.begin(), iSigma=sigmaCollect.begin();
+	 id<nMeans; 
+	 ++id, ++iMean, ++iSigma) {
+      TMatrix<r_4> reducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+//       if(debuglev_>10){
+// 	cout << "reduced Mean [" << mode << "," << id << "]: " 
+// 	     << Mean(iMean->second) <<  " " 
+// 	     << Mean(spectreMean) <<  " " 
+// 	     << Mean(iSigma->second) << " "
+// 	     << sqrt(valNPaqPerWin_)
+// 	     << endl;
+//       }
+     
+      reducedRatio = iMean->second - spectreMean;
+      reducedRatio.Div(iSigma->second);
+      reducedRatio *= sqrt(valNPaqPerWin_);
+
+      meanReducedRatio   += reducedRatio;
+      sigma2ReducedRatio += reducedRatio&&reducedRatio;
+      
+//       if(debuglev_>10){
+// 	cout << "reduced Mean [" << mode << "," << id << "]: " << Mean(reducedRatio) <<endl;
+//       }
+     
+      reducedRatioCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,id),TMatrix<r_4>(reducedRatio,false) ));
+    }
+    
+    if(debuglev_>10) cout << "number of Means used: " << nMeans << "( =" << nSigma2s << ")" << endl;
+    meanReducedRatio   /= (r_4)nMeans;
+    sigma2ReducedRatio /= (r_4)nMeans;
+    sigma2ReducedRatio -= meanReducedRatio&&meanReducedRatio;
+    TMatrix<r_4> sigmaReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+    sigmaReducedRatio = Sqrt(sigma2ReducedRatio);
+    
+    
+    meanSigmaRedRatioCollect.insert( pair< string,  TMatrix<r_4> >(mode+"Mean",TMatrix<r_4>(meanReducedRatio,false)) );
+    meanSigmaRedRatioCollect.insert( pair< string,  TMatrix<r_4> >(mode+"Sigma",TMatrix<r_4>(sigmaReducedRatio,false)) );
+
+
+  }//end loop on mode for raw preocess
+
+  cout << "Save reduced variable based on Means/Sigmas" << endl;
+  string fileName;
+  
+  fileName = "./reducedMean_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
+  
+  POutPersist fos(fileName);
+  id=0;
+  iReducedEnd = reducedRatioCollect.end();
+  for (iReduced = reducedRatioCollect.begin();
+       iReduced != iReducedEnd ; ++iReduced, ++id) {
+    tag = "redMean";
+    
+    tag += (iReduced->first).first;
+    stringstream sid;
+    sid << (iReduced->first).second;
+    tag += sid.str();
+    if(debuglev_>9) {
+      cout << "save tag<" << tag << ">" << endl;
+    }
+    fos << PPFNameTag(tag) << iReduced->second;
+  }
+  
+  iMeanSigmaRedEnd = meanSigmaRedRatioCollect.end();
+  for (iMeanSigmaRed = meanSigmaRedRatioCollect.begin();
+       iMeanSigmaRed != iMeanSigmaRedEnd; 
+       ++iMeanSigmaRed){
+    tag = "redMean";
+    tag += iMeanSigmaRed->first;
+    if(debuglev_>9) {
+      cout << "save tag<" << tag << ">" << endl;
+    }
+    fos << PPFNameTag(tag) << iMeanSigmaRed->second;
+  }
+  
+  cout << "OK ProcessONOFFReducedMeanData finished" <<endl;
+  return rc;
+}
+//----------------------------------------------
+
+//----------------------------------------------
+//JEC 8/11/11
+//Process the files that are output of the specmfib -act = gain (median of signal files)
+//Compute the reduced variables r_i = (med_i - <med_i>)/(med_i/(Ln(2)*sqrt(N))
+//----------------------------------------------
+int ProcessONOFFReducedMedianData::processCmd() throw(string) {
+  int rc = 0;
+  try {
+    rc = ProcessBase::processCmd();
+  } 
+  catch (string s) {
+    throw s;
+  }
+
+  if(debuglev_>0)cout << "Process Data" << endl;
+  vector<string> modeList;
+  modeList.push_back("On");
+  modeList.push_back("Off");
+  vector<string>::const_iterator iMode;
+  
+  uint_4 id; 
+  string tag;
+
+  map<string,  TMatrix<r_4> > meanSigmaRedRatioCollect;
+  map<string,  TMatrix<r_4> >::iterator iMeanSigmaRed, iMeanSigmaRedEnd;
+
+  map< pair<string, sa_size_t>, TMatrix<r_4> > reducedRatioCollect;
+  map< pair<string, sa_size_t>, TMatrix<r_4> >::iterator iReduced, iReducedEnd;
+
+  map< sa_size_t, TMatrix<r_4> > medianCollect;
+  map< sa_size_t, TMatrix<r_4> >::iterator iMedian, iMedianEnd;
+
+  map< sa_size_t, TMatrix<r_4> > sigmaCollect;
+  map< sa_size_t, TMatrix<r_4> >::iterator iSigma, iSigmaEnd;
+  
+  //
+  //loop on modes
+  //
+  for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
+    string mode = *iMode;
+    if(debuglev_>0)cout << "Process Mean-mspec Mode " << mode << endl;
+
+
+    string directoryName;
+    list<string> listOfMedianFiles;
+    
+    list<string>::const_iterator iFile, iFileEnd;           
+    //Mean of all Medians (one per Mode)
+    TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
+    uint_4 nMedians  = 0;
+
+    //
+    //loop on cycles
+    //
+    for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
+      directoryName = inputPath_ + "/" 
+	+ sourceName_ + "/" + dateOfRun_ + StringToLower(sourceName_) + "/"
+	+ mode + "/";
+      stringstream sicycle;
+      sicycle << icycle;
+      directoryName += spectraDirectory_ + sicycle.str() + "/";
+
+      //read directory
+      listOfMedianFiles   = ListOfFileInDir(directoryName,typeOfFile_); //the means
+      
+      //get a mean spectra per file
+      iFileEnd = listOfMedianFiles.end();
+      for (iFile = listOfMedianFiles.begin(); iFile != iFileEnd; ++iFile) {
+// 	if(debuglev_>10){
+// 	  cout << "read file <" << *iFile << ">:";
+// 	}
+	FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
+	TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+	aSpectrum >> spectre;
+// 	if(debuglev_>10){
+// 	  cout << " mean of spectre = " << Mean(spectre) << endl;
+// 	}
+	//update mean
+	spectreMean   += spectre;
+	//save spectrum
+	medianCollect.insert( pair< sa_size_t, TMatrix<r_4> >(nMedians,TMatrix<r_4>(spectre,false) ));
+	sigmaCollect.insert( pair< sa_size_t, TMatrix<r_4> >(nMedians,TMatrix<r_4>(spectre,false) ));
+
+	nMedians++;
+      }// end of for files 
+
+    }//end of for cycles
+
+    
+    //finalize mean of means
+    if(nMedians>0) {
+      spectreMean /= (r_4)nMedians;
+//       if(debuglev_>10){
+// 	cout << "Mean mode [" << mode << "]: " << Mean(spectreMean) <<endl;
+//       }
+    } else {
+      throw "ProcessONOFFReducedMeanData: FATAL: nMedians=0 !!!";
+    }
+
+    iMedianEnd   = medianCollect.end();
+    iSigmaEnd  = sigmaCollect.end();
+    TMatrix<r_4> meanReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);   //implicit init to 0
+    TMatrix<r_4> sigma2ReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
+    for (id=0,iMedian = medianCollect.begin(), iSigma=sigmaCollect.begin();
+	 id<nMedians; 
+	 ++id, ++iMedian, ++iSigma) {
+      TMatrix<r_4> reducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+//       if(debuglev_>10){
+// 	cout << "reduced Mean [" << mode << "," << id << "]: " 
+// 	     << Mean(iMedian->second) <<  " " 
+// 	     << Mean(spectreMean) <<  " " 
+// 	     << Mean(iSigma->second) << " "
+// 	     << sqrt(valNPaqPerWin_)
+// 	     << endl;
+//       }
+     
+      reducedRatio = iMedian->second - spectreMean;
+      reducedRatio.Div(iSigma->second);
+      reducedRatio *= sqrt(valNPaqPerWin_)*log(2.0);
+
+      meanReducedRatio   += reducedRatio;
+      sigma2ReducedRatio += reducedRatio&&reducedRatio;
+      
+//       if(debuglev_>10){
+// 	cout << "reduced Mean [" << mode << "," << id << "]: " << Mean(reducedRatio) <<endl;
+//       }
+     
+      reducedRatioCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,id),TMatrix<r_4>(reducedRatio,false) ));
+    }
+    
+    if(debuglev_>10) cout << "number of Means used: " << nMedians << endl;
+    meanReducedRatio   /= (r_4)nMedians;
+    sigma2ReducedRatio /= (r_4)nMedians;
+    sigma2ReducedRatio -= meanReducedRatio&&meanReducedRatio;
+    TMatrix<r_4> sigmaReducedRatio(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
+    sigmaReducedRatio = Sqrt(sigma2ReducedRatio);
+    
+    
+    meanSigmaRedRatioCollect.insert( pair< string,  TMatrix<r_4> >(mode+"Mean",TMatrix<r_4>(meanReducedRatio,false)) );
+    meanSigmaRedRatioCollect.insert( pair< string,  TMatrix<r_4> >(mode+"Sigma",TMatrix<r_4>(sigmaReducedRatio,false)) );
+
+
+  }//end loop on mode for raw preocess
+
+  cout << "Save reduced variable based on Means/Sigmas" << endl;
+  string fileName;
+  
+  fileName = "./reducedMedian_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
+  
+  POutPersist fos(fileName);
+  id=0;
+  iReducedEnd = reducedRatioCollect.end();
+  for (iReduced = reducedRatioCollect.begin();
+       iReduced != iReducedEnd ; ++iReduced, ++id) {
+    tag = "redMedian";
+    
+    tag += (iReduced->first).first;
+    stringstream sid;
+    sid << (iReduced->first).second;
+    tag += sid.str();
+    if(debuglev_>9) {
+      cout << "save tag<" << tag << ">" << endl;
+    }
+    fos << PPFNameTag(tag) << iReduced->second;
+  }
+  
+  iMeanSigmaRedEnd = meanSigmaRedRatioCollect.end();
+  for (iMeanSigmaRed = meanSigmaRedRatioCollect.begin();
+       iMeanSigmaRed != iMeanSigmaRedEnd; 
+       ++iMeanSigmaRed){
+    tag = "redMedian";
+    tag += iMeanSigmaRed->first;
+    if(debuglev_>9) {
+      cout << "save tag<" << tag << ">" << endl;
+    }
+    fos << PPFNameTag(tag) << iMeanSigmaRed->second;
+  }
+  
+  cout << "OK ProcessONOFFReducedMedianData finished" <<endl;
   return rc;
 }
Index: ORadio/AmasNancay/trunk/calibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/calibmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,429 +1,0 @@
-#!/bin/sh -xvf
-#download SCA file, proceed to introspection, and upload results
-DATE=/bin/date
-GREP=/bin/grep
-AWK=/bin/awk
-ECHO=/bin/echo
-WC=/usr/bin/wc
-CAT=/bin/cat
-PRINTF=/usr/bin/printf
-FIND=/usr/bin/find
-MKDIR=/bin/mkdir
-XARGS=/usr/bin/xargs
-SORT=/bin/sort
-RM=/bin/rm
-TR=/usr/bin/tr
-CP=/bin/cp
-LS=/bin/ls
-CHMOD=/bin/chmod
-
-DefaultIFS=$' \t\n'
-IFS=$DefaultIFS
-
-#set Irods environment    
-. /usr/local/shared/bin/irods_env.sh -noverbose
-
-scriptName="`basename $0`"
-$ECHO "Processing script ${scriptName} at `date`"
-#which source to analyse
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-freqBAOCalib=1346
-bwBAOCalib=6.25
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=Off
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -freq) freqBAOCalib=$2; shift;;
-      -bwd)  bwBAOCalib=$2; shift;;
-      -sim) simulationMode=On;;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce [-freq freq in MHz (default ${freqBAOCalib})] [-bwd bandwidth in MHz (default ${bwBAOCalib})]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ ${simulationMode} = "On" ]; then
-    $ECHO "INFO ${scriptName} running in SIMUL mode"
-fi
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-case ${sourceRadio} in
-    Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
-    exit 1;;
-esac
-
-srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
-
-#Path to public backupable path
-publicpath="/afs/in2p3.fr/home/c/campagne/public"
-
-
-#temporary files to synchronize scripts
-tmppublicpath=${TMPPUBLICPATH}
-#wakeup the NFS disk
-$LS -l ${tmppublicpath} > /dev/null
-#clean previous spurious files
-$RM -f ${tmppublicpath}/*.finished
-
-#Path where the job will do temporary IO
-. ${SCRIPTPATH}/isInteractive.sh
-isInteractive=$(isInteractive)
-if [ ${isInteractive} == "1" ]; then
-  $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
-   exit 0;
-fi
-
-. ${SCRIPTPATH}/set_iojobpath.sh
-iojobpath=$(set_iojobpath)
-cd ${iojobpath}
-
-localpath="${sourceRadio}"
-$MKDIR -p ./${localpath}
-cd ./${localpath}
-
-#save the top directory
-topDir=`pwd`
-
-#Path of the utility scripts
-scriptpath=${SCRIPTPATH}
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-OUT1=${publicpath}/baodaqstatus-current.txt
-#
-#get the daq current irod status
-#tag=`${DATE} +%F`
-#OUT1=${publicpath}/baodaqstatus-${tag}.txt
-#
-if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
-    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
-    exit 1
-#    $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
-#    $RM -f ${tmppublicpath}/statusdaq.finished
-#   ${scriptpath}/statusdaq.sh > ${OUT1}
-#    while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	sleep 30
-#    done
-#    $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#    $CHMOD -v 444 ${OUT1} 
-fi
-
-
-#Nb: if we want to implement a loop on sources we have to take care of srclower...
-
-$ECHO "You have selected sourceRadio = $sourceRadio"
-tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
-IFS='
-' 
-tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
-IFS=$DefaultIFS
-
-
-for i in ${tableau[@]}
-  do
-#
-# start a "fresh" session  
-  cd ${topDir}
-  $LS | $XARGS -i $RM -rf {}
-
-  
-  $ECHO "DEBUG: (${scriptName}) irods root dir $i"
-  dateDAQ=`$ECHO ${i} | $AWK '{split($0,a,"/"); print a[6];}' | $AWK "{sub(/${srclower}/,\"\"); print}"`
-
-  $ECHO "DEBUG: (${scriptName}): we are in directory `pwd` the topDir=${topDir}"
-  $LS -lrt
-
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-#Look if the date has changed since beginning of the job!
-#  curtag=`${DATE} +%F`
-#  if [ "<${curtag}>" != "<${tag}>" ]; then
-#      tag=${curtag}
-#it is necessary to update the daq status as the day has changed during the processing... (batch can take a long time...)
-#      OUT1=${publicpath}/baodaqstatus-${curtag}.txt
-#      $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
-#      $RM -f ${tmppublicpath}/statusdaq.finished
-#      ${scriptpath}/statusdaq.sh > ${OUT1}
-#      while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	  sleep 30
-#      done
-#      $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#      $CHMOD -v 444 ${OUT1} 
-#  fi
-#
-# look if the calibration files already exist
-#
-  alreadyDone=`ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" | $WC -l`
-  if [ ${alreadyDone} -gt 0 ]; then
-      $ECHO "INFO (${scriptName}): calibration coef files already exist"
-      continue
-  fi
-#
-  somethingTodo=1
-  input4calibOff=`ils ${i}/Off 2>&1 | $GREP -i "calibcycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n`  
-  input4calibOn=`ils ${i}/On 2>&1 | $GREP -i "calibcycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n`  
-#
-  if [ "<${input4calibOff}>" != "<>" -a "<${input4calibOn}>" != "<>"  ]; then
-#look at the content of the calibcycle directory as may be the previous batch job has crashed
-      tableauOff=( `$ECHO ${input4calibOff}` )
-      IFS='
-'
-      tableauOff=( $( $PRINTF "%s\n" "${tableauOff[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-#
-      nTotFilesOff=0
-      for j in ${tableauOff[@]}
-	do
-	nFiles=`ils ${i}/Off/${j} | $GREP -i "medfiltmtx" | $WC -l`
-	nTotFilesOff=`expr ${nTotFilesOff} + ${nFiles}`
-      done
-#
-      tableauOn=( `$ECHO ${input4calibOn}` )
-      IFS='
-      '
-      tableauOn=( $( $PRINTF "%s\n" "${tableauOn[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-#
-      nTotFilesOn=0
-      for j in ${tableauOn[@]}
-	do
-	nFiles=`ils ${i}/On/${j} | $GREP -i "medfiltmtx" | $WC -l`
-	nTotFilesOn=`expr ${nTotFilesOn} + ${nFiles}`
-      done
-      diffOnOff=`expr ${nTotFilesOff} - ${nTotFilesOn}`
-      if [ ${diffOnOff} -lt 0 ]; then
-	  zero=0
-	  diffOnOff=`expr ${zero} - ${diffOnOff}` 
-      fi
-#allow up to 5 files differences
-      if [  ${nTotFilesOff} -gt 0 -a ${nTotFilesOn} -gt 0  ]; then
-	  somethingTodo=0
-	  $ECHO "DEBUG (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files but OK"
-      else
-	  $ECHO "INFO (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files => one should rebuild has something is wrong"
-      fi
-# 
-  fi 
-  if [ ${somethingTodo} -eq 1 ]; then
-#
-      $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ CALIBOFF"
-      $RM -f ${tmppublicpath}/proc_script.finished
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBOFF"
-      else
-	  ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBOFF
-	  while [ ! -e "${tmppublicpath}/proc_script.finished"  ]; do
-	      $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished"
-	      date +%T
-	      sleep 60
-	  done
-      fi
-      $ECHO "INFO (${scriptName}): proc_script has finished"
-      $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ CALIBOFF"
-      $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ CALIBON"
-      $RM ${tmppublicpath}/proc_script.finished
-      
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBON"
-      else
-	  ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBON
-	  while [ ! -e "${tmppublicpath}/proc_script.finished"  ]; do
-	      $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished"
-	      date +%T
-	      sleep 60
-	  done
-      fi
-      $ECHO "INFO (${scriptName}): proc_script has finished"
-      $RM ${tmppublicpath}/proc_script.finished
-#Todo see if there is errors in the log file before copy
-      $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ CALIBON"
-######
-  else
-######
-      $ECHO ">>>>>>>>>>>>> ANALYSIS Part of ${sourceRadio} ${dateDAQ}"
-      #go to the .../source/date-sourcelowercase directory
-#download Off/calibcycle<> and On/calibcycle<> directories
-      $MKDIR -p ${topDir}/${dateDAQ}${srclower}
-      cd ${topDir}/${dateDAQ}${srclower}
-      aboveOnOffDir=`pwd`
-      $ECHO "DEBUG (${scriptName}): we are in directory: <`pwd`>"
-#
-      mode="Off"
-      $ECHO "DEBUG (${scriptName}): START download the ${mode} calib fits files"
-      inFileDirectory="./${mode}"
-      $MKDIR -p ${inFileDirectory}
-      listOfCalibCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "calibcycle"|$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
-      IFS='
-'
-      listOfCalibCycle=( $( $PRINTF "%s\n" "${listOfCalibCycle[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-
-      firstCycleOff=`$ECHO ${listOfCalibCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-      nCyclesOff=`expr ${#listOfCalibCycle[*]} - 1`
-
-      lastCycleOff=`$ECHO ${listOfCalibCycle[${nCyclesOff}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-
-      listOfCalibCycle=( "${listOfCalibCycle[@]/#/${i}/${mode}/}" )
-
-      
-      for j in ${listOfCalibCycle[@]}
-	do
-	irodsDownDir="${j}"
-	OUT=./getInFits.$$
-	iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1
-	igetStatus=`$GREP "^ERROR" ${OUT}`
-	if [ "<$igetStatus>" != "<>" ]; then
-	    $ECHO "FATAL (${scriptName}): error while iget fits files:"
-	    $ECHO $igetStatus
-	    $ECHO " ==> skip this run $sourceRadio $dateDAQ"
-	    continue
-	fi
-	$RM -f ${OUT}
-      done
-      $ECHO "DEBUG (${scriptName}): END download the ${mode} calib fits files"
-#
-      mode="On"
-      $ECHO "DEBUG (${scriptName}): START download the ${mode} calib fits files"
-      inFileDirectory="./${mode}"
-      $MKDIR -p ${inFileDirectory}
-
-      listOfCalibCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "calibcycle" |$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
-      IFS='
-'
-      listOfCalibCycle=( $( $PRINTF "%s\n" "${listOfCalibCycle[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-
-      firstCycleOn=`$ECHO ${listOfCalibCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-      nCyclesOn=`expr ${#listOfCalibCycle[*]} - 1`
-
-      lastCycleOn=`$ECHO ${listOfCalibCycle[${nCyclesOn}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-
-      listOfCalibCycle=( "${listOfCalibCycle[@]/#/${i}/${mode}/}" )
-
-
-#
-#Check if there is the same number of cycles in Off and On mode
-#      
-#first cycle = max(firstCycleOn, firstCycleOff)
-#last  cycle = min(lastCycleOn,lastCycleOff)
-
-      if [ ${firstCycleOn} -eq ${firstCycleOff} -a ${lastCycleOn} -eq ${lastCycleOff} ]; then
-	  firstCycle=${firstCycleOff}
-	  lastCycle=${lastCycleOff}
-      else
-	  $ECHO "INFO (${scriptName}): missmatch between Off and On mode"
-	  $ECHO "${firstCycleOn} != ${firstCycleOff} OR ${lastCycleOn} != ${lastCycleOff}"
-	  firstCycle=${firstCycleOff}
-	  if [ ${firstCycleOn} -gt ${firstCycle} ]; then
-	      firstCycle=${firstCycleOn}
-	  fi
-	  lastCycle=${lastCycleOff}
-	  if [ ${lastCycleOn} -lt ${lastCycle} ]; then
-	      lastCycle=${lastCycleOn}
-	  fi
-      fi
-      $ECHO "INFO (${scriptName}): use cycles [${firstCycle}, ${lastCycle}]"
-      
-
-      for j in ${listOfCalibCycle[@]}
-	do
-	irodsDownDir="${j}"
-	OUT=./getInFits.$$
-	iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1
-	igetStatus=`$GREP "^ERROR" ${OUT}`
-	if [ "<$igetStatus>" != "<>" ]; then
-	    $ECHO "FATAL (${scriptName}): error while iget fits files:"
-	    $ECHO $igetStatus
-	    $ECHO " ==> skip this run $sourceRadio $dateDAQ"
-	    continue
-	fi
-	$RM -f ${OUT}
-      done
-      $ECHO "DEBUG (${scriptName}): END download the ${mode} calib fits files"
-#Get sca file
-      $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"
-	  continue
-      fi
-      $RM -f ${OUT1}
-
-      scaFile=`$FIND . -name "sca*.sum.trans" | $XARGS -i basename {}`
-      
-#prepare job submission
-      cd ${aboveOnOffDir}
-#the default spectra name is medfiltmtx, otherwise use -specname <a_string>
-
-      logFile="analyse_CALIB_${sourceRadio}_${dateDAQ}.log"
-      $ECHO "DEBUG (${scriptName}): execute the analysis... should not take long. `date`"
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/Objs/analyse -act calib -inPath ${iojobpath}  -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir calibcycle -numcycle ${firstCycle},${lastCycle} -calibopt mean  -debuglev 1 -freqBAOCalib ${freqBAOCalib} -bwBAOCalib ${bwBAOCalib} >& ${logFile}"
-	  cat > ${logFile} <<EOF
-	  Ok calibration finished
-EOF
-      else
-	  ${scriptpath}/Objs/analyse -act calib -inPath ${iojobpath}  -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir calibcycle  -numcycle ${firstCycle},${lastCycle} -calibopt mean  -debuglev 1 -freqBAOCalib ${freqBAOCalib} -bwBAOCalib ${bwBAOCalib} >& ${logFile}
-      fi
-      $ECHO "DEBUG (${scriptName}): analysis finished `date`. Look for errors before saving to Irods"
-      rcstatus=`$GREP -i "Ok calibration finished" ${logFile} | $WC -l`
-      if [ ${rcstatus} -eq 0 ]; then
-	  $ECHO "INFO (${scriptName}): analysis problem for ${sourceRadio} ${dateDAQ}"
-	  $ECHO "                      START logfile"
-	  $CAT ${logFile}
-	  $ECHO "                      END   logFile"
-#clean and leave
-	  cd ${aboveOnOffDir}
-	  $LS | $XARGS -i $RM -rf {}
-	  continue
-      fi
-#Save into Irods
-      $ECHO "DEBUG (${scriptName}): START save output files"
-      $LS ${aboveOnOffDir}
-#use -f option for iput ONLY to force override
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: here we look for calib file and put them in Irods"
-      else
-	  $FIND . -name "calib_*" -print | $XARGS -i  iput  -v -K {} ${i}
-      fi
-#save analysis logfile
-      $LS -l ${tmppublicpath} > /dev/null
-      $CP ${logFile} ${tmppublicpath}
-      $ECHO "DEBUG (${scriptName}): END save output files"
-#clean up to avoid scratch SIZE EXCEED LIMIT
-      cd ${aboveOnOffDir}
-      $LS | $XARGS -i $RM -rf {}
-  fi
-done
-
-exit 0
Index: ORadio/AmasNancay/trunk/gainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/gainmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,296 +1,0 @@
-#!/bin/sh -xvf
-#download SCA file, proceed to introspection, and upload results
-DATE=/bin/date
-GREP=/bin/grep
-AWK=/bin/awk
-ECHO=/bin/echo
-WC=/usr/bin/wc
-CAT=/bin/cat
-PRINTF=/usr/bin/printf
-FIND=/usr/bin/find
-MKDIR=/bin/mkdir
-XARGS=/usr/bin/xargs
-SORT=/bin/sort
-RM=/bin/rm
-TR=/usr/bin/tr
-CP=/bin/cp
-LS=/bin/ls
-CHMOD=/bin/chmod
-
-DefaultIFS=$' \t\n'
-IFS=$DefaultIFS
-
-#set Irods environment    
-. /usr/local/shared/bin/irods_env.sh -noverbose
-
-scriptName="`basename $0`"
-#$ECHO "Processing script ${scriptName} at `date`"
-
-#$ECHO "SHOULD BE RETUNED FOR THE inPath cmd line of analyse.cc (Sorry...): 21/7/11 by JEC"
-#exit 1
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=Off
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -sim) simulationMode=On;;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce [-sim]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ ${simulationMode} = "On" ]; then
-    $ECHO "INFO ${scriptName} running in SIMUL mode"
-fi
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-case ${sourceRadio} in
-    Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
-    exit 1;;
-esac
-
-
-srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
-
-#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}/isInteractive.sh
-isInteractive=$(isInteractive)
-if [ ${isInteractive} == "1" ]; then
-  $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
-   exit 0;
-fi
-
-. ${SCRIPTPATH}/set_iojobpath.sh
-iojobpath=$(set_iojobpath)
-cd ${iojobpath}
-
-localpath="${sourceRadio}"
-$MKDIR -p ./${localpath}
-cd ./${localpath}
-
-#save the top directory
-topDir=`pwd`
-
-#Path of the utility scripts
-scriptpath=${SCRIPTPATH}
-
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-#get the daq current irod status
-#tag=`${DATE} +%F`
-#OUT1=${publicpath}/baodaqstatus-${tag}.txt
-OUT1=${publicpath}/baodaqstatus-current.txt
-
-if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
-    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
-    exit 1
-#    $RM -f ${tmppublicpath}/statusdaq.finished
-#    ${scriptpath}/statusdaq.sh > ${OUT1}
-#    while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	sleep 30
-#    done
-#    $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#    $CHMOD -v 444 ${OUT1} 
-#
-fi
-
-#
-#We forbib to perform the gain for all the sources in one shot!
-#
-#if [ ! "<${sourceRadio}>" = "All" ]; then
-$ECHO "You have selected sourceRadio = $sourceRadio"
-tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
-#else
-#    tableau=( `$CAT ${OUT1} | $AWK '( NF==4 ) { print $2 }'`  )
-#fi
-IFS='
-'
-tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
-IFS=$DefaultIFS
-
-
-for i in ${tableau[@]}
-  do
-  $ECHO "DEBUG (${scriptName}): irods root dir $i"
-  dateDAQ=`$ECHO ${i} | $AWK '{split($0,a,"/"); print a[6];}' | $AWK "{sub(/${srclower}/,\"\"); print}"`
-#JEC 1/10/11 Use generic baodaqstatus name 
-#Look if the date has changed since beginning of the job!
-#  curtag=`${DATE} +%F`
-#  if [ "<${curtag}>" != "<${tag}>" ]; then
-#      tag=${curtag}
-#it is necessary to update the daq status as the day has changed during the processing... (batch can take a long time...)
-#      OUT1=${publicpath}/baodaqstatus-${curtag}.txt
-#      $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
-#      $RM -f ${tmppublicpath}/statusdaq.finished
-#      ${scriptpath}/statusdaq.sh > ${OUT1}
-#      while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	  sleep 30
-#      done
-#      $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#      $CHMOD -v 444 ${OUT1} 
-#  fi
-#
-# look if the fits file of the gains already exists
-  alreadyDone=`ils ${i} 2>&1 | $GREP -i "gain_.*\.fits" | $WC -l`
-  if [ ${alreadyDone} -gt 0 ]; then
-      $ECHO "INFO (${scriptName}): Fits file for gains already exists"
-      continue
-  fi
-# Something should be done...
-#look if the files for the input to gain computations have been done
-  somethingTodo=1
-  input4gainOk1=`ils ${i}/Off 2>&1 | $GREP -i "^ERROR" | $WC -l` 
-  input4gainOk2=`ils ${i}/Off 2>&1 | $GREP -i "gaincycle"` 
-  if [ $input4gainOk1 -eq 0 -a "<${input4gainOk2}>" != "<>"  ]; then
-      gaincycle=`$ECHO ${input4gainOk2} | $AWK '($1 == "C-"){print $2}'| $XARGS -i  basename {}`
-      input4gainOk3=`ils ${i}/Off/${gaincycle} 2>&1 | $GREP -i "medfiltmtx" | $WC -l`
-      if [ $input4gainOk3 -gt 0 ]; then
-	  somethingTodo=0
-      fi
-  fi
-  if [ $somethingTodo -eq 1 ]; then
-#
-      $ECHO ">>>>>>>>>>>>>>>> Do proc_script $sourceRadio $dateDAQ GAIN"
-      $RM -f ${tmppublicpath}/proc_script.finished
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ GAIN"
-      else      
-	  ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ GAIN
-	  while [ ! -e "${tmppublicpath}/proc_script.finished"  ]; do
-	      $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished"
-	      date +%T
-	      sleep 60
-	  done
-      fi
-      $ECHO "INFO (${scriptName}): proc_script has finished"
-      $RM ${tmppublicpath}/proc_script.finished
-#Todo see if there is errors in the log file before copy
-      $ECHO ">>>>>>>>>>>>>>>> Done proc_script $sourceRadio $dateDAQ GAIN"
-######
-  fi
-######
-  $ECHO ">>>>>>>>>>>>> ANALYSIS Part of ${sourceRadio} ${dateDAQ}"
-#go to the .../source/date-sourcelowercase directory
-  $MKDIR -p ${topDir}/${dateDAQ}${srclower}
-  cd ${topDir}/${dateDAQ}${srclower}
-  aboveOnOffDir=`pwd`
-  $ECHO "DEBUG (${scriptName}): we are in directory: <`pwd`>"
-# So the input files are there, so the fits file can be determined
-  mode="Off"
-  spectraGenDirName=`$ECHO ${gaincycle} | $AWK '{match($0,"[a-zA-Z]+",arr); print arr[0]}'`
-  cycleNumber=`$ECHO ${gaincycle} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-#care: the gaincycle variable contains the cycle number
-  $ECHO "DEBUG (${scriptName}): START download the fits files"
-  inFileDirectory="./${mode}"
-  $MKDIR -p ${inFileDirectory}
-  irodsDownDir="${i}/${mode}/${gaincycle}"
-  OUT=./getInFits.$$
-  iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1
-  $LS ${inFileDirectory}/${gaincycle}
-  igetStatus=`$GREP "^ERROR" ${OUT}`
-  if [ "<$igetStatus>" != "<>" ]; then
-      $ECHO "FATAL (${scriptName}): error while iget fits files:"
-      $ECHO $igetStatus
-      continue
-  fi
-  $RM -f ${OUT}
-  $ECHO "DEBUG (${scriptName}): END download the fits files"
-#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"
-      continue
-  fi
-  $RM -f ${OUT1}
-  $ECHO "DEBUG (${scriptName}): where am i `pwd`"
-  $LS -lrt
-  
-  scaFile=`$FIND . -name "sca*.sum.trans" | $XARGS -i basename {}`
-#	
-#the default spectra name is medfiltmtx, otherwise use -specname <a_string>
-  logFile="analyse_GAIN_${sourceRadio}_${dateDAQ}.log"
-  $ECHO "DEBUG (${scriptName}): execute the analysis... should not take long. `date`"
-  if [ ${simulationMode} = "On" ]; then
-      $ECHO "SIMUL: ${scriptpath}/Objs/analyse -act gain  -inPath ${iojobpath} -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir ${spectraGenDirName} -mode ${mode} -numcycle ${cycleNumber},${cycleNumber} -debug 1 >& ${logFile}"
-      cat > ${logFile} <<EOF
-      Ok gain finished
-EOF
-
-  else
-      ${scriptpath}/Objs/analyse -act gain  -inPath ${iojobpath} -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir ${spectraGenDirName} -mode ${mode} -numcycle ${cycleNumber},${cycleNumber} -debuglev 1 >& ${logFile}
-  fi
-#
-  $ECHO "DEBUG (${scriptName}): analysis finished `date`. Look for errors before saving to Irods"
-  rcstatus=`$GREP -i "OK gain finished" ${logFile} | $WC -l`
-  if [ ${rcstatus} -eq 0 ]; then
-      $ECHO "INFO (${scriptName}): analysis problem for ${sourceRadio} ${dateDAQ}"
-      $ECHO "                      START logfile"
-      $CAT ${logFile}
-      $ECHO "                      END   logFile"
-#clean and leave
-      cd ${aboveOnOffDir}
-      $RM -rf ./*
-      continue
-  fi
-#Save into Irods
-  $ECHO "DEBUG (${scriptName}): START save output files"
-  $LS ${aboveOnOffDir}
-#use -f option of iput ONLY to force override
-  if [ ${simulationMode} = "On" ]; then
-      $ECHO "SIMUL: here we look for gain file and put them in Irods"
-  else
-      $FIND . -name "gain_*" -print | $XARGS -i  iput  -v -K {} ${i}
-  fi
-#save analysis logfile
-  $LS -l ${tmppublicpath} > /dev/null
-  $CP ${logFile} ${tmppublicpath}
-  $ECHO "DEBUG (${scriptName}): END save output files"
-#clean
-  cd ${aboveOnOffDir}
-  $RM -rf ./*
-done
-
-exit 0
Index: /BAORadio/AmasNancay/trunk/makefile
===================================================================
--- /BAORadio/AmasNancay/trunk/makefile	(revision 597)
+++ /BAORadio/AmasNancay/trunk/makefile	(revision 598)
@@ -38,11 +38,2 @@
 	$(CXXCOMPILE) -c  -o $(OBJ)mergeAnaFiles.o mergeAnaFiles.cc
 
-anaTools : $(EXE)anaTools
-	echo '---anaTools made'
-
-$(EXE)anaTools : $(OBJ)anaTools.o
-	$(CXXLINK) -o $(EXE)anaTools $(OBJ)anaTools.o  $(SOPHYAALLSLBLIST)
-
-$(OBJ)anaTools.o : anaTools.cc
-	$(CXXCOMPILE) -c  -o $(OBJ)anaTools.o anaTools.cc
-
Index: ORadio/AmasNancay/trunk/onoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/onoffmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,460 +1,0 @@
-#!/bin/sh -xvf
-#Perform the ON-OFF analysis
-DATE=/bin/date
-GREP=/bin/grep
-AWK=/bin/awk
-ECHO=/bin/echo
-WC=/usr/bin/wc
-CAT=/bin/cat
-PRINTF=/usr/bin/printf
-FIND=/usr/bin/find
-MKDIR=/bin/mkdir
-XARGS=/usr/bin/xargs
-SORT=/bin/sort
-RM=/bin/rm
-TR=/usr/bin/tr
-CP=/bin/cp
-LS=/bin/ls
-CHMOD=/bin/chmod
-
-DefaultIFS=$' \t\n'
-IFS=$DefaultIFS
-
-#set Irods environment    
-. /usr/local/shared/bin/irods_env.sh -noverbose
-
-scriptName="`basename $0`"
-$ECHO "Processing script ${scriptName} at `date`"
-#which source to analyse
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-freqBAOCalib=1346
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=Off
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2;    shift;;
-      -date) dateSelected=$2;     shift;;
-      -freq) freqBAOCalib=$2;   shift;;
-      -sim)  simulationMode=On;;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-freq freq in MHz (default ${freqBAOCalib})] [-sim to trig simulation mode]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ ${simulationMode} = "On" ]; then
-    $ECHO "INFO ${scriptName} running in SIMUL mode"
-fi
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-case ${sourceRadio} in
-    Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
-    *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
-    exit 1;;
-esac
-
-srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
-
-#Path to public backupable path
-publicpath="/afs/in2p3.fr/home/c/campagne/public"
-
-
-#temporary files to synchronize scripts
-tmppublicpath=${TMPPUBLICPATH}
-#wakeup the NFS disk
-$LS -l ${tmppublicpath} > /dev/null
-#clean previous spurious files
-$RM -f ${tmppublicpath}/*.finished
-
-#Path where the job will do temporary IO
-. ${SCRIPTPATH}/isInteractive.sh
-isInteractive=$(isInteractive)
-if [ ${isInteractive} == "1" ]; then
-  $ECHO "Usage in INTERACTIVE may be destructive... To be used with great care !!!!"
-   exit 0;
-fi
-
-. ${SCRIPTPATH}/set_iojobpath.sh
-iojobpath=$(set_iojobpath)
-cd ${iojobpath}
-
-localpath="${sourceRadio}"
-$MKDIR -p ./${localpath}
-cd ./${localpath}
-
-#save the top directory
-topDir=`pwd`
-
-#Path of the utility scripts
-scriptpath=${SCRIPTPATH}
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-#get the daq current irod status
-#tag=`${DATE} +%F`
-#OUT1=${publicpath}/baodaqstatus-${tag}.txt
-OUT1=${publicpath}/baodaqstatus-current.txt
-
-if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
-    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
-    exit 1
-#    $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
-#    $RM -f ${tmppublicpath}/statusdaq.finished
-#    ${scriptpath}/statusdaq.sh > ${OUT1}
-#    while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	sleep 30
-#    done
-#    $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#    $CHMOD -v 444 ${OUT1} 
-fi
-
-
-#Nb: if we want to implement a loop on sources we have to take care of srclower...
-
-$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
-tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
-IFS='
-' 
-tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
-IFS=$DefaultIFS
-
-
-for i in ${tableau[@]}
-  do
-#
-# start a "fresh" session  
-  cd ${topDir}
-  $LS | $XARGS -i $RM -rf {}
-  
-  $ECHO "DEBUG: (${scriptName}) irods root dir $i"
-  dateDAQ=`$ECHO ${i} | $AWK '{split($0,a,"/"); print a[6];}' | $AWK "{sub(/${srclower}/,\"\"); print}"`
-
-  $ECHO "DEBUG: (${scriptName}): we are in directory `pwd` the topDir=${topDir}"
-  $LS -lrt
-
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-#Look if the date has changed since beginning of the job!
-#  curtag=`${DATE} +%F`
-#  if [ "<${curtag}>" != "<${tag}>" ]; then
-#      tag=${curtag}
-#it is necessary to update the daq status as the day has changed during the processing... (batch can take a long time...)
-#      OUT1=${publicpath}/baodaqstatus-${curtag}.txt
-#      $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..."
-#      $RM -f ${tmppublicpath}/statusdaq.finished
-#      ${scriptpath}/statusdaq.sh > ${OUT1}
-#      while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	  sleep 30
-#      done
-#      $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#      $CHMOD -v 444 ${OUT1} 
-#  fi
-#
-# look if the gain & calibration files exist
-#
-  gainDone=`ils ${i} 2>&1 | $GREP -i "gain_.*\.fits" | $WC -l`
-  if [ ! ${gainDone} -gt 0 ]; then
-      $ECHO "FATAL (${scriptName}): gain file DOES NOT exist skip `basename $i` "
-      continue
-  fi
-
-  calibDone=`ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" | $WC -l`
-  if [ ! ${calibDone} -gt 0 ]; then
-      $ECHO "FATAL (${scriptName}): calibration files DO NOT exist skip `basename $i` "
-      continue
-  fi
-#
-  somethingTodo=1
-  input4dataOff=`ils ${i}/Off 2>&1 | $GREP -i "datacycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.10n`  
-  input4dataOn=`ils ${i}/On 2>&1 | $GREP -i "datacycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.10n`  
-#
-  if [ "<${input4dataOff}>" != "<>" -a "<${input4dataOn}>" != "<>"  ]; then
-#look at the content of the datacycle directory as may be the previous batch job has crashed
-      tableauOff=( `$ECHO ${input4dataOff}` )
-      IFS='
-'
-      tableauOff=( $( $PRINTF "%s\n" "${tableauOff[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-#
-      nTotFilesOff=0
-      for j in ${tableauOff[@]}
-	do
-	nFiles=`ils ${i}/Off/${j} | $GREP -i "medfiltmtx" | $WC -l`
-	nTotFilesOff=`expr ${nTotFilesOff} + ${nFiles}`
-      done
-#
-      tableauOn=( `$ECHO ${input4dataOn}` )
-      IFS='
-      '
-      tableauOn=( $( $PRINTF "%s\n" "${tableauOn[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-#
-      nTotFilesOn=0
-      for j in ${tableauOn[@]}
-	do
-	nFiles=`ils ${i}/On/${j} | $GREP -i "medfiltmtx" | $WC -l`
-	nTotFilesOn=`expr ${nTotFilesOn} + ${nFiles}`
-      done
-      diffOnOff=`expr ${nTotFilesOff} - ${nTotFilesOn}`
-      if [ ${diffOnOff} -lt 0 ]; then
-	  zero=0
-	  diffOnOff=`expr ${zero} - ${diffOnOff}` 
-      fi
-#allow files differences
-      if [  ${nTotFilesOff} -gt 0 -a ${nTotFilesOn} -gt 0  ]; then
-	  somethingTodo=0
-	  $ECHO "DEBUG (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files but OK"
-      else
-	  $ECHO "INFO (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files => one should rebuild has something is wrong"
-      fi
-# 
-  fi 
-  if [ ${somethingTodo} -eq 1 ]; then
-#
-      $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ ANALOFF"
-      $RM -f ${tmppublicpath}/proc_script.finished
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ OFF"
-      else
-	  ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ OFF
-	  while [ ! -e "${tmppublicpath}/proc_script.finished"  ]; do
-	      $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished"
-	      date +%T
-	      sleep 60
-	  done
-      fi
-      $ECHO "INFO (${scriptName}): proc_script has finished"
-      $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ OFF"
-      $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ ON"
-      $RM ${tmppublicpath}/proc_script.finished
-      
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ ON"
-      else
-	  ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ ON
-	  while [ ! -e "${tmppublicpath}/proc_script.finished"  ]; do
-	      $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished"
-	      date +%T
-	      sleep 60
-	  done
-      fi
-      $ECHO "INFO (${scriptName}): proc_script has finished"
-      $RM ${tmppublicpath}/proc_script.finished
-#Todo see if there is errors in the log file before copy
-      $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ ON"
-######
-  else
-######
-      $ECHO ">>>>>>>>>>>>> ANALYSIS Part of ${sourceRadio} ${dateDAQ}"
-      #go to the .../source/date-sourcelowercase directory
-#download Off/datacycle<> and On/datacycle<> directories
-      $MKDIR -p ${topDir}/${dateDAQ}${srclower}
-      cd ${topDir}/${dateDAQ}${srclower}
-      aboveOnOffDir=`pwd`
-      $ECHO "DEBUG (${scriptName}): we are in directory: <`pwd`>"
-#
-      mode="Off"
-      $ECHO "DEBUG (${scriptName}): START download the ${mode} data fits files"
-      inFileDirectory="./${mode}"
-      $MKDIR -p ${inFileDirectory}
-      listOfDataCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "datacycle"|$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.10n` )
-      IFS='
-'
-      listOfDataCycle=( $( $PRINTF "%s\n" "${listOfDataCycle[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-
-      firstCycleOff=`$ECHO ${listOfDataCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-      nCyclesOff=`expr ${#listOfDataCycle[*]} - 1`
-
-      lastCycleOff=`$ECHO ${listOfDataCycle[${nCyclesOff}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-
-      listOfDataCycle=( "${listOfDataCycle[@]/#/${i}/${mode}/}" )
-
-      
-      for j in ${listOfDataCycle[@]}
-	do
-	irodsDownDir="${j}"
-	OUT=./getInFits.$$
-	iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1
-	igetStatus=`$GREP "^ERROR" ${OUT}`
-	if [ "<$igetStatus>" != "<>" ]; then
-	    $ECHO "FATAL (${scriptName}): error while iget fits files:"
-	    $ECHO $igetStatus
-	    $ECHO " ==> skip this run $sourceRadio $dateDAQ"
-	    continue
-	fi
-	$RM -f ${OUT}
-      done
-      $ECHO "DEBUG (${scriptName}): END download the ${mode} data fits files"
-#
-      mode="On"
-      $ECHO "DEBUG (${scriptName}): START download the ${mode} data fits files"
-      inFileDirectory="./${mode}"
-      $MKDIR -p ${inFileDirectory}
-
-      listOfDataCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "datacycle" |$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.10n` )
-      IFS='
-'
-      listOfDataCycle=( $( $PRINTF "%s\n" "${listOfDataCycle[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-
-      firstCycleOn=`$ECHO ${listOfDataCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-      nCyclesOn=`expr ${#listOfDataCycle[*]} - 1`
-
-      lastCycleOn=`$ECHO ${listOfDataCycle[${nCyclesOn}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'`
-
-      listOfDataCycle=( "${listOfDataCycle[@]/#/${i}/${mode}/}" )
-
-
-#
-#Check if there is the same number of cycles in Off and On mode
-#      
-#first cycle = max(firstCycleOn, firstCycleOff)
-#last  cycle = min(lastCycleOn,lastCycleOff)
-
-      if [ ${firstCycleOn} -eq ${firstCycleOff} -a ${lastCycleOn} -eq ${lastCycleOff} ]; then
-	  firstCycle=${firstCycleOff}
-	  lastCycle=${lastCycleOff}
-      else
-	  $ECHO "INFO (${scriptName}): missmatch between Off and On mode"
-	  $ECHO "${firstCycleOn} != ${firstCycleOff} OR ${lastCycleOn} != ${lastCycleOff}"
-	  firstCycle=${firstCycleOff}
-	  if [ ${firstCycleOn} -gt ${firstCycle} ]; then
-	      firstCycle=${firstCycleOn}
-	  fi
-	  lastCycle=${lastCycleOff}
-	  if [ ${lastCycleOn} -lt ${lastCycle} ]; then
-	      lastCycle=${lastCycleOn}
-	  fi
-      fi
-      $ECHO "INFO (${scriptName}): use cycles [${firstCycle}, ${lastCycle}]"
-      
-
-      for j in ${listOfDataCycle[@]}
-	do
-	irodsDownDir="${j}"
-	OUT=./getInFits.$$
-	iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1
-	igetStatus=`$GREP "^ERROR" ${OUT}`
-	if [ "<$igetStatus>" != "<>" ]; then
-	    $ECHO "FATAL (${scriptName}): error while iget fits files:"
-	    $ECHO $igetStatus
-	    $ECHO " ==> skip this run $sourceRadio $dateDAQ"
-	    continue
-	fi
-	$RM -f ${OUT}
-      done
-      $ECHO "DEBUG (${scriptName}): END download the ${mode} data fits files"
-#Get sca file
-      $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"
-	  continue
-      fi
-      $RM -f ${OUT1}
-
-      scaFile=`$FIND . -name "sca*.sum.trans" | $XARGS -i basename {}`
-
-
-#Get the calibration files
-      OUT2=./calibFiles.$$
-      ils ${i} | ${GREP} -i "calib.*\.txt" > ${OUT2}
-      listeOfCalib=( `$CAT ${OUT2}` )
-      IFS='
-'
-      listeOfCalib=( $( $PRINTF "%s\n" "${listeOfCalib[@]}" | $AWK 'x[$0]++ == 0' ) )
-      IFS=$DefaultIFS
-      $RM $OUT2
-      for fcal in ${listeOfCalib[@]}
-      do
-	OUT3=./getCalib.$$
-	iget -f -K -v ${i}/${fcal} ${aboveOnOffDir}> ${OUT3} 2>&1
-	igetStatus=`$GREP "^ERROR" ${OUT3}`
-	if [ "<$igetStatus>" != "<>" ]; then
-	    $ECHO "FATAL (${scriptName}): error while iget calib files:"
-	    $ECHO $igetStatus
-	    exit 1
-	fi
-	$RM -f ${OUT3}
-      done
-      
-#prepare job submission
-      cd ${aboveOnOffDir}
-#the default spectra name is medfiltmtx, otherwise use -specname <a_string>
-
-      logFile="analyse_DATA_${sourceRadio}_${dateDAQ}.log"
-      $ECHO "DEBUG (${scriptName}): execute the analysis... should not take long. `date`"
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: ${scriptpath}/Objs/analyse -act dataOnOff -inPath ${iojobpath}  -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir datacycle -numcycle ${firstCycle},${lastCycle} -debuglev 1 -freqBAOCalib ${freqBAOCalib} >& ${logFile}"
-	  cat > ${logFile} <<EOF
-	  Ok calibration finished
-EOF
-      else
-	  ${scriptpath}/Objs/analyse -act dataOnOff -inPath ${iojobpath}  -source  ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir datacycle -numcycle ${firstCycle},${lastCycle} -debuglev 1 -freqBAOCalib ${freqBAOCalib} >& ${logFile}
-      fi
-      $ECHO "DEBUG (${scriptName}): analysis finished `date`. Look for errors before saving to Irods"
-      rcstatus=`$GREP -i "Ok dataOnOff finished" ${logFile} | $WC -l`
-      if [ ${rcstatus} -eq 0 ]; then
-	  $ECHO "INFO (${scriptName}): analysis problem for ${sourceRadio} ${dateDAQ}"
-	  $ECHO "                      START logfile"
-	  $CAT ${logFile}
-	  $ECHO "                      END   logFile"
-#clean and leave
-	  cd ${aboveOnOffDir}
-	  $LS | $XARGS -i $RM -rf {}
-	  continue
-      fi
-#Save into Irods
-      $ECHO "DEBUG (${scriptName}): START save output files"
-      $LS ${aboveOnOffDir}
-#use -f option for iput ONLY to force override
-      if [ ${simulationMode} = "On" ]; then
-	  $ECHO "SIMUL: here we look for calib file and put them in Irods"
-      else
-	  $LS -lrth
-	  $FIND . -name "dataRaw_*" -print | $XARGS -i  iput  -v -K {} ${i}
-	  $FIND . -name "dataBAOCalib_*" -print | $XARGS -i  iput  -v -K {} ${i}
-	  $FIND . -name "dataBAORTCalib_*" -print | $XARGS -i  iput  -v -K {} ${i}
-	  $FIND . -name "diffOnOff_*" -print | $XARGS -i  iput  -v -K {} ${i}
-      fi
-#save analysis logfile
-      $LS -l ${tmppublicpath} > /dev/null
-      $CP ${logFile} ${tmppublicpath}
-      $ECHO "DEBUG (${scriptName}): END save output files"
-#clean up to avoid scratch SIZE EXCEED LIMIT
-      cd ${aboveOnOffDir}
-      $LS | $XARGS -i $RM -rf {}
-  fi
-done
-
-exit 0
Index: ORadio/AmasNancay/trunk/submit2bqs-anacalibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-anacalibmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,45 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-freqBAOCalib=
-bwBAOCalib=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -freq) freqBAOCalib="-freq $2"; shift;;
-      -bwd)  bwBAOCalib="-bwd $2"; shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-freq freq in MHz (default ${freqBAOCalib})] [-bwd bandwidth in MHz (default ${bwBAOCalib})]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="anacalibs-${sourceRadio}${dateJob}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=1000MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/anacalibmaker.sh  -src ${sourceRadio} ${dateSelected} ${freqBAOCalib} ${bwBAOCalib} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-anagainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-anagainmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,26 +1,0 @@
-#!/bin/sh -xv
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -sim) simulationMode="-sim";;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce [-sim]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-jobBatchName="gains-$sourceRadio"
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=500MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/gainmaker.sh  -src ${sourceRadio} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-anarawonoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-anarawonoffmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,42 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-dateJob=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-      -h)
-	echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-freq freq in MHz (default ${freqBAOCalib})] [-sim to trig simulation mode]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="anarawonoff-${sourceRadio}${dateJob}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=1000MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/anarawonoffmaker.sh  -src ${sourceRadio} ${dateSelected} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-calibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-calibmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio
-freqBAOCalib=
-bwBAOCalib=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -freq) freqBAOCalib="-freq $2"; shift;;
-      -bwd)  bwBAOCalib="-bwd $2"; shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce [-freq freq in MHz (default ${freqBAOCalib})] [-bwd bandwidth in MHz (default ${bwBAOCalib})]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="calibs-${sourceRadio}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=1000MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/calibmaker.sh  -src ${sourceRadio} ${freqBAOCalib} ${bwBAOCalib} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-gainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-gainmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,33 +1,0 @@
-#!/bin/sh -xv
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -sim) simulationMode="-sim";;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-sim]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-jobBatchName="anagains-${sourceRadio}${dateJob}"
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=500MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/anagainmaker.sh  -src ${sourceRadio} ${dateSelected} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-hdrfitsextractor.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-hdrfitsextractor.sh	(revision 597)
+++ 	(revision )
@@ -1,23 +1,0 @@
-#!/bin/sh
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-jobBatchName="headerMaker-$sourceRadio"
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=100000,M=256MB,scratch=700MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/hdrfitsextractor.sh  $sourceRadio
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-onoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-onoffmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,44 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-dateJob=
-freqBAOCalib=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -freq) freqBAOCalib="-freq $2"; shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-freq freq in MHz (default ${freqBAOCalib})] [-sim to trig simulation mode]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="onoff-${sourceRadio}${dateJob}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=120000,M=1000MB,scratch=1000MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/onoffmaker.sh  -src ${sourceRadio} ${dateSelected} ${freqBAOCalib} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-procspecmfib.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-procspecmfib.sh	(revision 597)
+++ 	(revision )
@@ -1,126 +1,0 @@
-#!/bin/sh -xv
-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`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-#action: gain|mspec (gain: gain-like doucble median filtering
-#                   mspec: mean+sigma wo filetring)
-action="-act gain"
-sourceRadio=
-dateSelected=
-typeofproc=
-#first and last cycle to process
-#
-firstCycle=
-lastCycle=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -act)  action="-act $2"; act=$2; shift;;
-      -src)  sourceRadio="$2"; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -type) typeofproc="-type $2"; type=$2; shift;;
-      -fcycle) firstCycle="-fcycle $2"; fcycle="$2"; shift;;
-      -lcycle) lastCycle="-lcycle $2"; lcycle="$2"; shift;;
-       -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD -type type [-fcycle firstCycle] [-lcycle lastCycle] [-sim to trig simulation mode]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-if [ "<${dateSelected}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the date option (-date)"
-    exit 1
-fi
-
-if [ "<${typeofproc}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the type option (-type)"
-    exit 1
-fi
-
-#Path to public backupable path
-publicpath="/afs/in2p3.fr/home/c/campagne/public"
-#temporary files to synchronize scripts
-tmppublicpath=${TMPPUBLICPATH}
-#Path of the utility scripts
-scriptpath=${SCRIPTPATH}
-#get the daq current irod status
-#JEC 1/10/11 Use generic baodaqstatus name 
-#### tag=`${DATE} +%F`
-OUT1=${publicpath}/baodaqstatus-current.txt
-
-if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
-    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
-    exit 1
-#JEC 29/9/11 avoid finished stuff
-#    $RM -f ${tmppublicpath}/statusdaq.finished
-#    ${scriptpath}/statusdaq.sh > ${OUT1}
-#    while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
-#	sleep 30
-#    done
-#    $RM ${tmppublicpath}/statusdaq.finished
-#protect against remove/rewriting    
-#    $CHMOD -v 444 ${OUT1} 
-fi
-
-#assume 20 files/cycles cf. 30sec/cycle et 3sec par signal et fact 2 margin 
-if [ "<${firstCycle}>" != "<>" -a "<${lastCycle}>" != "<>" ]; then
-    jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-${fcycle}-${lcycle}"
-    nFiles=`expr ${lcycle} - ${fcycle} + 1`
-    nFiles=`expr ${nFiles} \* 20`
-else
-    jobBatchName="procspecmfib-${sourceRadio}${dateJob}${type}-All"
-    #assume 30 cycles maxi!
-    nFiles=`expr 20 \* 30`
-
-fi
-
-jobLogName="${jobBatchName}.log.$$"
-
-#Nbre de paquets utilises pour 1 spectre
-tspwin="5120"
-#calcul du scratch sachant que l'on nettoie apres chaque cycle
-nSpectra=`expr 20 \* 25600 /  ${tspwin}`
-scratchSize=`expr  20 \* 500 + ${nSpectra} \* 200 / 1000 + 5`
-
-#le cpu total tient compte de l'emsemble des ficheirs a taiter
-cpu=`expr ${nFiles} \* 60 \* 50`
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=${cpu},M=1000MB,scratch=${scratchSize}MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/proc_specmfib.sh ${action} -src ${sourceRadio} ${dateSelected} ${typeofproc} ${firstCycle} ${lastCycle} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2bqs-scaextractor.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2bqs-scaextractor.sh	(revision 597)
+++ 	(revision )
@@ -1,63 +1,0 @@
-#!/bin/sh -xvf
-DATE=/bin/date
-GREP=/bin/grep
-AWK=/bin/awk
-ECHO=/bin/echo
-WC=/usr/bin/wc
-CAT=/bin/cat
-PRINTF=/usr/bin/printf
-FIND=/usr/bin/find
-MKDIR=/bin/mkdir
-XARGS=/usr/bin/xargs
-SORT=/bin/sort
-RM=/bin/rm
-TR=/usr/bin/tr
-CP=/bin/cp
-LS=/bin/ls
-CHMOD=/bin/chmod
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-force=
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -force) force="Yes";;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-#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 of the utility scripts
-scriptpath=${SCRIPTPATH}
-
-#JEC 1/10/11 Use generic baodaqstatus name 
-#the daq current irod status
-#tag=`${DATE} +%F`
-#OUT1=${publicpath}/baodaqstatus-${tag}.txt
-OUT1=${publicpath}/baodaqstatus-current.txt
-
-if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
-    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
-    exit 1
-fi
-
-jobBatchName="scaMaker-$sourceRadio"
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -l u_sps_baoradio,u_irods,u_irods_baoradio,T=100000,M=256MB,scratch=700MB,platform=LINUX -eo -o $jobLogName -N $jobBatchName -mb -me -mu ${LOGNAME}@lal.in2p3.fr <<EOF
-/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay/scaextractor.sh  ${sourceRadio} ${force}
-EOF
Index: /BAORadio/AmasNancay/trunk/submit2ge-anacalibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-anacalibmaker.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-anacalibmaker.sh	(revision 598)
@@ -41,5 +41,5 @@
 jobLogName="${jobBatchName}.log.$$"
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=1200,vmem=1000M,fsize=1000M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=1200,vmem=1000M,fsize=1000M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/anacalibmaker.sh  -src ${sourceRadio} ${dateSelected} ${freqBAOCalib} ${bwBAOCalib} ${simulationMode}
Index: /BAORadio/AmasNancay/trunk/submit2ge-anagainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-anagainmaker.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-anagainmaker.sh	(revision 598)
@@ -30,5 +30,5 @@
 jobLogName="${jobBatchName}.log.$$"
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=500M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=500M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/anagainmaker.sh -src ${sourceRadio} ${dateSelected} ${simulationMode}
Index: /BAORadio/AmasNancay/trunk/submit2ge-anarawonoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-anarawonoffmaker.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-anarawonoffmaker.sh	(revision 598)
@@ -38,5 +38,5 @@
 jobLogName="${jobBatchName}.log.$$"
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=1000M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=1000M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/anarawonoffmaker.sh  -src ${sourceRadio} ${dateSelected} ${simulationMode}
Index: ORadio/AmasNancay/trunk/submit2ge-calibmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-calibmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,44 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio
-freqBAOCalib=
-bwBAOCalib=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -freq) freqBAOCalib="-freq $2"; shift;;
-      -bwd)  bwBAOCalib="-bwd $2"; shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce [-freq freq in MHz (default ${freqBAOCalib})] [-bwd bandwidth in MHz (default ${bwBAOCalib})]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="calibs-${sourceRadio}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=1000M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
-
-${SCRIPTPATH}/calibmaker.sh  -src ${sourceRadio} ${freqBAOCalib} ${bwBAOCalib} ${simulationMode}
-EOF
Index: ORadio/AmasNancay/trunk/submit2ge-gainmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-gainmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,34 +1,0 @@
-#!/bin/sh -xv
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio=$2; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -sim) simulationMode="-sim";;
-	-h)
-	    echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-sim]"
-	    exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-jobBatchName="anagains-${sourceRadio}${dateJob}"
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=500M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
-
-${SCRIPTPATH}/anagainmaker.sh  -src ${sourceRadio} ${dateSelected} ${simulationMode}
-EOF
Index: /BAORadio/AmasNancay/trunk/submit2ge-hdrfitsextractor.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-hdrfitsextractor.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-hdrfitsextractor.sh	(revision 598)
@@ -19,5 +19,5 @@
 jobLogName="${jobBatchName}.log.$$"
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=2000,vmem=256M,fsize=700M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=2000,vmem=256M,fsize=700M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/hdrfitsextractor.sh  $sourceRadio
Index: ORadio/AmasNancay/trunk/submit2ge-onoffmaker.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-onoffmaker.sh	(revision 597)
+++ 	(revision )
@@ -1,45 +1,0 @@
-#!/bin/sh -xv
-
-scriptName="`basename $0`"
-echo "Processing script ${scriptName} at `date`"
-
-#Process cmd line args: the -src option is mandatory (source name as Abell85)
-sourceRadio=
-dateSelected=
-dateJob=
-freqBAOCalib=
-#use -sim option to simulate processing (debug the script as if...)
-simulationMode=""
-while [ $# -gt 0 ]
-do
-  case "$1" in
-      -src)  sourceRadio="$2"; shift;;
-      -date) dateSelected="-date $2"; dateJob="$2";     shift;;
-      -freq) freqBAOCalib="-freq $2"; shift;;
-      -sim) 
-      simulationMode="-sim On"
-      $ECHO "INFO ${scriptName} running in SIMUL mode";;
-	-h)
-	echo >&2 \
-	    "usage: $0 -src souce -date YYYYMMDD [-freq freq in MHz (default ${freqBAOCalib})] [-sim to trig simulation mode]"
-	exit 1;;
-	*)  break;;	# terminate while loop
-    esac
-    shift
-done
-
-
-if [ "<${sourceRadio}>" = "<>" ]; then
-    $ECHO "FATAL: You have forgotten to select the source option (-src)"
-    exit 1
-fi
-
-
-jobBatchName="onoff-${sourceRadio}${dateJob}"
-
-jobLogName="${jobBatchName}.log.$$"
-
-qsub -P P_baoradio -l sps=1,irods=1,ct=2400,vmem=1000M,fsize=1000M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
-
-${SCRIPTPATH}/onoffmaker.sh  -src ${sourceRadio} ${dateSelected} ${freqBAOCalib} ${simulationMode}
-EOF
Index: /BAORadio/AmasNancay/trunk/submit2ge-procspecmfib.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-procspecmfib.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-procspecmfib.sh	(revision 598)
@@ -125,5 +125,5 @@
 cpu=`expr ${nFiles} \* 60`
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=${cpu},vmem=1000M,fsize=${scratchSize}M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=${cpu},vmem=1000M,fsize=${scratchSize}M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/proc_specmfib.sh ${action} -src ${sourceRadio} ${dateSelected} ${typeofproc} ${firstCycle} ${lastCycle} ${simulationMode}
Index: /BAORadio/AmasNancay/trunk/submit2ge-scaextractor.sh
===================================================================
--- /BAORadio/AmasNancay/trunk/submit2ge-scaextractor.sh	(revision 597)
+++ /BAORadio/AmasNancay/trunk/submit2ge-scaextractor.sh	(revision 598)
@@ -59,5 +59,5 @@
 jobLogName="${jobBatchName}.log.$$"
 
-qsub -P P_baoradio -l sps=1,irods=1,ct=2000,vmem=256M,fsize=700M -o $jobLogName -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
+qsub -P P_baoradio -l sps=1,irods=1,ct=2000,vmem=256M,fsize=700M -o ${PWD}/${jobLogName} -j yes -N $jobBatchName -m be -M ${LOGNAME}@lal.in2p3.fr -V <<EOF
 
 ${SCRIPTPATH}/scaextractor.sh  ${sourceRadio} ${force}
