started with the implementation of a Fourier transform
This commit is contained in:
@@ -202,12 +202,14 @@ void PMusrFourier::Transform(unsigned int apodizationTag, unsigned int filterTag
|
||||
// loop over the phase
|
||||
double sum;
|
||||
double corr_phase;
|
||||
double min, min_phase;;
|
||||
double min, min_phase;
|
||||
TH1F sumHist("sumHist", "sumHist", 181, -90.5, 90.5);
|
||||
double dB = 1.0/(2.0 * F_GAMMA_BAR_MUON * (fEndTime-fStartTime));
|
||||
double Bmax = 1.0/(2.0 * F_GAMMA_BAR_MUON * fTimeResolution);
|
||||
TH1F re("re", "re", fNoOfBins/2+1, -dB/2.0, Bmax+dB/2.0);
|
||||
TH1F im("im", "im", fNoOfBins/2+1, -dB/2.0, Bmax+dB/2.0);
|
||||
TH1F pwr("pwr", "pwr", fNoOfBins/2+1, -dB/2.0, Bmax+dB/2.0);
|
||||
/*
|
||||
for (int p=-90; p<90; p++) {
|
||||
// calculate sum of the rotated imaginary part of fOut
|
||||
sum = 0.0;
|
||||
@@ -229,15 +231,18 @@ cout << endl << "-> min = " << min << ", min_phase = " << min_phase/PI*180.0;
|
||||
sumHist.SetBinContent(p+91, fabs(sum));
|
||||
}
|
||||
cout << endl << ">> min = " << min << ", min_phase = " << min_phase/PI*180.0;
|
||||
|
||||
*/
|
||||
min_phase = 0.0;
|
||||
for (unsigned int i=0; i<fNoOfBins/2; i++) {
|
||||
re.SetBinContent(i+1, fOut[i][0]*cos(min_phase) - fOut[i][1]*sin(min_phase));
|
||||
im.SetBinContent(i+1, fOut[i][0]*sin(min_phase) + fOut[i][1]*cos(min_phase));
|
||||
pwr.SetBinContent(i+1, sqrt(fOut[i][0]*fOut[i][0] + fOut[i][1]*fOut[i][1]));
|
||||
}
|
||||
|
||||
TFile f("test_out.root", "RECREATE");
|
||||
re.Write();
|
||||
im.Write();
|
||||
pwr.Write();
|
||||
sumHist.Write();
|
||||
f.Close();
|
||||
}
|
||||
|
||||
37
src/tests/fourier/PhaseShifter.C
Normal file
37
src/tests/fourier/PhaseShifter.C
Normal file
@@ -0,0 +1,37 @@
|
||||
void PhaseShifter(Double_t phase, TH1F *re, TH1F *im, TH1F *pwr)
|
||||
{
|
||||
static Double_t phaseAbs = 0.0;
|
||||
phaseAbs += phase;
|
||||
cout << ">> phase = " << phaseAbs << endl;
|
||||
|
||||
Int_t noOfEntries = re->GetEntries();
|
||||
Double_t min = re->GetBinLowEdge(1);
|
||||
Int_t maxBin = re->GetNbinsX()-1;
|
||||
Double_t max = re->GetBinLowEdge(maxBin)+re->GetBinWidth(maxBin);
|
||||
TH1F reShift("reShift", "reShift", noOfEntries, min, max);
|
||||
TH1F imShift("imShift", "imShift", noOfEntries, min, max);
|
||||
|
||||
Double_t phaseRad = phase/180.0*TMath::Pi();
|
||||
for (Int_t i=1; i<noOfEntries-1; i++) {
|
||||
reShift.SetBinContent(i, re->GetBinContent(i)*TMath::Cos(phaseRad) - im->GetBinContent(i)*TMath::Sin(phaseRad));
|
||||
imShift.SetBinContent(i, im->GetBinContent(i)*TMath::Cos(phaseRad) + re->GetBinContent(i)*TMath::Sin(phaseRad));
|
||||
}
|
||||
|
||||
for (Int_t i=1; i<noOfEntries-1; i++) {
|
||||
re->SetBinContent(i, reShift.GetBinContent(i));
|
||||
im->SetBinContent(i, imShift.GetBinContent(i));
|
||||
}
|
||||
|
||||
re->SetMarkerStyle(20);
|
||||
re->SetMarkerColor(TColor::GetColor(0,0,0));
|
||||
re->SetLineColor(TColor::GetColor(0,0,0));
|
||||
im->SetMarkerStyle(21);
|
||||
im->SetMarkerColor(TColor::GetColor(255,0,0));
|
||||
im->SetLineColor(TColor::GetColor(255,0,0));
|
||||
pwr->SetMarkerStyle(22);
|
||||
pwr->SetMarkerColor(TColor::GetColor(0,0,255));
|
||||
pwr->SetLineColor(TColor::GetColor(0,0,255));
|
||||
re->Draw("alp");
|
||||
im->Draw("plsame");
|
||||
pwr->Draw("plsame");
|
||||
}
|
||||
Reference in New Issue
Block a user