Changeset 8989 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 07/01/08 15:04:01 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MDataSet.cc
r8895 r8989 18 18 ! Author(s): Thomas Bretz, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2004-200 720 ! Copyright: MAGIC Software Development, 2004-2008 21 21 ! 22 22 ! … … 177 177 // 178 178 // 179 // =========================================================================== 180 // 179 181 // ToDO: 180 182 // * Default paths could be moved into the global .rootrc 181 183 // 184 // =========================================================================== 185 // 186 // 187 // Class Version 3: 188 // ---------------- 189 // + fFileName 190 // + fDataSet 182 191 // 183 192 // Class Version 2: 193 // ---------------- 184 194 // + fMonteCarlo 185 195 // + fWobbleMode … … 297 307 298 308 // FIXME: The sequence number from the sequence file is assigned!!! 299 MSequence *seq = new MSequence(useds?f Name:name, dir, num[i]);309 MSequence *seq = new MSequence(useds?fFileName:name, dir, num[i]); 300 310 seq->ExcludeRuns(excl); 301 311 … … 354 364 void MDataSet::Init(const char *fname, const UInt_t num, TString sequences, TString &data) 355 365 { 366 fName = "MDataSet"; 367 fTitle = "DataSet file"; 368 356 369 // Store given file name as name 357 f Name = fname;370 fFileName = fname; 358 371 359 372 // Delete the stored Sequences automatically at destruction … … 361 374 fSequencesOff.SetOwner(); 362 375 376 // Expand the file name (eg $MARS or ~ are expanded) 377 gSystem->ExpandPathName(fFileName); 378 379 // Check its accessibility 380 const Bool_t access = !gSystem->AccessPathName(fFileName, kFileExists); 381 if (!access) 382 { 383 gLog << err << "ERROR - Dataset file " << fname << " not accessible!" << endl; 384 fNumAnalysis = (UInt_t)-1; 385 return; 386 } 387 363 388 // Determin the prefix to access this resource 364 389 const TString prefix = num==(UInt_t)-1 ? "" : Form("%d", num); 365 390 366 // Expand the file name (eg $MARS or ~ are expanded)367 TString expname(fname);368 gSystem->ExpandPathName(expname);369 370 // Check its accessibility371 const Bool_t access = !gSystem->AccessPathName(expname, kFileExists);372 if (!access)373 gLog << err << "ERROR - Dataset file " << expname << " not accessible!" << endl;374 375 391 // Open and read the file 376 MEnv env( expname);392 MEnv env(fFileName); 377 393 378 394 // Get analysis number and name 379 395 fNumAnalysis = GetEnvValue2(env, prefix, "AnalysisNumber", (Int_t)num); 380 f Title = GetEnvValue2(env, prefix, "Name", expname);396 fDataSet = GetEnvValue2(env, prefix, "Name", GetBaseName()); 381 397 382 398 // Get sequences from file … … 443 459 //--------------------------------------------------------------------------- 444 460 // 445 // Make sure that the name used for writing doesn't contain a full path 446 // 447 const char *MDataSet::GetName() const 448 { 449 const char *pos = strrchr(GetRcName(), '/'); 450 return pos>0 ? pos+1 : GetRcName(); 461 // Return the name of the file 462 // 463 const char *MDataSet::GetBaseName() const 464 { 465 return gSystem->BaseName(fFileName); 466 } 467 468 //--------------------------------------------------------------------------- 469 // 470 // Return the directory of the file 471 // 472 const char *MDataSet::GetFilePath() const 473 { 474 return gSystem->DirName(fFileName); 451 475 } 452 476 … … 456 480 // Return '+' if both can be accessed, '-' otherwise. 457 481 // 458 void MDataSet::PrintFile( const MSequence &seq)482 void MDataSet::PrintFile(ostream &out, const MSequence &seq) 459 483 { 460 484 const Char_t access = … … 462 486 !gSystem->AccessPathName(seq.GetDataPath(), kFileExists) ? '+' : '-'; 463 487 464 gLog<< "# " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl;488 out << "# " << access << " " << seq.GetFileName() << " <" << seq.GetDataPath() << ">" << endl; 465 489 } 466 490 … … 469 493 // Helper to print a seqeunce in Print() 470 494 // 471 void MDataSet::PrintSeq( const MSequence &seq) const472 { 473 const Bool_t useds = seq.GetFileName()==f Name;474 475 gLog<< "Sequence" << Form("%08d", seq.GetSequence()) << ".File: " << (useds?"-":seq.GetFileName()) << endl;476 gLog<< "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir: " << seq.GetDataPath() << endl;495 void MDataSet::PrintSeq(ostream &out, const MSequence &seq) const 496 { 497 const Bool_t useds = seq.GetFileName()==fFileName; 498 499 out << "Sequence" << Form("%08d", seq.GetSequence()) << ".File: " << (useds?"-":seq.GetFileName()) << endl; 500 out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Dir: " << seq.GetDataPath() << endl; 477 501 if (!useds && seq.GetNumExclRuns()>0) 478 gLog<< "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl;502 out << "Sequence" << Form("%08d", seq.GetSequence()) << ".Exclude: " << seq.GetExcludedRuns() << endl; 479 503 480 504 if (useds) 481 505 { 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 // 493 void MDataSet::Print(Option_t *o) const 494 { 495 gLog << all; 506 out << endl; 507 seq.Print(out, "prefixed"); 508 out << endl << "# ---" << endl; 509 } 510 } 511 512 // -------------------------------------------------------------------------- 513 // 514 // Print the contents of the dataset to the ostream out 515 // 516 void MDataSet::Print(ostream &out, Option_t *o) const 517 { 496 518 if (!IsValid()) 497 519 { 498 gLog << "Dataset: " << fName << " <invalid - no analysis number available>" << endl;520 out << "Dataset: " << fFileName << " <invalid - no analysis number available>" << endl; 499 521 return; 500 522 } 501 gLog << "# Path: " << GetRcName() << endl;502 gLog << "# Name: " << GetName() << endl;503 gLog<< endl;504 gLog<< "AnalysisNumber: " << fNumAnalysis << endl << endl;505 506 if (!f Title.IsNull())507 gLog << "Name: " << fTitle<< endl << endl;508 509 gLog<< "SequencesOn: ";523 out << "# Path: " << GetFilePath() << endl; 524 out << "# Name: " << GetBaseName() << endl; 525 out << endl; 526 out << "AnalysisNumber: " << fNumAnalysis << endl << endl; 527 528 if (!fDataSet.IsNull()) 529 out << "Name: " << fDataSet << endl << endl; 530 531 out << "SequencesOn: "; 510 532 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; 533 out << " " << fNumSequencesOn[i]; 534 out << endl; 535 if (fNumSequencesOff.GetSize()>0) 536 { 537 out << "SequencesOff: "; 538 for (int i=0; i<fNumSequencesOff.GetSize(); i++) 539 out << " " << fNumSequencesOff[i]; 540 out << endl; 541 } 542 543 out << endl; 544 if (!fNameSource.IsNull()) 545 out << "SourceName: " << fNameSource << endl; 546 out << "Catalog: " << fCatalog << endl; 547 548 out << "WobbleMode: " << (fWobbleMode?"Yes":"No") << endl << endl; 549 out << "MonteCarlo: " << (fMonteCarlo?"Yes":"No") << endl << endl; 550 551 if (!fComment.IsNull()) 552 out << "Comment: " << fComment << endl; 525 553 526 554 if (fSequencesOn.GetEntries()>0) 527 gLog<< endl;555 out << endl; 528 556 529 557 // FIXME: If file==fName --> print Sequence0000.content … … 533 561 MSequence *seq=0; 534 562 while ((seq=(MSequence*)NextOn())) 535 PrintSeq( *seq);563 PrintSeq(out, *seq); 536 564 if (fSequencesOff.GetEntries()>0) 537 gLog<< endl;565 out << endl; 538 566 while ((seq=(MSequence*)NextOff())) 539 PrintSeq( *seq);567 PrintSeq(out, *seq); 540 568 541 569 if (TString(o).Contains("files", TString::kIgnoreCase)) 542 570 { 543 gLog<< endl;544 gLog<< "# On-Data Files:" << endl;571 out << endl; 572 out << "# On-Data Files:" << endl; 545 573 NextOn.Reset(); 546 574 while ((seq=(MSequence*)NextOn())) 547 PrintFile( *seq);548 549 gLog<< endl;550 gLog<< "# Off-Data Files:" << endl;575 PrintFile(out, *seq); 576 577 out << endl; 578 out << "# Off-Data Files:" << endl; 551 579 NextOff.Reset(); 552 580 while ((seq=(MSequence*)NextOff())) 553 PrintFile( *seq);581 PrintFile(out, *seq); 554 582 555 583 return; 556 584 } 585 } 586 587 // -------------------------------------------------------------------------- 588 // 589 // Print the contents of the dataset to the gLog stream 590 // 591 void MDataSet::Print(Option_t *o) const 592 { 593 gLog << all; 594 Print(gLog, o); 595 } 596 597 // -------------------------------------------------------------------------- 598 // 599 // Print the contents of the dataset to the file with name filename 600 // 601 void MDataSet::WriteFile(const char *name, const Option_t *o) const 602 { 603 ofstream fout(name); 604 if (!fout) 605 { 606 gLog << err << "Cannot open file " << name << ": "; 607 gLog << strerror(errno) << endl; 608 return; 609 } 610 611 Print(fout, o); 557 612 } 558 613 … … 755 810 } 756 811 812 /* 757 813 // -------------------------------------------------------------------------- 758 814 // … … 786 842 } 787 843 } 844 */ -
trunk/MagicSoft/Mars/mjobs/MDataSet.h
r8888 r8989 21 21 private: 22 22 static const TString fgCatalog; //! Default Catalog path 23 24 TString fFileName; // File name to original file (MParContainer::fName is not streamed) 25 TString fDataSet; // Name of the dataset given by the user 23 26 24 27 UInt_t fNumAnalysis; // Analysis number (artificial) … … 45 48 void ResolveSequences(const TEnv &env, const TString &prefix, const TArrayI &num, TList &list/*, const TString &sequences, const TString &data*/) const; 46 49 Bool_t GetWobbleMode(const TEnv &env, const TString &prefix) const; 47 static void PrintFile( const MSequence &obj);48 void PrintSeq( const MSequence &seq) const;50 static void PrintFile(ostream &out, const MSequence &obj); 51 void PrintSeq(ostream &out, const MSequence &seq) const; 49 52 50 53 // Directory and file handling 51 void ReplaceDir(TList &list, const TString &old, const TString &news) const;52 void ReplaceFile(TList &list, const TString &old, const TString &news) const;54 //void ReplaceDir(TList &list, const TString &old, const TString &news) const; 55 //void ReplaceFile(TList &list, const TString &old, const TString &news) const; 53 56 54 57 void SetupDefaultPath(TString &path, const TString &def) const … … 72 75 73 76 public: 74 MDataSet() : fNumAnalysis((UInt_t)-1) { } 77 MDataSet() : fNumAnalysis((UInt_t)-1) 78 { 79 fName = "MDataSet"; 80 fTitle = "DataSet file"; 81 } 75 82 MDataSet(const char *fname, TString sequences="", TString data=""); 76 83 MDataSet(const char *fname, Int_t num, TString sequences="", TString data=""); 77 84 78 const char *GetName() const; 79 const char *GetRcName() const { return fName; } 85 const char *GetBaseName() const; 86 const char *GetFilePath() const; 87 const TString &GetFileName() const { return fFileName; } 88 const TString &GetDataSet() const { return fDataSet; } 80 89 81 90 void Copy(TObject &obj) const … … 154 163 Bool_t AddFilesOff(MDirIter &iter) const; 155 164 165 /* 156 166 void ReplaceDir(const TString &old, const TString &news) 157 167 { … … 165 175 ReplaceFile(fSequencesOff, old, news); 166 176 } 177 */ 178 179 // I/O 180 void WriteFile(const char *filename, const Option_t *o) const; 181 void WriteFile(const char *filename) const { WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName} 167 182 168 183 // TObject 184 void Print(ostream &out, Option_t *o) const; 169 185 void Print(Option_t *o) const; 170 186 void Print() const { Print(""); } //*MENU* 171 187 172 ClassDef(MDataSet, 2)188 ClassDef(MDataSet, 3) 173 189 }; 174 190 -
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r8907 r8989 18 18 ! Author(s): Thomas Bretz, 1/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 720 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 461 461 *fLog << inf; 462 462 fLog->Separator(GetDescriptor()); 463 *fLog << "Filling MHSrcPosCam " << set.Get Name() << endl;463 *fLog << "Filling MHSrcPosCam " << set.GetBaseName() << endl; 464 464 *fLog << endl; 465 465 … … 591 591 *fLog << inf; 592 592 fLog->Separator(GetDescriptor()); 593 *fLog << "Perform cuts for data set " << set.Get Name() << endl;593 *fLog << "Perform cuts for data set " << set.GetBaseName() << endl; 594 594 *fLog << endl; 595 595 … … 693 693 TString fname0(path); 694 694 TString fname1(path); 695 fname0 += fNameSummary.IsNull() ? (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary; 696 fname1 += fNameResult.IsNull() ? (TString) Form("ganymed%08d.root", set.GetNumAnalysis()) : fNameResult; 697 698 MWriteRootFile *write0 = CanStoreSummary() ? new MWriteRootFile(fPathOut.IsNull()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW") : 0; 699 MWriteRootFile *write1 = CanStoreResult() ? new MWriteRootFile(fPathOut.IsNull()?0:fname1.Data(), fOverwrite?"RECREATE":"NEW") : 0; 695 fname0 += fNameSummary.IsNull() ? (TString) Form("ganymed%08d-summary.root", set.GetNumAnalysis()) : fNameSummary; 696 fname1 += fNameResult.IsNull() ? (TString) Form("ganymed%08d.root", set.GetNumAnalysis()) : fNameResult; 697 698 MWriteRootFile dummy0(fPathOut.IsNull()||!CanStoreSummary()?0:fname0.Data(), fOverwrite?"RECREATE":"NEW"); 699 MWriteRootFile dummy1(fPathOut.IsNull()||!CanStoreResult() ?0:fname1.Data(), fOverwrite?"RECREATE":"NEW"); 700 701 MWriteRootFile *write0 = CanStoreSummary() ? &dummy0 : 0; 702 MWriteRootFile *write1 = CanStoreResult() ? &dummy1 : 0; 700 703 SetupWriter(write0, "WriteAfterCut0"); 701 704 SetupWriter(write1, "WriteAfterCut3"); … … 1046 1049 } 1047 1050 1048 if (write0)1049 delete write0;1050 if (write1)1051 delete write1;1052 1053 1051 // FIXME: Perform fit and plot energy dependant alpha plots 1054 1052 // and fit result to new tabs! -
trunk/MagicSoft/Mars/mjobs/MJSpectrum.cc
r8985 r8989 18 18 ! Author(s): Thomas Bretz, 4/2005 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 720 ! Copyright: MAGIC Software Development, 2000-2008 21 21 ! 22 22 ! … … 311 311 312 312 TH1D *time = (TH1D*)arr.FindObjectInCanvas("ExcessTime", "TH1D", "Hist"); 313 if (! size)313 if (!time) 314 314 { 315 315 *fLog << err; … … 690 690 Bool_t MJSpectrum::Refill(MParList &plist, TH1D &h2)/*const*/ 691 691 { 692 // Try to find the class used to determin the signal!692 // Try to find the class used to determine the signal! 693 693 TString cls("MHAlpha"); 694 694 if (fDisplay) … … 1498 1498 *fLog << inf; 1499 1499 fLog->Separator(GetDescriptor()); 1500 *fLog << "Compile Monte Carlo sample (dataset " << set.Get Name() << ")" << endl;1500 *fLog << "Compile Monte Carlo sample (dataset " << set.GetBaseName() << ")" << endl; 1501 1501 *fLog << endl; 1502 1502 … … 1539 1539 if (ontime<0) 1540 1540 { 1541 *fLog << err << GetDescriptor() << ": Could not determin effective on time..." << endl;1541 *fLog << err << GetDescriptor() << ": Could not determine effective on time..." << endl; 1542 1542 return kFALSE; 1543 1543 } … … 1605 1605 // -------------- Fill excess events versus energy --------------- 1606 1606 1607 // Refill excess histogram to determin the excess events1607 // Refill excess histogram to determine the excess events 1608 1608 TH1D excess; 1609 1609 if (!Refill(plist, excess)) … … 1877 1877 return kTRUE; 1878 1878 1879 TNamed ganame("ganymed.root", gSystem->BaseName(fPathIn));1879 TNamed ganame("ganymed.root", fPathIn.Data()); 1880 1880 1881 1881 // Write the output -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r8969 r8989 141 141 // seq.SetupPedRuns(iter, "/mypath", "[DPC]"); 142 142 // 143 // 143 144 // =========================================================================== 144 145 // 146 // ToDO: 147 // * Default paths could be moved into the global .rootrc 148 // 149 // =========================================================================== 150 // 151 // 145 152 // Class Version 2: 153 // ---------------- 146 154 // + fMonteCarlo 147 155 // 148 156 // Class Version 3: 157 // ---------------- 149 158 // + fComment 150 159 // 151 160 // Class Version 4: 161 // ---------------- 152 162 // + fExclRuns 153 163 // 154 164 // Class Version 5: 165 // ---------------- 155 166 // + fRunsSub 156 167 // + fDatRunsSub … … 163 174 164 175 #include <stdlib.h> 176 #include <errno.h> 177 178 #include <fstream> 165 179 166 180 #include <TEnv.h> … … 538 552 *fLog << err; 539 553 *fLog << "ERROR - No input files for sequence #" << GetSequence() << endl; 540 *fLog << " read from " << Get Name() << endl;554 *fLog << " read from " << GetBaseName() << endl; 541 555 *fLog << " found in" << (def?" default-path ":" ") << d << endl; 542 556 return 0; … … 550 564 *fLog << " " << (def?" default-path ":" ") << d << endl; 551 565 *fLog << " but " << n2 << " files were defined in sequence file" << endl; 552 *fLog << " " << Get Name() << endl;566 *fLog << " " << GetBaseName() << endl; 553 567 if (fLog->GetDebugLevel()<=4) 554 568 return 0; … … 580 594 581 595 gLog << warn; 582 gLog << "WARNING - in " << fFileName<< ":" << endl;596 gLog << "WARNING - in " << GetBaseName() << ":" << endl; 583 597 gLog << " LightCondition-tag is '" << str << "' but must be n/a, no_moon, twilight, moon or day." << endl; 584 598 return kNA; … … 591 605 MSequence::MSequence(const char *fname, const char *path, UInt_t seq) 592 606 { 593 fName = fname;594 fTitle = path;607 fName = "MSequence"; 608 fTitle = "Sequence file"; 595 609 596 610 fFileName = fname; 597 611 fDataPath = path; 598 612 599 gSystem->ExpandPathName(f Name);600 gSystem->ExpandPathName(f Title);601 602 const Bool_t rc1 = gSystem->AccessPathName(f Name, kFileExists);603 const Bool_t rc2 = !f Title.IsNull() && gSystem->AccessPathName(fTitle, kFileExists);613 gSystem->ExpandPathName(fFileName); 614 gSystem->ExpandPathName(fDataPath); 615 616 const Bool_t rc1 = gSystem->AccessPathName(fFileName, kFileExists); 617 const Bool_t rc2 = !fDataPath.IsNull() && gSystem->AccessPathName(fDataPath, kFileExists); 604 618 605 619 if (rc1) 606 gLog << err << "ERROR - Sequence file '" << f Name << "' doesn't exist." << endl;620 gLog << err << "ERROR - Sequence file '" << fname << "' doesn't exist." << endl; 607 621 if (rc2) 608 gLog << err << "ERROR - Directory '" << fTitle<< "' doesn't exist." << endl;609 610 MEnv env(f Name);622 gLog << err << "ERROR - Directory '" << path << "' doesn't exist." << endl; 623 624 MEnv env(fFileName); 611 625 612 626 fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq); … … 659 673 // Make sure that the name used for writing doesn't contain a full path 660 674 // 661 const char *MSequence::GetName() const 662 { 663 const char *pos = strrchr(GetRcName(), '/'); 664 return pos>0 ? pos+1 : GetRcName(); 675 const char *MSequence::GetBaseName() const 676 { 677 return gSystem->BaseName(fFileName); 678 } 679 680 //--------------------------------------------------------------------------- 681 // 682 // Make sure that the name used for writing doesn't contain a full path 683 // 684 const char *MSequence::GetFilePath() const 685 { 686 return gSystem->DirName(fFileName); 665 687 } 666 688 … … 752 774 // simplyfing the file setup 753 775 // 754 TString MSequence::PrintRuns( const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const776 TString MSequence::PrintRuns(ostream &out, const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const 755 777 { 756 778 if (r.GetSize()==0) 757 779 return ""; 758 780 759 gLog<< pre << name;781 out << pre << name; 760 782 if (f.GetSize()==0) 761 783 const_cast<TArrayI&>(f).Set(r.GetSize()); … … 763 785 #ifdef DEBUG 764 786 for (int i=0; i<r.GetSize(); i++) 765 gLog<< " " << r[i] << "." << f[i];766 gLog<< endl;787 out << " " << r[i] << "." << f[i]; 788 out << endl; 767 789 return ""; 768 790 #endif … … 776 798 if (!rc.IsNull()) 777 799 { 778 gLog<< rc;800 out << rc; 779 801 continue; 780 802 } … … 788 810 if (n==1) 789 811 { 790 gLog<< " " << r[pos];812 out << " " << r[pos]; 791 813 if (f[pos]>0) 792 gLog<< "." << f[pos];814 out << "." << f[pos]; 793 815 } 794 816 else … … 802 824 if (isseq) 803 825 { 804 gLog<< " " << r[pos] << ".";826 out << " " << r[pos] << "."; 805 827 if (f[pos]!=0) 806 gLog<< f[pos];807 gLog<< ":" << f[pos+n-1];828 out << f[pos]; 829 out << ":" << f[pos+n-1]; 808 830 } 809 831 else 810 832 { 811 gLog<< " " << r[pos] << "+";833 out << " " << r[pos] << "+"; 812 834 813 835 str += '\n'; … … 821 843 } 822 844 823 gLog<< endl;845 out << endl; 824 846 825 847 return str; … … 830 852 // Print the numbers in the classical way (one run after the other) 831 853 // 832 void MSequence::PrintRunsClassic( const char *pre, const char *name, const TArrayI &r) const833 { 834 gLog<< pre << name;854 void MSequence::PrintRunsClassic(ostream &out, const char *pre, const char *name, const TArrayI &r) const 855 { 856 out << pre << name; 835 857 for (int i=0; i<r.GetSize(); i++) 836 gLog<< " " << r[i];837 gLog<< endl;858 out << " " << r[i]; 859 out << endl; 838 860 } 839 861 … … 842 864 // Print the contents of the sequence 843 865 // 844 void MSequence::Print( Option_t *o) const866 void MSequence::Print(ostream &out, Option_t *o) const 845 867 { 846 868 const TString opt(o); … … 848 870 const TString pre = opt.Contains("prefixed") ? Form("Sequence%08d.", fSequence) : ""; 849 871 850 gLog << all;851 872 if (!IsValid()) 852 873 { 853 gLog<< pre << "Sequence: " << fFileName << " <invalid>" << endl;874 out << pre << "Sequence: " << fFileName << " <invalid>" << endl; 854 875 return; 855 876 } 856 gLog << "# Path: " << GetRcName() << endl;857 gLog << "# Name: " << GetName() << endl;858 gLog<< endl;877 out << "# Path: " << GetFileName() << endl; 878 out << "# Name: " << GetBaseName() << endl; 879 out << endl; 859 880 if (pre.IsNull()) 860 gLog<< "Sequence: " << fSequence << endl;881 out << "Sequence: " << fSequence << endl; 861 882 if (fMonteCarlo) 862 gLog << pre << "MonteCarlo: Yes" << endl; 863 gLog << pre <<"Period: " << fPeriod << endl; 864 gLog << pre << "Night: " << fNight << endl << endl; 865 gLog << pre << "LightCondition: "; 883 out << pre << "MonteCarlo: Yes" << endl; 884 if (fPeriod>=0) 885 out << pre << "Period: " << fPeriod << endl; 886 if (fNight!=MTime()) 887 out << pre << "Night: " << fNight << endl; 888 out << endl; 889 out << pre << "LightCondition: "; 866 890 switch (fLightCondition) 867 891 { 868 case kNA: gLog << "n/a" << endl; break; 869 case kNoMoon: gLog << "NoMoon" << endl; break; 870 case kTwilight: gLog << "Twilight" << endl; break; 871 case kMoon: gLog << "Moon" << endl; break; 872 case kDay: gLog << "Day" << endl; break; 873 } 874 gLog << pre << "Start: " << fStart << endl; 875 gLog << pre << "LastRun: " << fLastRun << endl; 876 gLog << pre << "NumEvents: " << fNumEvents << endl; 877 gLog << pre << "Project: " << fProject << endl; 878 gLog << pre << "Source: " << fSource << endl; 879 gLog << pre << "TriggerTable: " << fTriggerTable << endl; 880 gLog << pre << "HvSettings: " << fHvSettings << endl << endl; 892 case kNA: out << "n/a" << endl; break; 893 case kNoMoon: out << "NoMoon" << endl; break; 894 case kTwilight: out << "Twilight" << endl; break; 895 case kMoon: out << "Moon" << endl; break; 896 case kDay: out << "Day" << endl; break; 897 } 898 899 if (fStart!=MTime()) 900 out << pre << "Start: " << fStart << endl; 901 if (fLastRun>=0) 902 out << pre << "LastRun: " << fLastRun << endl; 903 if (fNumEvents>=0) 904 out << pre << "NumEvents: " << fNumEvents << endl; 905 if (!fProject.IsNull()) 906 out << pre << "Project: " << fProject << endl; 907 if (!fSource.IsNull()) 908 out << pre << "Source: " << fSource << endl; 909 if (!fTriggerTable.IsNull()) 910 out << pre << "TriggerTable: " << fTriggerTable << endl; 911 if (!fHvSettings.IsNull()) 912 out << pre << "HvSettings: " << fHvSettings << endl; 913 out << endl; 881 914 882 915 TString str; 883 916 if (!HasSubRuns() && opt.Contains("classic")) 884 917 { 885 PrintRunsClassic( pre, "Runs: ", fRuns);886 PrintRunsClassic( pre, "CalRuns: ", fCalRuns);887 PrintRunsClassic( pre, "PedRuns: ", fPedRuns);888 PrintRunsClassic( pre, "DataRuns: ", fDatRuns);889 PrintRunsClassic( pre, "Exclude: ", fExclRuns);918 PrintRunsClassic(out, pre, "Runs: ", fRuns); 919 PrintRunsClassic(out, pre, "CalRuns: ", fCalRuns); 920 PrintRunsClassic(out, pre, "PedRuns: ", fPedRuns); 921 PrintRunsClassic(out, pre, "DataRuns: ", fDatRuns); 922 PrintRunsClassic(out, pre, "Exclude: ", fExclRuns); 890 923 } 891 924 else 892 925 { 893 str += PrintRuns( pre, "Runs: ", fRuns, fRunsSub);894 str += PrintRuns( pre, "CalRuns: ", fCalRuns, fCalRunsSub);895 str += PrintRuns( pre, "PedRuns: ", fPedRuns, fPedRunsSub);896 str += PrintRuns( pre, "DataRuns: ", fDatRuns, fDatRunsSub);897 str += PrintRuns( pre, "Exclude: ", fExclRuns, fExclRunsSub);926 str += PrintRuns(out, pre, "Runs: ", fRuns, fRunsSub); 927 str += PrintRuns(out, pre, "CalRuns: ", fCalRuns, fCalRunsSub); 928 str += PrintRuns(out, pre, "PedRuns: ", fPedRuns, fPedRunsSub); 929 str += PrintRuns(out, pre, "DataRuns: ", fDatRuns, fDatRunsSub); 930 str += PrintRuns(out, pre, "Exclude: ", fExclRuns, fExclRunsSub); 898 931 } 899 932 900 933 if (!fDataPath.IsNull()) 901 gLog<< endl << pre << "DataPath: " << fDataPath << endl;934 out << endl << pre << "DataPath: " << fDataPath << endl; 902 935 903 936 if (!str.IsNull()) 904 gLog << str << endl; 905 906 gLog << endl << pre << "Comment: " << fComment << endl; 937 out << str << endl; 938 939 out << endl; 940 941 if (!fComment.IsNull()) 942 out << pre << "Comment: " << fComment << endl; 943 } 944 945 // -------------------------------------------------------------------------- 946 // 947 // Print the contents of the sequence to gLog 948 // 949 void MSequence::Print(Option_t *o) const 950 { 951 gLog << all; 952 Print(gLog, o); 953 } 954 955 // -------------------------------------------------------------------------- 956 // 957 // Print the contents of the sequence to the file with name filename 958 // 959 void MSequence::WriteFile(const char *name, const Option_t *o) const 960 { 961 ofstream fout(name); 962 if (!fout) 963 { 964 gLog << err << "Cannot open file " << name << ": "; 965 gLog << strerror(errno) << endl; 966 return; 967 } 968 969 Print(fout, o); 907 970 } 908 971 -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r8969 r8989 22 22 }; 23 23 private: 24 TString fFileName; 25 TString fDataPath; 24 TString fFileName; // Expanded file name 25 TString fDataPath; // Path to data files 26 26 27 UInt_t fSequence; 27 UInt_t fSequence; // Sequence number 28 28 29 MTime fStart; 29 MTime fStart; // Start time of sequence 30 30 31 UInt_t fLastRun; 32 UInt_t fNumEvents; 31 UInt_t fLastRun; // Last run in sequence (necessary?) 32 UInt_t fNumEvents; // Number of events in sequence 33 33 34 UInt_t fPeriod; 35 MTime fNight; 34 UInt_t fPeriod; // Observation period of the sequence 35 MTime fNight; // Night (day of sunrise) of the sequence 36 36 37 37 LightCondition_t fLightCondition; … … 43 43 TString fComment; 44 44 45 TArrayI fRuns; 46 TArrayI fRunsSub; 45 TArrayI fRuns; // Run numbers 46 TArrayI fRunsSub; // Sub runs (files) 47 47 48 TArrayI fCalRuns; 49 TArrayI fCalRunsSub; 48 TArrayI fCalRuns; // Numbers of calibration runs/files 49 TArrayI fCalRunsSub; // Sub runs (files) of calibration runs 50 50 51 TArrayI fPedRuns; 52 TArrayI fPedRunsSub; 51 TArrayI fPedRuns; // Numbers of pedestal runs/files 52 TArrayI fPedRunsSub; // Sub runs (files) of pedestal runs 53 53 54 TArrayI fDatRuns; 55 TArrayI fDatRunsSub; 54 TArrayI fDatRuns; // Numbers of data runs/files 55 TArrayI fDatRunsSub; // Sub runs (files) of data runs 56 56 57 TArrayI fExclRuns; 58 TArrayI fExclRunsSub; 57 TArrayI fExclRuns; // Numbers of excluded runs/files 58 TArrayI fExclRunsSub; // Sub runs (files) of excluded runs 59 59 60 Bool_t fMonteCarlo; 60 Bool_t fMonteCarlo; // Flag for Monte Carlo sequences 61 61 62 62 // Helper for interpretation … … 78 78 TString GetNumSequence(Int_t &pos, const TArrayI &n, const TArrayI &f) const; 79 79 80 void PrintRunsClassic( const char *pre, const char *name, const TArrayI &r) const;81 TString PrintRuns( const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const;80 void PrintRunsClassic(ostream &out, const char *pre, const char *name, const TArrayI &r) const; 81 TString PrintRuns(ostream &out, const char *pre, const char *name, const TArrayI &r, const TArrayI &f) const; 82 82 83 83 // General helper … … 92 92 public: 93 93 MSequence() : fSequence((UInt_t)-1), fLastRun((UInt_t)-1), 94 fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) { } 94 fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fMonteCarlo(kFALSE) 95 { 96 fName = "MSequence"; 97 fTitle = "Sequence file"; 98 } 95 99 MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1); 96 MSequence(const MSequence &s) : fSequence(s.fSequence), fStart(s.fStart), 100 MSequence(const MSequence &s) : MParContainer(s), 101 fFileName(s.fFileName), fDataPath(s.fDataPath), 102 fSequence(s.fSequence), fStart(s.fStart), 97 103 fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod), 98 104 fNight(s.fNight), fProject(s.fProject), fSource(s.fSource), … … 101 107 fDatRuns(s.fDatRuns), fMonteCarlo(s.fMonteCarlo) { } 102 108 109 // I/O 110 void WriteFile(const char *filename, const Option_t *o) const; 111 void WriteFile(const char *filename) const { WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName} 112 103 113 // TObject 114 void Print(ostream &out, Option_t *o) const; 104 115 void Print(Option_t *o) const; 105 116 void Print() const { Print(""); } //*MENU* 106 107 const char *GetName() const;108 const char *GetRcName() const { return fName; }109 117 110 118 // Genaral interface … … 151 159 152 160 // Filesystem getter 161 const char *GetBaseName() const; 162 const char *GetFilePath() const; 153 163 const TString &GetFileName() const { return fFileName; } 154 164 const TString &GetDataPath() const { return fDataPath; }
Note:
See TracChangeset
for help on using the changeset viewer.