- Timestamp:
- 07/27/06 20:36:05 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r7812 r7813 18 18 19 19 -*-*- END OF LINE -*-*- 20 2006/07/26 Thomas Bretz 21 22 * datacenter/macros/buildsequenceentries.C: 23 - removed some obsolete output 24 - logging output redone 25 - added some missing delete of TSQLResults 26 - fixed some overwrite of local variables 27 - added more comments 28 - moved code building the blocks to its own function 29 - simplified buildblocks 30 31 32 20 33 2006/07/27 Daniela Dorner 21 34 -
trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
r7629 r7813 92 92 #include <TSystem.h> 93 93 #include <TObjString.h> 94 #include <TObjArray.h> 94 95 95 96 #include <MTime.h> … … 258 259 // without the check for manuallychanged, all manually 259 260 // changed sequences would be deleted 260 cout << " found no sequence in Sequ-DB -> check other tables" << endl;261 cout << " deleting every sequence found in Calibration, Star or SequenceProcessStatus between "262 261 cout << " + found no sequence in Sequ-DB -> check other tables" << endl; 262 cout << " deleting every sequence found in Calibration, Star or" << endl; 263 cout << " SequenceProcessStatus between " << from << " and " << to << endl; 263 264 264 265 //calibration table … … 315 316 316 317 case 1: 317 cout << " found 1 sequence: " << sequences.At(0) << " -> check sequ#" << endl;318 cout << " + found one sequence: " << sequences.At(0) << " -> check sequence." << endl; 318 319 if (sequences.At(0)!=from) 319 320 { … … 324 325 else 325 326 { 326 cout << " sequence# is the same -> checking the runs" << endl;327 cout << " * sequence is the same -> checking the runs." << endl; 327 328 328 329 //getting olf runs … … 370 371 else 371 372 { 372 cout << " number of runs is the same -> checking the single runnumbers" << endl;373 cout << " · number of runs is the same -> checking the single runnumbers." << endl; 373 374 374 375 for (Int_t i=0;i<newruns.GetSize();i++) … … 378 379 continue; 379 380 380 cout << i << ". run is not the same ( " << oldruns.At(i) << " -- " << newruns.At(i)381 cout << " · " << i << ". run is not the same ( " << oldruns.At(i) << " -- " << newruns.At(i) 381 382 << ") -> deleting sequence " << sequences.At(0) << endl; 382 383 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(0), dummy)) 383 384 return -1; 384 rc=1; 385 break; 385 return 1; 386 386 } 387 387 } 388 388 } 389 rc=2; 390 break; 389 return 2; 391 390 392 391 default: 393 cout << " found " << numsequ << " sequences -> deleting them " << endl;392 cout << " - found " << numsequ << " sequences -> deleting them " << endl; 394 393 395 394 for (Int_t i=0;i<sequences.GetSize();i++) 396 395 { 397 cout << " deleting sequence " << sequences.At(i) << "... <" << i << ">" << endl;396 cout << " + deleting sequence " << sequences.At(i) << "... <" << i << ">" << endl; 398 397 if (!DeleteSequence(serv, datapath, sequpath, sequences.At(i), dummy)) 399 398 return -1; … … 407 406 Bool_t InsertSequence(MSQLServer &serv, Int_t from, Int_t to) 408 407 { 409 410 cout << "Inserting sequence " << from << " ... " << endl; 408 cout << " · Inserting sequence " << from << " ... " << endl; 411 409 412 410 // ========== Request number of events ========== … … 481 479 482 480 TString query1("INSERT Sequences SET"); 483 query1+=Form(" fSequenceFirst=%d, fSequenceLast=%d,", from, to); 484 query1+=Form(" fSourceKEY=%s,", (*row)[0]); 485 query1+=Form(" fProjectKEY=%s,", (*row)[1]); 486 query1+=Form(" fNumEvents=%s,", nevts.Data()); 487 query1+=Form(" fRunTime=%s,", secs.Data()); 488 query1+=Form(" fRunStart=\"%s\",", start.Data()); 489 query1+=Form(" fZenithDistanceMin=%s,", zdmin.Data()); 490 query1+=Form(" fZenithDistanceMax=%s,", zdmax.Data()); 491 query1+=Form(" fAzimuthMin=%s,", azmin.Data()); 492 query1+=Form(" fAzimuthMax=%s,", azmax.Data()); 493 query1+=Form(" fL1TriggerTableKEY=%s,", (*row)[2]); 494 query1+=Form(" fL2TriggerTableKEY=%s,", (*row)[3]); 495 query1+=Form(" fHvSettingsKEY=%s,", (*row)[4]); 496 query1+=Form(" fDiscriminatorThresholdTableKEY=%s,", (*row)[5]); 497 query1+=Form(" fTriggerDelayTableKEY=%s,", (*row)[6]); 498 query1+=Form(" fLightConditionsKEY=%s,", (*row)[7]); 499 query1+=Form(" fTestFlagKEY=%s, ", (*row)[8]); 500 query1+=Form(" fObservationModeKEY=%s, fManuallyChangedKEY=1", (*row)[9]); 481 query1 += Form(" fSequenceFirst=%d, fSequenceLast=%d,", from, to); 482 query1 += Form(" fSourceKEY=%s,", (*row)[0]); 483 query1 += Form(" fProjectKEY=%s,", (*row)[1]); 484 query1 += Form(" fNumEvents=%s,", nevts.Data()); 485 query1 += Form(" fRunTime=%s,", secs.Data()); 486 query1 += Form(" fRunStart=\"%s\",", start.Data()); 487 query1 += Form(" fZenithDistanceMin=%s,", zdmin.Data()); 488 query1 += Form(" fZenithDistanceMax=%s,", zdmax.Data()); 489 query1 += Form(" fAzimuthMin=%s,", azmin.Data()); 490 query1 += Form(" fAzimuthMax=%s,", azmax.Data()); 491 query1 += Form(" fL1TriggerTableKEY=%s,", (*row)[2]); 492 query1 += Form(" fL2TriggerTableKEY=%s,", (*row)[3]); 493 query1 += Form(" fHvSettingsKEY=%s,", (*row)[4]); 494 query1 += Form(" fDiscriminatorThresholdTableKEY=%s,", (*row)[5]); 495 query1 += Form(" fTriggerDelayTableKEY=%s,", (*row)[6]); 496 query1 += Form(" fLightConditionsKEY=%s,", (*row)[7]); 497 query1 += Form(" fTestFlagKEY=%s,", (*row)[8]); 498 query1 += Form(" fObservationModeKEY=%s, ", (*row)[9]); 499 query1+="fManuallyChangedKEY=1"; 501 500 502 501 … … 511 510 delete res; 512 511 513 cout << "q1: " << query1 << endl; 514 cout << "q2: " << query2 << endl; 515 cout << "q3: " << query3 << endl; 512 /* 513 cout << "q1: " << query1 << endl; 514 cout << "q2: " << query2 << endl; 515 cout << "q3: " << query3 << endl; 516 */ 516 517 517 518 res = serv.Query(query1); … … 547 548 Bool_t NewSequence(MSQLServer &serv, TString datapath, TString sequpath, Int_t from, Int_t to, TList &sequlist, Bool_t dummy) 548 549 { 549 cout << " Found Sequence (" << from << ", " << to << ") ... checking runs..." << flush;550 cout << " - Found Sequence (" << from << ", " << to << ") ... checking runs..." << flush; 550 551 551 552 if (!CheckRuns(serv, from, to, 2)) … … 567 568 568 569 569 cout << " checking Sequence..." << endl;570 cout << " + checking sequence..." << endl; 570 571 571 572 TObject *sequ; … … 574 575 { 575 576 case 0: 576 cout << " sequence not found -> inserting " << from << flush;577 cout << " · sequence not found -> inserting " << from << flush; 577 578 if (dummy) 578 579 { … … 586 587 587 588 case 1: 588 cout << " deleting successfully finished -> inserting sequence " << from << flush;589 cout << " · deleting successfully finished -> inserting sequence " << from << flush; 589 590 if (dummy) 590 591 { … … 598 599 599 600 case 2: 600 cout << " sequence " << from << " is already existing -> inserting not necessary" << endl;601 cout << " · sequence " << from << " is already existing -> inserting not necessary" << endl; 601 602 if ((sequ=sequlist.Remove(sequlist.FindObject(Form("%d", from))))) 602 603 delete sequ; … … 604 605 605 606 case -1: 606 cout << " deleting went wrong " << endl;607 cout << " · deleting went wrong " << endl; 607 608 return kFALSE; 608 609 } … … 784 785 } 785 786 786 787 void buildblocks(TSQLResult *res, TExMap &blocks) 788 { 789 //build blocks of runs, which have the same values 790 //for each block the first and the last run are stored in a TExMap 791 //the values are checked with the help of an array of TStrings 792 TString keys[7]; 793 794 Long_t runstart = -1; 795 Long_t runstop = -1; 796 797 // "Result set closed" means "Result set empty" 798 799 // Loop over runs 800 TSQLRow *row=0; 801 while ((row=res->Next())) 802 { 803 // Check whether all keys for this run fit 804 for (Int_t i=1; i<8; i++) 805 { 806 // Do not check project key for this runs 807 // (this condition is never true for the first run) 808 if (i==2 && runstart>20100 && runstop<45100) 809 continue; 810 811 // Check whether key has changed for this run 812 // (this condition is never true for the first run) 813 if (keys[i-1] == (*row)[i]) 814 continue; 815 816 // Found one block with unique keys, fill values into TExMap 817 // (except if this is the first run processed) 818 if (runstart>0) 819 blocks.Add((ULong_t)blocks.GetSize(), runstart, runstop); 820 821 // This is the runnumber of the first run in the new block 822 runstart=atoi((*row)[0]); 823 824 // These are the keys corresponding to the first run in the new block 825 for (int i=1; i<8; i++) 826 keys[i-1] = (*row)[i]; 827 828 break; 829 } 830 831 // This is the new runnumber of the last run in this block 832 runstop=atoi((*row)[0]); 833 } 834 835 if (runstart!=runstop) 836 { 837 //fill values into TExMap (last value) 838 blocks.Add((ULong_t)blocks.GetSize(), runstart, runstop); 839 } 840 } 787 841 788 842 // … … 811 865 day.Data(), day.Data())); 812 866 867 TString elts = "fSourceKEY"; 868 TString eltp2 = "fProjectKEY"; 869 813 870 //get all values from the database, that are relevant for building sequences 814 TString query(Form("SELECT fRunNumber, fSourceKEY, fProjectKEY, fHvSettingsKEY, fLightConditionsKEY, fDiscriminatorThresholdTableKEY, fTriggerDelayTableKEY, fObservationModeKEY FROM RunData WHERE %s AND fExcludedFDAKEY=1 order by fRunNumber", cond.Data())); 871 TString query("SELECT fRunNumber, "); 872 query += elts; 873 query += ", "; 874 query += eltp2; 875 query += Form(", fHvSettingsKEY, fLightConditionsKEY, fDiscriminatorThresholdTableKEY, " 876 "fTriggerDelayTableKEY, fObservationModeKEY FROM RunData " 877 "WHERE %s AND fExcludedFDAKEY=1 order by fRunNumber", cond.Data()); 815 878 816 879 TSQLResult *res = serv.Query(query); … … 818 881 return 2; 819 882 820 //build blocks of runs, which have the same values821 //for each block the first and the last run are stored in a TExMap822 //the values are checked with the help of an array of TStrings823 TString keys[7]= { "NULL", "NULL", "NULL", "NULL", "NULL", "NULL" , "NULL" };824 TString stop = "NULL";825 TString runstart = "NULL";826 TString runstop = "NULL";827 Int_t count = 0;828 883 TExMap blocks; 829 Int_t runbegin; 830 Int_t runend; 831 832 TSQLRow *row=0; 833 while ((row=res->Next())) 834 { 835 if (count==0) 836 { 837 for (Int_t i=1 ; i<8 ; i++) 838 keys[i-1]=(*row)[i]; 839 runstart=(*row)[0]; 840 } 841 842 for (Int_t i=1 ; i<8 ; i++) 843 { 844 runbegin=atoi(runstart.Data()); 845 runend=atoi(runstop.Data()); 846 if (i==2 && runbegin>20100 && runend<45100) 847 continue; 848 849 TString value=(*row)[i]; 850 TString key=keys[i-1]; 851 if (!value.CompareTo(key)) 852 continue; 853 854 keys[i-1]=value; 855 //fill values into TExMap 856 blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend); 857 runstart=(*row)[0]; 858 for (Int_t i=1 ; i<8 ; i++) 859 keys[i-1]=(*row)[i]; 860 break; 861 } 862 runstop=(*row)[0]; 863 count++; 864 } 865 866 //fill values into TExMap (last value) 867 runbegin=atoi(runstart.Data()); 868 runend=atoi(runstop.Data()); 869 blocks.Add((ULong_t)blocks.GetSize(), (Long_t)runbegin, (Long_t)runend); 870 884 buildblocks(res, blocks); 885 delete res; 886 887 // --- 888 // Now the blocks containing the same observation conditions 889 // are created... 890 // --- 871 891 872 892 //get list of current sequence of this night from the database and store it in sequlist … … 874 894 query=Form("SELECT fSequenceFirst FROM Sequences WHERE fManuallyChangedKEY=1 AND %s order by fSequenceFirst", 875 895 cond.Data()); 876 // cout << "Q: " << query << endl;877 896 878 897 res = serv.Query(query); … … 880 899 return 2; 881 900 882 cout << "old sequences: " << flush; 901 cout << "Old sequences: " << flush; 902 TSQLRow *row=0; 883 903 while ((row=res->Next())) 884 904 { … … 888 908 } 889 909 cout << endl; 910 911 delete res; 890 912 891 913 Bool_t rc = kTRUE; … … 896 918 while (nblocks.Next(key, val)) 897 919 { 898 Int_t runstart2 = (Int_t)key; 899 Int_t runstop2 = (Int_t)val; 900 cout << endl << "datablock from " << runstart2 << " to " << runstop2 << endl; 901 902 if (!Process(serv, datapath, sequpath, runstart2, runstop2, sequlist, dummy)) 920 const Int_t runstart = (Int_t)key; 921 const Int_t runstop = (Int_t)val; 922 923 cout << endl << "Datablock from " << runstart << " to " << runstop << ":" << endl; 924 925 if (!Process(serv, datapath, sequpath, runstart, runstop, sequlist, dummy)) 903 926 rc = kFALSE; 904 927 … … 912 935 while ((obj=Next())) 913 936 { 914 cout << " sequ:" << obj->GetName() << " deleting... " << endl;937 cout << " - Sequence " << obj->GetName() << " deleting... " << endl; 915 938 if (!DeleteSequence(serv, datapath, sequpath, atoi(obj->GetName()), dummy)) 916 939 return 2; … … 947 970 { 948 971 date=(*row)[0]; 949 cout << "date: " << date << endl;950 972 buildsequenceentries(date, datapath, sequpath, dummy); 951 973 } 974 975 delete res; 952 976 953 977 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.