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