// ArchTOIPipe (C) CEA/DAPNIA/SPP IN2P3/LAL // Eric Aubourg // Christophe Magneville // Reza Ansari /* Calcul de statistique simples sur TOI ---------------- Exemple d'appel --------------------- csh> toistat -start 104385384 -end 104399964 -range -500,500 \ -intoi boloMuV_26 -wtoi 8192 -wclean 512,5 \ inputbolo.fits filt.fits xx.ppf */ #include "machdefs.h" #include #include #include "toimanager.h" #include "cgt.h" #include "fitstoirdr.h" #include "fitstoiwtr.h" #include "simtoipr.h" #include "simoffset.h" #include "simcleaner.h" #include "nooppr.h" #include "timing.h" #include "histinit.h" #include "ntuple.h" #include "fitsntuple.h" #include "psighand.h" #include void Usage(bool fgerr) { cout << endl; if (fgerr) { cout << " toistat : Argument Error ! toistat -h for usage " << endl; exit(1); } else { cout << " toistat : produce a stat NTuple (mean,sigma) from a TOI" << endl; cout << "\n Usage : toistat [-intoi toiname] [-start snb] [-end sne] \n" << " [-wtoi sz] [-wclean wsz,nbw] [-range min,max] [-cleannsig nsig] \n" << " [-outppf] [-noprstat] [-useseqbuff] \n" << " inFitsName outFileName \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 bolo)\n" << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n" << " -wclean wsz,nbw : sets cleaner window parameters (256,5) \n" << " -cleannsig nsig : Sets cleanner ThrNSig (default = 999999.) \n" << " -outppf : Write the NTuple in PPF format (default: FITS) \n" << " -noprstat : DO NOT PrintStat with ProcSampleCounter \n" << " -useseqbuff : Use TOISeqBuffered TOI's (default: TOISegmented) \n" << endl; } if (fgerr) exit(1); } int main(int narg, char** arg) { if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false); cout << "toistat starting - Decoding arguments " << " narg=" << narg << endl; bool fgsetstart = false; bool fgprstat = true; bool fgsegmented = true; bool fgoutppf = false; int dbglev = 0; int wtoi = 8192; int nmax = 10; int istart = 0; int iend = 0; double range_min = -16000; double range_max = 16000.; // cleaner parameters int clean_wsz = 256; int clean_nbw = 5; double clean_nsig = 999999.; // File names string infile; string outfile; string intoi = "bolo"; if (narg < 3) Usage(true); int ko=1; // decoding arguments for(int ia=1; ia>>> toistat: Infile= " << infile << " outFile=" << outfile << endl; cout << " 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); cout << "> Creating FITSTOIReader object - InFile=" << infile << endl; FITSTOIReader r(infile); cout << "> Creating SimpleCleaner() " << endl; SimpleCleaner cleaner(clean_wsz, clean_nbw); cout << " Setting Range for cleaner: " << range_min << " - " << range_max << endl; cleaner.SetRange(range_min, range_max); cleaner.SetCleanForMeanThrNSig(clean_nsig); cleaner.FillMeanSigNTuple(true); CGT plombier(fgsegmented, wtoi); // plombier.SetDebugLevel(dbglev); cout << "> Connecting Processors through plombier ... " << endl; string inname = "in"; string outname = "out"; plombier.Connect(r, intoi, cleaner, inname); cout << "> Plombier status before start" << endl; cout << plombier ; cout << cleaner; PrtTim("starting processors"); plombier.Start(); // ------------------- Impression continu de stat ------------------------ if (fgprstat) { ProcSampleCounter stats(cleaner); stats.InfoMessage() = "toistat/Info"; stats.PrintStats(); } // ----------------------------------------------------------------------- cout << cleaner; mgr->joinAll(); PrtTim("End threads"); cleaner.GetMeanSigNTuple().Info()["TOIFILE"] = infile; cleaner.GetMeanSigNTuple().Info()["TOINAME"] = intoi; if (fgoutppf) { cout << " \n --------------------------------------------------------- " << endl; cout << " Saving Stats (mean-sigma) NTuple to PPF file " << outfile << endl; POutPersist pos(outfile); pos << cleaner.GetMeanSigNTuple(); cout << " \n --------------------------------------------------------- " << endl; } else { cout << " \n --------------------------------------------------------- " << endl; cout << " Saving Stats (mean-sigma NTuple to FITS file " << outfile << endl; FitsOutFile fos(outfile, FitsFile::clear); fos << cleaner.GetMeanSigNTuple(); cout << " \n --------------------------------------------------------- " << endl; } } catch (PThrowable & exc) { cerr << "\n toistat: Catched Exception \n" << (string)typeid(exc).name() << " - Msg= " << exc.Msg() << endl; } catch (const std::exception & sex) { cerr << "\n toistat: Catched std::exception \n" << (string)typeid(sex).name() << endl; } catch (...) { cerr << "\n toistat: some other exception was caught ! " << endl; } return(0); }