source: Sophya/trunk/ArchTOIPipe/TestPipes/simtst.cc@ 1463

Last change on this file since 1463 was 1462, checked in by cmv, 24 years ago

changement getData... intermediaire NE COMPILE PAS cmv+rz 10/4/2001

File size: 6.7 KB
RevLine 
[1462]1#include "machdefs.h"
2#include "array.h"
[1442]3#include <unistd.h>
4#include <stdexcept>
5#include "toi.h"
6#include "toiprocessor.h"
7#include "fitstoirdr.h"
8#include "fitstoiwtr.h"
9#include "toisqfilter.h"
10#include "toimanager.h"
11#include "simtoipr.h"
12#include "toiseqbuff.h"
13#include "timing.h"
14#include "sambainit.h"
15
16void Usage(bool fgerr)
17{
18 cout << endl;
19 if (fgerr) {
20 cout << " simtst : Argument Error ! tstrztoi -h for usage " << endl;
21 exit(1);
22 }
23 else {
[1454]24 cout << "\n Usage : simtst [-sproc] [-rwtoi] [-dbg] [-start snb] [-end sne] \n"
[1442]25 << " [-w1 sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
26 << " -sproc : Run RzSimpleTOIProc (default RzTOIProc) \n"
27 << " -rwtoi : Use Regular Window TOI (default TOISeqBuffered) \n"
28 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
29 << " -start snb : sets the start sample num \n"
30 << " -end sne : sets the end sample num \n"
[1454]31 << " -range min,max : sets the acceptable range for intoi \n"
32 << " default= -16000,16000\n"
33 << " -intoi toiName : select input TOI name (def boloMuV_11)\n"
[1442]34 << " -w1 sz : sets main data window size (def= 8192)\n"
35 << " -w2 sz : sets secondary window size (def= 512) \n"
36 << endl;
37 exit(0);
38 }
39}
40
41int main(int narg, char** arg) {
42
43 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
44
45 cout << "simtst starting - Decoding arguments " << " narg=" << narg << endl;
46
47 bool fgsimple = false;
48 bool fgrwtoi = false;
49 bool fgdbg = false;
50 int w1 = 8192;
[1454]51 int w2 = 256;
[1442]52 int nmax = 10;
53 int istart = 104121000+w1*5;
54 int iend = 0;
[1454]55 double range_min = -16000;
56 double range_max = 16000.;
[1442]57 string infile;
58 string outfile;
59 string ppffile;
[1454]60 string intoi = "boloMuV_11";
[1442]61
62 if (narg < 4) Usage(true);
63 int ko=1;
64 // decoding arguments
65 for(int ia=1; ia<narg; ia++) {
66 if (strcmp(arg[ia],"-start") == 0) {
67 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
68 istart = atoi(arg[ia+1]); ia++;
69 }
70 else if (strcmp(arg[ia],"-end") == 0) {
71 if (ia == narg-1) Usage(true);
72 iend = atoi(arg[ia+1]); ia++;
73 }
74 else if (strcmp(arg[ia],"-w1") == 0) {
75 if (ia == narg-1) Usage(true);
76 w1 = atoi(arg[ia+1]); ia++;
77 }
78 else if (strcmp(arg[ia],"-w2") == 0) {
79 if (ia == narg-1) Usage(true);
80 w2 = atoi(arg[ia+1]); ia++;
81 }
[1454]82 else if (strcmp(arg[ia],"-range") == 0) {
83 if (ia == narg-1) Usage(true);
84 sscanf(arg[ia+1],"%lf,%lf",&range_min, &range_max);
85 ia++;
86 }
87 else if (strcmp(arg[ia],"-intoi") == 0) {
88 if (ia == narg-1) Usage(true);
89 intoi = arg[ia+1]; ia++;
90 }
[1442]91 else if (strcmp(arg[ia],"-sproc") == 0) fgsimple = true;
92 else if (strcmp(arg[ia],"-rwtoi") == 0) fgrwtoi = true;
93 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
94
95 else { ko = ia; break; } // Debut des noms
96 }
97
98 if (iend < istart) iend = istart+w1*(nmax+5);
99 if ((narg-ko) < 3) Usage(true);
100 infile = arg[ko];
101 outfile = arg[ko+1];
102 ppffile = arg[ko+2];
103
104 cout << " Initializing SOPHYA ... " << endl;
105 SophyaInit();
106 InitTim();
107
108 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
109 << " ppfFile= " << ppffile << endl;
110 cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
111 << " iStart= " << istart << " iEnd= " << iend << endl;
[1454]112 cout << ">>>> InTOIName= " << intoi << endl;
[1442]113 try {
114 TOIManager* mgr = TOIManager::getManager();
115
116 // mgr->setRequestedSample(11680920,11710584);
117 // mgr->setRequestedSample(104121000, 104946120);
118
119 mgr->setRequestedSample(istart, iend);
120
121 // FITSTOIReader r("/data/Archeops/bolo11.fits);
122 FITSTOIReader r(infile);
123 cout << "reader created" << endl;
124 // FITSTOIWriter w("/data/Archeops/rz.fits");
125 FITSTOIWriter w(outfile);
126 cout << "fits writer created" << endl;
127
128
[1454]129 // char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
130 // char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
[1442]131 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
132 if (fgdbg) toiin->setDebugLevel(1);
133 TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
134 if (fgdbg) toiout->setDebugLevel(1);
135 TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1);
136 if (fgdbg) toimean->setDebugLevel(1);
137 TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w1);
138 if (fgdbg) toisig->setDebugLevel(1);
[1443]139 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
140 if (fgdbg) toiincopie->setDebugLevel(1);
[1442]141
142
143
144 // Connecting TOI to FITSTOIReader Processor
145 // for(kk=0; kk<5; kk++) {
146 // r.addOutput(colname[kk], toitab[kk]);
147 // }
148
[1454]149 // int kk = 2;
150 r.addOutput(intoi, toiin);
[1442]151 // toi->dbg=true;
152 // r.addOutput("boloMuV_11", toi);
153 cout << " connecting in/out to RzTOIProcessor ... " << endl;
154
155 // TOIProcessor * filt = NULL;
156
157 cout << " Creating SimpleDeglitcher() " << endl;
[1454]158 SimpleDeglitcher degl(w2);
159 cout << " Setting Range for deglitcher: " << range_min
160 << " - " << range_max << endl;
161 degl.SetRange(range_min, range_max);
[1442]162 degl.addInput("in", toiin);
163 degl.addOutput("out", toiout);
164 degl.addOutput("mean", toimean);
165 degl.addOutput("sigma", toisig);
[1443]166 degl.addOutput("incopie", toiincopie);
[1454]167
168 /*
169 cout << " Creating a GaussianFilter SimplFilterObject " << endl;
170 SimpleFilter filt(..)
171 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
172 if (fgdbg) toiincopie->setDebugLevel(1);
173 */
[1442]174
175 w.setOutFlags(true);
[1443]176 w.addInput("in", toiincopie);
[1442]177 w.addInput("degli", toiout);
178 w.addInput("mean", toimean);
179 w.addInput("sigma", toisig);
180
181 cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
182 r.PrintStatus(cout);
183 cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
184 w.PrintStatus(cout);
185
186 PrtTim("starting threads");
187 r.start();
188 degl.start();
189 w.start();
190
[1454]191 /*
192 for(int jj=0; jj<3; jj++) {
193 cout << *toiin;
194 cout << *toiout;
195 sleep(1);
196 }
197 */
198
[1442]199 mgr->joinAll();
200 PrtTim("End threads");
201
202 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
203 // r.PrintStatus(cout);
204 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
205 // w.PrintStatus(cout);
206
[1443]207 cout << degl;
[1442]208 cout << " ------ toiin and toiout Status information ------- " << endl;
209 cout << *toiin;
210 cout << *toiout;
211 }
212 catch (PThrowable & exc) {
213 cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
214 << " - Msg= " << exc.Msg() << endl;
215 }
216 catch (const std::exception & sex) {
217 cerr << "\nrztsttoi: Catched std::exception \n"
218 << (string)typeid(sex).name() << endl;
219 }
220 catch (...) {
221 cerr << "\nrztsttoi: some other exception was caught ! " << endl;
222 }
223
224 return(0);
225}
Note: See TracBrowser for help on using the repository browser.