Class Reference for E1039 Core & Analysis Software
ana_NMR_raw_signal.cc
Go to the documentation of this file.
1 #include "NMRDataManager.h"
2 
4 {
5  NMRDataManager man;
6  man.Verb(0); // 0 = silent, 1 = some, 2 = every event
7  gSystem->mkdir("result", true);
8 
12  //man.ReadEventFile("2024-02-08_19h02m57s");
13  //man.ReadEventFile("2024-02-08_22h13m47s");
14  man.ReadEventFile("2024-02-12_16h05m57s");
15  //man.ReadEventFile("2024-02-13_19h58m19s");
16 
17  int ScanSweeps; // N of sweeps per measurement
18  int ScanSteps; // N of frequency steps per scan
19  double RFFreq; // Center frequency in MHz
20  double RFMod; // Half width of frequency range in kHz
21  man.GetScanParam(ScanSweeps, ScanSteps, RFFreq, RFMod);
22 
26  //TTimeStamp ts0(2024, 2, 8, 18, 0, 0);
27  TTimeStamp ts0(2024, 2, 11, 18, 0, 0); // For "2024-02-12_16h05m57s"
28  //TTimeStamp ts0(2024, 2, 12, 18, 0, 0); // For "2024-02-12_16h05m57s"
29  int utime0 = ts0.GetSec() + TTimeStamp::GetZoneOffset();
30 
34  TGraph* gr_first = new TGraph();
35  TGraph* gr_last = new TGraph();
36  TGraph* gr_diff = new TGraph();
37 
38  int n_evt = man.GetNumEvent();
39  int i_evt_ok = 0;
40  for (int i_evt = 0; i_evt < n_evt; i_evt++) {
41  NMREvent* evt = man.GetEvent(i_evt);
42  int evt_num = evt->GetInt("EventNum");
43  int n_pt = evt->GetInt("ScanSteps");
44  if (utime0 == 0) utime0 = evt_num;
45  if (evt_num < utime0) continue;
46 
47  NMRSignal* sig = man.GetRawSignal(evt_num);
48  double val0 = sig->GetPoint(0);
49  double val1 = sig->GetPoint(n_pt-1);
50  double hour = (evt_num - utime0) / 3600.0;
51  gr_first->SetPoint(gr_first->GetN(), hour, val0);
52  gr_last ->SetPoint(gr_last ->GetN(), hour, val1);
53  gr_diff ->SetPoint(gr_diff ->GetN(), hour, val0 - val1);
54  }
55 
59  TCanvas* c1 = new TCanvas("c1", "", 1600, 600);
60  c1->SetGrid(true);
61  c1->SetMargin(0.05, 0.05, 0.1, 0.1); // (l, r, b, t)
62  TGaxis::SetMaxDigits(3);
63 
64  gr_last ->SetMarkerStyle(7);
65  gr_last ->SetMarkerColor(kBlue);
66  gr_first->SetMarkerStyle(7);
67  gr_first->SetMarkerColor(kRed);
68 
69  TMultiGraph* mg = new TMultiGraph();
70  string title_x = "Hours since " + NMRUtil::ConvEventNum(utime0);
71  mg->SetTitle((";" + title_x + ";RawSignal").c_str());
72  mg->Add(gr_first, "P");
73  mg->Add(gr_last , "P");
74  mg->Draw("A");
75  mg->GetYaxis()->SetTitleOffset(0.6);
76 
77  TLegend* leg = new TLegend(0.85, 0.90, 0.99, 0.99);
78  leg->AddEntry(gr_first, "First point", "p");
79  leg->AddEntry(gr_last , "Last point", "p");
80  leg->Draw();
81 
82  c1->SaveAs("result/gr_voltage_vs_time.png");
83 
84  gr_diff->SetTitle((";" + title_x + ";V_{First} - V_{Last}").c_str());
85  gr_diff->GetYaxis()->SetTitleOffset(0.6);
86  gr_diff->SetMarkerStyle(7);
87  gr_diff->SetMarkerColor(kRed);
88  gr_diff->Draw("AP");
89  c1->SaveAs("result/gr_diff_vs_time.png");
90 
91  delete c1;
92  exit(0);
93 }
void ana_NMR_raw_signal()
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)
NMRSignal * GetRawSignal(const int evt_num)
int GetInt(const int idx)
Definition: NMREvent.h:23
double GetPoint(const int idx)
Definition: NMRSignal.h:15
void ConvEventNum(const int event_num, int &YYYY, int &MM, int &DD, int &hh, int &mm, int &ss)
Definition: NMRUtil.h:6