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

Last change on this file since 8988 was 8895, 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 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//
491// Print the contents of the sequence
492//
493void MDataSet::Print(Option_t *o) const
494{
495 gLog << all;
496 if (!IsValid())
497 {
498 gLog << "Dataset: " << fName << " <invalid - no analysis number available>" << endl;
499 return;
500 }
501 gLog << "# Path: " << GetRcName() << endl;
502 gLog << "# Name: " << GetName() << endl;
503 gLog << endl;
504 gLog << "AnalysisNumber: " << fNumAnalysis << endl << endl;
505
506 if (!fTitle.IsNull())
507 gLog << "Name: " << fTitle << endl << endl;
508
509 gLog << "SequencesOn: ";
510 for (int i=0; i<fNumSequencesOn.GetSize(); i++)
511 gLog << " " << fNumSequencesOn[i];
512 gLog << endl;
513 gLog << "SequencesOff: ";
514 for (int i=0; i<fNumSequencesOff.GetSize(); i++)
515 gLog << " " << fNumSequencesOff[i];
516 gLog << endl << endl;
517
518 gLog << "SourceName: " << fNameSource << endl;
519 gLog << "Catalog: " << fCatalog << endl;
520
521 gLog << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl;
522 gLog << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl;
523
524 gLog << "Comment: " << fComment << endl;
525
526 if (fSequencesOn.GetEntries()>0)
527 gLog << endl;
528
529 // FIXME: If file==fName --> print Sequence0000.content
530
531 TIter NextOn(&fSequencesOn);
532 TIter NextOff(&fSequencesOff);
533 MSequence *seq=0;
534 while ((seq=(MSequence*)NextOn()))
535 PrintSeq(*seq);
536 if (fSequencesOff.GetEntries()>0)
537 gLog << endl;
538 while ((seq=(MSequence*)NextOff()))
539 PrintSeq(*seq);
540
541 if (TString(o).Contains("files", TString::kIgnoreCase))
542 {
543 gLog << endl;
544 gLog << "# On-Data Files:" << endl;
545 NextOn.Reset();
546 while ((seq=(MSequence*)NextOn()))
547 PrintFile(*seq);
548
549 gLog << endl;
550 gLog << "# Off-Data Files:" << endl;
551 NextOff.Reset();
552 while ((seq=(MSequence*)NextOff()))
553 PrintFile(*seq);
554
555 return;
556 }
557}
558
559// --------------------------------------------------------------------------
560//
561// Adds all sequences contained in list to the MDirIter. After adding
562// everything MDirIter::Sort is called to sort all entries by name.
563//
564Bool_t MDataSet::AddSequencesFromList(const TList &list, MDirIter &files)
565{
566 TIter Next(const_cast<TList*>(&list));
567
568 MSequence *seq=0;
569 while ((seq=(MSequence*)Next()))
570 {
571 if (!seq->IsValid())
572 {
573 gLog << err;
574 gLog << "ERROR - MDataSet::AddSequencesFromList: Sequence invalid!" << endl;
575 gLog << " + File: " << seq->GetFileName() << endl;
576 gLog << " + Dir: " << seq->GetDataPath() << endl;
577 return kFALSE;
578 }
579
580 if (seq->SetupDatRuns(files, MSequence::kImages)<=0)
581 return kFALSE;
582 }
583
584 // This is important in case of synchronisation, because the
585 // files in the sequences can be interleaved (eg W1, W2)
586 // Filenames MUST begin with an appropriate string which allow
587 // to order them correctly in time!
588 // files.Sort();
589
590 if (gLog.GetDebugLevel()>4)
591 {
592 gLog << inf << "Files which are searched:" << endl;
593 files.Print();
594 }
595 return kTRUE;
596}
597
598Bool_t MDataSet::AddFilesOn(MDirIter &iter) const
599{
600 return AddSequencesFromList(fSequencesOn, iter);
601}
602
603Bool_t MDataSet::AddFilesOff(MDirIter &iter) const
604{
605 return AddSequencesFromList(fSequencesOff, iter);
606}
607
608Bool_t MDataSet::AddFiles(MDirIter &iter) const
609{
610 const Bool_t rc1 = AddFilesOff(iter);
611 const Bool_t rc2 = AddFilesOn(iter);
612 return rc1 && rc2;
613}
614
615Bool_t MDataSet::AddFilesOn(MRead &read) const
616{
617 MDirIter files;
618 if (!AddFilesOn(files))
619 return kFALSE;
620 return read.AddFiles(files)>0;
621}
622
623Bool_t MDataSet::AddFilesOff(MRead &read) const
624{
625 MDirIter files;
626 if (!AddFilesOff(files))
627 return kFALSE;
628 return read.AddFiles(files)>0;
629}
630
631Bool_t MDataSet::AddFiles(MRead &read) const
632{
633 const Bool_t rc1 = AddFilesOff(read);
634 const Bool_t rc2 = AddFilesOn(read);
635 return rc1 && rc2;
636}
637
638Int_t MDataSet::AddFilesToChain(MDirIter &files, TChain &chain)
639{
640 Int_t num=0;
641 while (1)
642 {
643 const TString fname = files.Next();
644 if (fname.IsNull())
645 break;
646
647 const Int_t n = chain.Add(fname);
648 if (n<=0)
649 return kFALSE;
650 num += n;
651 }
652 return num;
653}
654
655Bool_t MDataSet::AddFilesOn(TChain &chain) const
656{
657 MDirIter files;
658 if (!AddSequencesFromList(fSequencesOn, files))
659 return kFALSE;
660 return AddFilesToChain(files, chain)>0;
661}
662
663Bool_t MDataSet::AddFilesOff(TChain &chain) const
664{
665 MDirIter files;
666 if (!AddSequencesFromList(fSequencesOff, files))
667 return kFALSE;
668 return AddFilesToChain(files, chain)>0;
669}
670
671Bool_t MDataSet::AddFiles(TChain &read) const
672{
673 const Bool_t rc1 = AddFilesOff(read);
674 const Bool_t rc2 = AddFilesOn(read);
675 return rc1 && rc2;
676}
677
678Bool_t MDataSet::GetSourcePos(MPointingPos &pos) const
679{
680 if (!HasSource())
681 {
682 gLog << err << "ERROR - MDataSet::GetSourcePos called, but no source available." << endl;
683 return kFALSE;
684 }
685
686 TString catalog(fCatalog);
687 gSystem->ExpandPathName(catalog);
688
689 ifstream fin(catalog);
690 if (!fin)
691 {
692 gLog << err << "Cannot open file " << catalog << ": ";
693 gLog << strerror(errno) << endl;
694 return kFALSE;
695 }
696
697 TString ra, dec, epoch;
698
699 Int_t n = 0;
700 while (1)
701 {
702 TString line;
703 line.ReadLine(fin);
704 if (!fin)
705 {
706 gLog << err << "ERROR - Source '" << fNameSource << "' not found in " << catalog << "." << endl;
707 return kFALSE;
708 }
709
710 n++;
711
712 TObjArray *arr = line.Tokenize(",");
713
714 if (arr->GetEntries()<6)
715 {
716 gLog << err << "ERROR - Not enough arguments in line #" << n << " of " << catalog << endl;
717 delete arr;
718 return kFALSE;;
719 }
720
721 const TString name = (*arr)[0]->GetName();
722
723 ra = (*arr)[2]->GetName();
724 dec = (*arr)[3]->GetName();
725 epoch = (*arr)[5]->GetName();
726
727 delete arr;
728
729 if (name.Strip(TString::kBoth)==fNameSource)
730 break;
731 }
732
733 if (epoch.Strip(TString::kBoth)!=(TString)"2000")
734 {
735 gLog << err << "ERROR - Epoch not 2000... not supported." << endl;
736 return kFALSE;
737 }
738
739 Double_t r,d;
740 if (!MAstro::Coordinate2Angle(ra, r))
741 {
742 gLog << err << "ERROR - Interpreting right ascension: " << ra << endl;
743 return kFALSE;
744 }
745 if (!MAstro::Coordinate2Angle(dec, d))
746 {
747 gLog << err << "ERROR - Interpreting declination: " << dec << endl;
748 return kFALSE;
749 }
750
751 pos.SetSkyPosition(r, d);
752 pos.SetTitle(fNameSource);
753
754 return kTRUE;
755}
756
757// --------------------------------------------------------------------------
758//
759// Calls ReplaceAll(old, news) for all Dir-entries
760//
761void MDataSet::ReplaceDir(TList &list, const TString &old, const TString &news) const
762{
763 TIter Next(&list);
764 TNamed *name = 0;
765 while ((name=(TNamed*)Next()))
766 {
767 TString dir = name->GetTitle();
768 dir.ReplaceAll(old, news);
769 name->SetTitle(dir);
770 }
771}
772
773// --------------------------------------------------------------------------
774//
775// Calls ReplaceAll(old, news) for all File-entries
776//
777void MDataSet::ReplaceFile(TList &list, const TString &old, const TString &news) const
778{
779 TIter Next(&list);
780 TNamed *name = 0;
781 while ((name=(TNamed*)Next()))
782 {
783 TString file = name->GetName();
784 file.ReplaceAll(old, news);
785 name->SetName(file);
786 }
787}
Note: See TracBrowser for help on using the repository browser.