Changeset 9019
- Timestamp:
- 07/20/08 15:53:17 (16 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9018 r9019 53 53 * mjobs/Makefile, mjobs/JobsLinkDef.h: 54 54 - added MJMerpp 55 56 * datacenter/macros/checkfileavail.C, datacenter/macros/checkstardone.C: 57 - reduced queries to a single query 58 - take sequence number as argumenet instead of filename 59 60 * datacenter/scripts/checkstardone: 61 - adapted to changes in checkstardone.C 62 63 * mjobs/MSequence.[h,cc]: 64 - a lot of rework to the file-interface 65 - included subsystem (cc) files 66 - some renaming to some functions 67 - improved the interface to the database 68 - unified the Setup*Runs into GetRuns 69 - when inflating a sequence name allow to use [tel:]squence now 70 71 * mjobs/MSequenceSQL.[h,cc]: 72 - adapted to changes in MSequence 55 73 56 74 -
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r9015 r9019 141 141 // seq.SetNight("2004-07-06"); 142 142 // seq.AddFiles(31753, 0, 120); 143 // seq. SetupRuns(iter);143 // seq.GetRuns(iter); 144 144 // seq.SetupPedRuns(iter, "/mypath", "[DPC]"); 145 145 // … … 386 386 } 387 387 388 TString MSequence::Inflate RunPath(const MTime &night, Bool_t mc)388 TString MSequence::InflateFilePath(const MTime &night, Bool_t mc) 389 389 { 390 390 TString rc = GetStandardPath(mc); … … 394 394 } 395 395 396 TString MSequence::Inflate RunPath(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type)397 { 398 return Inflate RunPath(night)+InflateRunName(night, tel, run, file, type);396 TString MSequence::InflateFilePath(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type) 397 { 398 return InflateFilePath(night)+InflateFileName(night, tel, run, file, type); 399 399 } 400 400 … … 411 411 { 412 412 d = GetStandardPath(); 413 switch (type )413 switch (type&kFileType) 414 414 { 415 case kRawDat: // rawdata 416 case kRawPed: 417 case kRawCal: 418 case kRawAll: 419 case kRootDat: // mcdata 420 case kRootPed: 421 case kRootCal: 422 case kRootAll: 415 case kRaw: // rawdata 416 case kRoot: // mcdata 423 417 d += "rawfiles/"; 418 d += fNight.GetStringFmt("%Y/%m/%d"); 419 break; 420 case kReport: 421 d += "../subsystemdata/cc/"; 424 422 d += fNight.GetStringFmt("%Y/%m/%d"); 425 423 break; … … 441 439 } 442 440 443 TString MSequence::InflateRunName(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type) 441 // -------------------------------------------------------------------------- 442 // 443 // Compile FileName according to night, tel, run, file and type. 444 // 445 TString MSequence::InflateFileName(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type) 444 446 { 445 447 const char *id="_"; 446 switch (type) 447 { 448 case kRawDat: 449 case kRootDat: 448 switch ((RunType_t)(type&kRunType)) 449 { 450 case kDat: 450 451 id = "D"; 451 452 break; 452 case kRawPed: 453 case kRootPed: 453 case kPed: 454 454 id = "P"; 455 455 break; 456 case kRawCal: 457 case kRootCal: 456 case kCal: 458 457 id = "C"; 459 458 break; 460 case kRawAll: 461 case kRootAll: 459 case kAll: 462 460 id = "[PCD]"; 463 461 break; 464 case kCalib rated:462 case kCalib: 465 463 id = "Y"; 466 464 break; 467 case kImage s:465 case kImage: 468 466 id = "I"; 469 467 break; 470 } 468 case kExcl: 469 break; 470 } 471 472 // Is report file? 473 const Bool_t isrep = type&kReport; 474 475 // Calculate limit for transition from 5-digit to 8-digit numbers 476 const Int_t limit = isrep ? 39373 : 35487; 471 477 472 478 // ------------- Create file name -------------- … … 484 490 // Changes to read the DAQ numbering format. Changes takes place 485 491 // between runs 35487 and 00035488 (2004_08_30) 486 n += Form(run> 35487? "%08d" : "%05d", run);492 n += Form(run>limit ? "%08d" : "%05d", run); 487 493 488 494 if (tel>0) … … 494 500 n += "_*"; 495 501 496 if (tel==0 )497 n += "_E";498 499 switch (type )500 { 501 case kRaw Dat:502 case kRawPed:503 case kRawCal:504 case kR awAll:505 n += ".r aw.?g?z?"; // TPRegexp: (\.gz)?502 if (tel==0 && run>=0) 503 n += isrep ? "_S" : "_E"; 504 505 switch (type&kFileType) 506 { 507 case kRaw: // MC // DATA 508 n += run<0 ? ".root" : ".raw.?g?z?"; // TPRegexp: (\.gz)? 509 break; 510 case kReport: 511 n += ".rep"; // TPRegexp: (\.gz)? 506 512 break; 507 513 default: 508 514 n += ".root"; 515 break; 509 516 } 510 517 … … 519 526 // the extension is defined by the type as well. 520 527 // 521 TString MSequence::GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type) const 522 { 523 return InflateRunName(fNight, arr[i]>999999?fTelescope:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type); 528 TString MSequence::GetFileRegexp(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type) const 529 { 530 if (i>=(UInt_t)arr.GetSize()) 531 return ""; 532 533 return InflateFileName(fNight, arr[i]>999999?fTelescope:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type); 534 } 535 536 // -------------------------------------------------------------------------- 537 // 538 // Get the filename from the dirctory and the file-regexp. 539 // return "" if file is not accessible or the regular expression is not 540 // unambiguous. 541 // 542 TString MSequence::FindFile(const TString &d, const TString &f) const 543 { 544 // Check existance and accessibility of file 545 MDirIter file(d, f, 0); 546 547 TString name = file(); 548 gSystem->ExpandPathName(name); 549 if (gSystem->AccessPathName(name, kFileExists)) 550 { 551 *fLog << err; 552 *fLog << "ERROR - File " << d << f << " not accessible!" << endl; 553 return ""; 554 } 555 if (!file().IsNull()) 556 { 557 *fLog << err; 558 *fLog << "ERROR - Searching for file " << d << f << " gave more than one result!" << endl; 559 return ""; 560 } 561 562 return name; 563 } 564 565 // -------------------------------------------------------------------------- 566 // 567 // Set the path accoring to type (if fDataPath=path=0), fDataPath 568 // (if path=0) or path. 569 // Returns accessability of the path. 570 // 571 Bool_t MSequence::FindPath(TString &path, FileType_t type) const 572 { 573 if (path.IsNull()) 574 path = fDataPath; 575 576 const Bool_t def = path.IsNull(); 577 578 path = GetPathName(path, type); 579 580 return def; 524 581 } 525 582 … … 528 585 // Add the entries from the arrays to the MDirIter 529 586 // 530 UInt_t MSequence::SetupRuns(MDirIter &iter, const TArrayI &arr, const TArrayI &sub, FileType_t type, const char *path) const 531 { 532 TString d(path); 533 if (d.IsNull()) 534 d = fDataPath; 535 536 const Bool_t def = d.IsNull(); 537 538 d = GetPathName(d, type); 587 UInt_t MSequence::GetRuns(MDirIter &iter, const TArrayI &arr, const TArrayI &sub, FileType_t type, TString path) const 588 { 589 const Bool_t def = FindPath(path, type); 539 590 540 591 // For this particular case we assume that the files are added one by … … 551 602 } 552 603 553 const TString n = GetFileName(i, arr, sub, type); 554 555 // Check existance and accessibility of file 556 MDirIter file(d, n, 0); 557 TString name = file(); 558 gSystem->ExpandPathName(name); 559 if (gSystem->AccessPathName(name, kFileExists)) 560 { 561 *fLog << err; 562 *fLog << "ERROR - File " << d << n << " not accessible!" << endl; 563 return 0; 564 } 565 if (!file().IsNull()) 566 { 567 *fLog << err; 568 *fLog << "ERROR - Searching for file " << d << n << " gave more than one result!" << endl; 569 return 0; 570 } 604 const TString n = GetFileRegexp(i, arr, sub, type); 605 606 if (FindFile(path, n).IsNull()) 607 continue; 571 608 572 609 // Add Path/File to TIter 573 iter.AddDirectory( d, n, 0);610 iter.AddDirectory(path, n, 0); 574 611 } 575 612 … … 584 621 *fLog << "ERROR - No input files for sequence #" << GetSequence() << endl; 585 622 *fLog << " read from " << GetBaseName() << endl; 586 *fLog << " found in" << (def?" default-path ":" ") << d<< endl;623 *fLog << " found in" << (def?" default-path ":" ") << path << endl; 587 624 return 0; 588 625 } … … 593 630 *fLog << err; 594 631 *fLog << "ERROR - " << n1 << " input files for sequence #" << GetSequence() << " found in" << endl; 595 *fLog << " " << (def?" default-path ":" ") << d<< endl;632 *fLog << " " << (def?" default-path ":" ") << path << endl; 596 633 *fLog << " but " << n2 << " files were defined in sequence file" << endl; 597 634 *fLog << " " << GetBaseName() << endl; … … 602 639 iter.Print(); 603 640 return 0; 641 } 642 643 // -------------------------------------------------------------------------- 644 // 645 // Returns "0" if file at i-th index is excluded. Get the access-path 646 // defined by the default or data-path (if path=0) or path. 647 // Get the full file-name by accessing the file. 648 // 649 TString MSequence::GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type, const char *path) const 650 { 651 if (IsExcluded(arr[i], sub[i])) 652 return "0"; 653 654 const TString d = FindPath(type, path); 655 const TString n = GetFileRegexp(i, arr, sub, type); 656 657 return FindFile(d, n); 658 } 659 660 // -------------------------------------------------------------------------- 661 // 662 // Return the pointers to the arrays with the runs/files depending on the 663 // given type. 664 // 665 void MSequence::GetArrays(const TArrayI* &r, const TArrayI* &f, Int_t type) const 666 { 667 switch ((RunType_t)(type&kRunType)) 668 { 669 case kPed: 670 r = &fPedRuns; 671 f = &fPedRunsSub; 672 break; 673 case kDat: 674 case kImage: 675 case kCalib: 676 r = &fDatRuns; 677 f = &fDatRunsSub; 678 break; 679 case kCal: 680 r = &fCalRuns; 681 f = &fCalRunsSub; 682 break; 683 case kExcl: 684 r = &fExclRuns; 685 f = &fExclRunsSub; 686 break; 687 case kAll: 688 r = &fRuns; 689 f = &fRunsSub; 690 break; 691 } 692 } 693 694 // -------------------------------------------------------------------------- 695 // 696 // Add runs from the sequence to MDirIter. If path==0 fDataPath is 697 // used instead. If it is also empty the standard path of the 698 // data-center is assumed. If you have the runs locally use path="." 699 // 700 // Returns the number of files added. 701 // 702 // Runs which are in fExlRuns are ignored. 703 // 704 UInt_t MSequence::GetRuns(MDirIter &iter, FileType_t type, const char *path) const 705 { 706 const TArrayI *r=0, *f=0; 707 GetArrays(r, f, type); 708 return GetRuns(iter, *r, *f, type, path); 709 } 710 711 // -------------------------------------------------------------------------- 712 // 713 // Returns the num-th entry of FileType_t as regular expression. 714 // If the file is excluded return "". 715 // To get the number of valid entries use GetNumEntries(FileType_t) 716 // 717 // e.g. 718 // if (GetNumEntries(MSequence::kDat))<5) 719 // GetFileRegexp(3, MSequence::kRawDat); 720 // 721 TString MSequence::GetFileRegexp(UInt_t num, FileType_t type) const 722 { 723 const TArrayI *r=0, *f=0; 724 GetArrays(r, f, type); 725 726 TString rc = GetFileRegexp(num, *r, *f, type); 727 rc.ReplaceAll(".", "\\."); 728 rc.ReplaceAll("*", ".*"); 729 return rc; 730 } 731 732 // -------------------------------------------------------------------------- 733 // 734 // Returns the num-th entry of FileType_t as filename. To access the 735 // path the default is used if path IsNull, path otherwise. 736 // If the file could not be accessed "" is returned, if it is 737 // excluded "0". 738 // To get the number of valid entries use GetNumEntries(FileType_t) 739 // 740 // e.g. 741 // if (GetNumEntries(MSequence::kDat))<5) 742 // GetFileName(3, MSequence::kRawDat); 743 // 744 TString MSequence::GetFileName(UInt_t num, FileType_t type, const char *path) const 745 { 746 const TArrayI *r=0, *f=0; 747 GetArrays(r, f, type); 748 return GetFileName(num, *r, *f, type, path); 749 } 750 751 // -------------------------------------------------------------------------- 752 // 753 // Returns the num-th entry of FileType_t as filename. 754 // If the file could not be accessed or excluded return "". 755 // To get the number of valid entries use GetNumEntries(RunType_t) 756 // 757 UInt_t MSequence::GetNumEntries(RunType_t type) const 758 { 759 const TArrayI *r=0, *f=0; 760 GetArrays(r, f, type); 761 return r->GetSize(); 762 } 763 764 // -------------------------------------------------------------------------- 765 // 766 // Returns the num-th entry of RunType_t as run- and file-number. 767 // Returns -1 if index is out of range, 0 if file is excluded and 768 // 1 in case of success. 769 // 770 // e.g. 771 // UInt_t run, file; 772 // GetFile(3, MSequence::kDat, run, file); 773 // 774 Int_t MSequence::GetFile(UInt_t i, RunType_t type, UInt_t &run, UInt_t &file) const 775 { 776 const TArrayI *r=0, *f=0; 777 GetArrays(r, f, type); 778 779 if (i>=(UInt_t)r->GetSize()) 780 return -1; 781 782 run = (*r)[i]; 783 file = i<(UInt_t)f->GetSize() ? (*f)[i] : 0; 784 785 if (IsExcluded(run, file)) 786 return 0; 787 788 return 1; 789 } 790 791 // -------------------------------------------------------------------------- 792 // 793 // Add a file (run/file) to the arrays defined by RunType_t 794 // 795 void MSequence::AddFile(UInt_t run, UInt_t file, RunType_t type) 796 { 797 const TArrayI *rconst=0, *fconst=0; 798 799 GetArrays(rconst, fconst, type); 800 801 TArrayI &r=*const_cast<TArrayI*>(rconst); 802 TArrayI &f=*const_cast<TArrayI*>(fconst); 803 804 AddEntry(run, file, r, f); 805 806 SortArrays(r, f); 604 807 } 605 808 … … 631 834 // -------------------------------------------------------------------------- 632 835 // 633 // Read the file fname as setup file for the sequence.634 // 635 MSequence::MSequence(const char *fname, const char *path, UInt_t seq) 636 { 637 fName = "MSequence"; 638 fTitle = "Sequence file"; 639 640 fFileName = fname; 836 // Set the path to the data. If no path is given the data-center default 837 // path is used to access the files. 838 // 839 // kTRUE is returned if the path is acessible, kFALSE otherwise. 840 // (In case of the default path kTRUE is returned in any case) 841 // 842 Bool_t MSequence::SetDataPath(const char *path) 843 { 641 844 fDataPath = path; 642 845 846 gSystem->ExpandPathName(fDataPath); 847 848 const Bool_t rc = !fDataPath.IsNull() && gSystem->AccessPathName(fDataPath, kFileExists); 849 if (rc) 850 gLog << err << "ERROR - Directory '" << path << "' doesn't exist." << endl; 851 852 return !rc; 853 } 854 855 // -------------------------------------------------------------------------- 856 // 857 // Read a sequence from a file. To set the location of the data (datapath) 858 // use SetDataPath. The sequence number given is used if no sequence 859 // number is found in the sequence file. 860 // 861 // If the file could not be found or accesed kFALSE is returned, kTRUE 862 // otherwise. 863 // 864 Bool_t MSequence::ReadFile(const char *filename, UInt_t seq) 865 { 866 fFileName = filename; 867 643 868 gSystem->ExpandPathName(fFileName); 644 gSystem->ExpandPathName(fDataPath); 645 646 const Bool_t rc1 = gSystem->AccessPathName(fFileName, kFileExists); 647 const Bool_t rc2 = !fDataPath.IsNull() && gSystem->AccessPathName(fDataPath, kFileExists); 648 649 if (rc1) 650 gLog << err << "ERROR - Sequence file '" << fname << "' doesn't exist." << endl; 651 if (rc2) 652 gLog << err << "ERROR - Directory '" << path << "' doesn't exist." << endl; 869 870 const Bool_t rc = gSystem->AccessPathName(fFileName, kFileExists); 871 if (rc) 872 gLog << err << "ERROR - Sequence file '" << filename << "' doesn't exist." << endl; 653 873 654 874 MEnv env(fFileName); 655 875 656 876 fSequence = (UInt_t)env.GetValue("Sequence", (Int_t)seq); 657 if (rc1 || rc2)658 fSequence = (UInt_t)-1;659 660 877 661 878 const TString prefix = Form("Sequence%08d", fSequence); … … 703 920 env.PrintUntouched(); 704 921 } 922 923 return !rc; 924 } 925 926 // -------------------------------------------------------------------------- 927 // 928 // Instantiate a file from either a file or the database. 929 // 930 // If not valid sequence could be created the sequence is invalidated, 931 // which can be queried with IsValid. 932 // 933 // see ReadFile, ReadDatabase and SetDataPath for more details. 934 // 935 MSequence::MSequence(const char *fname, const char *path, UInt_t seq) 936 { 937 // regular expression to distinguish beween a mysql-path and 938 // a filename from where the sequence should be retrieved 939 TPRegexp regexp("mysql://[a-zA-Z0-9]+:.+@[a-zA-Z0-9]+/[a-zA-Z0-9]+/([0-9]+:)?[0-9]+"); 940 941 const TString db = TString(fname)(regexp); 942 943 const Bool_t rc1 = db.IsNull() ? ReadFile(fname, seq) : ReadDatabase(fname, seq); 944 const Bool_t rc2 = SetDataPath(path); 945 946 fName = "MSequence"; 947 fTitle = "Sequence file"; 948 949 if (!rc1 || !rc2) 950 fSequence = (UInt_t)-1; 951 } 952 953 // -------------------------------------------------------------------------- 954 // 955 // Read a sequence from the database. Give the path to the database as: 956 // mysql://user:password@name/database 957 // In this case you MUST give a sequence number. 958 // 959 // You can code the telescope and sequence number into the path and 960 // omit the arguments: 961 // mysql://user:password@name/database/[tel:]sequence 962 // 963 // The third option is to give just the sql.rc as string in the argument. 964 // In this case you MUST give a sequence number. 965 // 966 // If the telecope number is omitted as argument, i.e. ==0, or in the 967 // database path, a sequence is read from the database if the sequence 968 // number is unambiguous. 969 // 970 // kFALSE is returned if the final sequence is invalid, kTRUE in case of 971 // success. 972 // 973 Bool_t MSequence::ReadDatabase(TString name, UInt_t seq, UShort_t tel) 974 { 975 TPRegexp regexp("([0-9]+:)?[0-9]+$"); 976 977 const TString telseq = name(regexp); 978 979 if (!telseq.IsNull()) 980 { 981 const Ssiz_t p = telseq.First(':'); 982 983 const TString strtel = p<0 ? TString("") : telseq(0, p); 984 const TString strseq = telseq(p+1, telseq.Length()); 985 986 tel = strtel.Atoi(); 987 seq = strseq.Atoi(); 988 989 name = gSystem->DirName(name); 990 } 991 992 *this = MSequenceSQL(name, seq, tel); 993 994 return IsValid(); 705 995 } 706 996 … … 715 1005 // MSequence seq(mysql, sequence, telescope); 716 1006 // 717 // For more details see MSequenceSQL. 1007 // Is the telescope number is omitted (==0) the database is checked for 1008 // an unambiguous sequence. 1009 // 1010 // For more details see ReadDatabase and MSequenceSQL. 718 1011 // 719 1012 MSequence::MSequence(const char *fname, UInt_t seq, UShort_t tel) 720 1013 { 721 *this = MSequenceSQL(fname, seq, tel); 1014 const Bool_t rc = ReadDatabase(fname, seq, tel); 1015 1016 fName = "MSequence"; 1017 fTitle = "Sequence file"; 1018 1019 if (!rc) 1020 fSequence = (UInt_t)-1; 722 1021 } 723 1022 … … 1084 1383 { 1085 1384 // FIXME: This needs more check! 1385 // FORBID the + syntax in "Runs" 1086 1386 // Could we make "Runs" an automatic summary of all runs? 1087 1387 // Should we add a check forbidding the same run in 1088 1388 // Cal/Ped/Data? What about the Exclude? 1089 str +=PrintRuns(out, pre, "Runs: ", fRuns, fRunsSub);1090 /*str +=*/PrintRuns(out, pre, "CalRuns: ", fCalRuns, fCalRunsSub);1091 /*str +=*/PrintRuns(out, pre, "PedRuns: ", fPedRuns, fPedRunsSub);1092 /*str +=*/PrintRuns(out, pre, "DataRuns: ", fDatRuns, fDatRunsSub);1093 /*str +=*/PrintRuns(out, pre, "Exclude: ", fExclRuns, fExclRunsSub);1389 /*str +=*/ PrintRuns(out, pre, "Runs: ", fRuns, fRunsSub); 1390 str += PrintRuns(out, pre, "CalRuns: ", fCalRuns, fCalRunsSub); 1391 str += PrintRuns(out, pre, "PedRuns: ", fPedRuns, fPedRunsSub); 1392 str += PrintRuns(out, pre, "DataRuns: ", fDatRuns, fDatRunsSub); 1393 str += PrintRuns(out, pre, "Exclude: ", fExclRuns, fExclRunsSub); 1094 1394 } 1095 1395 … … 1144 1444 // -------------------------------------------------------------------------- 1145 1445 // 1146 // Add all ped runs from the sequence to MDirIter.1147 // If path==0 fDataPath is used instead. If it is also empty1148 // the standard path of the data-center is assumed.1149 // If you have the runs locally use path="."1150 // Using raw=kTRUE you get correspodning raw-files setup.1151 // Return the number of files added.1152 //1153 // Runs which are in fExlRuns are ignored.1154 //1155 UInt_t MSequence::SetupPedRuns(MDirIter &iter, const char *path, Bool_t raw) const1156 {1157 return SetupRuns(iter, fPedRuns, fPedRunsSub, raw?kRawPed:kRootPed, path);1158 }1159 1160 // --------------------------------------------------------------------------1161 //1162 // Add all data runs from the sequence to MDirIter.1163 // If path==0 fDataPath is used instead. If it is also empty1164 // the standard path of the data-center is assumed.1165 // If you have the runs locally use path="."1166 // Using raw=kTRUE you get correspodning raw-files setup.1167 // Return the number of files added.1168 //1169 // Runs which are in fExlRuns are ignored.1170 //1171 UInt_t MSequence::SetupDatRuns(MDirIter &iter, const char *path, Bool_t raw) const1172 {1173 return SetupRuns(iter, fDatRuns, fDatRunsSub, raw?kRawDat:kRootDat, path);1174 }1175 1176 // --------------------------------------------------------------------------1177 //1178 // Add all runs from the sequence to MDirIter.1179 // If path==0 fDataPath is used instead. If it is also empty1180 // the standard path of the data-center is assumed.1181 // If you have the runs locally use path="."1182 // Using raw=kTRUE you get correspodning raw-files setup.1183 // Return the number of files added.1184 //1185 // Runs which are in fExlRuns are ignored.1186 //1187 UInt_t MSequence::SetupAllRuns(MDirIter &iter, const char *path, Bool_t raw) const1188 {1189 return SetupRuns(iter, fRuns, fRunsSub, raw?kRawAll:kRootAll, path);1190 }1191 1192 // --------------------------------------------------------------------------1193 //1194 // Add all calibration runs from the sequence to MDirIter.1195 // If path==0 fDataPath is used instead. If it is also empty1196 // the standard path of the data-center is assumed.1197 // If you have the runs locally use path="."1198 // Using raw=kTRUE you get correspodning raw-files setup.1199 // Return the number of files added.1200 //1201 // Runs which are in fExlRuns are ignored.1202 //1203 UInt_t MSequence::SetupCalRuns(MDirIter &iter, const char *path, Bool_t raw) const1204 {1205 return SetupRuns(iter, fCalRuns, fCalRunsSub, raw?kRawCal:kRootCal, path);1206 }1207 1208 // --------------------------------------------------------------------------1209 //1210 // Add all data runs from the sequence to MDirIter.1211 // If path==0 fDataPath is used instead. If it is also empty1212 // the standard path of the data-center is assumed.1213 // If you have the runs locally use path="."1214 // Using raw=kTRUE you get correspodning raw-files setup.1215 // Return the number of files added.1216 //1217 // Runs which are in fExlRuns are ignored.1218 //1219 UInt_t MSequence::SetupDatRuns(MDirIter &iter, FileType_t type, const char *path) const1220 {1221 return SetupRuns(iter, fDatRuns, fDatRunsSub, type, path);1222 }1223 1224 // --------------------------------------------------------------------------1225 //1226 1446 // check if the run/file is contained in the arrays. 1227 1447 // … … 1242 1462 } 1243 1463 return kFALSE; 1244 }1245 1246 // --------------------------------------------------------------------------1247 //1248 // Add a file (run/file) to the arrays defined by type (P, C, D, X)1249 //1250 void MSequence::AddFile(UInt_t run, UInt_t file, char type)1251 {1252 TArrayI *r=0, *f=0;1253 switch (type)1254 {1255 case 'P':1256 r = &fPedRuns;1257 f = &fPedRunsSub;1258 break;1259 case 'D':1260 r = &fDatRuns;1261 f = &fDatRunsSub;1262 break;1263 case 'C':1264 r = &fCalRuns;1265 f = &fCalRunsSub;1266 break;1267 case 'X':1268 r = &fExclRuns;1269 f = &fExclRunsSub;1270 break;1271 default:1272 r = &fRuns;1273 f = &fRunsSub;1274 break;1275 }1276 1277 AddEntry(run, file, *r, *f);1278 1279 SortArrays(*r, *f);1280 1464 } 1281 1465 … … 1339 1523 Bool_t MSequence::InflateSeq(TString &seq, Bool_t ismc) 1340 1524 { 1341 if (seq.IsDigit()) 1342 { 1343 const Int_t numseq = seq.Atoi(); 1344 seq = "/magic/"; 1345 if (ismc) 1525 TObjArray *arr = seq.Tokenize(':'); 1526 if (arr->GetEntries()<3) 1527 { 1528 TString num1 = (*arr)[0]->GetName(); 1529 TString num2 = arr->GetEntries()==2 ? (*arr)[1]->GetName() : ""; 1530 1531 if (num1.IsDigit() && num2.IsDigit()) 1532 { 1533 gLog << err << "ERROR - InflateSeq 'telescope:sequence' not yet implemented." << endl; 1534 delete arr; 1535 return kFALSE; 1536 } 1537 1538 if (num1.IsDigit() && num2.IsNull()) 1539 { 1540 const Int_t numseq = seq.Atoi(); 1541 seq = "/magic/"; 1542 if (ismc) 1346 1543 seq += "montecarlo/"; 1347 seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq); 1348 gLog << inf << "Inflated sequence file: " << seq << endl; 1349 } 1544 seq += Form("sequences/%04d/sequence%08d.txt", numseq/10000, numseq); 1545 gLog << inf << "Inflated sequence file: " << seq << endl; 1546 } 1547 } 1548 delete arr; 1350 1549 1351 1550 if (!gSystem->AccessPathName(seq, kFileExists)) -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r9015 r9019 15 15 { 16 16 friend class MSequenceSQL; 17 17 18 public: 18 19 enum LightCondition_t { kNA, kNoMoon, kTwilight, kMoon, kDay }; 20 21 enum FileExt_t { 22 kRaw =BIT(0), 23 kRoot =BIT(1), 24 kReport=BIT(2), 25 }; 26 enum RunType_t { 27 kPed =BIT(3), 28 kCal =BIT(4), 29 kDat =BIT(5), 30 kExcl =BIT(6), 31 kAll =kPed|kDat|kCal, 32 kImage =BIT(7), 33 kCalib =BIT(8) 34 }; 35 36 enum { kRunType = kPed|kCal|kDat|kImage|kCalib }; 37 enum { kFileType = kRaw|kRoot|kReport }; 38 19 39 enum FileType_t { 20 kRawDat, kRawPed, kRawCal, kRawAll, 21 kRootDat, kRootPed, kRootCal, kRootAll, 22 kCalibrated, kImages 40 kRawDat = kRaw |kDat, 41 kRawPed = kRaw |kPed, 42 kRawCal = kRaw |kCal, 43 kRawAll = kRaw |kAll, 44 kRootDat = kRoot |kDat, 45 kRootPed = kRoot |kPed, 46 kRootCal = kRoot |kCal, 47 kRootAll = kRoot |kAll, 48 kReportPed = kReport|kPed, 49 kReportCal = kReport|kCal, 50 kReportDat = kReport|kDat, 51 kReportAll = kReport|kAll, 52 kCalibrated = kRoot |kCalib, 53 kImages = kRoot |kImage, 23 54 }; 24 55 … … 73 104 74 105 // Helper for file setup 106 void GetArrays(const TArrayI* &r, const TArrayI* &f, Int_t type) const; 107 Bool_t FindPath(TString &path, FileType_t type) const; 108 TString FindPath(FileType_t type, TString path="") const { FindPath(path, type); return path; } 109 TString FindFile(const TString &d, const TString &f) const; 75 110 TString GetPathName(TString d, FileType_t type) const; 76 TString GetFileName(UInt_t num, const TArrayI &arr, const TArrayI &sub, FileType_t type) const; 77 UInt_t SetupRuns(MDirIter &iter, const TArrayI &arr, const TArrayI &file, FileType_t type, const char *path=0) const; 111 TString GetFileRegexp(UInt_t num, const TArrayI &arr, const TArrayI &sub, FileType_t type) const; 112 TString GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type, const char *path) const; 113 UInt_t GetRuns(MDirIter &iter, const TArrayI &arr, const TArrayI &file, FileType_t type, TString path="") const; 78 114 79 115 // Helper for Print() … … 121 157 122 158 // I/O 159 Bool_t ReadDatabase(TString sql, UInt_t seq=0, UShort_t tel=0); 160 Bool_t ReadFile(const char *filename, UInt_t id=(UInt_t)-1); 123 161 Bool_t WriteFile(const char *filename, const Option_t *o) const; 124 162 Bool_t WriteFile(const char *filename) const { return WriteFile(filename,""); } //*MENU *ARGS={filename=>fBaseName} 163 Bool_t SetDataPath(const char *path=""); 125 164 126 165 // TObject … … 138 177 void SetNight(const char*night); 139 178 140 void AddRun(UInt_t run, char type='*') { AddFile(run, 0, type); }141 void AddRuns(UInt_t run1, UInt_t run2, char type='*') { for (UInt_t i=run1; i<=run2; i++) AddFile(i, 0, type); }142 void AddFile(UInt_t run, UInt_t file, char type='*');143 void AddFiles(UInt_t run, UInt_t f1, UInt_t f2, char type='*') { for (UInt_t i=f1; i<=f2; i++) AddFile(run, i, type); }144 145 void ExcludeFile(UInt_t run, UInt_t file=0) { /*if (!force || !IsExcluded(run, file))*/ AddFile(run, file, 'X'); }179 void AddRun(UInt_t run, RunType_t type=kAll) { AddFile(run, 0, type); } 180 void AddRuns(UInt_t run1, UInt_t run2, RunType_t type=kAll) { for (UInt_t i=run1; i<=run2; i++) AddFile(i, 0, type); } 181 void AddFile(UInt_t run, UInt_t file, RunType_t type=kAll); 182 void AddFiles(UInt_t run, UInt_t f1, UInt_t f2, RunType_t type=kAll) { for (UInt_t i=f1; i<=f2; i++) AddFile(run, i, type); } 183 184 void ExcludeFile(UInt_t run, UInt_t file=0) { /*if (!force || !IsExcluded(run, file))*/ AddFile(run, file, kExcl); } 146 185 void ExcludeRuns(TString runs); 147 186 … … 157 196 Bool_t HasMoon() const { return fLightCondition==kMoon; } 158 197 198 Int_t GetFile(UInt_t i, RunType_t type, UInt_t &run, UInt_t &file) const; 199 159 200 LightCondition_t GetLightCondition() const { return fLightCondition; } 160 201 … … 166 207 167 208 // Filesystem interface 168 UInt_t SetupPedRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const; 169 UInt_t SetupDatRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const; 170 UInt_t SetupAllRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const; 171 UInt_t SetupCalRuns(MDirIter &iter, const char *path=0, Bool_t raw=kFALSE) const; 172 UInt_t SetupDatRuns(MDirIter &iter, FileType_t type, const char *path=0) const; 209 UInt_t GetRuns(MDirIter &iter, FileType_t type, const char *path=0) const; 210 TString GetFileRegexp(UInt_t num, FileType_t type) const; 211 TString GetFileName(UInt_t i, FileType_t type, const char *path=0) const; 212 UInt_t GetNumEntries(RunType_t type=kAll) const; 173 213 174 214 // Filesystem getter … … 184 224 static Bool_t InflateSeq(TString &seq, /*FIXME: TELNUM*/ Bool_t ismc=kFALSE); 185 225 186 static TString Inflate RunName(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type=kRawAll);187 static TString Inflate RunName(const MTime &night, Int_t run, Int_t type=kRawAll) { return InflateRunName(night, 1, run, 0, type); }188 189 static TString Inflate RunPath(const MTime &night, UShort_t tel, Int_t run, Int_t file=0, Int_t type=kRawAll);190 static TString Inflate RunPath(const MTime &night, Int_t run, Int_t type=kRawAll) { return InflateRunPath(night, 1, run, 0, type); }191 192 static TString Inflate RunPath(const MTime &night, Bool_t mc=kFALSE);226 static TString InflateFileName(const MTime &night, UShort_t tel, Int_t run, Int_t file, Int_t type=kRawAll); 227 static TString InflateFileName(const MTime &night, Int_t run, Int_t type=kRawAll) { return InflateFileName(night, 1, run, 0, type); } 228 229 static TString InflateFilePath(const MTime &night, UShort_t tel, Int_t run, Int_t file=0, Int_t type=kRawAll); 230 static TString InflateFilePath(const MTime &night, Int_t run, Int_t type=kRawAll) { return InflateFilePath(night, 1, run, 0, type); } 231 232 static TString InflateFilePath(const MTime &night, Bool_t mc=kFALSE); 193 233 194 234 ClassDef(MSequence, 6) // Describes a sequences, reads and writes sequence files -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc
r9015 r9019 86 86 // return kFALSE in case of error or if no events are in the files. 87 87 // 88 Bool_t MSequenceSQL::GetRuns(MSQLMagic &serv, TString query, chartype, UInt_t nevts)88 Bool_t MSequenceSQL::GetRuns(MSQLMagic &serv, TString query, RunType_t type, UInt_t nevts) 89 89 { 90 90 TSQLResult *res = serv.Query(query); … … 211 211 212 212 // get and setup runs 213 if (!GetRuns(serv, queryA ))214 return kFALSE; 215 if (!GetRuns(serv, queryC, 'C'))216 return kFALSE; 217 if (!GetRuns(serv, queryP, 'P', 1000))218 return kFALSE; 219 if (!GetRuns(serv, queryD, 'D'))213 if (!GetRuns(serv, queryA, kAll)) 214 return kFALSE; 215 if (!GetRuns(serv, queryC, kCal)) 216 return kFALSE; 217 if (!GetRuns(serv, queryP, kPed, 1000)) 218 return kFALSE; 219 if (!GetRuns(serv, queryD, kDat)) 220 220 return kFALSE; 221 221 -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.h
r9015 r9019 14 14 { 15 15 private: 16 Bool_t GetRuns(MSQLMagic &serv, TString query, char type='*', UInt_t nevts=(UInt_t)-1);16 Bool_t GetRuns(MSQLMagic &serv, TString query, RunType_t type, UInt_t nevts=(UInt_t)-1); 17 17 TString GetTimeFromDatabase(MSQLMagic &serv, const TString &query); 18 18 Bool_t GetFromDatabase(MSQLMagic &serv, TSQLResult &res);
Note:
See TracChangeset
for help on using the changeset viewer.