Added debug flag.

This commit is contained in:
nemu 2010-02-28 17:58:32 +00:00
parent a5e89b2070
commit 12db37213c
3 changed files with 13 additions and 5 deletions

View File

@ -63,6 +63,7 @@ PSimulateMuTransition::PSimulateMuTransition(UInt_t seed)
fMuonPhase = fInitialPhase; fMuonPhase = fInitialPhase;
fMuonDecayTime = 0.; fMuonDecayTime = 0.;
fAsymmetry = 0.27; fAsymmetry = 0.27;
fDebugFlag = kFALSE;
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@ -167,7 +168,6 @@ Double_t PSimulateMuTransition::NextEventTime(const Double_t &EventRate)
* *
* \param time duration of precession (us); * \param time duration of precession (us);
* \param frequency muon spin precession frequency (MHz); * \param frequency muon spin precession frequency (MHz);
* \param phase initial muon phase (degree);
*/ */
Double_t PSimulateMuTransition::PrecessionPhase(const Double_t &time, const Double_t &frequency) Double_t PSimulateMuTransition::PrecessionPhase(const Double_t &time, const Double_t &frequency)
{ {
@ -197,10 +197,12 @@ void PSimulateMuTransition::Event()
// charge-exchange loop until muon decay // charge-exchange loop until muon decay
eventTime = 0.; eventTime = 0.;
eventDiffTime = 0.; eventDiffTime = 0.;
if (fDebugFlag) cout << "Decay time = " << fMuonDecayTime << endl;
while (1) { while (1) {
// assume Mu+ as initial state; get next electron capture time // assume Mu+ as initial state; get next electron capture time
captureTime = NextEventTime(fCaptureRate); captureTime = NextEventTime(fCaptureRate);
eventTime += captureTime; eventTime += captureTime;
if (fDebugFlag) cout << "Capture time = " << captureTime << " Phase = " << fMuonPhase << endl;
if (eventTime < fMuonDecayTime) if (eventTime < fMuonDecayTime)
fMuonPhase += PrecessionPhase(captureTime, muonPrecessionFreq); fMuonPhase += PrecessionPhase(captureTime, muonPrecessionFreq);
else{ //muon decays; handle precession prior to muon decay else{ //muon decays; handle precession prior to muon decay
@ -212,6 +214,7 @@ void PSimulateMuTransition::Event()
// now, we have Mu0; get next ionization time // now, we have Mu0; get next ionization time
ionizationTime = NextEventTime(fIonizationRate); ionizationTime = NextEventTime(fIonizationRate);
eventTime += ionizationTime; eventTime += ionizationTime;
if (fDebugFlag) cout << "Ioniza. time = " << ionizationTime << " Phase = " << fMuonPhase << endl;
if (eventTime < fMuonDecayTime) if (eventTime < fMuonDecayTime)
fMuonPhase += PrecessionPhase(ionizationTime, fMuCoupling); fMuonPhase += PrecessionPhase(ionizationTime, fMuCoupling);
else{ //muon decays; handle precession prior to muon decay else{ //muon decays; handle precession prior to muon decay
@ -220,6 +223,8 @@ void PSimulateMuTransition::Event()
break; break;
} }
} }
if (fDebugFlag) cout << " Final Phase = " << fMuonPhase << endl;
//fMuonPhase = TMath::ACos(TMath::Cos(fMuonPhase))*360./TMath::TwoPi(); //transform back to [0, 180] degree interval //fMuonPhase = TMath::ACos(TMath::Cos(fMuonPhase))*360./TMath::TwoPi(); //transform back to [0, 180] degree interval
return; return;
} }

View File

@ -47,6 +47,7 @@ class PSimulateMuTransition : public TObject
virtual void PrintSettings() const; virtual void PrintSettings() const;
virtual void SetNmuons(Int_t value) { fNmuons = value; } //!< number of muons virtual void SetNmuons(Int_t value) { fNmuons = value; } //!< number of muons
virtual void SetDebugFlag(Bool_t value) { fDebugFlag = value; } //!< debug flag
virtual void SetBfield(Double_t value) { fBfield = value; } //!< sets magnetic field (T) virtual void SetBfield(Double_t value) { fBfield = value; } //!< sets magnetic field (T)
virtual void SetMuCoupling(Double_t value) { fMuCoupling = value; } //!< sets Mu hyperfine coupling (MHz) virtual void SetMuCoupling(Double_t value) { fMuCoupling = value; } //!< sets Mu hyperfine coupling (MHz)
virtual void SetCaptureRate(Double_t value){ fCaptureRate = value; } //!< sets Mu+ electron capture rate (MHz) virtual void SetCaptureRate(Double_t value){ fCaptureRate = value; } //!< sets Mu+ electron capture rate (MHz)
@ -75,6 +76,7 @@ class PSimulateMuTransition : public TObject
Double_t fMuonPhase; //!< phase of muon spin Double_t fMuonPhase; //!< phase of muon spin
Double_t fAsymmetry; //!< muon decay asymmetry Double_t fAsymmetry; //!< muon decay asymmetry
Int_t fNmuons; //!< number of muons to simulate Int_t fNmuons; //!< number of muons to simulate
Bool_t fDebugFlag; //!< debug flag
virtual Double_t NextEventTime(const Double_t &EventRate); virtual Double_t NextEventTime(const Double_t &EventRate);
virtual Double_t PrecessionPhase(const Double_t &time, const Double_t &frequency); virtual Double_t PrecessionPhase(const Double_t &time, const Double_t &frequency);

View File

@ -43,7 +43,7 @@ void runMuSimulation()
decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms"); decayAnaModule = histosFolder->AddFolder("DecayAnaModule", "muSR decay histograms");
// feed run info header // feed run info header
UInt_t runNo = 9010; UInt_t runNo = 9015;
TString tstr; TString tstr;
runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "LEM RunInfo"); runInfo = gROOT->GetRootFolder()->AddFolder("RunInfo", "LEM RunInfo");
gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo"); gROOT->GetListOfBrowsables()->Add(runInfo, "RunInfo");
@ -86,12 +86,13 @@ void runMuSimulation()
} }
//prepare to run simulation //prepare to run simulation
simulateMuTransition->SetMuCoupling(100.); // MHz simulateMuTransition->SetMuCoupling(35.); // MHz
simulateMuTransition->SetBfield(0.01); // Tesla simulateMuTransition->SetBfield(0.1); // Tesla
simulateMuTransition->SetCaptureRate(1.0); // MHz simulateMuTransition->SetCaptureRate(1.0); // MHz
simulateMuTransition->SetIonizationRate(500.0); // MHz simulateMuTransition->SetIonizationRate(250.0); // MHz
simulateMuTransition->SetNmuons(1e6); simulateMuTransition->SetNmuons(1e6);
simulateMuTransition->SetDecayAsymmetry(0.27); simulateMuTransition->SetDecayAsymmetry(0.27);
simulateMuTransition->SetDebugFlag(kFALSE); // to print time and phase during charge-changing cycle
simulateMuTransition->PrintSettings(); simulateMuTransition->PrintSettings();