Changeset 8644 for trunk/MagicSoft/Mars/mjobs
- Timestamp:
- 07/24/07 14:36:39 (17 years ago)
- Location:
- trunk/MagicSoft/Mars/mjobs
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJCut.cc
r8636 r8644 553 553 554 554 // -------------------------------------------------------------------------------- 555 556 if (!set.IsWobbleMode() && fNumOffSourcePos!=1) 557 { 558 *fLog << inf << "No wobble mode but NumOffSoucePos!=1 (" << fNumOffSourcePos << ")... reset to 1." << endl; 559 fNumOffSourcePos = 1; 560 } 555 561 556 562 // Possible source position (eg. Wobble Mode) -
trunk/MagicSoft/Mars/mjobs/MJob.cc
r8587 r8644 18 18 ! Author(s): Thomas Bretz, 8/2004 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200 420 ! Copyright: MAGIC Software Development, 2000-2007 21 21 ! 22 22 ! … … 34 34 // SetDebugEnv(3) // do 2) and debug setting env completely 35 35 // 36 // To allow overwriting the output files call SetOverwrite() 37 // 36 38 ///////////////////////////////////////////////////////////////////////////// 37 39 #include "MJob.h" … … 66 68 } 67 69 70 //------------------------------------------------------------------------ 71 // 72 // If MJob is the owner of fEnv delete fEnv. 73 // 74 // Reset the owenership bit. 75 // 76 // Set fEnv to NULL. 77 // 68 78 void MJob::ClearEnv() 69 79 { … … 74 84 } 75 85 86 //------------------------------------------------------------------------ 87 // 88 // ClearEnv() 89 // 76 90 MJob::~MJob() 77 91 { … … 79 93 } 80 94 81 Bool_t MJob::SetEnv(const char *env, const char *prefix) 82 { 83 ClearEnv(); 84 85 fEnv = new MEnv(env); 86 SetBit(kIsOwner); 87 88 if (!fEnv->IsValid()) 89 { 90 ClearEnv(); 91 return kFALSE; 92 } 93 95 //------------------------------------------------------------------------ 96 // 97 // If prefix==0 the prefix is taken from fName up to the first 98 // whitespace. 99 // 100 // A trailing dot is removed.void MJob::SetPrefix(const char *prefix) 101 void MJob::SetPrefix(const char *prefix) 102 { 94 103 fEnvPrefix = prefix; 104 95 105 if (!prefix) 96 106 fEnvPrefix = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName; … … 98 108 if (fEnvPrefix.EndsWith(".")) 99 109 fEnvPrefix.Remove(fEnvPrefix.Length()-1); 100 101 return kTRUE; 102 } 103 110 } 111 112 //------------------------------------------------------------------------ 113 // 114 // Create a new MEnv from the file env. MJob takes of course the 115 // ownership of the newly created MEnv. 116 // 117 // SetPrefix(prefix) 118 // 119 // return kFALSE if MEnv is invalid 120 // 121 Bool_t MJob::SetEnv(const char *env, const char *prefix) 122 { 123 SetEnv(new MEnv(env), prefix); 124 125 // Take the owenership of the MEnv instance 126 SetBit(kIsOwner); 127 128 return fEnv->IsValid(); 129 } 130 131 //------------------------------------------------------------------------ 132 // 133 // Set a new fEnv and a new general prefix. 134 // 135 // Calls SetPrefix(prefix) 136 // 137 // MJob does not take the owenership of the MEnv instance. 138 // 104 139 void MJob::SetEnv(MEnv *env, const char *prefix) 105 140 { … … 108 143 fEnv = env; 109 144 110 fEnvPrefix = prefix; 111 if (!prefix) 112 fEnvPrefix = fName.First(' ')>0 ? fName(0, fName.First(' ')) : fName; 113 114 if (fEnvPrefix.EndsWith(".")) 115 fEnvPrefix.Remove(fEnvPrefix.Length()-1); 116 } 117 118 void MJob::FixPath(TString &path) const 145 SetPrefix(prefix); 146 } 147 148 //------------------------------------------------------------------------ 149 // 150 // Removes LF's from the path (necessary if the resource file was written 151 // with a different operating system than Linux. 152 // 153 // Removes a trailing slash if the path is not the root-path. 154 // 155 // Adds fname to the path if given. 156 // 157 void MJob::FixPath(TString &path) 119 158 { 120 159 path.ReplaceAll("\015", ""); … … 127 166 } 128 167 168 //------------------------------------------------------------------------ 169 // 170 // Calls FixPath 171 // 172 // Adds fname to the path if given. 173 // 174 TString MJob::CombinePath(TString path, TString fname) 175 { 176 FixPath(path); 177 178 if (fname.IsNull()) 179 return path; 180 181 if (path!=(TString)"/") 182 path += "/"; 183 184 path += fname; 185 186 return path; 187 } 188 189 //------------------------------------------------------------------------ 190 // 191 // Sets the output path. The exact meaning (could also be a file) is 192 // deined by the derived class. 193 // 129 194 void MJob::SetPathOut(const char *path) 130 195 { … … 133 198 } 134 199 200 //------------------------------------------------------------------------ 201 // 202 // Sets the input path. The exact meaning (could also be a file) is 203 // deined by the derived class. 204 // 135 205 void MJob::SetPathIn(const char *path) 136 206 { … … 139 209 } 140 210 211 //------------------------------------------------------------------------ 212 // 213 // Returns the TEnv 214 // 141 215 const TEnv *MJob::GetEnv() const 142 216 { … … 144 218 } 145 219 220 //------------------------------------------------------------------------ 221 // 222 // Checks GetEnvValue(*fEnv, fEnvPrefix, name, dftl) 223 // For details see MParContainer 224 // 146 225 Int_t MJob::GetEnv(const char *name, Int_t dflt) const 147 226 { … … 149 228 } 150 229 230 //------------------------------------------------------------------------ 231 // 232 // Checks GetEnvValue(*fEnv, fEnvPrefix, name, dftl) 233 // For details see MParContainer 234 // 151 235 Double_t MJob::GetEnv(const char *name, Double_t dflt) const 152 236 { … … 154 238 } 155 239 240 //------------------------------------------------------------------------ 241 // 242 // Checks GetEnvValue(*fEnv, fEnvPrefix, name, dftl) 243 // For details see MParContainer 244 // 156 245 const char *MJob::GetEnv(const char *name, const char *dflt) const 157 246 { … … 159 248 } 160 249 250 //------------------------------------------------------------------------ 251 // 252 // Checks IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug>2) 253 // For details see MParContainer 254 // 161 255 Bool_t MJob::HasEnv(const char *name) const 162 256 { … … 164 258 } 165 259 260 //------------------------------------------------------------------------ 261 // 262 // Check the resource file for 263 // PathOut 264 // PathIn 265 // MaxEvents 266 // Overwrite 267 // EnvDebug 268 // 269 // and call the virtual function CheckEnvLocal 270 // 166 271 Bool_t MJob::CheckEnv() 167 272 { … … 202 307 } 203 308 309 //------------------------------------------------------------------------ 310 // 311 // Call the eventsloops ReadEnv and print untouched resources afterwards 312 // if fEnvDebug>1 313 // 204 314 Bool_t MJob::SetupEnv(MEvtLoop &loop) const 205 315 { … … 214 324 215 325 return kTRUE; 326 } 327 328 //------------------------------------------------------------------------ 329 // 330 // Checks whether write permissions to fname exists including 331 // the fOverwrite data amember. 332 // 333 Bool_t MJob::HasWritePermission(TString fname) const 334 { 335 gSystem->ExpandPathName(fname); 336 337 const Bool_t exists = !gSystem->AccessPathName(fname, kFileExists); 338 if (!exists) 339 return kTRUE; 340 341 const Bool_t write = !gSystem->AccessPathName(fname, kWritePermission); 342 if (!write) 343 { 344 *fLog << err << "ERROR - No permission to write to " << fname << endl; 345 return kFALSE; 346 } 347 348 if (!fOverwrite) 349 return kTRUE; 350 351 *fLog << err; 352 *fLog << "ERROR - File " << fname << " already exists and overwrite not allowed." << endl; 353 354 return kFALSE; 216 355 } 217 356 … … 274 413 //------------------------------------------------------------------------ 275 414 // 276 // Write containers in cont (and - if available) the status display to277 // fPathOut+"/"+name415 // Write containers in cont to fPathOut+"/"+name, or fPathOut only 416 // if name is empty. 278 417 // 279 418 Bool_t MJob::WriteContainer(TCollection &cont, const char *name, const char *option, const int compr) const … … 285 424 } 286 425 287 TString oname(fPathOut); 288 if (!TString(name).IsNull()) 289 { 290 if (oname!="/") 291 oname += "/"; 292 oname += name; 293 } 426 const TString oname = CombinePath(fPathOut, name); 294 427 295 428 *fLog << inf << "Writing to file: " << oname << endl; 296 429 297 TString title("File Written by ");430 TString title("File written by "); 298 431 title += fName; 299 432 … … 308 441 } 309 442 443 //------------------------------------------------------------------------ 444 // 445 // return kTRUE if no display is set. 446 // 447 // Write the display to the TFile with name name, options option and 448 // compression level comp. 449 // 450 // If name IsNull fPathOut is assumed to contain the name, otherwise 451 // name is appended to fPathOut. fPathOut might be null. 452 // 310 453 Bool_t MJob::WriteDisplay(const char *name, const char *option, const int compr) const 311 454 { … … 348 491 349 492 // check if path ends with a slash 350 if (!path.EndsWith("/")) 351 path += "/"; 352 353 // compile full qualified path 354 path += fname; 493 path = CombinePath(path, fname); 355 494 356 495 gLog << dbg << "MJob::ExpandPath - Filename expanded to " << path << endl; … … 360 499 } 361 500 501 //------------------------------------------------------------------------ 502 // 503 // Sorts the array. 504 // 362 505 void MJob::SortArray(TArrayI &arr) 363 506 { -
trunk/MagicSoft/Mars/mjobs/MJob.h
r8518 r8644 14 14 enum { kIsOwner = BIT(14) }; 15 15 16 void FixPath(TString &path) const; 16 // Helper functions for paths 17 static TString CombinePath(TString path, TString fname); 18 static void FixPath(TString &path); 19 20 // Helper functions to set a new fEnv 21 void SetPrefix(const char *prefix); 17 22 void ClearEnv(); 18 23 24 // Data members for resource files 19 25 const MEnv *fEnv; // Resource file 20 26 TString fEnvPrefix; // Prefix for resources … … 28 34 Int_t fMaxEvents; // Maximum number of events 29 35 36 // FIXME: Split into MJobSequence and MJobDataSet 30 37 MSequence fSequence; // Sequence 31 38 … … 71 78 TString GetPathIn() const { return fPathIn; } 72 79 80 Bool_t HasWritePermission(TString fname) const; 81 73 82 // Others 74 83 MStatusDisplay *GetDisplay() { return fDisplay; }
Note:
See TracChangeset
for help on using the changeset viewer.