Changeset 9015 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 07/19/08 12:55:42 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r9012 r9015 47 47 // Sequence: 31015 48 48 // 49 // # Observation Period (not needed )50 // Period: 1849 // # Observation Period (not needed, calculated from Night) 50 // # Period: 18 51 51 // 52 52 // # Date of sunrise of the observation night - necessary if the path … … 74 74 // # Total number of data-events in sequence (not needed) 75 75 // NumEvents: 250914 76 // 77 // # Brightest light condition of the contained runs (not needed) 78 // LightCondition: Twilight 76 79 // 77 80 // # Whether this is MC data or not (necessary in case of MCs if … … 661 664 fLastRun = GetEnvValue2(env, prefix, "LastRun", -1); 662 665 fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1); 663 fPeriod = GetEnvValue2(env, prefix, "Period", -1);664 666 665 667 TString str; 666 str = GetEnvValue2(env, prefix, "LightCondition s", "n/a");668 str = GetEnvValue2(env, prefix, "LightCondition", "n/a"); 667 669 fLightCondition = GetLightCondition(str); 668 670 … … 673 675 str += " 00:00:00"; 674 676 fNight.SetSqlDateTime(str); 677 678 fPeriod = fNight.GetMagicPeriod(); 675 679 676 680 fProject = GetEnvValue2(env, prefix, "Project", ""); … … 688 692 689 693 // Dummies: 694 env.Touch("Period"); 690 695 env.Touch("ZdMin"); 691 696 env.Touch("ZdMax"); … … 700 705 } 701 706 707 // -------------------------------------------------------------------------- 708 // 709 // Create a sequence from the database, e.g. 710 // 711 // TString mysql = "mysql://MAGIC:password@vela/MyMagic"; 712 // Int_t sequence = 100002; 713 // Int_t telescope = 1; 714 // 715 // MSequence seq(mysql, sequence, telescope); 716 // 717 // For more details see MSequenceSQL. 718 // 702 719 MSequence::MSequence(const char *fname, UInt_t seq, UShort_t tel) 703 720 { … … 705 722 } 706 723 724 // -------------------------------------------------------------------------- 725 // 726 // Some helper functions for the comparison functions 727 // 707 728 static int operator==(const TArrayI &a, const TArrayI &b) 708 729 { 709 return a.GetSize()==b.GetSize() ? 710 memcmp(a.GetArray(), b.GetArray(), a.GetSize()*sizeof(Int_t))==0 : 711 false; 712 } 713 714 static int IsNull(const TArrayI &a) 715 { 716 if (a.GetSize()==0) 717 return true; 718 719 return a.GetSize()==0 ? true : a==TArrayI(a.GetSize()); 730 return a.GetSize()==b.GetSize() && 731 memcmp(a.GetArray(), b.GetArray(), a.GetSize()*sizeof(Int_t)); 720 732 } 721 733 722 734 static int IsNull(const TArrayI &a, const TArrayI &b) 723 735 { 724 return IsNull(a) && IsNull(b); 725 } 726 727 Bool_t MSequence::IsSimilar(const MSequence &s) const 736 return a==TArrayI(a.GetSize()) && b==TArrayI(b.GetSize()); 737 } 738 739 static int Check(const TArrayI &a, const TArrayI &b) 740 { 741 return a==b || IsNull(a, b); 742 } 743 744 // -------------------------------------------------------------------------- 745 // 746 // Here we test all things mandatory for a sequence: 747 // fTelescope 748 // fSequence 749 // fNight 750 // fMonteCarlo 751 // fCalRuns 752 // fCalRunsSub 753 // fPedRuns 754 // fPedRunsSub 755 // fDatRuns 756 // fDatRunsSub 757 // fExclRuns 758 // fExclRunsSub 759 // 760 Bool_t MSequence::IsCompatible(const MSequence &s) const 728 761 { 729 762 return // Mandatory 730 fTelescope==s.fTelescope && fSequence==s.fSequence && 731 fNight==s.fNight 732 && fLightCondition==s.fLightCondition && 733 734 fMonteCarlo==s.fMonteCarlo && 735 736 (fRunsSub ==s.fRunsSub || IsNull(fRunsSub, s.fRunsSub)) && 737 (fCalRunsSub ==s.fCalRunsSub || IsNull(fCalRunsSub, s.fCalRunsSub)) && 738 (fPedRunsSub ==s.fPedRunsSub || IsNull(fPedRunsSub, s.fPedRunsSub)) && 739 (fDatRunsSub ==s.fDatRunsSub || IsNull(fDatRunsSub, s.fDatRunsSub)) && 740 (fExclRunsSub==s.fExclRunsSub || IsNull(fExclRunsSub, s.fExclRunsSub)) 741 ; 742 } 743 763 fTelescope == s.fTelescope && 764 fSequence == s.fSequence && 765 fNight == s.fNight && 766 767 fMonteCarlo == s.fMonteCarlo && 768 769 fCalRuns == s.fCalRuns && 770 fPedRuns == s.fPedRuns && 771 fDatRuns == s.fDatRuns && 772 fExclRuns == s.fExclRuns && 773 774 Check(fCalRunsSub, s.fCalRunsSub) && 775 Check(fPedRunsSub, s.fPedRunsSub) && 776 Check(fDatRunsSub, s.fDatRunsSub) && 777 Check(fExclRunsSub, s.fExclRunsSub); 778 } 779 780 // -------------------------------------------------------------------------- 781 // 782 // Here we test whether all values of a sequence are identical 783 // IsCompaticle(s) 784 // fStart 785 // fLastRun 786 // fNumEvents 787 // fPeriod 788 // fProject 789 // fSource 790 // fRuns 791 // fHvSettings 792 // fTriggerTable 793 // fLightCondition 794 // fRuns 795 // fRunsSub 796 // 797 Bool_t MSequence::operator==(const MSequence &s) const 798 { 799 return IsCompatible(s) && 800 // Unnecessary 801 fStart == s.fStart && 802 fLastRun == s.fLastRun && 803 fNumEvents == s.fNumEvents && 804 fPeriod == s.fPeriod && 805 fProject == s.fProject && 806 fSource == s.fSource && 807 fRuns == s.fRuns && 808 fHvSettings == s.fHvSettings && 809 fTriggerTable == s.fTriggerTable && 810 fLightCondition == s.fLightCondition && 811 Check(fRunsSub, s.fRunsSub); 812 } 813 814 // -------------------------------------------------------------------------- 815 // 816 // Check whether the sequence has also identical source, i.e. 817 // the sequence filepath and the datapath in addition to operator== 818 // 744 819 Bool_t MSequence::IsIdentical(const MSequence &s) const 745 820 { 746 return IsSimilar(s) && 747 // Unnecessary 748 fStart==s.fStart && fLastRun==s.fLastRun && 749 fNumEvents==s.fNumEvents && fPeriod==s.fPeriod && 750 fProject==s.fProject && fSource==s.fSource && 751 /*fTriggerTable==s.fTriggerTable &&*/ fHvSettings==s.fHvSettings; 752 } 753 754 Bool_t MSequence::operator==(const MSequence &s) const 755 { 756 return IsIdentical(s) && 821 return *this==s && 757 822 // Obsolete 758 823 fDataPath==s.fDataPath && fFileName==s.fFileName; … … 981 1046 out << pre << "Night: " << fNight.GetStringFmt("%Y-%m-%d") << endl; 982 1047 out << endl; 983 out << pre << "LightCondition s: ";1048 out << pre << "LightCondition: "; 984 1049 switch (fLightCondition) 985 1050 { … … 1018 1083 else 1019 1084 { 1085 // FIXME: This needs more check! 1086 // Could we make "Runs" an automatic summary of all runs? 1087 // Should we add a check forbidding the same run in 1088 // Cal/Ped/Data? What about the Exclude? 1020 1089 str += PrintRuns(out, pre, "Runs: ", fRuns, fRunsSub); 1021 1090 /*str +=*/ PrintRuns(out, pre, "CalRuns: ", fCalRuns, fCalRunsSub); … … 1196 1265 f = &fCalRunsSub; 1197 1266 break; 1267 case 'X': 1268 r = &fExclRuns; 1269 f = &fExclRunsSub; 1270 break; 1198 1271 default: 1199 1272 r = &fRuns; … … 1204 1277 AddEntry(run, file, *r, *f); 1205 1278 1206 MJob::SortArray(fExclRuns); 1207 } 1208 1209 // -------------------------------------------------------------------------- 1210 // 1211 // Exclude this run (i.e. add it to fExclRuns) 1212 // 1213 void MSequence::ExcludeFile(UInt_t run, UInt_t file/*, Bool_t force*/) 1214 { 1215 // if (force && IsExcluded(run, file)) 1216 // return; 1217 1218 AddEntry(run, file, fExclRuns, fExclRunsSub); 1219 1220 MJob::SortArray(fExclRuns); 1279 SortArrays(*r, *f); 1221 1280 } 1222 1281 … … 1268 1327 fNight.SetSqlDateTime(night); 1269 1328 1270 fPeriod = MAstro::GetMagicPeriod(fNight.GetMjd());1329 fPeriod = fNight.GetMagicPeriod(); 1271 1330 } 1272 1331 -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r9012 r9015 101 101 } 102 102 MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1); 103 MSequence(const char *fname, UInt_t seq, UShort_t tel= 1);103 MSequence(const char *fname, UInt_t seq, UShort_t tel=0); 104 104 MSequence(const MSequence &s) : MParContainer(s), 105 105 fFileName(s.fFileName), fDataPath(s.fDataPath), … … 116 116 fExclRunsSub(s.fExclRunsSub), fMonteCarlo(s.fMonteCarlo) { } 117 117 118 Bool_t Is Similar(const MSequence &s) const;118 Bool_t IsCompatible(const MSequence &s) const; 119 119 Bool_t IsIdentical(const MSequence &s) const; 120 120 Bool_t operator==(const MSequence &s) const; … … 143 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 144 145 void ExcludeFile(UInt_t num, UInt_t file=0);145 void ExcludeFile(UInt_t run, UInt_t file=0) { /*if (!force || !IsExcluded(run, file))*/ AddFile(run, file, 'X'); } 146 146 void ExcludeRuns(TString runs); 147 147 -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc
r9013 r9015 55 55 // 56 56 // 57 // A telscope number of -1 means: Take fTelescope as telescope number 58 // to request. A telescope number of 0 tries to get the sequence from 59 // the db including the telescope number. This will fail if more than 60 // one sequence with the same number exist in the db for several 61 // telescopes. 62 // 63 // 57 64 // This tool will work from Period017 (2004_05_17) on... 58 65 // … … 169 176 fLastRun = atoi(data[0]); 170 177 fNumEvents = atoi(data[8]); 178 fTelescope = atoi(data[11]); 171 179 fProject = str[0]; 172 180 fSource = str[1]; … … 175 183 fLightCondition = GetLightCondition(str[5]); 176 184 177 // MISSING: ---> ZdMin, ZdMax, fComment, fMonteCarlo <--- 185 // FIXME: ZdMin (str[9]) ZdMax(str[10]) --> Comment 186 // FIXME: fMonteCarlo 187 // FIXME: fComment? 178 188 179 189 // Now prepare queries to request the runs from the database 180 TString where(Form(" FROM RunData WHERE"181 " fTelescopeNumber=%d AND fSequenceFirst=%d AND"182 " fExcludedFDAKEY=1 AND fRunTypeKEY%%s",183 fTelescope, fSequence));190 const TString where(Form(" FROM RunData WHERE" 191 " fTelescopeNumber=%d AND fSequenceFirst=%d AND" 192 " fExcludedFDAKEY=1 AND fRunTypeKEY%%s", 193 fTelescope, fSequence)); 184 194 185 195 const TString query1(Form("SELECT fRunNumber, fFileNumber, fNumEvents %s", where.Data())); … … 229 239 if (res.GetRowCount()>1) 230 240 { 231 *fLog << err << "ERROR - Database request returned unexpected number of rows." << endl;232 return kFALSE; 233 } 234 235 if (res.GetFieldCount()!=1 1)241 *fLog << err << "ERROR - Database request returned morethan one sequence." << endl; 242 return kFALSE; 243 } 244 245 if (res.GetFieldCount()!=12) 236 246 { 237 247 *fLog << err << "ERROR - Database request returned unexpected number of rows." << endl; … … 268 278 // kTrue in case of success. 269 279 // 270 Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, Int_t sequno, Int_t tel)280 Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, UInt_t sequno, Int_t tel) 271 281 { 272 282 // Check if we are connected to the sql server … … 277 287 } 278 288 279 // check if any telescope number is avlid 280 if (tel<=0 && fTelescope<=0) 289 /* 290 // check if any telescope number is valid 291 if (tel<0 && fTelescope==0) 281 292 { 282 293 *fLog << err << "ERROR - No telescope number given in GetSeqFromDatabase." << endl; 283 294 return kFALSE; 284 295 } 285 286 // check if any sequence number is avlid 287 if (sequno<0 && fSequence<0) 296 */ 297 298 // check if any sequence number is valid 299 if (sequno==(UInt_t)-1 && fSequence==(UInt_t)-1) 288 300 { 289 301 *fLog << err << "ERROR - No sequence number given in GetSeqFromDatabase." << endl; … … 292 304 293 305 // set "filename" and sequence number 294 fFileName = serv.GetName();295 if (tel> 0)306 fFileName = serv.GetName(); 307 if (tel>=0) 296 308 fTelescope = tel; 297 if (sequno >=0)309 if (sequno!=(UInt_t)-1) 298 310 fSequence = sequno; 299 311 … … 302 314 " fL1TriggerTableKEY, fL2TriggerTableKEY, fHvSettingsKEY, " 303 315 " fLightConditionsKEY, fRunStart, fNumEvents, " 304 " fZenithDistanceMin, fZenithDistanceMax "316 " fZenithDistanceMin, fZenithDistanceMax, fTelescopeNumber " 305 317 " FROM Sequences WHERE "); 306 query += Form("fTelescopeNumber=%d AND fSequenceFirst=%d", 307 fTelescope, fSequence); 318 query += Form("fSequenceFirst=%d", fSequence); 319 320 if (tel>0) 321 query += Form(" AND fTelescopeNumber=%d", fTelescope); 308 322 309 323 // Request information from database … … 348 362 // kTrue in case of success. 349 363 // 350 Bool_t MSequenceSQL::GetFromDatabase(const char *rc, Int_t sequno, Int_t tel)364 Bool_t MSequenceSQL::GetFromDatabase(const char *rc, UInt_t sequno, Int_t tel) 351 365 { 352 366 MSQLMagic serv(rc); -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.h
r9002 r9015 20 20 21 21 public: 22 MSequenceSQL(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1){ GetFromDatabase(serv, seqno, tel); }23 MSequenceSQL(const char *rc, Int_t seqno=-1, Int_t tel=-1){ GetFromDatabase(rc, seqno, tel); }24 MSequenceSQL( Int_t seqno=-1, Int_t tel=-1){ GetFromDatabase(seqno, tel); }22 MSequenceSQL(MSQLMagic &serv, UInt_t seqno, Int_t tel=0) { GetFromDatabase(serv, seqno, tel); } 23 MSequenceSQL(const char *rc, UInt_t seqno, Int_t tel=0) { GetFromDatabase(rc, seqno, tel); } 24 MSequenceSQL(UInt_t seqno, Int_t tel=0) { GetFromDatabase(seqno, tel); } 25 25 26 Bool_t GetFromDatabase(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1);27 Bool_t GetFromDatabase(const char *rc, Int_t seqno=-1, Int_t tel=-1);28 Bool_t GetFromDatabase( Int_t seqno=-1, Int_t tel=-1) { return GetFromDatabase("sql.rc", seqno, tel); }26 Bool_t GetFromDatabase(MSQLMagic &serv, UInt_t seqno=(UInt_t)-1, Int_t tel=-1); 27 Bool_t GetFromDatabase(const char *rc, UInt_t seqno=(UInt_t)-1, Int_t tel=-1); 28 Bool_t GetFromDatabase(UInt_t seqno=(UInt_t)-1, Int_t tel=-1) { return GetFromDatabase("sql.rc", seqno, tel); } 29 29 30 30 ClassDef(MSequenceSQL, 0) // Extension of MSequence to get a sequence from a database
Note:
See TracChangeset
for help on using the changeset viewer.