source: trunk/Mars/hawc/processing/trigger.C@ 20029

Last change on this file since 20029 was 20027, checked in by tbretz, 4 years ago
Added.
File size: 1.8 KB
Line 
1#include <algorithm>
2
3void trigger(const char *fname, double beg=0, double end=100000)
4{
5 fits file(fname);
6
7 //file.PrintColumns();
8 //file.PrintKeys();
9
10 Double_t time;
11 UShort_t adc;
12 UInt_t dead, run;
13 float temp;
14 UInt_t qos;
15 file.SetPtrAddress("QoS", &qos);
16 file.SetPtrAddress("Time", &time);
17 //file.SetPtrAddress("adc", &adc);
18 file.SetPtrAddress("dead_time", &dead);
19 file.SetPtrAddress("run_time", &run);
20 file.SetPtrAddress("temp", &temp);
21
22 UInt_t offset = file.GetUInt("MJDREF");
23 if (beg < 30000)
24 beg+=offset;
25 if (end < 30000)
26 end+=offset;
27
28 double average = 0;
29 double med_avg = 0;
30 double med_rms = 0;
31 UShort_t max_tot = 0;
32 int cnt = 0;
33
34 double th_last = -1;
35 float temp_last = -1;
36 UShort_t max_last = -1;
37 double diff = -1;
38
39 double tot_dead = 0;
40 double tot_run = 0;
41 double avg_temp = 0;
42 double avg_th = 0;
43 int count = 0;
44
45
46 while (file.GetNextRow())
47 {
48 if (qos!=4)
49 continue;
50
51 time += offset;
52
53 if (time>end)
54 break;
55
56 if (time<beg)
57 {
58 //th_last = adc;
59 temp_last = temp;
60 diff = beg-time;
61 continue;
62 }
63
64 //avg_th += adc;
65 avg_temp += temp;
66 tot_dead += dead;
67 tot_run += run,
68
69 count ++;
70 }
71
72 if (count==0)
73 {
74 if (diff<5./24/3600)
75 {
76 cout << "result NULL NULL NULL NULL" << endl;
77 return;
78 }
79
80 cout << "result NULL NULL NULL " << temp_last << endl;
81 return;
82 }
83
84 //avg_th /= count;
85 avg_temp /= count;
86
87 cout << "result " << tot_run*10e-9 << " " << tot_dead*10e-9 << " " << 1.-tot_dead/tot_run << " " << avg_temp << endl;
88}
Note: See TracBrowser for help on using the repository browser.