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