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