source: BAORadio/AmasNancay/v2/analyse.cc@ 579

Last change on this file since 579 was 527, checked in by campagne, 14 years ago

1) do always the Raw spectra, 2) raw ON - OFF for the mean on cycles/channel too (jec)

File size: 55.9 KB
Line 
1//
2// Analyse of Amas@Nancay runs by J.E Campagne (LAL)
3// Version 0: 1/6/2011
4//-----------------------------
5
6// Utilisation de SOPHYA pour faciliter les tests ...
7#include "sopnamsp.h"
8#include "machdefs.h"
9
10#include <stdlib.h>
11#include <dirent.h>
12#include <matharr.h>
13
14// include standard c/c++
15#include <iostream>
16#include <fstream>
17#include <string>
18#include <vector>
19#include <map>
20#include <functional>
21#include <algorithm>
22#include <numeric>
23#include <list>
24#include <exception>
25
26// include sophya mesure ressource CPU/memoire ...
27#include "resusage.h"
28#include "ctimer.h"
29#include "timing.h"
30#include "timestamp.h"
31#include "strutilxx.h"
32#include "ntuple.h"
33#include "fioarr.h"
34#include "tarrinit.h"
35#include "histinit.h"
36#include "fitsioserver.h"
37#include "fiosinit.h"
38#include "ppersist.h"
39
40
41const sa_size_t NUMBER_OF_CHANNELS = 2;
42const sa_size_t NUMBER_OF_FREQ = 8192;
43const r_4 LOWER_FREQUENCY = 1250.0; //MHz
44const r_4 TOTAL_BANDWIDTH = 250.0; //MHz
45
46//decalration of non class members functions
47extern "C" {
48 int Usage(bool);
49}
50
51
52//----------------------------------------------------------
53//Utility fonctions
54// Function for deleting pointers in map.
55template<class A, class B>
56struct DeleteMapFntor
57{
58 // Overloaded () operator.
59 // This will be called by for_each() function.
60 bool operator()(pair<A,B> x) const
61 {
62 // Assuming the second item of map is to be
63 // deleted. Change as you wish.
64 delete x.second;
65 return true;
66 }
67};
68//-----
69bool compare(const pair<string,r_4>& i, const pair<string,r_4>& j) {
70 return i.second < j.second;
71}
72//-----
73sa_size_t round_sa(r_4 r) {
74 return static_cast<sa_size_t>((r > 0.0) ? (r + 0.5) : (r - 0.5));
75}
76//-----
77string StringToLower(string strToConvert){
78 //change each element of the string to lower case
79 for(unsigned int i=0;i<strToConvert.length();i++) {
80 strToConvert[i] = tolower(strToConvert[i]);
81 }
82 return strToConvert;//return the converted string
83}
84//-----
85//JEC 22/9/11 comparison, not case sensitive to sort File liste START
86bool stringCompare( const string &left, const string &right ){
87 if( left.size() < right.size() )
88 return true;
89 return false;
90 for( string::const_iterator lit = left.begin(), rit = right.begin(); lit != left.end() && rit != right.end(); ++lit, ++rit )
91 if( tolower( *lit ) < tolower( *rit ) )
92 return true;
93 else if( tolower( *lit ) > tolower( *rit ) )
94 return false;
95}//JEC 22/9/11 comparison, not case sensitive to sort File liste END
96//-----
97list<string> ListOfFileInDir(string dir, string filePettern) throw(string) {
98 list<string> theList;
99
100
101 DIR *dip;
102 struct dirent *dit;
103 string msg; string fileName;
104 string fullFileName;
105 size_t found;
106
107 if ((dip=opendir(dir.c_str())) == NULL ) {
108 msg = "opendir failed on directory "+dir;
109 throw msg;
110 }
111 while ( (dit = readdir(dip)) != NULL ) {
112 fileName = dit->d_name;
113 found=fileName.find(filePettern);
114 if (found != string::npos) {
115 fullFileName = dir + "/";
116 fullFileName += fileName;
117 theList.push_back(fullFileName);
118 }
119 }//eo while
120 if (closedir(dip) == -1) {
121 msg = "closedir failed on directory "+dir;
122 throw msg;
123 }
124
125 //JEC 22/9/11 START
126 theList.sort(stringCompare);
127 //JEC 22/9/11 END
128
129 return theList;
130}
131
132
133//Declaration of local classes
134//----------------------------------------------
135//Process Interface
136class IProcess {
137public:
138 IProcess() {}
139 virtual ~IProcess() {}
140 virtual int processCmd() throw(string) =0;
141};
142//------------
143//Common Process
144class ProcessBase : public IProcess {
145public:
146 ProcessBase();
147 virtual ~ProcessBase();
148 void SetInputPath(const string& inputPath) {inputPath_ = inputPath;}
149 void SetOutputPath(const string& outputPath) {outputPath_ = outputPath;}
150 void SetSourceName(const string& sourceName) {sourceName_ = sourceName;}
151 void SetDateOfRun(const string& dateOfRun) {dateOfRun_ = dateOfRun;}
152 void SetSpectraDirectory(const string& spectraDirectory) {spectraDirectory_ = spectraDirectory;}
153 void SetTypeOfFile(const string& typeOfFile) { typeOfFile_ = typeOfFile; }
154 void SetNumCycle(const string& numcycle) {numcycle_ = numcycle; }
155 void SetScaFileName(const string& scaFileName) { scaFileName_ =scaFileName; }
156
157 void SetDebugLevel(const string& debuglev) {
158 debuglev_ = atoi(debuglev.c_str());
159 }
160
161 virtual int processCmd() throw(string);
162
163protected:
164 string inputPath_;
165 string outputPath_;
166 string sourceName_;
167 string dateOfRun_;
168 string spectraDirectory_;
169 string typeOfFile_;
170
171 string numcycle_; //cycle numbers format="first,last"
172 sa_size_t ifirstCycle_;
173 sa_size_t ilastCycle_;
174
175
176 uint_4 debuglev_;
177 string scaFileName_;
178 NTuple* scaTuple_;
179 map<sa_size_t,sa_size_t> idCycleInTuple_;
180};
181ProcessBase::ProcessBase() {
182 scaTuple_ = 0;
183}
184ProcessBase::~ProcessBase() {
185 if (scaTuple_) delete scaTuple_;
186 scaTuple_ = 0;
187}
188//------------
189//Process ON/OFF data
190//------------
191class ProcessONOFFData : public ProcessBase {
192protected:
193 string freqBAOCalibration_;//string MHz
194public:
195 ProcessONOFFData(){}
196 virtual ~ProcessONOFFData(){}
197
198 void SetFreqBAOCalibration(const string& freqBAOCalibration) {
199 freqBAOCalibration_ = freqBAOCalibration;
200 }
201
202 virtual int processCmd() throw(string);
203};
204
205//JEC 22/9/11 Make ON-OFF analysis WO any calibration START
206//------------
207//Process ON/OFF Raw data
208//------------
209class ProcessONOFFRawData : public ProcessBase {
210
211public:
212 ProcessONOFFRawData(){}
213 virtual ~ProcessONOFFRawData(){}
214
215 virtual int processCmd() throw(string);
216};
217//JEC 22/9/11 Make ON-OFF analysis WO any calibration END
218
219//------------
220//Process Gain
221//------------
222class ProcessGain : public ProcessBase {
223protected:
224 string mode_; //mode of data taken for gain computation On || Off
225public:
226 ProcessGain(){}
227 virtual ~ProcessGain(){}
228
229 void SetMode(const string& mode) {mode_ = mode;}
230
231 virtual int processCmd() throw(string);
232};
233//------------
234//Process Calibration
235//------------
236class ProcessCalibration : public ProcessBase {
237protected:
238 string option_; //option of calibration procedure
239 string freqBAOCalibration_;//string MHz
240 r_4 valfreqBAOCalibration_; //value MHz
241 string bandWidthBAOCalibration_;//string MHz
242 r_4 valbandWidthBAOCalibration_;//value MHz
243
244 sa_size_t lowerFreqBin_;
245 sa_size_t upperFreqBin_;
246
247public:
248 ProcessCalibration() {}
249 virtual ~ProcessCalibration(){}
250
251 void SetOption(const string& option) {option_ = option;}
252 void SetFreqBAOCalibration(const string& freqBAOCalibration) {
253 freqBAOCalibration_ = freqBAOCalibration;
254 valfreqBAOCalibration_ = atof(freqBAOCalibration_.c_str());
255 }
256 void SetBandWidthBAOCalibration(const string& bandWidthBAOCalibration) {
257 bandWidthBAOCalibration_ = bandWidthBAOCalibration;
258 valbandWidthBAOCalibration_ = atof(bandWidthBAOCalibration_.c_str());
259 }
260
261 void ComputeLowerUpperFreqBin();
262
263 virtual int processCmd() throw(string);
264};
265void ProcessCalibration::ComputeLowerUpperFreqBin() {
266 sa_size_t c0 = round_sa(NUMBER_OF_FREQ*(valfreqBAOCalibration_-LOWER_FREQUENCY)/TOTAL_BANDWIDTH);
267 sa_size_t dc = round_sa(NUMBER_OF_FREQ*valbandWidthBAOCalibration_/TOTAL_BANDWIDTH);
268 lowerFreqBin_ = c0-dc/2;
269 upperFreqBin_ = c0+dc/2;
270}
271
272
273//----------------------------------------------------
274//----------------------------------------------------
275int main(int narg, char* arg[])
276{
277
278 //Init process types
279 map<string,IProcess*> process;
280 //JEC 22/9/11 Make ON-OFF analysis WO any calibration START
281 process["rawOnOff"] = new ProcessONOFFRawData();
282 //JEC 22/9/11 Make ON-OFF analysis WO any calibration END
283 process["dataOnOff"] = new ProcessONOFFData();
284 process["gain"] = new ProcessGain();
285 process["calib"] = new ProcessCalibration();
286
287 //Init Sophya related modules
288 // SophyaInit();
289 TArrayInitiator _inia; //nneded for TArray persistancy
290 FitsIOServerInit(); //needed for input file
291
292 //message used in Exceptions
293 string msg;
294
295 //Return code
296 int rc = 0;
297
298 //Arguments managements
299 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
300 if (narg<11) return Usage(true);
301
302 string action;
303 string inputPath = ".";
304 string outputPath = ".";
305 string sourceName;
306 string scaFile;
307 string dateOfRun;
308 string spectraDirectory;
309 string freqBAOCalib = "";
310 string bandWidthBAOCalib = "";
311 string debuglev = "0";
312 string mode = "";
313 string numcycle;
314 string calibrationOpt = "";
315
316 string typeOfFile="medfiltmtx";
317
318
319 // bool okarg=false;
320 int ka=1;
321 while (ka<(narg-1)) {
322 if (strcmp(arg[ka],"-debug")==0) {
323 debuglev=arg[ka+1];
324 ka+=2;
325 }
326 else if (strcmp(arg[ka],"-act")==0) {
327 action=arg[ka+1];
328 ka+=2;
329 }
330 else if (strcmp(arg[ka],"-inPath")==0) {
331 inputPath=arg[ka+1];
332 ka+=2;
333 }
334 else if (strcmp(arg[ka],"-outPath")==0) {
335 outputPath=arg[ka+1];
336 ka+=2;
337 }
338 else if (strcmp(arg[ka],"-source")==0) {
339 sourceName=arg[ka+1];
340 ka+=2;
341 }
342 else if (strcmp(arg[ka],"-sca")==0) {
343 scaFile=arg[ka+1];
344 ka+=2;
345 }
346 else if (strcmp(arg[ka],"-date")==0) {
347 dateOfRun=arg[ka+1];
348 ka+=2;
349 }
350 else if (strcmp(arg[ka],"-specdir")==0) {
351 spectraDirectory=arg[ka+1];
352 ka+=2;
353 }
354 else if (strcmp(arg[ka],"-specname")==0) {
355 typeOfFile=arg[ka+1];
356 ka+=2;
357 }
358 else if (strcmp(arg[ka],"-freqBAOCalib")==0) {
359 freqBAOCalib = arg[ka+1];
360 ka+=2;
361 }
362 else if (strcmp(arg[ka],"-bwBAOCalib")==0) {
363 bandWidthBAOCalib = arg[ka+1];
364 ka+=2;
365 }
366 else if (strcmp(arg[ka],"-mode")==0) {
367 mode =arg[ka+1];
368 ka+=2;
369 }
370 else if (strcmp(arg[ka],"-numcycle")==0) {
371 numcycle =arg[ka+1];
372 ka+=2;
373 }
374 else if (strcmp(arg[ka],"-calibopt")==0) {
375 calibrationOpt =arg[ka+1];
376 ka+=2;
377 }
378 else ka++;
379 }//eo while
380
381
382 //JEC 21/9/11 Give the input parameters START
383 cout << "Dump Iiitial parameters ............" << endl;
384 cout << " action = " << action << "\n"
385 << " inputPath = " << inputPath << "\n"
386 << " outputPath = " << outputPath << "\n"
387 << " sourceName = " << sourceName << "\n"
388 << " scaFile = " << scaFile << "\n"
389 << " dateOfRun = " << dateOfRun << "\n"
390 << " spectraDirectory = " << spectraDirectory << "\n"
391 << " freqBAOCalib = " << freqBAOCalib << "\n"
392 << " bandWidthBAOCalib = " << bandWidthBAOCalib << "\n"
393 << " debuglev = " << debuglev << "\n"
394 << " mode = " << mode << "\n"
395 << " numcycle = " << numcycle << "\n"
396 << " calibrationOpt = " << calibrationOpt << endl;
397 cout << "...................................." << endl;
398 //JEC 21/9/11 Give the input parameters END
399
400
401 try {
402 //verification of action
403 if(process.find(action) == process.end()) {
404 msg = "action ";
405 msg += action + " not valid... FATAL";
406 rc = 999;
407 throw msg;
408 }
409
410
411 //
412 //Process initialisation...
413 //
414 try {
415 ProcessBase* procbase = dynamic_cast<ProcessBase*>(process[action]);
416 if (procbase == 0) {
417 msg= "action ";
418 msg += action + "Not a <process base> type...FATAL";
419 rc = 999;
420 throw msg;
421 }
422 procbase->SetInputPath(inputPath);
423 procbase->SetOutputPath(outputPath);
424
425 if ("" == sourceName) {
426 msg = "(FATAL) missingsourceName for action " + action;
427 Usage(true);
428 throw msg;
429 }
430 procbase->SetSourceName(sourceName);
431
432 if ("" == dateOfRun) {
433 msg = "(FATAL) missing dateOfRun for action " + action;
434 Usage(true);
435 throw msg;
436 }
437 procbase->SetDateOfRun(dateOfRun);
438
439
440 if ("" == spectraDirectory) {
441 msg = "(FATAL) missing spectraDirectory for action " + action;
442 Usage(true);
443 throw msg;
444 }
445 procbase->SetSpectraDirectory(spectraDirectory);
446
447 if ("" == scaFile) {
448 msg = "(FATAL) missing scaFile for action " + action;
449 Usage(true);
450 throw msg;
451 }
452 procbase->SetScaFileName(scaFile);
453
454 if ("" == numcycle) {
455 msg = "(FATAL) missing cycle number for action " + action;
456 Usage(true);
457 throw msg;
458 }
459 procbase->SetNumCycle(numcycle);
460
461
462 procbase->SetTypeOfFile(typeOfFile);
463
464 procbase->SetDebugLevel(debuglev);
465 }
466 catch(exception& e){
467 throw e.what();
468 }
469
470 //JEC 22/9/11 Make ON-OFF analysis WO any calibration START
471// try {
472// ProcessONOFFRawData* procRawdata = dynamic_cast<ProcessONOFFRawData*>(process[action]);
473// }
474// catch(exception& e){
475// throw e.what();
476// }
477 //JEC 22/9/11 Make ON-OFF analysis WO any calibration END
478
479
480 try {
481 ProcessONOFFData* procdata = dynamic_cast<ProcessONOFFData*>(process[action]);
482 if (procdata) {
483 if (freqBAOCalib == "") {
484 msg = "(FATAL) missing calibration BAO frequency for action " + action;
485 Usage(true);
486 throw msg;
487 }
488 procdata->SetFreqBAOCalibration(freqBAOCalib);
489 }
490 }
491 catch(exception& e){
492 throw e.what();
493 }
494
495
496 try {
497 ProcessGain* procgain = dynamic_cast<ProcessGain*>(process[action]);
498 if(procgain) {
499 if (mode == "") {
500 msg = "(FATAL) missing mode-type for action " + action;
501 Usage(true);
502 throw msg;
503 }
504 procgain->SetMode(mode);
505 }
506 }
507 catch(exception& e){
508 throw e.what();
509 }
510
511 try {
512 ProcessCalibration* proccalib = dynamic_cast<ProcessCalibration*>(process[action]);
513 if(proccalib) {
514 if (calibrationOpt == "") {
515 msg = "(FATAL) missing calibration option";
516 Usage(true);
517 throw msg;
518 }
519 if (freqBAOCalib == "") {
520 msg = "(FATAL) missing calibration BAO frequency for action " + action;
521 Usage(true);
522 throw msg;
523 }
524 if (bandWidthBAOCalib == "") {
525 msg = "(FATAL) missing calibration BAO frequency band width for action " + action;
526 Usage(true);
527 throw msg;
528 }
529 proccalib->SetOption(calibrationOpt);
530 proccalib->SetFreqBAOCalibration(freqBAOCalib);
531 proccalib->SetBandWidthBAOCalibration(bandWidthBAOCalib);
532 proccalib->ComputeLowerUpperFreqBin();
533 }
534 }
535 catch(exception& e){
536 throw e.what();
537 }
538
539 //
540 //execute command
541 //
542 rc = process[action]->processCmd();
543
544 }
545 catch (std::exception& sex) {
546 cerr << "\n analyse.cc std::exception :" << (string)typeid(sex).name()
547 << "\n msg= " << sex.what() << endl;
548 rc = 78;
549 }
550 catch ( string str ) {
551 cerr << "analyse.cc Exception raised: " << str << endl;
552 }
553 catch (...) {
554 cerr << " analyse.cc catched unknown (...) exception " << endl;
555 rc = 79;
556 }
557
558
559
560
561 cout << ">>>> analyse.cc ------- END ----------- RC=" << rc << endl;
562
563 //Delete processes
564 for_each(process.begin(),process.end(), DeleteMapFntor<string,IProcess*>());
565
566 return rc;
567}
568
569//---------------------------------------------------
570int Usage(bool flag) {
571 cout << "Analyse.cc usage...." << endl;
572 cout << "analyse -act <action_type>: dataOnOff, rawOnOff, gain, calib\n"
573 << " -inPath <path for input files: default='.'>\n"
574 << " -outPath <path for output files: default='.'>\n"
575 << " -source <source name> \n"
576 << " -date <YYYYMMDD>\n"
577 << " -sca <file name scaXYZ.sum.trans>\n"
578 << " -specdir <generic directory name of spectra fits files>\n"
579 << " -specname <generic name of spectra fits files>\n"
580 << " -freqBAOCalib <freq in MHZ> freq. of calibration BAO\n"
581 << " valid for act=dataOnOff\n"
582 << " -bwBAOCalib <band width MHz> band width arround central freq. for calibration BAO\n"
583 << " valid for act=calib\n"
584 << " -mode <mode_type>:\n"
585 << " valid for act=gain, mode_type: On, Off\n"
586 << " -numcycle <number>,<number>:\n"
587 << " valid for all actions"
588 << " -calibopt <option>:\n"
589 << " valid for act=calib: indiv OR mean (NOT USED)"
590 << " -debuglev <number> [0=default]\n"
591 << " 1: normal print\n"
592 << " 2: save intermediate spectra\n"
593 << endl;
594 if (flag) {
595 cout << "use <path>/analyse -h for detailed instructions" << endl;
596 return 5;
597 }
598 return 1;
599}
600
601int ProcessBase::processCmd() throw(string) {
602 int rc =0;
603 string msg;
604 if(debuglev_>0)cout << "Process Base" << endl;
605 //------------------------
606 //Use the sca file informations
607 //------------------------
608 // string scaFullPathName = "./";
609 //TOBE FIXED scaFullPathName += sourceName_+"/"+dateOfRun_ + StringToLower(sourceName_)+"/";
610 string scaFullPathName = inputPath_ + "/"
611 + sourceName_+ "/" +dateOfRun_ + StringToLower(sourceName_)+ "/" + scaFileName_;
612 char* scaTupleColumnName[9] = {"cycle","stcalOn","spcalOn","stOn","spOn","stcalOff","spcalOff","stOff","spOff"};
613 scaTuple_ = new NTuple(9,scaTupleColumnName);
614 int n = scaTuple_->FillFromASCIIFile(scaFullPathName);
615 if(n<0){ //Error
616 msg = "(FATAL) NTuple error loading "+ scaFullPathName;
617 rc = 999;
618 throw msg;
619 }
620
621 if(debuglev_>1){
622 cout << "ProcessBase::processCmd: dump tuple in " << scaFullPathName << endl;
623 scaTuple_->Show(cout);
624 }
625
626
627 //Get the cycles (here consider consecutive cycles)
628 //The SCA file cannot be used as the DAQ can miss some cycles...
629 // r_8 firstCycle, lastCycle;
630 // scaTuple_->GetMinMax("cycle",firstCycle,lastCycle);
631 // ifirstCycle_ = (sa_size_t)firstCycle;
632 // ilastCycle_ = (sa_size_t)lastCycle;
633 //Analyse the string given by -numcycle command line
634 int ai1=0,ai2=0;
635 sscanf(numcycle_.c_str(),"%d,%d",&ai1,&ai2);
636 ifirstCycle_ = (sa_size_t)ai1;
637 ilastCycle_ = (sa_size_t)ai2;
638
639
640 //associate cycle number to index line in tuple
641 sa_size_t nLines = scaTuple_->NbLines();
642 for(sa_size_t iL=0; iL<nLines; ++iL){
643 idCycleInTuple_[(sa_size_t)scaTuple_->GetCell(iL,"cycle")]=iL;
644 }
645
646
647 return rc;
648}
649//JEC 22/9/11 Make ON-OFF analysis WO any calibration START
650//----------------------------------------------
651int ProcessONOFFRawData::processCmd() throw(string) {
652 int rc = 0;
653 try {
654 rc = ProcessBase::processCmd();
655 }
656 catch (string s) {
657 throw s;
658 }
659 if(debuglev_>0)cout << "Process Raw Data ON OFF" << endl;
660 vector<string> modeList;
661 modeList.push_back("On");
662 modeList.push_back("Off");
663 vector<string>::const_iterator iMode;
664
665 uint_4 id;
666 string tag;
667
668 //
669 //Process to get sucessively
670 //Raw Spectra,
671 //The pocesses are separated to allow intermediate save of results
672
673 map< pair<string, sa_size_t>, TMatrix<r_4> > spectreCollect;
674 map< pair<string, sa_size_t>, TMatrix<r_4> >::iterator iSpectre, iSpectreEnd;
675
676 for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
677 string mode = *iMode;
678 if(debuglev_>0)cout << "Process RAW Mode " << mode << endl;
679
680 //------------------------------------------
681 //Produce Raw spectra per cycle
682 //------------------------------------------
683
684 string directoryName;
685 list<string> listOfSpecFiles;
686 list<string>::const_iterator iFile, iFileEnd;
687
688
689 //
690 //loop on cycles
691 //
692 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
693 directoryName = "./" + mode + "/";
694 stringstream sicycle;
695 sicycle << icycle;
696 directoryName += spectraDirectory_ + sicycle.str() + "/";
697
698 //read directory
699 listOfSpecFiles = ListOfFileInDir(directoryName,typeOfFile_);
700
701
702 //compute mean of spectra created in a cycle
703 if(debuglev_>0)cout << "compute mean for cycle " << icycle << endl;
704 TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
705 iFileEnd = listOfSpecFiles.end();
706 r_4 nSpectres = 0;
707 for (iFile = listOfSpecFiles.begin(); iFile != iFileEnd; ++iFile) {
708 FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
709 TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
710 aSpectrum >> spectre;
711 spectreMean += spectre;
712 nSpectres++;
713 }// end of for files
714 if(nSpectres>0) spectreMean /= nSpectres;
715
716 //save mean spectrum
717 spectreCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,icycle),TMatrix<r_4>(spectreMean,false) ));
718 }//end of for cycles
719 }//end loop on mode for raw preocess
720
721 //JEC 23/9/11 DO IT
722 // if(debuglev_>1) {//save mean spectra on file
723 cout << "Save mean raw spectra" << endl;
724 string fileName;
725 fileName = "./dataRaw_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
726
727 POutPersist fos(fileName);
728 id=0;
729 iSpectreEnd = spectreCollect.end();
730 for (iSpectre = spectreCollect.begin();
731 iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
732 tag = "specRaw";
733 tag += (iSpectre->first).first;
734 stringstream sid;
735 sid << (iSpectre->first).second;
736 tag += sid.str();
737 if(debuglev_>9) {
738 cout << "save tag<" << tag << ">" << endl;
739 }
740 fos << PPFNameTag(tag) << iSpectre->second;
741 }
742 // }//end of save fits
743
744
745 //------------------------------------------
746 // Perform ON-OFF
747 //------------------------------------------
748
749 map< sa_size_t, TMatrix<r_4> > diffCollect;
750 map< sa_size_t, TMatrix<r_4> >::iterator iDiff, iDiffEnd;
751
752 TMatrix<r_4> diffMeanOnOff(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //init zero
753 r_4 nCycles = 0;
754 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
755 nCycles++;
756 TMatrix<r_4> specmtxOn(spectreCollect[make_pair(modeList[0],icycle)],false); //clone the memory
757 TMatrix<r_4> specmtxOff(spectreCollect[make_pair(modeList[1],icycle)],false); //clone the memory
758 TMatrix<r_4> diffOnOff = specmtxOn - specmtxOff;
759 diffCollect.insert(pair< sa_size_t,TMatrix<r_4> >(icycle,TMatrix<r_4>(diffOnOff,false) ));
760 diffMeanOnOff += diffOnOff;
761 }//end loop on cycle
762 if(nCycles>0) diffMeanOnOff/=nCycles;
763
764 //exctract channels and do the mean
765 TVector<r_4> meanOfChan(NUMBER_OF_FREQ); //implicitly init to 0
766 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh) {
767 meanOfChan += diffMeanOnOff.Row(iCh).Transpose();
768 }
769 meanOfChan /= (r_4)NUMBER_OF_CHANNELS;
770
771
772
773 {//save diff ON-OFF on Raw data
774 if(debuglev_>0)cout << "save ON-OFF RAW spectra" << endl;
775 string fileName;
776 fileName = "./diffOnOffRaw_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
777 POutPersist fos(fileName);
778 iDiffEnd = diffCollect.end();
779 id = 0;
780
781 //JEC 22/9/11 Mean & Sigma in 32-bins size START
782 sa_size_t nSliceFreq = 32; //TODO: put as an input parameter option ?
783 sa_size_t deltaFreq = NUMBER_OF_FREQ/nSliceFreq;
784 //JEC 22/9/11 Mean & Sigma in 32-bins size END
785
786 for (iDiff = diffCollect.begin();iDiff != iDiffEnd ; ++iDiff, id++) {
787 tag = "specONOFFRaw";
788 stringstream sid;
789 sid << iDiff->first;
790 tag += sid.str();
791 fos << PPFNameTag(tag) << iDiff->second;
792
793 //JEC 22/9/11 Mean & Sigma in 32-bins size START
794 if (debuglev_>9) {
795 cout << "Debug slicing: slice/delta " << nSliceFreq << " " << deltaFreq << endl;
796 }
797 TMatrix<r_4> reducedMeanDiffOnOff(NUMBER_OF_CHANNELS,nSliceFreq); //init 0 by default
798 TMatrix<r_4> reducedSigmaDiffOnOff(NUMBER_OF_CHANNELS,nSliceFreq); //init 0 by default
799 for (sa_size_t iSlice=0; iSlice<nSliceFreq; iSlice++){
800 sa_size_t freqLow= iSlice*deltaFreq;
801 sa_size_t freqHigh= freqLow + deltaFreq -1;
802 if (debuglev_>9) {
803 cout << "Debug .......... slicing ["<< iSlice << "]: low/high freq" << freqLow << "/" << freqHigh << endl;
804 }
805 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
806 if (debuglev_>9) {
807 cout << "Debug .......... Channel " << iCh;
808 }
809 TVector<r_4> reducedRow;
810 reducedRow = (iDiff->second).SubMatrix(Range(iCh),Range(freqLow,freqHigh)).CompactAllDimensions();
811 double mean;
812 double sigma;
813 MeanSigma(reducedRow,mean,sigma);
814 if (debuglev_>9) {
815 cout << "mean/signa " << mean << "/" << sigma << endl;
816 }
817 reducedMeanDiffOnOff(iCh,iSlice) = mean;
818 reducedSigmaDiffOnOff(iCh,iSlice) = sigma;
819 }//loop on Channel
820 }//loop on Freq. slice
821 tag = "redMeanONOFFRaw";
822 tag += sid.str();
823 fos << PPFNameTag(tag) << reducedMeanDiffOnOff;
824 tag = "redSigmaONOFFRaw";
825 tag += sid.str();
826 fos << PPFNameTag(tag) << reducedSigmaDiffOnOff;
827 //JEC 22/9/11 END
828
829 }//loop on ON-OFF spectre
830 //save the mean also
831 fos << PPFNameTag("specONOFFRawMean") << diffMeanOnOff;
832
833 //JEC 22/9/11 START
834 TMatrix<r_4> reducedMeanDiffOnOffAll(NUMBER_OF_CHANNELS,nSliceFreq); //init 0 by default
835 TMatrix<r_4> reducedSigmaDiffOnOffAll(NUMBER_OF_CHANNELS,nSliceFreq); //init 0 by default
836 for (sa_size_t iSlice=0; iSlice<nSliceFreq; iSlice++){
837 sa_size_t freqLow= iSlice*deltaFreq;
838 sa_size_t freqHigh= freqLow + deltaFreq -1;
839 if (debuglev_>9) {
840 cout << "Debug .......... slicing ["<< iSlice << "]: low/high freq" << freqLow << "/" << freqHigh << endl;
841 }
842 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh){
843 if (debuglev_>9) {
844 cout << "Debug .......... Channel " << iCh;
845 }
846 TVector<r_4> reducedRow;
847 reducedRow = diffMeanOnOff.SubMatrix(Range(iCh),Range(freqLow,freqHigh)).CompactAllDimensions();
848 double mean;
849 double sigma;
850 MeanSigma(reducedRow,mean,sigma);
851 if (debuglev_>9) {
852 cout << "mean/signa " << mean << "/" << sigma << endl;
853 }
854 reducedMeanDiffOnOffAll(iCh,iSlice) = mean;
855 reducedSigmaDiffOnOffAll(iCh,iSlice) = sigma;
856 }//loop on Channel
857 }//loop on Freq. slice
858 tag = "redMeanONOFFRawAll";
859 fos << PPFNameTag(tag) << reducedMeanDiffOnOffAll;
860 tag = "redSigmaONOFFRawAll";
861 fos << PPFNameTag(tag) << reducedSigmaDiffOnOffAll;
862 //JEC 22/9/11 END
863
864
865
866 fos << PPFNameTag("specONOFFRaw2ChanMean") << meanOfChan;
867 }//end of save fits
868
869
870 cout << "OK rawOnOff finished" <<endl;
871 return rc;
872} //ProcessONOFFRawData::processCmd
873
874//JEC 22/9/11 Make ON-OFF analysis WO any calibration END
875//----------------------------------------------
876int ProcessONOFFData::processCmd() throw(string) {
877 int rc = 0;
878 try {
879 rc = ProcessBase::processCmd();
880 }
881 catch (string s) {
882 throw s;
883 }
884 if(debuglev_>0)cout << "Process Data" << endl;
885 vector<string> modeList;
886 modeList.push_back("On");
887 modeList.push_back("Off");
888 vector<string>::const_iterator iMode;
889
890 uint_4 id;
891 string tag;
892
893 //
894 //Process to get sucessively
895 //Raw Spectra,
896 //BAO Calibrated Spectra
897 //and RT Calibrated Spectra
898 //The pocesses are separated to allow intermediate save of results
899
900 map< pair<string, sa_size_t>, TMatrix<r_4> > spectreCollect;
901 map< pair<string, sa_size_t>, TMatrix<r_4> >::iterator iSpectre, iSpectreEnd;
902
903 for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
904 string mode = *iMode;
905 if(debuglev_>0)cout << "Process RAW Mode " << mode << endl;
906
907 //------------------------------------------
908 //Produce Raw spectra per cycle
909 //------------------------------------------
910
911 string directoryName;
912 list<string> listOfSpecFiles;
913 list<string>::const_iterator iFile, iFileEnd;
914
915
916 //
917 //loop on cycles
918 //
919 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
920 //TOBE FIXED directoryName = "./" + sourceName_ + "/"+ dateOfRun_ + StringToLower(sourceName_) + "/" +mode + "/";
921 directoryName = "./" + mode + "/";
922 stringstream sicycle;
923 sicycle << icycle;
924 directoryName += spectraDirectory_ + sicycle.str() + "/";
925
926 //read directory
927 listOfSpecFiles = ListOfFileInDir(directoryName,typeOfFile_);
928
929
930 //compute mean of spectra created in a cycle
931 if(debuglev_>0)cout << "compute mean for cycle " << icycle << endl;
932 TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
933 iFileEnd = listOfSpecFiles.end();
934 r_4 nSpectres = 0;
935 for (iFile = listOfSpecFiles.begin(); iFile != iFileEnd; ++iFile) {
936 FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
937 TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
938 aSpectrum >> spectre;
939 spectreMean += spectre;
940 nSpectres++;
941 }// end of for files
942 if(nSpectres>0) spectreMean /= nSpectres;
943
944 //save mean spectrum
945 spectreCollect.insert( pair< pair<string,sa_size_t>, TMatrix<r_4> >(make_pair(mode,icycle),TMatrix<r_4>(spectreMean,false) ));
946 }//end of for cycles
947 }//end loop on mode for raw preocess
948
949 if(debuglev_>1) {//save mean spectra on file
950 cout << "Save mean raw spectra" << endl;
951 string fileName;
952 //TOBE FIXED fileName = "./" + sourceName_ + "/" + dateOfRun_ + "_" + StringToLower(sourceName_) + "_" + "dataRaw" + ".ppf";
953 fileName = "./dataRaw_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
954
955 POutPersist fos(fileName);
956 id=0;
957 iSpectreEnd = spectreCollect.end();
958 for (iSpectre = spectreCollect.begin();
959 iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
960 tag = "specRaw";
961
962 //JEC 20/9/11 modif tag to take into account Mode and Cycle number START
963// stringstream sid;
964// sid << id;
965// tag += sid.str();
966 tag += (iSpectre->first).first;
967 stringstream sid;
968 sid << (iSpectre->first).second;
969 tag += sid.str();
970 if(debuglev_>9) {
971 cout << "save tag<" << tag << ">" << endl;
972 }
973 //JEC 20/9/11 modif tag to take into account Mode and Cycle number END
974
975 fos << PPFNameTag(tag) << iSpectre->second;
976 }
977 }//end of save fits
978
979
980
981 for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
982 string mode = *iMode;
983 if(debuglev_>0)cout << "Process CALIB BAO Mode " << mode << endl;
984 //------------------------------------------
985 // Correct Raw spectra for BAO calibration
986 //------------------------------------------
987 //Read BAO calibration files
988 sa_size_t nr,nc; //values read
989
990 string calibFileName = inputPath_+ "/"
991 + sourceName_ + "/" + dateOfRun_ + StringToLower(sourceName_)
992 + "/calib_" + dateOfRun_ + "_" + StringToLower(sourceName_) + "_"
993 + mode + "_" + freqBAOCalibration_ + "MHz-All.txt";
994
995 if(debuglev_>0) cout << "Read file " << calibFileName << endl;
996 ifstream ifs(calibFileName.c_str());
997 if ( ! ifs.is_open() ) {
998 rc = 999;
999 throw calibFileName + " cannot be opened...";
1000 }
1001 TVector<r_4> calibBAOfactors;
1002 if(debuglev_>9) cout << "Debug 1" << endl;
1003 calibBAOfactors.ReadASCII(ifs,nr,nc);
1004 if(debuglev_>9){
1005 cout << "Debug 2: (nr,nc): "<< nr << "," << nc << endl;
1006 calibBAOfactors.Print(cout);
1007 }
1008
1009//JEC 20/9/11 use mean calibration coeff upon all cycles END
1010
1011 //
1012 //spectra corrected by BAO calibration factor
1013 //-----make it different on Channels and Cycles (1/06/2011) OBSOLETE
1014 //use mean calibration coeff upon all cycles (20/6/11)
1015 //warning cycles are numbered from 1,...,N
1016 //
1017 if(debuglev_>0)cout << "do calibration..." << endl;
1018 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
1019 TMatrix<r_4> specmtx(spectreCollect[make_pair(mode,icycle)],true); //share the memory
1020
1021 for (sa_size_t iCh=0;iCh<NUMBER_OF_CHANNELS;++iCh){
1022 //JEC 20/9/11 use mean calibration coeff upon all cycles START
1023
1024 // specmtx( Range(iCh), Range::all() ) /= calibBAOfactors(iCh,icycle-1);
1025 specmtx( Range(iCh), Range::all() ) /= calibBAOfactors(iCh);
1026 //JEC 20/9/11 use mean calibration coeff upon all cycles END
1027 }
1028 }
1029 } //end loop mode for BAO calib
1030
1031 if(debuglev_>1){ //save mean spectra BAO calibrated on file
1032 cout << "save calibrated BAO spectra" << endl;
1033 string fileName;
1034 //TO BE FIXED fileName = "./" + sourceName_ + "/" + dateOfRun_ + "_" + StringToLower(sourceName_) + "_" + "dataBAOCalib" + ".ppf";
1035 fileName = "./dataBAOCalib_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
1036
1037 POutPersist fos(fileName);
1038 iSpectreEnd = spectreCollect.end();
1039 id=0;
1040 for (iSpectre = spectreCollect.begin();iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
1041
1042 tag = "specBAOCalib";
1043 //JEC 20/9/11 modif tag to take into account Mode and Cycle number START
1044// stringstream sid;
1045// sid << id;
1046// tag += sid.str();
1047 tag += (iSpectre->first).first;
1048 stringstream sid;
1049 sid << (iSpectre->first).second;
1050 tag += sid.str();
1051 if(debuglev_>9) {
1052 cout << "save tag<" << tag << ">" << endl;
1053 }
1054 //JEC 20/9/11 modif tag to take into account Mode and Cycle number END
1055
1056 fos << PPFNameTag(tag) << iSpectre->second;
1057 }
1058 }//end of save fits
1059
1060
1061 for (iMode = modeList.begin(); iMode != modeList.end(); ++iMode) {
1062 string mode = *iMode;
1063 if(debuglev_>0)cout << "Process CALIB RT Mode " << mode << endl;
1064 //------------------------------------------
1065 // Correct BAO calib spectra for RT calibration
1066 //------------------------------------------
1067 //Very Preliminary May-June 11
1068 //coef RT @ 1346MHz Ouest - Est associees a Ch 0 et 1
1069 r_4 calibRT[NUMBER_OF_CHANNELS] = {27.724, 22.543};
1070 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
1071 TMatrix<r_4> specmtx(spectreCollect[make_pair(mode,icycle)],true); //share the memory
1072 for (sa_size_t iCh=0;iCh<NUMBER_OF_CHANNELS;++iCh){
1073 specmtx( Range(iCh), Range::all() ) *= calibRT[iCh];
1074 }
1075 }
1076 }//end loop on mode RT calib
1077
1078 {//save mean spectra BAO & RT calibrated on file
1079 if(debuglev_>0)cout << "save calibrated BAO & RT spectra" << endl;
1080 string fileName;
1081 //TO BE FIXED fileName = "./" + sourceName_ + "/" + dateOfRun_ + "_" + StringToLower(sourceName_) + "_" + "dataBAORTCalib" + ".ppf";
1082 fileName = "./dataBAORTCalib_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
1083 POutPersist fos(fileName);
1084 iSpectreEnd = spectreCollect.end();
1085 id = 0;
1086 for (iSpectre = spectreCollect.begin();iSpectre != iSpectreEnd ; ++iSpectre, ++id) {
1087 tag = "specBAORTCalib";
1088 //JEC 20/9/11 modif tag to take into account Mode and Cycle number START
1089// stringstream sid;
1090// sid << id;
1091// tag += sid.str();
1092 tag += (iSpectre->first).first;
1093 stringstream sid;
1094 sid << (iSpectre->first).second;
1095 tag += sid.str();
1096 if(debuglev_>9) {
1097 cout << "save tag<" << tag << ">" << endl;
1098 }
1099 //JEC 20/9/11 modif tag to take into account Mode and Cycle number END
1100 fos << PPFNameTag(tag) << iSpectre->second;
1101 }
1102 }//end of save fits
1103
1104 //------------------------------------------
1105 // Perform ON-OFF
1106 //------------------------------------------
1107
1108 map< sa_size_t, TMatrix<r_4> > diffCollect;
1109 map< sa_size_t, TMatrix<r_4> >::iterator iDiff, iDiffEnd;
1110
1111 TMatrix<r_4> diffMeanOnOff(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //init zero
1112 r_4 nCycles = 0;
1113 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
1114 nCycles++;
1115 TMatrix<r_4> specmtxOn(spectreCollect[make_pair(modeList[0],icycle)],false); //clone the memory
1116 TMatrix<r_4> specmtxOff(spectreCollect[make_pair(modeList[1],icycle)],false); //clone the memory
1117 TMatrix<r_4> diffOnOff = specmtxOn - specmtxOff;
1118 diffCollect.insert(pair< sa_size_t,TMatrix<r_4> >(icycle,TMatrix<r_4>(diffOnOff,false) ));
1119 diffMeanOnOff += diffOnOff;
1120 }//end loop on cycle
1121 if(nCycles>0) diffMeanOnOff/=nCycles;
1122
1123 //exctract channels and do the mean
1124 TVector<r_4> meanOfChan(NUMBER_OF_FREQ); //implicitly init to 0
1125 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh) {
1126 meanOfChan += diffMeanOnOff.Row(iCh).Transpose();
1127 }
1128 meanOfChan /= (r_4)NUMBER_OF_CHANNELS;
1129
1130
1131
1132 {//save diff ON-OFF BAO & RT calibrated
1133 if(debuglev_>0)cout << "save ON-OFF spectra" << endl;
1134 string fileName;
1135 //TO BE FIXED fileName = "./" + sourceName_ + "/" + dateOfRun_ + "_" + StringToLower(sourceName_) + "_" + "diffOnOff" + ".ppf";
1136 fileName = "./diffOnOff_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
1137 POutPersist fos(fileName);
1138 iDiffEnd = diffCollect.end();
1139 id = 0;
1140 for (iDiff = diffCollect.begin();iDiff != iDiffEnd ; ++iDiff, id++) {
1141 tag = "specONOFF";
1142 stringstream sid;
1143 //JEC 20/9/11 sid << id;
1144 sid << iDiff->first;
1145 tag += sid.str();
1146 if(debuglev_>9) {
1147 cout << "save tag<" << tag << ">" << endl;
1148 }
1149 fos << PPFNameTag(tag) << iDiff->second;
1150 }
1151 //save the mean also
1152 fos << PPFNameTag("specONOFFMean") << diffMeanOnOff;
1153 fos << PPFNameTag("specONOFF2ChanMean") << meanOfChan;
1154 }//end of save fits
1155
1156 cout << "OK dataOnOff finished";
1157
1158 return rc;
1159} //ProcessONOFFData::processCmd
1160//
1161//----------------------------------------------
1162//
1163int ProcessGain::processCmd() throw(string) {
1164 int rc = 0;
1165 string msg = "";
1166
1167 try {
1168 rc = ProcessBase::processCmd();
1169 }
1170 catch (string s) {
1171 throw s;
1172 }
1173 if(debuglev_>0)cout << "Process Gain" << endl;
1174
1175 string directoryName;
1176 //TOBE FIXED directoryName = "./" + sourceName_ + "/"+ dateOfRun_ + StringToLower(sourceName_) + "/" +mode_ + "/";
1177 //JEC 6/09/2011 numcycle_ repalced by ifirstCycle_ according to definition of numcycle_ and the fact that for GAIN 1 cycle is involved
1178 stringstream thegaincycle;
1179 thegaincycle << ifirstCycle_;
1180 directoryName = inputPath_ + "/"
1181 + sourceName_ + "/" + dateOfRun_ + StringToLower(sourceName_) + "/"
1182 + mode_ + "/" + spectraDirectory_ + thegaincycle.str() + "/";
1183
1184 list<string> listOfSpecFiles;
1185 list<string>::const_iterator iFile, iFileEnd;
1186 //read directory
1187
1188 listOfSpecFiles = ListOfFileInDir(directoryName,typeOfFile_);
1189
1190 //Mean power computed over the N channels to select the spectra for gain computation
1191 //The threshold is computed "on-line" as 1% of the difference (max power -min power) over the
1192 // the min power.
1193 //A possible alternative is to set an absolute value...
1194 if(debuglev_>0)cout << "compute mean poser spectra for files in " << directoryName << endl;
1195 iFileEnd = listOfSpecFiles.end();
1196 map<string, r_4> meanpowerCollect;
1197 //JEC 21/9/11 add meanpower for each Channels START
1198 map<string, r_4> meanPowerPerChanCollect;
1199 //JEC 21/9/11 add meanpower for each Channels END
1200
1201 map<string, r_4>::const_iterator iMeanPow, iMeanPowEnd;
1202
1203 for (iFile = listOfSpecFiles.begin(); iFile != iFileEnd; ++iFile) {
1204 FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
1205 TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
1206 aSpectrum >> spectre;
1207 meanpowerCollect[*iFile] = spectre.Sum()/spectre.Size();
1208 //JEC 21/9/11 add meanpower for each Channels START
1209 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; ++iCh) {
1210 TVector<r_4> specChan(NUMBER_OF_FREQ);
1211 specChan = spectre.Row(iCh).Transpose();
1212 stringstream tmp;
1213 tmp << iCh;
1214 string tag = *iFile + "_" + tmp.str();
1215 meanPowerPerChanCollect[tag] = specChan.Sum()/specChan.Size();
1216 }
1217 //JEC 21/9/11 add meanpower for each Channels END
1218 }//end of for files
1219 pair<string, r_4> minelement = *min_element(meanpowerCollect.begin(),meanpowerCollect.end(),compare);
1220 pair<string, r_4> maxelement = *max_element(meanpowerCollect.begin(),meanpowerCollect.end(),compare);
1221 if(debuglev_>1){
1222 cout << "meanpowerCollect has " << meanpowerCollect.size() << " spectra registered" << endl;
1223 cout << "find min mean power "<<minelement.second << " for " << minelement.first << endl;
1224 cout << "find max mean power "<<maxelement.second << " for " << maxelement.first << endl;
1225 }
1226 r_4 threshold = minelement.second + 0.01*(maxelement.second-minelement.second);
1227 if(debuglev_>1){
1228 cout << "threshold found at " << threshold <<endl;
1229 }
1230
1231 TMatrix<r_4> spectreMean(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
1232 r_4 nSpectres = 0;
1233 iMeanPowEnd = meanpowerCollect.end();
1234 for (iMeanPow = meanpowerCollect.begin(); iMeanPow != iMeanPowEnd; ++iMeanPow) {
1235 if ( iMeanPow->second <= threshold ) {
1236 //TODO avoid the reloading of the file may speed up
1237 FitsInOutFile aSpectrum(iMeanPow->first,FitsInOutFile::Fits_RO);
1238 TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ);
1239 aSpectrum >> spectre;
1240 spectreMean += spectre;
1241 nSpectres++;
1242 }
1243 }
1244 if(debuglev_>1){
1245 cout << "Number of files selected for gain " << nSpectres <<endl;
1246 }
1247 if(nSpectres>0) {
1248 spectreMean /= nSpectres;
1249 } else {
1250 stringstream tmp;
1251 tmp << threshold;
1252 msg = "Gain: cannot find a spectra above threshold value =" + tmp.str() + " ... FATAL";
1253 throw msg;
1254 }
1255
1256 //Save gain spectra
1257 {
1258 //use ! to override the file: special features of cfitsio library
1259 string fileName;
1260 //TOBE FIXED fileName = "!./" + sourceName_ + "/gain_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".fits";
1261 fileName = "!"+ outputPath_ + "/gain_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".fits";
1262 if(debuglev_>1){
1263 cout << "save gains in " << fileName << endl;
1264 }
1265 FitsInOutFile fos(fileName, FitsInOutFile::Fits_Create);
1266 fos << spectreMean;
1267 }
1268 //save mean power values
1269 {
1270 vector<r_4> tmp;
1271 //JEC 21/9/11 add meanpower for each Channels START
1272 vector<r_4> tmpCh0; //for Chan 0
1273 vector<r_4> tmpCh1; //for Chan 1
1274 //JEC 21/9/11 add meanpower for each Channels END
1275 for (iFile = listOfSpecFiles.begin(); iFile != iFileEnd; ++iFile) {
1276 if (debuglev_>9) {
1277 cout << "Gain: save mean power of file: " << *iFile << endl;
1278 }
1279 tmp.push_back(meanpowerCollect[*iFile]);
1280 //JEC 21/9/11 add meanpower for each Channels START
1281 stringstream tmp0;
1282 tmp0 << (sa_size_t)0;
1283 string tag0 = *iFile + "_" + tmp0.str();
1284 tmpCh0.push_back(meanPowerPerChanCollect[tag0]);
1285 if (NUMBER_OF_CHANNELS>1){
1286 stringstream tmp1;
1287 tmp1 << (sa_size_t)1;
1288 string tag1 = *iFile + "_" + tmp1.str();
1289 tmpCh1.push_back(meanPowerPerChanCollect[tag1]);
1290 }
1291 //JEC 21/9/11 add meanpower for each Channels END
1292 }
1293 string fileName;
1294 //TOBE FIXED fileName = "./" + sourceName_ + "/gain_monitor_" + dateOfRun_
1295 fileName = outputPath_ + "/gain_monitor_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
1296 POutPersist fos(fileName);
1297 TVector<r_4> tvtmp(tmp);
1298 fos.PutObject(tvtmp,"gainmoni"); //Attention initialement le tag etait "monitor"...
1299 //JEC 21/9/11 add meanpower for each Channels START
1300 TVector<r_4> tvtmp0(tmpCh0);
1301 fos.PutObject(tvtmp0,"gainmoni0");
1302 if (NUMBER_OF_CHANNELS>1){
1303 TVector<r_4> tvtmp1(tmpCh1);
1304 fos.PutObject(tvtmp1,"gainmoni1");
1305 }
1306 //JEC 21/9/11 add meanpower for each Channels END
1307 }
1308
1309 cout << "OK gain finished" <<endl;
1310 return rc;
1311}//ProcessGain::processCmd
1312//
1313//----------------------------------------------
1314//
1315int ProcessCalibration::processCmd() throw(string) {
1316 int rc = 0;
1317 string msg = "";
1318
1319 try {
1320 rc = ProcessBase::processCmd();
1321 }
1322 catch (string s) {
1323 throw s;
1324 }
1325 if(debuglev_>0)cout << "Process Calibration with option "<< option_ << endl;
1326
1327 vector<string> modeList;
1328 modeList.push_back("On");
1329 modeList.push_back("Off");
1330
1331 r_8 t0absolute = -1; //TIMEWIN of the first spectra used
1332 r_8 timeTag0 = -1; //MEANTT, mean TIME TAG of the first paquet window
1333 bool first = true; // for initialisation
1334
1335 // Power Tuple
1336 // mode, cycle, time, {Ch0, ... ,ChN} mean poser in the range [f0-Bw/2, f0+Bw/2]
1337 vector<string> varPowerTupleName; //ntuple variable naming
1338 varPowerTupleName.push_back("mode");
1339 varPowerTupleName.push_back("cycle");
1340 varPowerTupleName.push_back("time");
1341 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS;++iCh){
1342 stringstream tmp;
1343 tmp << iCh;
1344 varPowerTupleName.push_back("Ch"+tmp.str());
1345 }
1346 r_4 valPowerTuple[varPowerTupleName.size()];
1347 NTuple powerEvolution(varPowerTupleName);
1348
1349
1350 //-----------------
1351 //Start real process
1352 //------------------
1353 for (size_t iMode = 0; iMode < modeList.size(); ++iMode) {
1354 string mode = modeList[iMode];
1355 if(debuglev_>0)cout << "Process Calibration for Mode " << mode << endl;
1356
1357 //initialize the start of each calibration procedure given by the RT SCA file
1358 //see ProcessBase::processCmd for the structure of the sca file
1359 string scaStartCalibName = "stcal"+mode;
1360 sa_size_t idStartCalib = scaTuple_->ColumnIndex(scaStartCalibName);
1361
1362 string directoryName;
1363 list<string> listOfSpecFiles;
1364 list<string>::const_iterator iFile, iFileEnd;
1365 //
1366 //loop on cycles
1367 //
1368 for (sa_size_t icycle = ifirstCycle_; icycle <= ilastCycle_; icycle++) {
1369
1370 directoryName = inputPath_ + "/"
1371 + sourceName_ + "/"+ dateOfRun_ + StringToLower(sourceName_) + "/" +mode + "/";
1372 stringstream sicycle;
1373 sicycle << icycle;
1374 directoryName += spectraDirectory_ + sicycle.str() + "/";
1375
1376 //read directory
1377 listOfSpecFiles = ListOfFileInDir(directoryName,typeOfFile_);
1378
1379 iFileEnd = listOfSpecFiles.end();
1380 DVList header;
1381 TMatrix<r_4> spectre(NUMBER_OF_CHANNELS,NUMBER_OF_FREQ); //implicit init to 0
1382
1383 for (iFile = listOfSpecFiles.begin(); iFile != iFileEnd; ++iFile) {
1384 FitsInOutFile aSpectrum(*iFile,FitsInOutFile::Fits_RO);
1385 aSpectrum.GetHeaderRecords(header);
1386 aSpectrum >> spectre;
1387
1388 if(first){//initialise the timer
1389 first = false;
1390 t0absolute = header.GetD("TIMEWIN")/1000.;
1391 timeTag0 = header.GetD("MEANTT");
1392 if (debuglev_>1){
1393 cout << "debug Header of " << *iFile << endl;
1394 cout << "TIMEWIN = " << setprecision(12) << t0absolute << " "
1395 << "MEANTT = " << setprecision(12) << timeTag0 << endl;
1396 }
1397 }//end init timer
1398
1399 //Set time of current file
1400 //Add to the non-precise absolute origin an precise increment
1401 r_4 timeTag = t0absolute + (header.GetD("MEANTT") - timeTag0);
1402 int index=0;
1403 valPowerTuple[index++] = iMode;
1404 valPowerTuple[index++] = icycle;
1405 valPowerTuple[index++] = timeTag-scaTuple_->GetCell(idCycleInTuple_[icycle],idStartCalib); //take the RT time start as refernce
1406
1407 //Compute the mean power of the two channel (separatly) in the range [f-bw/2, f+bw/2]
1408 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS;++iCh){
1409 TMatrix<r_4> tmp(spectre(Range(iCh),Range(lowerFreqBin_,upperFreqBin_)),false);
1410 r_4 mean = tmp.Sum()/(r_4)tmp.Size();
1411 valPowerTuple[index++] = mean;
1412 }//end of channel loop
1413
1414 //Fill Tuple
1415 powerEvolution.Fill(valPowerTuple);
1416 }//end of files loop
1417 }//end of cycles loop
1418 }//end of mode loop
1419
1420 //store power evolution Tuple
1421 if(debuglev_>0){
1422 cout << "ProcessCalibration::processCmd: dump powerEvolution tuple" << endl;
1423 powerEvolution.Show(cout);
1424 }
1425 //
1426 //Compute Calibration Coefficients as function of mode/cycle/channels
1427 //
1428
1429 //Tsys,Incremant Intensity... Tuple
1430 //mode mode cycle [(tsys0,dint0),...,(tsysN,dintN)]
1431 vector<string> varCalibTupleName;
1432 varCalibTupleName.push_back("mode");
1433 varCalibTupleName.push_back("cycle");
1434 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS;++iCh){
1435 stringstream tmp;
1436 tmp << iCh;
1437 varCalibTupleName.push_back("tsys"+tmp.str());
1438 varCalibTupleName.push_back("dint"+tmp.str());
1439 }
1440 r_4 valCalibTuple[varCalibTupleName.size()];
1441 NTuple calibEvolution(varCalibTupleName);
1442
1443 // select time E [twin0,twin1] U [twin2,twin3] for Tsys
1444 // time unit = second
1445 const r_4 twin0 = -3.;
1446 const r_4 twin1 = -1.;
1447 const r_4 twin2 = 6.;
1448 const r_4 twin3 = 8;
1449 const r_4 thresholdFactor = 0.80; //80% of the diff. Max-Min intensity
1450
1451 sa_size_t inModeIdx = powerEvolution.ColumnIndex("mode");
1452 sa_size_t inCycleIdx= powerEvolution.ColumnIndex("cycle");
1453 sa_size_t inTimeIdx = powerEvolution.ColumnIndex("time");
1454 sa_size_t inOffsetCh0 = powerEvolution.ColumnIndex("Ch0"); //nb Ch0 position in the powerEvolution tuple
1455 if(debuglev_>1) cout << "DEBUG: in Idx: ("
1456 << inModeIdx << ", "
1457 << inCycleIdx << ", "
1458 << inTimeIdx << ", "
1459 << inOffsetCh0 << ")"
1460 << endl;
1461
1462
1463 size_t outModeIdx = calibEvolution.ColumnIndex("mode");
1464 size_t outCycleIdx= calibEvolution.ColumnIndex("cycle");
1465 size_t outOffsetCh0 = calibEvolution.ColumnIndex("tsys0"); //nb Ch0 position in the monitor tuple
1466 size_t outNDataPerCh= 2;
1467 if(debuglev_>1) cout << "DEBUG: out Idx: ("
1468 << outModeIdx << ", "
1469 << outCycleIdx << ", "
1470 << outOffsetCh0 << ")"
1471 << endl;
1472
1473 sa_size_t nPowerEvolEntry = powerEvolution.NEntry();
1474 double minMode;
1475 double maxMode;
1476 powerEvolution.GetMinMax("mode",minMode,maxMode);
1477 double minCycleNum;
1478 double maxCycleNum;
1479 powerEvolution.GetMinMax("cycle",minCycleNum,maxCycleNum);
1480 if(debuglev_>1) cout << "DEBUG mode ("<<minMode<<","<<maxMode<<")\n"
1481 << "cycle ("<<minCycleNum<<","<<maxCycleNum<<")"
1482 << endl;
1483
1484 r_4* aPowerEvolEntry; // a ligne of the powerEvolution tuple
1485// r_4* aPowerEvolEntry = new r_4[powerEvolution.NbColumns()]; // a ligne of the powerEvolution tuple
1486
1487 r_4 minMean;
1488 r_4 maxMean;
1489
1490 for (size_t iMode = (size_t)minMode; iMode <= (size_t)maxMode; iMode++){
1491 for (size_t iCycle = (size_t)minCycleNum; iCycle <= (size_t)maxCycleNum; iCycle++ ){
1492 if(debuglev_>1) cout<<"DEBUG >>>>>>> mode/cycle: " << iMode << "/" << iCycle << endl;
1493
1494 valCalibTuple[outModeIdx]=iMode;
1495 valCalibTuple[outCycleIdx]=iCycle;
1496 //
1497 //Compute the Min && Max value of each Ch<i> data
1498 if(debuglev_>1) cout<<"DEBUG compute Min and Max for each channels" << endl;
1499 //
1500 TVector<r_4> chMean[NUMBER_OF_CHANNELS];
1501 for (sa_size_t iCh=0;iCh<NUMBER_OF_CHANNELS;iCh++){
1502 chMean[iCh].SetSize(nPowerEvolEntry);
1503 }
1504 for (sa_size_t ie=0; ie<nPowerEvolEntry; ie++){
1505 aPowerEvolEntry = powerEvolution.GetVec(ie);
1506 if ( (size_t)aPowerEvolEntry[inModeIdx] == iMode && (size_t)aPowerEvolEntry[inCycleIdx] == iCycle ){
1507 for (sa_size_t iCh=0;iCh<NUMBER_OF_CHANNELS;iCh++){
1508 chMean[iCh](ie) = aPowerEvolEntry[iCh+inOffsetCh0];
1509 }//end cut
1510 }
1511 }//eo loop on tuple entries
1512 for (sa_size_t iCh=0;iCh<NUMBER_OF_CHANNELS;iCh++){
1513 //
1514 //select values to compute background Tsys
1515 if(debuglev_>1) {
1516 cout<< "DEBUG >>>> Ch[" << iCh << "]" << endl;
1517 cout<< "DEBUG select values to compute background Tsys " << endl;
1518 }
1519 //
1520
1521 std::vector<r_4> lowerInt;
1522 for (sa_size_t ie=0; ie<nPowerEvolEntry; ie++){
1523 aPowerEvolEntry = powerEvolution.GetVec(ie);
1524 if ( (size_t)aPowerEvolEntry[inModeIdx] == iMode && (size_t)aPowerEvolEntry[inCycleIdx] == iCycle ){
1525 r_4 time = aPowerEvolEntry[inTimeIdx];
1526 if ( (time >= twin0 && time <= twin1) ||
1527 (time >= twin2 && time <= twin3)
1528 ) lowerInt.push_back(aPowerEvolEntry[iCh+inOffsetCh0]);
1529 }//end cut
1530 } //end loop entries
1531 //
1532 //compute the Tsys
1533 if(debuglev_>1) cout <<"DEBUG compute Tsys" << endl;
1534 //
1535 std::nth_element(lowerInt.begin(),
1536 lowerInt.begin()+lowerInt.size()/2,
1537 lowerInt.end());
1538 r_4 tsys = *(lowerInt.begin()+lowerInt.size()/2);
1539 if(debuglev_>1) cout << "DEBUG tsys["<<iCh<<"] : " << tsys <<endl;
1540 //
1541 //set the threshold for DAB detection
1542 //
1543 chMean[iCh].MinMax(minMean,maxMean);
1544 minMean = (tsys > minMean) ? tsys : minMean; //pb of empty vector
1545 if(debuglev_>1) cout << "DEBUG min["<<iCh<<"] : " << minMean
1546 << " max["<<iCh<<"] : " << maxMean
1547 <<endl;
1548 r_4 deltathres = thresholdFactor * (maxMean-minMean);
1549 r_4 thres = tsys + deltathres;
1550 if(debuglev_>1) cout << "DEBUG thres["<<iCh<<"] : " << thres <<endl;
1551 //
1552 //collect upper part of the DAB
1553 if(debuglev_>1) cout <<"DEBUG collect upper part of the DAB" << endl;
1554 //
1555 std::vector<r_4> upperInt;
1556 for (sa_size_t ie=0; ie<nPowerEvolEntry; ie++){
1557 aPowerEvolEntry = powerEvolution.GetVec(ie);
1558 if ( (size_t)aPowerEvolEntry[inModeIdx] == iMode && (size_t)aPowerEvolEntry[inCycleIdx] == iCycle ){
1559 r_4 mean = aPowerEvolEntry[iCh+inOffsetCh0];
1560 if (mean >= thres) upperInt.push_back(mean);
1561 }//end cut
1562 }//eo loop on channels
1563 //
1564 //compute adjacent differences to detect the 2 DAB levels
1565 //
1566 if(debuglev_>1) cout << "(DEBUG )size upper [" << iCh << "]: " << upperInt.size() <<endl;
1567 std::vector<r_4> upperIntAdjDiff(upperInt.size());
1568 std::adjacent_difference(upperInt.begin(),
1569 upperInt.end(),
1570 upperIntAdjDiff.begin());
1571 //
1572 //Search the 2 DAB states
1573 if(debuglev_>1) cout<<"DEBUG Search the 2 DAB states" << endl;
1574 //
1575 std::vector<r_4> upIntState[2];
1576 int state=-1;
1577 for (size_t i=1;i<upperInt.size();i++) {//skip first value
1578 if (fabs(upperIntAdjDiff[i])<upperInt[i]*0.010) {
1579 if(state == -1) state=0;
1580 if(state == -2) state=1;
1581 upIntState[state].push_back(upperInt[i]);
1582 } else {
1583 if (state == 0) state=-2;
1584 }
1585 }
1586 //
1587 //Take the mean of the median values of each levels
1588 if(debuglev_>1)cout << "DEBUG mean of the median values of each levels" << endl;
1589 //
1590 r_4 meanUpper = 0;
1591 r_4 nval = 0;
1592 for (int i=0;i<2;i++) {
1593 if (!upIntState[i].empty()) {
1594 std::nth_element(upIntState[i].begin(),
1595 upIntState[i].begin()+upIntState[i].size()/2,
1596 upIntState[i].end());
1597 meanUpper += *(upIntState[i].begin()+upIntState[i].size()/2);
1598 nval++;
1599 }
1600 }
1601 meanUpper /= nval;
1602 //
1603 //Finaly the increase of power due to the DAB is:
1604 //
1605 r_4 deltaInt = meanUpper - tsys;
1606 if(debuglev_>1) cout << "DEBUG deltaInt["<<iCh<<"] : " << deltaInt <<endl;
1607 //
1608 //Save for monitoring and final calibration operations
1609 //
1610 valCalibTuple[outOffsetCh0+outNDataPerCh*iCh] = tsys;
1611 valCalibTuple[outOffsetCh0+outNDataPerCh*iCh+1] = deltaInt;
1612 }//end loop on channels
1613 if(debuglev_>1) cout<<"DEBUG Fill the calibEvolution tuple" << endl;
1614 calibEvolution.Fill(valCalibTuple);
1615 }//eo loop on Cycles
1616 }//eo loop on Modes
1617 //
1618 //store calibration evolution Tuple
1619 //
1620 if(debuglev_>0){
1621 cout << "ProcessCalibration::processCmd: dump calibEvolution tuple" << endl;
1622 calibEvolution.Show(cout);
1623 }
1624 //
1625 //Compute the means per channel of the calibration coefficients (deltaInt)
1626 //and save cycle based Calibration Ctes in file named as
1627 // <source>-<date>-<mode>-<fcalib>MHz-Ch<channel>Cycles.txt
1628 // format <cycle> <coef>
1629 //the means are stored in files
1630 // <source>-<date>-<mode>-<fcalib>MHz-All.txt
1631 // format <channel> <coef>
1632 //
1633 sa_size_t nModes = (sa_size_t)(maxMode - minMode) + 1;
1634 string calibCoefFileName;
1635 ofstream calibMeanCoefFile[nModes]; //Mean over cycles
1636 ofstream calibCoefFile[nModes][NUMBER_OF_CHANNELS]; //cycle per cycle
1637 for (sa_size_t iMode=0; iMode<nModes; iMode++){
1638 //The file for the Means Coeff.
1639 calibCoefFileName = outputPath_ + "/calib_"
1640 + dateOfRun_ + "_" + StringToLower(sourceName_) + "_"
1641 + modeList[iMode] + "_"
1642 + freqBAOCalibration_ + "MHz-All.txt";
1643 calibMeanCoefFile[iMode].open(calibCoefFileName.c_str());
1644 //The file for the cycle per cycle Coeff.
1645 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; iCh++){
1646 stringstream chString;
1647 chString << iCh;
1648 calibCoefFileName = outputPath_ + "/calib_"
1649 + dateOfRun_ + "_" + StringToLower(sourceName_) + "_"
1650 + modeList[iMode] + "_"
1651 + freqBAOCalibration_ + "MHz-Ch" + chString.str() + "Cycles.txt";
1652 calibCoefFile[iMode][iCh].open(calibCoefFileName.c_str());
1653 }
1654 }
1655
1656 r_4* aCalibEvolEntry;
1657 sa_size_t nCalibEvolEntry = calibEvolution.NEntry();
1658
1659 TMatrix<r_4> meanCalibCoef(nModes,NUMBER_OF_CHANNELS); //by default init to 0
1660 TMatrix<r_4> nData4Mean(nModes,NUMBER_OF_CHANNELS);
1661
1662 //READ the calibration tuple, fill the array for mean and write to ascii file
1663 for (sa_size_t ie=0; ie<nCalibEvolEntry; ie++){
1664 aCalibEvolEntry = calibEvolution.GetVec(ie);
1665 if(debuglev_>1){
1666 cout << "DEBUG mode/cycle/Coef "
1667 << aCalibEvolEntry[outModeIdx] << " "
1668 << aCalibEvolEntry[outCycleIdx] << " ";
1669 }
1670 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; iCh++){
1671 if(debuglev_>1) cout << aCalibEvolEntry[outOffsetCh0+outNDataPerCh*iCh+1] << " "; // for debug
1672 sa_size_t currentMode = (sa_size_t)(aCalibEvolEntry[outModeIdx] - minMode); //ok even if minMode <> 0
1673 nData4Mean(currentMode,iCh)++;
1674 meanCalibCoef(currentMode,iCh) += aCalibEvolEntry[outOffsetCh0+outNDataPerCh*iCh+1];
1675
1676 calibCoefFile[currentMode][iCh] << aCalibEvolEntry[outCycleIdx] << " "
1677 << setprecision(12)
1678 << aCalibEvolEntry[outOffsetCh0+outNDataPerCh*iCh+1]
1679 << endl;
1680 }
1681 if(debuglev_>1) cout << endl; //for debug
1682 }
1683
1684 //Perform means: true means that div per 0 is treated (slower but safer)
1685 meanCalibCoef.Div(nData4Mean,true);
1686
1687 if(debuglev_>0){
1688 cout << "DEBUG nData4Mean" << endl;
1689 nData4Mean.Print(cout);
1690 cout << "DEBUG meanCalibCoef (averaged)" << endl;
1691 meanCalibCoef.Print(cout);
1692 }
1693
1694 //Save means Coef
1695 for (sa_size_t iMode=0; iMode<nModes; iMode++){
1696 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; iCh++){
1697 calibMeanCoefFile[iMode] << setprecision(12)
1698 << meanCalibCoef(iMode,iCh)
1699 << endl;
1700 }
1701 }
1702
1703 //Save Monitor File
1704 {
1705 string fileName = outputPath_ + "/calib_monitor_" + dateOfRun_ + "_" + StringToLower(sourceName_) + ".ppf";
1706 POutPersist calibMonitorFile(fileName);
1707 calibMonitorFile << PPFNameTag("powermoni") << powerEvolution;
1708 calibMonitorFile << PPFNameTag("calibmoni") << calibEvolution;
1709 }
1710
1711 //Clean & Return
1712 for (sa_size_t iMode=0; iMode<nModes; iMode++){
1713 calibMeanCoefFile[iMode].close();
1714 for (sa_size_t iCh=0; iCh<NUMBER_OF_CHANNELS; iCh++){
1715 calibCoefFile[iMode][iCh].close();
1716 }
1717 }
1718
1719 cout << "Ok calibration finished" << endl;
1720 return rc;
1721}//ProcessCalibration::processCmd
1722
Note: See TracBrowser for help on using the repository browser.