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

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

Modifs effectuees a St Pierre de Charetreuse - Reza 9/4/2001

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