[540] | 1 | // Utilisation de SOPHYA pour faciliter les tests ...
|
---|
| 2 | #include "sopnamsp.h"
|
---|
| 3 | #include "machdefs.h"
|
---|
| 4 | #include <dirent.h>
|
---|
| 5 | #include <matharr.h>
|
---|
| 6 |
|
---|
| 7 | // include standard c/c++
|
---|
[562] | 8 | #include <regex.h>
|
---|
| 9 | #include <stdio.h>
|
---|
| 10 | #include <stdlib.h>
|
---|
| 11 | #include <limits>
|
---|
[540] | 12 | #include <iostream>
|
---|
| 13 | #include <fstream>
|
---|
| 14 | #include <string>
|
---|
| 15 | #include <vector>
|
---|
| 16 | #include <map>
|
---|
| 17 | #include <functional>
|
---|
| 18 | #include <algorithm>
|
---|
| 19 | #include <numeric>
|
---|
| 20 | #include <list>
|
---|
| 21 | #include <exception>
|
---|
| 22 |
|
---|
| 23 | // include sophya mesure ressource CPU/memoire ...
|
---|
| 24 | #include "resusage.h"
|
---|
| 25 | #include "ctimer.h"
|
---|
| 26 | #include "timing.h"
|
---|
| 27 | #include "timestamp.h"
|
---|
| 28 | #include "strutilxx.h"
|
---|
| 29 | #include "ntuple.h"
|
---|
| 30 | #include "fioarr.h"
|
---|
| 31 | #include "tarrinit.h"
|
---|
| 32 | #include "histinit.h"
|
---|
| 33 | #include "fitsioserver.h"
|
---|
| 34 | #include "fiosinit.h"
|
---|
| 35 | #include "ppersist.h"
|
---|
| 36 |
|
---|
| 37 | //-----------------------------------------------
|
---|
[563] | 38 | //Usage
|
---|
| 39 | //
|
---|
[577] | 40 | //./Objs/mergeAnaFiles -act meanCalibBAODiffOnOff -inPath /sps/baoradio/AmasNancay/JEC/ -src Abell85 -ppfFile dataRaw -debug 1 -mxcycles 500
|
---|
| 41 | //./Objs/mergeAnaFiles -src Abell85 -act meanCalibBAODiffOnOff -mxcycles 500 -calibfreq 1410 -inPath /sps/baoradio/AmasNancay/JEC/ -ppfFile dataRaw -debug 1 >& mergeAna-500.log
|
---|
[563] | 42 | //
|
---|
| 43 | //
|
---|
| 44 | //-----------------------------------------------
|
---|
[542] | 45 | const sa_size_t NUMBER_OF_CHANNELS = 2;
|
---|
[544] | 46 | const sa_size_t NUMBER_OF_FREQ = 8192;
|
---|
[560] | 47 | const r_4 LOWER_FREQUENCY = 1250.0; //MHz
|
---|
| 48 | const r_4 TOTAL_BANDWIDTH = 250.0; //MHz
|
---|
[544] | 49 | //Input parameters
|
---|
| 50 | struct Param {
|
---|
| 51 | int debuglev_; //debug
|
---|
| 52 | string inPath_; //root directory of the input files
|
---|
| 53 | string outPath_; //output files are located here
|
---|
| 54 | string sourceName_; //source name & subdirectory of the input files
|
---|
| 55 | string ppfFile_; //generic name of the input files
|
---|
| 56 | int nSliceInFreq_; //used by reduceSpectra() fnc
|
---|
[561] | 57 | string calibFreq_; //freq. value used for calibration
|
---|
[562] | 58 | r_4 rcalibFreq_; //float version
|
---|
| 59 | string calibBandFreq_; //band of freq. used for calibration
|
---|
| 60 | r_4 rcalibBandFreq_; //float version
|
---|
| 61 | int maxNumberCycles_;//maximum number of cycles to be treated
|
---|
[544] | 62 | } para;
|
---|
| 63 | //--------------------------------------------------------------
|
---|
| 64 | //Utility functions
|
---|
[552] | 65 |
|
---|
[562] | 66 | sa_size_t freqToChan(r_4 f){
|
---|
[553] | 67 | return (sa_size_t)((f-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*NUMBER_OF_FREQ);
|
---|
| 68 | }
|
---|
[562] | 69 | //--------
|
---|
| 70 | //COMPUTE the mean value on a freq. range for all channels
|
---|
| 71 | //--------
|
---|
| 72 | void meanInRange(const TMatrix<r_4> mtx,
|
---|
| 73 | sa_size_t chLow,
|
---|
| 74 | sa_size_t chHigh,
|
---|
| 75 | TVector<r_4>& vec){
|
---|
[563] | 76 |
|
---|
[562] | 77 | sa_size_t nr = mtx.NRows();
|
---|
[563] | 78 |
|
---|
[562] | 79 | for (sa_size_t ir=0; ir<nr; ir++){
|
---|
| 80 | TVector<r_4> tmp(mtx(Range(ir),Range(chLow,chHigh)),false);
|
---|
| 81 | double mean, sigma;
|
---|
| 82 | MeanSigma(tmp,mean,sigma);
|
---|
| 83 | vec(ir) = mean;
|
---|
| 84 | }
|
---|
| 85 | }
|
---|
[553] | 86 | //---------
|
---|
[561] | 87 | class median_of_empty_list_exception:public std::exception{
|
---|
[552] | 88 | virtual const char* what() const throw() {
|
---|
| 89 | return "Attempt to take the median of an empty list of numbers. "
|
---|
| 90 | "The median of an empty list is undefined.";
|
---|
| 91 | }
|
---|
| 92 | };
|
---|
| 93 | template<class RandAccessIter>
|
---|
| 94 | double median(RandAccessIter begin, RandAccessIter end)
|
---|
| 95 | throw(median_of_empty_list_exception){
|
---|
| 96 | if(begin == end){ throw median_of_empty_list_exception(); }
|
---|
| 97 | std::size_t size = end - begin;
|
---|
| 98 | std::size_t middleIdx = size/2;
|
---|
| 99 | RandAccessIter target = begin + middleIdx;
|
---|
| 100 | std::nth_element(begin, target, end);
|
---|
| 101 |
|
---|
| 102 | if(size % 2 != 0){ //Odd number of elements
|
---|
| 103 | return *target;
|
---|
| 104 | }else{ //Even number of elements
|
---|
| 105 | double a = *target;
|
---|
| 106 | RandAccessIter targetNeighbor= target-1;
|
---|
| 107 | std::nth_element(begin, targetNeighbor, end);
|
---|
| 108 | return (a+*targetNeighbor)/2.0;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 |
|
---|
[561] | 112 | //-------------
|
---|
| 113 | void split(const string& str, const string& delimiters , vector<string>& tokens) {
|
---|
| 114 | // Skip delimiters at beginning.
|
---|
| 115 | string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
---|
| 116 | // Find first "non-delimiter".
|
---|
| 117 | string::size_type pos = str.find_first_of(delimiters, lastPos);
|
---|
| 118 |
|
---|
| 119 | while (string::npos != pos || string::npos != lastPos)
|
---|
| 120 | {
|
---|
| 121 | // Found a token, add it to the vector.
|
---|
| 122 | tokens.push_back(str.substr(lastPos, pos - lastPos));
|
---|
| 123 | // Skip delimiters. Note the "not_of"
|
---|
| 124 | lastPos = str.find_first_not_of(delimiters, pos);
|
---|
| 125 | // Find next "non-delimiter"
|
---|
| 126 | pos = str.find_first_of(delimiters, lastPos);
|
---|
| 127 | }
|
---|
| 128 | }
|
---|
[544] | 129 | //--------------------------------------------------------------
|
---|
[540] | 130 | char *regexp (const char *string, const char *patrn, int *begin, int *end) {
|
---|
| 131 | int i, w=0, len;
|
---|
| 132 | char *word = NULL;
|
---|
| 133 | regex_t rgT;
|
---|
| 134 | regmatch_t match;
|
---|
| 135 | regcomp(&rgT,patrn,REG_EXTENDED);
|
---|
| 136 | if ((regexec(&rgT,string,1,&match,0)) == 0) {
|
---|
| 137 | *begin = (int)match.rm_so;
|
---|
| 138 | *end = (int)match.rm_eo;
|
---|
| 139 | len = *end-*begin;
|
---|
| 140 | word=(char*)malloc(len+1);
|
---|
| 141 | for (i=*begin; i<*end; i++) {
|
---|
| 142 | word[w] = string[i];
|
---|
| 143 | w++; }
|
---|
| 144 | word[w]=0;
|
---|
| 145 | }
|
---|
| 146 | regfree(&rgT);
|
---|
| 147 | return word;
|
---|
| 148 | }
|
---|
[544] | 149 | //-------
|
---|
[540] | 150 | sa_size_t round_sa(r_4 r) {
|
---|
| 151 | return static_cast<sa_size_t>((r > 0.0) ? (r + 0.5) : (r - 0.5));
|
---|
| 152 | }
|
---|
| 153 | //-----
|
---|
| 154 | string StringToLower(string strToConvert){
|
---|
| 155 | //change each element of the string to lower case
|
---|
| 156 | for(unsigned int i=0;i<strToConvert.length();i++) {
|
---|
| 157 | strToConvert[i] = tolower(strToConvert[i]);
|
---|
| 158 | }
|
---|
| 159 | return strToConvert;//return the converted string
|
---|
| 160 | }
|
---|
| 161 | //-----
|
---|
| 162 | bool stringCompare( const string &left, const string &right ){
|
---|
| 163 | if( left.size() < right.size() )
|
---|
| 164 | return true;
|
---|
| 165 | for( string::const_iterator lit = left.begin(), rit = right.begin(); lit != left.end() && rit != right.end(); ++lit, ++rit )
|
---|
| 166 | if( tolower( *lit ) < tolower( *rit ) )
|
---|
| 167 | return true;
|
---|
| 168 | else if( tolower( *lit ) > tolower( *rit ) )
|
---|
| 169 | return false;
|
---|
| 170 | return false;
|
---|
| 171 | }
|
---|
| 172 | //-----
|
---|
| 173 | list<string> ListOfFileInDir(string dir, string filePettern) throw(string) {
|
---|
| 174 | list<string> theList;
|
---|
| 175 |
|
---|
| 176 |
|
---|
| 177 | DIR *dip;
|
---|
| 178 | struct dirent *dit;
|
---|
| 179 | string msg; string fileName;
|
---|
| 180 | string fullFileName;
|
---|
| 181 | size_t found;
|
---|
| 182 |
|
---|
| 183 | if ((dip=opendir(dir.c_str())) == NULL ) {
|
---|
| 184 | msg = "opendir failed on directory "+dir;
|
---|
| 185 | throw msg;
|
---|
| 186 | }
|
---|
| 187 | while ( (dit = readdir(dip)) != NULL ) {
|
---|
| 188 | fileName = dit->d_name;
|
---|
| 189 | found=fileName.find(filePettern);
|
---|
| 190 | if (found != string::npos) {
|
---|
| 191 | fullFileName = dir + "/";
|
---|
| 192 | fullFileName += fileName;
|
---|
| 193 | theList.push_back(fullFileName);
|
---|
| 194 | }
|
---|
| 195 | }//eo while
|
---|
| 196 | if (closedir(dip) == -1) {
|
---|
| 197 | msg = "closedir failed on directory "+dir;
|
---|
| 198 | throw msg;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 | theList.sort(stringCompare);
|
---|
| 202 |
|
---|
| 203 | return theList;
|
---|
| 204 |
|
---|
| 205 | }
|
---|
| 206 | //
|
---|
| 207 | class StringMatch : public unary_function<string,bool> {
|
---|
| 208 | public:
|
---|
| 209 | StringMatch(const string& pattern): pattern_(pattern){}
|
---|
| 210 | bool operator()(const string& aStr) const {
|
---|
| 211 |
|
---|
| 212 |
|
---|
| 213 | int b,e;
|
---|
| 214 | regexp(aStr.c_str(),pattern_.c_str(),&b,&e);
|
---|
| 215 |
|
---|
[541] | 216 | // cout << "investigate " << aStr << " to find " << pattern_
|
---|
| 217 | // << "[" <<b<<","<<e<<"]"
|
---|
| 218 | // << endl;
|
---|
[540] | 219 |
|
---|
| 220 |
|
---|
| 221 | if (b != 0) return false;
|
---|
[544] | 222 | if (e != (int)aStr.size()) return false;
|
---|
[540] | 223 | return true;
|
---|
| 224 |
|
---|
| 225 | }
|
---|
| 226 | private:
|
---|
| 227 | string pattern_;
|
---|
| 228 | };
|
---|
| 229 | //-------------------------------------------------------
|
---|
[544] | 230 | //Rebin in frequence + compute mean and sigma
|
---|
| 231 | void reduceSpectra(const TMatrix<r_4>& specMtxInPut,
|
---|
| 232 | TMatrix<r_4>& meanMtx,
|
---|
| 233 | TMatrix<r_4>& sigmaMtx) {
|
---|
| 234 | sa_size_t nSliceFreq = para.nSliceInFreq_;
|
---|
| 235 | sa_size_t deltaFreq = NUMBER_OF_FREQ/nSliceFreq;
|
---|
| 236 | for (sa_size_t iSlice=0; iSlice<nSliceFreq; iSlice++){
|
---|
| 237 | sa_size_t freqLow= iSlice*deltaFreq;
|
---|
| 238 | sa_size_t freqHigh= freqLow + deltaFreq -1;
|
---|
| 239 | for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
|
---|
| 240 | TVector<r_4> reducedRow;
|
---|
| 241 | reducedRow = specMtxInPut.SubMatrix(Range(iCh),Range(freqLow,freqHigh)).CompactAllDimensions();
|
---|
| 242 | double mean;
|
---|
| 243 | double sigma;
|
---|
| 244 | MeanSigma(reducedRow,mean,sigma);
|
---|
| 245 | meanMtx(iCh,iSlice) = mean;
|
---|
| 246 | sigmaMtx(iCh,iSlice) = sigma;
|
---|
| 247 | }//eo loop on channels
|
---|
| 248 | }//eo loop on slices
|
---|
| 249 | }
|
---|
[541] | 250 | //-------------------------------------------------------
|
---|
[560] | 251 | //Compute the mean of Diff ON-OFF BAO-calibrated spectra and also the mean/sigma of rebinned spectra
|
---|
| 252 | //
|
---|
| 253 | void meanCalibBAODiffOnOffCycles() throw(string) {
|
---|
| 254 |
|
---|
| 255 | list<string> listOfFiles;
|
---|
| 256 | string directoryName;
|
---|
| 257 | directoryName = para.inPath_ + "/" + para.sourceName_;
|
---|
| 258 |
|
---|
| 259 | //Make the listing of the directory
|
---|
| 260 | listOfFiles = ListOfFileInDir(directoryName,para.ppfFile_);
|
---|
| 261 |
|
---|
[561] | 262 | list<string>::const_iterator iFile, iFileEnd, iSpec, iSpecEnd;
|
---|
[560] | 263 | iFileEnd = listOfFiles.end();
|
---|
[561] | 264 |
|
---|
[562] | 265 | //mean ON-OFF over the list of cycles
|
---|
| 266 | TMatrix<r_4> meanDiffONOFF_noCalib(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //set to 0
|
---|
| 267 | TMatrix<r_4> meanDiffONOFF_perRunCalib(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //set to 0
|
---|
| 268 | TMatrix<r_4> meanDiffONOFF_perCycleCalib(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //set to 0
|
---|
[577] | 269 | static const int NINFO=19;
|
---|
| 270 | char* onffTupleName[NINFO]={"cycle"
|
---|
| 271 | ,"onoffRaw0","onoffRaw1"
|
---|
| 272 | ,"onoffRun0","onoffRun1"
|
---|
| 273 | ,"onoffCycle0","onoffCycle1"
|
---|
| 274 | ,"onoffRaw01420","onoffRaw11420"
|
---|
| 275 | ,"onoffRun01420","onoffRun11420"
|
---|
| 276 | ,"onoffCycle01420","onoffCycle11420"
|
---|
| 277 | ,"onoffRaw01420side","onoffRaw11420side"
|
---|
| 278 | ,"onoffRun01420side","onoffRun11420side"
|
---|
| 279 | ,"onoffCycle01420side","onoffCycle11420side"
|
---|
| 280 | };
|
---|
| 281 | NTuple onoffevolution(NINFO,onffTupleName);
|
---|
| 282 | r_4 xnt[NINFO];
|
---|
[562] | 283 |
|
---|
[577] | 284 | //Lower and Higher freq. arround the Calibration Freq. bin to perform mean follow up
|
---|
| 285 | sa_size_t chCalibLow = freqToChan(para.rcalibFreq_ - (para.rcalibBandFreq_*0.5));
|
---|
| 286 | sa_size_t chCalibHigh = freqToChan(para.rcalibFreq_ + (para.rcalibBandFreq_*0.5));
|
---|
| 287 | //Lower and Higher freq. just arround 1420.4MHz Freq. bin to perform mean follow up
|
---|
| 288 | sa_size_t ch1420Low = freqToChan(1420);
|
---|
| 289 | sa_size_t ch1420High = freqToChan(1421);
|
---|
| 290 |
|
---|
| 291 | //Lower and Higher freq. on the sides of 1420.4Mhz Freq. bin to perform mean follow up
|
---|
| 292 | sa_size_t ch1420aLow = freqToChan(1418);
|
---|
| 293 | sa_size_t ch1420aHigh = freqToChan(1419);
|
---|
| 294 | sa_size_t ch1420bLow = freqToChan(1422);
|
---|
| 295 | sa_size_t ch1420bHigh = freqToChan(1423);
|
---|
| 296 |
|
---|
| 297 |
|
---|
[563] | 298 | if (para.debuglev_>90){
|
---|
[577] | 299 | cout << "freq. band for follow up [" << chCalibLow << ", "<< chCalibHigh << "]" << endl;
|
---|
| 300 | cout << "freq. band for follow up [" << ch1420Low << ", "<< ch1420High << "]" << endl;
|
---|
[563] | 301 | }
|
---|
[562] | 302 |
|
---|
[561] | 303 | //Loop on files/run
|
---|
[562] | 304 |
|
---|
| 305 | int totalNumberCycles=0; //total number of cycles for normalisation
|
---|
[560] | 306 | for (iFile = listOfFiles.begin(); iFile != iFileEnd; ++iFile) {
|
---|
| 307 | if (para.debuglev_>90){
|
---|
| 308 | cout << "load file <" << *iFile << ">" << endl;
|
---|
| 309 | }
|
---|
[561] | 310 |
|
---|
| 311 | vector<string> tokens;
|
---|
| 312 | split(*iFile,"_",tokens);
|
---|
| 313 | string dateOfRun = tokens[1];
|
---|
| 314 | if (para.debuglev_>90){
|
---|
| 315 | cout << "date <" << dateOfRun << ">" << endl;
|
---|
| 316 | }
|
---|
| 317 | vector<string> tokens2;
|
---|
| 318 | split(tokens[2],".",tokens2);
|
---|
| 319 | string srcLower = tokens2[0];
|
---|
| 320 |
|
---|
| 321 |
|
---|
| 322 |
|
---|
[560] | 323 | PInPersist fin(*iFile);
|
---|
| 324 | vector<string> vec = fin.GetNameTags();
|
---|
| 325 |
|
---|
[561] | 326 | vector<string> modeList;
|
---|
| 327 | modeList.push_back("On");
|
---|
| 328 | modeList.push_back("Off");
|
---|
| 329 | vector<string>::const_iterator iMode;
|
---|
| 330 |
|
---|
| 331 | map<string, list<int> > cycleModeCollect;
|
---|
| 332 |
|
---|
| 333 | for (iMode = modeList.begin(); iMode!=modeList.end(); ++iMode) {
|
---|
| 334 | list<string> listOfSpectra;
|
---|
[560] | 335 | //Keep only required PPF objects
|
---|
[561] | 336 | string matchstr = "specRaw"+(*iMode)+"[0-9]+";
|
---|
[560] | 337 | std::remove_copy_if(
|
---|
| 338 | vec.begin(), vec.end(), back_inserter(listOfSpectra),
|
---|
[561] | 339 | not1(StringMatch(matchstr))
|
---|
[560] | 340 | );
|
---|
| 341 |
|
---|
[561] | 342 | listOfSpectra.sort(stringCompare);
|
---|
| 343 | iSpecEnd = listOfSpectra.end();
|
---|
[560] | 344 |
|
---|
[561] | 345 | matchstr = "[0-9]+";
|
---|
[560] | 346 | //Loop of spectra matrix
|
---|
[561] | 347 | list<int> listOfCycles;
|
---|
| 348 | for (iSpec = listOfSpectra.begin(); iSpec!=iSpecEnd; ++iSpec){
|
---|
| 349 | int b,e;
|
---|
| 350 | regexp(iSpec->c_str(),matchstr.c_str(),&b,&e);
|
---|
[560] | 351 | if (para.debuglev_>90){
|
---|
[561] | 352 | cout << " spactra <" << *iSpec << ">" << endl;
|
---|
| 353 | cout << " cycle " << iSpec->substr(b) << endl;
|
---|
[560] | 354 | }
|
---|
[561] | 355 | listOfCycles.push_back(atoi((iSpec->substr(b)).c_str()));
|
---|
| 356 | }//end loop spectra
|
---|
| 357 | cycleModeCollect[*iMode] = listOfCycles;
|
---|
| 358 | }//end of mode
|
---|
| 359 |
|
---|
| 360 | //Take the Intersection of the list Of cycles in mode Off and On
|
---|
| 361 | list<int> commonCycles;
|
---|
| 362 | set_intersection(cycleModeCollect["On"].begin(),
|
---|
| 363 | cycleModeCollect["On"].end(),
|
---|
| 364 | cycleModeCollect["Off"].begin(),
|
---|
| 365 | cycleModeCollect["Off"].end(),
|
---|
| 366 | back_inserter(commonCycles)
|
---|
| 367 | );
|
---|
| 368 |
|
---|
| 369 | if (para.debuglev_>90){
|
---|
| 370 | cout << "Liste of cycles common to On & Off: <";
|
---|
| 371 | for (list<int>::iterator i=commonCycles.begin(); i!=commonCycles.end(); ++i){
|
---|
| 372 | cout << *i << " ";
|
---|
| 373 | }
|
---|
| 374 | cout << ">" << endl;
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | //
|
---|
| 378 | //Load BAO Calibration factors "per Cycle and Channels"
|
---|
| 379 | //Compute the mean per Cycle to
|
---|
| 380 | // fill factors "per Run and Channels" with the same cycle list
|
---|
| 381 | //
|
---|
| 382 | //
|
---|
| 383 | //TODO improve the code....
|
---|
| 384 |
|
---|
| 385 | TMatrix<r_4> calibBAOfactors_Off_Cycle_Ch0;
|
---|
| 386 | TMatrix<r_4> calibBAOfactors_Off_Cycle_Ch1;
|
---|
| 387 | TMatrix<r_4> calibBAOfactors_On_Cycle_Ch0;
|
---|
| 388 | TMatrix<r_4> calibBAOfactors_On_Cycle_Ch1;
|
---|
| 389 |
|
---|
| 390 | string calibFileName;
|
---|
| 391 | ifstream ifs;
|
---|
| 392 | sa_size_t nr,nc; //values read
|
---|
| 393 |
|
---|
| 394 | //OFF Cycle per Channel
|
---|
| 395 | calibFileName = directoryName + "/"
|
---|
| 396 | + "calib_" + dateOfRun + "_" + srcLower + "_Off_"
|
---|
| 397 | + para.calibFreq_ +"MHz-Ch0Cycles.txt";
|
---|
| 398 | if(para.debuglev_>0) cout << "Read Calib file " << calibFileName << endl;
|
---|
| 399 | ifs.open(calibFileName.c_str());
|
---|
| 400 | if ( ! ifs.is_open() ) {
|
---|
| 401 |
|
---|
| 402 | throw calibFileName + " cannot be opened...";
|
---|
| 403 | }
|
---|
| 404 | calibBAOfactors_Off_Cycle_Ch0.ReadASCII(ifs,nr,nc);
|
---|
| 405 | if(para.debuglev_>9){
|
---|
| 406 | cout << "(nr,nc): "<< nr << "," << nc << endl;
|
---|
| 407 | calibBAOfactors_Off_Cycle_Ch0.Print(cout);
|
---|
[562] | 408 | cout << endl;
|
---|
[561] | 409 | }
|
---|
| 410 |
|
---|
| 411 | TMatrix<r_4> calibBAOfactors_Off_Run_Ch0(nr,nc);
|
---|
| 412 | calibBAOfactors_Off_Run_Ch0.Column(0) = calibBAOfactors_Off_Cycle_Ch0.Column(0);
|
---|
| 413 | {//Compute the mean
|
---|
| 414 | TVector<r_4> coef(calibBAOfactors_Off_Cycle_Ch0(Range::all(),Range::last()),false);
|
---|
| 415 | double mean,sigma;
|
---|
| 416 | MeanSigma(coef,mean,sigma);
|
---|
| 417 | calibBAOfactors_Off_Run_Ch0.Column(1).SetCst(mean);
|
---|
| 418 | }
|
---|
| 419 | if(para.debuglev_>9){
|
---|
| 420 | cout << "Fill calib. with mean value " << endl;
|
---|
| 421 | calibBAOfactors_Off_Run_Ch0.Print(cout);
|
---|
[562] | 422 | cout << endl;
|
---|
[561] | 423 | }
|
---|
| 424 | ifs.close();
|
---|
| 425 |
|
---|
| 426 | //
|
---|
| 427 | calibFileName = directoryName + "/"
|
---|
| 428 | + "calib_" + dateOfRun + "_" + srcLower + "_Off_"
|
---|
| 429 | + para.calibFreq_ +"MHz-Ch1Cycles.txt";
|
---|
| 430 | if(para.debuglev_>0) cout << "Read Calib file " << calibFileName << endl;
|
---|
| 431 | ifs.open(calibFileName.c_str());
|
---|
| 432 | if ( ! ifs.is_open() ) {
|
---|
| 433 |
|
---|
| 434 | throw calibFileName + " cannot be opened...";
|
---|
| 435 | }
|
---|
| 436 | calibBAOfactors_Off_Cycle_Ch1.ReadASCII(ifs,nr,nc);
|
---|
| 437 | if(para.debuglev_>9){
|
---|
| 438 | cout << "(nr,nc): "<< nr << "," << nc << endl;
|
---|
| 439 | calibBAOfactors_Off_Cycle_Ch1.Print(cout);
|
---|
[562] | 440 | cout << endl;
|
---|
[561] | 441 | }
|
---|
| 442 | TMatrix<r_4> calibBAOfactors_Off_Run_Ch1(nr,nc);
|
---|
| 443 | calibBAOfactors_Off_Run_Ch1.Column(0) = calibBAOfactors_Off_Cycle_Ch1.Column(0);
|
---|
| 444 | {//Compute the mean
|
---|
| 445 | TVector<r_4> coef(calibBAOfactors_Off_Cycle_Ch1(Range::all(),Range::last()),false);
|
---|
| 446 | double mean,sigma;
|
---|
| 447 | MeanSigma(coef,mean,sigma);
|
---|
[563] | 448 | // cout << "Mean: " << mean << " sigma " << sigma << endl;
|
---|
[561] | 449 | calibBAOfactors_Off_Run_Ch1.Column(1).SetCst(mean);
|
---|
| 450 | }
|
---|
| 451 | if(para.debuglev_>9){
|
---|
| 452 | cout << "Fill calib. with mean value " << endl;
|
---|
| 453 | calibBAOfactors_Off_Run_Ch1.Print(cout);
|
---|
[562] | 454 | cout << endl;
|
---|
[561] | 455 | }
|
---|
| 456 | ifs.close();
|
---|
| 457 |
|
---|
| 458 | //ON Cycle per Channel
|
---|
| 459 | calibFileName = directoryName + "/"
|
---|
| 460 | + "calib_" + dateOfRun + "_" + srcLower + "_On_"
|
---|
| 461 | + para.calibFreq_ +"MHz-Ch0Cycles.txt";
|
---|
| 462 | if(para.debuglev_>0) cout << "Read Calib file " << calibFileName << endl;
|
---|
| 463 | ifs.open(calibFileName.c_str());
|
---|
| 464 | if ( ! ifs.is_open() ) {
|
---|
| 465 |
|
---|
| 466 | throw calibFileName + " cannot be opened...";
|
---|
| 467 | }
|
---|
| 468 | calibBAOfactors_On_Cycle_Ch0.ReadASCII(ifs,nr,nc);
|
---|
| 469 | if(para.debuglev_>9){
|
---|
| 470 | cout << "(nr,nc): "<< nr << "," << nc << endl;
|
---|
| 471 | calibBAOfactors_On_Cycle_Ch0.Print(cout);
|
---|
[562] | 472 | cout << endl;
|
---|
[561] | 473 | }
|
---|
| 474 |
|
---|
| 475 | TMatrix<r_4> calibBAOfactors_On_Run_Ch0(nr,nc);
|
---|
| 476 | calibBAOfactors_On_Run_Ch0.Column(0) = calibBAOfactors_On_Cycle_Ch0.Column(0);
|
---|
| 477 | {//Compute the mean
|
---|
| 478 | TVector<r_4> coef(calibBAOfactors_On_Cycle_Ch0(Range::all(),Range::last()),false);
|
---|
| 479 | double mean,sigma;
|
---|
| 480 | MeanSigma(coef,mean,sigma);
|
---|
[563] | 481 | // cout << "Mean: " << mean << " sigma " << sigma << endl;
|
---|
[561] | 482 | calibBAOfactors_On_Run_Ch0.Column(1).SetCst(mean);
|
---|
| 483 | }
|
---|
| 484 | if(para.debuglev_>9){
|
---|
| 485 | cout << "Fill calib. with mean value " << endl;
|
---|
| 486 | calibBAOfactors_On_Run_Ch0.Print(cout);
|
---|
[562] | 487 | cout << endl;
|
---|
[561] | 488 | }
|
---|
| 489 | ifs.close();
|
---|
| 490 |
|
---|
| 491 |
|
---|
| 492 | calibFileName = directoryName + "/"
|
---|
| 493 | + "calib_" + dateOfRun + "_" + srcLower + "_On_"
|
---|
| 494 | + para.calibFreq_ +"MHz-Ch1Cycles.txt";
|
---|
| 495 | if(para.debuglev_>0) cout << "Read Calib file " << calibFileName << endl;
|
---|
| 496 | ifs.open(calibFileName.c_str());
|
---|
| 497 | if ( ! ifs.is_open() ) {
|
---|
| 498 | throw calibFileName + " cannot be opened...";
|
---|
| 499 | }
|
---|
| 500 | calibBAOfactors_On_Cycle_Ch1.ReadASCII(ifs,nr,nc);
|
---|
| 501 | if(para.debuglev_>9){
|
---|
| 502 | cout << "(nr,nc): "<< nr << "," << nc << endl;
|
---|
| 503 | calibBAOfactors_On_Cycle_Ch1.Print(cout);
|
---|
[562] | 504 | cout << endl;
|
---|
[561] | 505 | }
|
---|
| 506 | TMatrix<r_4> calibBAOfactors_On_Run_Ch1(nr,nc);
|
---|
| 507 | calibBAOfactors_On_Run_Ch1.Column(0) = calibBAOfactors_On_Cycle_Ch1.Column(0);
|
---|
| 508 | {//Compute the mean
|
---|
| 509 | TVector<r_4> coef(calibBAOfactors_On_Cycle_Ch1(Range::all(),Range::last()),false);
|
---|
| 510 | double mean,sigma;
|
---|
| 511 | MeanSigma(coef,mean,sigma);
|
---|
[563] | 512 | // cout << "Mean: " << mean << " sigma " << sigma << endl;
|
---|
[561] | 513 | calibBAOfactors_On_Run_Ch1.Column(1).SetCst(mean);
|
---|
| 514 | }
|
---|
| 515 | if(para.debuglev_>9){
|
---|
| 516 | cout << "Fill calib. with mean value " << endl;
|
---|
| 517 | calibBAOfactors_On_Run_Ch1.Print(cout);
|
---|
[562] | 518 | cout << endl;
|
---|
[561] | 519 | }
|
---|
| 520 |
|
---|
| 521 | ifs.close();
|
---|
| 522 |
|
---|
| 523 | //link <cycle> - <calibration coefficient>
|
---|
[562] | 524 | //We cannot rely on identical cycle list of the OFF and ON calibration
|
---|
| 525 | map<int,r_4> calibBAO_Off_Run_Ch0;
|
---|
| 526 | map<int,r_4> calibBAO_Off_Run_Ch1;
|
---|
| 527 | map<int,r_4> calibBAO_On_Run_Ch0;
|
---|
| 528 | map<int,r_4> calibBAO_On_Run_Ch1;
|
---|
[561] | 529 |
|
---|
[562] | 530 | map<int,r_4> calibBAO_Off_Cycle_Ch0;
|
---|
| 531 | map<int,r_4> calibBAO_Off_Cycle_Ch1;
|
---|
| 532 | map<int,r_4> calibBAO_On_Cycle_Ch0;
|
---|
| 533 | map<int,r_4> calibBAO_On_Cycle_Ch1;
|
---|
[560] | 534 |
|
---|
[562] | 535 | //per Run based BAO coefficients
|
---|
| 536 | nr = calibBAOfactors_Off_Run_Ch0.NRows();
|
---|
| 537 | for (sa_size_t ir=0; ir<nr; ++ir){
|
---|
[563] | 538 | // cout << "Calib. Off Run Ch0 cycle ["<< calibBAOfactors_Off_Run_Ch0(ir,0)<<"], val "
|
---|
| 539 | // << calibBAOfactors_Off_Run_Ch0(ir,1) << endl;
|
---|
| 540 |
|
---|
[562] | 541 | calibBAO_Off_Run_Ch0[(int)calibBAOfactors_Off_Run_Ch0(ir,0)]
|
---|
| 542 | = calibBAOfactors_Off_Run_Ch0(ir,1);
|
---|
| 543 | calibBAO_Off_Cycle_Ch0[(int)calibBAOfactors_Off_Cycle_Ch0(ir,0)]
|
---|
| 544 | = calibBAOfactors_Off_Cycle_Ch0(ir,1);
|
---|
| 545 | calibBAO_Off_Run_Ch1[(int)calibBAOfactors_Off_Run_Ch1(ir,0)]
|
---|
| 546 | = calibBAOfactors_Off_Run_Ch1(ir,1);
|
---|
| 547 | calibBAO_Off_Cycle_Ch1[(int)calibBAOfactors_Off_Cycle_Ch1(ir,0)]
|
---|
| 548 | = calibBAOfactors_Off_Cycle_Ch1(ir,1);
|
---|
[563] | 549 | }//eo loop on coef Off
|
---|
[562] | 550 |
|
---|
| 551 | nr = calibBAOfactors_On_Run_Ch0.NRows();
|
---|
| 552 | for (sa_size_t ir=0; ir<nr; ++ir){
|
---|
| 553 | calibBAO_On_Run_Ch0[(int)calibBAOfactors_On_Run_Ch0(ir,0)]
|
---|
| 554 | = calibBAOfactors_On_Run_Ch0(ir,1);
|
---|
| 555 | calibBAO_On_Cycle_Ch0[(int)calibBAOfactors_On_Cycle_Ch0(ir,0)]
|
---|
| 556 | = calibBAOfactors_On_Cycle_Ch0(ir,1);
|
---|
| 557 | calibBAO_On_Run_Ch1[(int)calibBAOfactors_On_Run_Ch1(ir,0)]
|
---|
| 558 | = calibBAOfactors_On_Run_Ch1(ir,1);
|
---|
| 559 | calibBAO_On_Cycle_Ch1[(int)calibBAOfactors_On_Cycle_Ch1(ir,0)]
|
---|
| 560 | = calibBAOfactors_On_Cycle_Ch1(ir,1);
|
---|
[563] | 561 | }//eo loop on coef On
|
---|
[562] | 562 |
|
---|
[561] | 563 | //Loop on cyles
|
---|
| 564 | for (list<int>::iterator ic=commonCycles.begin(); ic!=commonCycles.end(); ++ic){
|
---|
[562] | 565 |
|
---|
[563] | 566 | //Look if the cycle has been calibrated...
|
---|
| 567 | bool isCycleCalibrated =
|
---|
| 568 | ( calibBAO_On_Run_Ch0.count(*ic) *
|
---|
| 569 | calibBAO_On_Run_Ch1.count(*ic) *
|
---|
| 570 | calibBAO_Off_Run_Ch0.count(*ic) *
|
---|
| 571 | calibBAO_Off_Run_Ch1.count(*ic) *
|
---|
| 572 | calibBAO_On_Cycle_Ch0.count(*ic) *
|
---|
| 573 | calibBAO_On_Cycle_Ch1.count(*ic) *
|
---|
| 574 | calibBAO_Off_Cycle_Ch0.count(*ic) *
|
---|
| 575 | calibBAO_Off_Cycle_Ch1.count(*ic) ) != 0 ? true : false;
|
---|
| 576 |
|
---|
| 577 | if(para.debuglev_>9) {
|
---|
[562] | 578 | cout << "Calibration coefficients for cycle "<<*ic << endl;
|
---|
[563] | 579 | if (isCycleCalibrated) {
|
---|
| 580 | cout << "Cycle calibrated " << endl;
|
---|
| 581 | cout << "Off Run Ch0 " << calibBAO_Off_Run_Ch0[*ic] << " "
|
---|
| 582 | << "Ch1 " << calibBAO_Off_Run_Ch1[*ic] << "\n"
|
---|
| 583 | << "On Run Ch0 " << calibBAO_On_Run_Ch0[*ic] << " "
|
---|
| 584 | << "Ch1 " << calibBAO_On_Run_Ch1[*ic] << "\n"
|
---|
| 585 | << "Off Cycle Ch0 " << calibBAO_Off_Cycle_Ch0[*ic] << " "
|
---|
| 586 | << "Ch1 " << calibBAO_Off_Cycle_Ch1[*ic] << "\n"
|
---|
| 587 | << "On Cycle Ch0 " << calibBAO_On_Cycle_Ch0[*ic] << " "
|
---|
| 588 | << "Ch1 " << calibBAO_On_Cycle_Ch1[*ic] << endl;
|
---|
| 589 | } else {
|
---|
| 590 | cout << "Cycle NOT calibrated " << endl;
|
---|
| 591 | }
|
---|
| 592 | }//debug
|
---|
| 593 |
|
---|
| 594 |
|
---|
| 595 | if ( ! isCycleCalibrated ) continue;
|
---|
[562] | 596 |
|
---|
[561] | 597 | string ppftag;
|
---|
| 598 | //load ON phase
|
---|
| 599 | stringstream cycle;
|
---|
| 600 | cycle << *ic;
|
---|
| 601 |
|
---|
| 602 | ppftag = "specRawOn"+cycle.str();
|
---|
[562] | 603 | TMatrix<r_4> aSpecOn(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
| 604 | fin.GetObject(aSpecOn,ppftag);
|
---|
[561] | 605 |
|
---|
[562] | 606 | TMatrix<r_4> aSpecOn_BAOCalibRun(aSpecOn,false);
|
---|
| 607 | aSpecOn_BAOCalibRun(Range(0),Range::all()) /= calibBAO_On_Run_Ch0[*ic];
|
---|
| 608 | aSpecOn_BAOCalibRun(Range(1),Range::all()) /= calibBAO_On_Run_Ch1[*ic];
|
---|
| 609 |
|
---|
| 610 | TMatrix<r_4> aSpecOn_BAOCalibCycle(aSpecOn,false);
|
---|
| 611 | aSpecOn_BAOCalibCycle(Range(0),Range::all()) /= calibBAO_On_Cycle_Ch0[*ic];
|
---|
| 612 | aSpecOn_BAOCalibCycle(Range(1),Range::all()) /= calibBAO_On_Cycle_Ch1[*ic];
|
---|
[561] | 613 |
|
---|
[562] | 614 | ppftag = "specRawOff"+cycle.str();
|
---|
| 615 | TMatrix<r_4> aSpecOff(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
| 616 | fin.GetObject(aSpecOff,ppftag);
|
---|
[561] | 617 |
|
---|
[562] | 618 | TMatrix<r_4> aSpecOff_BAOCalibRun(aSpecOff,false);
|
---|
| 619 | aSpecOff_BAOCalibRun(Range(0),Range::all()) /= calibBAO_Off_Run_Ch0[*ic];
|
---|
| 620 | aSpecOff_BAOCalibRun(Range(1),Range::all()) /= calibBAO_Off_Run_Ch1[*ic];
|
---|
[561] | 621 |
|
---|
[562] | 622 | TMatrix<r_4> aSpecOff_BAOCalibCycle(aSpecOff,false);
|
---|
| 623 | aSpecOff_BAOCalibCycle(Range(0),Range::all()) /= calibBAO_Off_Cycle_Ch0[*ic];
|
---|
| 624 | aSpecOff_BAOCalibCycle(Range(1),Range::all()) /= calibBAO_Off_Cycle_Ch1[*ic];
|
---|
[561] | 625 |
|
---|
[562] | 626 |
|
---|
| 627 | //Perform the difference ON-OFF with the different calibration options
|
---|
| 628 | TMatrix<r_4> diffOnOff_noCalib = aSpecOn - aSpecOff;
|
---|
| 629 | meanDiffONOFF_noCalib += diffOnOff_noCalib;
|
---|
[561] | 630 |
|
---|
[562] | 631 | TMatrix<r_4> diffOnOff_perRunCalib = aSpecOn_BAOCalibRun - aSpecOff_BAOCalibRun;
|
---|
| 632 | meanDiffONOFF_perRunCalib += diffOnOff_perRunCalib;
|
---|
| 633 |
|
---|
| 634 | TMatrix<r_4> diffOnOff_perCycleCalib = aSpecOn_BAOCalibCycle - aSpecOff_BAOCalibCycle;
|
---|
| 635 | meanDiffONOFF_perCycleCalib += diffOnOff_perCycleCalib;
|
---|
| 636 |
|
---|
[563] | 637 | //
|
---|
| 638 | totalNumberCycles++;
|
---|
[562] | 639 | //Fill NTuple
|
---|
[563] | 640 | xnt[0] = totalNumberCycles;
|
---|
[577] | 641 |
|
---|
| 642 | //Follow up arround the Calibration Freq.
|
---|
| 643 | TVector<r_4> meanInRange_CalibFreq_noCalib(NUMBER_OF_CHANNELS);
|
---|
| 644 | meanInRange(diffOnOff_noCalib,chCalibLow,chCalibHigh,meanInRange_CalibFreq_noCalib);
|
---|
| 645 | xnt[1] = meanInRange_CalibFreq_noCalib(0);
|
---|
| 646 | xnt[2] = meanInRange_CalibFreq_noCalib(1);
|
---|
[562] | 647 |
|
---|
[577] | 648 | TVector<r_4> meanInRange_CalibFreq_perRunCalib(NUMBER_OF_CHANNELS);
|
---|
| 649 | meanInRange(diffOnOff_perRunCalib,chCalibLow,chCalibHigh,meanInRange_CalibFreq_perRunCalib);
|
---|
| 650 | xnt[3] = meanInRange_CalibFreq_perRunCalib(0);
|
---|
| 651 | xnt[4] = meanInRange_CalibFreq_perRunCalib(1);
|
---|
[562] | 652 |
|
---|
[577] | 653 | TVector<r_4> meanInRange_CalibFreq_perCycleCalib(NUMBER_OF_CHANNELS);
|
---|
| 654 | meanInRange(diffOnOff_perCycleCalib,chCalibLow,chCalibHigh,meanInRange_CalibFreq_perCycleCalib);
|
---|
| 655 | xnt[5] = meanInRange_CalibFreq_perCycleCalib(0);
|
---|
| 656 | xnt[6] = meanInRange_CalibFreq_perCycleCalib(1);
|
---|
| 657 |
|
---|
| 658 |
|
---|
| 659 | //Follow up arround the 1420.4MHz Freq.
|
---|
| 660 | TVector<r_4> meanInRange_1420Freq_noCalib(NUMBER_OF_CHANNELS);
|
---|
| 661 | meanInRange(diffOnOff_noCalib,ch1420Low,ch1420High,meanInRange_1420Freq_noCalib);
|
---|
| 662 | xnt[7] = meanInRange_1420Freq_noCalib(0);
|
---|
| 663 | xnt[8] = meanInRange_1420Freq_noCalib(1);
|
---|
| 664 |
|
---|
| 665 | TVector<r_4> meanInRange_1420Freq_perRunCalib(NUMBER_OF_CHANNELS);
|
---|
| 666 | meanInRange(diffOnOff_perRunCalib,ch1420Low,ch1420High,meanInRange_1420Freq_perRunCalib);
|
---|
| 667 | xnt[9] = meanInRange_1420Freq_perRunCalib(0);
|
---|
| 668 | xnt[10] = meanInRange_1420Freq_perRunCalib(1);
|
---|
| 669 |
|
---|
| 670 | TVector<r_4> meanInRange_1420Freq_perCycleCalib(NUMBER_OF_CHANNELS);
|
---|
| 671 | meanInRange(diffOnOff_perCycleCalib,ch1420Low,ch1420High,meanInRange_1420Freq_perCycleCalib);
|
---|
| 672 | xnt[11] = meanInRange_1420Freq_perCycleCalib(0);
|
---|
| 673 | xnt[12] = meanInRange_1420Freq_perCycleCalib(1);
|
---|
| 674 |
|
---|
| 675 |
|
---|
| 676 | //Follow up below the 1420.4MHz Freq.
|
---|
| 677 | TVector<r_4> meanInRange_1420aFreq_noCalib(NUMBER_OF_CHANNELS);
|
---|
| 678 | meanInRange(diffOnOff_noCalib,ch1420aLow,ch1420aHigh,meanInRange_1420aFreq_noCalib);
|
---|
| 679 | TVector<r_4> meanInRange_1420bFreq_noCalib(NUMBER_OF_CHANNELS);
|
---|
| 680 | meanInRange(diffOnOff_noCalib,ch1420bLow,ch1420bHigh,meanInRange_1420bFreq_noCalib);
|
---|
| 681 |
|
---|
| 682 | xnt[13] = (meanInRange_1420aFreq_noCalib(0) + meanInRange_1420bFreq_noCalib(0))/2.;
|
---|
| 683 | xnt[14] = (meanInRange_1420aFreq_noCalib(1) + meanInRange_1420bFreq_noCalib(1))/2.;
|
---|
| 684 |
|
---|
| 685 |
|
---|
| 686 | TVector<r_4> meanInRange_1420aFreq_perRun(NUMBER_OF_CHANNELS);
|
---|
| 687 | meanInRange(diffOnOff_perRunCalib,ch1420aLow,ch1420aHigh,meanInRange_1420aFreq_perRun);
|
---|
| 688 | TVector<r_4> meanInRange_1420bFreq_perRun(NUMBER_OF_CHANNELS);
|
---|
| 689 | meanInRange(diffOnOff_perRunCalib,ch1420bLow,ch1420bHigh,meanInRange_1420bFreq_perRun);
|
---|
| 690 |
|
---|
| 691 | xnt[15] = (meanInRange_1420aFreq_perRun(0) + meanInRange_1420bFreq_perRun(0))/2.;
|
---|
| 692 | xnt[16] = (meanInRange_1420aFreq_perRun(1) + meanInRange_1420bFreq_perRun(1))/2.;
|
---|
| 693 |
|
---|
| 694 |
|
---|
| 695 | TVector<r_4> meanInRange_1420aFreq_perCycle(NUMBER_OF_CHANNELS);
|
---|
| 696 | meanInRange(diffOnOff_perCycleCalib,ch1420aLow,ch1420aHigh,meanInRange_1420aFreq_perCycle);
|
---|
| 697 | TVector<r_4> meanInRange_1420bFreq_perCycle(NUMBER_OF_CHANNELS);
|
---|
| 698 | meanInRange(diffOnOff_perCycleCalib,ch1420bLow,ch1420bHigh,meanInRange_1420bFreq_perCycle);
|
---|
| 699 |
|
---|
| 700 | xnt[17] = (meanInRange_1420aFreq_perCycle(0) + meanInRange_1420bFreq_perCycle(0))/2.;
|
---|
| 701 | xnt[18] = (meanInRange_1420aFreq_perCycle(1) + meanInRange_1420bFreq_perCycle(1))/2.;
|
---|
| 702 |
|
---|
[562] | 703 |
|
---|
[577] | 704 | //store infos to Ntuple
|
---|
[562] | 705 | onoffevolution.Fill(xnt);
|
---|
| 706 |
|
---|
[563] | 707 | //Quit if enough
|
---|
[562] | 708 | if (totalNumberCycles >= para.maxNumberCycles_) break;
|
---|
| 709 |
|
---|
[561] | 710 | }//eo loop on cycles
|
---|
[562] | 711 | if (totalNumberCycles >= para.maxNumberCycles_) break;
|
---|
| 712 |
|
---|
| 713 | }//eo loop on spectra in a file
|
---|
| 714 | cout << "End of jobs: we have treated " << totalNumberCycles << " cycles" << endl;
|
---|
| 715 | //Normalisation
|
---|
[563] | 716 | if(totalNumberCycles > 0){
|
---|
[562] | 717 | meanDiffONOFF_noCalib /= (r_4)totalNumberCycles;
|
---|
| 718 | meanDiffONOFF_perRunCalib /= (r_4)totalNumberCycles;
|
---|
| 719 | meanDiffONOFF_perCycleCalib /= (r_4)totalNumberCycles;
|
---|
| 720 | }
|
---|
| 721 |
|
---|
| 722 | //Compute the reduced version of the mean and sigma
|
---|
| 723 | TMatrix<r_4> meanRedMtx_noCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 724 | TMatrix<r_4> sigmaRedMtx_noCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 725 | reduceSpectra(meanDiffONOFF_noCalib,meanRedMtx_noCalib,sigmaRedMtx_noCalib);
|
---|
[561] | 726 |
|
---|
[562] | 727 | TMatrix<r_4> meanRedMtx_perRunCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 728 | TMatrix<r_4> sigmaRedMtx_perRunCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 729 | reduceSpectra(meanDiffONOFF_perRunCalib,meanRedMtx_perRunCalib,sigmaRedMtx_perRunCalib);
|
---|
| 730 |
|
---|
| 731 | TMatrix<r_4> meanRedMtx_perCycleCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 732 | TMatrix<r_4> sigmaRedMtx_perCycleCalib(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 733 | reduceSpectra(meanDiffONOFF_perCycleCalib,meanRedMtx_perCycleCalib,sigmaRedMtx_perCycleCalib);
|
---|
| 734 |
|
---|
| 735 | {//save the results
|
---|
| 736 | stringstream tmp;
|
---|
| 737 | tmp << totalNumberCycles;
|
---|
| 738 | string fileName = para.outPath_+"/onoffsurvey_"+StringToLower(para.sourceName_)+"-"+tmp.str()+"Cycles.ppf";
|
---|
[563] | 739 |
|
---|
[562] | 740 | POutPersist fos(fileName);
|
---|
[563] | 741 | cout << "Save output in " << fileName << endl;
|
---|
[562] | 742 |
|
---|
| 743 | string tag = "meanNoCalib";
|
---|
| 744 | fos << PPFNameTag(tag) << meanDiffONOFF_noCalib;
|
---|
| 745 | tag = "meanPerRunCalib";
|
---|
| 746 | fos << PPFNameTag(tag) << meanDiffONOFF_perRunCalib;
|
---|
| 747 | tag = "meanPerCycleCalib";
|
---|
| 748 | fos << PPFNameTag(tag) << meanDiffONOFF_perCycleCalib;
|
---|
| 749 |
|
---|
| 750 | tag = "redmeanNoCalib";
|
---|
| 751 | fos << PPFNameTag(tag) << meanRedMtx_noCalib;
|
---|
| 752 | tag = "redsigmaNoCalib";
|
---|
| 753 | fos << PPFNameTag(tag) << sigmaRedMtx_noCalib;
|
---|
| 754 |
|
---|
| 755 | tag = "redmeanPerRunCalib";
|
---|
| 756 | fos << PPFNameTag(tag) << meanRedMtx_perRunCalib;
|
---|
| 757 | tag = "redsigmaPerRunCalib";
|
---|
| 758 | fos << PPFNameTag(tag) << sigmaRedMtx_perRunCalib;
|
---|
| 759 |
|
---|
| 760 | tag = "redmeanPerCycleCalib";
|
---|
| 761 | fos << PPFNameTag(tag) << meanRedMtx_perCycleCalib;
|
---|
| 762 | tag = "redsigmaPerCycleCalib";
|
---|
| 763 | fos << PPFNameTag(tag) << sigmaRedMtx_perCycleCalib;
|
---|
| 764 |
|
---|
| 765 | tag = "onoffevol";
|
---|
| 766 | fos << PPFNameTag(tag) << onoffevolution;
|
---|
| 767 | }//end of save
|
---|
[560] | 768 | }
|
---|
| 769 | //-------------------------------------------------------
|
---|
| 770 | //Compute the mean of Diff ON-OFF Raw spectra and also the mean/sigma of rebinned spectra
|
---|
[544] | 771 | //Used like:
|
---|
| 772 | //
|
---|
[560] | 773 | void meanRawDiffOnOffCycles() throw(string) {
|
---|
[540] | 774 | list<string> listOfFiles;
|
---|
| 775 | string directoryName;
|
---|
| 776 | directoryName = para.inPath_ + "/" + para.sourceName_;
|
---|
| 777 |
|
---|
[542] | 778 | //Make the listing of the directory
|
---|
[541] | 779 | listOfFiles = ListOfFileInDir(directoryName,para.ppfFile_);
|
---|
[540] | 780 |
|
---|
[541] | 781 | list<string>::const_iterator iFile, iFileEnd, iSpec, iSpecEnd;
|
---|
[540] | 782 | iFileEnd = listOfFiles.end();
|
---|
| 783 |
|
---|
[542] | 784 | StringMatch match("specONOFFRaw[0-9]+"); //Tag of the PPF objects
|
---|
[544] | 785 | TMatrix<r_4> meanOfSpectra(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
[542] | 786 | uint_4 nSpectra=0;
|
---|
| 787 | //Loop on files
|
---|
[540] | 788 | for (iFile = listOfFiles.begin(); iFile != iFileEnd; ++iFile) {
|
---|
[542] | 789 | if (para.debuglev_>90){
|
---|
| 790 | cout << "load file <" << *iFile << ">" << endl;
|
---|
| 791 | }
|
---|
[540] | 792 | PInPersist fin(*iFile);
|
---|
| 793 | vector<string> vec = fin.GetNameTags();
|
---|
[541] | 794 | list<string> listOfSpectra;
|
---|
[542] | 795 | //Keep only required PPF objects
|
---|
[540] | 796 | std::remove_copy_if(
|
---|
| 797 | vec.begin(), vec.end(), back_inserter(listOfSpectra),
|
---|
| 798 | not1(match)
|
---|
| 799 | );
|
---|
| 800 |
|
---|
[560] | 801 | listOfSpectra.sort(stringCompare);
|
---|
[541] | 802 | iSpecEnd = listOfSpectra.end();
|
---|
[542] | 803 | //Loop of spectra matrix
|
---|
[541] | 804 | for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd; ++iSpec){
|
---|
[542] | 805 | if (para.debuglev_>90){
|
---|
| 806 | cout << " spactra <" << *iSpec << ">" << endl;
|
---|
| 807 | }
|
---|
| 808 | TMatrix<r_4> aSpec(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
| 809 | fin.GetObject(aSpec,*iSpec);
|
---|
| 810 | //How to see if the GetObject is ok?? Ask Reza
|
---|
| 811 | nSpectra++;
|
---|
[544] | 812 | meanOfSpectra+=aSpec;
|
---|
[542] | 813 | }//eo loop on spectra in a file
|
---|
| 814 | }//eo loop on files
|
---|
| 815 |
|
---|
| 816 | //Normalisation
|
---|
[544] | 817 | if(nSpectra>0)meanOfSpectra/=(r_4)(nSpectra);
|
---|
[541] | 818 |
|
---|
[544] | 819 | //Compute the reduced version of the mean and sigma
|
---|
| 820 | TMatrix<r_4> meanRedMtx(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 821 | TMatrix<r_4> sigmaRedMtx(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 822 | reduceSpectra(meanOfSpectra,meanRedMtx,sigmaRedMtx);
|
---|
| 823 |
|
---|
[542] | 824 | {//Save the result
|
---|
| 825 | stringstream tmp;
|
---|
| 826 | tmp << nSpectra;
|
---|
| 827 | string fileName = para.outPath_+"/meanDiffOnOffRaw_"+StringToLower(para.sourceName_)+"-"+tmp.str()+"Cycles.ppf";
|
---|
| 828 | cout << "Save mean based on " << nSpectra << " cycles " << endl;
|
---|
[544] | 829 | POutPersist fos(fileName);
|
---|
| 830 |
|
---|
[542] | 831 | string tag = "mean";
|
---|
[544] | 832 | fos << PPFNameTag(tag) << meanOfSpectra;
|
---|
| 833 | tag = "meanred";
|
---|
| 834 | fos << PPFNameTag(tag) << meanRedMtx;
|
---|
| 835 | tag = "sigmared";
|
---|
| 836 | fos << PPFNameTag(tag) << sigmaRedMtx;
|
---|
| 837 | }
|
---|
| 838 | }
|
---|
| 839 | //-------------------------------------------------------
|
---|
[560] | 840 | //Compute the median of Diff ON-OFF Raw spectra and also the mean/sigma of rebinned spectra
|
---|
[544] | 841 | //Used like:
|
---|
| 842 | //
|
---|
[560] | 843 | void medianRawDiffOnOffCycles() throw(string) {
|
---|
[544] | 844 | list<string> listOfFiles;
|
---|
| 845 | string directoryName;
|
---|
| 846 | directoryName = para.inPath_ + "/" + para.sourceName_;
|
---|
| 847 |
|
---|
| 848 | //Make the listing of the directory
|
---|
| 849 | listOfFiles = ListOfFileInDir(directoryName,para.ppfFile_);
|
---|
| 850 |
|
---|
| 851 | list<string>::const_iterator iFile, iFileEnd, iSpec, iSpecEnd;
|
---|
| 852 | iFileEnd = listOfFiles.end();
|
---|
| 853 |
|
---|
| 854 |
|
---|
[562] | 855 | TArray<r_4> tableOfSpectra(NUMBER_OF_FREQ,NUMBER_OF_CHANNELS,para.maxNumberCycles_); //para.maxNumberCycles_ should be large enough...
|
---|
[544] | 856 |
|
---|
| 857 | StringMatch match("specONOFFRaw[0-9]+"); //Tag of the PPF objects
|
---|
| 858 | uint_4 nSpectra=0;
|
---|
| 859 | //Loop on files
|
---|
| 860 | for (iFile = listOfFiles.begin(); iFile != iFileEnd; ++iFile) {
|
---|
| 861 | if (para.debuglev_>90){
|
---|
| 862 | cout << "load file <" << *iFile << ">" << endl;
|
---|
| 863 | }
|
---|
| 864 | PInPersist fin(*iFile);
|
---|
| 865 | vector<string> vec = fin.GetNameTags();
|
---|
| 866 | list<string> listOfSpectra;
|
---|
| 867 | //Keep only required PPF objects
|
---|
| 868 | std::remove_copy_if(
|
---|
| 869 | vec.begin(), vec.end(), back_inserter(listOfSpectra),
|
---|
| 870 | not1(match)
|
---|
| 871 | );
|
---|
| 872 |
|
---|
[560] | 873 | listOfSpectra.sort(stringCompare);
|
---|
[544] | 874 | iSpecEnd = listOfSpectra.end();
|
---|
| 875 | //Loop of spectra matrix
|
---|
[562] | 876 | for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd && (sa_size_t)nSpectra < para.maxNumberCycles_ ; ++iSpec){
|
---|
[544] | 877 | if (para.debuglev_>90){
|
---|
| 878 | cout << " spactra <" << *iSpec << ">" << endl;
|
---|
| 879 | }
|
---|
| 880 | TMatrix<r_4> aSpec(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
| 881 | fin.GetObject(aSpec,*iSpec);
|
---|
| 882 |
|
---|
[553] | 883 | tableOfSpectra(Range::all(),Range::all(),Range(nSpectra)) = aSpec;
|
---|
| 884 |
|
---|
[544] | 885 | nSpectra++;
|
---|
| 886 | }//eo loop on spectra in a file
|
---|
| 887 | }//eo loop on files
|
---|
| 888 |
|
---|
| 889 |
|
---|
| 890 |
|
---|
| 891 | TMatrix<r_4> medianOfSpectra(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
|
---|
| 892 | //Compute the median for each freq. and Channel
|
---|
| 893 | for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; iCh++){
|
---|
| 894 | for (sa_size_t freq =0; freq<NUMBER_OF_FREQ; freq++){
|
---|
[552] | 895 | TVector<r_4> tmp0(tableOfSpectra(Range(freq),Range(iCh),Range(0,nSpectra-1)).CompactAllDimensions());
|
---|
[544] | 896 | vector<r_4> tmp;
|
---|
| 897 | tmp0.FillTo(tmp);
|
---|
[552] | 898 | medianOfSpectra(iCh,freq) = median(tmp.begin(),tmp.end());
|
---|
[544] | 899 | }
|
---|
| 900 | }
|
---|
| 901 |
|
---|
| 902 |
|
---|
| 903 | //Compute the reduced version of the mean and sigma
|
---|
| 904 | TMatrix<r_4> meanRedMtx(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 905 | TMatrix<r_4> sigmaRedMtx(NUMBER_OF_CHANNELS,para.nSliceInFreq_);
|
---|
| 906 | reduceSpectra(medianOfSpectra,meanRedMtx,sigmaRedMtx);
|
---|
| 907 |
|
---|
[553] | 908 |
|
---|
[562] | 909 | sa_size_t f1320=freqToChan(1320.);
|
---|
| 910 | sa_size_t f1345=freqToChan(1345.);
|
---|
| 911 | sa_size_t f1355=freqToChan(1355.);
|
---|
| 912 | sa_size_t f1380=freqToChan(1380.);
|
---|
[553] | 913 | //Compute baseline arround 1350Mhz on [1320-1345] U [1355-1380]
|
---|
| 914 | if (para.debuglev_>9){
|
---|
| 915 | cout << "Compute baseline arround 1350Mhz on [1320-1345] U [1355-1380]" << endl;
|
---|
| 916 | }
|
---|
| 917 | TVector<r_4>meanMed(NUMBER_OF_CHANNELS);
|
---|
| 918 | for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
|
---|
| 919 | double meanMed1;
|
---|
| 920 | double sigmaMed1;
|
---|
| 921 | TVector<r_4> band1;
|
---|
| 922 | band1 = medianOfSpectra(Range(iCh),Range(f1320,f1345)).CompactAllDimensions();
|
---|
| 923 | MeanSigma(band1,meanMed1,sigmaMed1);
|
---|
| 924 | double meanMed2;
|
---|
| 925 | double sigmaMed2;
|
---|
| 926 | TVector<r_4> band2;
|
---|
| 927 | band2 = medianOfSpectra(Range(iCh),Range(f1355,f1380)).CompactAllDimensions();
|
---|
| 928 | MeanSigma(band2,meanMed2,sigmaMed2);
|
---|
| 929 | meanMed(iCh) = (meanMed1+meanMed2)*0.5;
|
---|
| 930 | }
|
---|
| 931 | meanMed.Print(cout);
|
---|
[562] | 932 | cout << endl;
|
---|
| 933 |
|
---|
[553] | 934 |
|
---|
| 935 | //Compute the sigma in the range 1320MHz-1380MHz
|
---|
| 936 | if (para.debuglev_>9){
|
---|
| 937 | cout << "Compute the sigma in the range 1320MHz-1380MHz" << endl;
|
---|
| 938 | }
|
---|
| 939 | TVector<r_4>sigmaMed(NUMBER_OF_CHANNELS);
|
---|
[560] | 940 | sa_size_t redf1320=(sa_size_t)((1320.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_);
|
---|
| 941 | sa_size_t redf1380=(sa_size_t)((1380.0-LOWER_FREQUENCY)/TOTAL_BANDWIDTH*para.nSliceInFreq_);
|
---|
[553] | 942 |
|
---|
| 943 | for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
|
---|
| 944 | double meanSigma;
|
---|
| 945 | double sigmaSigma;
|
---|
| 946 | TVector<r_4> band;
|
---|
| 947 | band = sigmaRedMtx(Range(iCh),Range(redf1320,redf1380)).CompactAllDimensions();
|
---|
| 948 | MeanSigma(band,meanSigma,sigmaSigma);
|
---|
| 949 | meanSigma *= sqrt(para.nSliceInFreq_); //to scale to orignal spectra
|
---|
| 950 | sigmaMed(iCh) = meanSigma;
|
---|
| 951 | }
|
---|
| 952 | sigmaMed.Print(cout);
|
---|
[562] | 953 | cout << endl;
|
---|
| 954 |
|
---|
[553] | 955 |
|
---|
| 956 |
|
---|
| 957 | if (para.debuglev_>9){
|
---|
| 958 | cout << "Compute medianOfSpectraNorm" << endl;
|
---|
| 959 | }
|
---|
| 960 | TMatrix<r_4> medianOfSpectraNorm(medianOfSpectra,false); //do not share the data...
|
---|
| 961 | for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
|
---|
| 962 | medianOfSpectraNorm.Row(iCh) -= meanMed(iCh);
|
---|
| 963 | medianOfSpectraNorm.Row(iCh) /= sigmaMed(iCh);
|
---|
| 964 | }
|
---|
| 965 |
|
---|
| 966 |
|
---|
| 967 |
|
---|
[544] | 968 | {//Save the result
|
---|
| 969 | stringstream tmp;
|
---|
| 970 | tmp << nSpectra;
|
---|
| 971 | string fileName = para.outPath_+"/medianDiffOnOffRaw_"+StringToLower(para.sourceName_)+"-"+tmp.str()+"Cycles.ppf";
|
---|
[552] | 972 | cout << "Save median based on " << nSpectra << " cycles " << endl;
|
---|
[542] | 973 | POutPersist fos(fileName);
|
---|
[544] | 974 |
|
---|
| 975 | string tag = "median";
|
---|
| 976 | fos << PPFNameTag(tag) << medianOfSpectra;
|
---|
[553] | 977 |
|
---|
| 978 | tag = "medianNorm";
|
---|
| 979 | fos << PPFNameTag(tag) << medianOfSpectraNorm;
|
---|
| 980 |
|
---|
| 981 |
|
---|
[544] | 982 | tag = "meanmedred";
|
---|
| 983 | fos << PPFNameTag(tag) << meanRedMtx;
|
---|
| 984 | tag = "sigmamedred";
|
---|
| 985 | fos << PPFNameTag(tag) << sigmaRedMtx;
|
---|
[552] | 986 | tag = "cycleVsfreq";
|
---|
| 987 |
|
---|
| 988 | TArray<r_4> tarr(tableOfSpectra(Range::all(),Range::all(),Range(0,nSpectra-1)));
|
---|
| 989 | fos << PPFNameTag(tag) << tarr;
|
---|
[540] | 990 | }
|
---|
| 991 | }
|
---|
[544] | 992 |
|
---|
[540] | 993 | //-------------------------------------------------------
|
---|
[544] | 994 | int main(int narg, char* arg[]) {
|
---|
[540] | 995 |
|
---|
| 996 | int rc = 0; //return code
|
---|
| 997 | string msg; //message used in Exceptions
|
---|
| 998 |
|
---|
| 999 |
|
---|
[544] | 1000 |
|
---|
| 1001 | //default value for initial parameters (see Para structure on top of the file)
|
---|
[540] | 1002 | string debuglev = "0";
|
---|
[544] | 1003 | string action = "meanDiffOnOff";
|
---|
[540] | 1004 | string inputPath = ".";
|
---|
| 1005 | string outputPath = ".";
|
---|
| 1006 | string sourceName = "Abell85";
|
---|
[541] | 1007 | string ppfFile;
|
---|
[544] | 1008 | string nSliceInFreq = "32";
|
---|
[560] | 1009 | string typeOfCalib="perRun";
|
---|
[561] | 1010 | string calibFreq = "1346";
|
---|
[562] | 1011 | string calibBandFreq="6.25";
|
---|
| 1012 | string mxcycles;
|
---|
| 1013 |
|
---|
[540] | 1014 | // bool okarg=false;
|
---|
| 1015 | int ka=1;
|
---|
[554] | 1016 | while (ka<narg) {
|
---|
[551] | 1017 | if (strcmp(arg[ka],"-h")==0) {
|
---|
[560] | 1018 | cout << "Usage: -act [meanRawDiffOnOff]|medianRawDiffOnOff|meanCalibBAODiffOnOff\n"
|
---|
[562] | 1019 | << " -mxcycles <number> (max. number of cycles to be treated)\n"
|
---|
[561] | 1020 | << " -calibfreq <number> (cf. freq. used by calibration operation)\n"
|
---|
[562] | 1021 | << " -calibbandfreq <number> (cf. band of freq. used by calibration operation)\n"
|
---|
[577] | 1022 | << " -src [Abell85]\n"
|
---|
| 1023 | << " -inPath [.]|<top_root_dir of the ppf file>\n"
|
---|
[551] | 1024 | << " (ex. /sps/baoradio/AmasNancay/JEC/\n "
|
---|
| 1025 | << " -outPath [.]|<dir of the output> \n"
|
---|
| 1026 | << " -nSliceInFreq [32]|<number of bin in freq. to cumulate>\n"
|
---|
[561] | 1027 | << " -ppfFile <generic name of the input ppf files> (ex. diffOnOffRaw)\n"
|
---|
[551] | 1028 | << " -debug <level> "
|
---|
| 1029 | << endl;
|
---|
| 1030 | return 0;
|
---|
| 1031 | }
|
---|
| 1032 | else if (strcmp(arg[ka],"-debug")==0) {
|
---|
[540] | 1033 | debuglev=arg[ka+1];
|
---|
| 1034 | ka+=2;
|
---|
| 1035 | }
|
---|
| 1036 | else if (strcmp(arg[ka],"-act")==0) {
|
---|
| 1037 | action=arg[ka+1];
|
---|
| 1038 | ka+=2;
|
---|
| 1039 | }
|
---|
[561] | 1040 | else if (strcmp(arg[ka],"-calibfreq")==0) {
|
---|
| 1041 | calibFreq=arg[ka+1];
|
---|
| 1042 | ka+=2;
|
---|
| 1043 | }
|
---|
[562] | 1044 | else if (strcmp(arg[ka],"-calibbandfreq")==0) {
|
---|
| 1045 | calibBandFreq=arg[ka+1];
|
---|
| 1046 | ka+=2;
|
---|
| 1047 | }
|
---|
| 1048 | else if (strcmp(arg[ka],"-mxcycles")==0) {
|
---|
| 1049 | mxcycles=arg[ka+1];
|
---|
| 1050 | ka+=2;
|
---|
| 1051 | }
|
---|
[540] | 1052 | else if (strcmp(arg[ka],"-inPath")==0) {
|
---|
| 1053 | inputPath=arg[ka+1];
|
---|
| 1054 | ka+=2;
|
---|
| 1055 | }
|
---|
| 1056 | else if (strcmp(arg[ka],"-outPath")==0) {
|
---|
| 1057 | outputPath=arg[ka+1];
|
---|
| 1058 | ka+=2;
|
---|
| 1059 | }
|
---|
[541] | 1060 | else if (strcmp(arg[ka],"-src")==0) {
|
---|
[540] | 1061 | sourceName=arg[ka+1];
|
---|
| 1062 | ka+=2;
|
---|
| 1063 | }
|
---|
[541] | 1064 | else if (strcmp(arg[ka],"-ppfFile")==0) {
|
---|
| 1065 | ppfFile=arg[ka+1];
|
---|
[540] | 1066 | ka+=2;
|
---|
| 1067 | }
|
---|
[544] | 1068 | else if (strcmp(arg[ka],"-nSliceInFreq")==0) {
|
---|
| 1069 | nSliceInFreq=arg[ka+1];
|
---|
| 1070 | ka+=2;
|
---|
| 1071 | }
|
---|
[540] | 1072 | else ka++;
|
---|
| 1073 | }//eo while
|
---|
| 1074 |
|
---|
[544] | 1075 | para.debuglev_ = atoi(debuglev.c_str());
|
---|
| 1076 | para.inPath_ = inputPath;
|
---|
| 1077 | para.outPath_ = outputPath;
|
---|
[540] | 1078 | para.sourceName_ = sourceName;
|
---|
[544] | 1079 | para.ppfFile_ = ppfFile;
|
---|
| 1080 | para.nSliceInFreq_ = atoi(nSliceInFreq.c_str());
|
---|
[561] | 1081 | para.calibFreq_ = calibFreq;
|
---|
[562] | 1082 | para.calibBandFreq_ = calibBandFreq;
|
---|
| 1083 | para.rcalibFreq_ = atof(calibFreq.c_str());
|
---|
| 1084 | para.rcalibBandFreq_ = atof(calibBandFreq.c_str());
|
---|
| 1085 | if (mxcycles != "") {
|
---|
| 1086 | para.maxNumberCycles_ = atoi(mxcycles.c_str());
|
---|
| 1087 | } else {
|
---|
| 1088 | para.maxNumberCycles_ = std::numeric_limits<int>::max();
|
---|
| 1089 | }
|
---|
[540] | 1090 |
|
---|
| 1091 | cout << "Dump Initial parameters ............" << endl;
|
---|
| 1092 | cout << " action = " << action << "\n"
|
---|
[562] | 1093 | << " maxNumberCycles = " << para.maxNumberCycles_ << "\n"
|
---|
[544] | 1094 | << " inputPath = " << para.inPath_ << "\n"
|
---|
| 1095 | << " outputPath = " << para.outPath_ << "\n"
|
---|
| 1096 | << " sourceName = " << para.sourceName_ << "\n"
|
---|
| 1097 | << " ppfFile = " << para.ppfFile_ << "\n"
|
---|
| 1098 | << " nSliceInFreq = " << para.nSliceInFreq_ << "\n"
|
---|
[561] | 1099 | << " calibFreq = " << para.calibFreq_ << "\n"
|
---|
[562] | 1100 | << " calibBandFreq = " << para.calibBandFreq_ << "\n"
|
---|
[544] | 1101 | << " debuglev = " << para.debuglev_ << "\n";
|
---|
[540] | 1102 | cout << "...................................." << endl;
|
---|
| 1103 |
|
---|
[541] | 1104 | if ( "" == ppfFile ) {
|
---|
[560] | 1105 | cerr << "mergeAnaFiles.cc: you have forgotten ppfFile option"
|
---|
[541] | 1106 | << endl;
|
---|
| 1107 | return 999;
|
---|
| 1108 | }
|
---|
| 1109 |
|
---|
| 1110 |
|
---|
[540] | 1111 | try {
|
---|
| 1112 |
|
---|
[542] | 1113 | // int b,e;
|
---|
| 1114 | // char *match=regexp("truc0machin","[a-z]+[0-9]*",&b,&e);
|
---|
| 1115 | // printf("->%s<-\n(b=%d e=%d)\n",match,b,e);
|
---|
[540] | 1116 |
|
---|
[560] | 1117 | if ( action == "meanRawDiffOnOff" ) {
|
---|
| 1118 | meanRawDiffOnOffCycles();
|
---|
| 1119 | } else if (action == "medianRawDiffOnOff") {
|
---|
| 1120 | medianRawDiffOnOffCycles();
|
---|
| 1121 | } else if (action == "meanCalibBAODiffOnOff") {
|
---|
| 1122 | meanCalibBAODiffOnOffCycles();
|
---|
[544] | 1123 | } else {
|
---|
| 1124 | msg = "Unknown action " + action;
|
---|
| 1125 | throw msg;
|
---|
[540] | 1126 | }
|
---|
| 1127 |
|
---|
[544] | 1128 |
|
---|
[540] | 1129 | } catch (std::exception& sex) {
|
---|
| 1130 | cerr << "mergeRawOnOff.cc std::exception :" << (string)typeid(sex).name()
|
---|
| 1131 | << "\n msg= " << sex.what() << endl;
|
---|
| 1132 | rc = 78;
|
---|
| 1133 | }
|
---|
| 1134 | catch ( string str ) {
|
---|
| 1135 | cerr << "mergeRawOnOff.cc Exception raised: " << str << endl;
|
---|
| 1136 | }
|
---|
| 1137 | catch (...) {
|
---|
| 1138 | cerr << "mergeRawOnOff.cc catched unknown (...) exception " << endl;
|
---|
| 1139 | rc = 79;
|
---|
| 1140 | }
|
---|
| 1141 |
|
---|
| 1142 | return 0;
|
---|
| 1143 |
|
---|
| 1144 | }
|
---|