Changeset 9244 for trunk/MagicSoft
- Timestamp:
- 01/23/09 15:28:28 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mjobs/MJob.cc
r8882 r9244 40 40 41 41 #include "MEnv.h" 42 42 43 #include <TFile.h> 43 44 #include <TSystem.h> 45 #include <TRandom.h> 44 46 #include <TObjArray.h> 45 47 … … 225 227 Int_t MJob::GetEnv(const char *name, Int_t dflt) const 226 228 { 227 return GetEnvValue (*fEnv, fEnvPrefix, name, dflt); // return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);229 return GetEnvValue2(*fEnv, fEnvPrefix, name, dflt); // return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt); 228 230 } 229 231 … … 235 237 Double_t MJob::GetEnv(const char *name, Double_t dflt) const 236 238 { 237 return GetEnvValue (*fEnv, fEnvPrefix, name, dflt); // return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);239 return GetEnvValue2(*fEnv, fEnvPrefix, name, dflt); // return fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt); 238 240 } 239 241 … … 245 247 const char *MJob::GetEnv(const char *name, const char *dflt) const 246 248 { 247 return GetEnvValue (*fEnv, fEnvPrefix, name, dflt); //fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt);249 return GetEnvValue2(*fEnv, fEnvPrefix, name, dflt); //fEnv->GetValue(Form("%s%s", fEnvPrefix.Data(), name), dflt); 248 250 } 249 251 … … 256 258 { 257 259 return IsEnvDefined(*fEnv, fEnvPrefix, name, fEnvDebug>2);//fEnv->Lookup(Form("%s%s", fEnvPrefix.Data(), name)); 260 } 261 262 //------------------------------------------------------------------------ 263 // 264 // Check fEnv for RadnomNumberGenerator. If it is empty or the 265 // corresponding class does either not exist or not inherit from TRandom, 266 // gRandom remains unchanged. Otherwise gRandom is set to a newly created 267 // instance of this class. 268 // 269 // The second resource which is checked is RandomNumberSeedValue. If it 270 // is empty (not given) the seed keeps unchanged. If a number is given 271 // the seed value of gRandom is set accordingly. (0 means that 272 // the seed value is set accoring to the time, see TRandom::SetSeed()) 273 // 274 // If an error occured kFALSE is returned, kTRUE otherwise. 275 // 276 Bool_t MJob::InitRandomNumberGenerator() const 277 { 278 const TString rng = GetEnv("RandomNumberGenerator", ""); 279 if (!rng.IsNull()) 280 { 281 TClass *cls = MParContainer::GetClass(rng, &gLog); 282 if (!cls) 283 return kFALSE; 284 285 if (!cls->InheritsFrom(TRandom::Class())) 286 { 287 *fLog << err << "ERROR - RandomNumberGenerator " << rng << " doesn't inherit from TRandom." << endl; 288 return kFALSE; 289 } 290 291 delete gRandom; 292 gRandom = static_cast<TRandom*>(cls->New()); 293 294 *fLog << inf << "Random number generator " << rng << " initialized." << endl; 295 } 296 297 // Nothing: Keep seed value, 0 set time as seed value, val set seed 298 const TString seed = GetEnv("RandomNumberSeedNumber", ""); 299 if (!seed.IsNull()) 300 { 301 gRandom->SetSeed(seed.Atoi()); 302 *fLog << inf << "Random number seed value set to " << seed.Atoi() << endl; 303 } 304 305 return kTRUE; 258 306 } 259 307 … … 266 314 // Overwrite 267 315 // EnvDebug 316 // RandomNumberGenerator 317 // RandomNumberSeedValue 268 318 // 269 319 // and call the virtual function CheckEnvLocal … … 273 323 if (!fEnv) 274 324 return kTRUE; 325 326 if (!InitRandomNumberGenerator()) 327 return kFALSE; 275 328 276 329 TString p;
Note:
See TracChangeset
for help on using the changeset viewer.