source: Sophya/trunk/AddOn/TAcq/brproc.cc@ 3655

Last change on this file since 3655 was 3655, checked in by ansari, 16 years ago

Ajout calcul spectre moyenne et sigma das BRProcARaw2C, Reza 08/09/2009

File size: 21.3 KB
Line 
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//---------------------------------------------------------------
30// Classe thread de traitement donnees ADC avec 2 voies par frame
31//---------------------------------------------------------------
32
33// Mutex pour eviter le plantage du a FFTW qui ne semble pas thread-safe
34static ZMutex* pmutfftw=NULL;
35
36/* --Methode-- */
37BRProcARaw2C::BRProcARaw2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean,
38 uint_4 nmax, bool fghist, bool fgnotrl, int card)
39 : memgr(mem)
40{
41 nmax_ = nmax;
42 nmean_ = nmean;
43 stop_ = false;
44 path_ = path;
45 fgnotrl_ = fgnotrl;
46 fghist_ = fghist;
47 card_ = card;
48 if (pmutfftw==NULL) pmutfftw=new ZMutex;
49}
50
51/* --Methode-- */
52void BRProcARaw2C::Stop()
53{
54 stop_=true;
55 // cout <<" BRProcARaw2C::Stop ... > STOP " << endl;
56}
57
58
59static inline r_4 Zmod2(complex<r_4> z)
60{ return (z.real()*z.real()+z.imag()*z.imag()); }
61
62static inline string card2name_(int card)
63{
64 if (card==2) return " (Chan3,4) ";
65 else return " (Chan1,2) ";
66}
67/* --Methode-- */
68void BRProcARaw2C::run()
69{
70 setRC(1);
71 try {
72 Timer tm("BRProcARaw2C", false);
73 TimeStamp ts;
74 BRPaqChecker pcheck(!fgnotrl_); // Verification/comptage des paquets
75
76 size_t totnbytesout = 0;
77 size_t totnbytesproc = 0;
78
79 cout << " BRProcARaw2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
80 << " NMean=" << nmean_ << card2name_(card_) << endl;
81 cout << " BRProcARaw2C::run()... - Output Data Path: " << path_ << endl;
82 char fname[512];
83// sprintf(fname,"%s/proc.log",path_.c_str());
84// ofstream filog(fname);
85// filog << " BRProcARaw2C::run() - starting log file " << ts << endl;
86// filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl;
87
88/*----DELETE NTuple
89 const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"};
90 NTuple nt(8, nnames);
91 double xnt[10];
92 uint_4 nmnt = 0;
93 double ms1,ms2,ms12,ms12re,ms12im,ms12phi;
94----*/
95// Time sample histograms
96 Histo h1(-0.5, 255.5, 256);
97 Histo h2(-0.5, 255.5, 256);
98// Initialisation pour calcul FFT
99 TVector< complex<r_4> > cfour1; // composant TF
100 uint_4 paqsz = memgr.PaqSize();
101 uint_4 procpaqsz = memgr.ProcPaqSize();
102
103
104 BRPaquet pq(NULL, NULL, paqsz);
105 TVector<r_4> vx(pq.DataSize()/2);
106 int szfour = pq.DataSize()/2/2+1;
107 cfour1.SetSize(szfour);
108/*
109 vx = (r_4)(0.);
110 FFTPackServer ffts;
111 ffts.FFTForward(vx, cfour1);
112 szfour = cfour1.Size();
113*/
114
115 TVector< complex<r_4> > cfour2(cfour1.Size());
116
117 TVector<r_4> spectreV1(cfour1.Size());
118 TVector<r_4> spectreV2(cfour1.Size());
119 TVector<r_4> moyspecV1(cfour1.Size()); // Moyenne des Spectres
120 TVector<r_4> moyspecV2(cfour1.Size());
121 TVector<r_4> sigspecV1(cfour1.Size()); // Sigma des Spectres
122 TVector<r_4> sigspecV2(cfour1.Size());
123 TVector< complex<r_4> > visiV12( cfour1.Size() );
124
125 cout << " *DBG*BRProcARaw2C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
126 << " procpaqsz/2=" << procpaqsz/2 << " cfour1.Size()=" << cfour1.Size()
127 << " *8=" << cfour1.Size()*8 << endl;
128
129 pmutfftw->lock();
130 fftwf_plan plan1 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
131 (fftwf_complex*)cfour1.Data(), FFTW_ESTIMATE);
132 fftwf_plan plan2 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(),
133 (fftwf_complex*)cfour2.Data(), FFTW_ESTIMATE);
134 pmutfftw->unlock();
135
136 uint_4 ifile = 0;
137 uint_4 nzm = 0; // Nb de paquets moyennes pour le calcul de chaque spectre
138 uint_4 nmoyspec = 0; // Nb de spectres moyennes
139
140 uint_4 curfc=0;
141 uint_8 curtt=0;
142 uint_8 firsttt=0;
143 bool fgfirst=true;
144 for (uint_4 kmz=0; kmz<nmax_; kmz++) {
145 if (stop_) break;
146 int mid = memgr.FindMemZoneId(MemZA_ProcA);
147 Byte* buff = memgr.GetMemZone(mid);
148 if (buff == NULL) {
149 cout << " BRProcARaw2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl;
150 break;
151 }
152 Byte* procbuff = memgr.GetProcMemZone(mid);
153 if (procbuff == NULL) {
154 cout << " BRProcARaw2C::run()/ERROR memgr.GetProcMemZone(" << mid << ") -> NULL" << endl;
155 break;
156 }
157//---- DELETE nmnt=0; ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.;
158 for(uint_4 i=0; i<memgr.NbPaquets(); i++) {
159 BRPaquet paq(NULL, buff+i*paqsz, paqsz);
160 if (!pcheck.Check(paq)) continue; // on ne traite que les paquets OK
161 if (fgfirst) { firsttt=paq.TimeTag(); fgfirst=false; }
162 curfc=paq.FrameCounter();
163 curtt=paq.TimeTag()-firsttt;
164// Traitement voie 1
165 if (fghist_) {
166 for(sa_size_t j=0; j<vx.Size(); j++) {
167 r_4 vts=(r_4)(*(paq.Data1()+j));
168 h1.Add((r_8)vts);
169 vx(j) = vts-127.5;
170 }
171 }
172 else {
173 for(sa_size_t j=0; j<vx.Size(); j++)
174 vx(j) = (r_4)(*(paq.Data1()+j))-127.5;
175 }
176// fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz);
177 fftwf_execute(plan1);
178// complex<r_4>* zp1 = (complex<r_4>*)(vx.Data());
179// ffts.FFTForward(vx, cfour1);
180 for(sa_size_t j=0; j<spectreV1.Size(); j++)
181 spectreV1(j) += Zmod2(cfour1(j));
182 memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size());
183// Traitement voie 2
184 if (fghist_) {
185 for(sa_size_t j=0; j<vx.Size(); j++) {
186 r_4 vts=(r_4)(*(paq.Data2()+j));
187 h2.Add((r_8)vts);
188 vx(j) = vts-127.5;
189 }
190 }
191 else {
192 for(sa_size_t j=0; j<vx.Size(); j++)
193 vx(j) = (r_4)(*(paq.Data2()+j))-127.5;
194 }
195 fftwf_execute(plan2);
196 for(sa_size_t j=0; j<spectreV2.Size(); j++)
197 spectreV2(j) += Zmod2(cfour2(j)); // Zmod2(zp2[j]);
198 memcpy(procbuff+i*procpaqsz+procpaqsz/2, cfour2.Data(), sizeof(complex<r_4>)*cfour2.Size());
199
200// Calcul correlation (visibilite V1 * V2)
201 for(sa_size_t j=0; j<visiV12.Size(); j++)
202 visiV12(j)+=cfour1(j)*conj(cfour2(j));
203// for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j];
204 if (nzm==0) {
205 spectreV1.Info()["StartFC"] = curfc;
206 spectreV2.Info()["StartFC"] = curfc;
207 visiV12.Info()["StartFC"] = curfc;
208 spectreV1.Info()["StartTT"] = curtt;
209 spectreV2.Info()["StartTT"] = curtt;
210 visiV12.Info()["StartTT"] = curtt;
211 }
212 nzm++;
213/*----DELETE
214 if (nmnt==0) { xnt[0]=paq.FrameCounter(); xnt[1]=paq.TimeTag(); }
215 for(sa_size_t j=2700; j<2800; j++) {
216 ms1 += Zmod2(cfour1(j)); ms2 += Zmod2(cfour2(j));
217 complex<r_4> zvis = cfour1(j)*conj(cfour2(j));
218 ms12 += Zmod2(zvis); ms12re += zvis.real(); ms12im += zvis.imag();
219 ms12phi+= atan2(zvis.imag(),zvis.real());
220 }
221 nmnt++;
222----*/
223 totnbytesproc += paq.DataSize();
224 totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size());
225
226 } // Fin de boucle sur les paquets d'une zone
227
228/*---- DELETE
229 if (nmnt>0) {
230 double fnorm = (double)nmnt*(2800-2700);
231 xnt[2] = ms1 /= fnorm;
232 xnt[3] = ms2 /= fnorm;
233 xnt[4] = ms12 /= fnorm;
234 xnt[5] = ms12re /= fnorm;
235 xnt[6] = ms12im /= fnorm;
236 xnt[7] = ms12phi /= fnorm;
237 nt.Fill(xnt);
238 }
239----*/
240 if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
241 spectreV1 /= (r_4)(nzm);
242 spectreV2 /= (r_4)(nzm);
243
244 // pour le calcul des moyennes et sigmas de ces spectres
245 moyspecV1 += spectreV1;
246 moyspecV2 += spectreV2;
247 sigspecV1 += (spectreV1 && spectreV1);
248 sigspecV2 += (spectreV2 && spectreV2);
249 nmoyspec++;
250
251 visiV12 /= complex<r_4>((r_4)nzm, 0.);
252
253 spectreV1.Info()["NPaqMoy"] = nzm;
254 spectreV2.Info()["NPaqMoy"] = nzm;
255 visiV12.Info()["NPaqMoy"] = nzm;
256 spectreV1.Info()["EndFC"] = curfc;
257 spectreV2.Info()["EndFC"] = curfc;
258 visiV12.Info()["EndFC"] = curfc;
259 spectreV1.Info()["EndTT"] = curtt;
260 spectreV2.Info()["EndTT"] = curtt;
261 visiV12.Info()["EndTT"] = curtt;
262 {
263 sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
264 POutPersist po(fname);
265 string tag1="specV1";
266 string tag2="specV2";
267 string tag12="visiV12";
268 string tagh1="tshV1";
269 string tagh2="tshV2";
270 if (card_==2) {
271 tag1 = "specV3";
272 tag2 = "specV4";
273 tagh1 = "tshV1";
274 tagh2 = "tshV2";
275 tag12="visiV34";
276 }
277 po << PPFNameTag(tag1) << spectreV1;
278 po << PPFNameTag(tag2) << spectreV2;
279 po << PPFNameTag(tag12) << visiV12;
280 if (fghist_) {
281 po << PPFNameTag(tagh1) << h1;
282 po << PPFNameTag(tagh2) << h2;
283 }
284 }
285 spectreV1 = (r_4)(0.);
286 spectreV2 = (r_4)(0.);
287 visiV12 = complex<r_4>(0., 0.);
288 if (fghist_) {
289 h1.Zero();
290 h2.Zero();
291 }
292 nzm = 0; ifile++;
293// ts.SetNow();
294// filog << ts << " : proc file " << fname << endl;
295 cout << " BRProcARaw2C::run() created file " << fname << card2name_(card_) << endl;
296 }
297
298 memgr.FreeMemZone(mid, MemZS_ProcA);
299 } // Fin de boucle sur les zones a traiter
300 cout << " ------------ BRProcARaw2C::run() END " << card2name_(card_)
301 << " ------------ " << endl;
302/*---- DELETE
303 {
304 nt.Info()["FirstTT"]=firsttt;
305 cout << nt;
306 sprintf(fname,"%s_nt.ppf",path_.c_str());
307 POutPersist po(fname);
308 po << PPFNameTag("ntv12") << nt;
309 cout << " BRProcARaw2C::run() created NTuple file " << fname << card2name_(card_) << endl;
310 }
311---- */
312 if (nmoyspec>0) { // Calcul des moyennes et sigmas des spectres
313 r_4 fnms = nmoyspec;
314 moyspecV1 /= fnms;
315 moyspecV2 /= fnms;
316 sigspecV1 /= fnms;
317 sigspecV2 /= fnms;
318 sigspecV1 -= (moyspecV1 && moyspecV1);
319 sigspecV2 -= (moyspecV2 && moyspecV2);
320 sigspecV1 = Sqrt(sigspecV1);
321 sigspecV2 = Sqrt(sigspecV2);
322 TVector<r_4> rsbV1, rsbV2; // Rapport signal/bruit
323 moyspecV1.DivElt(sigspecV1, rsbV1, false, true);
324 moyspecV2.DivElt(sigspecV2, rsbV2, false, true);
325 sprintf(fname,"%s_ms.ppf",path_.c_str());
326 POutPersist po(fname);
327 po << PPFNameTag("moyspecV1") << moyspecV1;
328 po << PPFNameTag("moyspecV2") << moyspecV2;
329 po << PPFNameTag("sigspecV1") << sigspecV1;
330 po << PPFNameTag("sigspecV2") << sigspecV2;
331 po << PPFNameTag("rsbV1") << rsbV1;
332 po << PPFNameTag("rsbV2") << rsbV2;
333 cout << " BRProcARaw2C::run() created moysigspec file " << fname << card2name_(card_) << endl;
334 }
335
336 ts.SetNow();
337 tm.SplitQ();
338 cout << " TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= "
339 << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s"
340 << " ProcDataOut=" << totnbytesout/(1024*1024) << " MB" << endl;
341 cout << pcheck;
342 cout << " BRProcARaw2C::run()/Timing: " << card2name_(card_) << endl;
343 tm.Print();
344 cout << " ---------------------------------------------------------- " << endl;
345
346 }
347 catch (PException& exc) {
348 cout << " BRProcARaw2C::run()/catched PException " << exc.Msg() << endl;
349 setRC(3);
350 return;
351 }
352 catch(...) {
353 cout << " BRProcARaw2C::run()/catched unknown ... exception " << endl;
354 setRC(4);
355 return;
356 }
357 setRC(0);
358 return;
359}
360
361//---------------------------------------------------------------------
362// Classe thread de traitement 2 x 2 voies/frames (Apres BRProcARaw2C)
363//---------------------------------------------------------------------
364
365/* --Methode-- */
366BRProcBRaw4C::BRProcBRaw4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2,
367 string& path, uint_4 nmean, uint_4 nmax, bool fgnotrl)
368 : memgr1(mem1), memgr2(mem2)
369{
370 nmax_ = nmax;
371 nmean_ = nmean;
372 stop_ = false;
373 path_ = path;
374 fgnotrl_ = fgnotrl;
375}
376
377/* --Methode-- */
378void BRProcBRaw4C::Stop()
379{
380 stop_=true;
381 // cout <<" BRProcBRaw4C::Stop ... > STOP " << endl;
382}
383
384
385/* --Methode-- */
386void BRProcBRaw4C::run()
387{
388 setRC(1);
389 try {
390 Timer tm("BRProcBRaw4C", false);
391 TimeStamp ts;
392 BRPaqChecker pcheck1(!fgnotrl_); // Verification/comptage des paquets
393 BRPaqChecker pcheck2(!fgnotrl_); // Verification/comptage des paquets
394
395 size_t totnbytesout = 0;
396 size_t totnbytesproc = 0;
397
398 cout << " BRProcBRaw4C::run() - Starting " << ts << " NMaxMemZones=" << nmax_
399 << " NMean=" << nmean_ << endl;
400 cout << " BRProcBRaw4C::run()... - Output Data Path: " << path_ << endl;
401
402 uint_4 paqsz = memgr1.PaqSize();
403 uint_4 procpaqsz = memgr1.ProcPaqSize();
404 if ((paqsz != memgr2.PaqSize())||(procpaqsz!= memgr2.ProcPaqSize())) {
405 cout << "BRProcBRaw4C::run()/ERROR : different paquet size -> stop \n ...(PaqSz1="
406 << paqsz << " Sz2=" << memgr2.PaqSize() << " ProcPaqSz1="
407 << procpaqsz << " Sz2=" << memgr2.ProcPaqSize() << " )" << endl;
408 setRC(9);
409 return;
410 }
411
412 TVector< complex<r_4> > cfour; // composant TF
413 BRPaquet pq(NULL, NULL, paqsz);
414/*
415 TVector<r_4> vx(pq.DataSize()/2);
416 vx = (r_4)(0.);
417 FFTPackServer ffts;
418 ffts.FFTForward(vx, cfour);
419
420 TVector< complex<r_4> > visiV13( cfour.Size() );
421 TVector< complex<r_4> > visiV14( cfour.Size() );
422 TVector< complex<r_4> > visiV23( cfour.Size() );
423 TVector< complex<r_4> > visiV24( cfour.Size() );
424*/
425 int szfour = pq.DataSize()/2/2+1;
426// int szfour = (paqsz-40)/2+1;
427 TVector< complex<r_4> > visiV13( szfour );
428 TVector< complex<r_4> > visiV14( szfour );
429 TVector< complex<r_4> > visiV23( szfour );
430 TVector< complex<r_4> > visiV24( szfour );
431 // cout << " *DBG*AAAAA ---- Vectors OK" << endl;
432 cout << " *DBG*BRProcBRaw4C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz
433 << " procpaqsz/2=" << procpaqsz/2 << " cfour.Size()=" << szfour
434 << " *8=" << szfour*8 << endl;
435
436 DataTable dt;
437 dt.AddLongColumn("fc1");
438 dt.AddLongColumn("tt1");
439 dt.AddLongColumn("fc2");
440 dt.AddLongColumn("tt2");
441 DataTableRow dtr = dt.EmptyRow();
442
443 uint_4 nzm = 0;
444 uint_4 totnoksfc = 0;
445 uint_4 totnokpaq = 0;
446 uint_4 totnpaq = 0;
447 uint_4 ifile = 0;
448
449 uint_4 curfc=0;
450 uint_8 curtt=0;
451 uint_4 curfc2=0;
452 uint_8 curtt2=0;
453 uint_8 firsttt=0;
454 uint_8 firsttt2=0;
455 bool fgfirst=true;
456 for (uint_4 kmz=0; kmz<nmax_; kmz++) {
457 uint_4 noksfc = 0;
458 uint_4 nokpaq = 0;
459 if (stop_) break;
460 // cout << " *DBG*BBBBB" << kmz << endl;
461
462 int mid1 = memgr1.FindMemZoneId(MemZA_ProcB);
463 Byte* buff1 = memgr1.GetMemZone(mid1);
464 if (buff1 == NULL) {
465 cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid1 << ") -> NULL" << endl;
466 break;
467 }
468 Byte* procbuff1 = memgr1.GetProcMemZone(mid1);
469 if (procbuff1 == NULL) {
470 cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid1 << ") -> NULL" << endl;
471 break;
472 }
473 int mid2 = memgr2.FindMemZoneId(MemZA_ProcB);
474 Byte* buff2 = memgr2.GetMemZone(mid2);
475 if (buff1 == NULL) {
476 cout << " BRProcBRaw4C::run()/ERROR memgr.GetMemZone(" << mid2 << ") -> NULL" << endl;
477 break;
478 }
479 Byte* procbuff2 = memgr2.GetProcMemZone(mid2);
480 if (procbuff2 == NULL) {
481 cout << " BRProcBRaw4C::run()/ERROR memgr.GetProcMemZone(" << mid2 << ") -> NULL" << endl;
482 break;
483 }
484 uint_4 i1,i2;
485 i1=i2=0;
486// cout << " *DBG*CCCCCC " << kmz << " memgr1.NbPaquets() =" << memgr1.NbPaquets() << endl;
487 while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) {
488 BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz);
489 BRPaquet paq2(NULL, buff2+i2*paqsz, paqsz);
490 totnpaq++;
491// cout << " DBG["<<kmz<<"] i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
492//<<","<<paq2.FrameCounter()<<endl;
493 // on ne traite que les paquets OK
494 if (!pcheck1.Check(paq1)) { i1++; continue; }
495 if (!pcheck2.Check(paq2)) { i2++; continue; }
496 nokpaq++;
497 if (paq1.FrameCounter()<paq2.FrameCounter()) { i1++; continue; }
498 if (paq2.FrameCounter()<paq1.FrameCounter()) { i2++; continue; }
499// cout << " DBG["<<kmz<<"]OKOK i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter()
500// <<","<<paq2.FrameCounter()<<endl;
501
502 if ((i1>=memgr1.NbPaquets())||(i2>=memgr1.NbPaquets())) {
503 cout << " *BUG*BUG i1=" << i1 << " i2=" << i2 << endl;
504 break;
505 }
506 // Les deux framecounters sont identiques ...
507 noksfc++;
508 curfc=paq1.FrameCounter();
509 curfc2=paq2.FrameCounter();
510 if (fgfirst) {
511 firsttt=paq1.TimeTag(); firsttt2=paq2.TimeTag();
512 cout << " BRProcBRaw4C()/Info First FC="<<curfc<<" , "<<curfc2<<" -> TT="
513 << firsttt<<" , "<<firsttt2 <<endl;
514 fgfirst=false;
515 }
516 curtt=paq1.TimeTag()-firsttt;
517 curtt2=paq2.TimeTag()-firsttt2;
518 dtr[0]=curfc; dtr[1]=curtt;
519 dtr[2]=curfc2; dtr[3]=curtt2;
520 dt.AddRow(dtr);
521
522 complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz);
523 complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2);
524 complex<r_4>* zp3 = (complex<r_4>*)(procbuff2+i2*procpaqsz);
525 complex<r_4>* zp4 = (complex<r_4>*)(procbuff2+i2*procpaqsz+procpaqsz/2);
526 for(sa_size_t j=0; j<visiV13.Size(); j++) {
527 visiV13(j)+=zp1[j]*conj(zp3[j]);
528 visiV14(j)+=zp1[j]*conj(zp4[j]);
529 visiV23(j)+=zp2[j]*conj(zp3[j]);
530 visiV24(j)+=zp2[j]*conj(zp4[j]);
531 }
532 if (nzm==0) {
533 visiV13.Info()["StartFC"] = curfc;
534 visiV14.Info()["StartFC"] = curfc;
535 visiV23.Info()["StartFC"] = curfc;
536 visiV24.Info()["StartFC"] = curfc;
537 visiV13.Info()["StartTT"] = curtt;
538 visiV14.Info()["StartTT"] = curtt;
539 visiV23.Info()["StartTT"] = curtt;
540 visiV24.Info()["StartTT"] = curtt;
541 }
542 nzm++; i1++; i2++;
543 totnbytesproc += 2*paq1.DataSize();
544 } // Fin de boucle sur les paquets d'une zone
545 memgr1.FreeMemZone(mid1, MemZS_ProcB);
546 memgr2.FreeMemZone(mid2, MemZS_ProcB);
547
548 if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) {
549 visiV13 /= complex<r_4>((r_4)nzm, 0.);
550 visiV14 /= complex<r_4>((r_4)nzm, 0.);
551 visiV23 /= complex<r_4>((r_4)nzm, 0.);
552 visiV24 /= complex<r_4>((r_4)nzm, 0.);
553 visiV13.Info()["NPaqMoy"] = nzm;
554 visiV14.Info()["NPaqMoy"] = nzm;
555 visiV23.Info()["NPaqMoy"] = nzm;
556 visiV24.Info()["NPaqMoy"] = nzm;
557 visiV13.Info()["EndFC"] = curfc;
558 visiV14.Info()["EndFC"] = curfc;
559 visiV23.Info()["EndFC"] = curfc;
560 visiV24.Info()["EndFC"] = curfc;
561 visiV13.Info()["EndTT"] = curtt;
562 visiV14.Info()["EndTT"] = curtt;
563 visiV23.Info()["EndTT"] = curtt;
564 visiV24.Info()["EndTT"] = curtt;
565 char fname[512];
566 {
567 sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile);
568 POutPersist po(fname);
569 po << PPFNameTag("visiV13") << visiV13;
570 po << PPFNameTag("visiV14") << visiV14;
571 po << PPFNameTag("visiV23") << visiV23;
572 po << PPFNameTag("visiV24") << visiV24;
573 }
574 visiV13 = complex<r_4>(0., 0.);
575 visiV14 = complex<r_4>(0., 0.);
576 visiV23 = complex<r_4>(0., 0.);
577 visiV24 = complex<r_4>(0., 0.);
578 nzm = 0; ifile++;
579// ts.SetNow();
580// filog << ts << " : proc file " << fname << endl;
581 cout << " BRProcBRaw4C::run() created file " << fname << endl;
582 }
583 double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.;
584 cout << "BRProcBRaw4C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc
585 << " (" << okfrac << " %)" << endl;
586 totnokpaq += nokpaq;
587 totnoksfc += noksfc;
588 } // Fin de boucle sur les zones a traiter
589 cout << " ------------------ BRProcBRaw4C::run() END ----------------- " << endl;
590 {
591 dt.Info()["FirstTT1"]=firsttt;
592 dt.Info()["FirstTT2"]=firsttt2;
593 cout << dt;
594 char fname[512];
595 sprintf(fname,"%s_fctt.ppf",path_.c_str());
596 POutPersist po(fname);
597 po << PPFNameTag("ttfc") << dt;
598 cout << " BRProcBRaw4C::run() created TimeTag/FrameCounter file " << fname << endl;
599 }
600 ts.SetNow();
601 tm.SplitQ();
602 cout << " TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= "
603 << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" << endl;
604 double totokfrac = (totnokpaq>1)?((double)totnoksfc/(double)totnokpaq*100.):0.;
605 cout << " NOkPaq1,2=" << totnokpaq << " /TotNPaq=" << totnpaq << " TotNSameFC="
606 << totnoksfc << " (" << totokfrac << " %)" << endl;
607// cout << pcheck1;
608// cout << pcheck2;
609 cout << " BRProcBRaw4C::run()/Timing: \n";
610 tm.Print();
611 cout << " ---------------------------------------------------------- " << endl;
612}
613 catch (PException& exc) {
614 cout << " BRProcBRaw4C::run()/catched PException " << exc.Msg() << endl;
615 setRC(3);
616 return;
617 }
618 catch(...) {
619 cout << " BRProcBRaw4C::run()/catched unknown ... exception " << endl;
620 setRC(4);
621 return;
622 }
623 setRC(0);
624 return;
625}
626
627
Note: See TracBrowser for help on using the repository browser.