source: trunk/MagicSoft/Mars/manalysis/MSourcePosfromStarPos.cc@ 3370

Last change on this file since 3370 was 3339, checked in by wittek, 21 years ago
*** empty log message ***
File size: 22.8 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17! Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
18!
19! Copyright: MAGIC Software Development, 2000-2004
20!
21!
22\* ======================================================================== */
23
24/////////////////////////////////////////////////////////////////////////////
25//
26// MSourcePosfromStarPos
27//
28// This is a task which
29// - calculates the position of the source in the camera
30// from the position of a known star in the camera
31// - and puts the source position into the container MSrcPosCam
32//
33// Input :
34// ASCII file containing for each run
35// - the run number
36// - the direction (theta, phi) the telescope is pointing to in [deg]
37// - the position (xStar, yStar) of a known star in the camera in [mm]
38// - the error (dxStar, dyStar) of this position in [mm]
39//
40// Output Containers :
41// MSrcPosCam
42//
43/////////////////////////////////////////////////////////////////////////////
44#include <TList.h>
45#include <TSystem.h>
46#include <TMatrixD.h>
47
48#include <fstream>
49
50#include "MSourcePosfromStarPos.h"
51
52#include "MParList.h"
53#include "MRawRunHeader.h"
54#include "MGeomCam.h"
55#include "MSrcPosCam.h"
56#include "MMcEvt.hxx"
57
58#include "MLog.h"
59#include "MLogManip.h"
60
61ClassImp(MSourcePosfromStarPos);
62
63using namespace std;
64
65// --------------------------------------------------------------------------
66//
67// Default constructor.
68//
69MSourcePosfromStarPos::MSourcePosfromStarPos(
70 const char *name, const char *title)
71 : fIn(NULL)
72{
73 fName = name ? name : "MSourcePosfromStarPos";
74 fTitle = title ? title : "Calculate source position from star position";
75
76 fFileNames = new TList;
77 fFileNames->SetOwner();
78
79 fRuns = 0;
80 fSize = 100;
81 fStars = 0;
82
83 fRunNr.Set(fSize);
84
85 fThetaTel.Set(fSize);
86 fPhiTel.Set(fSize);
87 fdThetaTel.Set(fSize);
88 fdPhiTel.Set(fSize);
89
90 fDecStar.Set(1);
91 fRaStar.Set(1);
92 fxStar.ResizeTo(1,fSize);
93 fyStar.ResizeTo(1,fSize);
94 fdxStar.ResizeTo(1,fSize);
95 fdyStar.ResizeTo(1,fSize);
96
97}
98
99// --------------------------------------------------------------------------
100//
101// Delete the filename list and the input stream if one exists.
102//
103MSourcePosfromStarPos::~MSourcePosfromStarPos()
104{
105 delete fFileNames;
106 if (fIn)
107 delete fIn;
108}
109
110
111// --------------------------------------------------------------------------
112//
113// Set the sky coordinates of the source and of the star
114//
115// Input :
116// declination in units of (Deg, Min, Sec)
117// right ascension in units of (Hour, Min, Sec)
118//
119
120void MSourcePosfromStarPos::SetSourceAndStarPosition(
121 TString nameSource,
122 Double_t decSourceDeg, Double_t decSourceMin, Double_t decSourceSec,
123 Double_t raSourceHour, Double_t raSourceMin, Double_t raSourceSec,
124 TString nameStar,
125 Double_t decStarDeg, Double_t decStarMin, Double_t decStarSec,
126 Double_t raStarHour, Double_t raStarMin, Double_t raStarSec )
127{
128 *fLog << "MSourcePosfromStarPos::SetSourceAndStarPosition :" << endl;
129 *fLog << " Source : " << nameSource << " " << decSourceDeg << ":"
130 << decSourceMin << ":" << decSourceSec << endl;
131 *fLog << " Star : " << nameStar << " " << decStarDeg << ":"
132 << decStarMin << ":" << decStarSec << endl;
133
134 // convert into radians
135 fDecSource = (decSourceDeg + decSourceMin/60.0 + decSourceSec/3600.0)
136 / kRad2Deg;
137 fRaSource = (raSourceHour + raSourceMin/60.0 + raSourceSec/3600.0)
138 * 360.0 / (24.0 * kRad2Deg);
139
140 fStars += 1;
141 fDecStar.Set(fStars);
142 fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
143 / kRad2Deg;
144 fRaStar[fStars-1] = (raStarHour + raStarMin/60.0 + raStarSec/3600.0)
145 * 360.0 / (24.0 * kRad2Deg);
146
147 *fLog << all << "MSourcePosfromStarPos::SetSourceAndStarPosition; fDecSource, fRaSource, fDecStar, fRaStar were set to : [radians] "
148 << fDecSource << ", " << fRaSource << ", "
149 << fDecStar[fStars-1] << ", " << fRaStar[fStars-1] << endl;
150}
151
152// --------------------------------------------------------------------------
153//
154// Set the sky coordinates of another star
155//
156// Input :
157// declination in units of (Deg, Min, Sec)
158// right ascension in units of (Hour, Min, Sec)
159//
160
161void MSourcePosfromStarPos::AddStar(
162 TString nameStar,
163 Double_t decStarDeg, Double_t decStarMin, Double_t decStarSec,
164 Double_t raStarHour, Double_t raStarMin, Double_t raStarSec )
165{
166 *fLog << "MSourcePosfromStarPos::AddStar :" << endl;
167 *fLog << " Star : " << nameStar << " " << decStarDeg << ":"
168 << decStarMin << ":" << decStarSec << endl;
169
170 // convert into radians
171 fStars = fDecStar.GetSize() + 1;
172 fDecStar.Set(fStars);
173 fDecStar[fStars-1] = (decStarDeg + decStarMin/60.0 + decStarSec/3600.0)
174 / kRad2Deg;
175 fRaStar[fStars-1] = (raStarHour + raStarMin/60.0 + raStarSec/3600.0)
176 * 360.0 / (24.0 * kRad2Deg);
177
178 *fLog << all << "MSourcePosfromStarPos::AddStar; fDecStar, fRaStar were set to : [radians] "
179 << fDecStar[fStars-1] << ", " << fRaStar[fStars-1] << endl;
180}
181
182// --------------------------------------------------------------------------
183//
184//
185Int_t MSourcePosfromStarPos::PreProcess(MParList *pList)
186{
187 MGeomCam *geom = (MGeomCam*)pList->FindObject(AddSerialNumber("MGeomCam"));
188 if (!geom)
189 {
190 *fLog << err << "MSourcePosfromStarPos : MGeomCam (Camera Geometry) missing in Parameter List... aborting." << endl;
191 return kFALSE;
192 }
193 fMm2Deg = geom->GetConvMm2Deg();
194 // fDistCameraReflector is the distance of the camera from the reflector center in [mm]
195 fDistCameraReflector = kRad2Deg / fMm2Deg;
196 *fLog << all << "MSourcePosfromStarPos::PreProcess; fMm2Deg, fDistCameraReflector = "
197 << fMm2Deg << ", " << fDistCameraReflector << endl;
198
199
200 fRun = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
201 if (!fRun)
202 {
203 *fLog << err << "MSourcePosfromStarPos::PreProcess; MRawRunHeader not found... aborting." << endl;
204 return kFALSE;
205 }
206
207
208 fMcEvt = (MMcEvt*)pList->FindCreateObj("MMcEvt");
209 if (!fMcEvt)
210 {
211 *fLog << err << "MSourcePosfromStarPos::PreProcess; MMcEvt not found... aborting." << endl;
212 return kFALSE;
213 }
214
215
216 fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber("MSrcPosCam"));
217 if (!fSrcPos)
218 {
219 *fLog << err << "MSourcePosfromStarPos::PreProcess; MSrcPosCam not found... aborting" << endl;
220 return kFALSE;
221 }
222
223 //---------------------------------------------------------------------
224 // read all files and call ReadData() to read and store the information
225 //
226
227 *fLog << all << "---------------------------------" << endl;
228 while(1)
229 {
230 if (!OpenNextFile())
231 {
232 *fLog << "there is no more file to open" << endl;
233 break;
234 }
235
236 *fLog << "read data" << endl;
237 while (1)
238 {
239 if (fIn->eof())
240 {
241 *fLog << "eof encountered; open next file" << endl;
242
243 if (!OpenNextFile()) break;
244 }
245
246 // FIXME! Set InputStreamID
247
248 ReadData();
249 }
250 }
251
252 *fLog << "all data were read" << endl;
253 FixSize();
254
255 if (fDecSource == 0.0 || fRaSource == 0.0 || fStars == 0)
256 {
257 *fLog << err << "MSourcePosfromStarPos::PreProcess; there are no sky coordinates defined for the source or from stars"
258 << endl;
259 }
260 *fLog << all << "---------------------------------" << endl;
261
262 //-------------------------------------------------------------
263
264 return kTRUE;
265}
266
267//=========================================================================
268//
269// SourcefromStar
270//
271// this routine calculates the position of a source (for example Crab) in the camera
272// from the position of a star (for example ZetaTauri) in the camera. The latter
273// position may have been determined by analysing the DC currents in the different
274// pixels.
275//
276// Input : thetaTel, phiTel the direction the telescope is pointing to,
277// in local coordinates
278// f the distance between camera and reflector
279// decStar, raStar the position of the star in sky coordinates
280// decSource, raSource the position of the source in sky coordinates
281// xStar, yStar the position of the star in the camera
282// dxStar, dyStar error of the position of the star in the camera
283//
284// Output : xSource, ySource the calculated position of the source in the camera
285// dxSource, dySource error of the calculated position of the source in
286// the camera
287//
288// Useful formulas can be found in TDAS 00-11 and TDAS 01-05
289//
290
291void MSourcePosfromStarPos::SourcefromStar(Double_t &f,
292 TArrayD &decStar, TArrayD &raStar,
293 Double_t &decSource, Double_t &raSource,
294 Double_t &thetaTel, Double_t &phiTel,
295 TArrayD &xStar, TArrayD &yStar,
296 TArrayD &dxStar, TArrayD &dyStar,
297 Double_t &xSource, Double_t &ySource,
298 Double_t &dxSource, Double_t &dySource)
299{
300 /*
301 *fLog << "MSourcePosfromStarPos::SourcefromStar : printout in degrees" << endl;
302 *fLog << " decStar, raStar = " << decStar[0]*kRad2Deg << ", "
303 << raStar[0]*kRad2Deg << endl;
304 *fLog << " decSource, raSource = " << decSource*kRad2Deg << ", "
305 << raSource*kRad2Deg << endl;
306 *fLog << " thetaTel, phiTel = " << thetaTel*kRad2Deg << ", "
307 << phiTel*kRad2Deg << endl;
308 *fLog << " xStar, yStar = " << xStar[0]*fMm2Deg << ", "
309 << yStar[0]*fMm2Deg << endl;
310
311 *fLog << "MSourcePosfromStarPos::SourcefromStar : printout in radians and mm" << endl;
312 *fLog << " decStar, raStar = " << decStar[0] << ", "
313 << raStar[0] << endl;
314 *fLog << " decSource, raSource = " << decSource << ", "
315 << raSource << endl;
316 *fLog << " thetaTel, phiTel = " << thetaTel << ", "
317 << phiTel << endl;
318 *fLog << " xStar, yStar = " << xStar[0] << ", "
319 << yStar[0] << endl;
320 */
321
322 // the units are assumed to be radians for theta, phi, dec and ra
323 // and mm for f, x and y
324
325
326 // calculate rotation angle alpha of sky image in camera
327 // (see TDAS 00-11, eqs. (18) and (20))
328 // a1 = cos(Lat), a3 = -sin(Lat), where Lat is the geographical latitude of La Palma
329 Double_t a1 = 0.876627;
330 Double_t a3 = -0.481171;
331
332 Double_t denom = 1./ sqrt( sin(thetaTel)*sin(phiTel) * sin(thetaTel)*sin(phiTel) +
333 ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) ) *
334 ( a1*cos(thetaTel)+a3*sin(thetaTel)*cos(phiTel) ) );
335 Double_t cosal = - (a3 * sin(thetaTel) + a1 * cos(thetaTel) * cos(phiTel)) * denom;
336 Double_t sinal = a1 * sin(phiTel) * denom;
337
338 //*fLog << "thetaTel, phiTel, cosal, sinal = " << thetaTel << ", "
339 // << phiTel << ", " << cosal << ", " << sinal << endl;
340
341
342 // calculate coordinates of source in system B (see TDAS 00-11, eqs. (2))
343 // note that right ascension and hour angle go into opposite directions
344 Double_t xB0 = cos(decSource) * cos(-raSource);
345 Double_t yB0 = cos(decSource) * sin(-raSource);
346 Double_t zB0 = -sin(decSource);
347
348 //*fLog << "xB0, yB0, zB0 = " << xB0 << ", " << yB0 << ", "
349 // << zB0 << endl;
350
351 //-----------------------------------------------------
352 // loop over stars
353 Double_t sumx = 0.0;
354 Double_t sumy = 0.0;
355 Double_t sumwx = 0.0;
356 Double_t sumwy = 0.0;
357
358 for (Int_t i=0; i<decStar.GetSize(); i++)
359 {
360 // calculate weights
361 Double_t weightx = 1.0 / (dxStar[i]*dxStar[i]);
362 Double_t weighty = 1.0 / (dyStar[i]*dyStar[i]);
363 sumwx += weightx;
364 sumwy += weighty;
365
366 //*fLog << "weightx, weighty = " << weightx << ", " << weighty << endl;
367
368 // calculate coordinates of star in system B (see TDAS 00-11, eqs. (2))
369 // note that right ascension and hour angle go into opposite directions
370 Double_t xB = cos(decStar[i]) * cos(-raStar[i]);
371 Double_t yB = cos(decStar[i]) * sin(-raStar[i]);
372 Double_t zB = -sin(decStar[i]);
373
374
375 //*fLog << "xB, yB, zB = " << xB << ", " << yB << ", "
376 // << zB << endl;
377
378
379 // calculate coordinates of star in a system with the basis vectors e1, e2, e3
380 // where e1 is in the direction (r0 x a)
381 // e2 is in the direction (e1 x r0)
382 // and e3 is in the direction -r0;
383 // r0 is the direction to the source
384 // and a is the earth rotation axis (pointing to the celestial north pole)
385 //
386 Double_t x = (-xB*yB0 + xB0*yB) / sqrt( xB0*xB0 + yB0*yB0 );
387 Double_t y = ( xB*xB0*zB0 + yB*yB0*zB0 - zB*(xB0*xB0 + yB0*yB0) )
388 / sqrt( xB0*xB0 + yB0*yB0 );
389 Double_t z = -(xB*xB0 + yB*yB0 + zB*zB0);
390
391 //*fLog << "x, y, z = " << x << ", " << y << ", "
392 // << z << endl;
393
394
395 // calculate coordinates of star in camera
396 Double_t xtilde = -f/z * (cosal*x - sinal*y);
397 Double_t ytilde = -f/z * (sinal*x + cosal*y);
398
399 //*fLog << "xtilde, ytile = " << xtilde << ", " << ytilde << endl;
400
401
402 // calculate coordinates of source in camera
403 // note : in real camera signs are inverted (therefore s = -1.0)
404 Double_t s = -1.0;
405 sumx += s * (s*xStar[i] - xtilde) * weightx;
406 sumy += s * (s*yStar[i] - ytilde) * weighty;
407 }
408 //-----------------------------------------------------
409
410 xSource = sumx / sumwx;
411 ySource = sumy / sumwy;
412 dxSource = 1.0 / sqrt(sumwx);
413 dySource = 1.0 / sqrt(sumwy);
414
415 /*
416 Int_t run = fRun->GetRunNumber();
417 *fLog << all << "MSourcePosfromStarPos::SourcefromStar; run, xSource, ySource = "
418 << run << " : "
419 << xSource << " +- " << dxSource << ", "
420 << ySource << " +- " << dySource << endl;
421 */
422}
423
424// --------------------------------------------------------------------------
425//
426// Get the source position and put it into MSrcPosCam
427//
428//
429Bool_t MSourcePosfromStarPos::ReInit(MParList *pList)
430{
431
432 Int_t run = fRun->GetRunNumber();
433 *fLog << all << "MSourcePosfromStarPos::ReInit; run = " << run << endl;
434
435 // define default values for source position and (theta, phi)
436 Double_t xSource_def = 51.0;
437 Double_t ySource_def = -59.0;
438 Double_t theta_def = 25.0;
439 Double_t phi_def = 90.0;
440
441 //-------------------------------------------------------------------
442 // search this run in the list
443 for (Int_t i=0; i<fSize; i++)
444 {
445 if (run == fRunNr[i])
446 {
447 //-----------------------------------------
448 // put the zenith angle into MMcEvt
449
450 Double_t thetarad = fThetaTel[i];
451 Double_t phirad = fPhiTel[i];
452 fMcEvt->SetTelescopeTheta(thetarad);
453 fMcEvt->SetTelescopePhi(phirad);
454 fMcEvt->SetReadyToSave();
455
456 *fLog << all << "theta, phi = " << thetarad*kRad2Deg << ", "
457 << phirad*kRad2Deg << " deg" << endl;
458
459 //-----------------------------------------
460 // Get source position and put it into MSrcPosCam
461
462
463 if (fStars > 0)
464 {
465 TArrayD xStar(fxStar.GetNrows());
466 TArrayD dxStar(fdxStar.GetNrows());
467 TArrayD yStar(fyStar.GetNrows());
468 TArrayD dyStar(fdyStar.GetNrows());
469 for (Int_t j=0; j<fxStar.GetNrows(); j++)
470 {
471 xStar[j] = fxStar(j, i);
472 dxStar[j] = fdxStar(j, i);
473 yStar[j] = fyStar(j, i);
474 dyStar[j] = fdyStar(j, i);
475 }
476
477 MSourcePosfromStarPos::SourcefromStar( fDistCameraReflector,
478 fDecStar, fRaStar, fDecSource, fRaSource,
479 fThetaTel[i], fPhiTel[i],
480 xStar, yStar,
481 dxStar, dyStar,
482 fxSource, fySource,
483 fdxSource, fdySource);
484
485 fSrcPos->SetXY(fxSource, fySource);
486
487 *fLog << all << "MSourcePosfromStarPos::ReInit; fRunNr, fxSource, fySource = "
488 << fRunNr[i] << ", " << fxSource << " +- " << fdxSource
489 << ", " << fySource << " +- " << fdySource << endl;
490
491 fSrcPos->SetReadyToSave();
492 }
493 else
494 {
495 // set default values
496 fxSource = xSource_def;
497 fySource = ySource_def;
498 fSrcPos->SetXY(fxSource, fySource);
499 fSrcPos->SetReadyToSave();
500
501 *fLog << warn << "MSourcePosfromStarPos::ReInit; no information on source position for run number = "
502 << run << endl;
503 *fLog << warn << " set xSource, ySource = " << fxSource << ", "
504 << fySource << " mm" << endl;
505 }
506
507
508 return kTRUE;
509 }
510 }
511 //-------------------------------------------------------------------
512
513 // set default values
514 fxSource = xSource_def;
515 fySource = ySource_def;
516 fSrcPos->SetXY(fxSource, fySource);
517 fSrcPos->SetReadyToSave();
518
519 Double_t thetadeg = theta_def;
520 Double_t thetarad = thetadeg / kRad2Deg;
521 fMcEvt->SetTelescopeTheta(thetarad);
522
523 Double_t phideg = phi_def;
524 Double_t phirad = phideg / kRad2Deg;
525 fMcEvt->SetTelescopePhi(phirad);
526 fMcEvt->SetReadyToSave();
527
528 *fLog << warn << "MSourcePosfromStarPos::ReInit; no information on theta, phi and source position for run number = "
529 << run << endl;
530 *fLog << warn << " set xSource, ySource = " << fxSource << ", "
531 << fySource << " mm" << endl;
532 *fLog << warn << " set theta, phi = " << thetadeg << ", "
533 << phideg << " deg" << endl;
534
535
536 return kTRUE;
537}
538
539// --------------------------------------------------------------------------
540//
541//
542Int_t MSourcePosfromStarPos::Process()
543{
544 //Int_t run = fRun->GetRunNumber();
545 //*fLog << "MSourcePosfromStarPos::Process; run = " << run << endl;
546
547
548 return kTRUE;
549}
550
551// --------------------------------------------------------------------------
552//
553//
554Int_t MSourcePosfromStarPos::PostProcess()
555{
556
557 return kTRUE;
558}
559
560// --------------------------------------------------------------------------
561//
562// read the data from the ASCII file and store them
563//
564void MSourcePosfromStarPos::FixSize()
565{
566 *fLog << "MSourcePosfromStarPos::FixSize; fix size of arrays : fRuns = "
567 << fRuns << ", fStars = " << fStars << endl;
568
569 fSize = fRuns;
570
571 fRunNr.Set(fSize);
572
573 fThetaTel.Set(fSize);
574 fPhiTel.Set(fSize);
575 fdThetaTel.Set(fSize);
576 fdPhiTel.Set(fSize);
577
578 Int_t fRows = fxStar.GetNrows();
579 fxStar.ResizeTo(fRows, fSize);
580 fyStar.ResizeTo(fRows, fSize);
581 fdxStar.ResizeTo(fRows, fSize);
582 fdyStar.ResizeTo(fRows, fSize);
583}
584
585// --------------------------------------------------------------------------
586//
587// read the data from the ASCII file and store them
588//
589void MSourcePosfromStarPos::ReadData()
590{
591 Float_t val;
592 Int_t ival;
593
594 // extend size of arrays if necessary
595 if ( fRuns >= (fSize-1) )
596 {
597 fSize += 100;
598
599 fRunNr.Set(fSize);
600
601 fThetaTel.Set(fSize);
602 fPhiTel.Set(fSize);
603 fdThetaTel.Set(fSize);
604 fdPhiTel.Set(fSize);
605
606 fStars = fxStar.GetNrows();
607 fxStar.ResizeTo(fStars, fSize);
608 fyStar.ResizeTo(fStars, fSize);
609 fdxStar.ResizeTo(fStars, fSize);
610 fdyStar.ResizeTo(fStars, fSize);
611 }
612
613 //-------------------
614 // read header line
615 //*fIn >> val;
616
617 //*fLog << "val =" << val << endl;
618
619 //*fIn >> val;
620 //*fIn >> val;
621 //*fIn >> val;
622 //*fIn >> val;
623 //*fIn >> val;
624 //*fIn >> val;
625 //*fIn >> val;
626 //*fIn >> val;
627 //*fIn >> val;
628 //*fIn >> val;
629 //-------------------
630
631
632 fRuns += 1;
633
634 *fIn >> ival;
635
636 //*fLog << fRuns <<"th run : " << ival << endl;
637
638 fRunNr.AddAt(ival, fRuns-1);
639
640 //*fLog << "check : fRuns, fRunNr[fRuns-1], fRunNr[fRuns] = " << fRuns << ", "
641 // << fRunNr[fRuns-1] << ", " << fRunNr[fRuns] << endl;
642
643 // read mjdS, hmsS, mjdE, hmsE
644 *fIn >> val;
645 *fIn >> val;
646 *fIn >> val;
647 *fIn >> val;
648
649 *fIn >> val;
650 *fIn >> val;
651 *fIn >> val;
652 *fIn >> val;
653
654
655 *fIn >> val;
656 fThetaTel.AddAt(val/kRad2Deg, fRuns-1);
657 //*fLog << "val, fThetaTel[fRuns-1] = " << val << ", "
658 // << fThetaTel[fRuns-1] << endl;
659
660
661 *fIn >> val;
662 fPhiTel.AddAt(val/kRad2Deg, fRuns-1);
663 //*fLog << "val, fPhiTel[fRuns-1] = " << val << ", "
664 // << fPhiTel[fRuns-1] << endl;
665
666
667 //*fIn >> val;
668 //fdThetaTel.AddAt(val/kRad2Deg, fRuns-1);
669 //*fIn >> val;
670 //fdPhiTel.AddAt(val/kRad2Deg, fRuns-1);
671
672 // input is in [deg], convert to [mm]
673 fStars = fxStar.GetNrows();
674 for (Int_t i=0; i<fStars; i++)
675 {
676 *fIn >> val;
677 fxStar(i, fRuns-1) = val / fMm2Deg;;
678 //*fLog << "val, fxStar(i, fRuns-1) = " << val << ", "
679 // << fxStar(i, fRuns-1) << endl;
680
681 *fIn >> val;
682 fyStar(i, fRuns-1) = val / fMm2Deg;
683 //*fLog << "val, fyStar(i, fRuns-1) = " << val << ", "
684 // << fyStar(i, fRuns-1) << endl;
685
686
687 *fIn >> val;
688 //*fLog << "y=dxStar = " << val << endl;
689
690 fdxStar(i, fRuns-1) = val / fMm2Deg;
691 *fIn >> val;
692 //*fLog << "y=dyStar = " << val << endl;
693
694 fdyStar(i, fRuns-1) = val / fMm2Deg;
695 }
696
697}
698
699// --------------------------------------------------------------------------
700//
701// Add this file as the last entry in the chain
702//
703Int_t MSourcePosfromStarPos::AddFile(const char *txt, Int_t)
704{
705 TNamed *name = new TNamed(txt, "");
706 fFileNames->AddLast(name);
707
708 *fLog << "MSourcePosfromStarPos::AddFile; add file '" << txt << "'"
709 << endl;
710
711 return 1;
712}
713
714// --------------------------------------------------------------------------
715//
716// This opens the next file in the list and deletes its name from the list.
717//
718Bool_t MSourcePosfromStarPos::OpenNextFile()
719{
720 //
721 // open the input stream and check if it is really open (file exists?)
722 //
723 if (fIn)
724 delete fIn;
725 fIn = NULL;
726
727 //
728 // Check for the existence of a next file to read
729 //
730 TNamed *file = (TNamed*)fFileNames->First();
731 if (!file)
732 return kFALSE;
733
734 //
735 // open the file which is the first one in the chain
736 //
737 const char *name = file->GetName();
738
739 const char *expname = gSystem->ExpandPathName(name);
740 fIn = new ifstream(expname);
741 delete [] expname;
742
743 const Bool_t noexist = !(*fIn);
744
745
746 if (noexist)
747 *fLog << dbginf << "Cannot open file '" << name << "'" << endl;
748 else
749 *fLog << "Open file: '" << name << "'" << endl;
750
751 //
752 // Remove this file from the list of pending files
753 //
754 fFileNames->Remove(file);
755
756 return !noexist;
757}
758
759// --------------------------------------------------------------------------
760
761
762
763
764
765
766
767
768
769
770
Note: See TracBrowser for help on using the repository browser.