source: Sophya/trunk/SophyaExt/FitsIOServer/fitshistos.cc@ 3064

Last change on this file since 3064 was 3059, checked in by cmv, 19 years ago

Gestion des IO des projections associees a un Histo2D dans FITS multihdu (ecriture et lecture) cmv 13/8/2006

File size: 17.8 KB
Line 
1#include "machdefs.h"
2#include "sopnamsp.h"
3
4#include <stdio.h>
5#include <string.h>
6#include <iostream>
7#include <typeinfo>
8
9#include "histos.h"
10#include "hisprof.h"
11#include "histerr.h"
12#include "histos2.h"
13
14#include "fitsblkrw.h"
15#include "fitshandler.h"
16
17
18///////////////////////////////////////////////////////////////////////////
19///////////////////////// Histo , HProf , HistoErr ////////////////////////
20///////////////////////////////////////////////////////////////////////////
21
22DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
23int FitsHandler<Histo>::CheckReadability(FitsInOutFile& is)
24{
25 if (is.CurrentHDUType() == IMAGE_HDU ) return 0;
26 string key = "SOPCLSNM";
27 string clsnm = is.KeyValue(key);
28 if ( (clsnm == "SOPHYA::Histo")
29 || (clsnm == "SOPHYA::HProf")
30 || (clsnm == "SOPHYA::HistoErr") ) return 2;
31 return 0;
32}
33
34DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
35int FitsHandler<Histo>::CheckHandling(AnyDataObj & o)
36{
37 if (typeid(o) == typeid(Histo)) return 2;
38 Histo * po = dynamic_cast< Histo * >(& o);
39 if (po != NULL) return 2;
40 return 0;
41}
42
43DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
44void FitsHandler<Histo>::Write(FitsInOutFile& os)
45{
46 if(dobj==NULL)
47 throw NullPtrError("FitsHandler<Histo>::Write() NULL dobj pointer ");
48
49 //--- Le type d'objet et son pointeur
50 Histo* h = dynamic_cast< Histo *> (dobj);
51 HProf* hp = dynamic_cast< HProf *> (dobj);
52 HistoErr* he = dynamic_cast< HistoErr *> (dobj);
53
54 //--- Les noms de colonnes
55 int tbltyp = os.GetDef_TableType();
56 vector<string> colnames, tform, tunit;
57 // les valeurs du bin
58 if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
59 colnames.push_back("val");
60 tunit.push_back("");
61 // Les erreurs
62 if(h->mErr2) {
63 if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
64 colnames.push_back("e2");
65 tunit.push_back("");
66 }
67 // Le nombre d'entrees dans le bin
68 if(he!=NULL || hp!=NULL) {
69 if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
70 colnames.push_back("nb");
71 tunit.push_back("");
72 }
73
74 //--- On cree la table
75 string extname = os.NextExtensionName();
76 os.CreateTable(os.GetDef_TableType(),extname,colnames,tform, tunit);
77
78 // Ecriture des donnees des colonnes
79 int n = h->NBins();
80 if(n>0) {
81 if(hp) hp->UpdateHisto();
82 FitsBlockRW<r_8>::WriteColumnData(os,1,1,1,h->mData,n);
83 if(h->mErr2) FitsBlockRW<r_8>::WriteColumnData(os,2,1,1,h->mErr2,n);
84 if(hp!=NULL) FitsBlockRW<r_8>::WriteColumnData(os,3,1,1,hp->mSumW,n);
85 if(he!=NULL) FitsBlockRW<r_8>::WriteColumnData(os,3,1,1,he->mNData,n);
86 }
87
88 // Ecriture des clefs fits
89 MuTyV mtv;
90
91 mtv = "SOPHYA::Histo";
92 if(hp) mtv = "SOPHYA::HProf";
93 else if(he) mtv = "SOPHYA::HistoErr";
94 os.WriteKey("SOPCLSNM",mtv," SOPHYA class name");
95
96 mtv = "Histo";
97 if(hp) mtv = "HProf";
98 else if(he) mtv = "HistoErr";
99 os.WriteKey("CONTENT",mtv," name of SOPHYA object");
100
101 mtv = h->mBins;
102 os.WriteKey("NBIN",mtv," number of bins");
103
104 mtv = h->mMin;
105 os.WriteKey("XMIN",mtv," absc of beginning of 1srt bin");
106
107 mtv = h->mMax;
108 os.WriteKey("XMAX",mtv," absc of end of last bin");
109
110 mtv = h->binWidth;
111 os.WriteKey("WBIN",mtv," bin width");
112
113 mtv = h->mUnder;
114 os.WriteKey("UNDER",mtv," number of bins");
115
116 mtv = h->mOver;
117 os.WriteKey("OVER",mtv," underflow");
118
119 mtv = h->nHist;
120 os.WriteKey("NHIST",mtv," entries weighted somme");
121
122 double x = h->nEntries; mtv = x;
123 os.WriteKey("NENTRIES",mtv," number of entries");
124
125 int_4 haserr =(h->mErr2) ? 1: 0;
126 mtv = haserr;
127 os.WriteKey("HASERR2",mtv," square errors associated");
128
129 if(hp) {
130 int_4 ok = (hp->mOk)? 1: 0;
131 mtv = ok;
132 os.WriteKey("UPDOK",mtv," update status flag");
133
134 mtv = (int_4)hp->mOpt;
135 os.WriteKey("SIGOPT",mtv," sigma statistic flag");
136
137 mtv = hp->mYMin;
138 os.WriteKey("YMIN",mtv," sum low limit");
139
140 mtv = hp->mYMax;
141 os.WriteKey("YMAX",mtv," sum high limit");
142 }
143
144 if(he) {
145 mtv = he->mCorrel;
146 os.WriteKey("NCORREL",mtv," number of Correl calls");
147 }
148
149 return;
150}
151
152
153DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
154void FitsHandler<Histo>::Read(FitsInOutFile& is)
155{
156 int hdutyp = is.CurrentHDUType();
157 if( (hdutyp != BINARY_TBL ) && (hdutyp != ASCII_TBL) )
158 throw FitsIOException("FitsHandler<Histo>::Read() Not a binary or ascii table HDU");
159
160 //--- Nb de lignes et de colonnes
161 vector<string> colnames;
162 vector<int> coltypes;
163 vector<long> repcnt, width;
164 is.GetColInfo(colnames,coltypes,repcnt,width);
165 long ncol = colnames.size();
166 if(ncol<=0)
167 throw FitsIOException("FitsHandler<Histo>::Read() bad number of table columns");
168 long nbrows = is.GetNbRows();
169 if(nbrows<=0)
170 throw FitsIOException("FitsHandler<Histo>::Read() number of rows is zero, no reading");
171
172 //--- Lecture entete FITS
173 string key = "SOPCLSNM"; string clsnm = is.KeyValue(key);
174 DVList dvl; is.GetHeaderRecords(dvl,true,false);
175
176 int_4 nbin = dvl.GetI("NBIN",-1);
177 if(nbin<=0 && nbin!=nbrows)
178 throw FitsIOException("FitsHandler<Histo>::Read() number of bins is zero or bad, no reading");
179
180 r_8 xmin = dvl.GetD("XMIN",-1.);
181 r_8 xmax = dvl.GetD("XMAX",+1.);
182
183 //--- Creation de l'objet si necessaire
184 if(dobj == NULL) {
185 if(clsnm == "SOPHYA::Histo") dobj = new Histo;
186 else if(clsnm == "SOPHYA::HProf") dobj = new HProf;
187 else if(clsnm == "SOPHYA::HistoErr") dobj = new HistoErr;
188 }
189
190 //--- Type de l'histo
191 Histo* h = dynamic_cast< Histo *> (dobj);
192 HProf* hp = dynamic_cast< HProf *> (dobj);
193 HistoErr* he = dynamic_cast< HistoErr *> (dobj);
194
195 //--- Allocation pour histo
196 if(he && (clsnm=="SOPHYA::HistoErr")) {
197 if(ncol<3)
198 throw FitsIOException("FitsHandler<Histo>::Read() wrong number of columns for HistoErr");
199 he->CreateOrResize(xmin,xmax,nbin);
200 } else if(hp&& (clsnm=="SOPHYA::HProf")) {
201 if(ncol<3)
202 throw FitsIOException("FitsHandler<Histo>::Read() wrong number of columns for HProf");
203 r_8 ymin = dvl.GetD("YMIN",1.);
204 r_8 ymax = dvl.GetD("YMAX",-1.);
205 hp->CreateOrResize(xmin,xmax,nbin,ymin,ymax);
206 } else if(h && clsnm == "SOPHYA::Histo" ) {
207 h->CreateOrResize(xmin,xmax,nbin);
208 int_4 haserr2 = dvl.GetI("HASERR2",0);
209 if(ncol>1 && haserr2>0) h->Errors();
210 } else {
211 throw FitsIOException("FitsHandler<Histo>::Read() No assocaition classe/fits_header");
212 }
213
214 //--- remplissage des variables d'entete
215 h->mUnder = dvl.GetD("UNDER",0.);
216 h->mOver = dvl.GetD("OVER",0.);
217 h->nHist = dvl.GetD("NHIST",0.);
218 double x = dvl.GetD("NENTRIES",0.); h->nEntries = uint_8(x);
219
220 if(hp) {
221 int_4 ok = dvl.GetI("UPDOK",0); hp->mOk = (ok)? true : false;
222 hp->mOpt = (uint_2)dvl.GetI("SIGOPT",0);
223 hp->mYMin = dvl.GetD("YMIN",1.);
224 hp->mYMax = dvl.GetD("YMAX",-1.);
225 }
226
227 if(he) he->mCorrel = dvl.GetI("NCORREL",0);
228
229 //--- remplissage de l'histo
230 FitsBlockRW<r_8>::ReadColumnData(is,1,1,1,h->mData,nbin);
231 if(h->mErr2) FitsBlockRW<r_8>::ReadColumnData(is,2,1,1,h->mErr2,nbin);
232 if(hp) FitsBlockRW<r_8>::ReadColumnData(is,3,1,1,hp->mSumW,nbin);
233 if(he) FitsBlockRW<r_8>::ReadColumnData(is,3,1,1,he->mNData,nbin);
234
235 return;
236}
237
238
239///////////////////////////////////////////////////////////////////////////
240///////////////////////////////// Histo2D ////////////////////////////////
241///////////////////////////////////////////////////////////////////////////
242
243DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
244int FitsHandler<Histo2D>::CheckReadability(FitsInOutFile& is)
245{
246 if (is.CurrentHDUType() == IMAGE_HDU ) return 0;
247 string key = "SOPCLSNM";
248 string clsnm = is.KeyValue(key);
249 if( clsnm == "SOPHYA::Histo2D") return 2;
250 return 0;
251}
252
253DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
254int FitsHandler<Histo2D>::CheckHandling(AnyDataObj & o)
255{
256 if (typeid(o) == typeid(Histo2D)) return 2;
257 Histo2D * po = dynamic_cast< Histo2D * >(& o);
258 if (po != NULL) return 2;
259 return 0;
260}
261
262DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
263void FitsHandler<Histo2D>::Write(FitsInOutFile& os)
264{
265 if(dobj==NULL)
266 throw NullPtrError("FitsHandler<Histo2D>::Write() NULL dobj pointer ");
267
268 //--- Le type d'objet et son pointeur
269 Histo2D* h2 = dynamic_cast< Histo2D *> (dobj);
270
271 //--- Les noms de colonnes
272 int tbltyp = os.GetDef_TableType();
273 vector<string> colnames, tform, tunit;
274 // les valeurs du bin
275 if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
276 colnames.push_back("val");
277 tunit.push_back("");
278 // Les erreurs
279 if(h2->mErr2) {
280 if(tbltyp==ASCII_TBL) tform.push_back("D15.8"); else tform.push_back("D");
281 colnames.push_back("e2");
282 tunit.push_back("");
283 }
284
285 //--- On cree la table
286 string extname = os.NextExtensionName();
287 os.CreateTable(os.GetDef_TableType(),extname,colnames,tform, tunit);
288
289 // Ecriture des donnees des colonnes
290 long n = h2->mNxy;
291 if(n>0) {
292 FitsBlockRW<r_8>::WriteColumnData(os,1,1,1,h2->mData,n);
293 if(h2->mErr2) FitsBlockRW<r_8>::WriteColumnData(os,2,1,1,h2->mErr2,n);
294 }
295
296 // Ecriture des clefs fits
297 MuTyV mtv;
298
299 mtv = "SOPHYA::Histo2D";
300 os.WriteKey("SOPCLSNM",mtv," SOPHYA class name");
301
302 mtv = "Histo2D";
303 os.WriteKey("CONTENT",mtv," name of SOPHYA object");
304
305 mtv = h2->mNx;
306 os.WriteKey("NBINX",mtv," number of bins in X");
307 mtv = h2->mNy;
308 os.WriteKey("NBINY",mtv," number of bins in Y");
309 mtv = h2->mNxy;
310 os.WriteKey("NBINXY",mtv," number of elements");
311
312 mtv = h2->mXmin;
313 os.WriteKey("XMIN",mtv," absc of beginning of 1srt bin in X");
314 mtv = h2->mXmax;
315 os.WriteKey("XMAX",mtv," absc of end of last bin in X");
316 mtv = h2->mYmin;
317 os.WriteKey("YMIN",mtv," absc of beginning of 1srt bin in Y");
318 mtv = h2->mYmax;
319 os.WriteKey("YMAX",mtv," absc of end of last bin in Y");
320
321 mtv = h2->mWBinx;
322 os.WriteKey("WBINX",mtv," bin width in X");
323 mtv = h2->mWBiny;
324 os.WriteKey("WBINY",mtv," bin width in Y");
325
326 for(int i=0;i<3;i++) for(int j=0;j<3;j++) {
327 char str[16]; sprintf(str,"OUT%1d%1d",i,j);
328 mtv = h2->mOver[i][j];
329 os.WriteKey(str,mtv," under/over X/Y");
330 }
331
332 mtv = h2->nHist;
333 os.WriteKey("NHIST",mtv," entries weighted somme");
334
335 mtv = h2->nEntries;
336 os.WriteKey("NENTRIES",mtv," number of entries");
337
338 int_4 haserr =(h2->mErr2) ? 1: 0;
339 mtv = haserr;
340 os.WriteKey("HASERR2",mtv," square errors associated");
341
342
343
344 //-------------------------------------------------------------
345 //------ Gestion des Histo1D de projx/y bandx/t slicex/y ------
346 //-------------------------------------------------------------
347
348 int_4 nrel = 0;
349 if(h2->HProjX()) {nrel++; mtv=nrel; os.WriteKey("PROJX",mtv," relative HDU with HProjX");}
350 if(h2->HProjY()) {nrel++; mtv=nrel; os.WriteKey("PROJY",mtv," relative HDU with HProjY");}
351 if(h2->NSliX()>0) {
352 mtv=h2->NSliX(); os.WriteKey("NSLICEX",mtv," number of SliX");
353 nrel++;
354 mtv=nrel; os.WriteKey("SLICEX",mtv," relative HDU with first SliX");
355 nrel += h2->NSliX()-1;
356 }
357 if(h2->NSliY()>0) {
358 mtv=h2->NSliY(); os.WriteKey("NSLICEY",mtv," number of SliY");
359 nrel++;
360 mtv=nrel; os.WriteKey("SLICEY",mtv," relative HDU with first SliY");
361 nrel += h2->NSliY()-1;
362 }
363 if(h2->NBandX()>0) {
364 mtv=h2->NBandX(); os.WriteKey("NBANDEX",mtv," number of BandX");
365 nrel++;
366 mtv=nrel; os.WriteKey("BANDEX",mtv," relative HDU with first BandX");
367 nrel += h2->NBandX()-1;
368 for(int i=0;i<h2->NBandX();i++) {
369 char str[32]; r_8 vmin,vmax;
370 h2->GetBandX(i,vmin,vmax);
371 sprintf(str,"BXL%d",i);
372 mtv = vmin; os.WriteKey(str,mtv," low Y limit for BandX");
373 sprintf(str,"BXH%d",i);
374 mtv = vmax; os.WriteKey(str,mtv," high Y limit for BandX");
375 }
376 }
377 if(h2->NBandY()>0) {
378 mtv=h2->NBandY(); os.WriteKey("NBANDEY",mtv," number of BandY");
379 nrel++;
380 mtv=nrel; os.WriteKey("BANDEY",mtv," relative HDU with first BandY");
381 nrel += h2->NBandY()-1;
382 for(int i=0;i<h2->NBandY();i++) {
383 char str[32]; r_8 vmin,vmax;
384 h2->GetBandY(i,vmin,vmax);
385 sprintf(str,"BYL%d",i);
386 mtv = vmin; os.WriteKey(str,mtv," low X limit for BandY");
387 sprintf(str,"BYH%d",i);
388 mtv = vmax; os.WriteKey(str,mtv," high X limit for BandY");
389 }
390 }
391 mtv=nrel; os.WriteKey("NH1ASS",mtv," number of associated Histo1D");
392
393 if(h2->HProjX()) {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HProjX()))); fio.Write(os);}
394 if(h2->HProjY()) {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HProjY()))); fio.Write(os);}
395 if(h2->NSliX()>0) for(int i=0;i<h2->NSliX();i++)
396 {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HSliX(i)))); fio.Write(os);}
397 if(h2->NSliY()>0) for(int i=0;i<h2->NSliY();i++)
398 {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HSliY(i)))); fio.Write(os);}
399 if(h2->NBandX()>0) for(int i=0;i<h2->NBandX();i++)
400 {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HBandX(i)))); fio.Write(os);}
401 if(h2->NBandY()>0) for(int i=0;i<h2->NBandY();i++)
402 {FitsHandler<Histo> fio(const_cast<Histo &>(*(h2->HBandY(i)))); fio.Write(os);}
403
404 return;
405}
406
407DECL_TEMP_SPEC /* equivalent a template <> , pour SGI-CC en particulier */
408void FitsHandler<Histo2D>::Read(FitsInOutFile& is)
409{
410 int hdutyp = is.CurrentHDUType();
411 if( (hdutyp != BINARY_TBL ) && (hdutyp != ASCII_TBL) )
412 throw FitsIOException("FitsHandler<Histo2D>::Read() Not a binary or ascii table HDU");
413
414 //--- Nb de lignes et de colonnes
415 vector<string> colnames; vector<int> coltypes; vector<long> repcnt, width;
416 is.GetColInfo(colnames,coltypes,repcnt,width);
417 long ncol = colnames.size();
418 if(ncol<=0)
419 throw FitsIOException("FitsHandler<Histo2D>::Read() bad number of table columns");
420 long nbrows = is.GetNbRows();
421 if(nbrows<=0)
422 throw FitsIOException("FitsHandler<Histo2D>::Read() number of rows is zero, no reading");
423
424 //--- Lecture entete FITS
425 DVList dvl; is.GetHeaderRecords(dvl,true,false);
426
427 int_4 nbinx = dvl.GetI("NBINX",-1);
428 int_4 nbiny = dvl.GetI("NBINY",-1);
429 int_8 nbinxy = nbinx*nbiny;
430 if(nbinx<=0 || nbiny<=0 || nbinxy!=nbrows)
431 throw FitsIOException("FitsHandler<Histo2D>::Read() number of bins is zero or bad, no reading");
432
433 r_8 xmin = dvl.GetD("XMIN",-1.);
434 r_8 xmax = dvl.GetD("XMAX",1.);
435 r_8 ymin = dvl.GetD("YMIN",-1.);
436 r_8 ymax = dvl.GetD("YMAX",1.);
437
438 //--- Creation de l'objet
439 if(dobj == NULL) dobj = new Histo2D;
440 dobj->CreateOrResize(xmin,xmax,nbinx,ymin,ymax,nbiny);
441 int_4 haserr2 = dvl.GetI("HASERR2",0);
442 if(ncol>1 && haserr2>0) dobj->Errors();
443
444 //--- remplissage des variables d'entete
445 dobj->nHist = dvl.GetD("NHIST",0.);
446 dobj->nEntries = dvl.GetI("NENTRIES",0);
447
448 for(int i=0;i<3;i++) for(int j=0;j<3;j++) {
449 char str[16]; sprintf(str,"OUT%1d%1d",i,j);
450 dobj->mOver[i][j] = dvl.GetD(str,0.);
451 }
452
453 //--- remplissage de l'histo
454 FitsBlockRW<r_8>::ReadColumnData(is,1,1,1,dobj->mData,nbinxy);
455 if(dobj->mErr2) FitsBlockRW<r_8>::ReadColumnData(is,2,1,1,dobj->mErr2,nbinxy);
456
457
458
459 //-------------------------------------------------------------
460 //------ Gestion des Histo1D de projx/y bandx/t slicex/y ------
461 //-------------------------------------------------------------
462
463 int_4 nh1ass = dvl.GetI("NH1ASS",-1);
464 if(nh1ass<=0) return;
465 int hducur = is.CurrentHDU();
466
467 try { // ProjX
468 int_4 ipr = dvl.GetI("PROJX",-1);
469 is.MoveAbsToHDU(hducur+ipr);
470 dobj->SetProjX();
471 Histo *h = dobj->HProjX();
472 FitsHandler<Histo> fio(*h); fio.Read(is);
473 if(h->NBins()!=dobj->NBinX())
474 throw FitsIOException("unmatched bin number");
475 } catch (...) {
476 dobj->DelProjX();
477 cout<<"FitsHandler<Histo2D>::Read: Error reading PROJX"<<endl;
478 }
479
480 try { // ProjY
481 int_4 ipr = dvl.GetI("PROJY",-1);
482 is.MoveAbsToHDU(hducur+ipr);
483 dobj->SetProjY();
484 Histo *h = dobj->HProjY();
485 FitsHandler<Histo> fio(*h); fio.Read(is);
486 if(h->NBins()!=dobj->NBinY())
487 throw FitsIOException("unmatched bin number");
488 } catch (...) {
489 dobj->DelProjY();
490 cout<<"FitsHandler<Histo2D>::Read: Error reading PROJY"<<endl;
491 }
492
493 try { // SliX
494 int_4 nb = dvl.GetI("NSLICEX",-1);
495 int_4 ipr = dvl.GetI("SLICEX",-1);
496 dobj->SetSliX(nb);
497 for(int i=0;i<nb;i++) {
498 is.MoveAbsToHDU(hducur+ipr+i);
499 Histo *h = dobj->HSliX(i);
500 FitsHandler<Histo> fio(*h); fio.Read(is);
501 if(h->NBins()!=dobj->NBinX())
502 throw FitsIOException("unmatched bin number");
503 }
504 } catch (...) {
505 dobj->DelSliX();
506 cout<<"FitsHandler<Histo2D>::Read: Error reading SLICEX"<<endl;
507 }
508
509 try { // SliY
510 int_4 nb = dvl.GetI("NSLICEY",-1);
511 int_4 ipr = dvl.GetI("SLICEY",-1);
512 dobj->SetSliY(nb);
513 for(int i=0;i<nb;i++) {
514 is.MoveAbsToHDU(hducur+ipr+i);
515 Histo *h = dobj->HSliY(i);
516 FitsHandler<Histo> fio(*h); fio.Read(is);
517 if(h->NBins()!=dobj->NBinY())
518 throw FitsIOException("unmatched bin number");
519 }
520 } catch (...) {
521 dobj->DelSliY();
522 cout<<"FitsHandler<Histo2D>::Read: Error reading SLICEY"<<endl;
523 }
524
525 try { // BandeX
526 int_4 nb = dvl.GetI("NBANDEX",-1);
527 int_4 ipr = dvl.GetI("BANDEX",-1);
528 for(int i=0;i<nb;i++) {
529 char str[32];
530 sprintf(str,"BXL%d",i); r_8 vmin = dvl.GetD(str,0.);
531 sprintf(str,"BXH%d",i); r_8 vmax = dvl.GetD(str,0.);
532 dobj->SetBandX(vmin,vmax);
533 is.MoveAbsToHDU(hducur+ipr+i);
534 Histo *h = dobj->HBandX(i);
535 FitsHandler<Histo> fio(*h); fio.Read(is);
536 if(h->NBins()!=dobj->NBinX())
537 throw FitsIOException("unmatched bin number");
538 }
539 } catch (...) {
540 dobj->DelBandX();
541 cout<<"FitsHandler<Histo2D>::Read: Error reading BANDEX"<<endl;
542 }
543
544 try { // BandeY
545 int_4 nb = dvl.GetI("NBANDEY",-1);
546 int_4 ipr = dvl.GetI("BANDEY",-1);
547 for(int i=0;i<nb;i++) {
548 char str[32];
549 sprintf(str,"BYL%d",i); r_8 vmin = dvl.GetD(str,0.);
550 sprintf(str,"BYH%d",i); r_8 vmax = dvl.GetD(str,0.);
551 dobj->SetBandY(vmin,vmax);
552 is.MoveAbsToHDU(hducur+ipr+i);
553 Histo *h = dobj->HBandY(i);
554 FitsHandler<Histo> fio(*h); fio.Read(is);
555 if(h->NBins()!=dobj->NBinY())
556 throw FitsIOException("unmatched bin number");
557 }
558 } catch (...) {
559 dobj->DelBandY();
560 cout<<"FitsHandler<Histo2D>::Read: Error reading BANDEY"<<endl;
561 }
562
563 return;
564}
Note: See TracBrowser for help on using the repository browser.