Changeset 9002 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 07/17/08 12:59:54 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MSequence.cc
r8999 r9002 170 170 // + fExclRunsSub 171 171 // 172 // Class Version 6: 173 // ---------------- 174 // + fTelescope 175 // 172 176 ///////////////////////////////////////////////////////////////////////////// 173 177 #include "MSequenceSQL.h" … … 514 518 TString MSequence::GetFileName(UInt_t i, const TArrayI &arr, const TArrayI &sub, FileType_t type) const 515 519 { 516 const Int_t tel = 1; 517 return InflateRunName(fNight, arr[i]>999999?tel:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type); 520 return InflateRunName(fNight, arr[i]>999999?fTelescope:0, fMonteCarlo?-arr[i]:arr[i], sub.GetSize()>0?sub[i]:0, type); 518 521 } 519 522 … … 652 655 fSequence = (UInt_t)-1; 653 656 657 654 658 const TString prefix = Form("Sequence%08d", fSequence); 655 659 660 fTelescope = GetEnvValue2(env, prefix, "Telescope", 1); 656 661 fLastRun = GetEnvValue2(env, prefix, "LastRun", -1); 657 662 fNumEvents = GetEnvValue2(env, prefix, "NumEvents", -1); … … 695 700 } 696 701 697 MSequence::MSequence(const char *fname, UInt_t seq )698 { 699 *this = MSequenceSQL(fname, seq );702 MSequence::MSequence(const char *fname, UInt_t seq, UShort_t tel) 703 { 704 *this = MSequenceSQL(fname, seq, tel); 700 705 } 701 706 … … 913 918 if (pre.IsNull()) 914 919 out << "Sequence: " << fSequence << endl; 920 if (fTelescope!=1) 921 out << "Telescope: " << fTelescope << endl; 915 922 if (fMonteCarlo) 916 923 out << pre << "MonteCarlo: Yes" << endl; -
trunk/MagicSoft/Mars/mjobs/MSequence.h
r8999 r9002 26 26 TString fDataPath; // Path to data files 27 27 28 UInt_t fSequence; // Sequence number 29 30 // FIXME: UShort_t fTelescopeNumber ??? 28 UShort_t fTelescope; // Telescope number 29 UInt_t fSequence; // Sequence number 31 30 32 31 MTime fStart; // Start time of sequence … … 94 93 95 94 public: 96 MSequence() : f Sequence((UInt_t)-1), fLastRun((UInt_t)-1),95 MSequence() : fTelescope(0), fSequence((UInt_t)-1), fLastRun((UInt_t)-1), 97 96 fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE) 98 97 { … … 101 100 } 102 101 MSequence(const char *fname, const char *path="", UInt_t id=(UInt_t)-1); 103 MSequence(const char *fname, UInt_t seq );102 MSequence(const char *fname, UInt_t seq, UShort_t tel=1); 104 103 MSequence(const MSequence &s) : MParContainer(s), 105 104 fFileName(s.fFileName), fDataPath(s.fDataPath), 105 fTelescope(s.fTelescope), 106 106 fSequence(s.fSequence), fStart(s.fStart), 107 107 fLastRun(s.fLastRun), fNumEvents(s.fNumEvents), fPeriod(s.fPeriod), … … 125 125 126 126 // Genaral interface 127 Bool_t IsValid() const { return f Sequence!=(UInt_t)-1; }127 Bool_t IsValid() const { return fTelescope>0 && fSequence!=(UInt_t)-1; } 128 128 Bool_t IsMonteCarlo() const { return fMonteCarlo; } 129 129 Bool_t IsExcluded(UInt_t run, UInt_t file) const { return IsContained(fExclRuns, fExclRunsSub, run, file); } … … 146 146 UInt_t GetNumExclRuns() const { return fExclRuns.GetSize(); } 147 147 148 UShort_t GetTelescope() const { return fTelescope; } 148 149 UInt_t GetSequence() const { return fSequence; } 149 150 UInt_t GetLastRun() const { return fLastRun; } … … 186 187 static TString InflateRunPath(const MTime &night, Bool_t mc=kFALSE); 187 188 188 ClassDef(MSequence, 5) // Describes a sequences, reads and writes sequence files189 ClassDef(MSequence, 6) // Describes a sequences, reads and writes sequence files 189 190 }; 190 191 -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.cc
r8996 r9002 91 91 while ((row = res->Next()) && evts<nevts) 92 92 { 93 AddFile(atoi((*row)[0]), 0, type);94 evts += atoi((*row)[ 1]);93 AddFile(atoi((*row)[0]), atoi((*row)[1]), type); 94 evts += atoi((*row)[2]); 95 95 cnt++; 96 96 } … … 178 178 179 179 // Now prepare queries to request the runs from the database 180 TString where(Form(" FROM RunData WHERE fSequenceFirst=%d AND fExcludedFDAKEY=1" 181 " AND fRunTypeKEY%%s", fSequence)); 182 183 const TString query1(Form("SELECT fRunNumber, fNumEvents %s", where.Data())); 180 TString where(Form(" FROM RunData WHERE" 181 " fTelescopeTelescope=%d AND fSequenceFirst=%d AND" 182 " fExcludedFDAKEY=1 AND fRunTypeKEY%%s", 183 fTelescope, fSequence)); 184 185 const TString query1(Form("SELECT fRunNumber, fFileNumber, fNumEvents %s", where.Data())); 184 186 const TString query2(Form("SELECT fRunStart, fRunStop %s", where.Data())); 185 187 186 const TString queryA(Form(query1.Data(), " BETWEEN 2 AND 4 ORDER BY fRunNumber "));187 const TString queryC(Form(query1.Data(), "=4 ORDER BY fRunNumber "));188 const TString queryD(Form(query1.Data(), "=2 ORDER BY fRunNumber "));189 const TString queryT(Form(query2.Data(), "=4 ORDER BY fRunNumber LIMIT 1"));188 const TString queryA(Form(query1.Data(), " BETWEEN 2 AND 4 ORDER BY fRunNumber*1000+fFileNumber")); 189 const TString queryC(Form(query1.Data(), "=4 ORDER BY fRunNumber*1000+fFileNumber")); 190 const TString queryD(Form(query1.Data(), "=2 ORDER BY fRunNumber*1000+fFileNumber")); 191 const TString queryT(Form(query2.Data(), "=4 ORDER BY fRunNumber*1000+fFileNumber LIMIT 1")); 190 192 191 193 // Try to get a valid time for the first calibration run … … 266 268 // kTrue in case of success. 267 269 // 268 Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, Int_t sequno )270 Bool_t MSequenceSQL::GetFromDatabase(MSQLMagic &serv, Int_t sequno, Int_t tel) 269 271 { 270 272 // Check if we are connected to the sql server … … 275 277 } 276 278 277 // check if any sequence number os avlid 279 // check if any telescope number is avlid 280 if (tel<=0 && fTelescope<=0) 281 { 282 *fLog << err << "ERROR - No telescope number given in GetSeqFromDatabase." << endl; 283 return kFALSE; 284 } 285 286 // check if any sequence number is avlid 278 287 if (sequno<0 && fSequence<0) 279 288 { … … 284 293 // set "filename" and sequence number 285 294 fFileName = serv.GetName(); 295 if (tel>0) 296 fTelescope = tel; 286 297 if (sequno>=0) 287 298 fSequence = sequno; … … 292 303 " fLightConditionsKEY, fRunStart, fNumEvents, " 293 304 " fZenithDistanceMin, fZenithDistanceMax " 294 " FROM Sequences WHERE fSequenceFirst="); 295 query += fSequence; 305 " FROM Sequences WHERE "); 306 query += Form("fTelescopeNumber=%d AND fSequenceFirst=%d", 307 fTelescope, fSequence); 296 308 297 309 // Request information from database … … 302 314 // invalidate sequence if retrieval failed 303 315 if (!rc) 304 fSequence = (UInt_t)-1; 316 { 317 fTelescope = 0; 318 fSequence = (UInt_t)-1; 319 } 305 320 306 321 // return result … … 330 345 // kTrue in case of success. 331 346 // 332 Bool_t MSequenceSQL::GetFromDatabase(const char *rc, Int_t sequno )347 Bool_t MSequenceSQL::GetFromDatabase(const char *rc, Int_t sequno, Int_t tel) 333 348 { 334 349 MSQLMagic serv(rc); 335 return GetFromDatabase(serv, sequno );336 } 350 return GetFromDatabase(serv, sequno, tel); 351 } -
trunk/MagicSoft/Mars/mjobs/MSequenceSQL.h
r8996 r9002 20 20 21 21 public: 22 MSequenceSQL(MSQLMagic &serv, Int_t seqno=-1 ) { GetFromDatabase(serv, seqno); }23 MSequenceSQL(const char *rc, Int_t seqno=-1 ) { GetFromDatabase(rc, seqno); }24 MSequenceSQL(Int_t seqno=-1 ) { GetFromDatabase(seqno); }22 MSequenceSQL(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1) { GetFromDatabase(serv, seqno, tel); } 23 MSequenceSQL(const char *rc, Int_t seqno=-1, Int_t tel=-1) { GetFromDatabase(rc, seqno, tel); } 24 MSequenceSQL(Int_t seqno=-1, Int_t tel=-1) { GetFromDatabase(seqno, tel); } 25 25 26 Bool_t GetFromDatabase(MSQLMagic &serv, Int_t seqno=-1 );27 Bool_t GetFromDatabase(const char *rc, Int_t seqno=-1 );28 Bool_t GetFromDatabase(Int_t seqno=-1 ) { return GetFromDatabase("sql.rc", seqno); }26 Bool_t GetFromDatabase(MSQLMagic &serv, Int_t seqno=-1, Int_t tel=-1); 27 Bool_t GetFromDatabase(const char *rc, Int_t seqno=-1, Int_t tel=-1); 28 Bool_t GetFromDatabase(Int_t seqno=-1, Int_t tel=-1) { return GetFromDatabase("sql.rc", seqno, tel); } 29 29 30 30 ClassDef(MSequenceSQL, 0) // Extension of MSequence to get a sequence from a database
Note:
See TracChangeset
for help on using the changeset viewer.