Changeset 8065 for trunk/MagicSoft/Mars/datacenter/macros
- Timestamp:
- 10/14/06 19:16:21 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/datacenter/macros/buildsequenceentries.C
r8010 r8065 259 259 TList fListRegexp; 260 260 261 /*262 TString GetKeyName(TString col, TString key)263 {264 col(TRegexp("^Elt")) = "";265 return QueryNameOfKey(col, key, kFALSE);266 }*/267 268 261 Int_t CheckTransition(TSQLResult &res, const TString *keys, TSQLRow &row, Int_t i) 269 262 { … … 330 323 delete res; 331 324 325 const TString elts = GetELTSource(where); 326 if (elts.IsNull()) 327 return kFALSE; 328 329 const TString eltp = GetELTProject(where); 330 if (eltp.IsNull()) 331 return kFALSE; 332 332 333 // ========== Request data of sequence ========== 333 query = Form("SELECT fSourceKEY, fProjectKEY, " 334 " fL1TriggerTableKEY, fL2TriggerTableKEY," 335 " fHvSettingsKEY, fDiscriminatorThresholdTableKEY," 336 " fTriggerDelayTableKEY, fObservationModeKEY " 337 " FROM RunData WHERE fRunTypeKEY=2 AND %s" 338 " LIMIT 1", where.Data()); 334 query = "SELECT "; 335 query += elts; 336 query += ", "; 337 query += eltp; 338 query += ", fL1TriggerTableKEY, fL2TriggerTableKEY," 339 " fHvSettingsKEY, fDiscriminatorThresholdTableKEY," 340 " fTriggerDelayTableKEY, fObservationModeKEY " 341 " FROM RunData WHERE fRunTypeKEY=2 AND "; 342 query += where; 343 query += " LIMIT 1"; 339 344 340 345 res = Query(query); … … 692 697 } 693 698 699 TString GetELTQuery(const char *col, const char *cond) const 700 { 701 return Form("SELECT RunData.f%sKEY, f%sName FROM RunData " 702 "LEFT JOIN %s ON RunData.f%sKEY=%s.f%sKEY " 703 "WHERE %s GROUP BY f%sName", 704 col, col, col, col, col, col, cond, col); 705 } 706 707 TString GetELTSource(const char *cond) 708 { 709 //query all sources observed in this night 710 TSQLResult *resx = Query(GetELTQuery("Source", cond)); 711 if (!resx) 712 return ""; 713 714 // In the case there is only a single source 715 // do not replace the source key by the ELT 716 if (resx->GetRowCount()==1) 717 return "fSourceKEY"; 718 719 TString elts = GetELT("Source", resx, "\\-?W[1-9][ abc]?$"); 720 delete resx; 721 722 return elts; 723 } 724 725 TString GetELTProject(const char *cond) 726 { 727 //query all project names observed in this night 728 TSQLResult *resx = Query(GetELTQuery("Project", cond)); 729 if (!resx) 730 return ""; 731 732 // In the case there is only a single project 733 // do not replace the project key by the ELT 734 if (resx->GetRowCount()==1) 735 return "fProjectKEY"; 736 737 TList regexp; 738 regexp.Add(new TObjString("\\-?W[1-9][abc]?$")); 739 regexp.Add(new TObjString("\\-W[0-9]\\.[0-9][0-9]\\+[0-9][0-9][0-9]$")); 740 741 TString eltp2 = GetELT("Project", resx, regexp); 742 delete resx; 743 regexp.Delete(); 744 745 return eltp2; 746 } 747 694 748 Bool_t HasAtLeastOne(TString src, TString chk) const 695 749 { … … 1042 1096 fMap.DeleteAll(); 1043 1097 } 1044 /* 1045 SequenceBuild(SequenceBuild &sb) : MSQLServer(sb) 1046 { 1047 fPathRawData = sb.fPathRawData; 1048 fPathSequences = sb.fPathSequences; 1049 }*/ 1098 1050 1099 void SetPathRawData(const char *path) { fPathRawData=path; } 1051 1100 void SetPathSequences(const char *path) { fPathSequences=path; } … … 1059 1108 const TString cond = 1060 1109 Form("(fRunStart>ADDDATE(\"%s\", INTERVAL -1 DAY) AND fRunStart<\"%s\") " 1061 "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 " 1062 "ORDER BY fRunNumber", 1110 "AND fExcludedFDAKEY=1 AND fRunTypeKEY BETWEEN 2 AND 4 ", 1063 1111 day.Data(), day.Data()); 1064 1112 1065 1066 1067 1113 //query all sources observed in this night 1068 TString querys(Form("SELECT RunData.fSourceKEY, fSourceName FROM RunData " 1069 "LEFT JOIN Source ON RunData.fSourceKEY=Source.fSourceKEY " 1070 "WHERE %s", cond.Data())); 1071 TSQLResult *resx = Query(querys); 1072 if (!resx) 1073 return 2; 1074 TString elts = GetELT("Source", resx, "\\-?W[1-9][ abc]?$"); 1075 delete resx; 1114 const TString elts = GetELTSource(cond); 1115 if (elts.IsNull()) 1116 return 2; 1076 1117 1077 1118 //query all project names observed in this night 1078 TString queryp(Form("SELECT RunData.fProjectKEY, fProjectName FROM RunData " 1079 "LEFT JOIN Project ON RunData.fProjectKEY=Project.fProjectKEY " 1080 "WHERE %s", cond.Data())); 1081 resx = Query(queryp); 1082 if (!resx) 1083 return 2; 1084 1085 TList regexp; 1086 regexp.Add(new TObjString("\\-?W[1-9][abc]?$")); 1087 regexp.Add(new TObjString("\\-W[0-9]\\.[0-9][0-9]\\+[0-9][0-9][0-9]$")); 1088 TString eltp2 = GetELT("Project", resx, regexp); 1089 delete resx; 1090 regexp.Delete(); 1119 const TString eltp2 = GetELTProject(cond); 1120 if (elts.IsNull()) 1121 return 2; 1091 1122 1092 1123 // Setup query to get all values from the database, … … 1106 1137 query += mapkey->GetName(); 1107 1138 } 1108 query += Form(" FROM RunData WHERE %s ", cond.Data());1139 query += Form(" FROM RunData WHERE %s ORDER BY fRunNumber", cond.Data()); 1109 1140 1110 1141 TSQLResult *res = Query(query);
Note:
See TracChangeset
for help on using the changeset viewer.