Changeset 560


Ignore:
Timestamp:
Oct 7, 2011, 3:25:15 PM (13 years ago)
Author:
campagne
Message:

start merging with calibration options (jec)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BAORadio/AmasNancay/trunk/mergeAnaFiles.cc

    r558 r560  
    4141const sa_size_t NUMBER_OF_FREQ     = 8192;
    4242const sa_size_t TOTAL_NUM_CYCLES   = 500;
    43 const r_4    LOWER_FREQUENCY = 1250.0; //MHz
    44 const r_4    TOTAL_BANDWIDTH = 250.0; //MHz
     43const r_4    LOWER_FREQUENCY       = 1250.0; //MHz
     44const r_4    TOTAL_BANDWIDTH       = 250.0; //MHz
    4545//-----------------------------------------------
    4646//Input parameters
     
    5252  string ppfFile_;    //generic name of the input files
    5353  int nSliceInFreq_;  //used by reduceSpectra() fnc
     54  string typeOfCalib_;//type of calibration to be done
    5455} para;
    5556//--------------------------------------------------------------
     
    207208}
    208209//-------------------------------------------------------
    209 //Compute the mean of Raw spectra and also the mean/sigma of rebinned spectra
     210//Compute the mean of Diff ON-OFF BAO-calibrated spectra and also the mean/sigma of rebinned spectra
     211//Used like:
     212//
     213void meanCalibBAODiffOnOffCycles() throw(string) {
     214
     215  list<string> listOfFiles;
     216  string directoryName;
     217  directoryName = para.inPath_ + "/" + para.sourceName_;
     218
     219  //Make the listing of the directory
     220  listOfFiles = ListOfFileInDir(directoryName,para.ppfFile_);
     221 
     222  list<string>::const_iterator iFile, iFileEnd, iSpecOff, iSpecOffEnd, iSpecOn, iSpecOnEnd;
     223  iFileEnd = listOfFiles.end();
     224 
     225  //Loop on files
     226  for (iFile = listOfFiles.begin(); iFile != iFileEnd; ++iFile) {
     227    if (para.debuglev_>90){
     228      cout << "load file <" << *iFile << ">" << endl;
     229    }
     230    PInPersist fin(*iFile);
     231    vector<string> vec = fin.GetNameTags();
     232
     233    if (para.typeOfCalib_ == "perRun") {
     234      ///////////////////
     235      //make the calibration of the mean of all Off and On of the run and perform the difference
     236      ///////////////////
     237      //
     238      //Compute the mean of the Off
     239      //
     240      list<string> listOfSpectraOff;
     241      //Keep only required PPF objects
     242      std::remove_copy_if(
     243                          vec.begin(), vec.end(), back_inserter(listOfSpectra),
     244                          not1(match)
     245                          );
     246     
     247      listOfSpectraOff.sort(stringCompare);
     248      iSpecOffEnd = listOfSpectraOff.end();
     249      TMatrix<r_4> meanOfSpectraOff(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
     250      uint_4 nSpectraOff=0;
     251      //Loop of spectra matrix
     252      for (iSpecOff = listOfSpectraOff.begin(); iSpecOff !=iSpecOffEnd;  ++iSpecOff){
     253        if (para.debuglev_>90){
     254          cout << " spactra <" << *iSpecOff << ">" << endl;
     255        }
     256        TMatrix<r_4> aSpec(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
     257        fin.GetObject(aSpec,*iSpecOff);
     258        //How to see if the GetObject is ok?? Ask Reza
     259        nSpectraOff++;
     260        meanOfSpectraOff+=aSpec;
     261      }//end loop Off
     262      //Normalisation
     263      if(nSpectraOff>0)meanOfSpectraOff/=(r_4)(nSpectraOff);
     264      //
     265      //Compute the mean of the On
     266      //
     267      list<string> listOfSpectraOn;
     268      //Keep only required PPF objects
     269      std::remove_copy_if(
     270                          vec.begin(), vec.end(), back_inserter(listOfSpectra),
     271                          not1(match)
     272                          );
     273     
     274      listOfSpectraOn.sort(stringCompare);
     275      iSpecOnEnd = listOfSpectraOn.end();
     276      TMatrix<r_4> meanOfSpectraOn(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
     277      uint_4 nSpectraOn=0;
     278      //Loop of spectra matrix
     279      for (iSpecOn = listOfSpectraOn.begin(); iSpecOn !=iSpecOnEnd;  ++iSpecOn){
     280        if (para.debuglev_>90){
     281          cout << " spactra <" << *iSpecOn << ">" << endl;
     282        }
     283        TMatrix<r_4> aSpec(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
     284        fin.GetObject(aSpec,*iSpecOn);
     285        //How to see if the GetObject is ok?? Ask Reza
     286        nSpectraOn++;
     287        meanOfSpectraOn+=aSpec;
     288      }//end loop On
     289      //Normalisation
     290      if(nSpectraOn>0)meanOfSpectraOn/=(r_4)(nSpectraOn);
     291      //
     292      //Get the calibration file
     293      //
     294     
     295
     296
     297    } else if {para.typeOfCalib_ == "perCycle") {
     298      //perform the calibration of the OFF and ON per cycle, then make the mean and take the diff
     299    } else {
     300      string msg="FATAL (meanCalibBAODiffOnOffCycles); unknown calibration mode "
     301        + para.typeOfCalib_ ;
     302      throw(msg);
     303    }
     304
     305   
     306    }//eo loop on spectra in a file
     307  }//eo loop on files
     308 
     309}
     310//-------------------------------------------------------
     311//Compute the mean of Diff ON-OFF Raw spectra and also the mean/sigma of rebinned spectra
    210312//Used like:
    211313//
    212 void meanOnCycles() throw(string) {
     314void meanRawDiffOnOffCycles() throw(string) {
    213315  list<string> listOfFiles;
    214316  string directoryName;
     
    238340                        );
    239341   
     342    listOfSpectra.sort(stringCompare);
    240343    iSpecEnd = listOfSpectra.end();
    241     listOfSpectra.sort(stringCompare);
    242344    //Loop of spectra matrix
    243345    for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd;  ++iSpec){
     
    277379}
    278380//-------------------------------------------------------
    279 //Compute the median of Raw spectra and also the mean/sigma of rebinned spectra
     381//Compute the median of Diff ON-OFF Raw spectra and also the mean/sigma of rebinned spectra
    280382//Used like:
    281383//
    282 void medianOnCycles() throw(string) {
     384void medianRawDiffOnOffCycles() throw(string) {
    283385  list<string> listOfFiles;
    284386  string directoryName;
     
    310412                        );
    311413   
     414    listOfSpectra.sort(stringCompare);
    312415    iSpecEnd = listOfSpectra.end();
    313     listOfSpectra.sort(stringCompare);
    314416    //Loop of spectra matrix
    315417    for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd && (sa_size_t)nSpectra < TOTAL_NUM_CYCLES ;  ++iSpec){
     
    375477  }
    376478  TVector<r_4>sigmaMed(NUMBER_OF_CHANNELS);
    377   sa_size_t redf1320=(1320.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_;
    378   sa_size_t redf1380=(1380.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_;
     479  sa_size_t redf1320=(sa_size_t)((1320.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_);
     480  sa_size_t redf1380=(sa_size_t)((1380.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_);
    379481
    380482  for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
     
    442544  string ppfFile;
    443545  string nSliceInFreq = "32";
    444  
     546  string typeOfCalib="perRun";
    445547 
    446548  //  bool okarg=false;
     
    448550  while (ka<narg) {
    449551    if (strcmp(arg[ka],"-h")==0) {
    450       cout << "Usage:  -act [meanDiffOnOff]|medianDiffOnOff\n"
     552      cout << "Usage:  -act [meanRawDiffOnOff]|medianRawDiffOnOff|meanCalibBAODiffOnOff\n"
     553           << " -calibopt [perRun]|perCcyle (cf. in case of calibration to be done)"
    451554           << " -src [Abell85]\n -inPath [.]|<top_root_dir of the ppf file>\n"
    452555           << " (ex. /sps/baoradio/AmasNancay/JEC/\n "
     
    466569      ka+=2;
    467570    }
     571    else if (strcmp(arg[ka],"-calibopt")==0) {
     572      typeOfCalib=arg[ka+1];
     573      ka+=2;
     574    }   
    468575    else if (strcmp(arg[ka],"-inPath")==0) {
    469576      inputPath=arg[ka+1];
     
    507614
    508615  if ( "" == ppfFile ) {
    509     cerr << "mergeRawOnOff.cc: you have forgotten ppfFile option"
     616    cerr << "mergeAnaFiles.cc: you have forgotten ppfFile option"
    510617         << endl;
    511618    return 999;
     
    519626//     printf("->%s<-\n(b=%d e=%d)\n",match,b,e);
    520627
    521     if ( action == "meanDiffOnOff" ) {
    522       meanOnCycles();
    523     } else if (action == "medianDiffOnOff") {
    524       medianOnCycles();
     628    if ( action == "meanRawDiffOnOff" ) {
     629      meanRawDiffOnOffCycles();
     630    } else if (action == "medianRawDiffOnOff") {
     631      medianRawDiffOnOffCycles();
     632    } else if (action == "meanCalibBAODiffOnOff") {
     633      meanCalibBAODiffOnOffCycles();
    525634    } else {
    526635      msg = "Unknown action " + action;
Note: See TracChangeset for help on using the changeset viewer.