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