| [4022] | 1 | /*  ------------------------ Projet BAORadio -------------------- | 
|---|
|  | 2 | Programme de verification comportement en loi de puissance | 
|---|
|  | 3 | R. Ansari , Sep 2011 | 
|---|
|  | 4 |  | 
|---|
|  | 5 | Usage: ckpowl In3DMap  [InRenormFactor] | 
|---|
|  | 6 | ---------------------------------------------------------------  */ | 
|---|
|  | 7 |  | 
|---|
|  | 8 | #include "machdefs.h" | 
|---|
|  | 9 | #include "sopnamsp.h" | 
|---|
|  | 10 | #include <iostream> | 
|---|
|  | 11 | #include <string> | 
|---|
|  | 12 | #include <math.h> | 
|---|
|  | 13 |  | 
|---|
|  | 14 | #include <typeinfo> | 
|---|
|  | 15 |  | 
|---|
|  | 16 | #include "specpk.h" | 
|---|
|  | 17 | #include "histats.h" | 
|---|
|  | 18 |  | 
|---|
|  | 19 | #include "qhist.h" | 
|---|
|  | 20 | #include "lobe.h" | 
|---|
|  | 21 | #include "cubedef.h" | 
|---|
|  | 22 | #include "fgndsub.h" | 
|---|
|  | 23 |  | 
|---|
|  | 24 | #include "histinit.h" | 
|---|
|  | 25 | #include "fftwserver.h" | 
|---|
|  | 26 | #include "randr48.h" | 
|---|
|  | 27 |  | 
|---|
|  | 28 | #include "ctimer.h" | 
|---|
|  | 29 |  | 
|---|
|  | 30 | typedef ThSDR48RandGen RandomGenerator ; | 
|---|
|  | 31 |  | 
|---|
|  | 32 | //------------------------------------------------------------------------- | 
|---|
|  | 33 | //      ------------------ MAIN PROGRAM ------------------------------ | 
|---|
|  | 34 | //------------------------------------------------------------------------- | 
|---|
|  | 35 | int main(int narg, const char* arg[]) | 
|---|
|  | 36 | { | 
|---|
|  | 37 | if (narg<3) { | 
|---|
|  | 38 | cout << " Usage: calcpk In3DMap_PPFName OutName [InRenormFactor] [PixNoiseLevel] " << endl; | 
|---|
|  | 39 | return 1; | 
|---|
|  | 40 | } | 
|---|
|  | 41 | Timer tm("calcpk"); | 
|---|
|  | 42 | int rc = 0; | 
|---|
|  | 43 | try { | 
|---|
|  | 44 | string inppfname = arg[1]; | 
|---|
|  | 45 | string outname = arg[2]; | 
|---|
|  | 46 | double renfact=1.; | 
|---|
|  | 47 | bool fgrenfact=false; | 
|---|
|  | 48 | if (narg>3) { | 
|---|
|  | 49 | renfact=atof(arg[3]); | 
|---|
|  | 50 | fgrenfact=true; | 
|---|
|  | 51 | } | 
|---|
|  | 52 | double pixsignoise = 0.; | 
|---|
|  | 53 | bool fgaddnoise=false; | 
|---|
|  | 54 | if (narg>4) { | 
|---|
|  | 55 | pixsignoise=atof(arg[4]); | 
|---|
|  | 56 | if (pixsignoise>1.e-9)  fgaddnoise=true; | 
|---|
|  | 57 | } | 
|---|
|  | 58 |  | 
|---|
|  | 59 |  | 
|---|
|  | 60 | cout << "ckpowl[1] : reading 3D map from file " << inppfname << endl; | 
|---|
|  | 61 | TArray<r_4> inmap; | 
|---|
|  | 62 | { | 
|---|
|  | 63 | PInPersist pin(inppfname); | 
|---|
|  | 64 | pin >> inmap; | 
|---|
|  | 65 | } | 
|---|
|  | 66 | if (fgrenfact) { | 
|---|
|  | 67 | cout << "  Applying RenormFactor inmap = inmap*rfact, rfact=" << renfact << endl; | 
|---|
|  | 68 | inmap *= renfact; | 
|---|
|  | 69 | } | 
|---|
|  | 70 | double mean, sigma; | 
|---|
|  | 71 | MeanSigma(inmap, mean, sigma); | 
|---|
|  | 72 | cout << " InMap sizes " << inmap.InfoString() << endl; | 
|---|
|  | 73 | inmap.Show(); | 
|---|
|  | 74 | cout << "  Mean=" << mean << " Sigma=" << sigma << endl; | 
|---|
|  | 75 | if (fgaddnoise) { | 
|---|
|  | 76 | BeamEffect::AddNoise(inmap, pixsignoise); | 
|---|
|  | 77 | } | 
|---|
|  | 78 |  | 
|---|
|  | 79 | tm.Split(" After read "); | 
|---|
|  | 80 | cout << "ckpowl[2] : Checking power law behaviour " << endl; | 
|---|
|  | 81 | PowerLawChecker plck(inmap); | 
|---|
|  | 82 | plck.CheckXYMean(); | 
|---|
|  | 83 | tm.Split(" Done PowerLawChecker::CheckXYMean() "); | 
|---|
|  | 84 | }  // End of try bloc | 
|---|
|  | 85 | catch (PThrowable & exc) {  // catching SOPHYA exceptions | 
|---|
|  | 86 | cerr << " ckpowl.cc: Catched Exception (PThrowable)" << (string)typeid(exc).name() | 
|---|
|  | 87 | << "\n...exc.Msg= " << exc.Msg() << endl; | 
|---|
|  | 88 | rc = 99; | 
|---|
|  | 89 | } | 
|---|
|  | 90 | catch (std::exception & e) {  // catching standard C++ exceptions | 
|---|
|  | 91 | cerr << " ckpowl.cc: Catched std::exception "  << " - what()= " << e.what() << endl; | 
|---|
|  | 92 | rc = 98; | 
|---|
|  | 93 | } | 
|---|
|  | 94 | catch (...) {  // catching other exceptions | 
|---|
|  | 95 | cerr << " ckpowlx.cc: some other exception (...) was caught ! " << endl; | 
|---|
|  | 96 | rc = 97; | 
|---|
|  | 97 | } | 
|---|
|  | 98 | cout << " ==== End of ckpowl.cc program  Rc= " << rc << endl; | 
|---|
|  | 99 | return rc; | 
|---|
|  | 100 | } | 
|---|