source: trunk/Mars/fact/processing/drstemp.C@ 15593

Last change on this file since 15593 was 15225, checked in by Daniela Dorner, 12 years ago
added (macro to extract drs temperature from the file FAD_CONTROL_TEMPERATURE)
File size: 1.8 KB
Line 
1void drstemp(const char *fname, double beg=0, double end=100000)
2{
3 fits file(fname);
4
5 //file.PrintColumns();
6 //file.PrintKeys();
7
8 Double_t time;
9 Float_t temp[82];
10 file.SetPtrAddress("Time", &time);
11 file.SetPtrAddress("temp", temp);
12
13 UInt_t offset = file.GetUInt("MJDREF");
14 if (beg < 30000)
15 beg+=offset;
16 if (end < 30000)
17 end+=offset;
18
19 double avgmin = 0;
20 double avgmax = 0;
21 double rmsmin = 0;
22 double rmsmax = 0;
23
24 int cnt = 0;
25
26 double lastavgmin = -1;
27 double lastavgmax = -1;
28 double lastrmsmin = -1;
29 double lastrmsmax = -1;
30
31 double diff = -1;
32
33 while (file.GetNextRow())
34 {
35 time += offset;
36
37 if (time>end)
38 break;
39
40 double mn = 0;
41 double mx = 0;
42 double rn = 0;
43 double rx = 0;
44 for (int i=1; i<=40; i++)
45 {
46 mn += temp[i];
47 rn += temp[i]*temp[i];
48
49 mx += temp[i+41];
50 rx += temp[i+41]*temp[i+41];
51 }
52 mn /= 40;
53 mx /= 40;
54 rn /= 40;
55 rx /= 40;
56
57 if (time<beg)
58 {
59 lastavgmin = mn;
60 lastavgmax = mx;
61 lastrmsmin = sqrt(rn-mn*mn);
62 lastrmsmax = sqrt(rx-mx*mx);
63 diff = beg-time;
64 continue;
65 }
66
67 avgmin += mn;
68 avgmax += mx;
69
70 rmsmin += sqrt(rn-mn*mn);
71 rmsmax += sqrt(rx-mx*mx);
72
73 cnt ++;
74 }
75
76 if (cnt==0)
77 {
78 if (diff<5./24/3600)
79 return;
80
81 cout << "result " << lastavgmin << " " << lastavgmax << " " << lastrmsmin << " " << lastrmsmax << endl;
82 return;
83 }
84
85 avgmin /= cnt;
86 avgmax /= cnt;
87 rmsmin /= cnt;
88 rmsmax /= cnt;
89
90 cout << "result " << avgmin << " " << avgmax << " " << rmsmin << " " << rmsmax << endl;
91}
Note: See TracBrowser for help on using the repository browser.