| 1 | #include "racquproc.h" | 
|---|
| 2 |  | 
|---|
| 3 | #include <stdlib.h> | 
|---|
| 4 | #include <string.h> | 
|---|
| 5 | #include <unistd.h> | 
|---|
| 6 | #include <fstream> | 
|---|
| 7 | #include <signal.h> | 
|---|
| 8 |  | 
|---|
| 9 | #include "pexceptions.h" | 
|---|
| 10 | #include "tvector.h" | 
|---|
| 11 | #include "ntuple.h" | 
|---|
| 12 | #include "datatable.h" | 
|---|
| 13 | #include "histos.h" | 
|---|
| 14 | #include "fioarr.h" | 
|---|
| 15 | #include "matharr.h" | 
|---|
| 16 | #include "timestamp.h" | 
|---|
| 17 | #include "ctimer.h" | 
|---|
| 18 | #include "fftpserver.h" | 
|---|
| 19 | #include "fftwserver.h" | 
|---|
| 20 |  | 
|---|
| 21 | #include "FFTW/fftw3.h" | 
|---|
| 22 |  | 
|---|
| 23 |  | 
|---|
| 24 | #include "pciewrap.h" | 
|---|
| 25 | #include "brpaqu.h" | 
|---|
| 26 | #include "brproc.h" | 
|---|
| 27 |  | 
|---|
| 28 | //--------------------------------------------------------------------- | 
|---|
| 29 | // Classe de traitement - calcul de visibilite pour n fibres | 
|---|
| 30 | //--------------------------------------------------------------------- | 
|---|
| 31 |  | 
|---|
| 32 | /* --Methode-- */ | 
|---|
| 33 | BRVisibilityCalculator::BRVisibilityCalculator(RAcqMemZoneMgr& memgr, string outpath, uint_4 nmean, | 
|---|
| 34 | uint_4 freq1, uint_4 freq2, uint_4 nbfreq, size_t nthr) | 
|---|
| 35 | : BRBaseProcessor(memgr), paralex_(*this, nthr), nparthr_(nthr), outpath_(outpath), nmean_(nmean), | 
|---|
| 36 | numfreq1_(freq1), numfreq2_(freq2), nbinfreq_(nbfreq), vpdata_(2*memgr.NbFibres()) | 
|---|
| 37 | // , dtfos_(outpath+"visdt.fits", Fits_Create), visdt_(dtfos_, 1024, true); | 
|---|
| 38 |  | 
|---|
| 39 | { | 
|---|
| 40 | BRPaquet paq(memgr_.PaqSize()); | 
|---|
| 41 |  | 
|---|
| 42 | vismtx_.SetSize((2*memgr_.NbFibres()+1)*memgr_.NbFibres(), paq.DataSize()/4); | 
|---|
| 43 | chanum_.SetSize(vismtx_.NRows()); | 
|---|
| 44 | sa_size_t k=0; | 
|---|
| 45 | for(size_t i=0; i<2*memgr_.NbFibres(); i++)  vpdata_[i]=NULL; | 
|---|
| 46 | for(size_t i=0; i<2*memgr_.NbFibres(); i++) { | 
|---|
| 47 | for(size_t j=i; j<2*memgr_.NbFibres(); j++) { | 
|---|
| 48 | chanum_(k) = (i+1)*100+(j+1);  k++; | 
|---|
| 49 | } | 
|---|
| 50 | } | 
|---|
| 51 | //  visdt_.AddFloatColumn("mfc"); | 
|---|
| 52 | visdt_.AddDoubleColumn("mfc"); | 
|---|
| 53 | visdt_.AddDoubleColumn("mtt"); | 
|---|
| 54 | visdt_.AddIntegerColumn("jfreq"); | 
|---|
| 55 | visdt_.AddIntegerColumn("numch"); | 
|---|
| 56 | visdt_.AddFloatColumn("vre"); | 
|---|
| 57 | visdt_.AddFloatColumn("vim"); | 
|---|
| 58 |  | 
|---|
| 59 | if (nmean_ < 1)  nmean_=memgr_.NbPaquets(); | 
|---|
| 60 | if (nmean_ < 1)  nmean_=1; | 
|---|
| 61 |  | 
|---|
| 62 | totnbpaq_=0; | 
|---|
| 63 | numfile_=0; | 
|---|
| 64 | moyfc_=moytt_=0.; | 
|---|
| 65 |  | 
|---|
| 66 | jf1_=numfreq1_; jf2_=numfreq2_; | 
|---|
| 67 | if ((jf1_<1)||(jf1_>=vismtx_.NCols()))  jf1_=1; | 
|---|
| 68 | if ((jf2_<1)||(jf2_>=vismtx_.NCols())||(jf2_<jf1_))  jf2_=vismtx_.NCols()-1; | 
|---|
| 69 | if (nbinfreq_<1) nbinfreq_=1; | 
|---|
| 70 | djf_=(jf2_-jf1_)/nbinfreq_; | 
|---|
| 71 | if (djf_<1) djf_=0; | 
|---|
| 72 | xnt_ = new double[vismtx_.NRows()+20]; | 
|---|
| 73 | for(int kk=0; kk<vismtx_.NRows(); kk++)  xnt_[kk]=0.; | 
|---|
| 74 |  | 
|---|
| 75 | cout << " BRVisibilityCalculator/Info NMean= " << nmean_ << " JF1=" << jf1_ | 
|---|
| 76 | << " JF2=" << jf2_ << " DJF=" << djf_ << endl; | 
|---|
| 77 |  | 
|---|
| 78 | fgallfibok=NULL; | 
|---|
| 79 | fgcktt_=false; | 
|---|
| 80 | } | 
|---|
| 81 |  | 
|---|
| 82 | /* --Methode-- */ | 
|---|
| 83 | BRVisibilityCalculator::~BRVisibilityCalculator() | 
|---|
| 84 | { | 
|---|
| 85 | cout << " BRVisibilityCalculator - Visibility Datatable : " << endl; | 
|---|
| 86 | cout << visdt_; | 
|---|
| 87 | POutPersist po(outpath_+"visdt.ppf"); | 
|---|
| 88 | po << visdt_; | 
|---|
| 89 | POutPersist poc(outpath_+"chanum.ppf"); | 
|---|
| 90 | poc << chanum_; | 
|---|
| 91 |  | 
|---|
| 92 | if (fgcktt_) { | 
|---|
| 93 | cout << " BRVisibilityCalculator -  Check TimeTag done: TotNPaqProc= " << totnbpaq_ << endl; | 
|---|
| 94 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  { | 
|---|
| 95 | cout << " BRTTCheck-Fiber[" << fib << "] NBadTT=" << vbadtt_[fib] << " NDiffTT>5=" | 
|---|
| 96 | << vndiff5tt_[fib] << "  NotSameTT=" << vnsamett_[fib] << endl; | 
|---|
| 97 | } | 
|---|
| 98 | POutPersist pott(outpath_+"ttfcmtx.ppf"); | 
|---|
| 99 | pott << PPFNameTag("FC") << fcmtx_; | 
|---|
| 100 | pott << PPFNameTag("TT") << ttmtx_; | 
|---|
| 101 | } | 
|---|
| 102 | delete[] xnt_; | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | /* --Methode-- */ | 
|---|
| 106 | void BRVisibilityCalculator::run() | 
|---|
| 107 | { | 
|---|
| 108 | if (nparthr_ < 2)  return BRBaseProcessor::run(); | 
|---|
| 109 | // Execution multithread parallele | 
|---|
| 110 | setRC(1); | 
|---|
| 111 | int rc=0; | 
|---|
| 112 | try { | 
|---|
| 113 | cout << " BRVisibilityCalculator::run() - Starting " << " NFibers=" << memgr_.NbFibres() | 
|---|
| 114 | << " NChan=" << 2*memgr_.NbFibres() << endl; | 
|---|
| 115 | if ((nmean_%memgr_.NbPaquets())!=0) { | 
|---|
| 116 | uint_4 mnmean = (nmean_/memgr_.NbPaquets()+1)*memgr_.NbPaquets(); | 
|---|
| 117 | cout << " BRVisibilityCalculator::run()/Info changing nmean=" << nmean_  << " to multiple of" | 
|---|
| 118 | << " memgr_.NbPaquets() -> " << mnmean << endl; | 
|---|
| 119 | nmean_=mnmean; | 
|---|
| 120 | } | 
|---|
| 121 | paralex_.SetParallelTask(*this); | 
|---|
| 122 | cout << " BRVisibilityCalculator::run()/Info : starting ParallelExecutor with nThreads=" | 
|---|
| 123 | << paralex_.nThreads() << " ... " << endl; | 
|---|
| 124 | paralex_.start(); | 
|---|
| 125 |  | 
|---|
| 126 | fgallfibok = new bool[memgr_.NbPaquets()]; | 
|---|
| 127 |  | 
|---|
| 128 | size_t paqsz=memgr_.PaqSize(); | 
|---|
| 129 | bool fgrun=true; | 
|---|
| 130 | while (fgrun) { | 
|---|
| 131 | if (stop_) break; | 
|---|
| 132 | if (memgr_.GetRunState() == MemZR_Stopped) break; | 
|---|
| 133 | int mid = memgr_.FindMemZoneId(MemZA_ProcA); | 
|---|
| 134 | Byte* buffg = memgr_.GetMemZone(mid); | 
|---|
| 135 | if (buffg == NULL) { | 
|---|
| 136 | cout << "BRVisibilityCalculator::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
| 137 | setRC(7);      fgrun=false; | 
|---|
| 138 | break; | 
|---|
| 139 | } | 
|---|
| 140 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { | 
|---|
| 141 | fbuff_[fib] = memgr_.GetMemZone(mid,fib); | 
|---|
| 142 | if (fbuff_[fib] == NULL) { // cela ne devrait pas arriver | 
|---|
| 143 | cout << "BRBaseProcessor::run()/ERROR memgr.GetMemZone(" << mid << "," << fib << ") -> NULL" << endl; | 
|---|
| 144 | setRC(9);       fgrun=false; | 
|---|
| 145 | break; | 
|---|
| 146 | } | 
|---|
| 147 | } | 
|---|
| 148 |  | 
|---|
| 149 | if (totnbpaq_%nmean_ == 0) { | 
|---|
| 150 | if (totnbpaq_ > 0) { | 
|---|
| 151 | moyfc_/=nmean_; | 
|---|
| 152 | moytt_/=nmean_; | 
|---|
| 153 | vismtx_.Info()["MeanFC"] = moyfc_; | 
|---|
| 154 | vismtx_.Info()["MeanTT"] = moytt_; | 
|---|
| 155 | vismtx_.Info()["NPAQSUM"] = nmean_; | 
|---|
| 156 |  | 
|---|
| 157 | // ATTENTION : Matrice visibilites non moyennee | 
|---|
| 158 | char nfile[32]; | 
|---|
| 159 | sprintf(nfile,"vismtx%d.ppf",numfile_); | 
|---|
| 160 | string flnm=outpath_+nfile; | 
|---|
| 161 | POutPersist po(flnm); | 
|---|
| 162 | po << vismtx_; | 
|---|
| 163 | cout << numfile_ << "-BRVisibilityCalculator::run() NPaqProc=" | 
|---|
| 164 | << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl; | 
|---|
| 165 | FillVisibTable(moyfc_, moytt_); | 
|---|
| 166 | numfile_++; | 
|---|
| 167 | } | 
|---|
| 168 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.); | 
|---|
| 169 | moyfc_=moytt_=0.; | 
|---|
| 170 | } | 
|---|
| 171 |  | 
|---|
| 172 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone | 
|---|
| 173 | fgallfibok[jp]=fgokallfibers_=true; | 
|---|
| 174 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { | 
|---|
| 175 | vpaq_[fib].Set(fbuff_[fib]+jp*paqsz); | 
|---|
| 176 | vfgok_[fib] = vpchk_[fib].Check(vpaq_[fib],curfc_[fib]); | 
|---|
| 177 | if (!vfgok_[fib])  fgallfibok[jp]=fgokallfibers_=false; | 
|---|
| 178 | } | 
|---|
| 179 | if (fgokallfibers_)  { | 
|---|
| 180 | if (totprocnpaq_==0) { | 
|---|
| 181 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  { | 
|---|
| 182 | fcfirst_[fib]=curfc_[fib]; | 
|---|
| 183 | ttfirst_[fib]=vpaq_[fib].TimeTag(); | 
|---|
| 184 | } | 
|---|
| 185 | } | 
|---|
| 186 | totprocnpaq_++; | 
|---|
| 187 | moyfc_ += curfc_[0]; | 
|---|
| 188 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]); | 
|---|
| 189 | if (fgcktt_)  CheckTimeTag(); | 
|---|
| 190 | totnbpaq_++; | 
|---|
| 191 | } | 
|---|
| 192 | }  // Fin de boucle sur les paquets | 
|---|
| 193 |  | 
|---|
| 194 | // Execution parallele  pour calcul des visibilites par bandes de frequence | 
|---|
| 195 | int rcpex=paralex_.execute(); | 
|---|
| 196 | if (rcpex!=0)  cout << " BRVisibilityCalculator::run() / Error Rc[paralex_.execute()]=" << rcpex << endl; | 
|---|
| 197 |  | 
|---|
| 198 | memgr_.FreeMemZone(mid, MemZS_ProcA); | 
|---|
| 199 | } // Fin de boucle sur les zones a traiter | 
|---|
| 200 | //------------------------------------ | 
|---|
| 201 | cout << " --------- END BRVisibilityCalculator::run() , TotNbProcPaq=" << totprocnpaq_ << endl; | 
|---|
| 202 | /* | 
|---|
| 203 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  vpchk_[fib].Print(); | 
|---|
| 204 | cout << " ------------------------------------ " << endl; | 
|---|
| 205 | */ | 
|---|
| 206 | delete[] fgallfibok; | 
|---|
| 207 | } | 
|---|
| 208 | catch (std::exception& exc) { | 
|---|
| 209 | cout << " BRBaseProcessor::run()/catched std::exception " << exc.what() << endl; | 
|---|
| 210 | setRC(98); | 
|---|
| 211 | return; | 
|---|
| 212 | } | 
|---|
| 213 | catch(...) { | 
|---|
| 214 | cout << " BRBaseProcessor::run()/catched unknown ... exception " << endl; | 
|---|
| 215 | setRC(99); | 
|---|
| 216 | return; | 
|---|
| 217 | } | 
|---|
| 218 |  | 
|---|
| 219 | } | 
|---|
| 220 |  | 
|---|
| 221 | /* --Methode-- */ | 
|---|
| 222 | int BRVisibilityCalculator::ActivateTimeTagCheck(uint_8 maxnpaq) | 
|---|
| 223 | { | 
|---|
| 224 | mindeltatt_=memgr_.PaqSize()/2; | 
|---|
| 225 | if (mindeltatt_<1) mindeltatt_=1; | 
|---|
| 226 | fcmtx_.SetSize(memgr_.NbFibres(), maxnpaq); | 
|---|
| 227 | ttmtx_.SetSize(memgr_.NbFibres(), maxnpaq); | 
|---|
| 228 | vlasttt_.resize(memgr_.NbFibres(), 0); | 
|---|
| 229 | vbadtt_.resize(memgr_.NbFibres(), 0); | 
|---|
| 230 | vnsamett_.resize(memgr_.NbFibres(), 0); | 
|---|
| 231 | vndiff5tt_.resize(memgr_.NbFibres(), 0); | 
|---|
| 232 |  | 
|---|
| 233 | fgcktt_=true; | 
|---|
| 234 | cout << " BRVisibilityCalculator::ActivateTimeTagCheck() - TT/Fc matrix NCols=" << maxnpaq | 
|---|
| 235 | << " MinDeltaTT=" << mindeltatt_ << endl; | 
|---|
| 236 |  | 
|---|
| 237 | return 0; | 
|---|
| 238 | } | 
|---|
| 239 |  | 
|---|
| 240 | /* --Methode-- */ | 
|---|
| 241 | int BRVisibilityCalculator::Process() | 
|---|
| 242 | { | 
|---|
| 243 |  | 
|---|
| 244 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { | 
|---|
| 245 | vpdata_[2*fib] = vpaq_[fib].Data1C(); | 
|---|
| 246 | vpdata_[2*fib+1] = vpaq_[fib].Data2C(); | 
|---|
| 247 | } | 
|---|
| 248 |  | 
|---|
| 249 | if (totnbpaq_%nmean_ == 0) { | 
|---|
| 250 | if (totnbpaq_ > 0) { | 
|---|
| 251 | moyfc_/=nmean_; | 
|---|
| 252 | moytt_/=nmean_; | 
|---|
| 253 | vismtx_.Info()["MeanFC"] = moyfc_; | 
|---|
| 254 | vismtx_.Info()["MeanTT"] = moytt_; | 
|---|
| 255 | vismtx_.Info()["NPAQSUM"] = nmean_; | 
|---|
| 256 |  | 
|---|
| 257 | // ATTENTION : Matrice visibilites non moyennee | 
|---|
| 258 | char nfile[32]; | 
|---|
| 259 | sprintf(nfile,"vismtx%d.ppf",numfile_); | 
|---|
| 260 | string flnm=outpath_+nfile; | 
|---|
| 261 | POutPersist po(flnm); | 
|---|
| 262 | po << vismtx_; | 
|---|
| 263 | cout << numfile_ << "-BRVisibilityCalculator::Process() NPaqProc=" | 
|---|
| 264 | << totnbpaq_ << "  -> Visibility Matrix in " << flnm << endl; | 
|---|
| 265 | FillVisibTable(moyfc_, moytt_); | 
|---|
| 266 | numfile_++; | 
|---|
| 267 | } | 
|---|
| 268 | vismtx_ = complex<r_4>((r_4)0.,(r_4)0.); | 
|---|
| 269 | moyfc_=moytt_=0.; | 
|---|
| 270 | } | 
|---|
| 271 |  | 
|---|
| 272 | sa_size_t k=0; | 
|---|
| 273 | for(size_t i=0; i<vpdata_.size(); i++) { | 
|---|
| 274 | for(size_t j=i; j<vpdata_.size(); j++) { | 
|---|
| 275 | TVector< complex<r_4> > vis = vismtx_.Row(k);   k++; | 
|---|
| 276 | for(sa_size_t f=1; f<vis.Size(); f++) { | 
|---|
| 277 | vis(f) += complex<r_4>((r_4)vpdata_[i][f].realB(), (r_4)vpdata_[i][f].imagB()) * | 
|---|
| 278 | complex<r_4>((r_4)vpdata_[j][f].realB(), -(r_4)vpdata_[j][f].imagB()); | 
|---|
| 279 | } | 
|---|
| 280 | } | 
|---|
| 281 | } | 
|---|
| 282 |  | 
|---|
| 283 | moyfc_ += curfc_[0]; | 
|---|
| 284 | moytt_ += (vpaq_[0].TimeTag()-ttfirst_[0]); | 
|---|
| 285 | if (fgcktt_)  CheckTimeTag(); | 
|---|
| 286 | totnbpaq_++; | 
|---|
| 287 | return 0; | 
|---|
| 288 | } | 
|---|
| 289 |  | 
|---|
| 290 | /* --Methode-- */ | 
|---|
| 291 | int BRVisibilityCalculator::execute(int tid) | 
|---|
| 292 | { | 
|---|
| 293 | vector<TwoByteComplex*>  pvpdata(2*memgr_.NbFibres()); | 
|---|
| 294 | size_t paqsz=memgr_.PaqSize(); | 
|---|
| 295 | BRPaquet ppaq(paqsz); | 
|---|
| 296 |  | 
|---|
| 297 | sa_size_t fdelt = vismtx_.NCols()/nparthr_; | 
|---|
| 298 | sa_size_t fdeb = tid*fdelt; | 
|---|
| 299 | sa_size_t ffin = (tid+1)*fdelt; | 
|---|
| 300 |  | 
|---|
| 301 | if (fdeb<1) fdeb=1; | 
|---|
| 302 | if ((ffin>vismtx_.NCols())||(tid==(nparthr_-1))) ffin=vismtx_.NCols(); | 
|---|
| 303 |  | 
|---|
| 304 | for(size_t jp=0; jp<memgr_.NbPaquets(); jp++) {   // boucle sur les paquets d'une zone | 
|---|
| 305 | if (!fgallfibok[jp])  continue; | 
|---|
| 306 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { | 
|---|
| 307 | ppaq.Set(fbuff_[fib]+jp*paqsz); | 
|---|
| 308 | pvpdata[2*fib] = ppaq.Data1C(); | 
|---|
| 309 | pvpdata[2*fib+1] = ppaq.Data2C(); | 
|---|
| 310 | } | 
|---|
| 311 | sa_size_t k=0; | 
|---|
| 312 | for(size_t i=0; i<vpdata_.size(); i++) { | 
|---|
| 313 | for(size_t j=i; j<vpdata_.size(); j++) { | 
|---|
| 314 | TVector< complex<r_4> > vis = vismtx_.Row(k);   k++; | 
|---|
| 315 | for(sa_size_t f=fdeb; f<ffin; f++) { | 
|---|
| 316 | vis(f) += complex<r_4>((r_4)pvpdata[i][f].realB(), (r_4)pvpdata[i][f].imagB()) * | 
|---|
| 317 | complex<r_4>((r_4)pvpdata[j][f].realB(), -(r_4)pvpdata[j][f].imagB()); | 
|---|
| 318 | } | 
|---|
| 319 | } | 
|---|
| 320 | } | 
|---|
| 321 |  | 
|---|
| 322 | }  // Fin de boucle sur les paquets | 
|---|
| 323 |  | 
|---|
| 324 | return 0; | 
|---|
| 325 | } | 
|---|
| 326 |  | 
|---|
| 327 | /* --Methode-- */ | 
|---|
| 328 | int BRVisibilityCalculator::FillVisibTable(double fcm, double ttm) | 
|---|
| 329 | { | 
|---|
| 330 | xnt_[0]=fcm;  xnt_[1]=ttm/1.25e8; | 
|---|
| 331 |  | 
|---|
| 332 | if (djf_<2) { | 
|---|
| 333 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) { | 
|---|
| 334 | for(sa_size_t jf=jf1_; jf<jf2_; jf++) { | 
|---|
| 335 | xnt_[2]=jf; | 
|---|
| 336 | xnt_[3]=chanum_(rv); | 
|---|
| 337 | xnt_[4]=vismtx_(rv,jf).real()/(r_4)(nmean_); | 
|---|
| 338 | xnt_[5]=vismtx_(rv,jf).imag()/(r_4)(nmean_); | 
|---|
| 339 | visdt_.AddRow(xnt_); | 
|---|
| 340 | } | 
|---|
| 341 | } | 
|---|
| 342 | } | 
|---|
| 343 | else { | 
|---|
| 344 | for(sa_size_t rv=0; rv<vismtx_.NRows(); rv++) { | 
|---|
| 345 | for(sa_size_t jf=jf1_; jf<jf2_; jf+=djf_) { | 
|---|
| 346 | r_4 moyreal=0.; | 
|---|
| 347 | r_4 moyimag=0.; | 
|---|
| 348 | sa_size_t jjfmx=jf+djf_; | 
|---|
| 349 | if (jjfmx > vismtx_.NCols()) jjfmx=vismtx_.NCols(); | 
|---|
| 350 | for(sa_size_t jjf=jf; jjf<jjfmx; jjf++) { | 
|---|
| 351 | moyreal+=vismtx_(rv,jjf).real(); | 
|---|
| 352 | moyimag+=vismtx_(rv,jjf).imag(); | 
|---|
| 353 | } | 
|---|
| 354 | xnt_[2]=jf+djf_/2; | 
|---|
| 355 | xnt_[3]=chanum_(rv); | 
|---|
| 356 | xnt_[4]=moyreal/(r_4)(nmean_*djf_); | 
|---|
| 357 | xnt_[5]=moyimag/(r_4)(nmean_*djf_); | 
|---|
| 358 | visdt_.AddRow(xnt_); | 
|---|
| 359 | } | 
|---|
| 360 | } | 
|---|
| 361 | } | 
|---|
| 362 | return 0; | 
|---|
| 363 | } | 
|---|
| 364 |  | 
|---|
| 365 | /* --Methode-- */ | 
|---|
| 366 | int BRVisibilityCalculator::CheckTimeTag() | 
|---|
| 367 | { | 
|---|
| 368 | if (totnbpaq_==0) { | 
|---|
| 369 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++)  { | 
|---|
| 370 | vlasttt_[fib]=ttfirst_[fib]; | 
|---|
| 371 | if (ttmtx_.NCols()>0) { | 
|---|
| 372 | fcmtx_(fib,totnbpaq_) = curfc_[fib]; | 
|---|
| 373 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; | 
|---|
| 374 | } | 
|---|
| 375 | } | 
|---|
| 376 | return 0; | 
|---|
| 377 | } | 
|---|
| 378 | for(size_t fib=0; fib<(size_t)memgr_.NbFibres(); fib++) { | 
|---|
| 379 | int_8 ld = (int_8)vpaq_[fib].TimeTag()-(int_8)vlasttt_[fib]; | 
|---|
| 380 | int_8 fd = (int_8)vpaq_[fib].TimeTag()-(int_8)ttfirst_[fib]-(int_8)vpaq_[0].TimeTag()+(int_8)ttfirst_[0]; | 
|---|
| 381 | /*    if ( (ld < mindeltatt_) || (fd<-5) || (fd>5)) { vbadtt_[fib]++; vnsamett_[fib]++; } | 
|---|
| 382 | else { | 
|---|
| 383 | if (fd!=0)  vnsamett_[fib]++; | 
|---|
| 384 | } | 
|---|
| 385 | */ | 
|---|
| 386 | if  (ld < mindeltatt_) vbadtt_[fib]++; | 
|---|
| 387 | else { | 
|---|
| 388 | if (fd != 0)  vnsamett_[fib]++; | 
|---|
| 389 | if ((fd<-5)||(fd>5))  vndiff5tt_[fib]++; | 
|---|
| 390 | } | 
|---|
| 391 | vlasttt_[fib]=vpaq_[fib].TimeTag(); | 
|---|
| 392 | if (totnbpaq_<ttmtx_.NCols()) { | 
|---|
| 393 | fcmtx_(fib,totnbpaq_) = curfc_[fib]; | 
|---|
| 394 | ttmtx_(fib,totnbpaq_) = vlasttt_[fib]; | 
|---|
| 395 | } | 
|---|
| 396 | } | 
|---|
| 397 | return 0; | 
|---|
| 398 | } | 
|---|
| 399 |  | 
|---|
| 400 | //--------------------------------------------------------------- | 
|---|
| 401 | // Classe thread de traitement donnees ADC avec 2 voies par frame | 
|---|
| 402 | //--------------------------------------------------------------- | 
|---|
| 403 |  | 
|---|
| 404 | // Mutex pour eviter le plantage du a FFTW qui ne semble pas thread-safe | 
|---|
| 405 | static ZMutex* pmutfftw=NULL; | 
|---|
| 406 |  | 
|---|
| 407 | /* --Methode-- */ | 
|---|
| 408 | BRProcA2C::BRProcA2C(RAcqMemZoneMgr& mem, string& path, bool fgraw, uint_4 nmean, | 
|---|
| 409 | uint_4 nmax, bool fghist, uint_4 nfsmap, bool fgnotrl, int card) | 
|---|
| 410 | :  memgr(mem) | 
|---|
| 411 | { | 
|---|
| 412 | fgraw_ = fgraw; | 
|---|
| 413 | nmax_ = nmax; | 
|---|
| 414 | nmean_ = nmean; | 
|---|
| 415 | if (fgraw_) cout << " BRProcA2C::BRProcA2C() - constructeur RAW data - NMean=" << nmean_ << endl; | 
|---|
| 416 | else cout << " BRProcA2C::BRProcA2C() - constructeur FFT data - NMean=" << nmean_ << endl; | 
|---|
| 417 | nfsmap_ = nfsmap; | 
|---|
| 418 | stop_ = false; | 
|---|
| 419 | path_ = path; | 
|---|
| 420 | fgnotrl_ = fgnotrl; | 
|---|
| 421 | fghist_ = fghist; | 
|---|
| 422 | card_ = card; | 
|---|
| 423 | if (pmutfftw==NULL) pmutfftw=new ZMutex; | 
|---|
| 424 | } | 
|---|
| 425 |  | 
|---|
| 426 | /* --Methode-- */ | 
|---|
| 427 | void BRProcA2C::Stop() | 
|---|
| 428 | { | 
|---|
| 429 | stop_=true; | 
|---|
| 430 | // cout <<" BRProcA2C::Stop ... > STOP " << endl; | 
|---|
| 431 | } | 
|---|
| 432 |  | 
|---|
| 433 |  | 
|---|
| 434 | static inline r_4 Zmod2(complex<r_4> z) | 
|---|
| 435 | { return (z.real()*z.real()+z.imag()*z.imag()); } | 
|---|
| 436 |  | 
|---|
| 437 | static inline string card2name_(int card) | 
|---|
| 438 | { | 
|---|
| 439 | if (card==2) return " (Chan3,4) "; | 
|---|
| 440 | else return " (Chan1,2) "; | 
|---|
| 441 | } | 
|---|
| 442 | /* --Methode-- */ | 
|---|
| 443 | void BRProcA2C::run() | 
|---|
| 444 | { | 
|---|
| 445 | setRC(1); | 
|---|
| 446 | try { | 
|---|
| 447 | Timer tm("BRProcA2C", false); | 
|---|
| 448 | TimeStamp ts; | 
|---|
| 449 | BRPaqChecker pcheck(!fgnotrl_);  // Verification/comptage des paquets | 
|---|
| 450 |  | 
|---|
| 451 | size_t totnbytesout = 0; | 
|---|
| 452 | size_t totnbytesproc = 0; | 
|---|
| 453 |  | 
|---|
| 454 | cout << " BRProcA2C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
| 455 | << " NMean=" << nmean_ << card2name_(card_) << endl; | 
|---|
| 456 | cout << " BRProcA2C::run()... - Output Data Path: " << path_ << endl; | 
|---|
| 457 | char fname[512]; | 
|---|
| 458 | //    sprintf(fname,"%s/proc.log",path_.c_str()); | 
|---|
| 459 | //    ofstream filog(fname); | 
|---|
| 460 | //    filog << " BRProcA2C::run() - starting log file " << ts << endl; | 
|---|
| 461 | //    filog << " ... NMaxMemZones=" << nmax_ << " NMean=" << nmean_ << " Step=" << step_ << endl; | 
|---|
| 462 |  | 
|---|
| 463 | /*----DELETE   NTuple | 
|---|
| 464 | const char* nnames[8] = {"fcs","tts","s1","s2","s12","s12re","s12im","s12phi"}; | 
|---|
| 465 | NTuple nt(8, nnames); | 
|---|
| 466 | double xnt[10]; | 
|---|
| 467 | uint_4 nmnt = 0; | 
|---|
| 468 | double ms1,ms2,ms12,ms12re,ms12im,ms12phi; | 
|---|
| 469 | ----*/ | 
|---|
| 470 | // Time sample (raw data) /FFT coeff histograms | 
|---|
| 471 | Histo* ph1=NULL; | 
|---|
| 472 | Histo* ph2=NULL; | 
|---|
| 473 | if (fghist_) { | 
|---|
| 474 | if (fgraw_) { | 
|---|
| 475 | ph1 = new Histo(-0.5, 255.5, 256); | 
|---|
| 476 | ph2 = new Histo(-0.5, 255.5, 256); | 
|---|
| 477 | } | 
|---|
| 478 | else { | 
|---|
| 479 | ph1 = new Histo(-128.5, 128.5, 257); | 
|---|
| 480 | ph2 = new Histo(-128.5, 128.5, 257); | 
|---|
| 481 | } | 
|---|
| 482 | } | 
|---|
| 483 |  | 
|---|
| 484 | // Initialisation pour calcul FFT | 
|---|
| 485 | TVector< complex<r_4> > cfour1;  // composant TF | 
|---|
| 486 | uint_4 paqsz = memgr.PaqSize(); | 
|---|
| 487 | uint_4 procpaqsz = memgr.ProcPaqSize(); | 
|---|
| 488 |  | 
|---|
| 489 |  | 
|---|
| 490 | BRPaquet pq(NULL, NULL, paqsz); | 
|---|
| 491 | TVector<r_4> vx(pq.DataSize()/2); | 
|---|
| 492 | int szfour = pq.DataSize()/2/2+1; | 
|---|
| 493 | cfour1.SetSize(szfour); | 
|---|
| 494 | /* | 
|---|
| 495 | vx = (r_4)(0.); | 
|---|
| 496 | FFTPackServer ffts; | 
|---|
| 497 | ffts.FFTForward(vx, cfour1); | 
|---|
| 498 | szfour = cfour1.Size(); | 
|---|
| 499 | */ | 
|---|
| 500 |  | 
|---|
| 501 | bool fgtimfreq = false;  // true->cartes temps<>frequences | 
|---|
| 502 | if (nfsmap_>0) fgtimfreq=true; | 
|---|
| 503 |  | 
|---|
| 504 | TVector< complex<r_4> > cfour2(cfour1.Size()); | 
|---|
| 505 |  | 
|---|
| 506 | TVector<r_4> spectreV1(cfour1.Size()); | 
|---|
| 507 | TVector<r_4> spectreV2(cfour1.Size()); | 
|---|
| 508 | TVector<r_4> moyspecV1(cfour1.Size());   // Moyenne des Spectres | 
|---|
| 509 | TVector<r_4> moyspecV2(cfour1.Size()); | 
|---|
| 510 | TVector<r_4> sigspecV1(cfour1.Size());   // Sigma des Spectres | 
|---|
| 511 | TVector<r_4> sigspecV2(cfour1.Size()); | 
|---|
| 512 | TVector< complex<r_4> > visiV12( cfour1.Size() ); | 
|---|
| 513 |  | 
|---|
| 514 | TMatrix<r_4> timfreqV1, timfreqV2;   // Cartes temps<>frequences | 
|---|
| 515 | if (fgtimfreq) { | 
|---|
| 516 | timfreqV1.SetSize(nmean_, spectreV1.Size()/nfsmap_); | 
|---|
| 517 | timfreqV2.SetSize(nmean_, spectreV2.Size()/nfsmap_); | 
|---|
| 518 | } | 
|---|
| 519 | cout << " *DBG*BRProcA2C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz | 
|---|
| 520 | << " procpaqsz/2=" << procpaqsz/2 << " cfour1.Size()=" << cfour1.Size() | 
|---|
| 521 | << " *8="  << cfour1.Size()*8 << endl; | 
|---|
| 522 |  | 
|---|
| 523 | pmutfftw->lock(); | 
|---|
| 524 | fftwf_plan plan1 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
| 525 | (fftwf_complex*)cfour1.Data(), FFTW_ESTIMATE); | 
|---|
| 526 | fftwf_plan plan2 = fftwf_plan_dft_r2c_1d(vx.Size(), vx.Data(), | 
|---|
| 527 | (fftwf_complex*)cfour2.Data(), FFTW_ESTIMATE); | 
|---|
| 528 | pmutfftw->unlock(); | 
|---|
| 529 |  | 
|---|
| 530 | uint_4 ifile = 0; | 
|---|
| 531 | uint_4 nzm = 0;  // Nb de paquets moyennes pour le calcul de chaque spectre | 
|---|
| 532 | uint_4 nmoyspec = 0;  // Nb de spectres moyennes | 
|---|
| 533 |  | 
|---|
| 534 | uint_4 curfc=0; | 
|---|
| 535 | uint_8 curtt=0; | 
|---|
| 536 | uint_8 firsttt=0; | 
|---|
| 537 | bool fgfirst=true; | 
|---|
| 538 | double moysig[2]={0.,0.}; | 
|---|
| 539 | double sigsig[2]={0.,0.}; | 
|---|
| 540 | uint_8 nbsig[2]={0,0}; | 
|---|
| 541 |  | 
|---|
| 542 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
| 543 | if (stop_) break; | 
|---|
| 544 | int mid = memgr.FindMemZoneId(MemZA_ProcA); | 
|---|
| 545 | Byte* buff = memgr.GetMemZone(mid); | 
|---|
| 546 | if (buff == NULL) { | 
|---|
| 547 | cout << " BRProcA2C::run()/ERROR memgr.GetMemZone(" << mid << ") -> NULL" << endl; | 
|---|
| 548 | break; | 
|---|
| 549 | } | 
|---|
| 550 | Byte* procbuff = memgr.GetProcMemZone(mid); | 
|---|
| 551 | if (procbuff == NULL) { | 
|---|
| 552 | cout << " BRProcA2C::run()/ERROR memgr.GetProcMemZone(" << mid << ") -> NULL" << endl; | 
|---|
| 553 | break; | 
|---|
| 554 | } | 
|---|
| 555 | //---- DELETE      nmnt=0;  ms1=ms2=ms12=ms12re=ms12im=ms12phi=0.; | 
|---|
| 556 | for(uint_4 i=0; i<memgr.NbPaquets(); i++) { | 
|---|
| 557 | BRPaquet paq(NULL, buff+i*paqsz, paqsz); | 
|---|
| 558 | if (!pcheck.Check(paq)) continue;   // on ne traite que les paquets OK | 
|---|
| 559 | if (fgfirst) { firsttt=paq.TimeTag(); fgfirst=false; } | 
|---|
| 560 | curfc=paq.FrameCounter(); | 
|---|
| 561 | curtt=paq.TimeTag()-firsttt; | 
|---|
| 562 | // Traitement voie 1 | 
|---|
| 563 | if (fghist_) { | 
|---|
| 564 | for(sa_size_t j=0; j<vx.Size(); j++) { | 
|---|
| 565 | r_4 vts=(fgraw_)?((r_4)(*(paq.Data1()+j))):((r_4)(*(paq.Data1S()+j))); | 
|---|
| 566 | ph1->Add((r_8)vts); | 
|---|
| 567 | moysig[0] += (double)vts; | 
|---|
| 568 | sigsig[0] += ((double)vts)*((double)vts); | 
|---|
| 569 | nbsig[0]++; | 
|---|
| 570 | } | 
|---|
| 571 | for(sa_size_t j=0; j<vx.Size(); j++) { | 
|---|
| 572 | r_4 vts=(fgraw_)?((r_4)(*(paq.Data2()+j))):((r_4)(*(paq.Data2S()+j))); | 
|---|
| 573 | ph2->Add((r_8)vts); | 
|---|
| 574 | moysig[1] += (double)vts; | 
|---|
| 575 | sigsig[1] += ((double)vts)*((double)vts); | 
|---|
| 576 | nbsig[1]++; | 
|---|
| 577 | } | 
|---|
| 578 | } | 
|---|
| 579 | if (fgraw_) { | 
|---|
| 580 | for(sa_size_t j=0; j<vx.Size(); j++) | 
|---|
| 581 | vx(j) = (r_4)(*(paq.Data1()+j))-127.5; | 
|---|
| 582 | //        fftwf_complex* coeff1 = (fftwf_complex*)(procbuff+i*procpaqsz); | 
|---|
| 583 | fftwf_execute(plan1); | 
|---|
| 584 | // Traitement voie 2 | 
|---|
| 585 | for(sa_size_t j=0; j<vx.Size(); j++) | 
|---|
| 586 | vx(j) = (r_4)(*(paq.Data2()+j))-127.5; | 
|---|
| 587 | fftwf_execute(plan2); | 
|---|
| 588 | } | 
|---|
| 589 | else { | 
|---|
| 590 | for(sa_size_t j=1; j<cfour1.Size()-1; j++) { | 
|---|
| 591 | cfour1(j) = complex<r_4>((r_4)paq.Data1C()[j].realB(), (r_4)paq.Data1C()[j].imagB()); | 
|---|
| 592 | cfour2(j) = complex<r_4>((r_4)paq.Data2C()[j].realB(), (r_4)paq.Data2C()[j].imagB()); | 
|---|
| 593 | } | 
|---|
| 594 | cfour1(0) = complex<r_4>((r_4)paq.Data1C()[0].realB(), (r_4)0.); | 
|---|
| 595 | cfour1(cfour1.Size()-1) = complex<r_4>((r_4)paq.Data1C()[0].imagB(), (r_4)0.); | 
|---|
| 596 | cfour2(0) = complex<r_4>((r_4)paq.Data2C()[0].realB(), (r_4)0.); | 
|---|
| 597 | cfour2(cfour2.Size()-1) = complex<r_4>((r_4)paq.Data2C()[0].imagB(), (r_4)0.); | 
|---|
| 598 | } | 
|---|
| 599 | for(sa_size_t j=0; j<spectreV1.Size(); j++) | 
|---|
| 600 | spectreV1(j) += Zmod2(cfour1(j)); | 
|---|
| 601 | memcpy(procbuff+i*procpaqsz, cfour1.Data(), sizeof(complex<r_4>)*cfour1.Size()); | 
|---|
| 602 | if (fgtimfreq) {   // Remplissage tableau temps-frequence | 
|---|
| 603 | for(sa_size_t c=1; c<timfreqV1.NCols(); c++) { | 
|---|
| 604 | for(sa_size_t j=c*nfsmap_; j<(c+1)*nfsmap_; j++) | 
|---|
| 605 | timfreqV1(nzm, c) += Zmod2(cfour1(j)); | 
|---|
| 606 | } | 
|---|
| 607 | } | 
|---|
| 608 | for(sa_size_t j=0; j<spectreV2.Size(); j++) | 
|---|
| 609 | spectreV2(j) += Zmod2(cfour2(j));  // Zmod2(zp2[j]); | 
|---|
| 610 | memcpy(procbuff+i*procpaqsz+procpaqsz/2, cfour2.Data(), sizeof(complex<r_4>)*cfour2.Size()); | 
|---|
| 611 | if (fgtimfreq) {   // Remplissage tableau temps-frequence | 
|---|
| 612 | for(sa_size_t c=1; c<timfreqV2.NCols(); c++) { | 
|---|
| 613 | for(sa_size_t j=c*nfsmap_; j<(c+1)*nfsmap_; j++) | 
|---|
| 614 | timfreqV2(nzm,c) += Zmod2(cfour2(j)); | 
|---|
| 615 | } | 
|---|
| 616 | } | 
|---|
| 617 |  | 
|---|
| 618 | // Calcul correlation (visibilite V1 * V2) | 
|---|
| 619 | for(sa_size_t j=0; j<visiV12.Size(); j++) | 
|---|
| 620 | visiV12(j)+=cfour1(j)*conj(cfour2(j)); | 
|---|
| 621 | //        for(sa_size_t j=0; j<visiV12.Size(); j++) visiV12(j)+=zp1[j]*zp2[j]; | 
|---|
| 622 | if (nzm==0) { | 
|---|
| 623 | spectreV1.Info()["StartFC"] = curfc; | 
|---|
| 624 | spectreV2.Info()["StartFC"] = curfc; | 
|---|
| 625 | visiV12.Info()["StartFC"] = curfc; | 
|---|
| 626 | spectreV1.Info()["StartTT"] = curtt; | 
|---|
| 627 | spectreV2.Info()["StartTT"] = curtt; | 
|---|
| 628 | visiV12.Info()["StartTT"] = curtt; | 
|---|
| 629 | } | 
|---|
| 630 | nzm++; | 
|---|
| 631 | /*----DELETE | 
|---|
| 632 | if (nmnt==0)  { xnt[0]=paq.FrameCounter();  xnt[1]=paq.TimeTag(); } | 
|---|
| 633 | for(sa_size_t j=2700; j<2800; j++) { | 
|---|
| 634 | ms1 += Zmod2(cfour1(j)); ms2 += Zmod2(cfour2(j)); | 
|---|
| 635 | complex<r_4> zvis =  cfour1(j)*conj(cfour2(j)); | 
|---|
| 636 | ms12 += Zmod2(zvis);   ms12re += zvis.real();  ms12im += zvis.imag(); | 
|---|
| 637 | ms12phi+= atan2(zvis.imag(),zvis.real()); | 
|---|
| 638 | } | 
|---|
| 639 | nmnt++; | 
|---|
| 640 | ----*/ | 
|---|
| 641 | totnbytesproc += paq.DataSize(); | 
|---|
| 642 | totnbytesout += (2*sizeof(complex<r_4>)*cfour1.Size()); | 
|---|
| 643 |  | 
|---|
| 644 | } // Fin de boucle sur les paquets d'une zone | 
|---|
| 645 |  | 
|---|
| 646 | /*---- DELETE | 
|---|
| 647 | if (nmnt>0)  { | 
|---|
| 648 | double fnorm = (double)nmnt*(2800-2700); | 
|---|
| 649 | xnt[2] = ms1 /= fnorm; | 
|---|
| 650 | xnt[3] = ms2 /= fnorm; | 
|---|
| 651 | xnt[4] = ms12 /= fnorm; | 
|---|
| 652 | xnt[5] = ms12re /= fnorm; | 
|---|
| 653 | xnt[6] = ms12im /= fnorm; | 
|---|
| 654 | xnt[7] = ms12phi /= fnorm; | 
|---|
| 655 | nt.Fill(xnt); | 
|---|
| 656 | } | 
|---|
| 657 | ----*/ | 
|---|
| 658 | if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) { | 
|---|
| 659 | spectreV1 /= (r_4)(nzm); | 
|---|
| 660 | spectreV2 /= (r_4)(nzm); | 
|---|
| 661 |  | 
|---|
| 662 | // pour le calcul des moyennes et sigmas de ces spectres | 
|---|
| 663 | moyspecV1 += spectreV1; | 
|---|
| 664 | moyspecV2 += spectreV2; | 
|---|
| 665 | sigspecV1 += (spectreV1 && spectreV1); | 
|---|
| 666 | sigspecV2 += (spectreV2 && spectreV2); | 
|---|
| 667 | nmoyspec++; | 
|---|
| 668 |  | 
|---|
| 669 | visiV12 /= complex<r_4>((r_4)nzm, 0.); | 
|---|
| 670 |  | 
|---|
| 671 | spectreV1.Info()["NPaqMoy"] = nzm; | 
|---|
| 672 | spectreV2.Info()["NPaqMoy"] = nzm; | 
|---|
| 673 | visiV12.Info()["NPaqMoy"] = nzm; | 
|---|
| 674 | spectreV1.Info()["EndFC"] = curfc; | 
|---|
| 675 | spectreV2.Info()["EndFC"] = curfc; | 
|---|
| 676 | visiV12.Info()["EndFC"] = curfc; | 
|---|
| 677 | spectreV1.Info()["EndTT"] = curtt; | 
|---|
| 678 | spectreV2.Info()["EndTT"] = curtt; | 
|---|
| 679 | visiV12.Info()["EndTT"] = curtt; | 
|---|
| 680 | { | 
|---|
| 681 | sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile); | 
|---|
| 682 | POutPersist po(fname); | 
|---|
| 683 | string tag1="specV1"; | 
|---|
| 684 | string tag2="specV2"; | 
|---|
| 685 | string tag12="visiV12"; | 
|---|
| 686 | string tagh1="tshV1"; | 
|---|
| 687 | string tagh2="tshV2"; | 
|---|
| 688 | string tagtf1="timfreqV1"; | 
|---|
| 689 | string tagtf2="timfreqV2"; | 
|---|
| 690 | if (card_==2) { | 
|---|
| 691 | tag1 = "specV3"; | 
|---|
| 692 | tag2 = "specV4"; | 
|---|
| 693 | tagh1 = "tshV1"; | 
|---|
| 694 | tagh2 = "tshV2"; | 
|---|
| 695 | tag12="visiV34"; | 
|---|
| 696 | tagtf1="timfreqV3"; | 
|---|
| 697 | tagtf2="timfreqV4"; | 
|---|
| 698 | } | 
|---|
| 699 | po << PPFNameTag(tag1) << spectreV1; | 
|---|
| 700 | po << PPFNameTag(tag2) << spectreV2; | 
|---|
| 701 | po << PPFNameTag(tag12) << visiV12; | 
|---|
| 702 | if (fghist_) { | 
|---|
| 703 | po << PPFNameTag(tagh1) << (*ph1); | 
|---|
| 704 | po << PPFNameTag(tagh2) << (*ph2); | 
|---|
| 705 |  | 
|---|
| 706 | double sspvmax[3] = {0.,0.,0.}; | 
|---|
| 707 | int_4 sspvmaxidx[3] = {-1,-1,-1}; | 
|---|
| 708 | for(int jji=1;jji<visiV12.Size()-1;jji++) { | 
|---|
| 709 | r_4 zmv2 = Zmod2(visiV12(jji)); | 
|---|
| 710 | if (zmv2>sspvmax[2]) { sspvmax[2]=zmv2; sspvmaxidx[2]=jji; } | 
|---|
| 711 | } | 
|---|
| 712 | TVector<r_4>& sspv = spectreV1; | 
|---|
| 713 | for(int ic=0; ic<2; ic++) { | 
|---|
| 714 | if (ic==1) sspv = spectreV2; | 
|---|
| 715 | for(int jji=1;jji<sspv.Size()-1;jji++) | 
|---|
| 716 | if (sspv(jji)>sspvmax[ic]) { sspvmax[ic]=sspv(jji); sspvmaxidx[ic]=jji; } | 
|---|
| 717 | if (nbsig[ic] < 1) { moysig[ic]=sigsig[ic]=-1.;  } | 
|---|
| 718 | else { | 
|---|
| 719 | moysig[ic] /= (double)nbsig[ic]; | 
|---|
| 720 | sigsig[ic] /= (double)nbsig[ic]; | 
|---|
| 721 | sigsig[ic] -= (moysig[ic]*moysig[ic]); | 
|---|
| 722 | sigsig[ic] = sqrt(sigsig[ic]); | 
|---|
| 723 | cout << "===Voie " << ic << " Moy=" << moysig[ic] << " Sig=" << sigsig[ic] | 
|---|
| 724 | << " MaxSpec Amp= " << sqrt(sspvmax[ic])/double(pq.DataSize()/2/2) | 
|---|
| 725 | << " Pos=" << sspvmaxidx[ic] << "  (NPts=" << nbsig[ic] << ")" << endl; | 
|---|
| 726 | } | 
|---|
| 727 | } | 
|---|
| 728 | cout << "=== Voie1x2 MaxSpec Amp= " << sqrt(sqrt(sspvmax[2])/double(pq.DataSize()/2/2)) | 
|---|
| 729 | << " Pos=" << sspvmaxidx[2] << endl; | 
|---|
| 730 | }  // fin if (fghist_) | 
|---|
| 731 |  | 
|---|
| 732 | if (fgtimfreq) { | 
|---|
| 733 | timfreqV1 /= (r_4)nzm; | 
|---|
| 734 | timfreqV2 /= (r_4)nzm; | 
|---|
| 735 | po << PPFNameTag(tagtf1) << timfreqV1; | 
|---|
| 736 | po << PPFNameTag(tagtf2) << timfreqV2; | 
|---|
| 737 | } | 
|---|
| 738 | } | 
|---|
| 739 | spectreV1 = (r_4)(0.); | 
|---|
| 740 | spectreV2 = (r_4)(0.); | 
|---|
| 741 | visiV12 = complex<r_4>(0., 0.); | 
|---|
| 742 | if (fghist_) { | 
|---|
| 743 | ph1->Zero(); | 
|---|
| 744 | ph2->Zero(); | 
|---|
| 745 | moysig[0]=moysig[1]=0.; | 
|---|
| 746 | sigsig[0]=sigsig[1]=0.; | 
|---|
| 747 | nbsig[0]=nbsig[1]=0; | 
|---|
| 748 | } | 
|---|
| 749 | if (fgtimfreq) { | 
|---|
| 750 | timfreqV1 = (r_4)(0.); | 
|---|
| 751 | timfreqV2 = (r_4)(0.); | 
|---|
| 752 | } | 
|---|
| 753 | nzm = 0;  ifile++; | 
|---|
| 754 | //        ts.SetNow(); | 
|---|
| 755 | //        filog << ts << " :  proc file  " << fname << endl; | 
|---|
| 756 | cout << " BRProcA2C::run() created file  " << fname << card2name_(card_) << endl; | 
|---|
| 757 | } | 
|---|
| 758 |  | 
|---|
| 759 | memgr.FreeMemZone(mid, MemZS_ProcA); | 
|---|
| 760 | }  // Fin de boucle sur les zones a traiter | 
|---|
| 761 | cout << " ------------  BRProcA2C::run() END " << card2name_(card_) | 
|---|
| 762 | << " ------------ " << endl; | 
|---|
| 763 | /*---- DELETE | 
|---|
| 764 | { | 
|---|
| 765 | nt.Info()["FirstTT"]=firsttt; | 
|---|
| 766 | cout << nt; | 
|---|
| 767 | sprintf(fname,"%s_nt.ppf",path_.c_str()); | 
|---|
| 768 | POutPersist po(fname); | 
|---|
| 769 | po << PPFNameTag("ntv12") << nt; | 
|---|
| 770 | cout << " BRProcA2C::run() created NTuple file " << fname << card2name_(card_) << endl; | 
|---|
| 771 | } | 
|---|
| 772 | ---- */ | 
|---|
| 773 | if (nmoyspec>0) {  // Calcul des moyennes et sigmas des spectres | 
|---|
| 774 | r_4 fnms = nmoyspec; | 
|---|
| 775 | moyspecV1 /= fnms; | 
|---|
| 776 | moyspecV2 /= fnms; | 
|---|
| 777 | sigspecV1 /= fnms; | 
|---|
| 778 | sigspecV2 /= fnms; | 
|---|
| 779 | sigspecV1 -= (moyspecV1 && moyspecV1); | 
|---|
| 780 | sigspecV2 -= (moyspecV2 && moyspecV2); | 
|---|
| 781 | sigspecV1 = Sqrt(sigspecV1); | 
|---|
| 782 | sigspecV2 = Sqrt(sigspecV2); | 
|---|
| 783 | TVector<r_4> rsbV1, rsbV2;   // Rapport signal/bruit | 
|---|
| 784 | moyspecV1.DivElt(sigspecV1, rsbV1, false, true); | 
|---|
| 785 | moyspecV2.DivElt(sigspecV2, rsbV2, false, true); | 
|---|
| 786 | sprintf(fname,"%s_ms.ppf",path_.c_str()); | 
|---|
| 787 | POutPersist po(fname); | 
|---|
| 788 | po << PPFNameTag("moyspecV1") << moyspecV1; | 
|---|
| 789 | po << PPFNameTag("moyspecV2") << moyspecV2; | 
|---|
| 790 | po << PPFNameTag("sigspecV1") << sigspecV1; | 
|---|
| 791 | po << PPFNameTag("sigspecV2") << sigspecV2; | 
|---|
| 792 | po << PPFNameTag("rsbV1") << rsbV1; | 
|---|
| 793 | po << PPFNameTag("rsbV2") << rsbV2; | 
|---|
| 794 | cout << " BRProcA2C::run() created moysigspec file " << fname << card2name_(card_) << endl; | 
|---|
| 795 | } | 
|---|
| 796 |  | 
|---|
| 797 | if (fghist_) { | 
|---|
| 798 | delete ph1; | 
|---|
| 799 | delete ph2; | 
|---|
| 800 | } | 
|---|
| 801 | ts.SetNow(); | 
|---|
| 802 | tm.SplitQ(); | 
|---|
| 803 | cout << "  TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= " | 
|---|
| 804 | << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" | 
|---|
| 805 | << " ProcDataOut=" <<  totnbytesout/(1024*1024) << " MB" << endl; | 
|---|
| 806 | cout << pcheck; | 
|---|
| 807 | cout << " BRProcA2C::run()/Timing: " << card2name_(card_) << endl; | 
|---|
| 808 | tm.Print(); | 
|---|
| 809 | cout << " ---------------------------------------------------------- " << endl; | 
|---|
| 810 |  | 
|---|
| 811 | } | 
|---|
| 812 | catch (PException& exc) { | 
|---|
| 813 | cout << " BRProcA2C::run()/catched PException " << exc.Msg() << endl; | 
|---|
| 814 | setRC(3); | 
|---|
| 815 | return; | 
|---|
| 816 | } | 
|---|
| 817 | catch(...) { | 
|---|
| 818 | cout << " BRProcA2C::run()/catched unknown ... exception " << endl; | 
|---|
| 819 | setRC(4); | 
|---|
| 820 | return; | 
|---|
| 821 | } | 
|---|
| 822 | setRC(0); | 
|---|
| 823 | return; | 
|---|
| 824 | } | 
|---|
| 825 |  | 
|---|
| 826 | //--------------------------------------------------------------------- | 
|---|
| 827 | // Classe thread de traitement 2 x 2 voies/frames (Apres BRProcA2C) | 
|---|
| 828 | //--------------------------------------------------------------------- | 
|---|
| 829 |  | 
|---|
| 830 | /* --Methode-- */ | 
|---|
| 831 | BRProcB4C::BRProcB4C(RAcqMemZoneMgr& mem1, RAcqMemZoneMgr& mem2, string& path, | 
|---|
| 832 | bool fgraw, uint_4 nmean, uint_4 nmax, bool fgnotrl) | 
|---|
| 833 | :  memgr1(mem1), memgr2(mem2) | 
|---|
| 834 | { | 
|---|
| 835 | fgraw_ = fgraw; | 
|---|
| 836 | nmax_ = nmax; | 
|---|
| 837 | nmean_ = nmean; | 
|---|
| 838 | if (fgraw_) cout << " BRProcB4C::BRProcB4C() - constructeur RAW data - NMean= " << nmean_ << endl; | 
|---|
| 839 | else cout << " BRProcB4C::BRProcB4C() - constructeur FFT data - NMean= " << nmean_ << endl; | 
|---|
| 840 | stop_ = false; | 
|---|
| 841 | path_ = path; | 
|---|
| 842 | fgnotrl_ = fgnotrl; | 
|---|
| 843 | } | 
|---|
| 844 |  | 
|---|
| 845 | /* --Methode-- */ | 
|---|
| 846 | void BRProcB4C::Stop() | 
|---|
| 847 | { | 
|---|
| 848 | stop_=true; | 
|---|
| 849 | // cout <<" BRProcB4C::Stop ... > STOP " << endl; | 
|---|
| 850 | } | 
|---|
| 851 |  | 
|---|
| 852 |  | 
|---|
| 853 | /* --Methode-- */ | 
|---|
| 854 | void BRProcB4C::run() | 
|---|
| 855 | { | 
|---|
| 856 | setRC(1); | 
|---|
| 857 | try { | 
|---|
| 858 | Timer tm("BRProcB4C", false); | 
|---|
| 859 | TimeStamp ts; | 
|---|
| 860 | BRPaqChecker pcheck1(!fgnotrl_);  // Verification/comptage des paquets | 
|---|
| 861 | BRPaqChecker pcheck2(!fgnotrl_);  // Verification/comptage des paquets | 
|---|
| 862 |  | 
|---|
| 863 | size_t totnbytesout = 0; | 
|---|
| 864 | size_t totnbytesproc = 0; | 
|---|
| 865 |  | 
|---|
| 866 | cout << " BRProcB4C::run() - Starting " << ts << " NMaxMemZones=" << nmax_ | 
|---|
| 867 | << " NMean=" << nmean_ << endl; | 
|---|
| 868 | cout << " BRProcB4C::run()... - Output Data Path: " << path_ << endl; | 
|---|
| 869 |  | 
|---|
| 870 | uint_4 paqsz = memgr1.PaqSize(); | 
|---|
| 871 | uint_4 procpaqsz = memgr1.ProcPaqSize(); | 
|---|
| 872 | if ((paqsz != memgr2.PaqSize())||(procpaqsz!= memgr2.ProcPaqSize())) { | 
|---|
| 873 | cout << "BRProcB4C::run()/ERROR : different paquet size -> stop \n ...(PaqSz1=" | 
|---|
| 874 | << paqsz << " Sz2=" << memgr2.PaqSize() << " ProcPaqSz1=" | 
|---|
| 875 | << procpaqsz << " Sz2=" << memgr2.ProcPaqSize() << " )" << endl; | 
|---|
| 876 | setRC(9); | 
|---|
| 877 | return; | 
|---|
| 878 | } | 
|---|
| 879 |  | 
|---|
| 880 | TVector< complex<r_4> > cfour;  // composant TF | 
|---|
| 881 | BRPaquet pq(NULL, NULL, paqsz); | 
|---|
| 882 | /* | 
|---|
| 883 | TVector<r_4> vx(pq.DataSize()/2); | 
|---|
| 884 | vx = (r_4)(0.); | 
|---|
| 885 | FFTPackServer ffts; | 
|---|
| 886 | ffts.FFTForward(vx, cfour); | 
|---|
| 887 |  | 
|---|
| 888 | TVector< complex<r_4> > visiV13( cfour.Size() ); | 
|---|
| 889 | TVector< complex<r_4> > visiV14( cfour.Size() ); | 
|---|
| 890 | TVector< complex<r_4> > visiV23( cfour.Size() ); | 
|---|
| 891 | TVector< complex<r_4> > visiV24( cfour.Size() ); | 
|---|
| 892 | */ | 
|---|
| 893 | int szfour = pq.DataSize()/2/2+1; | 
|---|
| 894 | //    int szfour = (paqsz-40)/2+1; | 
|---|
| 895 | TVector< complex<r_4> > visiV13( szfour  ); | 
|---|
| 896 | TVector< complex<r_4> > visiV14( szfour ); | 
|---|
| 897 | TVector< complex<r_4> > visiV23( szfour ); | 
|---|
| 898 | TVector< complex<r_4> > visiV24( szfour ); | 
|---|
| 899 | // cout << " *DBG*AAAAA ---- Vectors OK" << endl; | 
|---|
| 900 | cout << " *DBG*BRProcB4C PaqSz=" << paqsz << " ProcPaqSize=" << procpaqsz | 
|---|
| 901 | << " procpaqsz/2=" << procpaqsz/2 << " cfour.Size()=" << szfour | 
|---|
| 902 | << " *8="  << szfour*8 << endl; | 
|---|
| 903 |  | 
|---|
| 904 | DataTable dt; | 
|---|
| 905 | dt.AddLongColumn("fc1"); | 
|---|
| 906 | dt.AddLongColumn("tt1"); | 
|---|
| 907 | dt.AddLongColumn("fc2"); | 
|---|
| 908 | dt.AddLongColumn("tt2"); | 
|---|
| 909 | DataTableRow dtr = dt.EmptyRow(); | 
|---|
| 910 |  | 
|---|
| 911 | uint_4 nzm = 0; | 
|---|
| 912 | uint_4 totnoksfc = 0; | 
|---|
| 913 | uint_4 totnokpaq = 0; | 
|---|
| 914 | uint_4 totnpaq = 0; | 
|---|
| 915 | uint_4 ifile = 0; | 
|---|
| 916 |  | 
|---|
| 917 | uint_4 curfc=0; | 
|---|
| 918 | uint_8 curtt=0; | 
|---|
| 919 | uint_4 curfc2=0; | 
|---|
| 920 | uint_8 curtt2=0; | 
|---|
| 921 | uint_8 firsttt=0; | 
|---|
| 922 | uint_8 firsttt2=0; | 
|---|
| 923 | bool fgfirst=true; | 
|---|
| 924 | for (uint_4 kmz=0; kmz<nmax_; kmz++) { | 
|---|
| 925 | uint_4 noksfc = 0; | 
|---|
| 926 | uint_4 nokpaq = 0; | 
|---|
| 927 | if (stop_) break; | 
|---|
| 928 | // cout << " *DBG*BBBBB" << kmz << endl; | 
|---|
| 929 |  | 
|---|
| 930 | int mid1 = memgr1.FindMemZoneId(MemZA_ProcB); | 
|---|
| 931 | Byte* buff1 = memgr1.GetMemZone(mid1); | 
|---|
| 932 | if (buff1 == NULL) { | 
|---|
| 933 | cout << " BRProcB4C::run()/ERROR memgr.GetMemZone(" << mid1 << ") -> NULL" << endl; | 
|---|
| 934 | break; | 
|---|
| 935 | } | 
|---|
| 936 | Byte* procbuff1 = memgr1.GetProcMemZone(mid1); | 
|---|
| 937 | if (procbuff1 == NULL) { | 
|---|
| 938 | cout << " BRProcB4C::run()/ERROR memgr.GetProcMemZone(" << mid1 << ") -> NULL" << endl; | 
|---|
| 939 | break; | 
|---|
| 940 | } | 
|---|
| 941 | int mid2 = memgr2.FindMemZoneId(MemZA_ProcB); | 
|---|
| 942 | Byte* buff2 = memgr2.GetMemZone(mid2); | 
|---|
| 943 | if (buff1 == NULL) { | 
|---|
| 944 | cout << " BRProcB4C::run()/ERROR memgr.GetMemZone(" << mid2 << ") -> NULL" << endl; | 
|---|
| 945 | break; | 
|---|
| 946 | } | 
|---|
| 947 | Byte* procbuff2 = memgr2.GetProcMemZone(mid2); | 
|---|
| 948 | if (procbuff2 == NULL) { | 
|---|
| 949 | cout << " BRProcB4C::run()/ERROR memgr.GetProcMemZone(" << mid2 << ") -> NULL" << endl; | 
|---|
| 950 | break; | 
|---|
| 951 | } | 
|---|
| 952 | uint_4 i1,i2; | 
|---|
| 953 | i1=i2=0; | 
|---|
| 954 | //      cout << " *DBG*CCCCCC " << kmz << " memgr1.NbPaquets() =" << memgr1.NbPaquets() << endl; | 
|---|
| 955 | while((i1<memgr1.NbPaquets())&&(i2<memgr2.NbPaquets())) { | 
|---|
| 956 | BRPaquet paq1(NULL, buff1+i1*paqsz, paqsz); | 
|---|
| 957 | BRPaquet paq2(NULL, buff2+i2*paqsz, paqsz); | 
|---|
| 958 | totnpaq++; | 
|---|
| 959 | //        cout << " DBG["<<kmz<<"] i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter() | 
|---|
| 960 | //<<","<<paq2.FrameCounter()<<endl; | 
|---|
| 961 | // on ne traite que les paquets OK | 
|---|
| 962 | if (!pcheck1.Check(paq1)) { i1++; continue; } | 
|---|
| 963 | if (!pcheck2.Check(paq2)) { i2++; continue; } | 
|---|
| 964 | nokpaq++; | 
|---|
| 965 | if (paq1.FrameCounter()<paq2.FrameCounter()) { i1++; continue; } | 
|---|
| 966 | if (paq2.FrameCounter()<paq1.FrameCounter()) { i2++; continue; } | 
|---|
| 967 | //        cout << " DBG["<<kmz<<"]OKOK i1,i2=" << i1 <<","<<i2<<" FC1,FC2=" <<paq1.FrameCounter() | 
|---|
| 968 | // <<","<<paq2.FrameCounter()<<endl; | 
|---|
| 969 |  | 
|---|
| 970 | if ((i1>=memgr1.NbPaquets())||(i2>=memgr1.NbPaquets())) { | 
|---|
| 971 | cout << " *BUG*BUG i1=" << i1 << " i2=" << i2 << endl; | 
|---|
| 972 | break; | 
|---|
| 973 | } | 
|---|
| 974 | // Les deux framecounters sont identiques ... | 
|---|
| 975 | noksfc++; | 
|---|
| 976 | curfc=paq1.FrameCounter(); | 
|---|
| 977 | curfc2=paq2.FrameCounter(); | 
|---|
| 978 | if (fgfirst) { | 
|---|
| 979 | firsttt=paq1.TimeTag();  firsttt2=paq2.TimeTag(); | 
|---|
| 980 | cout << " BRProcB4C()/Info First FC="<<curfc<<" , "<<curfc2<<" -> TT=" | 
|---|
| 981 | << firsttt<<" , "<<firsttt2 <<endl; | 
|---|
| 982 | fgfirst=false; | 
|---|
| 983 | } | 
|---|
| 984 | curtt=paq1.TimeTag()-firsttt; | 
|---|
| 985 | curtt2=paq2.TimeTag()-firsttt2; | 
|---|
| 986 | dtr[0]=curfc;  dtr[1]=curtt; | 
|---|
| 987 | dtr[2]=curfc2;  dtr[3]=curtt2; | 
|---|
| 988 | dt.AddRow(dtr); | 
|---|
| 989 |  | 
|---|
| 990 | complex<r_4>* zp1 = (complex<r_4>*)(procbuff1+i1*procpaqsz); | 
|---|
| 991 | complex<r_4>* zp2 = (complex<r_4>*)(procbuff1+i1*procpaqsz+procpaqsz/2); | 
|---|
| 992 | complex<r_4>* zp3 = (complex<r_4>*)(procbuff2+i2*procpaqsz); | 
|---|
| 993 | complex<r_4>* zp4 = (complex<r_4>*)(procbuff2+i2*procpaqsz+procpaqsz/2); | 
|---|
| 994 | for(sa_size_t j=0; j<visiV13.Size(); j++) { | 
|---|
| 995 | visiV13(j)+=zp1[j]*conj(zp3[j]); | 
|---|
| 996 | visiV14(j)+=zp1[j]*conj(zp4[j]); | 
|---|
| 997 | visiV23(j)+=zp2[j]*conj(zp3[j]); | 
|---|
| 998 | visiV24(j)+=zp2[j]*conj(zp4[j]); | 
|---|
| 999 | } | 
|---|
| 1000 | if (nzm==0) { | 
|---|
| 1001 | visiV13.Info()["StartFC"] = curfc; | 
|---|
| 1002 | visiV14.Info()["StartFC"] = curfc; | 
|---|
| 1003 | visiV23.Info()["StartFC"] = curfc; | 
|---|
| 1004 | visiV24.Info()["StartFC"] = curfc; | 
|---|
| 1005 | visiV13.Info()["StartTT"] = curtt; | 
|---|
| 1006 | visiV14.Info()["StartTT"] = curtt; | 
|---|
| 1007 | visiV23.Info()["StartTT"] = curtt; | 
|---|
| 1008 | visiV24.Info()["StartTT"] = curtt; | 
|---|
| 1009 | } | 
|---|
| 1010 | nzm++;  i1++; i2++; | 
|---|
| 1011 | totnbytesproc += 2*paq1.DataSize(); | 
|---|
| 1012 | } // Fin de boucle sur les paquets d'une zone | 
|---|
| 1013 | memgr1.FreeMemZone(mid1, MemZS_ProcB); | 
|---|
| 1014 | memgr2.FreeMemZone(mid2, MemZS_ProcB); | 
|---|
| 1015 |  | 
|---|
| 1016 | if ((nzm >= nmean_) || ((kmz==(nmax_-1))&&(nzm>1))) { | 
|---|
| 1017 | visiV13 /= complex<r_4>((r_4)nzm, 0.); | 
|---|
| 1018 | visiV14 /= complex<r_4>((r_4)nzm, 0.); | 
|---|
| 1019 | visiV23 /= complex<r_4>((r_4)nzm, 0.); | 
|---|
| 1020 | visiV24 /= complex<r_4>((r_4)nzm, 0.); | 
|---|
| 1021 | visiV13.Info()["NPaqMoy"] = nzm; | 
|---|
| 1022 | visiV14.Info()["NPaqMoy"] = nzm; | 
|---|
| 1023 | visiV23.Info()["NPaqMoy"] = nzm; | 
|---|
| 1024 | visiV24.Info()["NPaqMoy"] = nzm; | 
|---|
| 1025 | visiV13.Info()["EndFC"] = curfc; | 
|---|
| 1026 | visiV14.Info()["EndFC"] = curfc; | 
|---|
| 1027 | visiV23.Info()["EndFC"] = curfc; | 
|---|
| 1028 | visiV24.Info()["EndFC"] = curfc; | 
|---|
| 1029 | visiV13.Info()["EndTT"] = curtt; | 
|---|
| 1030 | visiV14.Info()["EndTT"] = curtt; | 
|---|
| 1031 | visiV23.Info()["EndTT"] = curtt; | 
|---|
| 1032 | visiV24.Info()["EndTT"] = curtt; | 
|---|
| 1033 | char fname[512]; | 
|---|
| 1034 | { | 
|---|
| 1035 | sprintf(fname,"%s_%d.ppf",path_.c_str(),(int)ifile); | 
|---|
| 1036 | POutPersist po(fname); | 
|---|
| 1037 | po << PPFNameTag("visiV13") << visiV13; | 
|---|
| 1038 | po << PPFNameTag("visiV14") << visiV14; | 
|---|
| 1039 | po << PPFNameTag("visiV23") << visiV23; | 
|---|
| 1040 | po << PPFNameTag("visiV24") << visiV24; | 
|---|
| 1041 | } | 
|---|
| 1042 | visiV13 = complex<r_4>(0., 0.); | 
|---|
| 1043 | visiV14 = complex<r_4>(0., 0.); | 
|---|
| 1044 | visiV23 = complex<r_4>(0., 0.); | 
|---|
| 1045 | visiV24 = complex<r_4>(0., 0.); | 
|---|
| 1046 | nzm = 0;  ifile++; | 
|---|
| 1047 | //        ts.SetNow(); | 
|---|
| 1048 | //        filog << ts << " :  proc file  " << fname << endl; | 
|---|
| 1049 | cout << " BRProcB4C::run() created file  " << fname << endl; | 
|---|
| 1050 | } | 
|---|
| 1051 | double okfrac = (nokpaq>1)?((double)noksfc/(double)nokpaq*100.):0.; | 
|---|
| 1052 | cout << "BRProcB4C ["<<kmz<<"] NOKPaq=" << nokpaq << " NSameFC=" << noksfc | 
|---|
| 1053 | << " (" << okfrac << " %)" << endl; | 
|---|
| 1054 | totnokpaq += nokpaq; | 
|---|
| 1055 | totnoksfc += noksfc; | 
|---|
| 1056 | }  // Fin de boucle sur les zones a traiter | 
|---|
| 1057 | cout << " ------------------  BRProcB4C::run() END ----------------- " << endl; | 
|---|
| 1058 | { | 
|---|
| 1059 | dt.Info()["FirstTT1"]=firsttt; | 
|---|
| 1060 | dt.Info()["FirstTT2"]=firsttt2; | 
|---|
| 1061 | cout << dt; | 
|---|
| 1062 | char fname[512]; | 
|---|
| 1063 | sprintf(fname,"%s_fctt.ppf",path_.c_str()); | 
|---|
| 1064 | POutPersist po(fname); | 
|---|
| 1065 | po << PPFNameTag("ttfc") << dt; | 
|---|
| 1066 | cout << " BRProcB4C::run() created TimeTag/FrameCounter file " << fname  << endl; | 
|---|
| 1067 | } | 
|---|
| 1068 | ts.SetNow(); | 
|---|
| 1069 | tm.SplitQ(); | 
|---|
| 1070 | cout << "  TotalProc= " << totnbytesproc/(1024*1024) << " MBytes, rate= " | 
|---|
| 1071 | << (double)(totnbytesproc)/1024./tm.PartialElapsedTimems() << " MB/s" << endl; | 
|---|
| 1072 | double totokfrac = (totnokpaq>1)?((double)totnoksfc/(double)totnokpaq*100.):0.; | 
|---|
| 1073 | cout << " NOkPaq1,2=" << totnokpaq << " /TotNPaq=" << totnpaq << " TotNSameFC=" | 
|---|
| 1074 | << totnoksfc << " (" << totokfrac << " %)" << endl; | 
|---|
| 1075 | //  cout << pcheck1; | 
|---|
| 1076 | //  cout << pcheck2; | 
|---|
| 1077 | cout << " BRProcB4C::run()/Timing: \n"; | 
|---|
| 1078 | tm.Print(); | 
|---|
| 1079 | cout << " ---------------------------------------------------------- " << endl; | 
|---|
| 1080 | } | 
|---|
| 1081 | catch (PException& exc) { | 
|---|
| 1082 | cout << " BRProcB4C::run()/catched PException " << exc.Msg() << endl; | 
|---|
| 1083 | setRC(3); | 
|---|
| 1084 | return; | 
|---|
| 1085 | } | 
|---|
| 1086 | catch(...) { | 
|---|
| 1087 | cout << " BRProcB4C::run()/catched unknown ... exception " << endl; | 
|---|
| 1088 | setRC(4); | 
|---|
| 1089 | return; | 
|---|
| 1090 | } | 
|---|
| 1091 | setRC(0); | 
|---|
| 1092 | return; | 
|---|
| 1093 | } | 
|---|
| 1094 |  | 
|---|
| 1095 |  | 
|---|