| [3537] | 1 | #include "racquproc.h" | 
|---|
|  | 2 |  | 
|---|
| [3681] | 3 | /* ---------------------------------------- | 
|---|
|  | 4 | Projet BAORadio --- LAL | 
|---|
|  | 5 | 2008 - 2010 | 
|---|
|  | 6 | -------------------------------------------  */ | 
|---|
|  | 7 |  | 
|---|
| [3537] | 8 | #include <stdlib.h> | 
|---|
|  | 9 | #include <unistd.h> | 
|---|
|  | 10 | #include <fstream> | 
|---|
| [3623] | 11 | #include <signal.h> | 
|---|
| [3537] | 12 |  | 
|---|
|  | 13 | #include "pexceptions.h" | 
|---|
|  | 14 | #include "tvector.h" | 
|---|
|  | 15 | #include "fioarr.h" | 
|---|
|  | 16 | #include "timestamp.h" | 
|---|
|  | 17 | #include "fftpserver.h" | 
|---|
|  | 18 | #include "fftwserver.h" | 
|---|
| [3683] | 19 | #include "histos.h" | 
|---|
| [3729] | 20 | #include "histos2.h" | 
|---|
| [3537] | 21 |  | 
|---|
|  | 22 | #include "FFTW/fftw3.h" | 
|---|
|  | 23 |  | 
|---|
|  | 24 |  | 
|---|
|  | 25 | #include "pciewrap.h" | 
|---|
|  | 26 | #include "brpaqu.h" | 
|---|
|  | 27 | #include "minifits.h" | 
|---|
|  | 28 |  | 
|---|
| [3681] | 29 | /* Fonction, module^2 des nombres complexes */ | 
|---|
|  | 30 | static inline r_4 Zmod2(complex<r_4> z) | 
|---|
|  | 31 | { return (z.real()*z.real()+z.imag()*z.imag()); } | 
|---|
|  | 32 | static inline r_8 Zmod2(complex<r_8> z) | 
|---|
|  | 33 | { return (z.real()*z.real()+z.imag()*z.imag()); } | 
|---|
|  | 34 | static inline r_4 Zmod2(TwoByteComplex z) | 
|---|
|  | 35 | { return ((r_4)z.realB()*(r_4)z.realB()+(r_4)z.imagB()*(r_4)z.imagB()); } | 
|---|
|  | 36 |  | 
|---|
|  | 37 | //--------------------------------------------------------------------- | 
|---|
|  | 38 | // Classe thread de traitement/monitoring multifibre Raw/FFT | 
|---|
|  | 39 | //--------------------------------------------------------------------- | 
|---|
| [4016] | 40 | /*! | 
|---|
|  | 41 | \class MonitorProc | 
|---|
|  | 42 | \ingroup TAcq | 
|---|
|  | 43 |  | 
|---|
|  | 44 | \brief Monitoring thread class for BAORadio/CRT acquisition program. | 
|---|
|  | 45 |  | 
|---|
|  | 46 | This class can handle data from Raw data firmware, as well as FFT firmware, | 
|---|
|  | 47 | one and two channels per fiber. | 
|---|
|  | 48 | */ | 
|---|
|  | 49 |  | 
|---|
| [3681] | 50 | /* --Methode-- */ | 
|---|
|  | 51 | MonitorProc::MonitorProc(RAcqMemZoneMgr& mem) | 
|---|
|  | 52 | :  memgr(mem) | 
|---|
|  | 53 | { | 
|---|
|  | 54 | BRAcqConfig bpar; | 
|---|
|  | 55 | par_.Set(bpar.GetParams()); | 
|---|
|  | 56 | nmax_ = par_.nmaxProc; | 
|---|
|  | 57 | if (nmax_==0) nmax_=par_.MaxNbBlocs(); | 
|---|
|  | 58 | nmean_ = par_.nmeanProc; | 
|---|
|  | 59 | step_ = par_.stepProc; | 
|---|
|  | 60 | stop_ = false; | 
|---|
|  | 61 | path_ = bpar.OutputDirectory(); | 
|---|
|  | 62 | nfiles_ = 0; | 
|---|
|  | 63 | nblocproc_ = 0; | 
|---|
|  | 64 | nprocpaq_=0; | 
|---|
|  | 65 | npaqsamefc_=0; | 
|---|
|  | 66 | totnprocpaq_=0; | 
|---|
|  | 67 | totnpaqsamefc_=0; | 
|---|
|  | 68 | curfc_.SetSize(memgr.NbFibres(), memgr.NbPaquets()); | 
|---|
|  | 69 | cpaqok_.SetSize(memgr.NbFibres(), memgr.NbPaquets()); | 
|---|
| [3876] | 70 | SetMemZAction(); | 
|---|
| [3681] | 71 | } | 
|---|
|  | 72 |  | 
|---|
|  | 73 | /* --Methode-- */ | 
|---|
|  | 74 | MonitorProc::~MonitorProc() | 
|---|
|  | 75 | { | 
|---|
|  | 76 | //  cout << " **** DBG ***** MonitorProc::~MonitorProc() " << endl; | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
|  | 79 | /* --Methode-- */ | 
|---|
| [3876] | 80 | MemZStatus MonitorProc::SetMemZAction(MemZaction mmact) | 
|---|
|  | 81 | { | 
|---|
|  | 82 | mmact_=mmact; | 
|---|
|  | 83 | mmsta_=MemZS_Proc; | 
|---|
|  | 84 | switch (mmact) { | 
|---|
|  | 85 | case MemZA_ProcA: | 
|---|
|  | 86 | mmsta_=MemZS_ProcA; | 
|---|
|  | 87 | break; | 
|---|
|  | 88 | case MemZA_ProcB: | 
|---|
|  | 89 | mmsta_=MemZS_ProcB; | 
|---|
|  | 90 | break; | 
|---|
|  | 91 | case MemZA_ProcC: | 
|---|
|  | 92 | mmsta_=MemZS_ProcC; | 
|---|
|  | 93 | break; | 
|---|
|  | 94 | case MemZA_ProcD: | 
|---|
|  | 95 | mmsta_=MemZS_ProcD; | 
|---|
|  | 96 | break; | 
|---|
|  | 97 | case MemZA_ProcE: | 
|---|
|  | 98 | mmsta_=MemZS_ProcE; | 
|---|
|  | 99 | break; | 
|---|
|  | 100 | case MemZA_ProcF: | 
|---|
|  | 101 | mmsta_=MemZS_ProcF; | 
|---|
|  | 102 | break; | 
|---|
|  | 103 | default: | 
|---|
|  | 104 | mmact_=MemZA_Proc; | 
|---|
|  | 105 | mmsta_=MemZS_Proc; | 
|---|
|  | 106 | break; | 
|---|
|  | 107 | } | 
|---|
|  | 108 | return mmsta_; | 
|---|
|  | 109 | } | 
|---|
|  | 110 |  | 
|---|
|  | 111 | /* --Methode-- */ | 
|---|
| [3681] | 112 | void MonitorProc::Stop() | 
|---|
|  | 113 | { | 
|---|
|  | 114 | stop_=true; | 
|---|
|  | 115 | } | 
|---|
|  | 116 |  | 
|---|
|  | 117 | /* --Methode-- */ | 
|---|
|  | 118 | void MonitorProc::run() | 
|---|
|  | 119 | { | 
|---|
|  | 120 | setRC(1); | 
|---|
|  | 121 | int rc=0; | 
|---|
|  | 122 | try { | 
|---|
|  | 123 | TimeStamp ts; | 
|---|
|  | 124 | cout << " MonitorProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
|  | 125 | << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
|  | 126 | cout << " MonitorProc::run()... - Output Data Path: " << path_ << endl; | 
|---|
|  | 127 | char fname[512]; | 
|---|
|  | 128 | sprintf(fname,"%s/monproc.log",path_.c_str()); | 
|---|
|  | 129 | ofstream filog(fname); | 
|---|
|  | 130 | filog << " MonitorProc::run() - starting log file " << ts << endl; | 
|---|
|  | 131 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
|  | 132 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 133 | BRPaquet pq(paqsz); | 
|---|
|  | 134 | if (par_.fgsinglechannel) { | 
|---|
|  | 135 | spectre_.SetSize(memgr.NbFibres(), pq.DataSize()/2); | 
|---|
|  | 136 | for(int kc=0; kc<memgr.NbFibres(); kc++)  nzm_.push_back(0); | 
|---|
|  | 137 | rc=procData1C(filog); | 
|---|
|  | 138 | } | 
|---|
|  | 139 | else { | 
|---|
|  | 140 | spectre_.SetSize(2*memgr.NbFibres(), pq.DataSize()/4); | 
|---|
|  | 141 | for(int kc=0; kc<2*memgr.NbFibres(); kc++)  nzm_.push_back(0); | 
|---|
|  | 142 | rc=procData2C(filog); | 
|---|
|  | 143 | } | 
|---|
|  | 144 | cout << " ---- MonitorProc::run()/End NBlocProcessed=" << nblocproc_ | 
|---|
|  | 145 | << " NFiles=" << nfiles_ << " Rc=" << rc << endl; | 
|---|
|  | 146 | ts.SetNow(); | 
|---|
|  | 147 | filog << " ---- MonitorProc::run()/End " << ts << endl; | 
|---|
|  | 148 | filog << " --------- MonitorProc::run()/End NBlocProcessed=" << nblocproc_ | 
|---|
|  | 149 | << " NFiles=" << nfiles_ << " Rc=" << rc << endl; | 
|---|
|  | 150 | } | 
|---|
|  | 151 | catch (std::exception& exc) { | 
|---|
|  | 152 | cout << " MonitorProc::run()/catched std::exception " << exc.what() << endl; | 
|---|
|  | 153 | setRC(98); | 
|---|
|  | 154 | return; | 
|---|
|  | 155 | } | 
|---|
|  | 156 | catch(...) { | 
|---|
|  | 157 | cout << " MonitorProc::run()/catched unknown ... exception " << endl; | 
|---|
|  | 158 | setRC(99); | 
|---|
|  | 159 | return; | 
|---|
|  | 160 | } | 
|---|
|  | 161 |  | 
|---|
|  | 162 | setRC(rc); | 
|---|
|  | 163 | return; | 
|---|
|  | 164 | } | 
|---|
|  | 165 |  | 
|---|
|  | 166 | /* --Methode-- */ | 
|---|
| [3944] | 167 | int MonitorProc::procData1C(ofstream& filog) | 
|---|
| [3681] | 168 | { | 
|---|
| [3944] | 169 | BRPaqChecker pcheck[MAXNBFIB];  // Verification/comptage des paquets | 
|---|
|  | 170 | // Initialisation pour calcul FFT | 
|---|
|  | 171 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 172 | BRPaquet pq(paqsz); | 
|---|
|  | 173 | TVector<r_4> vx(pq.DataSize()); | 
|---|
|  | 174 | vx = (r_4)(0.); | 
|---|
|  | 175 | TVector< complex<r_4> > cfour(pq.DataSize()/2+1);  // composant TF | 
|---|
|  | 176 |  | 
|---|
|  | 177 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
|  | 178 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); | 
|---|
|  | 179 |  | 
|---|
|  | 180 | // Histo pour valeurs des bytes dans les paquets | 
|---|
|  | 181 | Histo* phist[MAXNBFIB]; | 
|---|
|  | 182 | Histo2D* ph2[MAXNBFIB]; | 
|---|
|  | 183 | Histo* phexp[MAXNBFIB]; | 
|---|
|  | 184 | TMatrix<r_4>* psatur[MAXNBFIB]; | 
|---|
|  | 185 | TVector<uint_4>* pvsatfreq[MAXNBFIB]; | 
|---|
|  | 186 | for(int ifib=0; ifib<MAXNBFIB; ifib++) { | 
|---|
|  | 187 | phist[ifib]=NULL; ph2[ifib]=NULL; phexp[ifib]=NULL; psatur[ifib]=NULL; | 
|---|
|  | 188 | } | 
|---|
|  | 189 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
|  | 190 | for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++) { | 
|---|
|  | 191 | phist[lc] = new Histo(-128.5,+128.5,257); | 
|---|
|  | 192 | ph2[lc]   = new Histo2D(-128.5,+128.5,257, -128.5,+128.5,257); | 
|---|
|  | 193 | phexp[lc] = new Histo(-128.5,+128.5,257); | 
|---|
|  | 194 | psatur[lc] = new TMatrix<r_4>(3,3); | 
|---|
|  | 195 | pvsatfreq[lc] = new TVector<uint_4>(spectre_.NCols()); | 
|---|
|  | 196 | *psatur[lc] = 0.; | 
|---|
|  | 197 | } | 
|---|
|  | 198 | } | 
|---|
|  | 199 | else { | 
|---|
|  | 200 | for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++) | 
|---|
|  | 201 | phist[lc] = new Histo(-0.5,256.5,257); | 
|---|
|  | 202 | } | 
|---|
|  | 203 |  | 
|---|
|  | 204 | TimeStamp ts; | 
|---|
|  | 205 | char fname[512]; | 
|---|
|  | 206 | nfiles_ = 0; | 
|---|
|  | 207 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
|  | 208 | if (stop_) break; | 
|---|
|  | 209 | if (memgr.GetRunState() == MemZR_Stopped) break; | 
|---|
|  | 210 |  | 
|---|
|  | 211 | int mid = memgr.FindMemZoneId(mmact_);  // MemZA_Proc | 
|---|
|  | 212 | Byte* buffg = memgr.GetMemZone(mid); | 
|---|
|  | 213 | if (buffg == NULL) { | 
|---|
|  | 214 | cout << " MonitorProc::procData1C()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
|  | 215 | break; | 
|---|
|  | 216 | } | 
|---|
|  | 217 | if ((step_>1)&&(kmz%step_ != 0))  { | 
|---|
|  | 218 | memgr.FreeMemZone(mid, mmsta_);  //  MemZS_Proc); | 
|---|
|  | 219 | continue; | 
|---|
|  | 220 | } | 
|---|
|  | 221 | sa_size_t lc=0; | 
|---|
|  | 222 | Byte* fbuff[MAXNBFIB]; | 
|---|
|  | 223 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)  {  // Boucle sur les fibres | 
|---|
|  | 224 | fbuff[fib] = memgr.GetMemZone(mid,fib); | 
|---|
|  | 225 | if (fbuff[fib] == NULL) { // cela ne devrait pas arriver | 
|---|
|  | 226 | cout << " MonitorProc::procData1C()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl; | 
|---|
|  | 227 | return 9; | 
|---|
|  | 228 | } | 
|---|
|  | 229 | } | 
|---|
|  | 230 |  | 
|---|
|  | 231 | // DBG-ATTENTION : freq 0 pour expo full FFT si reordonne | 
|---|
|  | 232 | //    int idxexpo=(par_.fgfftshrink)?1023:0; // exposant FFT shrink 1024 freq, ou freq 0 pour full-FFT | 
|---|
|  | 233 | int idxexpo=0; | 
|---|
|  | 234 |  | 
|---|
|  | 235 | cpaqok_ = (uint_1)0; | 
|---|
|  | 236 | curfc_ = (uint_8)0; | 
|---|
|  | 237 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { | 
|---|
|  | 238 | for(uint_4 i=0; i<memgr.NbPaquets(); i++) { | 
|---|
|  | 239 | BRPaquet paq(fbuff[fib]+i*paqsz, paqsz); | 
|---|
|  | 240 | bool pqok=pcheck[fib].Check(paq,curfc_(fib,i));   // Verification du paquet / FrameCounter | 
|---|
|  | 241 | if (!pqok)  continue; | 
|---|
|  | 242 | cpaqok_(fib,i) = 1; | 
|---|
|  | 243 | sa_size_t lc=fib; | 
|---|
|  | 244 | if (par_.fgdatafft) {    // Traitement data de type FFT | 
|---|
|  | 245 | TwoByteComplex* tbcp=paq.Data1C(); | 
|---|
|  | 246 |  | 
|---|
|  | 247 | //  exposant FFT | 
|---|
|  | 248 | phexp[lc]->Add((r_4)tbcp[idxexpo].realD()); | 
|---|
|  | 249 |  | 
|---|
|  | 250 | for(sa_size_t j=1; j<spectre_.NCols(); j++) { | 
|---|
|  | 251 | phist[lc]->Add((r_4)tbcp[j].realD()); | 
|---|
|  | 252 | phist[lc]->Add((r_4)tbcp[j].imagD()); | 
|---|
|  | 253 | ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD()); | 
|---|
|  | 254 | // comptage saturation | 
|---|
|  | 255 | int sir=0, sii=0;  // saturation partie reelle, partie imaginaire | 
|---|
|  | 256 | if (tbcp[j].realI()==-128) sir=-1; | 
|---|
|  | 257 | else if (tbcp[j].realI()==127) sir=1; | 
|---|
|  | 258 | if (tbcp[j].imagI()==-128) sii=-1; | 
|---|
|  | 259 | else if (tbcp[j].imagI()==127) sii=1; | 
|---|
|  | 260 | (*psatur[lc])(sir+1,sii+1)+=1.; | 
|---|
|  | 261 | if ((sir!=0)||(sii!=0))  (*pvsatfreq[lc])(j)+=1; | 
|---|
|  | 262 | spectre_(lc,j) += Zmod2(tbcp[j]); | 
|---|
|  | 263 | } | 
|---|
|  | 264 | nzm_[lc]++; | 
|---|
|  | 265 | } | 
|---|
|  | 266 | else {   // Traitement RawData | 
|---|
|  | 267 | for(sa_size_t j=0; j<vx.Size(); j++) { | 
|---|
|  | 268 | phist[lc]->Add((r_8)(*(paq.Data1()+j))); | 
|---|
|  | 269 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5; | 
|---|
|  | 270 | } | 
|---|
|  | 271 | fftwf_execute(plan); | 
|---|
|  | 272 | //   ffts_.FFTForward(vx, cfour_); | 
|---|
|  | 273 | for(sa_size_t j=0; j<spectre_.NCols(); j++) | 
|---|
|  | 274 | spectre_(lc,j) += Zmod2(cfour(j+1)); | 
|---|
|  | 275 | nzm_[lc]++;      lc++; | 
|---|
|  | 276 | } | 
|---|
|  | 277 | }  // FIN de la boucle sur les paquets | 
|---|
|  | 278 | }   // Boucle sur les fibres | 
|---|
|  | 279 | memgr.FreeMemZone(mid, mmsta_);  // MemZS_Proc); | 
|---|
|  | 280 | CheckFrameCounters(); | 
|---|
|  | 281 |  | 
|---|
|  | 282 | nblocproc_ ++; | 
|---|
|  | 283 | totnprocpaq_ += memgr.NbPaquets();  nprocpaq_ += memgr.NbPaquets(); | 
|---|
|  | 284 | bool fgnzm=true; | 
|---|
|  | 285 | for(int lc=0; lc<memgr.NbFibres(); lc++) | 
|---|
|  | 286 | if (nzm_[lc]<nmean_) fgnzm=false; | 
|---|
|  | 287 |  | 
|---|
|  | 288 | if (fgnzm) { | 
|---|
|  | 289 | char buff[32]; | 
|---|
|  | 290 | for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++)  { | 
|---|
|  | 291 | spectre_.Row(lc) /= (r_4)nzm_[lc]; | 
|---|
|  | 292 | sprintf(buff,"NPaqMoy%d",(int)lc); | 
|---|
|  | 293 | spectre_.Info()[buff] = nzm_[lc]; | 
|---|
|  | 294 | } | 
|---|
|  | 295 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_); | 
|---|
|  | 296 | nfiles_++; | 
|---|
|  | 297 | POutPersist po(fname); | 
|---|
|  | 298 | po << PPFNameTag("spectre") << spectre_; | 
|---|
|  | 299 | spectre_ = (r_4)(0.); | 
|---|
|  | 300 | char buftag[32]; | 
|---|
|  | 301 | for(int lc=0; lc<memgr.NbFibres(); lc++)  { | 
|---|
|  | 302 | sprintf(buftag,"hvalV%d",(int)lc); | 
|---|
|  | 303 | po << PPFNameTag(buftag) << (*phist[lc]); | 
|---|
|  | 304 | phist[lc]->Zero(); | 
|---|
|  | 305 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
|  | 306 | sprintf(buftag,"h2dV%d",(int)lc); | 
|---|
|  | 307 | po << PPFNameTag(buftag) << (*ph2[lc]); | 
|---|
|  | 308 | ph2[lc]->Zero(); | 
|---|
|  | 309 | sprintf(buftag,"hexpV%d",(int)lc); | 
|---|
|  | 310 | po << PPFNameTag(buftag) << (*phexp[lc]); | 
|---|
|  | 311 | phexp[lc]->Zero(); | 
|---|
|  | 312 | sprintf(buftag,"saturV%d",(int)lc); | 
|---|
|  | 313 | po << PPFNameTag(buftag) << (*psatur[lc]); | 
|---|
|  | 314 | (*psatur[lc])=0.; | 
|---|
|  | 315 | sprintf(buftag,"satfreqV%d",(int)lc); | 
|---|
|  | 316 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]); | 
|---|
|  | 317 | (*pvsatfreq[lc])=0; | 
|---|
|  | 318 | } | 
|---|
|  | 319 | nzm_[lc]=0; | 
|---|
|  | 320 | } | 
|---|
|  | 321 | ts.SetNow(); | 
|---|
|  | 322 | // Calcul / impression fraction des paquets avec same-framecounter | 
|---|
|  | 323 | int fracsame=0; | 
|---|
|  | 324 | if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_; | 
|---|
|  | 325 | int totfracsame=0; | 
|---|
|  | 326 | if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_; | 
|---|
|  | 327 | filog << ts << " :  proc file (meanspectra) " << fname << endl; | 
|---|
|  | 328 | filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 329 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 330 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 331 | cout << " MonitorProc::procData1C() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 332 | cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 333 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 334 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 335 | nprocpaq_=npaqsamefc_=0; | 
|---|
|  | 336 | } | 
|---|
|  | 337 | }   // Fin de boucle sur les kmz ( bloc MemZoneMgr  a traiter ) | 
|---|
|  | 338 |  | 
|---|
|  | 339 | bool fgnzm=false; | 
|---|
|  | 340 | for(int lc=0; lc<memgr.NbFibres(); lc++) | 
|---|
|  | 341 | if (nzm_[lc]>0) fgnzm=true; | 
|---|
|  | 342 |  | 
|---|
|  | 343 | if (fgnzm) { | 
|---|
|  | 344 | char buff[32]; | 
|---|
|  | 345 | for(sa_size_t lc=0; lc<memgr.NbFibres(); lc++)  { | 
|---|
|  | 346 | if (nzm_[lc]>0)  spectre_.Row(lc) /= (r_4)nzm_[lc]; | 
|---|
|  | 347 | sprintf(buff,"NPaqMoy%d",(int)lc); | 
|---|
|  | 348 | spectre_.Info()[buff] = nzm_[lc]; | 
|---|
|  | 349 | } | 
|---|
|  | 350 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_); | 
|---|
|  | 351 | POutPersist po(fname); | 
|---|
|  | 352 | po << PPFNameTag("spectre") << spectre_; | 
|---|
|  | 353 | spectre_ = (r_4)(0.); | 
|---|
|  | 354 | char buftag[32]; | 
|---|
|  | 355 | for(int lc=0; lc<memgr.NbFibres(); lc++)  { | 
|---|
|  | 356 | sprintf(buftag,"hvalV%d",(int)lc); | 
|---|
|  | 357 | po << PPFNameTag(buftag) << (*phist[lc]); | 
|---|
|  | 358 | delete phist[lc]; | 
|---|
|  | 359 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
|  | 360 | sprintf(buftag,"h2dV%d",(int)lc); | 
|---|
|  | 361 | po << PPFNameTag(buftag) << (*ph2[lc]); | 
|---|
|  | 362 | delete ph2[lc]; | 
|---|
|  | 363 | sprintf(buftag,"hexpV%d",(int)lc); | 
|---|
|  | 364 | po << PPFNameTag(buftag) << (*phexp[lc]); | 
|---|
|  | 365 | delete phexp[lc]; | 
|---|
|  | 366 | sprintf(buftag,"saturV%d",(int)lc); | 
|---|
|  | 367 | po << PPFNameTag(buftag) << (*psatur[lc]); | 
|---|
|  | 368 | sprintf(buftag,"satfreqV%d",(int)lc); | 
|---|
|  | 369 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]); | 
|---|
|  | 370 | delete psatur[lc]; | 
|---|
|  | 371 | delete pvsatfreq[lc]; | 
|---|
|  | 372 | } | 
|---|
|  | 373 | nzm_[lc]=0; | 
|---|
|  | 374 | } | 
|---|
|  | 375 | ts.SetNow(); | 
|---|
|  | 376 | // Calcul / impression fraction des paquets avec same-framecounter | 
|---|
|  | 377 | int fracsame=0; | 
|---|
|  | 378 | if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_; | 
|---|
|  | 379 | int totfracsame=0; | 
|---|
|  | 380 | if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_; | 
|---|
|  | 381 | filog << ts << " :  proc file (meanspectra) " << fname << endl; | 
|---|
|  | 382 | filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 383 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 384 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 385 | cout << " MonitorProc::procData1C() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 386 | cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 387 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 388 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 389 | } | 
|---|
|  | 390 | return 0; | 
|---|
| [3681] | 391 | } | 
|---|
|  | 392 |  | 
|---|
|  | 393 | /* --Methode-- */ | 
|---|
|  | 394 | int MonitorProc::procData2C(ofstream& filog) | 
|---|
|  | 395 | { | 
|---|
|  | 396 | BRPaqChecker pcheck[MAXNBFIB];  // Verification/comptage des paquets | 
|---|
|  | 397 | // Initialisation pour calcul FFT | 
|---|
|  | 398 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 399 | BRPaquet pq(paqsz); | 
|---|
|  | 400 | TVector<r_4> vx(pq.DataSize()/2); | 
|---|
|  | 401 | vx = (r_4)(0.); | 
|---|
|  | 402 | TVector< complex<r_4> > cfour(pq.DataSize()/4+1);  // composant TF | 
|---|
|  | 403 |  | 
|---|
|  | 404 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
|  | 405 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); | 
|---|
| [3683] | 406 |  | 
|---|
|  | 407 | // Histo pour valeurs des bytes dans les paquets | 
|---|
| [3918] | 408 | Histo* phist[2*MAXNBFIB]; | 
|---|
|  | 409 | Histo2D* ph2[2*MAXNBFIB]; | 
|---|
|  | 410 | Histo* phexp[2*MAXNBFIB]; | 
|---|
|  | 411 | TMatrix<r_4>* psatur[2*MAXNBFIB]; | 
|---|
| [3920] | 412 | TVector<uint_4>* pvsatfreq[2*MAXNBFIB]; | 
|---|
| [3918] | 413 | for(int ifib=0; ifib<2*MAXNBFIB; ifib++) { | 
|---|
|  | 414 | phist[ifib]=NULL; ph2[ifib]=NULL; phexp[ifib]=NULL; psatur[ifib]=NULL; | 
|---|
|  | 415 | } | 
|---|
| [3683] | 416 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
| [3729] | 417 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++) { | 
|---|
| [3683] | 418 | phist[lc] = new Histo(-128.5,+128.5,257); | 
|---|
| [3729] | 419 | ph2[lc]   = new Histo2D(-128.5,+128.5,257, -128.5,+128.5,257); | 
|---|
|  | 420 | phexp[lc] = new Histo(-128.5,+128.5,257); | 
|---|
| [3918] | 421 | psatur[lc] = new TMatrix<r_4>(3,3); | 
|---|
| [3920] | 422 | pvsatfreq[lc] = new TVector<uint_4>(spectre_.NCols()); | 
|---|
| [3918] | 423 | *psatur[lc] = 0.; | 
|---|
| [3729] | 424 | } | 
|---|
| [3683] | 425 | } | 
|---|
|  | 426 | else { | 
|---|
|  | 427 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++) | 
|---|
|  | 428 | phist[lc] = new Histo(-0.5,256.5,257); | 
|---|
|  | 429 | } | 
|---|
|  | 430 |  | 
|---|
| [3681] | 431 | TimeStamp ts; | 
|---|
|  | 432 | char fname[512]; | 
|---|
|  | 433 | nfiles_ = 0; | 
|---|
|  | 434 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
|  | 435 | if (stop_) break; | 
|---|
|  | 436 | if (memgr.GetRunState() == MemZR_Stopped) break; | 
|---|
|  | 437 |  | 
|---|
| [3876] | 438 | int mid = memgr.FindMemZoneId(mmact_);  // MemZA_Proc | 
|---|
| [3681] | 439 | Byte* buffg = memgr.GetMemZone(mid); | 
|---|
|  | 440 | if (buffg == NULL) { | 
|---|
|  | 441 | cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
|  | 442 | break; | 
|---|
|  | 443 | } | 
|---|
|  | 444 | if ((step_>1)&&(kmz%step_ != 0))  { | 
|---|
| [3876] | 445 | memgr.FreeMemZone(mid, mmsta_);  //  MemZS_Proc); | 
|---|
| [3681] | 446 | continue; | 
|---|
|  | 447 | } | 
|---|
|  | 448 | sa_size_t lc=0; | 
|---|
|  | 449 | Byte* fbuff[MAXNBFIB]; | 
|---|
|  | 450 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++)  {  // Boucle sur les fibres | 
|---|
|  | 451 | fbuff[fib] = memgr.GetMemZone(mid,fib); | 
|---|
|  | 452 | if (fbuff[fib] == NULL) { // cela ne devrait pas arriver | 
|---|
|  | 453 | cout << " MonitorProc::procData2C()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl; | 
|---|
|  | 454 | return 9; | 
|---|
|  | 455 | } | 
|---|
|  | 456 | } | 
|---|
| [3918] | 457 |  | 
|---|
|  | 458 | // DBG-ATTENTION : freq 0 pour expo full FFT si reordonne | 
|---|
|  | 459 | int idxexpo=(par_.fgfftshrink)?1023:0; // exposant FFT shrink 1024 freq, ou freq 0 pour full-FFT | 
|---|
| [3681] | 460 |  | 
|---|
|  | 461 | cpaqok_ = (uint_1)0; | 
|---|
|  | 462 | curfc_ = (uint_8)0; | 
|---|
|  | 463 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { | 
|---|
|  | 464 | for(uint_4 i=0; i<memgr.NbPaquets(); i++) { | 
|---|
|  | 465 | BRPaquet paq(fbuff[fib]+i*paqsz, paqsz); | 
|---|
|  | 466 | bool pqok=pcheck[fib].Check(paq,curfc_(fib,i));   // Verification du paquet / FrameCounter | 
|---|
|  | 467 | if (!pqok)  continue; | 
|---|
|  | 468 | cpaqok_(fib,i) = 1; | 
|---|
|  | 469 | sa_size_t lc=2*fib; | 
|---|
|  | 470 | if (par_.fgdatafft) {    // Traitement data de type FFT | 
|---|
|  | 471 | TwoByteComplex* tbcp=paq.Data1C(); | 
|---|
| [3918] | 472 |  | 
|---|
|  | 473 | //  exposant FFT | 
|---|
|  | 474 | phexp[lc]->Add((r_4)tbcp[idxexpo].realD()); | 
|---|
|  | 475 |  | 
|---|
| [3683] | 476 | for(sa_size_t j=1; j<spectre_.NCols(); j++) { | 
|---|
|  | 477 | phist[lc]->Add((r_4)tbcp[j].realD()); | 
|---|
|  | 478 | phist[lc]->Add((r_4)tbcp[j].imagD()); | 
|---|
| [3729] | 479 | ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD()); | 
|---|
| [3918] | 480 | // comptage saturation | 
|---|
|  | 481 | int sir=0, sii=0;  // saturation partie reelle, partie imaginaire | 
|---|
|  | 482 | if (tbcp[j].realI()==-128) sir=-1; | 
|---|
|  | 483 | else if (tbcp[j].realI()==127) sir=1; | 
|---|
|  | 484 | if (tbcp[j].imagI()==-128) sii=-1; | 
|---|
|  | 485 | else if (tbcp[j].imagI()==127) sii=1; | 
|---|
|  | 486 | (*psatur[lc])(sir+1,sii+1)+=1.; | 
|---|
| [3920] | 487 | if ((sir!=0)||(sii!=0))  (*pvsatfreq[lc])(j)+=1; | 
|---|
| [3681] | 488 | spectre_(lc,j) += Zmod2(tbcp[j]); | 
|---|
| [3683] | 489 | } | 
|---|
| [3682] | 490 | nzm_[lc]++; | 
|---|
|  | 491 | tbcp=paq.Data2C();   lc++; | 
|---|
| [3918] | 492 | phexp[lc]->Add((r_4)tbcp[idxexpo].realD()); | 
|---|
| [3683] | 493 | for(sa_size_t j=1; j<spectre_.NCols(); j++) { | 
|---|
|  | 494 | phist[lc]->Add((r_4)tbcp[j].realD()); | 
|---|
|  | 495 | phist[lc]->Add((r_4)tbcp[j].imagD()); | 
|---|
| [3729] | 496 | ph2[lc]->Add((r_4)tbcp[j].realD(), (r_4)tbcp[j].imagD()); | 
|---|
| [3918] | 497 | // comptage saturation | 
|---|
|  | 498 | int sir=0, sii=0;  // saturation partie reelle, partie imaginaire | 
|---|
|  | 499 | if (tbcp[j].realI()==-128) sir=-1; | 
|---|
|  | 500 | else if (tbcp[j].realI()==127) sir=1; | 
|---|
|  | 501 | if (tbcp[j].imagI()==-128) sii=-1; | 
|---|
|  | 502 | else if (tbcp[j].imagI()==127) sii=1; | 
|---|
|  | 503 | (*psatur[lc])(sir+1,sii+1)+=1.; | 
|---|
| [3920] | 504 | if ((sir!=0)||(sii!=0))  (*pvsatfreq[lc])(j)+=1; | 
|---|
| [3918] | 505 |  | 
|---|
| [3681] | 506 | spectre_(lc,j) += Zmod2(tbcp[j]); | 
|---|
| [3683] | 507 | } | 
|---|
| [3682] | 508 | nzm_[lc]++; | 
|---|
| [3681] | 509 | } | 
|---|
|  | 510 | else {   // Traitement RawData | 
|---|
| [3683] | 511 | for(sa_size_t j=0; j<vx.Size(); j++) { | 
|---|
|  | 512 | phist[lc]->Add((r_8)(*(paq.Data1()+j))); | 
|---|
| [3681] | 513 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5; | 
|---|
| [3683] | 514 | } | 
|---|
| [3681] | 515 | fftwf_execute(plan); | 
|---|
|  | 516 | //   ffts_.FFTForward(vx, cfour_); | 
|---|
|  | 517 | for(sa_size_t j=0; j<spectre_.NCols(); j++) | 
|---|
|  | 518 | spectre_(lc,j) += Zmod2(cfour(j+1)); | 
|---|
| [3682] | 519 | nzm_[lc]++;      lc++; | 
|---|
| [3683] | 520 | for(sa_size_t j=0; j<vx.Size(); j++) { | 
|---|
|  | 521 | phist[lc]->Add((r_8)(*(paq.Data2()+j))); | 
|---|
| [3681] | 522 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5; | 
|---|
| [3683] | 523 | } | 
|---|
| [3681] | 524 | fftwf_execute(plan); | 
|---|
|  | 525 | //    ffts_.FFTForward(vx, cfour_); | 
|---|
|  | 526 | for(sa_size_t j=0; j<spectre_.NCols(); j++) | 
|---|
|  | 527 | spectre_(lc,j) += Zmod2(cfour(j+1)); | 
|---|
| [3682] | 528 | nzm_[lc]++; | 
|---|
| [3681] | 529 | } | 
|---|
|  | 530 | }  // FIN de la boucle sur les paquets | 
|---|
|  | 531 | }   // Boucle sur les fibres | 
|---|
| [3876] | 532 | memgr.FreeMemZone(mid, mmsta_);  // MemZS_Proc); | 
|---|
| [3681] | 533 | CheckFrameCounters(); | 
|---|
|  | 534 |  | 
|---|
|  | 535 | nblocproc_ ++; | 
|---|
|  | 536 | totnprocpaq_ += memgr.NbPaquets();  nprocpaq_ += memgr.NbPaquets(); | 
|---|
|  | 537 | bool fgnzm=true; | 
|---|
|  | 538 | for(int lc=0; lc<2*memgr.NbFibres(); lc++) | 
|---|
|  | 539 | if (nzm_[lc]<nmean_) fgnzm=false; | 
|---|
|  | 540 |  | 
|---|
|  | 541 | if (fgnzm) { | 
|---|
|  | 542 | char buff[32]; | 
|---|
|  | 543 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++)  { | 
|---|
|  | 544 | spectre_.Row(lc) /= (r_4)nzm_[lc]; | 
|---|
|  | 545 | sprintf(buff,"NPaqMoy%d",(int)lc); | 
|---|
|  | 546 | spectre_.Info()[buff] = nzm_[lc]; | 
|---|
|  | 547 | } | 
|---|
|  | 548 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_); | 
|---|
|  | 549 | nfiles_++; | 
|---|
|  | 550 | POutPersist po(fname); | 
|---|
| [3683] | 551 | po << PPFNameTag("spectre") << spectre_; | 
|---|
| [3681] | 552 | spectre_ = (r_4)(0.); | 
|---|
| [3683] | 553 | char buftag[32]; | 
|---|
|  | 554 | for(int lc=0; lc<2*memgr.NbFibres(); lc++)  { | 
|---|
|  | 555 | sprintf(buftag,"hvalV%d",(int)lc); | 
|---|
|  | 556 | po << PPFNameTag(buftag) << (*phist[lc]); | 
|---|
|  | 557 | phist[lc]->Zero(); | 
|---|
| [3729] | 558 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
|  | 559 | sprintf(buftag,"h2dV%d",(int)lc); | 
|---|
|  | 560 | po << PPFNameTag(buftag) << (*ph2[lc]); | 
|---|
|  | 561 | ph2[lc]->Zero(); | 
|---|
|  | 562 | sprintf(buftag,"hexpV%d",(int)lc); | 
|---|
|  | 563 | po << PPFNameTag(buftag) << (*phexp[lc]); | 
|---|
|  | 564 | phexp[lc]->Zero(); | 
|---|
| [3918] | 565 | sprintf(buftag,"saturV%d",(int)lc); | 
|---|
|  | 566 | po << PPFNameTag(buftag) << (*psatur[lc]); | 
|---|
|  | 567 | (*psatur[lc])=0.; | 
|---|
| [3920] | 568 | sprintf(buftag,"satfreqV%d",(int)lc); | 
|---|
|  | 569 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]); | 
|---|
|  | 570 | (*pvsatfreq[lc])=0; | 
|---|
| [3729] | 571 | } | 
|---|
| [3683] | 572 | nzm_[lc]=0; | 
|---|
|  | 573 | } | 
|---|
| [3681] | 574 | ts.SetNow(); | 
|---|
|  | 575 | // Calcul / impression fraction des paquets avec same-framecounter | 
|---|
|  | 576 | int fracsame=0; | 
|---|
|  | 577 | if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_; | 
|---|
|  | 578 | int totfracsame=0; | 
|---|
|  | 579 | if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_; | 
|---|
|  | 580 | filog << ts << " :  proc file (meanspectra) " << fname << endl; | 
|---|
|  | 581 | filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 582 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 583 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 584 | cout << " MonitorProc::procData2C() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 585 | cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 586 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 587 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 588 | nprocpaq_=npaqsamefc_=0; | 
|---|
|  | 589 | } | 
|---|
|  | 590 | }   // Fin de boucle sur les kmz ( bloc MemZoneMgr  a traiter ) | 
|---|
|  | 591 |  | 
|---|
|  | 592 | bool fgnzm=false; | 
|---|
|  | 593 | for(int lc=0; lc<2*memgr.NbFibres(); lc++) | 
|---|
|  | 594 | if (nzm_[lc]>0) fgnzm=true; | 
|---|
|  | 595 |  | 
|---|
|  | 596 | if (fgnzm) { | 
|---|
|  | 597 | char buff[32]; | 
|---|
|  | 598 | for(sa_size_t lc=0; lc<2*memgr.NbFibres(); lc++)  { | 
|---|
|  | 599 | if (nzm_[lc]>0)  spectre_.Row(lc) /= (r_4)nzm_[lc]; | 
|---|
|  | 600 | sprintf(buff,"NPaqMoy%d",(int)lc); | 
|---|
|  | 601 | spectre_.Info()[buff] = nzm_[lc]; | 
|---|
|  | 602 | } | 
|---|
|  | 603 | sprintf(fname,"%s/meanspec%d.ppf",path_.c_str(),(int)nfiles_); | 
|---|
|  | 604 | POutPersist po(fname); | 
|---|
| [3683] | 605 | po << PPFNameTag("spectre") << spectre_; | 
|---|
| [3681] | 606 | spectre_ = (r_4)(0.); | 
|---|
| [3683] | 607 | char buftag[32]; | 
|---|
|  | 608 | for(int lc=0; lc<2*memgr.NbFibres(); lc++)  { | 
|---|
|  | 609 | sprintf(buftag,"hvalV%d",(int)lc); | 
|---|
|  | 610 | po << PPFNameTag(buftag) << (*phist[lc]); | 
|---|
|  | 611 | delete phist[lc]; | 
|---|
| [3729] | 612 | if (par_.fgdatafft) {    // data de type FFT | 
|---|
|  | 613 | sprintf(buftag,"h2dV%d",(int)lc); | 
|---|
|  | 614 | po << PPFNameTag(buftag) << (*ph2[lc]); | 
|---|
|  | 615 | delete ph2[lc]; | 
|---|
|  | 616 | sprintf(buftag,"hexpV%d",(int)lc); | 
|---|
|  | 617 | po << PPFNameTag(buftag) << (*phexp[lc]); | 
|---|
|  | 618 | delete phexp[lc]; | 
|---|
| [3918] | 619 | sprintf(buftag,"saturV%d",(int)lc); | 
|---|
|  | 620 | po << PPFNameTag(buftag) << (*psatur[lc]); | 
|---|
| [3920] | 621 | sprintf(buftag,"satfreqV%d",(int)lc); | 
|---|
|  | 622 | po << PPFNameTag(buftag) << (*pvsatfreq[lc]); | 
|---|
|  | 623 | delete psatur[lc]; | 
|---|
|  | 624 | delete pvsatfreq[lc]; | 
|---|
| [3729] | 625 | } | 
|---|
| [3683] | 626 | nzm_[lc]=0; | 
|---|
|  | 627 | } | 
|---|
| [3681] | 628 | ts.SetNow(); | 
|---|
|  | 629 | // Calcul / impression fraction des paquets avec same-framecounter | 
|---|
|  | 630 | int fracsame=0; | 
|---|
|  | 631 | if (nprocpaq_>0)  fracsame=100*npaqsamefc_/nprocpaq_; | 
|---|
|  | 632 | int totfracsame=0; | 
|---|
|  | 633 | if (totnprocpaq_>0)  totfracsame=100*totnpaqsamefc_/totnprocpaq_; | 
|---|
|  | 634 | filog << ts << " :  proc file (meanspectra) " << fname << endl; | 
|---|
|  | 635 | filog << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 636 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 637 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 638 | cout << " MonitorProc::procData2C() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 639 | cout << "  NBlocProcessed=" << nblocproc_ << " NSameFC=" << totnpaqsamefc_ << " / " << totnprocpaq_ | 
|---|
|  | 640 | << " -> " << totfracsame << " % (LastPqs: " << npaqsamefc_ <<  " / " << nprocpaq_ | 
|---|
|  | 641 | << " -> " << fracsame << " % )" << endl; | 
|---|
|  | 642 | } | 
|---|
|  | 643 | return 0; | 
|---|
|  | 644 | } | 
|---|
|  | 645 |  | 
|---|
|  | 646 | /* --Methode-- */ | 
|---|
|  | 647 | int MonitorProc::CheckFrameCounters() | 
|---|
|  | 648 | { | 
|---|
|  | 649 | if (memgr.NbFibres()<2)  { | 
|---|
|  | 650 | npaqsamefc_++;  totnpaqsamefc_++; | 
|---|
|  | 651 | return 99; | 
|---|
|  | 652 | } | 
|---|
|  | 653 | sa_size_t  pidx[MAXNBFIB]; | 
|---|
|  | 654 | sa_size_t maxidx=curfc_.NCols(); | 
|---|
|  | 655 | uint_8 cfc=0; | 
|---|
|  | 656 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++) { | 
|---|
|  | 657 | pidx[fib]=0; | 
|---|
|  | 658 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++; | 
|---|
|  | 659 | } | 
|---|
|  | 660 |  | 
|---|
|  | 661 | bool fgsuite=true; | 
|---|
|  | 662 | while (fgsuite) {   // Boucle sur l'ensemble des paquets | 
|---|
|  | 663 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++)  { | 
|---|
|  | 664 | if ((pidx[fib]>=maxidx)||(cpaqok_(fib,pidx[fib])==0))  { fgsuite=false; break; } | 
|---|
|  | 665 | } | 
|---|
|  | 666 | if (!fgsuite) break; | 
|---|
|  | 667 | cfc=curfc_(0,pidx[0]); | 
|---|
|  | 668 | bool fgsame=true; | 
|---|
|  | 669 | for(uint_4 fib=1; fib<curfc_.NRows(); fib++) { | 
|---|
|  | 670 | if (curfc_(fib,pidx[fib])!=cfc) { | 
|---|
|  | 671 | fgsame=false; | 
|---|
|  | 672 | if (curfc_(fib,pidx[fib]) > cfc)  cfc=curfc_(fib,pidx[fib]); | 
|---|
|  | 673 | } | 
|---|
|  | 674 | } | 
|---|
|  | 675 | if (fgsame) { | 
|---|
|  | 676 | npaqsamefc_++;  totnpaqsamefc_++; | 
|---|
|  | 677 | for(uint_4 fib=0; fib<curfc_.NRows(); fib++) { | 
|---|
|  | 678 | pidx[fib]++; | 
|---|
|  | 679 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++; | 
|---|
|  | 680 | } | 
|---|
|  | 681 | }   // fin if (fgsame) | 
|---|
|  | 682 | else {  // else !fgsame | 
|---|
|  | 683 | for(uint_4 fib=0; fib<memgr.NbFibres(); fib++) { | 
|---|
|  | 684 | if (curfc_(fib,pidx[fib])<cfc) { | 
|---|
|  | 685 | pidx[fib]++; | 
|---|
|  | 686 | while((pidx[fib]<maxidx)&&(cpaqok_(fib,pidx[fib])==0)) pidx[fib]++; | 
|---|
|  | 687 | } | 
|---|
|  | 688 | } | 
|---|
|  | 689 | }   // fin de  else !fgsame | 
|---|
|  | 690 | }  // Fin de while sur l'ensemble des paquets | 
|---|
|  | 691 | return 0; | 
|---|
|  | 692 | } | 
|---|
|  | 693 |  | 
|---|
|  | 694 |  | 
|---|
|  | 695 | static struct sigaction act; | 
|---|
| [3537] | 696 | //------------------------------------------------------- | 
|---|
| [3623] | 697 | // Classe thread de traitement  avec 1 voie par frame | 
|---|
| [3537] | 698 | //------------------------------------------------------- | 
|---|
| [4016] | 699 | /*! | 
|---|
|  | 700 | \class DataProc | 
|---|
|  | 701 | \ingroup TAcq | 
|---|
| [3537] | 702 |  | 
|---|
| [4016] | 703 | \brief Deprecated monitoring class (replaced by MonitorProc) | 
|---|
|  | 704 | */ | 
|---|
|  | 705 |  | 
|---|
| [3623] | 706 | void DataProcSignal(int s) | 
|---|
|  | 707 | { | 
|---|
|  | 708 | cout <<"............................................... receive CtrlC" << endl; | 
|---|
|  | 709 |  | 
|---|
|  | 710 | } | 
|---|
|  | 711 |  | 
|---|
|  | 712 | DataProc::DataProc(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) | 
|---|
| [3537] | 713 | :  memgr(mem) | 
|---|
|  | 714 | { | 
|---|
|  | 715 | nmax_ = nmax; | 
|---|
|  | 716 | nmean_ = nmean; | 
|---|
| [3623] | 717 | step_ = step; | 
|---|
| [3537] | 718 | stop_ = false; | 
|---|
|  | 719 | path_ = path; | 
|---|
| [3623] | 720 | act.sa_handler=DataProcSignal; | 
|---|
| [3537] | 721 | } | 
|---|
|  | 722 |  | 
|---|
|  | 723 |  | 
|---|
| [3623] | 724 | void DataProc::Stop() | 
|---|
|  | 725 | { | 
|---|
|  | 726 | stop_=true; | 
|---|
|  | 727 | //  cout <<" DataProc::Stop ... > STOP " << endl; | 
|---|
|  | 728 | } | 
|---|
|  | 729 |  | 
|---|
| [3537] | 730 | void DataProc::run() | 
|---|
|  | 731 | { | 
|---|
| [3623] | 732 |  | 
|---|
|  | 733 | // sigaddset(&act.sa_mask,SIGINT);  // pour proteger le transfert DMA | 
|---|
|  | 734 | // sigaction(SIGINT,&act,NULL); | 
|---|
| [3537] | 735 | setRC(1); | 
|---|
|  | 736 | try { | 
|---|
|  | 737 | TimeStamp ts; | 
|---|
| [3623] | 738 | cout << " DataProc::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
|  | 739 | << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
| [3634] | 740 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl; | 
|---|
| [3537] | 741 | char fname[512]; | 
|---|
|  | 742 | sprintf(fname,"%s/proc.log",path_.c_str()); | 
|---|
|  | 743 | ofstream filog(fname); | 
|---|
|  | 744 | filog << " DataProc::run() - starting log file " << ts << endl; | 
|---|
| [3623] | 745 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
| [3537] | 746 |  | 
|---|
|  | 747 | // Initialisation pour clcul FFT | 
|---|
|  | 748 | TVector< complex<r_4> > cfour;  // composant TF | 
|---|
|  | 749 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 750 | BRPaquet pq(NULL, NULL, paqsz); | 
|---|
|  | 751 | TVector<r_4> vx(pq.DataSize()); | 
|---|
|  | 752 | vx = (r_4)(0.); | 
|---|
|  | 753 | FFTPackServer ffts; | 
|---|
|  | 754 | ffts.FFTForward(vx, cfour); | 
|---|
|  | 755 | TVector<r_4> spectre; | 
|---|
|  | 756 | spectre.ReSize(cfour.Size()); | 
|---|
|  | 757 |  | 
|---|
| [3623] | 758 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
|  | 759 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); | 
|---|
| [3537] | 760 |  | 
|---|
|  | 761 | uint_4 ifile = 0; | 
|---|
| [3623] | 762 | uint_4 nzm = 0; | 
|---|
| [3537] | 763 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
| [3623] | 764 | if (stop_) break; | 
|---|
| [3537] | 765 | int mid = memgr.FindMemZoneId(MemZA_Proc); | 
|---|
|  | 766 | Byte* buff = memgr.GetMemZone(mid); | 
|---|
|  | 767 | if (buff == NULL) { | 
|---|
|  | 768 | cout << " DataProc::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
|  | 769 | setRC(2); | 
|---|
|  | 770 | return; | 
|---|
|  | 771 | } | 
|---|
|  | 772 | BRPaquet paq0(NULL, buff, paqsz); | 
|---|
| [3623] | 773 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) { | 
|---|
| [3537] | 774 | BRPaquet paq(NULL, buff+i*paqsz, paqsz); | 
|---|
|  | 775 | Byte min = 255; | 
|---|
|  | 776 | Byte max = 0; | 
|---|
|  | 777 |  | 
|---|
|  | 778 | for(sa_size_t j=0; j<vx.Size(); j++) | 
|---|
| [3623] | 779 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5; | 
|---|
| [3537] | 780 | fftwf_execute(plan); | 
|---|
| [3623] | 781 | //        ffts_.FFTForward(vx, cfour_); | 
|---|
| [3537] | 782 | for(sa_size_t j=0; j<spectre.Size(); j++) | 
|---|
|  | 783 | spectre(j) += Zmod2(cfour(j)); | 
|---|
|  | 784 | nzm++; | 
|---|
|  | 785 | } | 
|---|
| [3623] | 786 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) { | 
|---|
| [3537] | 787 | spectre /= (r_4)(nzm); | 
|---|
| [3623] | 788 | spectre.Info()["NPaqMoy"] = nzm; | 
|---|
| [3537] | 789 | sprintf(fname,"%s/spectre%d.ppf",path_.c_str(),(int)ifile); | 
|---|
|  | 790 | POutPersist po(fname); | 
|---|
|  | 791 | po << spectre; | 
|---|
|  | 792 | spectre = (r_4)(0.); | 
|---|
|  | 793 | nzm = 0;  ifile++; | 
|---|
|  | 794 | ts.SetNow(); | 
|---|
|  | 795 | filog << ts << " :  proc file  " << fname << endl; | 
|---|
|  | 796 | cout << " DataProc::run() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 797 | } | 
|---|
|  | 798 |  | 
|---|
|  | 799 | memgr.FreeMemZone(mid, MemZS_Proc); | 
|---|
|  | 800 | } | 
|---|
|  | 801 | } | 
|---|
| [3671] | 802 | catch (std::exception& exc) { | 
|---|
|  | 803 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl; | 
|---|
| [3537] | 804 | setRC(3); | 
|---|
|  | 805 | return; | 
|---|
|  | 806 | } | 
|---|
|  | 807 | catch(...) { | 
|---|
|  | 808 | cout << " DataProc::run()/catched unknown ... exception " << endl; | 
|---|
|  | 809 | setRC(4); | 
|---|
|  | 810 | return; | 
|---|
|  | 811 | } | 
|---|
|  | 812 | setRC(0); | 
|---|
|  | 813 | return; | 
|---|
|  | 814 | } | 
|---|
| [3623] | 815 |  | 
|---|
|  | 816 | //--------------------------------------------------------------- | 
|---|
|  | 817 | // Classe thread de traitement donnees ADC avec 2 voies par frame | 
|---|
|  | 818 | //--------------------------------------------------------------- | 
|---|
|  | 819 |  | 
|---|
| [4016] | 820 | /*! | 
|---|
|  | 821 | \class DataProc2C | 
|---|
|  | 822 | \ingroup TAcq | 
|---|
|  | 823 |  | 
|---|
|  | 824 | \brief Deprecated monitoring class (replaced by MonitorProc) | 
|---|
|  | 825 | */ | 
|---|
|  | 826 |  | 
|---|
| [3623] | 827 | DataProc2C::DataProc2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) | 
|---|
|  | 828 | :  memgr(mem) | 
|---|
|  | 829 | { | 
|---|
|  | 830 | nmax_ = nmax; | 
|---|
|  | 831 | nmean_ = nmean; | 
|---|
|  | 832 | step_ = step; | 
|---|
|  | 833 | stop_ = false; | 
|---|
|  | 834 | path_ = path; | 
|---|
|  | 835 | act.sa_handler=DataProcSignal; | 
|---|
|  | 836 | } | 
|---|
|  | 837 | void DataProc2C::Stop() | 
|---|
|  | 838 | { | 
|---|
|  | 839 | stop_=true; | 
|---|
|  | 840 | // cout <<" DataProc2C::Stop ... > STOP " << endl; | 
|---|
|  | 841 | } | 
|---|
|  | 842 |  | 
|---|
|  | 843 | void DataProc2C::run() | 
|---|
|  | 844 | { | 
|---|
|  | 845 | //   sigaction(SIGINT,&act,NULL); | 
|---|
|  | 846 | setRC(1); | 
|---|
|  | 847 | try { | 
|---|
|  | 848 | TimeStamp ts; | 
|---|
|  | 849 | cout << " DataProc2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
|  | 850 | << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
| [3634] | 851 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl; | 
|---|
| [3623] | 852 | char fname[512]; | 
|---|
|  | 853 | sprintf(fname,"%s/proc.log",path_.c_str()); | 
|---|
|  | 854 | ofstream filog(fname); | 
|---|
|  | 855 | filog << " DataProc2C::run() - starting log file " << ts << endl; | 
|---|
|  | 856 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
|  | 857 |  | 
|---|
|  | 858 | // Initialisation pour clcul FFT | 
|---|
|  | 859 | TVector< complex<r_4> > cfour;  // composant TF | 
|---|
|  | 860 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 861 | BRPaquet pq(NULL, NULL, paqsz); | 
|---|
|  | 862 | TVector<r_4> vx(pq.DataSize()/2); | 
|---|
|  | 863 | vx = (r_4)(0.); | 
|---|
|  | 864 | FFTPackServer ffts; | 
|---|
|  | 865 | ffts.FFTForward(vx, cfour); | 
|---|
|  | 866 | TVector<r_4> spectreV1, spectreV2; | 
|---|
|  | 867 | spectreV1.ReSize(cfour.Size()); | 
|---|
|  | 868 | spectreV2.ReSize(cfour.Size()); | 
|---|
|  | 869 |  | 
|---|
|  | 870 | fftwf_plan plan = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
|  | 871 | (fftwf_complex *)cfour.Data(), FFTW_ESTIMATE); | 
|---|
|  | 872 |  | 
|---|
|  | 873 | uint_4 ifile = 0; | 
|---|
|  | 874 | uint_4 nzm = 0; | 
|---|
|  | 875 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
|  | 876 | if (stop_) break; | 
|---|
|  | 877 | int mid = memgr.FindMemZoneId(MemZA_Proc); | 
|---|
|  | 878 | Byte* buff = memgr.GetMemZone(mid); | 
|---|
|  | 879 | if (buff == NULL) { | 
|---|
|  | 880 | cout << " DataProc2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
|  | 881 | setRC(2); | 
|---|
|  | 882 | return; | 
|---|
|  | 883 | } | 
|---|
|  | 884 | BRPaquet paq0(NULL, buff, paqsz); | 
|---|
|  | 885 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) { | 
|---|
|  | 886 | BRPaquet paq(NULL, buff+i*paqsz, paqsz); | 
|---|
|  | 887 | Byte min = 255; | 
|---|
|  | 888 | Byte max = 0; | 
|---|
|  | 889 |  | 
|---|
|  | 890 | for(sa_size_t j=0; j<vx.Size(); j++) | 
|---|
|  | 891 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5; | 
|---|
|  | 892 | fftwf_execute(plan); | 
|---|
|  | 893 | //   ffts_.FFTForward(vx, cfour_); | 
|---|
|  | 894 | for(sa_size_t j=0; j<spectreV1.Size(); j++) | 
|---|
|  | 895 | spectreV1(j) += Zmod2(cfour(j)); | 
|---|
|  | 896 |  | 
|---|
|  | 897 | for(sa_size_t j=0; j<vx.Size(); j++) | 
|---|
|  | 898 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5; | 
|---|
|  | 899 | fftwf_execute(plan); | 
|---|
|  | 900 | //    ffts_.FFTForward(vx, cfour_); | 
|---|
|  | 901 | for(sa_size_t j=0; j<spectreV2.Size(); j++) | 
|---|
|  | 902 | spectreV2(j) += Zmod2(cfour(j)); | 
|---|
|  | 903 |  | 
|---|
|  | 904 | nzm++; | 
|---|
|  | 905 | } | 
|---|
|  | 906 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) { | 
|---|
|  | 907 | spectreV1 /= (r_4)(nzm); | 
|---|
|  | 908 | spectreV2 /= (r_4)(nzm); | 
|---|
|  | 909 | spectreV1.Info()["NPaqMoy"] = nzm; | 
|---|
|  | 910 | spectreV2.Info()["NPaqMoy"] = nzm; | 
|---|
|  | 911 | { | 
|---|
|  | 912 | sprintf(fname,"%s/spectre2C_%d.ppf",path_.c_str(),(int)ifile); | 
|---|
|  | 913 | POutPersist po(fname); | 
|---|
|  | 914 | po << PPFNameTag("specV1") << spectreV1; | 
|---|
|  | 915 | po << PPFNameTag("specV2") << spectreV2; | 
|---|
|  | 916 | } | 
|---|
|  | 917 | spectreV1 = (r_4)(0.); | 
|---|
|  | 918 | spectreV2 = (r_4)(0.); | 
|---|
|  | 919 | nzm = 0;  ifile++; | 
|---|
|  | 920 | ts.SetNow(); | 
|---|
|  | 921 | filog << ts << " :  proc file  " << fname << endl; | 
|---|
|  | 922 | cout << " DataProc2C::run() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 923 | } | 
|---|
|  | 924 |  | 
|---|
|  | 925 | memgr.FreeMemZone(mid, MemZS_Proc); | 
|---|
|  | 926 | } | 
|---|
|  | 927 | } | 
|---|
| [3671] | 928 | catch (std::exception& exc) { | 
|---|
|  | 929 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl; | 
|---|
| [3623] | 930 | setRC(3); | 
|---|
|  | 931 | return; | 
|---|
|  | 932 | } | 
|---|
|  | 933 | catch(...) { | 
|---|
|  | 934 | cout << " DataProc2C::run()/catched unknown ... exception " << endl; | 
|---|
|  | 935 | setRC(4); | 
|---|
|  | 936 | return; | 
|---|
|  | 937 | } | 
|---|
|  | 938 | setRC(0); | 
|---|
|  | 939 | return; | 
|---|
|  | 940 | } | 
|---|
|  | 941 |  | 
|---|
|  | 942 |  | 
|---|
|  | 943 |  | 
|---|
|  | 944 |  | 
|---|
|  | 945 | //--------------------------------------------------------------- | 
|---|
|  | 946 | // Classe thread de traitement donnees FFT avec 2 voies par frame | 
|---|
|  | 947 | //--------------------------------------------------------------- | 
|---|
| [4016] | 948 | /*! | 
|---|
|  | 949 | \class DataProcFFT2C | 
|---|
|  | 950 | \ingroup TAcq | 
|---|
| [3623] | 951 |  | 
|---|
| [4016] | 952 | \brief Deprecated monitoring class (replaced by MonitorProc) | 
|---|
|  | 953 | */ | 
|---|
|  | 954 |  | 
|---|
| [3623] | 955 | inline r_4 Zmod2TwoByte(TwoByteComplex z) | 
|---|
|  | 956 | { return (z.realD()*z.realD()+z.imagD()*z.imagD()); } | 
|---|
|  | 957 |  | 
|---|
|  | 958 | DataProcFFT2C::DataProcFFT2C(RAcqMemZoneMgr& mem, string& path, uint_4 nmean, uint_4 step, uint_4 nmax) | 
|---|
|  | 959 | :  memgr(mem) | 
|---|
|  | 960 | { | 
|---|
|  | 961 | nmax_ = nmax; | 
|---|
|  | 962 | nmean_ = nmean; | 
|---|
|  | 963 | step_ = step; | 
|---|
|  | 964 | stop_ = false; | 
|---|
|  | 965 | path_ = path; | 
|---|
|  | 966 | act.sa_handler=DataProcSignal; | 
|---|
|  | 967 | } | 
|---|
|  | 968 | void DataProcFFT2C::Stop() | 
|---|
|  | 969 | { | 
|---|
|  | 970 | stop_=true; | 
|---|
|  | 971 | // cout <<" DataProcFFT2C::Stop ... > STOP " << endl; | 
|---|
|  | 972 | } | 
|---|
|  | 973 |  | 
|---|
|  | 974 | void DataProcFFT2C::run() | 
|---|
|  | 975 | { | 
|---|
|  | 976 | // sigaction(SIGINT,&act,NULL); | 
|---|
|  | 977 | setRC(1); | 
|---|
|  | 978 | try { | 
|---|
|  | 979 | TimeStamp ts; | 
|---|
|  | 980 | cout << " DataProcFFT2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
|  | 981 | << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
| [3634] | 982 | cout << " DataProc::run()... - Output Data Path: " << path_ << endl; | 
|---|
| [3623] | 983 | char fname[512]; | 
|---|
|  | 984 | sprintf(fname,"%s/proc.log",path_.c_str()); | 
|---|
|  | 985 | ofstream filog(fname); | 
|---|
|  | 986 | filog << " DataProcFFT2C::run() - starting log file " << ts << endl; | 
|---|
|  | 987 | filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
|  | 988 |  | 
|---|
|  | 989 | // Initialisation pour clcul FFT | 
|---|
|  | 990 | TVector< complex<r_4> > cfour;  // composant TF | 
|---|
|  | 991 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
|  | 992 | BRPaquet pq(NULL, NULL, paqsz); | 
|---|
|  | 993 |  | 
|---|
|  | 994 | TVector<r_4> spectreV1(pq.DataSize()/4+1), spectreV2(pq.DataSize()/4+1); | 
|---|
|  | 995 |  | 
|---|
|  | 996 | uint_4 ifile = 0; | 
|---|
|  | 997 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
|  | 998 | if (stop_ ) break; | 
|---|
|  | 999 | int mid = memgr.FindMemZoneId(MemZA_Proc); | 
|---|
|  | 1000 | Byte* buff = memgr.GetMemZone(mid); | 
|---|
|  | 1001 | if (buff == NULL) { | 
|---|
|  | 1002 | cout << " DataProcFFT2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
|  | 1003 | setRC(2); | 
|---|
|  | 1004 | return; | 
|---|
|  | 1005 | } | 
|---|
|  | 1006 | BRPaquet paq0(NULL, buff, paqsz); | 
|---|
|  | 1007 | uint_4 nzm = 0; | 
|---|
|  | 1008 | for(uint_4 i=0; i<memgr.NbPaquets(); i+=step_) { | 
|---|
|  | 1009 | BRPaquet paq(NULL, buff+i*paqsz, paqsz); | 
|---|
|  | 1010 | Byte min = 255; | 
|---|
|  | 1011 | Byte max = 0; | 
|---|
|  | 1012 |  | 
|---|
|  | 1013 | TwoByteComplex* zz; | 
|---|
|  | 1014 | // Traitement Voie 1 | 
|---|
|  | 1015 | zz = (TwoByteComplex*)paq.Data1(); | 
|---|
|  | 1016 | spectreV1(0) += zz[0].realD()*zz[0].realD();  // Composante continue, partie reelle uniquement | 
|---|
|  | 1017 | for(sa_size_t j=1; j<spectreV1.Size()-1; j++)  spectreV1(j) += Zmod2TwoByte(zz[j]); | 
|---|
|  | 1018 |  | 
|---|
|  | 1019 | spectreV1(spectreV1.Size()-1) += zz[0].imagD()*zz[0].imagD();  // Freq. Nyquist a N/2 | 
|---|
|  | 1020 |  | 
|---|
|  | 1021 | // Traitement Voie 2 | 
|---|
|  | 1022 | zz = (TwoByteComplex*)paq.Data2(); | 
|---|
|  | 1023 | spectreV2(0) += zz[0].realD()*zz[0].realD();  // Composante continue, partie reelle uniquement | 
|---|
|  | 1024 | for(sa_size_t j=1; j<spectreV2.Size()-1; j++)  spectreV2(j) += Zmod2TwoByte(zz[j]); | 
|---|
|  | 1025 |  | 
|---|
|  | 1026 | spectreV2(spectreV2.Size()-1) += zz[0].imagD()*zz[0].imagD();  // Freq. Nyquist a N/2 | 
|---|
|  | 1027 |  | 
|---|
|  | 1028 | nzm++; | 
|---|
|  | 1029 | } | 
|---|
|  | 1030 | if ((nzm >= nmean_) ||(kmz==(nmax_-1))) { | 
|---|
|  | 1031 | spectreV1 /= (r_4)(nzm); | 
|---|
|  | 1032 | spectreV2 /= (r_4)(nzm); | 
|---|
|  | 1033 | spectreV1.Info()["NPaqMoy"] = nzm; | 
|---|
|  | 1034 | spectreV2.Info()["NPaqMoy"] = nzm; | 
|---|
|  | 1035 | { | 
|---|
|  | 1036 | sprintf(fname,"%s/spectreFFT2C_%d.ppf",path_.c_str(),(int)ifile); | 
|---|
|  | 1037 | POutPersist po(fname); | 
|---|
|  | 1038 | po << PPFNameTag("specV1") << spectreV1; | 
|---|
|  | 1039 | po << PPFNameTag("specV2") << spectreV2; | 
|---|
|  | 1040 | } | 
|---|
|  | 1041 | spectreV1 = (r_4)(0.); | 
|---|
|  | 1042 | spectreV2 = (r_4)(0.); | 
|---|
|  | 1043 | nzm = 0;  ifile++; | 
|---|
|  | 1044 | ts.SetNow(); | 
|---|
|  | 1045 | filog << ts << " :  proc file  " << fname << endl; | 
|---|
|  | 1046 | cout << " DataProcFFT2C::run() " << ts << " : created file  " << fname << endl; | 
|---|
|  | 1047 | } | 
|---|
|  | 1048 |  | 
|---|
|  | 1049 | memgr.FreeMemZone(mid, MemZS_Proc); | 
|---|
|  | 1050 | } | 
|---|
|  | 1051 | } | 
|---|
| [3671] | 1052 | catch (std::exception& exc) { | 
|---|
|  | 1053 | cout << " DataProc::run()/catched std::exception " << exc.what() << endl; | 
|---|
| [3623] | 1054 | setRC(3); | 
|---|
|  | 1055 | return; | 
|---|
|  | 1056 | } | 
|---|
|  | 1057 | catch(...) { | 
|---|
|  | 1058 | cout << " DataProcFFT2C::run()/catched unknown ... exception " << endl; | 
|---|
|  | 1059 | setRC(4); | 
|---|
|  | 1060 | return; | 
|---|
|  | 1061 | } | 
|---|
|  | 1062 | setRC(0); | 
|---|
|  | 1063 | return; | 
|---|
|  | 1064 | } | 
|---|