| 1 | #include <iomanip.h>
|
|---|
| 2 |
|
|---|
| 3 | void testtrack()
|
|---|
| 4 | {
|
|---|
| 5 | TGraph g;
|
|---|
| 6 |
|
|---|
| 7 | TH2F h("Hist", "dX/dY", 77, -768/2-.5, 768/2+.5, 58, -576/2-.5, 576/2+.5); // 3
|
|---|
| 8 | TH1F hmag("HistMag", "Mag", 19, 0, 100);
|
|---|
| 9 |
|
|---|
| 10 | TArrayF x;
|
|---|
| 11 | TArrayF y;
|
|---|
| 12 | TArrayF mag;
|
|---|
| 13 |
|
|---|
| 14 | ifstream fin0("data/tracking_702.999039.txt");
|
|---|
| 15 |
|
|---|
| 16 | int i=0;
|
|---|
| 17 |
|
|---|
| 18 | while (!fin0.eof())
|
|---|
| 19 | {
|
|---|
| 20 | double d, p, m;
|
|---|
| 21 | fin0 >> d >> p >> m;
|
|---|
| 22 | if (!fin0)
|
|---|
| 23 | break;
|
|---|
| 24 |
|
|---|
| 25 | y.Set(i+1);
|
|---|
| 26 | x.Set(i+1);
|
|---|
| 27 | mag.Set(i+1);
|
|---|
| 28 |
|
|---|
| 29 | y.AddAt(d, i);
|
|---|
| 30 | x.AddAt(p, i);
|
|---|
| 31 | mag.AddAt(m, i);
|
|---|
| 32 |
|
|---|
| 33 | i++;
|
|---|
| 34 |
|
|---|
| 35 | hmag.Fill(m);
|
|---|
| 36 | }
|
|---|
| 37 |
|
|---|
| 38 | TCanvas *c = new TCanvas;
|
|---|
| 39 | c->Divide(2,2);
|
|---|
| 40 | c->cd(1);
|
|---|
| 41 | hmag.DrawCopy();
|
|---|
| 42 |
|
|---|
| 43 | for (i=0; i<mag.GetSize(); i++)
|
|---|
| 44 | {
|
|---|
| 45 | if (mag[i]<48+15 && mag[i]>48-15)
|
|---|
| 46 | {
|
|---|
| 47 | h.Fill(x[i], y[i]);
|
|---|
| 48 | }
|
|---|
| 49 | }
|
|---|
| 50 |
|
|---|
| 51 | c->cd(2);
|
|---|
| 52 | h.DrawCopy("surf4");
|
|---|
| 53 |
|
|---|
| 54 | c->cd(3);
|
|---|
| 55 | TH1D *hist = h.ProjectionX();
|
|---|
| 56 | hist->SetLineColor(kGreen);
|
|---|
| 57 | hist->Draw();
|
|---|
| 58 | hist->SetBit(kCanDelete);
|
|---|
| 59 | hist = h.ProjectionY();
|
|---|
| 60 | hist->SetLineColor(kRed);
|
|---|
| 61 | hist->Draw("same");
|
|---|
| 62 | hist->SetBit(kCanDelete);
|
|---|
| 63 |
|
|---|
| 64 | Int_t y1, y2, y3;
|
|---|
| 65 | h.GetMaximumBin(y1, y2, y3);
|
|---|
| 66 |
|
|---|
| 67 | double ymax = h.GetYaxis()->GetBinCenter(y2);
|
|---|
| 68 | double dy = h.GetYaxis()->GetBinWidth(y2);
|
|---|
| 69 |
|
|---|
| 70 | double xmax = h.GetXaxis()->GetBinCenter(y1);
|
|---|
| 71 | double dx = h.GetXaxis()->GetBinWidth(y1);
|
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 | cout << "*** " << h.GetEntries() << " " << y1 << " " << y2 << endl;
|
|---|
| 75 |
|
|---|
| 76 | cout << "Cut-X: " << xmax << " " << dx*1 << endl;
|
|---|
| 77 | cout << "Cut-Y: " << ymax << " " << dy*1 << endl;
|
|---|
| 78 |
|
|---|
| 79 | TGraph g2;
|
|---|
| 80 | Int_t pnt=0;
|
|---|
| 81 | for (i=0; i<mag.GetSize(); i++)
|
|---|
| 82 | {
|
|---|
| 83 | if (y[i]>ymax-1*dy && y[i]<ymax+1*dy &&
|
|---|
| 84 | x[i]>xmax-1*dx && x[i]<xmax+1*dx &&
|
|---|
| 85 | mag[i]>48-15 && mag[i]<48+15)
|
|---|
| 86 | g2.SetPoint(g2.GetN(), x[i], y[i]);
|
|---|
| 87 | }
|
|---|
| 88 |
|
|---|
| 89 | c->cd(4);
|
|---|
| 90 | g2.DrawClone("A*");
|
|---|
| 91 |
|
|---|
| 92 | cout << setprecision(3);
|
|---|
| 93 | cout << "X: " << g2.GetMean(2) << "' +- " << g2.GetRMS(2) << "'" << endl;
|
|---|
| 94 | cout << "Y: " << g2.GetMean(1) << "' +- " << g2.GetRMS(1) << "'" << endl;
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 |
|
|---|