1 | #include "MStargHistograms.h"
|
---|
2 |
|
---|
3 | #include <iostream>
|
---|
4 | #include <iomanip>
|
---|
5 |
|
---|
6 | #include <TSystem.h>
|
---|
7 | #include <TFile.h>
|
---|
8 | #include <TTree.h>
|
---|
9 | #include <TH1.h>
|
---|
10 | #include <TH2.h>
|
---|
11 | #include <TGraph.h>
|
---|
12 | #include <TCanvas.h>
|
---|
13 |
|
---|
14 | #include "MTime.h"
|
---|
15 |
|
---|
16 | #include "Led.h"
|
---|
17 | #include "Leds.h"
|
---|
18 | #include "Ring.h"
|
---|
19 | #include "Rings.h"
|
---|
20 | #include "FilterLed.h"
|
---|
21 | #include "MStarList.h"
|
---|
22 |
|
---|
23 | #include "coord.h"
|
---|
24 |
|
---|
25 | using namespace std;
|
---|
26 |
|
---|
27 | void MStargHistograms::OpenFile()
|
---|
28 | {
|
---|
29 | int i=0;
|
---|
30 | char name[100];
|
---|
31 | while (1)
|
---|
32 | {
|
---|
33 | sprintf(name, "data/starg%03d.root", i++);
|
---|
34 | if (gSystem->AccessPathName(name, kFileExists))
|
---|
35 | break;
|
---|
36 | }
|
---|
37 |
|
---|
38 | if (fFile)
|
---|
39 | delete fFile;
|
---|
40 |
|
---|
41 | fFile = new TFile(name, "RECREATE");
|
---|
42 |
|
---|
43 | if (!fFile->IsOpen())
|
---|
44 | {
|
---|
45 | delete fFile;
|
---|
46 | fFile = NULL;
|
---|
47 |
|
---|
48 | cout << "Error: Cannot open file '" << name << "'" << endl;
|
---|
49 | }
|
---|
50 |
|
---|
51 | TTree *tree = new TTree("Data", "Real Starg Data");
|
---|
52 |
|
---|
53 |
|
---|
54 | fEvtTime = 0;
|
---|
55 |
|
---|
56 |
|
---|
57 | // Tracking Position Zd, Az in deg
|
---|
58 | tree->Branch("PosZd.", &fZenithDist, "fZenithDist/D");
|
---|
59 | tree->Branch("PosAz.", &fAzimuth, "fAzimuth/D");
|
---|
60 | // Event time, arbitrary start
|
---|
61 | tree->Branch("EvtTime.", &fEvtTime, "fEvtTime/D");
|
---|
62 | // Pointing Position Zd, Az in deg
|
---|
63 | tree->Branch("SaoZd.", &fNomZd, "fNomZd/D");
|
---|
64 | tree->Branch("SaoAz.", &fNomAz, "fNomAz/D");
|
---|
65 | // Misspointing from Starguider Zd, Az in deg
|
---|
66 | tree->Branch("MisZd.", &fdZd, "fdZd/D");
|
---|
67 | tree->Branch("MisAz.", &fdAz, "fdAz/D");
|
---|
68 | // LED Offset from StargLEDFinder, obsolete
|
---|
69 | tree->Branch("LEDOffsetX.", &fOffsetX, "fOffsX/D");
|
---|
70 | tree->Branch("LEDOffsetY.", &fOffsetY, "fOffsY/D");
|
---|
71 | // Center of Camera, offset from arb coords, in pix
|
---|
72 | tree->Branch("CenterX.", &fCenterX, "fCenterX/D");
|
---|
73 | tree->Branch("CenterY.", &fCenterY, "fCenterY/D");
|
---|
74 | // Center of Camera, offset from arb coords, in Zd, Az, deg
|
---|
75 | // tree->Branch("CenterZd.", &fCenterZd, "fCenterZd/D");
|
---|
76 | // tree->Branch("CenterAz.", &fCenterAz, "fCenterAz/D");
|
---|
77 | // Position of Star in Camera in Zd, Az
|
---|
78 | tree->Branch("StarZd.", &fStarZd, "fStarZd/D");
|
---|
79 | tree->Branch("StarAz.", &fStarAz, "fStarAz/D");
|
---|
80 | // number of spots found
|
---|
81 | tree->Branch("Spots.", &fSpots, "fSpots/D");
|
---|
82 | // number of stars expected
|
---|
83 | tree->Branch("Stars.", &fStars, "fStars/D");
|
---|
84 | tree->Branch("Bright.", &fBright, "fBright/D");
|
---|
85 |
|
---|
86 |
|
---|
87 | cout << "Root file '" << name << "' open." << endl;
|
---|
88 | }
|
---|
89 |
|
---|
90 | void MStargHistograms::CloseFile()
|
---|
91 | {
|
---|
92 | if (!fFile)
|
---|
93 | return;
|
---|
94 |
|
---|
95 | const TString name = fFile->GetName();
|
---|
96 | const Double_t n = ((TTree*)fFile->Get("Data"))->GetEntries();
|
---|
97 |
|
---|
98 | fFile->Write();
|
---|
99 | delete fFile;
|
---|
100 | fFile = NULL;
|
---|
101 |
|
---|
102 | cout << "Root file closed (n=" << n << ")" << endl;
|
---|
103 |
|
---|
104 | if (n<1)
|
---|
105 | {
|
---|
106 | gSystem->Unlink(name);
|
---|
107 | cout << "Root file deleted - no entries." << endl;
|
---|
108 | }
|
---|
109 | }
|
---|
110 |
|
---|
111 | void MStargHistograms::InitHistograms()
|
---|
112 | {
|
---|
113 |
|
---|
114 | }
|
---|
115 |
|
---|
116 | void MStargHistograms::DeleteHistograms()
|
---|
117 | {
|
---|
118 |
|
---|
119 | }
|
---|
120 |
|
---|
121 | void MStargHistograms::ShowHistograms()
|
---|
122 | {
|
---|
123 |
|
---|
124 | }
|
---|
125 |
|
---|
126 | void MStargHistograms::ResetHistograms()
|
---|
127 | {
|
---|
128 |
|
---|
129 | }
|
---|
130 |
|
---|
131 | void MStargHistograms::Fill(Leds &spots, MStarList &stars, ZdAz &d, ZdAz sao, Ring ¢er, ZdAz &star, Double_t bright, const ZdAz &pos, const MTime &t)
|
---|
132 | {
|
---|
133 | // FIXME!
|
---|
134 | static const MTime t0(t);
|
---|
135 | fEvtTime = t-t0;
|
---|
136 |
|
---|
137 | // cout << "@ evttime " << fEvtTime << endl;
|
---|
138 |
|
---|
139 | if (fFile && spots.GetEntries()>0)
|
---|
140 | {
|
---|
141 | fZenithDist = pos.Zd(); //fCosy ? fCosy->GetPointingPos().Zd() : 0
|
---|
142 | fAzimuth = pos.Az(); //fCosy ? fCosy->GetPointingPos().Az() : 0;
|
---|
143 | fNomZd = sao.Zd();
|
---|
144 | fNomAz = sao.Az();
|
---|
145 | fdZd = d.Zd();
|
---|
146 | fdAz = d.Az();
|
---|
147 |
|
---|
148 | fCenterX = center.GetX();
|
---|
149 | fCenterY = center.GetY();
|
---|
150 | //fCenterZd = centerzdaz.Zd();
|
---|
151 | //fCenterAz = centerzdaz.Az();
|
---|
152 | fStarZd = star.Zd();
|
---|
153 | fStarAz = star.Az();
|
---|
154 | fStars = stars.GetRealEntries();
|
---|
155 | fSpots = spots.GetEntries();
|
---|
156 | fBright = bright;
|
---|
157 |
|
---|
158 | // cout << " Evttime=" << fEvtTime
|
---|
159 | // << " ZD=" << fZenithDist
|
---|
160 | // << " Az=" << fAzimuth
|
---|
161 | // << " NomZd=" << fNomZd
|
---|
162 | // << " NomAz=" << fNomAz
|
---|
163 | // << " dZd=" << fdZd
|
---|
164 | // << " dAz=" << fdAz
|
---|
165 | // << " OffsX=" << fOffsetX
|
---|
166 | // << " OffsY=" << fOffsetY
|
---|
167 | // <<endl;
|
---|
168 |
|
---|
169 | TTree *t = (TTree*)fFile->Get("Data");
|
---|
170 | t->Fill();
|
---|
171 | }
|
---|
172 |
|
---|
173 | }
|
---|