- Timestamp:
- Oct 7, 2011, 3:25:15 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BAORadio/AmasNancay/trunk/mergeAnaFiles.cc
r558 r560 41 41 const sa_size_t NUMBER_OF_FREQ = 8192; 42 42 const sa_size_t TOTAL_NUM_CYCLES = 500; 43 const r_4 LOWER_FREQUENCY = 1250.0; //MHz44 const r_4 TOTAL_BANDWIDTH = 250.0;//MHz43 const r_4 LOWER_FREQUENCY = 1250.0; //MHz 44 const r_4 TOTAL_BANDWIDTH = 250.0; //MHz 45 45 //----------------------------------------------- 46 46 //Input parameters … … 52 52 string ppfFile_; //generic name of the input files 53 53 int nSliceInFreq_; //used by reduceSpectra() fnc 54 string typeOfCalib_;//type of calibration to be done 54 55 } para; 55 56 //-------------------------------------------------------------- … … 207 208 } 208 209 //------------------------------------------------------- 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 // 213 void 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 210 312 //Used like: 211 313 // 212 void mean OnCycles() throw(string) {314 void meanRawDiffOnOffCycles() throw(string) { 213 315 list<string> listOfFiles; 214 316 string directoryName; … … 238 340 ); 239 341 342 listOfSpectra.sort(stringCompare); 240 343 iSpecEnd = listOfSpectra.end(); 241 listOfSpectra.sort(stringCompare);242 344 //Loop of spectra matrix 243 345 for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd; ++iSpec){ … … 277 379 } 278 380 //------------------------------------------------------- 279 //Compute the median of Raw spectra and also the mean/sigma of rebinned spectra381 //Compute the median of Diff ON-OFF Raw spectra and also the mean/sigma of rebinned spectra 280 382 //Used like: 281 383 // 282 void median OnCycles() throw(string) {384 void medianRawDiffOnOffCycles() throw(string) { 283 385 list<string> listOfFiles; 284 386 string directoryName; … … 310 412 ); 311 413 414 listOfSpectra.sort(stringCompare); 312 415 iSpecEnd = listOfSpectra.end(); 313 listOfSpectra.sort(stringCompare);314 416 //Loop of spectra matrix 315 417 for (iSpec = listOfSpectra.begin(); iSpec !=iSpecEnd && (sa_size_t)nSpectra < TOTAL_NUM_CYCLES ; ++iSpec){ … … 375 477 } 376 478 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_); 379 481 380 482 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){ … … 442 544 string ppfFile; 443 545 string nSliceInFreq = "32"; 444 546 string typeOfCalib="perRun"; 445 547 446 548 // bool okarg=false; … … 448 550 while (ka<narg) { 449 551 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)" 451 554 << " -src [Abell85]\n -inPath [.]|<top_root_dir of the ppf file>\n" 452 555 << " (ex. /sps/baoradio/AmasNancay/JEC/\n " … … 466 569 ka+=2; 467 570 } 571 else if (strcmp(arg[ka],"-calibopt")==0) { 572 typeOfCalib=arg[ka+1]; 573 ka+=2; 574 } 468 575 else if (strcmp(arg[ka],"-inPath")==0) { 469 576 inputPath=arg[ka+1]; … … 507 614 508 615 if ( "" == ppfFile ) { 509 cerr << "merge RawOnOff.cc: you have forgotten ppfFile option"616 cerr << "mergeAnaFiles.cc: you have forgotten ppfFile option" 510 617 << endl; 511 618 return 999; … … 519 626 // printf("->%s<-\n(b=%d e=%d)\n",match,b,e); 520 627 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(); 525 634 } else { 526 635 msg = "Unknown action " + action;
Note: See TracChangeset
for help on using the changeset viewer.