1 | #include "racquproc.h"
|
---|
2 |
|
---|
3 | #include <stdlib.h>
|
---|
4 | #include <string.h>
|
---|
5 | #include <unistd.h>
|
---|
6 | #include <fstream>
|
---|
7 | #include <signal.h>
|
---|
8 |
|
---|
9 | #include "pexceptions.h"
|
---|
10 | #include "tvector.h"
|
---|
11 | #include "ntuple.h"
|
---|
12 | #include "datatable.h"
|
---|
13 | #include "histos.h"
|
---|
14 | #include "fioarr.h"
|
---|
15 | #include "matharr.h"
|
---|
16 | #include "timestamp.h"
|
---|
17 | #include "ctimer.h"
|
---|
18 | #include "fftpserver.h"
|
---|
19 | #include "fftwserver.h"
|
---|
20 |
|
---|
21 | #include "FFTW/fftw3.h"
|
---|
22 |
|
---|
23 |
|
---|
24 | #include "pciewrap.h"
|
---|
25 | #include "brpaqu.h"
|
---|
26 | #include "brproc.h"
|
---|
27 |
|
---|
28 | //---------------------------------------------------------------------
|
---|
29 | // Classe de traitement - calcul de visibilite pour n fibres
|
---|
30 | //---------------------------------------------------------------------
|
---|
31 |
|
---|
32 | /* --Methode-- */
|
---|
33 | BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
|
---|
34 | : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr),
|
---|
35 | outpath_(outpath), nmean_(nmean), nbcalc_(1), calcid_(0), vpdata_(2*memgr.NbFibres())
|
---|
36 | // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true);
|
---|
37 | {
|
---|
38 | DefineRank(1,0);
|
---|
39 |
|
---|
40 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
41 | chanum_.SetSize(maxnpairs);
|
---|
42 | sa_size_t k=0;
|
---|
43 | for(size_t i=0; i<2*memgr_.NbFibres(); i++) vpdata_[i]=NULL;
|
---|
44 | for(size_t i=0; i<2*memgr_.NbFibres(); i++) {
|
---|
45 | for(size_t j=i; j<2*memgr_.NbFibres(); j++) {
|
---|
46 | chanum_(k) = (i+1)*100+(j+1); k++;
|
---|
47 | }
|
---|
48 | }
|
---|
49 | SelectPairs();
|
---|
50 |
|
---|
51 | // visdt_.AddFloatColumn("mfc");
|
---|
52 | visdt_.AddDoubleColumn("mfc");
|
---|
53 | visdt_.AddDoubleColumn("mtt");
|
---|
54 | visdt_.AddIntegerColumn("jfreq");
|
---|
55 | visdt_.AddIntegerColumn("numch");
|
---|
56 | visdt_.AddFloatColumn("vre");
|
---|
57 | visdt_.AddFloatColumn("vim");
|
---|
58 |
|
---|
59 | if (nmean_ < 1) nmean_=memgr_.NbPaquets();
|
---|
60 | if (nmean_ < 1) nmean_=1;
|
---|
61 |
|
---|
62 | cout << " BRVisibilityCalculator::/Info nmean=" << nmean_ << endl;
|
---|
63 |
|
---|
64 | totnbpaq_=0;
|
---|
65 | numfile_=0;
|
---|
66 | moyfc_=moytt_=0.;
|
---|
67 |
|
---|
68 | fgallfibok=NULL;
|
---|
69 | fgcktt_=false;
|
---|
70 | }
|
---|
71 |
|
---|
72 | /* --Methode-- */
|
---|
73 | BRVisibilityCalculator::~BRVisibilityCalculator()
|
---|
74 | {
|
---|
75 | cout << " BRVisibilityCalculator - Visibility Datatable : " << endl;
|
---|
76 | cout << visdt_;
|
---|
77 | string filename;
|
---|
78 | filename = outpath_+"visdt.ppf";
|
---|
79 | if (nbcalc_>1) {
|
---|
80 | char sbuff[32];
|
---|
81 | sprintf(sbuff,"visdt_%d",(int)calcid_);
|
---|
82 | filename = outpath_+sbuff;
|
---|
83 | }
|
---|
84 | POutPersist po(filename);
|
---|
85 | po << visdt_;
|
---|
86 | if (calcid_ == 0) {
|
---|
87 | POutPersist poc(outpath_+"chanum.ppf");
|
---|
88 | poc << chanum_;
|
---|
89 |
|
---|
90 | if (fgcktt_) {
|
---|
91 | cout << " BRVisibilityCalculator - Check TimeTag done: TotNPaqProc= " << totnbpaq_ << endl;
|
---|
92 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
93 | cout << " BRTTCheck-Fiber[" << fib << "] NBadTT=" << vbadtt_[fib] << " NDiffTT>5="
|
---|
94 | << vndiff5tt_[fib] << " NotSameTT=" << vnsamett_[fib] << endl;
|
---|
95 | }
|
---|
96 | POutPersist pott(outpath_+"ttfcmtx.ppf");
|
---|
97 | pott << PPFNameTag("FC") << fcmtx_;
|
---|
98 | pott << PPFNameTag("TT") << ttmtx_;
|
---|
99 | }
|
---|
100 | }
|
---|
101 | }
|
---|
102 |
|
---|
103 | /* --Methode-- */
|
---|
104 | void BRVisibilityCalculator::DefineRank(uint_4 nbc, uint_4 cid)
|
---|
105 | {
|
---|
106 | if ((nbc>4)||(cid>=nbc))
|
---|
107 | throw ParmError("BRVisibilityCalculator::DefineRank() NbCalc > 4 !");
|
---|
108 | nbcalc_=nbc;
|
---|
109 | calcid_=cid;
|
---|
110 | if (nbcalc_>1) {
|
---|
111 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
112 | uint_4 npairs=maxnpairs/nbcalc_;
|
---|
113 | if (calcid_==(nbcalc_-1))
|
---|
114 | SelectPairs(calcid_*npairs, maxnpairs-calcid_*npairs);
|
---|
115 | else
|
---|
116 | SelectPairs(calcid_*npairs, npairs);
|
---|
117 | MemZaction mmzas[4]={MemZA_ProcA,MemZA_ProcB,MemZA_ProcC,MemZA_ProcD};
|
---|
118 | SetMemZAction(mmzas[calcid_]);
|
---|
119 | }
|
---|
120 | return ;
|
---|
121 | }
|
---|
122 |
|
---|
123 | /* --Methode-- */
|
---|
124 | uint_4 BRVisibilityCalculator::SelectPairs(uint_4 pair1, uint_4 nbpairs)
|
---|
125 | {
|
---|
126 | BRPaquet paq(memgr_.PaqSize());
|
---|
127 | uint_4 maxnpairs = (2*memgr_.NbFibres()+1)*memgr_.NbFibres();
|
---|
128 |
|
---|
129 | if (pair1 >= maxnpairs) pair1=maxnpairs-1;
|
---|
130 | if (nbpairs > maxnpairs-pair1) nbpairs=maxnpairs-pair1;
|
---|
131 | pairst_=pair1;
|
---|
132 | nbpairs_=nbpairs;
|
---|
133 | vismtx_.SetSize(nbpairs_, paq.DataSize()/4);
|
---|
134 | return nbpairs_;
|
---|
135 | }
|
---|
136 |
|
---|
137 | /* --Methode-- */
|
---|
138 | int BRVisibilityCalculator::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
|
---|
139 | {
|
---|
140 | jf1_=freq1; jf2_=freq2;
|
---|
141 | if ((jf1_<1)||(jf1_>=vismtx_.NCols())) jf1_=1;
|
---|
142 | if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_)) jf2_=vismtx_.NCols()-1;
|
---|
143 | if (nbfreq<1) nbfreq=1;
|
---|
144 | djf_=(jf2_-jf1_)/nbfreq;
|
---|
145 | if (djf_<1) djf_=0;
|
---|
146 | cout << " BRVisibilityCalculator::SelectFreqBinning/Info JF1=" << jf1_
|
---|
147 | << " JF2=" << jf2_ << " DJF=" << djf_ << endl;
|
---|
148 |
|
---|
149 | }
|
---|
150 |
|
---|
151 |
|
---|
152 | /* --Methode-- */
|
---|
153 | int BRVisibilityCalculator::ActivateTimeTagCheck(uint_8 maxnpaq)
|
---|
154 | {
|
---|
155 | mindeltatt_=memgr_.PaqSize()/2;
|
---|
156 | if (mindeltatt_<1) mindeltatt_=1;
|
---|
157 | fcmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
|
---|
158 | ttmtx_.SetSize(memgr_.NbFibres(), maxnpaq);
|
---|
159 | vlasttt_.resize(memgr_.NbFibres(), 0);
|
---|
160 | vbadtt_.resize(memgr_.NbFibres(), 0);
|
---|
161 | vnsamett_.resize(memgr_.NbFibres(), 0);
|
---|
162 | vndiff5tt_.resize(memgr_.NbFibres(), 0);
|
---|
163 |
|
---|
164 | fgcktt_=true;
|
---|
165 | cout << " BRVisibilityCalculator::ActivateTimeTagCheck() - TT/Fc matrix NCols=" << maxnpaq
|
---|
166 | << " MinDeltaTT=" << mindeltatt_ << endl;
|
---|
167 |
|
---|
168 | return 0;
|
---|
169 | }
|
---|
170 |
|
---|
171 |
|
---|
172 | /* --Methode-- */
|
---|
173 | void BRVisibilityCalculator::run()
|
---|
174 | {
|
---|
175 | cout << " BRVisibilityCalculator[" << calcid_ << "/" << nbcalc_
|
---|
176 | << "]::run() - Starting " << " NFibers=" << memgr_.NbFibres()
|
---|
177 | << " NChan=" << 2*memgr_.NbFibres() << " NPairs=" << nbpairs_ << " First:" << pairst_ << endl;
|
---|
178 |
|
---|
179 | if (nparthr_ < 2) return BRBaseProcessor::run();
|
---|
180 | // Execution multithread parallele
|
---|
181 | setRC(1);
|
---|
182 | int rc=0;
|
---|
183 | try {
|
---|
184 | if ((nmean_%memgr_.NbPaquets())!=0) {
|
---|
185 | uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets();
|
---|
186 | cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_ << " to multiple of"
|
---|
187 | << " memgr_.NbPaquets() -> " << mnmean << endl;
|
---|
188 | nmean_=mnmean;
|
---|
189 | }
|
---|
190 | paralex_.SetParallelTask(*this);
|
---|
191 | cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads="
|
---|
192 | << paralex_.nThreads() << " ... " << endl;
|
---|
193 | paralex_.start();
|
---|
194 |
|
---|
195 | fgallfibok = new bool[memgr_.NbPaquets()];
|
---|
196 |
|
---|
197 | size_t paqsz=memgr_.PaqSize();
|
---|
198 | bool fgrun=true;
|
---|
199 | while (fgrun) {
|
---|
200 | if (stop_) break;
|
---|
201 | if (memgr_.GetRunState() == MemZR_Stopped) break;
|
---|
202 | int mid = memgr_.FindMemZoneId(mmact_); // (MemZA_ProcA);
|
---|
203 | Byte* buffg = memgr_.GetMemZone(mid);
|
---|
204 | if (buffg == NULL) {
|
---|
205 | cout << "BRVisibilityCalculator::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
206 | setRC(7); fgrun=false;
|
---|
207 | break;
|
---|
208 | }
|
---|
209 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
210 | fbuff_[fib] = memgr_.GetMemZone(mid,fib);
|
---|
211 | if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver
|
---|
212 | cout << "BRVisibilityCalculator::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl;
|
---|
213 | setRC(9); fgrun=false;
|
---|
214 | break;
|
---|
215 | }
|
---|
216 | }
|
---|
217 |
|
---|
218 | if (totnbpaq_%nmean_ == 0) {
|
---|
219 | if (totnbpaq_ > 0) {
|
---|
220 | moyfc_/=nmean_;
|
---|
221 | moytt_/=nmean_;
|
---|
222 | vismtx_.Info()["MeanFC"] = moyfc_;
|
---|
223 | vismtx_.Info()["MeanTT"] = moytt_;
|
---|
224 | vismtx_.Info()["NPAQSUM"] = nmean_;
|
---|
225 |
|
---|
226 | // ATTENTION : Matrice visibilites non moyennee
|
---|
227 | char nfile[48];
|
---|
228 | if (nbcalc_==1)
|
---|
229 | sprintf(nfile,"vismtx%d.ppf",numfile_);
|
---|
230 | else
|
---|
231 | sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
|
---|
232 | string flnm=outpath_+nfile;
|
---|
233 | POutPersist po(flnm);
|
---|
234 | po << vismtx_;
|
---|
235 | cout << numfile_ << "-BRVisibilityCalculator::run() NPaqProc="
|
---|
236 | << totnbpaq_ << " -> Visibility Matrix in " << flnm << endl;
|
---|
237 | FillVisibTable(moyfc_, moytt_);
|
---|
238 | numfile_++;
|
---|
239 | }
|
---|
240 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
|
---|
241 | moyfc_=moytt_=0.;
|
---|
242 | }
|
---|
243 |
|
---|
244 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
|
---|
245 | fgallfibok[jp]=fgokallfibers_=true;
|
---|
246 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
247 | vpaq_[fib].Set(fbuff_[fib]+jp*paqsz);
|
---|
248 | vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]);
|
---|
249 | if (!vfgok_[fib]) fgallfibok[jp]=fgokallfibers_=false;
|
---|
250 | }
|
---|
251 | if (fgokallfibers_) {
|
---|
252 | if (totprocnpaq_==0) {
|
---|
253 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
254 | fcfirst_[fib]=curfc_[fib];
|
---|
255 | ttfirst_[fib]=vpaq_[fib].TimeTag();
|
---|
256 | }
|
---|
257 | }
|
---|
258 | totprocnpaq_++;
|
---|
259 | moyfc_ += curfc_[0];
|
---|
260 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
261 | if ((fgcktt_)&&(calcid_==0)) CheckTimeTag();
|
---|
262 | totnbpaq_++;
|
---|
263 | }
|
---|
264 | } // Fin de boucle sur les paquets
|
---|
265 |
|
---|
266 | // Execution parallele pour calcul des visibilites par bandes de frequence
|
---|
267 | int rcpex=paralex_.execute();
|
---|
268 | if (rcpex!=0) cout << " BRVisibilityCalculator::run() / Error Rc[paralex_.execute()]=" << rcpex << endl;
|
---|
269 |
|
---|
270 | memgr_.FreeMemZone(mid, mmsta_); // (MemZS_ProcA);
|
---|
271 | } // Fin de boucle sur les zones a traiter
|
---|
272 | //------------------------------------
|
---|
273 | cout << " --------- END BRVisibilityCalculator::run() , TotNbProcPaq=" << totprocnpaq_ << endl;
|
---|
274 | /*
|
---|
275 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) vpchk_[fib].Print();
|
---|
276 | cout << " ------------------------------------ " << endl;
|
---|
277 | */
|
---|
278 | delete[] fgallfibok;
|
---|
279 | }
|
---|
280 | catch (std::exception& exc) {
|
---|
281 | cout << " BRVisibilityCalculator::run()/catched std::exception " << exc.what() << endl;
|
---|
282 | setRC(98);
|
---|
283 | return;
|
---|
284 | }
|
---|
285 | catch(...) {
|
---|
286 | cout << " BRVisibilityCalculator::run()/catched unknown ... exception " << endl;
|
---|
287 | setRC(99);
|
---|
288 | return;
|
---|
289 | }
|
---|
290 |
|
---|
291 | }
|
---|
292 |
|
---|
293 | /* --Methode-- */
|
---|
294 | int BRVisibilityCalculator::Process()
|
---|
295 | {
|
---|
296 |
|
---|
297 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
298 | vpdata_[2*fib] = vpaq_[fib].Data1C();
|
---|
299 | vpdata_[2*fib+1] = vpaq_[fib].Data2C();
|
---|
300 | }
|
---|
301 |
|
---|
302 | if (totnbpaq_%nmean_ == 0) {
|
---|
303 | if (totnbpaq_ > 0) {
|
---|
304 | moyfc_/=nmean_;
|
---|
305 | moytt_/=nmean_;
|
---|
306 | vismtx_.Info()["MeanFC"] = moyfc_;
|
---|
307 | vismtx_.Info()["MeanTT"] = moytt_;
|
---|
308 | vismtx_.Info()["NPAQSUM"] = nmean_;
|
---|
309 |
|
---|
310 | // ATTENTION : Matrice visibilites non moyennee
|
---|
311 | char nfile[48];
|
---|
312 | if (nbcalc_==1)
|
---|
313 | sprintf(nfile,"vismtx%d.ppf",numfile_);
|
---|
314 | else
|
---|
315 | sprintf(nfile,"vismtx_%d_%d.ppf",(int)calcid_,numfile_);
|
---|
316 | string flnm=outpath_+nfile;
|
---|
317 | POutPersist po(flnm);
|
---|
318 | po << vismtx_;
|
---|
319 | cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc="
|
---|
320 | << totnbpaq_ << " -> Visibility Matrix in " << flnm << endl;
|
---|
321 | FillVisibTable(moyfc_, moytt_);
|
---|
322 | numfile_++;
|
---|
323 | }
|
---|
324 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.);
|
---|
325 | moyfc_=moytt_=0.;
|
---|
326 | }
|
---|
327 |
|
---|
328 | sa_size_t k=0;
|
---|
329 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
330 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
331 | size_t kpair=i*vpdata_.size()+j;
|
---|
332 | if (kpair<pairst_) continue;
|
---|
333 | if (kpair>=(pairst_+nbpairs_)) break;
|
---|
334 | TVector< complex<r_4> > vis = vismtx_.Row(k); k++;
|
---|
335 | for(sa_size_t f=1; f<vis.Size(); f++) {
|
---|
336 | vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) *
|
---|
337 | complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB());
|
---|
338 | }
|
---|
339 | }
|
---|
340 | }
|
---|
341 |
|
---|
342 | moyfc_ += curfc_[0];
|
---|
343 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]);
|
---|
344 | if ((fgcktt_)&&(calcid_==0)) CheckTimeTag();
|
---|
345 | totnbpaq_++;
|
---|
346 | return 0;
|
---|
347 | }
|
---|
348 |
|
---|
349 | /* --Methode-- */
|
---|
350 | int BRVisibilityCalculator::execute(int tid)
|
---|
351 | {
|
---|
352 | vector<TwoByteComplex*> pvpdata(2*memgr_.NbFibres());
|
---|
353 | size_t paqsz=memgr_.PaqSize();
|
---|
354 | BRPaquet ppaq(paqsz);
|
---|
355 |
|
---|
356 | sa_size_t fdelt = vismtx_.NCols()/nparthr_;
|
---|
357 | sa_size_t fdeb = tid*fdelt;
|
---|
358 | sa_size_t ffin = (tid+1)*fdelt;
|
---|
359 |
|
---|
360 | if (fdeb<1) fdeb=1;
|
---|
361 | if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols();
|
---|
362 |
|
---|
363 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) { // boucle sur les paquets d'une zone
|
---|
364 | if (!fgallfibok[jp]) continue;
|
---|
365 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
366 | ppaq.Set(fbuff_[fib]+jp*paqsz);
|
---|
367 | pvpdata[2*fib] = ppaq.Data1C();
|
---|
368 | pvpdata[2*fib+1] = ppaq.Data2C();
|
---|
369 | }
|
---|
370 | sa_size_t k=0;
|
---|
371 | for(size_t i=0; i<vpdata_.size(); i++) {
|
---|
372 | for(size_t j=i; j<vpdata_.size(); j++) {
|
---|
373 | size_t kpair=i*vpdata_.size()+j;
|
---|
374 | if (kpair<pairst_) continue;
|
---|
375 | if (kpair>=(pairst_+nbpairs_)) break;
|
---|
376 | TVector< complex<r_4> > vis = vismtx_.Row(k); k++;
|
---|
377 | for(sa_size_t f=fdeb; f<ffin; f++) {
|
---|
378 | vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) *
|
---|
379 | complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB());
|
---|
380 | }
|
---|
381 | }
|
---|
382 | }
|
---|
383 |
|
---|
384 | } // Fin de boucle sur les paquets
|
---|
385 |
|
---|
386 | return 0;
|
---|
387 | }
|
---|
388 |
|
---|
389 | /* --Methode-- */
|
---|
390 | int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm)
|
---|
391 | {
|
---|
392 | double xnt[10];
|
---|
393 | xnt[0]=fcm; xnt[1]=ttm/1.25e8;
|
---|
394 |
|
---|
395 | if (djf_<2) {
|
---|
396 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
|
---|
397 | for(sa_size_t jf=jf1_; jf<jf2_; jf++) {
|
---|
398 | xnt[2]=jf;
|
---|
399 | xnt[3]=chanum_(rv+pairst_);
|
---|
400 | xnt[4]=vismtx_(rv,jf).real()/(r_4)(nmean_);
|
---|
401 | xnt[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_);
|
---|
402 | visdt_.AddRow(xnt);
|
---|
403 | }
|
---|
404 | }
|
---|
405 | }
|
---|
406 | else {
|
---|
407 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) {
|
---|
408 | for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) {
|
---|
409 | r_4 moyreal=0.;
|
---|
410 | r_4 moyimag=0.;
|
---|
411 | sa_size_t jjfmx=jf+djf_;
|
---|
412 | if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols();
|
---|
413 | for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) {
|
---|
414 | moyreal+=vismtx_(rv,jjf).real();
|
---|
415 | moyimag+=vismtx_(rv,jjf).imag();
|
---|
416 | }
|
---|
417 | xnt[2]=jf+djf_/2;
|
---|
418 | xnt[3]=chanum_(rv+pairst_);
|
---|
419 | xnt[4]=moyreal/(r_4)(nmean_*djf_);
|
---|
420 | xnt[5]=moyimag/(r_4)(nmean_*djf_);
|
---|
421 | visdt_.AddRow(xnt);
|
---|
422 | }
|
---|
423 | }
|
---|
424 | }
|
---|
425 | return 0;
|
---|
426 | }
|
---|
427 |
|
---|
428 | /* --Methode-- */
|
---|
429 | int BRVisibilityCalculator::CheckTimeTag()
|
---|
430 | {
|
---|
431 | if (totnbpaq_==0) {
|
---|
432 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
433 | vlasttt_[fib]=ttfirst_[fib];
|
---|
434 | if (ttmtx_.NCols()>0) {
|
---|
435 | fcmtx_(fib,totnbpaq_) = curfc_[fib];
|
---|
436 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib];
|
---|
437 | }
|
---|
438 | }
|
---|
439 | return 0;
|
---|
440 | }
|
---|
441 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) {
|
---|
442 | int_8 ld = (int_8)vpaq_[fib].TimeTag()-(int_8)vlasttt_[fib];
|
---|
443 | int_8 fd = (int_8)vpaq_[fib].TimeTag()-(int_8)ttfirst_[fib]-(int_8)vpaq_[0].TimeTag()+(int_8)ttfirst_[0];
|
---|
444 | /* if ( (ld < mindeltatt_) || (fd<-5) || (fd>5)) { vbadtt_[fib]++; vnsamett_[fib]++; }
|
---|
445 | else {
|
---|
446 | if (fd!=0) vnsamett_[fib]++;
|
---|
447 | }
|
---|
448 | */
|
---|
449 | if (ld < mindeltatt_) vbadtt_[fib]++;
|
---|
450 | else {
|
---|
451 | if (fd != 0) vnsamett_[fib]++;
|
---|
452 | if ((fd<-5)||(fd>5)) vndiff5tt_[fib]++;
|
---|
453 | }
|
---|
454 | vlasttt_[fib]=vpaq_[fib].TimeTag();
|
---|
455 | if (totnbpaq_<ttmtx_.NCols()) {
|
---|
456 | fcmtx_(fib,totnbpaq_) = curfc_[fib];
|
---|
457 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib];
|
---|
458 | }
|
---|
459 | }
|
---|
460 | return 0;
|
---|
461 | }
|
---|
462 |
|
---|
463 | //-------------------------------------------------------------------------------
|
---|
464 | // Classe Groupe (ensemble) de Calculateur de Visibilites, tourant en parallele
|
---|
465 | //-------------------------------------------------------------------------------
|
---|
466 |
|
---|
467 | /* --Methode-- */
|
---|
468 | BRVisCalcGroup::BRVisCalcGroup(size_t nbcalc, RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, size_t nthr)
|
---|
469 | {
|
---|
470 | if ((nbcalc<1)||(nbcalc>4))
|
---|
471 | throw ParmError("BRVisCalcGroup::BRVisCalcGroup NbCalc > 4 !");
|
---|
472 | for(size_t i=0; i<nbcalc; i++) {
|
---|
473 | BRVisibilityCalculator * viscp=new BRVisibilityCalculator(memgr, outpath, nmean, nthr);
|
---|
474 | viscp->DefineRank(nbcalc, i);
|
---|
475 | viscalcp_.push_back(viscp);
|
---|
476 | }
|
---|
477 | }
|
---|
478 | /* --Methode-- */
|
---|
479 | BRVisCalcGroup::~BRVisCalcGroup()
|
---|
480 | {
|
---|
481 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
482 | delete viscalcp_[i];
|
---|
483 | }
|
---|
484 | /* --Methode-- */
|
---|
485 | int BRVisCalcGroup::SelectFreqBinning(uint_4 freq1, uint_4 freq2, uint_4 nbfreq)
|
---|
486 | {
|
---|
487 | int rc=0;
|
---|
488 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
489 | rc=viscalcp_[i]->SelectFreqBinning(freq1, freq2, nbfreq);
|
---|
490 | return rc;
|
---|
491 | }
|
---|
492 | /* --Methode-- */
|
---|
493 | void BRVisCalcGroup::start()
|
---|
494 | {
|
---|
495 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
496 | viscalcp_[i]->start();
|
---|
497 | }
|
---|
498 | /* --Methode-- */
|
---|
499 | void BRVisCalcGroup::join()
|
---|
500 | {
|
---|
501 | for(size_t i=0; i<viscalcp_.size(); i++)
|
---|
502 | viscalcp_[i]->join();
|
---|
503 | }
|
---|
504 |
|
---|
505 |
|
---|
506 | //---------------------------------------------------------------------
|
---|
507 | // Classe de traitement simple - calcul de spectres moyennes / voie
|
---|
508 | //---------------------------------------------------------------------
|
---|
509 | /* --Methode-- */
|
---|
510 | BRMeanSpecCalculator::BRMeanSpecCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean)
|
---|
511 | : BRBaseProcessor(memgr), outpath_(outpath), nmean_(nmean)
|
---|
512 | {
|
---|
513 | BRPaquet paq(memgr_.PaqSize());
|
---|
514 | mspecmtx_.SetSize(2*memgr_.NbFibres(), paq.DataSize()/4);
|
---|
515 | numfile_=0;
|
---|
516 | totnbpaq_=0;
|
---|
517 | }
|
---|
518 |
|
---|
519 | /* --Methode-- */
|
---|
520 | BRMeanSpecCalculator::~BRMeanSpecCalculator()
|
---|
521 | {
|
---|
522 | }
|
---|
523 |
|
---|
524 |
|
---|
525 | /* --Methode-- */
|
---|
526 | int BRMeanSpecCalculator::Process()
|
---|
527 | {
|
---|
528 |
|
---|
529 | if (totnbpaq_%nmean_ == 0) {
|
---|
530 | if (totnbpaq_ > 0) {
|
---|
531 | mspecmtx_.Info()["NPAQSUM"] = nmean_;
|
---|
532 | mspecmtx_ /= (double)nmean_;
|
---|
533 | char nfile[32];
|
---|
534 | sprintf(nfile,"mspecmtx%d.ppf",numfile_);
|
---|
535 | string flnm=outpath_+nfile;
|
---|
536 | POutPersist po(flnm);
|
---|
537 | po << mspecmtx_;
|
---|
538 | cout << numfile_ << "-BRMeanSpecCalculator::Process() NPaqProc="
|
---|
539 | << totnbpaq_ << " -> Mean spectra Matrix in " << flnm << endl;
|
---|
540 | numfile_++;
|
---|
541 | }
|
---|
542 | mspecmtx_ = (r_8)(0.);
|
---|
543 | }
|
---|
544 |
|
---|
545 | sa_size_t k=0;
|
---|
546 | for(size_t i=0; i<(size_t)2*memgr_.NbFibres(); i++) {
|
---|
547 | TwoByteComplex* zp=vpaq_[i/2].Data1C();
|
---|
548 | if (i%2==1) zp=vpaq_[i/2].Data2C();
|
---|
549 | TVector< r_4 > spec = mspecmtx_.Row(k); k++;
|
---|
550 | for(sa_size_t f=1; f<spec.Size(); f++) {
|
---|
551 | spec(f) += zp[f].module2F();
|
---|
552 | }
|
---|
553 | }
|
---|
554 |
|
---|
555 | totnbpaq_++;
|
---|
556 | return 0;
|
---|
557 | }
|
---|
558 |
|
---|
559 |
|
---|
560 | //---------------------------------------------------------------
|
---|
561 | // Classe thread de traitement donnees ADC avec 2 voies par frame
|
---|
562 | //---------------------------------------------------------------
|
---|
563 |
|
---|
564 | // Mutex pour eviter le plantage du a FFTW qui ne semble pas thread-safe
|
---|
565 | static ZMutex* pmutfftw=NULL;
|
---|
566 |
|
---|
567 | /* --Methode-- */
|
---|
568 | BRProcA2C::BRProcA2C(RAcqMemZoneMgr& mem, string& path, bool fgraw, uint_4 nmean,
|
---|
569 | uint_4 nmax, bool fghist, uint_4 nfsmap, bool fgnotrl, int card)
|
---|
570 | : memgr(mem)
|
---|
571 | {
|
---|
572 | fgraw_ = fgraw;
|
---|
573 | nmax_ = nmax;
|
---|
574 | nmean_ = nmean;
|
---|
575 | if (fgraw_) cout << " BRProcA2C::BRProcA2C() - constructeur RAW data - NMean=" << nmean_ << endl;
|
---|
576 | else cout << " BRProcA2C::BRProcA2C() - constructeur FFT data - NMean=" << nmean_ << endl;
|
---|
577 | nfsmap_ = nfsmap;
|
---|
578 | stop_ = false;
|
---|
579 | path_ = path;
|
---|
580 | fgnotrl_ = fgnotrl;
|
---|
581 | fghist_ = fghist;
|
---|
582 | card_ = card;
|
---|
583 | if (pmutfftw==NULL) pmutfftw=new ZMutex;
|
---|
584 | }
|
---|
585 |
|
---|
586 | /* --Methode-- */
|
---|
587 | void BRProcA2C::Stop()
|
---|
588 | {
|
---|
589 | stop_=true;
|
---|
590 | // cout <<" BRProcA2C::Stop ... > STOP " << endl;
|
---|
591 | }
|
---|
592 |
|
---|
593 |
|
---|
594 | static inline r_4 Zmod2(complex<r_4> z)
|
---|
595 | { return (z.real()*z.real()+z.imag()*z.imag()); }
|
---|
596 |
|
---|
597 | static inline string card2name_(int card)
|
---|
598 | {
|
---|
599 | if (card==2) return " (Chan3,4) ";
|
---|
600 | else return " (Chan1,2) ";
|
---|
601 | }
|
---|
602 | /* --Methode-- */
|
---|
603 | void BRProcA2C::run()
|
---|
604 | {
|
---|
605 | setRC(1);
|
---|
606 | try {
|
---|
607 | Timer tm("BRProcA2C", false);
|
---|
608 | TimeStamp ts;
|
---|
609 | BRPaqChecker pcheck(!fgnotrl_); // Verification/comptage des paquets
|
---|
610 |
|
---|
611 | size_t totnbytesout = 0;
|
---|
612 | size_t totnbytesproc = 0;
|
---|
613 |
|
---|
614 | cout << " BRProcA2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
615 | << " NMean=" << nmean_ << card2name_(card_) << endl;
|
---|
616 | cout << " BRProcA2C::run()... - Output Data Path: " << path_ << endl;
|
---|
617 | char fname[512];
|
---|
618 | // sprintf(fname,"%s/proc.log",path_.c_str());
|
---|
619 | // ofstream filog(fname);
|
---|
620 | // filog << " BRProcA2C::run() - starting log file " << ts << endl;
|
---|
621 | // filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
|
---|
622 |
|
---|
623 | /*----DELETE NTuple
|
---|
624 | const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"};
|
---|
625 | NTuple nt(8, nnames);
|
---|
626 | double xnt[10];
|
---|
627 | uint_4 nmnt = 0;
|
---|
628 | double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
|
---|
629 | ----*/
|
---|
630 | // Time sample (raw data) /FFT coeff histograms
|
---|
631 | Histo* ph1=NULL;
|
---|
632 | Histo* ph2=NULL;
|
---|
633 | if (fghist_) {
|
---|
634 | if (fgraw_) {
|
---|
635 | ph1 = new Histo(-0.5, 255.5, 256);
|
---|
636 | ph2 = new Histo(-0.5, 255.5, 256);
|
---|
637 | }
|
---|
638 | else {
|
---|
639 | ph1 = new Histo(-128.5, 128.5, 257);
|
---|
640 | ph2 = new Histo(-128.5, 128.5, 257);
|
---|
641 | }
|
---|
642 | }
|
---|
643 |
|
---|
644 | // Initialisation pour calcul FFT
|
---|
645 | TVector< complex<r_4> > cfour1; // composant TF
|
---|
646 | uint_4 paqsz = memgr.PaqSize();
|
---|
647 | uint_4 procpaqsz = memgr.ProcPaqSize();
|
---|
648 |
|
---|
649 |
|
---|
650 | BRPaquet pq(NULL, NULL, paqsz);
|
---|
651 | TVector<r_4> vx(pq.DataSize()/2);
|
---|
652 | int szfour = pq.DataSize()/2/2+1;
|
---|
653 | cfour1.SetSize(szfour);
|
---|
654 | /*
|
---|
655 | vx = (r_4)(0.);
|
---|
656 | FFTPackServer ffts;
|
---|
657 | ffts.FFTForward(vx, cfour1);
|
---|
658 | szfour = cfour1.Size();
|
---|
659 | */
|
---|
660 |
|
---|
661 | bool fgtimfreq = false; // true->cartes temps<>frequences
|
---|
662 | if (nfsmap_>0) fgtimfreq=true;
|
---|
663 |
|
---|
664 | TVector< complex<r_4> > cfour2(cfour1.Size());
|
---|
665 |
|
---|
666 | TVector<r_4> spectreV1(cfour1.Size());
|
---|
667 | TVector<r_4> spectreV2(cfour1.Size());
|
---|
668 | TVector<r_4> moyspecV1(cfour1.Size()); // Moyenne des Spectres
|
---|
669 | TVector<r_4> moyspecV2(cfour1.Size());
|
---|
670 | TVector<r_4> sigspecV1(cfour1.Size()); // Sigma des Spectres
|
---|
671 | TVector<r_4> sigspecV2(cfour1.Size());
|
---|
672 | TVector< complex<r_4> > visiV12( cfour1.Size() );
|
---|
673 |
|
---|
674 | TMatrix<r_4> timfreqV1, timfreqV2; // Cartes temps<>frequences
|
---|
675 | if (fgtimfreq) {
|
---|
676 | timfreqV1.SetSize(nmean_, spectreV1.Size()/nfsmap_);
|
---|
677 | timfreqV2.SetSize(nmean_, spectreV2.Size()/nfsmap_);
|
---|
678 | }
|
---|
679 | cout << " *DBG*BRProcA2C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
|
---|
680 | << " procpaqsz/2=" << procpaqsz/2 << " cfour1.Size()=" << cfour1.Size()
|
---|
681 | << " *8=" << cfour1.Size()*8 << endl;
|
---|
682 |
|
---|
683 | pmutfftw->lock();
|
---|
684 | fftwf_plan plan1 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
|
---|
685 | (fftwf_complex*)cfour1.Data(), FFTW_ESTIMATE);
|
---|
686 | fftwf_plan plan2 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
|
---|
687 | (fftwf_complex*)cfour2.Data(), FFTW_ESTIMATE);
|
---|
688 | pmutfftw->unlock();
|
---|
689 |
|
---|
690 | uint_4 ifile = 0;
|
---|
691 | uint_4 nzm = 0; // Nb de paquets moyennes pour le calcul de chaque spectre
|
---|
692 | uint_4 nmoyspec = 0; // Nb de spectres moyennes
|
---|
693 |
|
---|
694 | uint_4 curfc=0;
|
---|
695 | uint_8 curtt=0;
|
---|
696 | uint_8 firsttt=0;
|
---|
697 | bool fgfirst=true;
|
---|
698 | double moysig[2]={0.,0.};
|
---|
699 | double sigsig[2]={0.,0.};
|
---|
700 | uint_8 nbsig[2]={0,0};
|
---|
701 |
|
---|
702 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
703 | if (stop_) break;
|
---|
704 | int mid = memgr.FindMemZoneId(MemZA_ProcA);
|
---|
705 | Byte* buff = memgr.GetMemZone(mid);
|
---|
706 | if (buff == NULL) {
|
---|
707 | cout << " BRProcA2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
|
---|
708 | break;
|
---|
709 | }
|
---|
710 | Byte* procbuff = memgr.GetProcMemZone(mid);
|
---|
711 | if (procbuff == NULL) {
|
---|
712 | cout << " BRProcA2C::run()/ERROR memgr.GetProcMemZone(" << mid << ") -> NULL" << endl;
|
---|
713 | break;
|
---|
714 | }
|
---|
715 | //---- DELETE nmnt=0; ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
|
---|
716 | for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
|
---|
717 | BRPaquet paq(NULL, buff+i*paqsz, paqsz);
|
---|
718 | if (!pcheck.Check(paq)) continue; // on ne traite que les paquets OK
|
---|
719 | if (fgfirst) { firsttt=paq.TimeTag(); fgfirst=false; }
|
---|
720 | curfc=paq.FrameCounter();
|
---|
721 | curtt=paq.TimeTag()-firsttt;
|
---|
722 | // Traitement voie 1
|
---|
723 | if (fghist_) {
|
---|
724 | for(sa_size_t j=0; j<vx.Size(); j++) {
|
---|
725 | r_4 vts=(fgraw_)?((r_4)(*(paq.Data1()+j))):((r_4)(*(paq.Data1S()+j)));
|
---|
726 | ph1->Add((r_8)vts);
|
---|
727 | moysig[0] += (double)vts;
|
---|
728 | sigsig[0] += ((double)vts)*((double)vts);
|
---|
729 | nbsig[0]++;
|
---|
730 | }
|
---|
731 | for(sa_size_t j=0; j<vx.Size(); j++) {
|
---|
732 | r_4 vts=(fgraw_)?((r_4)(*(paq.Data2()+j))):((r_4)(*(paq.Data2S()+j)));
|
---|
733 | ph2->Add((r_8)vts);
|
---|
734 | moysig[1] += (double)vts;
|
---|
735 | sigsig[1] += ((double)vts)*((double)vts);
|
---|
736 | nbsig[1]++;
|
---|
737 | }
|
---|
738 | }
|
---|
739 | if (fgraw_) {
|
---|
740 | for(sa_size_t j=0; j<vx.Size(); j++)
|
---|
741 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
|
---|
742 | // fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
|
---|
743 | fftwf_execute(plan1);
|
---|
744 | // Traitement voie 2
|
---|
745 | for(sa_size_t j=0; j<vx.Size(); j++)
|
---|
746 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
|
---|
747 | fftwf_execute(plan2);
|
---|
748 | }
|
---|
749 | else {
|
---|
750 | for(sa_size_t j=1; j<cfour1.Size()-1; j++) {
|
---|
751 | cfour1(j) = complex<r_4>((r_4)paq.Data1C()[j].realB(), (r_4)paq.Data1C()[j].imagB());
|
---|
752 | cfour2(j) = complex<r_4>((r_4)paq.Data2C()[j].realB(), (r_4)paq.Data2C()[j].imagB());
|
---|
753 | }
|
---|
754 | cfour1(0) = complex<r_4>((r_4)paq.Data1C()[0].realB(), (r_4)0.);
|
---|
755 | cfour1(cfour1.Size()-1) = complex<r_4>((r_4)paq.Data1C()[0].imagB(), (r_4)0.);
|
---|
756 | cfour2(0) = complex<r_4>((r_4)paq.Data2C()[0].realB(), (r_4)0.);
|
---|
757 | cfour2(cfour2.Size()-1) = complex<r_4>((r_4)paq.Data2C()[0].imagB(), (r_4)0.);
|
---|
758 | }
|
---|
759 | for(sa_size_t j=0; j<spectreV1.Size(); j++)
|
---|
760 | spectreV1(j) += Zmod2(cfour1(j));
|
---|
761 | memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
|
---|
762 | if (fgtimfreq) { // Remplissage tableau temps-frequence
|
---|
763 | for(sa_size_t c=1; c<timfreqV1.NCols(); c++) {
|
---|
764 | for(sa_size_t j=c*nfsmap_; j<(c+1)*nfsmap_; j++)
|
---|
765 | timfreqV1(nzm, c) += Zmod2(cfour1(j));
|
---|
766 | }
|
---|
767 | }
|
---|
768 | for(sa_size_t j=0; j<spectreV2.Size(); j++)
|
---|
769 | spectreV2(j) += Zmod2(cfour2(j)); // Zmod2(zp2[j]);
|
---|
770 | memcpy(procbuff+i*procpaqsz+procpaqsz/2, cfour2.Data(), sizeof(complex<r_4>)*cfour2.Size());
|
---|
771 | if (fgtimfreq) { // Remplissage tableau temps-frequence
|
---|
772 | for(sa_size_t c=1; c<timfreqV2.NCols(); c++) {
|
---|
773 | for(sa_size_t j=c*nfsmap_; j<(c+1)*nfsmap_; j++)
|
---|
774 | timfreqV2(nzm,c) += Zmod2(cfour2(j));
|
---|
775 | }
|
---|
776 | }
|
---|
777 |
|
---|
778 | // Calcul correlation (visibilite V1 * V2)
|
---|
779 | for(sa_size_t j=0; j<visiV12.Size(); j++)
|
---|
780 | visiV12(j)+=cfour1(j)*conj(cfour2(j));
|
---|
781 | // for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
|
---|
782 | if (nzm==0) {
|
---|
783 | spectreV1.Info()["StartFC"] = curfc;
|
---|
784 | spectreV2.Info()["StartFC"] = curfc;
|
---|
785 | visiV12.Info()["StartFC"] = curfc;
|
---|
786 | spectreV1.Info()["StartTT"] = curtt;
|
---|
787 | spectreV2.Info()["StartTT"] = curtt;
|
---|
788 | visiV12.Info()["StartTT"] = curtt;
|
---|
789 | }
|
---|
790 | nzm++;
|
---|
791 | /*----DELETE
|
---|
792 | if (nmnt==0) { xnt[0]=paq.FrameCounter(); xnt[1]=paq.TimeTag(); }
|
---|
793 | for(sa_size_t j=2700; j<2800; j++) {
|
---|
794 | ms1 += Zmod2(cfour1(j)); ms2 += Zmod2(cfour2(j));
|
---|
795 | complex<r_4> zvis = cfour1(j)*conj(cfour2(j));
|
---|
796 | ms12 += Zmod2(zvis); ms12re += zvis.real(); ms12im += zvis.imag();
|
---|
797 | ms12phi+= atan2(zvis.imag(),zvis.real());
|
---|
798 | }
|
---|
799 | nmnt++;
|
---|
800 | ----*/
|
---|
801 | totnbytesproc += paq.DataSize();
|
---|
802 | totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size());
|
---|
803 |
|
---|
804 | } // Fin de boucle sur les paquets d'une zone
|
---|
805 |
|
---|
806 | /*---- DELETE
|
---|
807 | if (nmnt>0) {
|
---|
808 | double fnorm = (double)nmnt*(2800-2700);
|
---|
809 | xnt[2] = ms1 /= fnorm;
|
---|
810 | xnt[3] = ms2 /= fnorm;
|
---|
811 | xnt[4] = ms12 /= fnorm;
|
---|
812 | xnt[5] = ms12re /= fnorm;
|
---|
813 | xnt[6] = ms12im /= fnorm;
|
---|
814 | xnt[7] = ms12phi /= fnorm;
|
---|
815 | nt.Fill(xnt);
|
---|
816 | }
|
---|
817 | ----*/
|
---|
818 | if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
|
---|
819 | spectreV1 /= (r_4)(nzm);
|
---|
820 | spectreV2 /= (r_4)(nzm);
|
---|
821 |
|
---|
822 | // pour le calcul des moyennes et sigmas de ces spectres
|
---|
823 | moyspecV1 += spectreV1;
|
---|
824 | moyspecV2 += spectreV2;
|
---|
825 | sigspecV1 += (spectreV1 && spectreV1);
|
---|
826 | sigspecV2 += (spectreV2 && spectreV2);
|
---|
827 | nmoyspec++;
|
---|
828 |
|
---|
829 | visiV12 /= complex<r_4>((r_4)nzm, 0.);
|
---|
830 |
|
---|
831 | spectreV1.Info()["NPaqMoy"] = nzm;
|
---|
832 | spectreV2.Info()["NPaqMoy"] = nzm;
|
---|
833 | visiV12.Info()["NPaqMoy"] = nzm;
|
---|
834 | spectreV1.Info()["EndFC"] = curfc;
|
---|
835 | spectreV2.Info()["EndFC"] = curfc;
|
---|
836 | visiV12.Info()["EndFC"] = curfc;
|
---|
837 | spectreV1.Info()["EndTT"] = curtt;
|
---|
838 | spectreV2.Info()["EndTT"] = curtt;
|
---|
839 | visiV12.Info()["EndTT"] = curtt;
|
---|
840 | {
|
---|
841 | sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
|
---|
842 | POutPersist po(fname);
|
---|
843 | string tag1="specV1";
|
---|
844 | string tag2="specV2";
|
---|
845 | string tag12="visiV12";
|
---|
846 | string tagh1="tshV1";
|
---|
847 | string tagh2="tshV2";
|
---|
848 | string tagtf1="timfreqV1";
|
---|
849 | string tagtf2="timfreqV2";
|
---|
850 | if (card_==2) {
|
---|
851 | tag1 = "specV3";
|
---|
852 | tag2 = "specV4";
|
---|
853 | tagh1 = "tshV1";
|
---|
854 | tagh2 = "tshV2";
|
---|
855 | tag12="visiV34";
|
---|
856 | tagtf1="timfreqV3";
|
---|
857 | tagtf2="timfreqV4";
|
---|
858 | }
|
---|
859 | po << PPFNameTag(tag1) << spectreV1;
|
---|
860 | po << PPFNameTag(tag2) << spectreV2;
|
---|
861 | po << PPFNameTag(tag12) << visiV12;
|
---|
862 | if (fghist_) {
|
---|
863 | po << PPFNameTag(tagh1) << (*ph1);
|
---|
864 | po << PPFNameTag(tagh2) << (*ph2);
|
---|
865 |
|
---|
866 | double sspvmax[3] = {0.,0.,0.};
|
---|
867 | int_4 sspvmaxidx[3] = {-1,-1,-1};
|
---|
868 | for(int jji=1;jji<visiV12.Size()-1;jji++) {
|
---|
869 | r_4 zmv2 = Zmod2(visiV12(jji));
|
---|
870 | if (zmv2>sspvmax[2]) { sspvmax[2]=zmv2; sspvmaxidx[2]=jji; }
|
---|
871 | }
|
---|
872 | TVector<r_4>& sspv = spectreV1;
|
---|
873 | for(int ic=0; ic<2; ic++) {
|
---|
874 | if (ic==1) sspv = spectreV2;
|
---|
875 | for(int jji=1;jji<sspv.Size()-1;jji++)
|
---|
876 | if (sspv(jji)>sspvmax[ic]) { sspvmax[ic]=sspv(jji); sspvmaxidx[ic]=jji; }
|
---|
877 | if (nbsig[ic] < 1) { moysig[ic]=sigsig[ic]=-1.; }
|
---|
878 | else {
|
---|
879 | moysig[ic] /= (double)nbsig[ic];
|
---|
880 | sigsig[ic] /= (double)nbsig[ic];
|
---|
881 | sigsig[ic] -= (moysig[ic]*moysig[ic]);
|
---|
882 | sigsig[ic] = sqrt(sigsig[ic]);
|
---|
883 | cout << "===Voie " << ic << " Moy=" << moysig[ic] << " Sig=" << sigsig[ic]
|
---|
884 | << " MaxSpec Amp= " << sqrt(sspvmax[ic])/double(pq.DataSize()/2/2)
|
---|
885 | << " Pos=" << sspvmaxidx[ic] << " (NPts=" << nbsig[ic] << ")" << endl;
|
---|
886 | }
|
---|
887 | }
|
---|
888 | cout << "=== Voie1x2 MaxSpec Amp= " << sqrt(sqrt(sspvmax[2])/double(pq.DataSize()/2/2))
|
---|
889 | << " Pos=" << sspvmaxidx[2] << endl;
|
---|
890 | } // fin if (fghist_)
|
---|
891 |
|
---|
892 | if (fgtimfreq) {
|
---|
893 | timfreqV1 /= (r_4)nzm;
|
---|
894 | timfreqV2 /= (r_4)nzm;
|
---|
895 | po << PPFNameTag(tagtf1) << timfreqV1;
|
---|
896 | po << PPFNameTag(tagtf2) << timfreqV2;
|
---|
897 | }
|
---|
898 | }
|
---|
899 | spectreV1 = (r_4)(0.);
|
---|
900 | spectreV2 = (r_4)(0.);
|
---|
901 | visiV12 = complex<r_4>(0., 0.);
|
---|
902 | if (fghist_) {
|
---|
903 | ph1->Zero();
|
---|
904 | ph2->Zero();
|
---|
905 | moysig[0]=moysig[1]=0.;
|
---|
906 | sigsig[0]=sigsig[1]=0.;
|
---|
907 | nbsig[0]=nbsig[1]=0;
|
---|
908 | }
|
---|
909 | if (fgtimfreq) {
|
---|
910 | timfreqV1 = (r_4)(0.);
|
---|
911 | timfreqV2 = (r_4)(0.);
|
---|
912 | }
|
---|
913 | nzm = 0; ifile++;
|
---|
914 | // ts.SetNow();
|
---|
915 | // filog << ts << " : proc file " << fname << endl;
|
---|
916 | cout << " BRProcA2C::run() created file " << fname << card2name_(card_) << endl;
|
---|
917 | }
|
---|
918 |
|
---|
919 | memgr.FreeMemZone(mid, MemZS_ProcA);
|
---|
920 | } // Fin de boucle sur les zones a traiter
|
---|
921 | cout << " ------------ BRProcA2C::run() END " << card2name_(card_)
|
---|
922 | << " ------------ " << endl;
|
---|
923 | /*---- DELETE
|
---|
924 | {
|
---|
925 | nt.Info()["FirstTT"]=firsttt;
|
---|
926 | cout << nt;
|
---|
927 | sprintf(fname,"%s_nt.ppf",path_.c_str());
|
---|
928 | POutPersist po(fname);
|
---|
929 | po << PPFNameTag("ntv12") << nt;
|
---|
930 | cout << " BRProcA2C::run() created NTuple file " << fname << card2name_(card_) << endl;
|
---|
931 | }
|
---|
932 | ---- */
|
---|
933 | if (nmoyspec>0) { // Calcul des moyennes et sigmas des spectres
|
---|
934 | r_4 fnms = nmoyspec;
|
---|
935 | moyspecV1 /= fnms;
|
---|
936 | moyspecV2 /= fnms;
|
---|
937 | sigspecV1 /= fnms;
|
---|
938 | sigspecV2 /= fnms;
|
---|
939 | sigspecV1 -= (moyspecV1 && moyspecV1);
|
---|
940 | sigspecV2 -= (moyspecV2 && moyspecV2);
|
---|
941 | sigspecV1 = Sqrt(sigspecV1);
|
---|
942 | sigspecV2 = Sqrt(sigspecV2);
|
---|
943 | TVector<r_4> rsbV1, rsbV2; // Rapport signal/bruit
|
---|
944 | moyspecV1.DivElt(sigspecV1, rsbV1, false, true);
|
---|
945 | moyspecV2.DivElt(sigspecV2, rsbV2, false, true);
|
---|
946 | sprintf(fname,"%s_ms.ppf",path_.c_str());
|
---|
947 | POutPersist po(fname);
|
---|
948 | po << PPFNameTag("moyspecV1") << moyspecV1;
|
---|
949 | po << PPFNameTag("moyspecV2") << moyspecV2;
|
---|
950 | po << PPFNameTag("sigspecV1") << sigspecV1;
|
---|
951 | po << PPFNameTag("sigspecV2") << sigspecV2;
|
---|
952 | po << PPFNameTag("rsbV1") << rsbV1;
|
---|
953 | po << PPFNameTag("rsbV2") << rsbV2;
|
---|
954 | cout << " BRProcA2C::run() created moysigspec file " << fname << card2name_(card_) << endl;
|
---|
955 | }
|
---|
956 |
|
---|
957 | if (fghist_) {
|
---|
958 | delete ph1;
|
---|
959 | delete ph2;
|
---|
960 | }
|
---|
961 | ts.SetNow();
|
---|
962 | tm.SplitQ();
|
---|
963 | cout << " TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= "
|
---|
964 | << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s"
|
---|
965 | << " ProcDataOut=" << totnbytesout/(1024*1024) << " MB" << endl;
|
---|
966 | cout << pcheck;
|
---|
967 | cout << " BRProcA2C::run()/Timing: " << card2name_(card_) << endl;
|
---|
968 | tm.Print();
|
---|
969 | cout << " ---------------------------------------------------------- " << endl;
|
---|
970 |
|
---|
971 | }
|
---|
972 | catch (PException& exc) {
|
---|
973 | cout << " BRProcA2C::run()/catched PException " << exc.Msg() << endl;
|
---|
974 | setRC(3);
|
---|
975 | return;
|
---|
976 | }
|
---|
977 | catch(...) {
|
---|
978 | cout << " BRProcA2C::run()/catched unknown ... exception " << endl;
|
---|
979 | setRC(4);
|
---|
980 | return;
|
---|
981 | }
|
---|
982 | setRC(0);
|
---|
983 | return;
|
---|
984 | }
|
---|
985 |
|
---|
986 | //---------------------------------------------------------------------
|
---|
987 | // Classe thread de traitement 2 x 2 voies/frames (Apres BRProcA2C)
|
---|
988 | //---------------------------------------------------------------------
|
---|
989 |
|
---|
990 | /* --Methode-- */
|
---|
991 | BRProcB4C::BRProcB4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, string& path,
|
---|
992 | bool fgraw, uint_4 nmean, uint_4 nmax, bool fgnotrl)
|
---|
993 | : memgr1(mem1), memgr2(mem2)
|
---|
994 | {
|
---|
995 | fgraw_ = fgraw;
|
---|
996 | nmax_ = nmax;
|
---|
997 | nmean_ = nmean;
|
---|
998 | if (fgraw_) cout << " BRProcB4C::BRProcB4C() - constructeur RAW data - NMean= " << nmean_ << endl;
|
---|
999 | else cout << " BRProcB4C::BRProcB4C() - constructeur FFT data - NMean= " << nmean_ << endl;
|
---|
1000 | stop_ = false;
|
---|
1001 | path_ = path;
|
---|
1002 | fgnotrl_ = fgnotrl;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | /* --Methode-- */
|
---|
1006 | void BRProcB4C::Stop()
|
---|
1007 | {
|
---|
1008 | stop_=true;
|
---|
1009 | // cout <<" BRProcB4C::Stop ... > STOP " << endl;
|
---|
1010 | }
|
---|
1011 |
|
---|
1012 |
|
---|
1013 | /* --Methode-- */
|
---|
1014 | void BRProcB4C::run()
|
---|
1015 | {
|
---|
1016 | setRC(1);
|
---|
1017 | try {
|
---|
1018 | Timer tm("BRProcB4C", false);
|
---|
1019 | TimeStamp ts;
|
---|
1020 | BRPaqChecker pcheck1(!fgnotrl_); // Verification/comptage des paquets
|
---|
1021 | BRPaqChecker pcheck2(!fgnotrl_); // Verification/comptage des paquets
|
---|
1022 |
|
---|
1023 | size_t totnbytesout = 0;
|
---|
1024 | size_t totnbytesproc = 0;
|
---|
1025 |
|
---|
1026 | cout << " BRProcB4C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
|
---|
1027 | << " NMean=" << nmean_ << endl;
|
---|
1028 | cout << " BRProcB4C::run()... - Output Data Path: " << path_ << endl;
|
---|
1029 |
|
---|
1030 | uint_4 paqsz = memgr1.PaqSize();
|
---|
1031 | uint_4 procpaqsz = memgr1.ProcPaqSize();
|
---|
1032 | if ((paqsz != memgr2.PaqSize())||(procpaqsz!= memgr2.ProcPaqSize())) {
|
---|
1033 | cout << "BRProcB4C::run()/ERROR : different paquet size -> stop \n ...(PaqSz1="
|
---|
1034 | << paqsz << " Sz2=" << memgr2.PaqSize() << " ProcPaqSz1="
|
---|
1035 | << procpaqsz << " Sz2=" << memgr2.ProcPaqSize() << " )" << endl;
|
---|
1036 | setRC(9);
|
---|
1037 | return;
|
---|
1038 | }
|
---|
1039 |
|
---|
1040 | TVector< complex<r_4> > cfour; // composant TF
|
---|
1041 | BRPaquet pq(NULL, NULL, paqsz);
|
---|
1042 | /*
|
---|
1043 | TVector<r_4> vx(pq.DataSize()/2);
|
---|
1044 | vx = (r_4)(0.);
|
---|
1045 | FFTPackServer ffts;
|
---|
1046 | ffts.FFTForward(vx, cfour);
|
---|
1047 |
|
---|
1048 | TVector< complex<r_4> > visiV13( cfour.Size() );
|
---|
1049 | TVector< complex<r_4> > visiV14( cfour.Size() );
|
---|
1050 | TVector< complex<r_4> > visiV23( cfour.Size() );
|
---|
1051 | TVector< complex<r_4> > visiV24( cfour.Size() );
|
---|
1052 | */
|
---|
1053 | int szfour = pq.DataSize()/2/2+1;
|
---|
1054 | // int szfour = (paqsz-40)/2+1;
|
---|
1055 | TVector< complex<r_4> > visiV13( szfour );
|
---|
1056 | TVector< complex<r_4> > visiV14( szfour );
|
---|
1057 | TVector< complex<r_4> > visiV23( szfour );
|
---|
1058 | TVector< complex<r_4> > visiV24( szfour );
|
---|
1059 | // cout << " *DBG*AAAAA ---- Vectors OK" << endl;
|
---|
1060 | cout << " *DBG*BRProcB4C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
|
---|
1061 | << " procpaqsz/2=" << procpaqsz/2 << " cfour.Size()=" << szfour
|
---|
1062 | << " *8=" << szfour*8 << endl;
|
---|
1063 |
|
---|
1064 | DataTable dt;
|
---|
1065 | dt.AddLongColumn("fc1");
|
---|
1066 | dt.AddLongColumn("tt1");
|
---|
1067 | dt.AddLongColumn("fc2");
|
---|
1068 | dt.AddLongColumn("tt2");
|
---|
1069 | DataTableRow dtr = dt.EmptyRow();
|
---|
1070 |
|
---|
1071 | uint_4 nzm = 0;
|
---|
1072 | uint_4 totnoksfc = 0;
|
---|
1073 | uint_4 totnokpaq = 0;
|
---|
1074 | uint_4 totnpaq = 0;
|
---|
1075 | uint_4 ifile = 0;
|
---|
1076 |
|
---|
1077 | uint_4 curfc=0;
|
---|
1078 | uint_8 curtt=0;
|
---|
1079 | uint_4 curfc2=0;
|
---|
1080 | uint_8 curtt2=0;
|
---|
1081 | uint_8 firsttt=0;
|
---|
1082 | uint_8 firsttt2=0;
|
---|
1083 | bool fgfirst=true;
|
---|
1084 | for (uint_4 kmz=0; kmz<nmax_; kmz++) {
|
---|
1085 | uint_4 noksfc = 0;
|
---|
1086 | uint_4 nokpaq = 0;
|
---|
1087 | if (stop_) break;
|
---|
1088 | // cout << " *DBG*BBBBB" << kmz << endl;
|
---|
1089 |
|
---|
1090 | int mid1 = memgr1.FindMemZoneId(MemZA_ProcB);
|
---|
1091 | Byte* buff1 = memgr1.GetMemZone(mid1);
|
---|
1092 | if (buff1 == NULL) {
|
---|
1093 | cout << " BRProcB4C::run()/ERROR memgr.GetMemZone(" << mid1 << ") -> NULL" << endl;
|
---|
1094 | break;
|
---|
1095 | }
|
---|
1096 | Byte* procbuff1 = memgr1.GetProcMemZone(mid1);
|
---|
1097 | if (procbuff1 == NULL) {
|
---|
1098 | cout << " BRProcB4C::run()/ERROR memgr.GetProcMemZone(" << mid1 << ") -> NULL" << endl;
|
---|
1099 | break;
|
---|
1100 | }
|
---|
1101 | int mid2 = memgr2.FindMemZoneId(MemZA_ProcB);
|
---|
1102 | Byte* buff2 = memgr2.GetMemZone(mid2);
|
---|
1103 | if (buff1 == NULL) {
|
---|
1104 | cout << " BRProcB4C::run()/ERROR memgr.GetMemZone(" << mid2 << ") -> NULL" << endl;
|
---|
1105 | break;
|
---|
1106 | }
|
---|
1107 | Byte* procbuff2 = memgr2.GetProcMemZone(mid2);
|
---|
1108 | if (procbuff2 == NULL) {
|
---|
1109 | cout << " BRProcB4C::run()/ERROR memgr.GetProcMemZone(" << mid2 << ") -> NULL" << endl;
|
---|
1110 | break;
|
---|
1111 | }
|
---|
1112 | uint_4 i1,i2;
|
---|
1113 | i1=i2=0;
|
---|
1114 | // cout << " *DBG*CCCCCC " << kmz << " memgr1.NbPaquets() =" << memgr1.NbPaquets() << endl;
|
---|
1115 | while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) {
|
---|
1116 | BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz);
|
---|
1117 | BRPaquet paq2(NULL, buff2+i2*paqsz, paqsz);
|
---|
1118 | totnpaq++;
|
---|
1119 | // cout << " DBG["<<kmz<<"] i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
|
---|
1120 | //<<","<<paq2.FrameCounter()<<endl;
|
---|
1121 | // on ne traite que les paquets OK
|
---|
1122 | if (!pcheck1.Check(paq1)) { i1++; continue; }
|
---|
1123 | if (!pcheck2.Check(paq2)) { i2++; continue; }
|
---|
1124 | nokpaq++;
|
---|
1125 | if (paq1.FrameCounter()<paq2.FrameCounter()) { i1++; continue; }
|
---|
1126 | if (paq2.FrameCounter()<paq1.FrameCounter()) { i2++; continue; }
|
---|
1127 | // cout << " DBG["<<kmz<<"]OKOK i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
|
---|
1128 | // <<","<<paq2.FrameCounter()<<endl;
|
---|
1129 |
|
---|
1130 | if ((i1>=memgr1.NbPaquets())||(i2>=memgr1.NbPaquets())) {
|
---|
1131 | cout << " *BUG*BUG i1=" << i1 << " i2=" << i2 << endl;
|
---|
1132 | break;
|
---|
1133 | }
|
---|
1134 | // Les deux framecounters sont identiques ...
|
---|
1135 | noksfc++;
|
---|
1136 | curfc=paq1.FrameCounter();
|
---|
1137 | curfc2=paq2.FrameCounter();
|
---|
1138 | if (fgfirst) {
|
---|
1139 | firsttt=paq1.TimeTag(); firsttt2=paq2.TimeTag();
|
---|
1140 | cout << " BRProcB4C()/Info First FC="<<curfc<<" , "<<curfc2<<" -> TT="
|
---|
1141 | << firsttt<<" , "<<firsttt2 <<endl;
|
---|
1142 | fgfirst=false;
|
---|
1143 | }
|
---|
1144 | curtt=paq1.TimeTag()-firsttt;
|
---|
1145 | curtt2=paq2.TimeTag()-firsttt2;
|
---|
1146 | dtr[0]=curfc; dtr[1]=curtt;
|
---|
1147 | dtr[2]=curfc2; dtr[3]=curtt2;
|
---|
1148 | dt.AddRow(dtr);
|
---|
1149 |
|
---|
1150 | complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz);
|
---|
1151 | complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2);
|
---|
1152 | complex<r_4>* zp3 = (complex<r_4>*)(procbuff2+i2*procpaqsz);
|
---|
1153 | complex<r_4>* zp4 = (complex<r_4>*)(procbuff2+i2*procpaqsz+procpaqsz/2);
|
---|
1154 | for(sa_size_t j=0; j<visiV13.Size(); j++) {
|
---|
1155 | visiV13(j)+=zp1[j]*conj(zp3[j]);
|
---|
1156 | visiV14(j)+=zp1[j]*conj(zp4[j]);
|
---|
1157 | visiV23(j)+=zp2[j]*conj(zp3[j]);
|
---|
1158 | visiV24(j)+=zp2[j]*conj(zp4[j]);
|
---|
1159 | }
|
---|
1160 | if (nzm==0) {
|
---|
1161 | visiV13.Info()["StartFC"] = curfc;
|
---|
1162 | visiV14.Info()["StartFC"] = curfc;
|
---|
1163 | visiV23.Info()["StartFC"] = curfc;
|
---|
1164 | visiV24.Info()["StartFC"] = curfc;
|
---|
1165 | visiV13.Info()["StartTT"] = curtt;
|
---|
1166 | visiV14.Info()["StartTT"] = curtt;
|
---|
1167 | visiV23.Info()["StartTT"] = curtt;
|
---|
1168 | visiV24.Info()["StartTT"] = curtt;
|
---|
1169 | }
|
---|
1170 | nzm++; i1++; i2++;
|
---|
1171 | totnbytesproc += 2*paq1.DataSize();
|
---|
1172 | } // Fin de boucle sur les paquets d'une zone
|
---|
1173 | memgr1.FreeMemZone(mid1, MemZS_ProcB);
|
---|
1174 | memgr2.FreeMemZone(mid2, MemZS_ProcB);
|
---|
1175 |
|
---|
1176 | if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
|
---|
1177 | visiV13 /= complex<r_4>((r_4)nzm, 0.);
|
---|
1178 | visiV14 /= complex<r_4>((r_4)nzm, 0.);
|
---|
1179 | visiV23 /= complex<r_4>((r_4)nzm, 0.);
|
---|
1180 | visiV24 /= complex<r_4>((r_4)nzm, 0.);
|
---|
1181 | visiV13.Info()["NPaqMoy"] = nzm;
|
---|
1182 | visiV14.Info()["NPaqMoy"] = nzm;
|
---|
1183 | visiV23.Info()["NPaqMoy"] = nzm;
|
---|
1184 | visiV24.Info()["NPaqMoy"] = nzm;
|
---|
1185 | visiV13.Info()["EndFC"] = curfc;
|
---|
1186 | visiV14.Info()["EndFC"] = curfc;
|
---|
1187 | visiV23.Info()["EndFC"] = curfc;
|
---|
1188 | visiV24.Info()["EndFC"] = curfc;
|
---|
1189 | visiV13.Info()["EndTT"] = curtt;
|
---|
1190 | visiV14.Info()["EndTT"] = curtt;
|
---|
1191 | visiV23.Info()["EndTT"] = curtt;
|
---|
1192 | visiV24.Info()["EndTT"] = curtt;
|
---|
1193 | char fname[512];
|
---|
1194 | {
|
---|
1195 | sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
|
---|
1196 | POutPersist po(fname);
|
---|
1197 | po << PPFNameTag("visiV13") << visiV13;
|
---|
1198 | po << PPFNameTag("visiV14") << visiV14;
|
---|
1199 | po << PPFNameTag("visiV23") << visiV23;
|
---|
1200 | po << PPFNameTag("visiV24") << visiV24;
|
---|
1201 | }
|
---|
1202 | visiV13 = complex<r_4>(0., 0.);
|
---|
1203 | visiV14 = complex<r_4>(0., 0.);
|
---|
1204 | visiV23 = complex<r_4>(0., 0.);
|
---|
1205 | visiV24 = complex<r_4>(0., 0.);
|
---|
1206 | nzm = 0; ifile++;
|
---|
1207 | // ts.SetNow();
|
---|
1208 | // filog << ts << " : proc file " << fname << endl;
|
---|
1209 | cout << " BRProcB4C::run() created file " << fname << endl;
|
---|
1210 | }
|
---|
1211 | double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.;
|
---|
1212 | cout << "BRProcB4C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc
|
---|
1213 | << " (" << okfrac << " %)" << endl;
|
---|
1214 | totnokpaq += nokpaq;
|
---|
1215 | totnoksfc += noksfc;
|
---|
1216 | } // Fin de boucle sur les zones a traiter
|
---|
1217 | cout << " ------------------ BRProcB4C::run() END ----------------- " << endl;
|
---|
1218 | {
|
---|
1219 | dt.Info()["FirstTT1"]=firsttt;
|
---|
1220 | dt.Info()["FirstTT2"]=firsttt2;
|
---|
1221 | cout << dt;
|
---|
1222 | char fname[512];
|
---|
1223 | sprintf(fname,"%s_fctt.ppf",path_.c_str());
|
---|
1224 | POutPersist po(fname);
|
---|
1225 | po << PPFNameTag("ttfc") << dt;
|
---|
1226 | cout << " BRProcB4C::run() created TimeTag/FrameCounter file " << fname << endl;
|
---|
1227 | }
|
---|
1228 | ts.SetNow();
|
---|
1229 | tm.SplitQ();
|
---|
1230 | cout << " TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= "
|
---|
1231 | << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" << endl;
|
---|
1232 | double totokfrac = (totnokpaq>1)?((double)totnoksfc/(double)totnokpaq*100.):0.;
|
---|
1233 | cout << " NOkPaq1,2=" << totnokpaq << " /TotNPaq=" << totnpaq << " TotNSameFC="
|
---|
1234 | << totnoksfc << " (" << totokfrac << " %)" << endl;
|
---|
1235 | // cout << pcheck1;
|
---|
1236 | // cout << pcheck2;
|
---|
1237 | cout << " BRProcB4C::run()/Timing: \n";
|
---|
1238 | tm.Print();
|
---|
1239 | cout << " ---------------------------------------------------------- " << endl;
|
---|
1240 | }
|
---|
1241 | catch (PException& exc) {
|
---|
1242 | cout << " BRProcB4C::run()/catched PException " << exc.Msg() << endl;
|
---|
1243 | setRC(3);
|
---|
1244 | return;
|
---|
1245 | }
|
---|
1246 | catch(...) {
|
---|
1247 | cout << " BRProcB4C::run()/catched unknown ... exception " << endl;
|
---|
1248 | setRC(4);
|
---|
1249 | return;
|
---|
1250 | }
|
---|
1251 | setRC(0);
|
---|
1252 | return;
|
---|
1253 | }
|
---|
1254 |
|
---|
1255 |
|
---|