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

Last change on this file since 20034 was 20030, checked in by tbretz, 4 years ago
Do not do any splitting of the aux data in the script files, instead add the commas in the root macros (simplification)
File size: 1.7 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 return;
76
77 cout << "result NULL, NULL, NULL, " << temp_last << endl;
78 return;
79 }
80
81 //avg_th /= count;
82 avg_temp /= count;
83
84 cout << "result " << tot_run*10e-9 << ", " << tot_dead*10e-9 << ", " << 1.-tot_dead/tot_run << ", " << avg_temp << endl;
85}
Note: See TracBrowser for help on using the repository browser.