Changeset 9539 for trunk/MagicSoft/Mars/datacenter/macros
- Timestamp:
- 01/15/10 09:27:25 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
r9213 r9539 90 90 #include <TExMap.h> 91 91 #include <TArrayI.h> 92 #include <TArrayL.h> 92 93 #include <TArrayD.h> 93 94 #include <TPRegexp.h> … … 103 104 using namespace std; 104 105 105 /*static*/ U Int_t GetId(const TString str)106 /*static*/ ULong_t GetId(const TString str) 106 107 { 107 108 const Ssiz_t dot = str.First('.'); … … 110 111 const UInt_t sub = dot<0 ? 0 : atoi(str.Data()+dot+1); 111 112 112 return run*1000+sub;113 return ULong_t(run)*1000+sub; 113 114 } 114 115 … … 119 120 TPRegexp fRegexp; 120 121 121 U Int_t fMin;122 U Int_t fMax;122 ULong_t fMin; 123 ULong_t fMax; 123 124 124 125 public: 125 126 Rule(TObjArray &arr) : 126 127 fRegexp(arr.GetEntries()>0?Form("^%s", arr[0]->GetName()):""), 127 fMin(0), fMax((U Int_t)-1)128 fMin(0), fMax((ULong_t)-1) 128 129 { 129 130 if (arr.GetEntries()>1) … … 133 134 } 134 135 135 Ssiz_t Match(const TString &str, Int_t idx, Int_t run=-1)136 Ssiz_t Match(const TString &str, Int_t idx, Long_t run=-1) 136 137 { 137 138 if (!IsValid(run)) … … 145 146 } 146 147 147 Bool_t IsValid(U Int_t run) const { return run<0 || (run>=fMin && run<=fMax); }148 Bool_t IsValid(ULong_t run) const { return run>=fMin && run<=fMax; } 148 149 ClassDef(Rule, 0) 149 150 }; … … 159 160 TPRegexp fRegexp2; 160 161 161 U Int_t fMin;162 U Int_t fMax;162 ULong_t fMin; 163 ULong_t fMax; 163 164 164 165 void Init(const TObjArray &arr, Int_t idx=0) … … 191 192 CheckMatch() : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2("") {} 192 193 193 CheckMatch(const TString &txt) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((U Int_t)-1)194 CheckMatch(const TString &txt) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((ULong_t)-1) 194 195 { 195 196 TObjArray *arr = txt.Tokenize(" "); … … 198 199 } 199 200 200 CheckMatch(TObjArray &arr, Int_t idx=0) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((U Int_t)-1)201 CheckMatch(TObjArray &arr, Int_t idx=0) : fRunType1(""), fRunType2(""), fRegexp1(""), fRegexp2(""), fMin(0), fMax((ULong_t)-1) 201 202 { 202 203 Init(arr, idx); 203 204 } 204 205 205 CheckMatch(const char *from, const char *to, Int_t min=0, Int_t max=-1)206 CheckMatch(const char *from, const char *to, Long_t min=0, Long_t max=-1) 206 207 : fRunType1(".*"), fRunType2(".*"), fRegexp1(Form("^%s$", from)), fRegexp2(Form("^%s$", to)), fMin(min), fMax(max) 207 208 { 208 209 } 209 210 210 Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, U Int_t run=0)211 Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, ULong_t run=0) 211 212 { 212 213 if (run>0) … … 234 235 public: 235 236 CheckList() { SetOwner(); } 236 Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, Int_t run=-1) const237 Int_t Matches(const TString &rt1, const TString &rt2, const TString &lc1, const TString &lc2, Long_t run=-1) const 237 238 { 238 239 TIter Next(this); … … 277 278 // (row[i]) and the current run-type (row[1]) matches the attribute 278 279 // of the last run (keys[i] with run-type row[i]) 279 return list->Matches(keys[1], row[1], keys[i], row[i], ato i(row[0]));280 } 281 282 Bool_t InsertSequence( Int_t from, Int_t to)280 return list->Matches(keys[1], row[1], keys[i], row[i], atol(row[0])); 281 } 282 283 Bool_t InsertSequence(Long_t from, Long_t to) 283 284 { 284 285 cout << " - Inserting Sequence into database." << endl; … … 291 292 "SUM(TIME_TO_SEC(TIMEDIFF(fRunStop,fRunStart))), "; 292 293 293 const TString where = Form("(fRunNumber*1000+fFileNumber BETWEEN % d AND %d) "294 const TString where = Form("(fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld) " 294 295 "AND fTelescopeNumber=%d AND fExcludedFDAKEY=1", 295 296 from, to, fTelescopeNumber); … … 361 362 } 362 363 363 const TString set = Form("fSequenceFirst=% d, fTelescopeNumber=%d ", from/1000, fTelescopeNumber);364 const TString set = Form("fSequenceFirst=%ld, fTelescopeNumber=%d ", from/1000, fTelescopeNumber); 364 365 365 366 TString query1; 366 367 query1 += set; 367 query1 += Form(",fSequenceLast=% d,", to/1000);368 query1 += Form(",fSequenceLast=%ld,", to/1000); 368 369 query1 += Form(" fSourceKEY=%s,", (*row)[0]); 369 370 query1 += Form(" fProjectKEY=%s,", (*row)[1]); … … 404 405 405 406 TString prio = set; 406 prio += Form(", fPriority=% d ", from/1000);407 prio += Form(", fPriority=%ld ", from/1000); 407 408 if (!Insert("SequenceProcessStatus", prio)) 408 409 { … … 465 466 } 466 467 467 Int_t CheckSequence( Int_t runstart, Int_t runstop)468 Int_t CheckSequence(Long_t runstart, Long_t runstop) 468 469 { 469 470 const char *fmt1 = "SELECT fRunNumber*1000+fFileNumber AS Id FROM RunData WHERE"; 470 471 const char *fmt2 = "AND fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4) ORDER BY Id"; 471 472 472 const TString query1 = Form("%s fTelescopeNumber=%d AND fSequenceFirst=% d %s",fmt1, fTelescopeNumber, runstart/1000, fmt2);473 const TString query2 = Form("%s fTelescopeNumber=%d AND fRunNumber*1000+fFileNumber BETWEEN % d AND %d %s", fmt1, fTelescopeNumber, runstart, runstop, fmt2);473 const TString query1 = Form("%s fTelescopeNumber=%d AND fSequenceFirst=%ld %s", fmt1, fTelescopeNumber, runstart/1000, fmt2); 474 const TString query2 = Form("%s fTelescopeNumber=%d AND fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld %s", fmt1, fTelescopeNumber, runstart, runstop, fmt2); 474 475 475 476 TSQLResult *res1 = Query(query1); … … 495 496 return kFALSE; 496 497 497 if (ato i((*row1)[0])!=atoi((*row2)[0]))498 if (atol((*row1)[0])!=atol((*row2)[0])) 498 499 return kFALSE; 499 500 } … … 502 503 } 503 504 504 Int_t CreateSequence( Int_t runstart, Int_t runstop)505 Int_t CreateSequence(Long_t runstart, Long_t runstop) 505 506 { 506 507 cout << " * Creating Sequence " << runstart << "-" << runstop << ":" << endl; … … 508 509 TString query= 509 510 Form("SELECT fSequenceFirst FROM RunData " 510 " WHERE fRunNumber*1000+fFileNumber BETWEEN % d AND %d AND "511 " WHERE fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld AND " 511 512 " fTelescopeNumber=%d AND fSequenceFirst>0 AND " 512 513 " fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)" … … 794 795 } 795 796 796 TString PrepareString(TSQLResult &res, TArray I&runs)797 TString PrepareString(TSQLResult &res, TArrayL &runs) 797 798 { 798 799 // Number of result rows … … 810 811 while ((row=res.Next())) 811 812 { 812 runs[idx] = ato i((*row)[0]); // run number813 runs[idx] = atol((*row)[0]); // run number 813 814 814 815 const TString tstart = ((*row)[2]); // start time … … 862 863 } 863 864 864 void PrintResidual( Int_t runstart, Int_t runstop, TString residual, const char *descr)865 void PrintResidual(Long_t runstart, Long_t runstop, TString residual, const char *descr) 865 866 { 866 867 residual.ToLower(); … … 891 892 } 892 893 893 Int_t SplitBlock( Int_t runstart, Int_t runstop, const TString &cond)894 Int_t SplitBlock(Long_t runstart, Long_t runstop, const TString &cond) 894 895 { 895 896 // Request data necessary to split block into sequences … … 897 898 Form("SELECT fRunNumber*1000+fFileNumber AS Id, fRunTypeKEY, fRunStart, fRunStop" 898 899 " FROM RunData " 899 " WHERE fRunNumber*1000+fFileNumber BETWEEN % d AND %d AND "900 " WHERE fRunNumber*1000+fFileNumber BETWEEN %ld AND %ld AND " 900 901 /*" fExcludedFDAKEY=1 AND (fRunTypeKEY BETWEEN 2 AND 4)" 901 902 " ORDER BY Id"*/, runstart, runstop); … … 912 913 // Get String containing the sequence of P-,C- and D-Runs 913 914 // and an array with the corresponding run-numbers 914 TArray Iruns;915 TArrayL runs; 915 916 const TString str = PrepareString(*res, runs); 916 917 … … 1035 1036 // This is the runnumber of the first run in the new block 1036 1037 if (runstart<0) 1037 runstart=ato i((*row)[0]);1038 runstart=atol((*row)[0]); 1038 1039 1039 1040 // Check which transitions might be allowed for this run and … … 1085 1086 1086 1087 // This is already the first run of the new block 1087 runstart=ato i((*row)[0]);1088 runstart=atol((*row)[0]); 1088 1089 1089 1090 // These are the keys corresponding to the first run … … 1101 1102 1102 1103 // This is the new runnumber of the last run in this block 1103 runstop=ato i((*row)[0]);1104 runstop=atol((*row)[0]); 1104 1105 } 1105 1106
Note:
See TracChangeset
for help on using the changeset viewer.