source: trunk/MagicSoft/Mars/mjobs/MDataSet.cc@ 8785

Last change on this file since 8785 was 8780, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 23.9 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!
18! Author(s): Thomas Bretz, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2004-2007
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// MDataSet
28//
29// This class describes a collection of sequences.
30//
31// Such an input file looks like:
32//
33// crab.txt:
34// ---------
35// AnalysisNumber: 1
36//
37// Name: SecondCrab
38//
39// SequencesOn: 35222 35229
40// SequencesOff: 36817
41//
42// SequencePath: /magic/sequences
43// DataPath: /magic/data/star
44//
45// Sequence00035222.File: sequences/sequence035222.txt
46// Sequence00036817.File: sequences/sequence036817.txt
47//
48// Sequence00035222.Dir: /data2/wuerzburg/Crab-Analyse/images/035222
49// Sequence00036817.Dir: /data2/wuerzburg/Crab-Analyse/images/036817
50//
51// Sequence00036817.Exclude: 36818 36819
52//
53// WobbleMode: No
54// MonteCarlo: No
55//
56// SourceName: CrabNebula
57// Catalog: /magic/datacenter/setup/magic_favorites_dc.edb
58//
59//
60// Reading the file is based on TEnv. For more details see also
61// the class reference of TEnv.
62//
63//
64// AnalysisNumber: The analysis number is an artifical number used to name
65// the output files automatically if the names are not overwritten in the
66// corresponding programs.
67//
68// SequencePath: In case it is not specified the datacenter default path is
69// used. If it is given it is the place at which the sequence files
70// are searched, if not overwritten by either a program command line
71// option (aka. a argument to the constructor) or a resource for
72// an individual sequence file. Note, that the four digits high-level
73// directories to sort the sequences are added to the given path.
74//
75// DataPath: In case it is not specified the datacenter default path is
76// used. If it is given it is the place at which the data files
77// are searched, if not overwritten by either a program command line
78// option (aka. a argument to the constructor) or a resource for
79// an individual data path. Note, that the four digits high-level
80// directories to sort the sequences are added to the given path.
81//
82// SequencesOn/Off: The sequence number are used to concatenate the filenames
83// of the sequences using the file structure used in the datacenter. Each
84// sequence can be added to the on and off data at the same time but only
85// once.
86//
87// If you have different file names you can overwrite the default file names
88// using Sequence%08d.File (make sure you have 8 digits!)
89//
90// If the file name is given as "-", e.g.
91// Sequence00035222.File: -
92// the current dataset file is read as sequence file. In this case all
93// resources defined for a sequence file should be prefixed by
94// "Sequence%08d."; if not prefixed the default without the prefix
95// is looked up. Be aware that the "Sequence" resource for sequence-files
96// (for more details see MSequence) is ignored and the already defined
97// number is used instead and thus should be identical to the sequence
98// number - which normally is not necessary.
99//
100// In standard coditions (datacenter file system) paths are concatenated
101// by using the information in the sequence files (date, etc). You can
102// overwrite the directories in which the sequence-files (eg I-files) are
103// stored using Sequence%08d.Dir (make sure you have 8 digits!)
104//
105// Using the resource Sequence%08d.Exclude you can exclude a list of
106// runs from a sequence.
107//
108// WobbleMode: This is just a flag which is passed to the program
109// end eveluated (or not) by the individual program, which takes this
110// dataset as an input. For example this is necessary in ganymed to do
111// some wobble mode special setup. If no resource is given (or it is
112// set to "auto") wobble mode if set if the datset contains no off-
113// sequences.
114//
115// MonetCarlo: This is just a flag which is passed to the program
116// end eveluated (or not) by the individual program, which takes this
117// dataset as an input. For example this tells ganymed to skip some
118// parts accessing time stamps which are not available in the MCs.
119//
120// SequencePath/DataPath: This determined were the sequences and data-files
121// are stored. The priorities are as follows:
122// 0) Build in default path: /magic/sequences /magic/data/star
123// 1) Def.path from dataset file: SequencePath DataPath
124// 2) Indiv.path from dataset file: 12345.SequencePath 12345.DataPath
125// 3) Path from command line: Argument in the constructors
126// 4) Path for an indiv. dataset: Sequences00022555.File/Dir
127//
128// Catalog: This is the xephem-style file from the central control
129// containing the observed sky positions.
130//
131// SourceName: The source name, as defined in the catalog, of the object
132// the data corresponds to.
133//
134// Name: A name is stored for your convinience
135//
136// Comment: It is just stored.
137//
138// General Remark: MDataSet doesn't implement any action on the given
139// resources. Whether a resource is used, necessary or ignored, and
140// what will happen if you change the resource is always defined by the
141// executed macro or program.
142//
143// Resource file entries are case sensitive!
144//
145//
146// Collection of datsets
147// ---------------------
148//
149// You can combine more than one datset in a file (if your program
150// supports this) Such a dataset file could look like this:
151//
152// 35222.SequencesOn: 35222
153// 35222.SequencesOff: 36817
154//
155// 65778.SequencesOn: 65778
156//
157// 12345.SequencesOn: 12345
158//
159// 12345.SequencePath: /home/nobody/specialsequences
160// 65778.DataPath: /home/nobody/specialstars
161//
162// SequencePath: /home/nobody/defaultsequences
163// DataPath: /home/nobody/defaultstars
164//
165// Sequence00035222.File: sequences/sequence035222.txt
166// Sequence00035222.Dir: /data2/wuerzburg/Crab-Analyse/images/035222
167//
168// 35222.WobbleMode: Off
169// WobbleMode: On
170//
171//
172// IMPORTANT:
173// * Run filenames must begin with a string which allows correct
174// ordering in time, otherwise synchronization might fail.
175// * Sequence filenames should also have names allowing to order them
176// in time, but it is not necessary.
177//
178//
179// ToDO:
180// * Default paths could be moved into the global .rootrc
181//
182//
183// Class Version 2:
184// + fMonteCarlo
185// + fWobbleMode
186// - fIsWobbleMode
187//
188/////////////////////////////////////////////////////////////////////////////
189#include "MDataSet.h"
190
191#include <string.h> // necessary for Fedora core 2 with kernel 2.6.9-1.667 #1 and gcc 3.4.2
192#include <errno.h> // necessary for Fedora core 2 with kernel 2.6.9-1.667 #1 and gcc 3.4.2
193
194#include <stdlib.h>
195#include <fstream>
196
197#include <TEnv.h>
198#include <TChain.h>
199#include <TRegexp.h>
200#include <TSystem.h> // TSystem::ExpandPath
201
202#include "MLog.h"
203#include "MLogManip.h"
204
205#include "MRead.h"
206#include "MJob.h"
207#include "MEnv.h"
208#include "MAstro.h"
209#include "MDirIter.h"
210#include "MSequence.h"
211#include "MPointingPos.h"
212
213ClassImp(MDataSet);
214
215using namespace std;
216
217const TString MDataSet::fgCatalog = "/magic/datacenter/setup/magic_favorites.edb";
218
219// --------------------------------------------------------------------------
220//
221// Copy the sequence numbers from the TString runs into the TArrayI data
222// Sequences which are twice in the list are only added once. In this case
223// a warning is emitted.
224//
225void MDataSet::Split(TString &runs, TArrayI &data) const
226{
227 const TRegexp regexp("[0-9]+");
228
229 data.Set(0);
230
231 runs.ReplaceAll("\t", " ");
232 runs = runs.Strip(TString::kBoth);
233
234 while (!runs.IsNull())
235 {
236 const TString num = runs(regexp);
237
238 if (num.IsNull())
239 {
240 *fLog << warn << "WARNING - Sequence is NaN (not a number): '" << runs << "'" << endl;
241 break;
242 }
243
244 const Int_t seq = atoi(num.Data());
245 const Int_t n = data.GetSize();
246
247 // skip already existing entries
248 int i;
249 for (i=0; i<n; i++)
250 if (data[i] == seq)
251 break;
252
253 if (i<n)
254 *fLog << warn << "WARNING - Sequence #" << seq << " already in list... skipped." << endl;
255 else
256 {
257 // set new entry
258 data.Set(n+1);
259 data[n] = seq;
260 }
261
262 // remove entry from string
263 runs.Remove(0, runs.First(num)+num.Length());
264 }
265
266 MJob::SortArray(data);
267}
268
269// --------------------------------------------------------------------------
270//
271// After resolving the sequence filename and directory either from the
272// default (/magic/data/sequences/0004/sequence00004000.txt) or from
273// the corresponding entries in the dataset file.
274// The entries are sorted by filename.
275//
276void MDataSet::ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list) const
277{
278 TString sequences = fPathSequences;
279 TString data = fPathDataFiles;
280
281 for (int i=0; i<num.GetSize(); i++)
282 {
283 const TString seqid = Form("Sequence%08d", num[i]);
284
285 TString name = GetEnvValue2(env, prefix, Form("%s.File", seqid.Data()), "");
286 TString dir = GetEnvValue2(env, prefix, Form("%s.Dir", seqid.Data()), "");
287 TString excl = GetEnvValue2(env, prefix, Form("%s.Exclude", seqid.Data()), "");
288
289 // Set default sequence file and dir name
290 if (name.IsNull())
291 name = Form("%s%04d/sequence%08d.txt", sequences.Data(), num[i]/10000, num[i]);
292 if (dir.IsNull())
293 dir = Form("%s%04d/%08d", data.Data(), num[i]/10000, num[i]);
294
295 // Check if sequence information is contained in Dataset file
296 const Bool_t useds = name=="-";
297
298 // FIXME: The sequence number from the sequence file is assigned!!!
299 MSequence *seq = new MSequence(useds?fName:name, dir, num[i]);
300 seq->ExcludeRuns(excl);
301
302 if (seq->IsValid() && seq->GetSequence()!=(UInt_t)num[i])
303 *fLog << warn << "WARNING - Sequence number " << num[i] << " in dataset file doesn't match sequence number " << seq->GetSequence() << " in sequence file!" << endl;
304
305 list.Add(seq);
306 }
307
308 // For the synchronization we must make sure, that all sequences are
309 // in the correct order...
310 // list.Sort();
311}
312
313Bool_t MDataSet::GetWobbleMode(const TEnv &env, const TString &prefix) const
314{
315 TString wob = GetEnvValue2(env, prefix, "WobbleMode", "auto");
316
317 wob.ToLower();
318 wob=wob.Strip(TString::kBoth);
319
320 if (wob=="auto")
321 return !HasOffSequences();
322
323 return GetEnvValue2(env, prefix, "WobbleMode", kFALSE);
324}
325
326// --------------------------------------------------------------------------
327//
328// Read a dataset from the file fname. If num is != -1 all resources are
329// prefixed with the number. This allows constrcutions like:
330//
331// 89123.SequencesOn: 1 2 3 4
332// 89130.SequencesOn: 5 6 7 8
333//
334// For one dataset:
335//
336// 89123.DataPath: /magic/data/star
337//
338// For all other datasets:
339//
340// DataPath: /magic/data/star
341//
342// For one sequence of one datasets:
343//
344// 89123.Sequence00000002.Dir: /magic/data/star
345//
346// and therefore allows storage of several datsets in one file with
347// a defaults for non specific resources.
348//
349// sequences and data are the path to the sequences (/magic/sequences)
350// and the data (/magic/data/star) respectively. Both can be overwritten
351// be a default from the dataset file or a resource for an individual
352// sequence.
353//
354void MDataSet::Init(const char *fname, const UInt_t num, TString sequences, TString &data)
355{
356 // Store given file name as name
357 fName = fname;
358
359 // Delete the stored Sequences automatically at destruction
360 fSequencesOn.SetOwner();
361 fSequencesOff.SetOwner();
362
363 // Determin the prefix to access this resource
364 const TString prefix = num==(UInt_t)-1 ? "" : Form("%d", num);
365
366 // Expand the file name (eg $MARS or ~ are expanded)
367 TString expname(fname);
368 gSystem->ExpandPathName(expname);
369
370 // Check its accessibility
371 const Bool_t access = !gSystem->AccessPathName(expname, kFileExists);
372 if (!access)
373 gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;
374
375 // Open and read the file
376 MEnv env(expname);
377
378 // Get analysis number and name
379 fNumAnalysis = GetEnvValue2(env, prefix, "AnalysisNumber", (Int_t)num);
380 fTitle = GetEnvValue2(env, prefix, "Name", expname);
381
382 // Get sequences from file
383 TString str;
384 str = GetEnvValue2(env, prefix, "SequencesOn", "");
385 Split(str, fNumSequencesOn);
386 str = GetEnvValue2(env, prefix, "SequencesOff", "");
387 Split(str, fNumSequencesOff);
388
389 // Get other resources
390 fNameSource = GetEnvValue2(env, prefix, "SourceName", "");
391 fCatalog = GetEnvValue2(env, prefix, "Catalog", fgCatalog);
392 fMonteCarlo = GetEnvValue2(env, prefix, "MonteCarlo", kFALSE);
393 fComment = GetEnvValue2(env, prefix, "Comment", "");
394
395 fWobbleMode = GetWobbleMode(env, prefix); // needs the number of off sequences
396
397 fNameSource = fNameSource.Strip(TString::kBoth);
398 fCatalog = fCatalog.Strip(TString::kBoth);
399
400 // Check for sequence and data path (GetDefPath needs the monte carlo flag)
401 const TString defpathseq = GetEnvValue2(env, prefix, "SequencePath", GetDefPathSequences());
402 const TString defpathdata = GetEnvValue2(env, prefix, "DataPath", GetDefPathDataFiles());
403
404 SetupDefaultPath(sequences, defpathseq);
405 SetupDefaultPath(data, defpathdata);
406
407 fPathSequences = sequences;
408 fPathDataFiles = data;
409
410 // Resolve sequences
411 ResolveSequences(env, prefix, fNumSequencesOn, fSequencesOn);
412 ResolveSequences(env, prefix, fNumSequencesOff, fSequencesOff);
413
414 // --- Now "touch" resources which are not yet stored in MDataSet ---
415 env.Touch("RunTime");
416
417 // --- Print "untouch" resources ---
418 if (env.GetNumUntouched()>0)
419 {
420 gLog << warn << "WARNING - At least one resource in the dataset-file has not been touched!" << endl;
421 env.PrintUntouched();
422 }
423}
424
425// --------------------------------------------------------------------------
426//
427// Constructor. See Read for more details.
428//
429MDataSet::MDataSet(const char *fname, TString sequences, TString data)
430{
431 Init(fname, (UInt_t)-1, sequences, data);
432}
433
434// --------------------------------------------------------------------------
435//
436// Constructor. See Read for more details.
437//
438MDataSet::MDataSet(const char *fname, Int_t num, TString sequences, TString data)
439{
440 Init(fname, num, sequences, data);
441}
442
443//---------------------------------------------------------------------------
444//
445// Make sure that the name used for writing doesn't contain a full path
446//
447const char *MDataSet::GetName() const
448{
449 const char *pos = strrchr(GetRcName(), '/');
450 return pos>0 ? pos+1 : GetRcName();
451}
452
453
454// --------------------------------------------------------------------------
455//
456// Return '+' if both can be accessed, '-' otherwise.
457//
458void MDataSet::PrintFile(const MSequence &seq)
459{
460 const Char_t access =
461 !gSystem->AccessPathName(seq.GetFileName(), kFileExists) &&
462 !gSystem->AccessPathName(seq.GetDataPath(), kFileExists) ? '+' : '-';
463
464 gLog << "# " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;
465}
466
467// --------------------------------------------------------------------------
468//
469// Helper to print a seqeunce in Print()
470//
471void MDataSet::PrintSeq(const MSequence &seq) const
472{
473 const Bool_t useds = seq.GetFileName()==fName;
474
475 gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".File: " << (useds?"-":seq.GetFileName()) << endl;
476 gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir: " << seq.GetDataPath() << endl;
477 if (!useds && seq.GetNumExclRuns()>0)
478 gLog << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;
479
480 if (useds)
481 {
482 gLog << endl;
483 seq.Print("prefixed");
484 gLog << endl << "# ---" << endl;
485 }
486}
487
488// --------------------------------------------------------------------------
489//
490// Print the contents of the sequence
491//
492void MDataSet::Print(Option_t *o) const
493{
494 gLog << all;
495 if (!IsValid())
496 {
497 gLog << "Dataset: " << fName << " <invalid - no analysis number available>" << endl;
498 return;
499 }
500 gLog << "# Path: " << GetRcName() << endl;
501 gLog << "# Name: " << GetName() << endl;
502 gLog << endl;
503 gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl;
504
505 if (!fTitle.IsNull())
506 gLog << "Name: " << fTitle << endl << endl;
507
508 gLog << "SequencesOn: ";
509 for (int i=0; i<fNumSequencesOn.GetSize(); i++)
510 gLog << " " << fNumSequencesOn[i];
511 gLog << endl;
512 gLog << "SequencesOff: ";
513 for (int i=0; i<fNumSequencesOff.GetSize(); i++)
514 gLog << " " << fNumSequencesOff[i];
515 gLog << endl << endl;
516
517 gLog << "SourceName: " << fNameSource << endl;
518 gLog << "Catalog: " << fCatalog << endl;
519
520 gLog << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl;
521 gLog << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl;
522
523 gLog << "Comment: " << fComment << endl;
524
525 if (fSequencesOn.GetEntries()>0)
526 gLog << endl;
527
528 // FIXME: If file==fName --> print Sequence0000.content
529
530 TIter NextOn(&fSequencesOn);
531 TIter NextOff(&fSequencesOff);
532 MSequence *seq=0;
533 while ((seq=(MSequence*)NextOn()))
534 PrintSeq(*seq);
535 if (fSequencesOff.GetEntries()>0)
536 gLog << endl;
537 while ((seq=(MSequence*)NextOff()))
538 PrintSeq(*seq);
539
540 if (TString(o).Contains("files", TString::kIgnoreCase))
541 {
542 gLog << endl;
543 gLog << "# On-Data Files:" << endl;
544 NextOn.Reset();
545 while ((seq=(MSequence*)NextOn()))
546 PrintFile(*seq);
547
548 gLog << endl;
549 gLog << "# Off-Data Files:" << endl;
550 NextOff.Reset();
551 while ((seq=(MSequence*)NextOff()))
552 PrintFile(*seq);
553
554 return;
555 }
556}
557
558// --------------------------------------------------------------------------
559//
560// Adds all sequences contained in list to the MDirIter. After adding
561// everything MDirIter::Sort is called to sort all entries by name.
562//
563Bool_t MDataSet::AddSequencesFromList(const TList &list, MDirIter &files)
564{
565 TIter Next(const_cast<TList*>(&list));
566
567 MSequence *seq=0;
568 while ((seq=(MSequence*)Next()))
569 {
570 if (!seq->IsValid())
571 {
572 gLog << err;
573 gLog << "ERROR - MDataSet::AddSequencesFromList: Sequence invalid!" << endl;
574 gLog << " + File: " << seq->GetFileName() << endl;
575 gLog << " + Dir: " << seq->GetDataPath() << endl;
576 return kFALSE;
577 }
578
579 if (seq->SetupDatRuns(files, MSequence::kImages)<=0)
580 return kFALSE;
581 }
582
583 // This is important in case of synchronisation, because the
584 // files in the sequences can be interleaved (eg W1, W2)
585 // Filenames MUST begin with an appropriate string which allow
586 // to order them correctly in time!
587 // files.Sort();
588
589 if (gLog.GetDebugLevel()>4)
590 {
591 gLog << inf << "Files which are searched:" << endl;
592 files.Print();
593 }
594 return kTRUE;
595}
596
597Bool_t MDataSet::AddFilesOn(MDirIter &iter) const
598{
599 return AddSequencesFromList(fSequencesOn, iter);
600}
601
602Bool_t MDataSet::AddFilesOff(MDirIter &iter) const
603{
604 return AddSequencesFromList(fSequencesOff, iter);
605}
606
607Bool_t MDataSet::AddFiles(MDirIter &iter) const
608{
609 const Bool_t rc1 = AddFilesOff(iter);
610 const Bool_t rc2 = AddFilesOn(iter);
611 return rc1 && rc2;
612}
613
614Bool_t MDataSet::AddFilesOn(MRead &read) const
615{
616 MDirIter files;
617 if (!AddFilesOn(files))
618 return kFALSE;
619 return read.AddFiles(files)>0;
620}
621
622Bool_t MDataSet::AddFilesOff(MRead &read) const
623{
624 MDirIter files;
625 if (!AddFilesOff(files))
626 return kFALSE;
627 return read.AddFiles(files)>0;
628}
629
630Bool_t MDataSet::AddFiles(MRead &read) const
631{
632 const Bool_t rc1 = AddFilesOff(read);
633 const Bool_t rc2 = AddFilesOn(read);
634 return rc1 && rc2;
635}
636
637Int_t MDataSet::AddFilesToChain(MDirIter &files, TChain &chain)
638{
639 Int_t num=0;
640 while (1)
641 {
642 const TString fname = files.Next();
643 if (fname.IsNull())
644 break;
645
646 const Int_t n = chain.Add(fname);
647 if (n<=0)
648 return kFALSE;
649 num += n;
650 }
651 return num;
652}
653
654Bool_t MDataSet::AddFilesOn(TChain &chain) const
655{
656 MDirIter files;
657 if (!AddSequencesFromList(fSequencesOn, files))
658 return kFALSE;
659 return AddFilesToChain(files, chain)>0;
660}
661
662Bool_t MDataSet::AddFilesOff(TChain &chain) const
663{
664 MDirIter files;
665 if (!AddSequencesFromList(fSequencesOff, files))
666 return kFALSE;
667 return AddFilesToChain(files, chain)>0;
668}
669
670Bool_t MDataSet::AddFiles(TChain &read) const
671{
672 const Bool_t rc1 = AddFilesOff(read);
673 const Bool_t rc2 = AddFilesOn(read);
674 return rc1 && rc2;
675}
676
677Bool_t MDataSet::GetSourcePos(MPointingPos &pos) const
678{
679 if (!HasSource())
680 {
681 gLog << err << "ERROR - MDataSet::GetSourcePos called, but no source available." << endl;
682 return kFALSE;
683 }
684
685 TString catalog(fCatalog);
686 gSystem->ExpandPathName(catalog);
687
688 ifstream fin(catalog);
689 if (!fin)
690 {
691 gLog << err << "Cannot open file " << catalog << ": ";
692 gLog << strerror(errno) << endl;
693 return kFALSE;
694 }
695
696 TString ra, dec, epoch;
697
698 Int_t n = 0;
699 while (1)
700 {
701 TString line;
702 line.ReadLine(fin);
703 if (!fin)
704 {
705 gLog << err << "ERROR - Source '" << fNameSource << "' not found in " << catalog << "." << endl;
706 return kFALSE;
707 }
708
709 n++;
710
711 TObjArray *arr = line.Tokenize(",");
712
713 if (arr->GetEntries()<6)
714 {
715 gLog << err << "ERROR - Not enough arguments in line #" << n << " of " << catalog << endl;
716 delete arr;
717 return kFALSE;;
718 }
719
720 const TString name = (*arr)[0]->GetName();
721
722 ra = (*arr)[2]->GetName();
723 dec = (*arr)[3]->GetName();
724 epoch = (*arr)[5]->GetName();
725
726 delete arr;
727
728 if (name.Strip(TString::kBoth)==fNameSource)
729 break;
730 }
731
732 if (epoch.Strip(TString::kBoth)!=(TString)"2000")
733 {
734 gLog << err << "ERROR - Epoch not 2000... not supported." << endl;
735 return kFALSE;
736 }
737
738 Double_t r,d;
739 if (!MAstro::Coordinate2Angle(ra, r))
740 {
741 gLog << err << "ERROR - Interpreting right ascension: " << ra << endl;
742 return kFALSE;
743 }
744 if (!MAstro::Coordinate2Angle(dec, d))
745 {
746 gLog << err << "ERROR - Interpreting declination: " << dec << endl;
747 return kFALSE;
748 }
749
750 pos.SetSkyPosition(r, d);
751 pos.SetTitle(fNameSource);
752
753 return kTRUE;
754}
755
756// --------------------------------------------------------------------------
757//
758// Calls ReplaceAll(old, news) for all Dir-entries
759//
760void MDataSet::ReplaceDir(TList &list, const TString &old, const TString &news) const
761{
762 TIter Next(&list);
763 TNamed *name = 0;
764 while ((name=(TNamed*)Next()))
765 {
766 TString dir = name->GetTitle();
767 dir.ReplaceAll(old, news);
768 name->SetTitle(dir);
769 }
770}
771
772// --------------------------------------------------------------------------
773//
774// Calls ReplaceAll(old, news) for all File-entries
775//
776void MDataSet::ReplaceFile(TList &list, const TString &old, const TString &news) const
777{
778 TIter Next(&list);
779 TNamed *name = 0;
780 while ((name=(TNamed*)Next()))
781 {
782 TString file = name->GetName();
783 file.ReplaceAll(old, news);
784 name->SetName(file);
785 }
786}
Note: See TracBrowser for help on using the repository browser.