// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari // $Id: simtst.cc,v 1.18 2001-11-13 16:01:39 aubourg Exp $ /* Test de processeurs ds simtoipr.cc - Reza Avril 2001 ---------------- Exemple d'appel --------------------- csh> simtst -start 104385384 -end 104399964 -range -500,500 \ -intoi boloMuV_26 -wtoi 8192 -wdegli 1024 \ inputbolo.fits filt.fits xx.ppf # Avec Filtre de Fourier csh> simtst -start 104385384 -end 104399964 -range -500,500 \ -intoi boloMuV_26 -wtoi 8192 -wdegli 1024 \ -wfft 4096 -keepfft 5 -killfreq 15,4,2.5 \ inputbolo.fits filtfft.fits spectre.ppf # Autre exemple b545k02 cool> ./simtst -start 104389122 -end 104649122 -range -1000.,1000. -intoi boloMu V_23 -wtoi 8192 -wdegli 1024 -wfft 4096 -keepfft 5 -killfreq 15,4,2.5 Cmv/b545k02 2_16.00_16.49.fits b545.fits b545.ppf */ #include "machdefs.h" #include #include "array.h" #include #include "toi.h" #include "toiprocessor.h" #include "fitstoirdr.h" #include "fitstoiwtr.h" #include "toisqfilter.h" #include "toimanager.h" #include "simtoipr.h" #include "nooppr.h" #include "toiseqbuff.h" #include "timing.h" #include "sambainit.h" #include void Usage(bool fgerr) { cout << endl; if (fgerr) { cout << " simtst : Argument Error ! simtst -h for usage " << endl; exit(1); } else { cout << "\n Usage : simtst [-intoi toiname] [-start snb] [-end sne] \n" << " [-dbg] [-wtoi sz] [-wdegli sz] [-range min,max] \n" << " [-degli ns,ns2,mxpt,mnpt,wrec] [-gfilt wsz,sigma] \n" << " [-wfft sz] [-keepfft n] [-killfreq bf,nharm,sigf] \n" << " [-nooutflg] [-nowrtms] [-nowrticd] \n" << " inFitsName outFitsName outPPFName \n" << " -dbg : sets TOISeqBuffered debug level to 1 \n" << " -start snb : sets the start sample num \n" << " -end sne : sets the end sample num \n" << " -range min,max : sets the acceptable range for intoi \n" << " default= -16000,16000\n" << " -intoi toiName : select input TOI name (def boloMuV_27)\n" << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n" << " -wdegli sz : sets deglitcher window size (def= 512) \n" << " -degli ns,ns2,maxnpt,minnpt,wrec : sets deglitcher parameters\n" << " -gfilt wsz,sigma : Gaussian filter window size and sigma\n" << " -wfft sz : Activate Fourier filter and sets its width \n" << " -keepfft n : Keeps n spectra (if Fourier filter activated) \n" << " -killfreq bf,nharm,sigf : kills nharm frequency, basefreq=bf \n" << " with a gaussian with width=sigf \n" << " -nooutflg : Don't write flags to output FITS \n" << " -nowrtms : Don't write mean/sigma TOI's \n" << " -nowrticd : Don't write incopie,degli,deglioffset TOI's \n" << endl; } } int main(int narg, char** arg) { if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false); cout << "simtst starting - Decoding arguments " << " narg=" << narg << endl; bool fgdbg = false; bool fgsetstart = false; int wtoi = 8192; int wdegli = 512; int wfft = 4096; int keepfft = 0; int nmax = 10; int istart = 0; int iend = 0; double range_min = -16000; double range_max = 16000.; // Deglitcher parameters double degli_ns1 = 3.; double degli_ns2 = 1.5; int degli_minnpt = 2; int degli_maxnpt = 4; int degli_wrec = 10; // Gaussian filter parameters int gfilt_wsz = 16; double gfilt_sigma = 2.; // File names string infile; string outfile; string outppfname; string intoi = "boloMuV_27"; bool fg_wrtflag = true; bool fg_nowrtms = false; bool fg_nowrticd = false; bool fg_f_filt = false; bool fg_killfreq = false; int bf_killfreq = 1; int nharm_killfreq = 1; double sigf_killfreq = 1.; if (narg < 4) Usage(true); int ko=1; // decoding arguments for(int ia=1; ia>>> simtst: Infile= " << infile << " outFile=" << outfile << endl; cout << ">>>> Window Size WTOI= " << wtoi << " WDEGLI= " << wdegli << " iStart= " << istart << " iEnd= " << iend << endl; cout << ">>>> InTOIName= " << intoi << endl; try { TOIManager* mgr = TOIManager::getManager(); // mgr->setRequestedSample(11680920,11710584); // mgr->setRequestedSample(104121000, 104946120); if (fgsetstart) mgr->setRequestedSample(istart, iend); // FITSTOIReader r("/data/Archeops/bolo11.fits); FITSTOIReader r(infile); cout << "reader created" << endl; // FITSTOIWriter w("/data/Archeops/rz.fits"); FITSTOIWriter w(outfile); cout << "fits writer created" << endl; int w1 = wtoi; int w2 = (fg_f_filt) ? wfft+3*w1 : w1; // char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"}; TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1); if (fgdbg) toiin->setDebugLevel(1); TOISeqBuffered * toidegli = new TOISeqBuffered("degli", w1); if (fgdbg) toidegli->setDebugLevel(1); TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1); if (fgdbg) toimean->setDebugLevel(1); TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w2); if (fgdbg) toisig->setDebugLevel(1); TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w2); if (fgdbg) toiincopie->setDebugLevel(1); // Connecting TOI to FITSTOIReader Processor // for(kk=0; kk<5; kk++) { // r.addOutput(colname[kk], toitab[kk]); // } // int kk = 2; r.addOutput(intoi, toiin); // toi->dbg=true; // r.addOutput("boloMuV_11", toi); cout << " connecting in/out to RzTOIProcessor ... " << endl; // TOIProcessor * filt = NULL; cout << " Creating SimpleDeglitcher() " << endl; SimpleDeglitcher degl(wdegli); degl.SetDetectionParam(degli_ns1, degli_ns2, degli_maxnpt, degli_minnpt, degli_wrec); cout << " Setting Range for deglitcher: " << range_min << " - " << range_max << endl; degl.SetRange(range_min, range_max); degl.addInput("in", toiin); degl.addOutput("out", toidegli); degl.addOutput("mean", toimean); degl.addOutput("sigma", toisig); degl.addOutput("incopie", toiincopie); cout << " Creating a FanOut SimpleFanOut Object " << endl; SimpleFanOut fanout(2,2); TOISeqBuffered * toidegli0 = new TOISeqBuffered("degli0", w1); if (fgdbg) toidegli0->setDebugLevel(1); TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w2); TOISeqBuffered * toimean0 = new TOISeqBuffered("mean0", w1); if (fgdbg) toimean0->setDebugLevel(1); TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w2); if (fgdbg) toimean1->setDebugLevel(1); fanout.addInput("in0", toidegli); fanout.addOutput("out0_0", toidegli0); fanout.addOutput("out0_1", toidegli1); fanout.addInput("in1", toimean); fanout.addOutput("out1_0", toimean0); fanout.addOutput("out1_1", toimean1); cout << " Creating an Adder SimpleAdder Object " << endl; SimpleAdder adder(2); adder.addInput("in0", toidegli0); adder.addInput("in1", toimean0); adder.SetGain(0, 1.); adder.SetGain(1, -1.); TOISeqBuffered * toideglioff = new TOISeqBuffered("deglioff", w1); if (fgdbg) toideglioff->setDebugLevel(1); adder.addOutput("out", toideglioff); cout << " Creating a GaussianFilter SimpleFilter Object " << endl; double G_sigma = gfilt_sigma; double G_a = 1./(G_sigma*sqrt(M_PI*2.)); SimpleFilter filt(gfilt_wsz, SimpleFilter::GaussFilter, G_a, G_sigma); filt.addInput("in", toideglioff); TOISeqBuffered * toiout = new TOISeqBuffered("out", w1); if (fgdbg) toiout->setDebugLevel(1); TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w2); if (fgdbg) toideglioffcopie->setDebugLevel(1); filt.addOutput("out", toiout); filt.addOutput("incopie", toideglioffcopie); Vector fcoef(wfft/2+1); // fcoef = RegularSequence(1., -2./wfft); fcoef = 1.; for(int kfk=0; kfk= fcoef.Size() ) ) continue; xfreq = (cfreq-kfj)/sigf_killfreq; fcoef(kfj) -= exp(-xfreq*xfreq/2.0); } } cout << " Creating Fourier Filter ... " << endl; SimpleFourierFilter sfft(fcoef); sfft.KeepSpectra(outppfname, keepfft); sfft.ComputeMeanSpectra(true); TOISeqBuffered * toifft = NULL; TOISeqBuffered * toifiltcopie = NULL; if (fg_f_filt) { cout << " Connecting Fourier Filter ... " << endl; toifft = new TOISeqBuffered("fftout", w1); toifiltcopie = new TOISeqBuffered("filtcopie", w1); sfft.addInput("in",toiout); sfft.addOutput("out", toifft); sfft.addOutput("incopie", toifiltcopie); } cout << " Connecting to output (FitsWriter) " << endl; // Pour connecter les lignes non connectees au FitsWriter NoOpProcessor noop[3]; if (fg_nowrticd) noop[0].addInput("in", toiincopie); else w.addInput("in", toiincopie); if (fg_f_filt) { w.addInput("filtout", toifiltcopie, fg_wrtflag); w.addInput("fftout", toifft, fg_wrtflag); } else w.addInput("filtout", toiout, fg_wrtflag); if (fg_nowrticd) { noop[1].addInput("in", toidegli1); noop[1].addInput("in2", toideglioffcopie); } else { w.addInput("degli", toidegli1); w.addInput("deglioff", toideglioffcopie); } if (fg_nowrtms) { noop[2].addInput("in", toimean1); noop[2].addInput("in2", toisig); } else { w.addInput("mean", toimean1); w.addInput("sigma", toisig); } cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl; r.PrintStatus(cout); cout << " ------ FanOut::PrintStatus() : ----- " << endl; fanout.PrintStatus(cout); cout << " ------ Adder::PrintStatus() : ----- " << endl; adder.PrintStatus(cout); cout << " ------ Filter::PrintStatus() : ----- " << endl; filt.PrintStatus(cout); cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl; w.PrintStatus(cout); PrtTim("starting threads"); r.start(); degl.start(); fanout.start(); adder.start(); filt.start(); if (fg_f_filt) sfft.start(); w.start(); if (fg_nowrticd) { noop[0].start(); noop[1].start(); } if (fg_nowrtms) noop[2].start(); // ------------------- Impression continu de stat ------------------------ ProcSampleCounter stats(filt); stats.InfoMessage() = "simtst/Info"; stats.PrintStats(); // ----------------------------------------------------------------------- /* for(int jj=0; jj<3; jj++) { cout << *toiin; cout << *toimean; cout << *toimean1; cout << *toiout; sleep(1); } */ mgr->joinAll(); PrtTim("End threads"); // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl; // r.PrintStatus(cout); // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl; // w.PrintStatus(cout); cout << " ------ toiin, toidegli and toiout Status information ------- " << endl; cout << *toiin; cout << *toidegli; cout << *toiout; if (fg_f_filt) { cout << *toisig; cout << *toimean1; } cout << degl; cout << filt; cout << adder; if (fg_f_filt) cout << sfft ; } catch (PThrowable & exc) { cerr << "\n simtst: Catched Exception \n" << (string)typeid(exc).name() << " - Msg= " << exc.Msg() << endl; } catch (const std::exception & sex) { cerr << "\n simtst: Catched std::exception \n" << (string)typeid(sex).name() << endl; } catch (...) { cerr << "\n simtst: some other exception was caught ! " << endl; } return(0); }