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

Last change on this file since 1467 was 1467, checked in by ansari, 24 years ago

Debug de SimpleDeglitcher, ajout de SimpleFanOut , Reza 12/4/2001

File size: 8.4 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 {
[1467]24 cout << "\n Usage : simtst [-dbg] [-start snb] [-end sne] \n"
25 << " [-wtoi sz] [-w2 sz] inFitsName outFitsName ppfFileName \n"
[1442]26 << " -dbg : sets TOISeqBuffered debug level to 1 \n"
27 << " -start snb : sets the start sample num \n"
28 << " -end sne : sets the end sample num \n"
[1454]29 << " -range min,max : sets the acceptable range for intoi \n"
30 << " default= -16000,16000\n"
[1467]31 << " -intoi toiName : select input TOI name (def boloMuV_27)\n"
32 << " -wtoi sz : sets TOISeqBuff buffer size (def= 8192)\n"
33 << " -wdegli sz : sets deglitcher window size (def= 512) \n"
[1442]34 << endl;
35 exit(0);
36 }
37}
38
39int main(int narg, char** arg) {
40
41 if ((narg > 1) && (strcmp(arg[1],"-h") == 0) ) Usage(false);
42
43 cout << "simtst starting - Decoding arguments " << " narg=" << narg << endl;
44
45 bool fgdbg = false;
46 int w1 = 8192;
[1467]47 int w2 = 512;
[1442]48 int nmax = 10;
49 int istart = 104121000+w1*5;
50 int iend = 0;
[1454]51 double range_min = -16000;
52 double range_max = 16000.;
[1442]53 string infile;
54 string outfile;
55 string ppffile;
[1467]56 string intoi = "boloMuV_27";
[1442]57
58 if (narg < 4) Usage(true);
59 int ko=1;
60 // decoding arguments
61 for(int ia=1; ia<narg; ia++) {
62 if (strcmp(arg[ia],"-start") == 0) {
63 if (ia == narg-1) Usage(true); // -start est suivi d'un argument
64 istart = atoi(arg[ia+1]); ia++;
65 }
66 else if (strcmp(arg[ia],"-end") == 0) {
67 if (ia == narg-1) Usage(true);
68 iend = atoi(arg[ia+1]); ia++;
69 }
[1467]70 else if (strcmp(arg[ia],"-wtoi") == 0) {
[1442]71 if (ia == narg-1) Usage(true);
72 w1 = atoi(arg[ia+1]); ia++;
73 }
[1467]74 else if (strcmp(arg[ia],"-wdegli") == 0) {
[1442]75 if (ia == narg-1) Usage(true);
76 w2 = atoi(arg[ia+1]); ia++;
77 }
[1454]78 else if (strcmp(arg[ia],"-range") == 0) {
79 if (ia == narg-1) Usage(true);
80 sscanf(arg[ia+1],"%lf,%lf",&range_min, &range_max);
81 ia++;
82 }
83 else if (strcmp(arg[ia],"-intoi") == 0) {
84 if (ia == narg-1) Usage(true);
85 intoi = arg[ia+1]; ia++;
86 }
[1442]87 else if (strcmp(arg[ia],"-dbg") == 0) fgdbg = true;
88
89 else { ko = ia; break; } // Debut des noms
90 }
91
92 if (iend < istart) iend = istart+w1*(nmax+5);
93 if ((narg-ko) < 3) Usage(true);
94 infile = arg[ko];
95 outfile = arg[ko+1];
96 ppffile = arg[ko+2];
97
98 cout << " Initializing SOPHYA ... " << endl;
99 SophyaInit();
100 InitTim();
101
102 cout << ">>>> tstrztoi: Infile= " << infile << " outFile=" << outfile
103 << " ppfFile= " << ppffile << endl;
104 cout << ">>>> Window Size W1= " << w1 << " W2= " << w2
105 << " iStart= " << istart << " iEnd= " << iend << endl;
[1454]106 cout << ">>>> InTOIName= " << intoi << endl;
[1442]107 try {
108 TOIManager* mgr = TOIManager::getManager();
109
110 // mgr->setRequestedSample(11680920,11710584);
111 // mgr->setRequestedSample(104121000, 104946120);
112
113 mgr->setRequestedSample(istart, iend);
114
115 // FITSTOIReader r("/data/Archeops/bolo11.fits);
116 FITSTOIReader r(infile);
117 cout << "reader created" << endl;
118 // FITSTOIWriter w("/data/Archeops/rz.fits");
119 FITSTOIWriter w(outfile);
120 cout << "fits writer created" << endl;
121
122
[1454]123 // char * colname[5] = {"MJD", "UTC","boloMuV_11","magnFlux","pivot"};
124 // char * toiname[5] = {"MJD", "UTC","bolo11","magneto","pivot"};
[1442]125 TOISeqBuffered * toiin = new TOISeqBuffered("f2in", w1);
126 if (fgdbg) toiin->setDebugLevel(1);
[1467]127 TOISeqBuffered * toidegli = new TOISeqBuffered("degli", w1);
128 if (fgdbg) toidegli->setDebugLevel(1);
[1442]129 TOISeqBuffered * toimean = new TOISeqBuffered("mean", w1);
130 if (fgdbg) toimean->setDebugLevel(1);
131 TOISeqBuffered * toisig = new TOISeqBuffered("sigma", w1);
132 if (fgdbg) toisig->setDebugLevel(1);
[1443]133 TOISeqBuffered * toiincopie = new TOISeqBuffered("incopie", w1);
134 if (fgdbg) toiincopie->setDebugLevel(1);
[1442]135
136
137
138 // Connecting TOI to FITSTOIReader Processor
139 // for(kk=0; kk<5; kk++) {
140 // r.addOutput(colname[kk], toitab[kk]);
141 // }
142
[1454]143 // int kk = 2;
144 r.addOutput(intoi, toiin);
[1442]145 // toi->dbg=true;
146 // r.addOutput("boloMuV_11", toi);
147 cout << " connecting in/out to RzTOIProcessor ... " << endl;
148
149 // TOIProcessor * filt = NULL;
150
151 cout << " Creating SimpleDeglitcher() " << endl;
[1454]152 SimpleDeglitcher degl(w2);
153 cout << " Setting Range for deglitcher: " << range_min
154 << " - " << range_max << endl;
155 degl.SetRange(range_min, range_max);
[1442]156 degl.addInput("in", toiin);
[1467]157 degl.addOutput("out", toidegli);
[1442]158 degl.addOutput("mean", toimean);
159 degl.addOutput("sigma", toisig);
[1443]160 degl.addOutput("incopie", toiincopie);
[1467]161
162 cout << " Creating a FanOut SimpleFanOut Object " << endl;
163 SimpleFanOut fanout(2,2);
164 TOISeqBuffered * toidegli0 = new TOISeqBuffered("degli0", w1);
165 if (fgdbg) toidegli0->setDebugLevel(1);
166 TOISeqBuffered * toidegli1 = new TOISeqBuffered("degli1", w1);
[1442]167
[1467]168 TOISeqBuffered * toimean0 = new TOISeqBuffered("mean0", w1);
169 if (fgdbg) toimean0->setDebugLevel(1);
170 TOISeqBuffered * toimean1 = new TOISeqBuffered("mean1", w1);
171 if (fgdbg) toimean1->setDebugLevel(1);
172
173 fanout.addInput("in0", toidegli);
174 fanout.addOutput("out0_0", toidegli0);
175 fanout.addOutput("out0_1", toidegli1);
176 fanout.addInput("in1", toimean);
177 fanout.addOutput("out1_0", toimean0);
178 fanout.addOutput("out1_1", toimean1);
179
180 cout << " Creating an Adder SimpleAdder Object " << endl;
181 SimpleAdder adder(2);
182 adder.addInput("in0", toidegli0);
183 adder.addInput("in1", toimean0);
184 adder.SetGain(0, 1.);
185 adder.SetGain(1, -1.);
186 TOISeqBuffered * toideglioff = new TOISeqBuffered("deglioff", w1);
187 if (fgdbg) toideglioff->setDebugLevel(1);
188 adder.addOutput("out", toideglioff);
189
190 cout << " Creating a GaussianFilter SimpleFilter Object " << endl;
191 SimpleFilter filt(8, SimpleFilter::GaussFilter, 1., 2.);
192
193 filt.addInput("in", toideglioff);
194 TOISeqBuffered * toiout = new TOISeqBuffered("out", w1);
195 if (fgdbg) toiout->setDebugLevel(1);
196 TOISeqBuffered * toideglioffcopie = new TOISeqBuffered("deglioffcopie", w1);
197 if (fgdbg) toideglioffcopie->setDebugLevel(1);
198 filt.addOutput("out", toiout);
199 filt.addOutput("incopie", toideglioffcopie);
200
201
202 cout << " Connecting to output (FitsWriter) " << endl;
203
[1442]204 w.setOutFlags(true);
[1443]205 w.addInput("in", toiincopie);
[1467]206 w.addInput("out", toiout);
207 w.addInput("degli", toidegli1);
208 w.addInput("deglioff", toideglioffcopie);
209 w.addInput("mean", toimean1);
[1442]210 w.addInput("sigma", toisig);
211
212 cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
213 r.PrintStatus(cout);
[1467]214 cout << " ------ FanOut::PrintStatus() : ----- " << endl;
215 fanout.PrintStatus(cout);
216 cout << " ------ Adder::PrintStatus() : ----- " << endl;
217 adder.PrintStatus(cout);
218 cout << " ------ Filter::PrintStatus() : ----- " << endl;
219 filt.PrintStatus(cout);
[1442]220 cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
221 w.PrintStatus(cout);
222
223 PrtTim("starting threads");
224 r.start();
225 degl.start();
[1467]226 fanout.start();
227 adder.start();
228 filt.start();
[1442]229 w.start();
230
[1467]231 /*
[1454]232 for(int jj=0; jj<3; jj++) {
233 cout << *toiin;
[1467]234 cout << *toimean;
235 cout << *toimean1;
[1454]236 cout << *toiout;
237 sleep(1);
238 }
[1467]239
[1454]240 */
241
[1442]242 mgr->joinAll();
243 PrtTim("End threads");
244
245 // cout << " ------ FITSReaderTOI::PrintStatus() : ----- " << endl;
246 // r.PrintStatus(cout);
247 // cout << "----- FITSWriterTOI::PrintStatus() : ----- " << endl;
248 // w.PrintStatus(cout);
249
[1467]250 cout << " ------ toiin, toidegli and toiout Status information ------- " << endl;
[1442]251 cout << *toiin;
[1467]252 cout << *toidegli;
[1442]253 cout << *toiout;
[1467]254
255 cout << degl;
256 cout << filt;
257 cout << adder;
258
[1442]259 }
260 catch (PThrowable & exc) {
261 cerr << "\nrztsttoi: Catched Exception \n" << (string)typeid(exc).name()
262 << " - Msg= " << exc.Msg() << endl;
263 }
264 catch (const std::exception & sex) {
265 cerr << "\nrztsttoi: Catched std::exception \n"
266 << (string)typeid(sex).name() << endl;
267 }
268 catch (...) {
269 cerr << "\nrztsttoi: some other exception was caught ! " << endl;
270 }
271
272 return(0);
273}
Note: See TracBrowser for help on using the repository browser.