Changeset 7688 for trunk/MagicSoft/Mars/mhflux
- Timestamp:
- 05/04/06 08:26:21 (19 years ago)
- Location:
- trunk/MagicSoft/Mars/mhflux
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.cc
r7535 r7688 19 19 ! Author(s): Marcos Lopez 10/2003 <mailto:marcos@gae.ucm.es> 20 20 ! 21 ! Copyright: MAGIC Software Development, 2000-200 521 ! Copyright: MAGIC Software Development, 2000-2006 22 22 ! 23 23 ! … … 26 26 ////////////////////////////////////////////////////////////////////////////// 27 27 // 28 // MMc WeightEnergySlopeCalc28 // MMcSpectrumWeight 29 29 // 30 30 // Change the spectrum of the MC showers simulated with Corsika (a power law) … … 104 104 AddToBranchList("MMcEvt.fEnergy"); 105 105 106 fNameWeight = "MWeight"; 107 fNameMcEvt = "MMcEvt"; 108 109 fNewSlope = -1; 110 fOldSlope = -1; 111 112 fEnergyMin = -1; 113 fEnergyMax = -2; 114 115 fNorm = 1; 106 fNameWeight = "MWeight"; 107 fNameMcEvt = "MMcEvt"; 108 109 fNewSlope = -1; 110 fOldSlope = -1; 111 112 fEnergyMin = -1; 113 fEnergyMax = -2; 114 115 fNorm = 1; 116 fNormEnergy = 1; 116 117 117 118 fAllowChange = kFALSE; … … 235 236 // Return the formula to calculate weights. 236 237 // Is is compiled by 237 // o = integral(fEnergyMin, fEnergyMax, GetFormulaSpecOldX()); 238 // n = integral(fEnergyMin, fEnergyMax, GetFormulaSpecNewX()); 239 // 240 // result: fNorm*o/n*GetFormulaNewSpec()/GetFormulaOldSpec() 238 // o1 = integral(fEnergyMin, fEnergyMax, GetFormulaSpecOldX()); 239 // n1 = integral(fEnergyMin, fEnergyMax, GetFormulaSpecNewX()); 240 // o2 = CalcSpecOld(fNormEnergy); 241 // n2 = CalcSpecNew(fNormEnergy); 242 // 243 // result (fNormEnergy<0): 244 // fNorm*o1/n1*GetFormulaNewSpec()/GetFormulaOldSpec() 245 // 246 // result (fNormEnergy>0): 247 // fNorm*o2/n2*GetFormulaNewSpec()/GetFormulaOldSpec() 241 248 // 242 249 // fNorm is 1 by default but can be overwritten using SetNorm() … … 254 261 return Form("%.16f", fNorm); 255 262 256 const Double_t iold = GetSpecOldIntegral();257 const Double_t inew = GetSpecNewIntegral();263 const Double_t iold = fNormEnergy<0 ? GetSpecOldIntegral() : CalcSpecOld(fNormEnergy); 264 const Double_t inew = fNormEnergy<0 ? GetSpecNewIntegral() : CalcSpecNew(fNormEnergy); 258 265 259 266 const Double_t norm = fNorm*iold/inew; … … 282 289 TF1 funcold("Dummy", GetFormulaSpecOldX()); 283 290 return funcold.Integral(fEnergyMin, fEnergyMax); 291 } 292 293 // --------------------------------------------------------------------------- 294 // 295 // Returns the value of GetFormulaSpecNewX() at the energy e describing 296 // the destination spectrum 297 // 298 Double_t MMcSpectrumWeight::CalcSpecNew(Double_t e) const 299 { 300 TF1 funcnew("Dummy", GetFormulaSpecNewX()); 301 return funcnew.Eval(e); 302 } 303 304 // --------------------------------------------------------------------------- 305 // 306 // Returns the value of GetFormulaSpecOldX() at the energy e describing 307 // the simulated spectrum 308 // 309 Double_t MMcSpectrumWeight::CalcSpecOld(Double_t e) const 310 { 311 TF1 funcnew("Dummy", GetFormulaSpecOldX()); 312 return funcnew.Eval(e); 284 313 } 285 314 … … 392 421 *fLog << " New spectral slope: " << fNewSlope << endl; 393 422 *fLog << " User normalization: " << fNorm << endl; 423 *fLog << " Spectra are normalized: " << (fNormEnergy<0?"by integral":Form("at %.1fGeV", fNormEnergy)) << endl; 394 424 *fLog << " Old Spectrum: " << GetFormulaSpecOldX() << " (I=" << GetSpecOldIntegral() << ")" << endl; 395 425 *fLog << " New Spectrum: " << GetFormulaSpecNewX() << " (I=" << GetSpecNewIntegral() << ")" << endl; … … 446 476 // 447 477 // Read the setup from a TEnv, eg: 448 // MMcSpectrumWeight.NewSlope: -2.6 449 // MMcSpectrumWeight.Norm: 1.0 450 // MMcSpectrumWeight.Formula: pow(X, -2.6) 478 // MMcSpectrumWeight.NewSlope: -2.6 479 // MMcSpectrumWeight.Norm: 1.0 480 // MMcSpectrumWeight.NormEnergy: 200 481 // MMcSpectrumWeight.Formula: pow(X, -2.6) 451 482 // 452 483 Int_t MMcSpectrumWeight::ReadEnv(const TEnv &env, TString prefix, Bool_t print) … … 463 494 SetNorm(GetEnvValue(env, prefix, "Norm", fNorm)); 464 495 } 496 if (IsEnvDefined(env, prefix, "NormEnergy", print)) 497 { 498 rc = kTRUE; 499 SetNormEnergy(GetEnvValue(env, prefix, "NormEnergy", fNormEnergy)); 500 } 465 501 if (IsEnvDefined(env, prefix, "Formula", print)) 466 502 { -
trunk/MagicSoft/Mars/mhflux/MMcSpectrumWeight.h
r7174 r7688 40 40 41 41 Double_t fNorm; // Normalization constant (additional normalization constant) 42 Double_t fNormEnergy; // Energy at which the spectra are normalized (default -1 means the integral is used) 42 43 43 44 TString fFormula; // Text Formula for new spectrum: eg. "pow(MMcEvt.fEnergy, -2.0)" … … 66 67 void SetNewSlope(Double_t s=-1) { fNewSlope = s; } 67 68 void SetNorm(Double_t s=1) { fNorm = s; } 69 void SetNormEnergy(Double_t s=1) { fNormEnergy = s; } 68 70 void SetFormula(const char *f="") { fFormula = f; } 69 71 void SetEnergyRange(Double_t min=-2, Double_t max=-1) { fEnergyMin=min; fEnergyMax=max; } … … 71 73 void SetWeightsZd(TH1 *h=0) { fWeightsZd = h; } 72 74 void SetWeightsSize(TH1D *h=0); 75 73 76 Bool_t Set(const MMcCorsikaRunHeader &h); 74 77 … … 85 88 Double_t GetSpecOldIntegral() const; 86 89 90 Double_t CalcSpecNew(Double_t e) const; 91 Double_t CalcSpecOld(Double_t e) const; 92 87 93 Double_t GetEnergyMin() const { return fEnergyMin; } 88 94 Double_t GetEnergyMax() const { return fEnergyMax; }
Note:
See TracChangeset
for help on using the changeset viewer.