2 void DrawPolySignal(TH2* h2_vt,
const int i_evt_b,
const int i_evt_e,
const int time_b,
const int time_e);
8 gSystem->mkdir(
"result",
true);
68 TTimeStamp ts0(2024, 3, 15, 0, 0, 0);
69 int utime0 = ts0.GetSec() + TTimeStamp::GetZoneOffset();
74 double RF_lo = RFFreq - RFMod;
75 double RF_hi = RFFreq + RFMod;
76 double sig_min, sig_max;
78 TH2* h2_vt =
new TH2D(
"h2_vt",
"", ScanSteps, RF_lo, RF_hi, 100, sig_min, sig_max);
79 TGraphErrors* gr_noise =
new TGraphErrors();
81 const int n_draw_step = 50;
87 for (
int i_evt = 0; i_evt < n_evt; i_evt++) {
89 int evt_num = evt->
GetInt(
"EventNum");
90 if (utime0 == 0) utime0 = evt_num;
91 if (evt_num < utime0)
continue;
97 i_evt_draw = i_evt_ok;
101 for (
int ii = 0; ii < ScanSteps; ii++) {
102 double rf = RF_lo + 2.0 * RFMod / (ScanSteps - 1) * ii;
105 if ((i_evt_ok + 1) % n_draw_step == 0 ||
106 i_evt == n_evt - 1) {
107 if (draw_h2)
DrawPolySignal(h2_vt, i_evt_draw, i_evt_ok, utime_draw-utime0, evt_num-utime0);
109 TH1* h1_lo = h2_vt->ProjectionY(
"h1_lo", 1, ScanSteps/10);
110 TH1* h1_hi = h2_vt->ProjectionY(
"h1_hi", ScanSteps*9/10, ScanSteps );
112 double rms = h1_lo->GetRMS();
113 double rms_err = h1_lo->GetRMSError();
114 int n_gr_pt = gr_noise->GetN();
115 double time = evt_num/2.0 + utime_draw/2.0 - utime0;
116 double time_err = (evt_num - utime_draw) / 2.0;
117 gr_noise->SetPoint (n_gr_pt, time /3600, rms );
118 gr_noise->SetPointError(n_gr_pt, time_err/3600, rms_err);
130 TCanvas* c1 =
new TCanvas(
"c1",
"", 3200, 600);
133 c1->SetMargin(0.03, 0.03, 0.1, 0.1);
134 gStyle->SetOptStat(0);
135 TGaxis::SetMaxDigits(4);
137 gr_noise->SetTitle((
";Hours since " +
NMRUtil::ConvEventNum(utime0) +
";Std. dev. of PolySignal outer regions").c_str());
139 gr_noise->SetMarkerStyle(7);
140 gr_noise->SetMarkerColor(kRed);
141 gr_noise->SetLineColor (kRed);
142 gr_noise->Draw(
"AP");
144 c1->SaveAs(
"result/gr_noise.png");
149 void DrawPolySignal(TH2* h2_vt,
const int i_evt_b,
const int i_evt_e,
const int time_b,
const int time_e)
151 TCanvas* c1 =
new TCanvas(
"c1",
"");
153 gStyle->SetOptStat(0);
154 TGaxis::SetMaxDigits(4);
157 oss <<
"Data #" << i_evt_b <<
"-" << i_evt_e <<
" ("
158 << fixed << setprecision(2) << time_b/3600.0 <<
"-" << time_e/3600.0
159 <<
" hours);Frequency;PolySignal";
160 h2_vt->SetTitle(oss.str().c_str());
164 oss << setfill(
'0') <<
"result/h2_vt_" << setw(6) << i_evt_b <<
".png";
165 c1->SaveAs(oss.str().c_str());
void ana_NMR_noise(const bool draw_h2=true)
void DrawPolySignal(TH2 *h2_vt, const int i_evt_b, const int i_evt_e, const int time_b, const int time_e)
NMRSignal * GetPolySignal(const int evt_num)
void ReadEventFile(const std::string label)
void GetScanParam(int &ScanSweeps, int &ScanSteps, double &RFFreq, double &RFMod)
void Verb(const int verb)
NMREvent * GetEvent(const int index)
void GetPolySignalRange(double &min, double &max)
int GetInt(const int idx)
double GetPoint(const int idx)
void ConvEventNum(const int event_num, int &YYYY, int &MM, int &DD, int &hh, int &mm, int &ss)