source: Sophya/trunk/ArchTOIPipe/ProcWSophya/PSB2ring.cc@ 1984

Last change on this file since 1984 was 1984, checked in by cecile, 23 years ago

pour release juin 02 de L2 gph 425

File size: 6.9 KB
RevLine 
[1984]1// This may look like C code, but it's really -*- C++ -*-
2
3/////////////////////////////
4// PSB2ring.cc //
5/////////////////////////////
6
7/// This is a processor for ArchTOIPipe using the Sophya Library.
8/// An example of the use of it is in the file gph425_5.cc
9///
10/// The goal of this processor is to give Q and U rings
11// computed with either 3 timelines coming from the
12// two channels of 1 PSB and one of the channels of a second PSB,
13// or with the differences of the two channels of each PSB.
14// The first of these two cases can be used if one channel is out
15// or order, the second one is supposed to be better when all channels
16// work fine, since it fully uses the advantage of PSB's.
17// Both methods should give the same results when the 4 channels work ok.
18
19// Authors CR/NP, rcecile@in2p3.fr, ponthieu@isn.in2p3.fr
20//////////////////////////////////////////////////////////////////////////////////////
21
22#include <stdlib.h>
23#include <stdio.h>
24#include <math.h>
25#include <vector>
26//#include <strstream>
27#include "tmatrix.h"
28#include "tvector.h"
29#include "vector3d.h"
30#include "ctimer.h"
31#include "PSB2ring.h"
32
33#define UNSEEN_HEALPIX (-1.6375e30)
34
35
36// Constructor
37PSB2ring::PSB2ring(SphereHEALPix<r_8>* ringQ,
38 SphereHEALPix<r_8>* ringU,
39 SphereHEALPix<r_8>* ringQW,
40 SphereHEALPix<r_8>* ringUW,
41 const vector<r_8>& table_angle,
42 int_4 wsz)
43 : ringq(ringQ), ringu(ringU), ringqw(ringQW), ringuw(ringUW), TableFP_(table_angle)
44{
45 SetWSize(wsz);
46 totsncount_ = 0;
47
48 if( ringq->NbPixels()<1) {
49 cout << "PSB2ring::PSB2ring : bad number of pixel in ringQ "
50 << ringq->NbPixels() << endl;
51 throw ParmError("PSB2ring::PSB2ring : bad number of pixel in ringQ");
52 }
53 if( ringu->NbPixels()<1) {
54 cout << "PSB2ring::PSB2ring : bad number of pixel in ringU "
55 << ringu->NbPixels()
56 << endl;
57 throw ParmError("PSB2ring::PSB2ring : bad number of pixel in ringU");
58 }
59
60 if( ringqw->NbPixels()<1) {
61 cout << "PSB2ring::PSB2ring : bad number of pixel in ringQW "
62 << ringqw->NbPixels() << endl;
63 throw ParmError("PSB2ring::PSB2ring : bad number of pixel in ringQW");
64 }
65 if( ringuw->NbPixels()<1) {
66 cout << "PSB2ring::PSB2ring : bad number of pixel in ringUW "
67 << ringuw->NbPixels() << endl;
68 throw ParmError("PSB2ring::PSB2ring : bad number of pixel in ringUW");
69 }
70
71 if( ringq->NbPixels() != ringu->NbPixels())
72 throw(ParmError("PSB2ring::PSB2ring : rings don't have the same size!!"));
73
74 Npix_ = ringq->NbPixels();
75 int nlat = ringq->SizeIndex();
76 if(nlat != ringqw->SizeIndex()) ringqw->Resize(nlat);
77 if(nlat != ringuw->SizeIndex()) ringuw->Resize(nlat);
78 cout << "RINGS of " <<ringu->NbPixels() << " pixels" << endl;
79
80 ringq->SetPixels(0.);
81 ringu->SetPixels(0.);
82 ringqw->SetPixels(0);
83 ringuw->SetPixels(0);
84}
85
86// Destructor
87PSB2ring::~PSB2ring()
88{
89}
90
91void PSB2ring::PrintStatus(ostream& os)
92{
93 os << "____________________________________________" << endl
94 << " PSB2ring::PrintStatus() - wsize= "<<wsize_<< endl;
95 TOIProcessor::PrintStatus(os);
96 os << " ProcessedSampleCount=" << ProcessedSampleCount() << endl;
97 os << "____________________________________________" << endl;
98}
99
100void PSB2ring::init()
101{
102 cout << "PSB2ring::init" << endl;
103
104 // on branche les TOIs des 4 bolos (l'un peut etre "vide")
105 for(int i=0; i < 4; i++)// if (PSB_ok[i] > 0)
106 {
107 char str[80];
108 sprintf(str,"Bolo%d",i);
109 cout << str << endl;
110 declareInput(str);
111 }
112
113 // on branche le poinatge des 2 PSB
114 for(int i=0; i < 2; i++)// if (PSB_ok[i] > 0)
115 {
116 char str[80];
117 sprintf(str,"theta_pointing%d",i);
118 cout << str << endl;
119 declareInput(str);
120 sprintf(str,"phi_pointing%d",i);
121 cout << str << endl;
122 declareInput(str);
123 }
124
125 declareOutput("out_toiQ");
126 declareOutput("out_toiU");
127
128 name = "PSB2ring";
129}
130
131void PSB2ring::run()
132{
133 int snb = getMinIn();
134 int sne = getMaxIn();
135
136 if (!checkInputTOIIndex(0) && !checkInputTOIIndex(1)) {
137 cerr << " PSB2ring::run() - Input TOIs (in1, in2 and in3, in4) not connected! "
138 << endl;
139 throw ParmError("PSB2ring::run() Input TOIs (in1, in2 and in3, in4) not connected!");
140 }
141
142 cout << " Bolo2ring::run() SNRange=" << snb << " - " << sne << endl;
143
144 for(int i=0; i<4; i++) //if (PSB_ok[i/2,i%2])
145 if( !checkInputTOIIndex(i) )
146 {
147 cerr << " PSB2ring::run() - Input TOIs not connected! ("
148 << i << ')' << endl;
149 throw ParmError("PSB2ring::run() - Input TOIs not connected!");
150 }
151
152 // pas de sortie a verifier
153
154 cout << "PSB2ring::run() - SNRange="<< snb << '-' << sne << endl;
155
156 try {
157
158 Timer tm("PSB2ring::run()");
159 cout << "****************************" << endl;
160 cout << "****************************" << endl;
161 cout << "4 bolos working and ordered" << endl;
162
163 // Generation des timelines
164 double v0,v1,v2,v3; // values of bolometers outputs
165 double l0, b0, l1, b1; // galactic coordinates
166 uint_8 vfg0,vfg1,vfg2,vfg3;
167 double Q,U;
168
169 for(int s=snb;s<=sne;s++) {
170
171 getData(0, s, v0, vfg0);
172 getData(1, s, v1, vfg1);
173 getData(2, s, v2, vfg2);
174 getData(3, s, v3, vfg3);
175
176 l0 = getData(4, s);
177 b0 = getData(5, s);
178 l1 = getData(6, s);
179 b1 = getData(7, s);
180
181 double theta0 = (90. - b0)/180 * 3.14159;
182 double phi0 = l0/180. * 3.14159;
183 double theta1 = (90. - b1)/180 * 3.14159;
184 double phi1 = l1/180 *3.14159;
185
186
187
188 // cout << " ********** Q(t) and U(t) finished *********** " << endl;
189
190 // cout << " ********** Projection on the ring ********* " << endl;
191
192 //Projection
193
194 if((vfg0 == 0) && (vfg1 == 0))
195 {
196 Q = v0 - v1;
197 int_4 pixelQ = ringq->PixIndexSph(theta0, phi0); // numero du pixel touche
198 ringqw->PixVal(pixelQ) += 1 ; // nombre de hits dans le pixel
199 ringq->PixVal(pixelQ) += Q ;
200 }
201
202 if((vfg2 == 0) && (vfg3 == 0))
203 {
204 U = v2 - v3;
205 int_4 pixelU = ringu->PixIndexSph(theta1, phi1);
206 ringuw->PixVal(pixelU) += 1 ;
207 ringu->PixVal(pixelU) += U ;
208 }
209
210 if (!(s%10000)) cout << s << " ****** filling rings ****** " << endl;
211
212 putData(0, s, Q);
213 putData(1, s, U);
214 }
215
216 // Moyennage des pixels
217 // comme on bosse directement avec des timelines de Q et U
218 // dans ce cas precis, on a juste a prendre la moyenne des valeurs
219 // qui tombent dans un pixel pour avoir la carte
220 // on ne doit inverser de matrice etc que dans le cas
221 // trois bolos.
222
223 for(int pix=0 ; pix < Npix_ ; pix++) {
224
225 if( ringqw->PixVal(pix) < 1.0 ) //pixel pas vu
226 ringq->PixVal(pix) = ringu->PixVal(pix) = UNSEEN_HEALPIX;
227 else
228 ringq->PixVal(pix) = ringq->PixVal(pix) / ringqw->PixVal(pix);
229
230 if( ringuw->PixVal(pix) < 1.0 )
231 ringu->PixVal(pix) = ringu->PixVal(pix) = UNSEEN_HEALPIX;
232 else
233 ringu->PixVal(pix) = ringu->PixVal(pix) / ringuw->PixVal(pix);
234
235 }
236 cout << " ********** rings filled ********* " << endl;
237 }
238
239
240 catch( PThrowable& exc )
241 {
242 cerr << " Exception: " << exc.Msg() << endl;
243 }
244}
245
246
247
Note: See TracBrowser for help on using the repository browser.