source: Sophya/trunk/AddOn/TAcq/branap.cc@ 3883

Last change on this file since 3883 was 3883, checked in by ansari, 15 years ago

1/ Correction bug de lecture ds BRMultiFitsReader et EthernetReader lorsque lecture avec SameFrameCounter etait demande
2/ Amelioration des impressions ds ces deux classes et ajout possibilite de controle du flag "SameFC" avec les classes de parametres BRParList et BRAnaParam
3/ Nouveaux datacard @ethrforcesamefc et @prtlev pour acquisition

Reza, 23/09/2010

File size: 6.9 KB
RevLine 
[3704]1#include <stdlib.h>
2#include <string.h>
3
[3687]4#include "branap.h"
5#include "minifits.h"
6#include "strutilxx.h"
7#include "sopnamsp.h"
8
9//--------------------------------------------------------------
10// Projet BAORadio - (C) LAL/IRFU 2008-2010
11// Classe de gestion des parametres programmes d'analyse
12//--------------------------------------------------------------
13
14/* --Methode-- */
15BRAnaParam::BRAnaParam(uint_4 nmean, uint_4 nzon, uint_4 npaqz)
16{
17 outpath_="./";
18 nmean_=nmean;
[3688]19 nbloc_=1;
[3687]20 imin_=imax_=0;
21 istep_=1;
[3883]22 rdsamefc_=true; // read paquets with same frame counter
[3688]23 freqmin_=freqmax_=0;
24 nbinfreq_=1;
[3687]25 paqsize_=16424;
26 nzones_=nzon;
27 npaqinzone_=npaqz;
[3872]28 fgdatafft_=false; fgsinglechannel_=false;
[3688]29 prtlevel_=0;
[3883]30 prtmodulo_=50000;
[3776]31 nbcalgrp_=1;
[3724]32 nthreads_=1;
[3687]33}
34
35/* --Methode-- */
36int BRAnaParam::DecodeArgs(int narg, char* arg[])
37{
38 if ((narg>1)&&(strcmp(arg[1],"-h")==0)) return Usage(false);
39 if (narg<5) return Usage(true);
40
41 bool okarg=false;
42 int ka=1;
43 while (ka<(narg-1)) {
44 if (strcmp(arg[ka],"-act")==0) {
45 action_=arg[ka+1];
46 ka+=2;
47 }
48 else if (strcmp(arg[ka],"-out")==0) {
49 outpath_=arg[ka+1];
[3688]50 size_t lenp=outpath_.size();
51 if ((lenp>0)&&(outpath_[lenp-1]!='/')) outpath_+='/';
[3687]52 ka+=2;
53 }
54 else if (strcmp(arg[ka],"-nmean")==0) {
55 nmean_=atoi(arg[ka+1]);
56 ka+=2;
57 }
[3688]58 else if (strcmp(arg[ka],"-nbloc")==0) {
59 nbloc_=atoi(arg[ka+1]);
60 ka+=2;
61 }
62 else if (strcmp(arg[ka],"-freq")==0) {
63 sscanf(arg[ka+1],"%d,%d,%d",&freqmin_,&freqmax_,&nbinfreq_);
64 ka+=2;
65 }
[3687]66 else if (strcmp(arg[ka],"-zones")==0) {
67 int nzon=4;
68 int npaqz=128;
69 sscanf(arg[ka+1],"%d,%d",&nzon,&npaqz);
70 nzones_=nzon; npaqinzone_=npaqz;
71 ka+=2;
72 }
[3883]73 else if (strcmp(arg[ka],"-prt")==0) {
74 sscanf(arg[ka+1],"%d,%ld",&prtlevel_,&prtmodulo_);
[3688]75 ka+=2;
76 }
[3724]77 else if (strcmp(arg[ka],"-nthr")==0) {
78 nthreads_=atoi(arg[ka+1]);
79 ka+=2;
80 }
[3776]81 else if (strcmp(arg[ka],"-nvcal")==0) {
82 nbcalgrp_=atoi(arg[ka+1]);
83 ka+=2;
84 }
[3883]85 else if (strcmp(arg[ka],"-nosfc")==0) {
86 rdsamefc_=false;
87 ka++;
88 }
[3687]89 else if (strcmp(arg[ka],"-in")==0) {
90 if ((narg-ka)<4) {
91 cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
92 return Usage(true);
93 }
94 sscanf(arg[ka+1],"%d,%d,%d",&imin_,&imax_,&istep_); ka+=2;
[3688]95 while(ka<(narg-1)) {
[3687]96 string inpath = arg[ka];
[3688]97 size_t lenp=inpath.size();
98 if (lenp<1) inpath="./";
99 if ((lenp>0)&&(inpath[lenp-1]!='/')) inpath+='/';
[3687]100 vector<string> fiblist;
101 string sa1 = arg[ka+1];
102 FillVStringFrString(sa1, fiblist, ',');
103 char dbuff[32];
104 for(size_t i=0; i<fiblist.size(); i++) {
105 sprintf(dbuff,"Fiber%d/",(int)atoi(fiblist[i].c_str()));
106 dirlist_.push_back(inpath+dbuff);
107 }
108 ka += 2;
109 }
110 okarg=true;
111 }
[3688]112 else ka++;
[3687]113 }
[3688]114
[3687]115 if (!okarg) {
116 cout << " BRAnaParam::DecodeArgs() / Argument error " << endl;
117 return Usage(true);
118 }
119 return 0;
120}
121
122/* --Methode-- */
123int BRAnaParam::Usage(bool fgshort)
124{
125 cout << " --- BRAnaParam : Reading/Processing BAORadio FITS files parameters " << endl;
126 cout << " Usage: prgname [-act ACT] [-out OutPath] [-nmean NMean] [-zones NZones,nPaqinZone] \n"
[3724]127 << " [-nbloc NBloc] [-freq NumFreqMin,NumFreqMax,NBinFreq] \n"
[3883]128 << " [-prt lev,modulo] [-nvcal n] [-nthr n] [-nosfc] \n"
[3687]129 << " -in Imin,Imax,Istep InPath FiberList [InPath2 FiberList2 InPath3 FiberList3 ...] \n" << endl;
130 if (fgshort) {
131 cout << " prgname -h for detailed instructions" << endl;
132 return 5;
133 }
[3774]134 cout << " -act Action: cube3d or vis or viscktt or mspec \n"
[3705]135 << " cube3d: create 3D fits cubes, vis: compute visibilites, \n"
[3706]136 << " viscktt: compute visibilities and check TimeTag/FrameCounter\n "
[3774]137 << " mspec: compute and save mean spectra for each channel \n "
[3687]138 << " -out OutPath: Output directory name \n"
139 << " -nmean NMean: Number of packet used for spectra/visibility computation \n"
[3688]140 << " -nbloc NBloc: Number of MemMgr blocs in output file\n"
[3687]141 << " -zones NZones,NbPaqinZone : Number of Zones and number of paquets in one zone \n"
[3688]142 << " -freq NumFreqMin,NumFreqMax,NBinFreq : Frequency zone and number of bins \n"
[3883]143 << " -prt lev,modulo : Print level (0,1,2...) and print counter modulo (10000, 50000 ...) \n"
[3776]144 << " -nvcal n : number of BRVisibilityCalculator objects running in parallel in BRVisCalcGroup (default=1) \n"
145 << " -nthr n : number of threads for parallel execution in BRVisibilityCalculator (default=1) \n"
[3883]146 << " -nosfc : Don't force reading with SAME FrameCounter \n"
[3687]147 << " -in : input files/directory definition : \n"
148 << " Imin,Imax,Istep: fits files signalII.fits Imin<=II<=Imax Istep=increment \n"
149 << " InPath: Input directerory fits files in InPath/FiberJJ directory \n"
150 << " FiberList: List of fiber numbers (JJ - Ex: 2,1,4 ) \n" << endl;
151 return 1;
152}
153
154/* --Fonction-- */
155int BRAnaParam::PaqSizeFromFits()
156{
157 uint_4 paqsz, npaqf;
158 char flnm[1024];
159 sprintf(flnm,"%s/signal%d.fits",dirlist_[0].c_str(),imin_);
[3872]160 return DecodeMiniFitsHeader(flnm,paqsize_, npaqinfile_,fgdatafft_, fgsinglechannel_);
[3687]161}
162
163/* --Fonction-- */
164ostream& BRAnaParam::Print(ostream& os)
165{
166 os << " BRAnaParam::Print() dirlist_.size()=" << dirlist_.size() << " Input directories: " << endl;
167 for(size_t k=0; k< dirlist_.size(); k++)
168 cout << k+1 << " : " << dirlist_[k] << endl;
[3883]169 cout << " IMin= " << imin_ << " IMax= " << imax_ << " IStep= " << istep_
170 << ((rdsamefc_)?" SameFrameCounter read mode":" AllOKPaquets read mode ") << endl;
[3687]171 cout << " OutPath= " << outpath_ << endl;
[3688]172 cout << " Action=" << action_ << " NMean=" << nmean_ << " NBloc=" << nbloc_ << endl;
173 cout << " FreqMin= " << freqmin_ << " FreqMax= " << freqmax_ << " NBinFreq= " << nbinfreq_ << endl;
174 cout << " PaqSize=" << paqsize_ << " - NZones=" << nzones_ << " NPaqZone=" << npaqinzone_
[3883]175 << " PrtLevel=" << prtlevel_ << " PrtCntModulo=" << prtmodulo_ << endl;
[3872]176 cout << " AcqMode: " << ((fgdatafft_)?" Data_FFT " : " Data_Raw " )
177 << ((fgsinglechannel_)?" SingleChannel " : " TwoChannels " ) << endl;
[3776]178 cout << " NbVisibCalculator in Group: " << nbcalgrp_ << " with N//threads: " << nthreads_ << endl;
179
180
[3687]181 return os;
182}
183
184/* --Fonction-- */
[3872]185int BRAnaParam::DecodeMiniFitsHeader(const char* filename, uint_4& paqsz, uint_4& npaq,
186 bool& fgdatafft, bool& fgsinglechannel)
[3687]187{
188 cout << " DecodeMiniFitsHeader - Opening file: " << filename << endl;
189 MiniFITSFile mff(filename, MF_Read);
[3872]190 string acqmode=mff.GetKeyValue("ACQMODE");
[3687]191 cout << "DecodeMiniFitsHeader()... Type=" << mff.DataTypeToString() << " NAxis1=" << mff.NAxis1()
[3872]192 << " NAxis2=" << mff.NAxis2() << " AcqMode=" << acqmode << endl;
[3687]193 paqsz = mff.NAxis1();
194 npaq = mff.NAxis2();
[3872]195 if (acqmode.substr(0,3)=="fft") fgdatafft=true;
196 if (acqmode.find("1c") < acqmode.length()) fgsinglechannel=true;
[3687]197 return 0;
198}
199
Note: See TracBrowser for help on using the repository browser.