- Timestamp:
- 01/10/06 13:44:29 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
r7395 r7459 30 30 // 31 31 // to group the runs of one night into sequences, this marco: 32 // - reads the runinformation of one night from the database 33 // - group the runs into sets of following runs with the same conditions 34 // - groups the runs in this sets to sequences such that each run belongs 35 // to the nearest (in time) calibration run 36 // - check if the runs with the same runtype have the same calibration script 37 // and the same trigger tables 32 // - reads the runinformation of one night from the database 33 // - group the runs into sets of following runs with the same conditions 34 // - groups the runs in this sets to sequences such that each run belongs 35 // to the nearest (in time) calibration run 36 // - check if the runs with the same runtype have the same calibration script 37 // and the same trigger tables 38 // if sequence is okay: 39 // - check if in the range of the runnumbers of this sequence other sequences 40 // exist in the database 41 // if there are no sequences, insert the new sequence, else: 42 // - delete overlaping sequences 43 // if there's only one sequence in the same runnumber range: 44 // - check if the new and the old sequence are identical 45 // if they are identical, do nothing, if not, delete the old sequence and 46 // insert the new one 47 // 48 // remark: deleting sequences includes the following steps: 49 // - delete entries from the tables Sequences, SequenceProcessStatus, 50 // Calibration and Star 51 // - updating the sequence number (fSequenceFirst) in the table RunData 52 // - remove the Sequence File, the calibrated data and the image files from 53 // the disk 54 // 55 // the macro can be executed either for all nights or for one single night 56 // .x buildsequenceentries.C+( "datapath", "sequpath", Bool_t dummy=kTRUE) 57 // .x buildsequenceentries.C+( "night", "datapath", "sequpath") 58 // 59 // the Bool_t dummy: 60 // kTRUE: dummy-mode, i.e. nothing is inserted into the database, but the 61 // commands, that would be executed are returned 62 // kFALSE: the information is inserted into the database and the files of 63 // removed sequences is deleted 64 // be careful with this option - for tests use always kTRUE 65 // 66 // TString datapath, TString sequpath: 67 // datapath: path, where the processed data is stored in the datacenter 68 // sequpath: path, where the sequence files are stored in the datacenter 69 // the datapath (standard: /magic/data/) and the sequencepath (standard: 70 // /magic/sequences) have to be given, that the sequence file, the 71 // calibrated data and the star files can be removed, when an old sequence 72 // has to be removed from the database 73 // 74 // If nothing failes 1 is returned. In the case of an error 0 is returned. 75 // This is needed for the scripts that execute the macro. 38 76 // 39 77 ///////////////////////////////////////////////////////////////////////////// … … 63 101 Bool_t DeleteSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t sequ, Bool_t dummy) 64 102 { 103 //queries to delete information from the database 65 104 TString query1(Form("DELETE FROM Calibration WHERE fSequenceFirst=%d", sequ)); 66 105 TString query2(Form("DELETE FROM Star WHERE fSequenceFirst=%d", sequ)); … … 69 108 TString query5(Form("DELETE FROM Sequences WHERE fSequenceFirst=%d AND fManuallyChangedKEY=1", sequ)); 70 109 110 //commands to delete files from the disk 71 111 TString fname(Form("%s/%04d/sequence%08d.txt", sequpath.Data(),sequ/10000, sequ)); 72 112 TString command(Form("rm -r %s/callisto/%04d/%08d/", datapath.Data(), sequ/10000, sequ)); … … 148 188 } 149 189 190 191 //check values, that can be different for different runtypes 150 192 Bool_t CheckRuns(MSQLServer &serv, Int_t from, Int_t to, Int_t type) 151 193 { … … 497 539 } 498 540 541 // 542 // Handling new sequence (checking runs; checking for old sequence; inserting sequence, if everything is okay) 543 // 499 544 Bool_t NewSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy) 500 545 { … … 564 609 } 565 610 611 // 612 // Build Sequences in range of runs 613 // 566 614 Bool_t Process(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy) 567 615 { … … 735 783 736 784 785 // 786 // Build Sequences for the night given by TString day 787 // 737 788 int buildsequenceentries(TString day, TString datapath, TString sequpath, Bool_t dummy=kTRUE) 738 789 { … … 757 808 day.Data(), day.Data())); 758 809 810 //get all values from the database, that are relevant for building sequences 759 811 TString query(Form("SELECT fRunNumber, fSourceKEY, fProjectKEY, fHvSettingsKEY, fLightConditionsKEY, fDiscriminatorThresholdTableKEY, fTriggerDelayTableKEY FROM RunData WHERE %s AND fExcludedFDAKEY=1 order by fRunNumber", cond.Data())); 760 812 … … 763 815 return 0; 764 816 817 //build blocks of runs, which have the same values 818 //for each block the first and the last run are stored in a TExMap 819 //the values are checked with the help of an array of TStrings 765 820 TString keys[6]= { "NULL", "NULL", "NULL", "NULL", "NULL", "NULL" }; 766 821 TString stop = "NULL"; … … 795 850 796 851 keys[i-1]=value; 797 // hier einfuellen852 //fill values into TExMap 798 853 blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend); 799 854 runstart=(*row)[0]; … … 806 861 } 807 862 808 // und hier einfuellen (letzter wert)863 //fill values into TExMap (last value) 809 864 runbegin=atoi(runstart.Data()); 810 865 runend=atoi(runstop.Data()); … … 812 867 813 868 869 //get list of current sequence of this night from the database and store it in sequlist 814 870 TList sequlist; 815 871 query=Form("SELECT fSequenceFirst FROM Sequences WHERE fManuallyChangedKEY=1 AND %s order by fSequenceFirst", 816 872 cond.Data()); 817 818 873 // cout << "Q: " << query << endl; 819 874 … … 833 888 Bool_t rc = kTRUE; 834 889 890 //build sequences in each block of runs 835 891 Long_t key, val; 836 892 TExMapIter nblocks(&blocks); … … 846 902 } 847 903 904 //newly build or remaining sequences are removed from sequlist while building sequences 905 //delete sequences that remained in the list 906 //this is necessary if e.g. all runs of one old sequence have been excluded in the meantime 848 907 TIter Next(&sequlist); 849 908 TObject *obj = 0; … … 858 917 } 859 918 860 919 // 920 // Build Sequences for all Nights 921 // 861 922 int buildsequenceentries(TString datapath, TString sequpath, Bool_t dummy=kTRUE) 862 923 { … … 870 931 } 871 932 933 //get all dates from the database 872 934 TString query="SELECT fDate FROM SequenceBuildStatus"; 873 935 … … 876 938 return 0; 877 939 940 //execute buildsequenceentries for all dates 878 941 TString date; 879 942 TSQLRow *row=0;
Note:
See TracChangeset
for help on using the changeset viewer.