Changeset 8052
- Timestamp:
- 10/11/06 19:27:39 (18 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8051 r8052 59 59 * mbase/MLogHtml.cc: 60 60 - fixed a bug which caused the output to be totally corrupted 61 62 * datacenter/macros/writesequencefile.C: 63 - implemented again that the 1000 pedestal events are taken which 64 are next to the calibration run 61 65 62 66 -
trunk/MagicSoft/Mars/datacenter/macros/writesequencefile.C
r8046 r8052 57 57 #include "MDirIter.h" 58 58 59 #include "MSQL Server.h"59 #include "MSQLMagic.h" 60 60 61 61 using namespace std; 62 62 63 Bool_t GetRuns(MSQLServer &serv, ofstream &fout, TString query, TString name )63 Bool_t GetRuns(MSQLServer &serv, ofstream &fout, TString query, TString name, UInt_t nevts=(UInt_t)-1) 64 64 { 65 65 TSQLResult *res = serv.Query(query); … … 67 67 return kFALSE; 68 68 69 Int_t cnt=0; 69 UInt_t cnt=0; 70 UInt_t evts=0; 70 71 71 72 fout << name << ":"; 72 73 TSQLRow *row=0; 73 while ((row = res->Next()) )74 while ((row = res->Next()) && evts<nevts) 74 75 { 75 76 fout << " " << (*row)[0]; 77 evts += atoi((*row)[1]); 76 78 cnt++; 77 79 } … … 89 91 } 90 92 91 TString GetName(MSQLServer &serv, const char *col, const char *n) 92 { 93 TString query(Form("SELECT f%sName FROM %s WHERE f%sKEY=%s", 94 col, col, col, n)); 95 96 TSQLResult *res = serv.Query(query); 93 TString GetTime(const char *type) 94 { 95 return Form("if(TIME_TO_SEC(fRun%s)<12*60*60," 96 " TIME_TO_SEC(fRun%s)+24*60*60," 97 " TIME_TO_SEC(fRun%s))", type, type, type); 98 } 99 100 Int_t GetTimeC(MSQLServer &serv, const TString &str) 101 { 102 TSQLResult *res = serv.Query(str); 97 103 if (!res) 98 { 99 cout << "ERROR - Resolving " << col << " failed! " << endl; 100 return ""; 101 } 102 103 TSQLRow *row = res->Next(); 104 return -1; 105 106 TSQLRow *row=res->Next(); 104 107 if (!row) 105 108 { 106 cout << "ERROR - No name in " << col << " for key " << n << endl; 107 return ""; 108 } 109 110 return (*row)[0]; 111 } 112 113 Bool_t GetSequence(MSQLServer &serv, TSQLRow &data, TString sequpath) 109 delete res; 110 return -1; 111 } 112 113 Int_t rc = (*row)[0] ? atoi((*row)[0]) : -1; 114 delete res; 115 return rc; 116 } 117 118 Bool_t GetSequence(MSQLMagic &serv, TSQLRow &data, TString sequpath) 114 119 { 115 120 UShort_t y; … … 125 130 126 131 TString str[6]; 127 str[0] = GetName(serv,"Project", data[2]);128 str[1] = GetName(serv,"Source", data[3]);129 str[2] = GetName(serv,"L1TriggerTable", data[4]);130 str[3] = GetName(serv,"L2TriggerTable", data[5]);131 str[4] = GetName(serv,"HvSettings", data[6]);132 str[5] = GetName(serv,"LightConditions", data[7]);132 str[0] = serv.QueryNameOfKey("Project", data[2]); 133 str[1] = serv.QueryNameOfKey("Source", data[3]); 134 str[2] = serv.QueryNameOfKey("L1TriggerTable", data[4]); 135 str[3] = serv.QueryNameOfKey("L2TriggerTable", data[5]); 136 str[4] = serv.QueryNameOfKey("HvSettings", data[6]); 137 str[5] = serv.QueryNameOfKey("LightConditions", data[7]); 133 138 134 139 if (str[0].IsNull() || str[1].IsNull() || str[2].IsNull() || str[3].IsNull() || str[4].IsNull() || str[5].IsNull()) … … 164 169 fout << endl; 165 170 166 TString query(Form("SELECT fRunNumber, fRunTypeKEY, fRunStart, fRunStop, fNumEvents" 167 " FROM RunData WHERE fSequenceFirst=%s AND fExcludedFDAKEY=1" 168 " AND fRunTypeKEY %%s ORDER BY fRunNumber", 169 data[0])); 170 171 172 TString queryA(Form(query.Data(), "BETWEEN 2 AND 4")); 173 TString queryC(Form(query.Data(), "BETWEEN 4 AND 4")); 174 TString queryD(Form(query.Data(), "BETWEEN 2 AND 2")); 175 TString queryP(Form(query.Data(), "BETWEEN 3 AND 3")); 171 TString where(Form(" FROM RunData WHERE fSequenceFirst=%s AND fExcludedFDAKEY=1" 172 " AND fRunTypeKEY%%s", data[0])); 173 174 TString query1(Form("SELECT fRunNumber, fNumEvents %s", where.Data())); 175 TString query2(Form("SELECT %s %s", GetTime("Start").Data(), where.Data())); 176 TString query3(Form("SELECT %s %s", GetTime("Stop").Data(), where.Data())); 177 178 TString queryA(Form(query1.Data(), " BETWEEN 2 AND 4 ORDER BY fRunNumber")); 179 TString queryC(Form(query1.Data(), "=4 ORDER BY fRunNumber")); 180 TString queryD(Form(query1.Data(), "=2 ORDER BY fRunNumber")); 181 TString queryT(Form(query2.Data(), "=4 ORDER BY fRunNumber LIMIT 1")); 182 183 Int_t timec = GetTimeC(serv, queryT); 184 if (timec<0) 185 { 186 cout << "WARNING - Requesting start time of first calibration run failed." << endl; 187 queryT = Form(query3.Data(), "=4 ORDER BY fRunNumber LIMIT 1"); 188 timec = GetTimeC(serv, queryT); 189 if (timec<0) 190 { 191 cout << "ERROR - Neither start nor stop time of first calibration could be requested." << endl; 192 return kFALSE; 193 } 194 } 195 196 TString query4(Form("=3 ORDER BY ABS(%s-%d) ASC", GetTime("Stop").Data(), timec)); 197 TString queryP(Form(query1.Data(), query4.Data())); 176 198 177 199 //write runs into sequence file … … 183 205 if (!GetRuns(serv, fout, queryC, "CalRuns")) 184 206 return kFALSE; 185 if (!GetRuns(serv, fout, queryP, "PedRuns" ))207 if (!GetRuns(serv, fout, queryP, "PedRuns", 1000)) 186 208 return kFALSE; 187 209 if (!GetRuns(serv, fout, queryD, "DatRuns")) … … 200 222 TEnv env("sql.rc"); 201 223 202 MSQL Serverserv(env);224 MSQLMagic serv(env); 203 225 if (!serv.IsConnected()) 204 226 {
Note:
See TracChangeset
for help on using the changeset viewer.