Changeset 7275 for trunk/MagicSoft/Mars/datacenter/macros
- Timestamp:
- 08/08/05 17:19:04 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
r7274 r7275 52 52 #include <TRegexp.h> 53 53 #include <TSystem.h> 54 #include <TObjString.h> 54 55 55 56 #include <MTime.h> … … 175 176 } 176 177 177 Bool_t CheckSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, Bool_t dummy)178 Int_t CheckSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, Bool_t dummy) 178 179 { 179 180 Int_t rc=0; … … 216 217 217 218 //calibration table 218 query (Form("SELECT fSequenceFirst FROM Calibration WHERE fSequenceFirst BETWEEN %d and %d", from, to));219 query=Form("SELECT fSequenceFirst FROM Calibration WHERE fSequenceFirst BETWEEN %d and %d", from, to); 219 220 res = serv.Query(query); 220 221 if (!res) … … 225 226 if (!DeleteSequence(serv, datapath, sequpath, atoi((*row)[0]), dummy)) 226 227 return -1; 227 else 228 rc=1; 228 rc=1; 229 229 } 230 230 delete res; 231 231 232 232 //Star table 233 query (Form("SELECT fSequenceFirst FROM Star WHERE fSequenceFirst BETWEEN %d and %d", from, to));233 query=Form("SELECT fSequenceFirst FROM Star WHERE fSequenceFirst BETWEEN %d and %d", from, to); 234 234 res = serv.Query(query); 235 235 if (!res) … … 240 240 if (!DeleteSequence(serv, datapath, sequpath, atoi((*row)[0]), dummy)) 241 241 return -1; 242 else 243 rc=1; 242 rc=1; 244 243 } 245 244 delete res; 246 245 247 246 //SequenceProcessStatus table 248 query (Form("SELECT fSequenceFirst FROM SequenceProcessStatus WHERE fSequenceFirst BETWEEN %d and %d", from, to));247 query=Form("SELECT fSequenceFirst FROM SequenceProcessStatus WHERE fSequenceFirst BETWEEN %d and %d", from, to); 249 248 res = serv.Query(query); 250 249 if (!res) … … 255 254 if (!DeleteSequence(serv, datapath, sequpath, atoi((*row)[0]), dummy)) 256 255 return -1; 257 else 258 rc=1; 256 rc=1; 259 257 } 260 258 delete res; … … 267 265 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(0), dummy)) 268 266 return -1; 269 else 270 rc=1; 267 rc=1; 271 268 } 272 269 else … … 275 272 276 273 //getting olf runs 277 query (Form("SELECT fRunNumber FROM RunData WHERE fSequenceFirst=%d ", from));274 query=Form("SELECT fRunNumber FROM RunData WHERE fSequenceFirst=%d ", from); 278 275 res = serv.Query(query); 279 276 if (!res) … … 292 289 293 290 //getting new runs 294 query (Form("SELECT fRunNumber FROM RunData WHERE fRunNumber BETWEEN %d and %d AND fExcludedFDAKEY=1", from, to));291 query=Form("SELECT fRunNumber FROM RunData WHERE fRunNumber BETWEEN %d and %d AND fExcludedFDAKEY=1", from, to); 295 292 res = serv.Query(query); 296 293 if (!res) … … 302 299 { 303 300 count++; 304 oldruns.Set(count);305 oldruns.AddAt(atoi((*row)[0]), count-1);301 newruns.Set(count); 302 newruns.AddAt(atoi((*row)[0]), count-1); 306 303 } 307 304 delete res; … … 310 307 if (oldruns.GetSize()!=newruns.GetSize()) 311 308 { 312 cout << " number of runs is not the same -> deleting sequence " << sequences.At(0) << endl; 309 // cout << " number of runs (" << oldruns.GetSize() << " - " << newruns.GetSize() 310 // << ") is not the same -> deleting sequence " << sequences.At(0) << endl; 313 311 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(0), dummy)) 314 312 return -1; 315 else 316 rc=1; 313 rc=1; 317 314 } 318 315 else … … 322 319 for (Int_t i=0;i<newruns.GetSize();i++) 323 320 { 321 // cout << "i: " << i << " - new: " << newruns.At(i) << " - old: " << oldruns.At(i) << endl; 324 322 if (newruns.At(i)==oldruns.At(i)) 325 323 continue; … … 329 327 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(0), dummy)) 330 328 return -1; 331 else 332 rc=1; 329 rc=1; 333 330 break; 334 331 } … … 346 343 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(i), dummy)) 347 344 return -1; 348 else 349 rc=1; 345 rc=1; 350 346 } 351 347 } … … 489 485 } 490 486 491 Bool_t NewSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, Bool_t dummy)487 Bool_t NewSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy) 492 488 { 493 489 cout << "Found Sequence (" << from << ", " << to << ") ... checking runs..." << flush; … … 513 509 cout << "checking Sequence..." << endl; 514 510 511 TObject *sequ; 515 512 Bool_t rc=kFALSE; 516 513 switch (CheckSequence(serv, datapath, sequpath, from, to, dummy)) … … 524 521 } 525 522 cout << endl; 523 if ((sequ=sequlist.Remove(sequlist.FindObject(Form("%d", from))))) 524 delete sequ; 526 525 return InsertSequence(serv, from, to); 527 526 … … 534 533 } 535 534 cout << endl; 535 if ((sequ=sequlist.Remove(sequlist.FindObject(Form("%d", from))))) 536 delete sequ; 536 537 return InsertSequence(serv, from, to); 537 538 538 539 case 2: 539 cout << " sequence is already existing -> inserting not necessary" << endl; 540 cout << " sequence " << from << " is already existing -> inserting not necessary" << endl; 541 if ((sequ=sequlist.Remove(sequlist.FindObject(Form("%d", from))))) 542 delete sequ; 540 543 return kTRUE; 541 544 … … 549 552 } 550 553 551 Bool_t Process(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, Bool_t dummy)554 Bool_t Process(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy) 552 555 { 553 556 … … 692 695 if (n!=-1) 693 696 { 694 if (!NewSequence(serv, datapath, sequpath, start, last, dummy))697 if (!NewSequence(serv, datapath, sequpath, start, last, sequlist, dummy)) 695 698 { 696 699 rc = kFALSE; … … 708 711 if (n!=-1 && start!=last) 709 712 { 710 if (!NewSequence(serv, datapath, sequpath, start, last, dummy))713 if (!NewSequence(serv, datapath, sequpath, start, last, sequlist, dummy)) 711 714 rc = kFALSE; 712 715 } … … 797 800 798 801 802 TList sequlist; 803 query=Form("SELECT fSequenceFirst FROM Sequences WHERE %s order by fSequenceFirst", 804 cond.Data()); 805 806 // cout << "Q: " << query << endl; 807 808 res = serv.Query(query); 809 if (!res) 810 return 0; 811 812 cout << "old sequences: " << flush; 813 while ((row=res->Next())) 814 { 815 const char *str = (*row)[0]; 816 cout << str << " " << flush; 817 sequlist.Add(new TObjString(str)); 818 } 819 cout << endl; 820 799 821 Bool_t rc = kTRUE; 800 822 … … 807 829 cout << endl << "datablock from " << runstart2 << " to " << runstop2 << endl; 808 830 809 if (!Process(serv, datapath, sequpath, runstart2, runstop2, dummy))831 if (!Process(serv, datapath, sequpath, runstart2, runstop2, sequlist, dummy)) 810 832 rc = kFALSE; 811 833 812 834 } 835 836 TIter Next(&sequlist); 837 TObject *obj = 0; 838 while ((obj=Next())) 839 { 840 cout << "sequ: " << obj->GetName() << " deleting... " << endl; 841 if (!DeleteSequence(serv, datapath, sequpath, atoi(obj->GetName()), dummy)) 842 return 0; 843 } 844 813 845 return rc ? 1 : 0; 814 846 } … … 832 864 return 0; 833 865 866 TString date; 834 867 TSQLRow *row=0; 835 868 while ((row=res->Next())) 836 869 { 837 cout << "date: " << (*row)[0] << endl; 838 buildsequenceentries((*row)[0], dummy); 870 date=(*row)[0]; 871 cout << "date: " << date << endl; 872 buildsequenceentries(date, datapath, sequpath, dummy); 839 873 } 840 874
Note:
See TracChangeset
for help on using the changeset viewer.