All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRTRawTree.cc
Go to the documentation of this file.
1 #ifndef CRT_RAW_TREE_CC
2 #define CRT_RAW_TREE_CC
3 
5 
6 using namespace icarus::crt;
7 
9 
10  fTree = tr;
11  //fTree->SetMaxVirtualSize(16e9);
12  fTree->LoadBaskets(16e9);
13  Init();
14 }
15 
17 
18  fTree->SetBranchAddress("mac5", &fMac5, &b_Mac5);
19  fTree->SetBranchAddress("flags", &fFlags, &b_Flags);
20  fTree->SetBranchAddress("lostcpu", &fLostcpu, &b_Lostcpu);
21  fTree->SetBranchAddress("lostfpga", &fLostfpga, &b_Lostfpga);
22  fTree->SetBranchAddress("ts0", &fTs0, &b_Ts0);
23  fTree->SetBranchAddress("ts1", &fTs1, &b_Ts1);
24  fTree->SetBranchAddress("adc", &fAdc, &b_Adc);
25  fTree->SetBranchAddress("coinc", &fCoinc, &b_Coinc);
26  fTree->SetBranchAddress("run_start_time", &fRun_start_time, &b_Run_start_time);
27  fTree->SetBranchAddress("this_poll_start", &fThis_poll_start, &b_This_poll_start);
28  fTree->SetBranchAddress("this_poll_end", &fThis_poll_end, &b_This_poll_end);
29  fTree->SetBranchAddress("last_poll_start", &fLast_poll_start, &b_Last_poll_start);
30  fTree->SetBranchAddress("last_poll_end", &fLast_poll_end, &b_Last_poll_end);
31  fTree->SetBranchAddress("system_clock_deviation", &fSystem_clock_deviation, &b_System_clock_deviation);
32  fTree->SetBranchAddress("feb_in_poll", &fFeb_in_poll, &b_Feb_in_poll);
33  fTree->SetBranchAddress("feb_event_number", &fFeb_event_number, &b_Feb_event_number);
34  fTree->SetBranchAddress("sequence_id", &fSequence_id, &b_Sequence_id);
35  fTree->SetBranchAddress("fragment_timestamp", &fFragment_timestamp, &b_Fragment_timestamp);
36 
37 
38 }
39 
40 size_t CRTRawTree::GetNEntries() const {
41  return (size_t)fTree->GetEntriesFast();
42 }
43 
44 uint64_t CRTRawTree::GetAbsTime(size_t ientry) const {
45  if(ientry >= GetNEntries()) {
46  std::cout << "ERROR in CRTRawTree::GetAbsTime: entry out of range" << std::endl;
47  return UINT64_MAX;
48  }
49 
50  fTree->GetEntry(ientry);
51  return (uint64_t)fFragment_timestamp;
52 }
53 
54 uint8_t CRTRawTree::GetMac(size_t ientry) const {
55  if(ientry >= GetNEntries()) {
56  std::cout << "ERROR in CRTRawTree::GetMac: entry out of range" << std::endl;
57  return UINT8_MAX;
58  }
59 
60  fTree->GetEntry(ientry);
61  return fMac5;
62 }
63 
64 uint16_t CRTRawTree::GetADC(size_t ientry, uint8_t chan) const {
65  if(ientry >= GetNEntries()) {
66  std::cout << "ERROR in CRTRawTree::GetADC: entry out of range" << std::endl;
67  return UINT16_MAX;
68  }
69 
70  fTree->GetEntry(ientry);
71  return fAdc[chan];
72 }
73 
74 float CRTRawTree::GetInstRate(size_t ientry_prev, size_t ientry_next) const {
75 
76 
77  return 1.0/GetInterval(ientry_prev, ientry_next);
78 }
79 
80 float CRTRawTree::GetPollRate(size_t ientry) const {
81  if(ientry >= GetNEntries()) {
82  std::cout << "ERROR in CRTRawTree::GetPollRate: entry out of range" << std::endl;
83  return FLT_MAX;
84  }
85 
86  fTree->GetEntry(ientry);
88 }
89 
90 uint64_t CRTRawTree::GetInterval(size_t ientry1, size_t ientry2) const {
91  if(ientry1 >= GetNEntries() || ientry2 >= GetNEntries()) {
92  std::cout << "ERROR in CRTRawTree::GetInterval: entry out of range" << std::endl;
93  return UINT64_MAX;
94  }
95 
96  uint64_t tprev, tnext;
97  fTree->GetEntry(ientry1);
98  tprev = fFragment_timestamp;
99 
100  fTree->GetEntry(ientry2);
101  tnext = fFragment_timestamp;
102 
103  if(tnext < tprev){
104  std::cout << "ERROR in CRTRawTree::GetInterval: reverse ordered!" << std::endl;
105  return UINT64_MAX;
106  }
107 
108  return tnext - tprev;
109 }
110 
111 #endif
ULong64_t fFragment_timestamp
Definition: CRTRawTree.h:48
TBranch * b_Run_start_time
Definition: CRTRawTree.h:58
TBranch * b_This_poll_end
Definition: CRTRawTree.h:60
TBranch * b_This_poll_start
Definition: CRTRawTree.h:59
TBranch * b_Last_poll_end
Definition: CRTRawTree.h:62
TBranch * b_Last_poll_start
Definition: CRTRawTree.h:61
float GetPollRate(size_t ientry) const
Definition: CRTRawTree.cc:80
size_t GetNEntries() const
Definition: CRTRawTree.cc:40
float GetInstRate(size_t ientry_prev, size_t ientry_next) const
Definition: CRTRawTree.cc:74
TBranch * b_System_clock_deviation
Definition: CRTRawTree.h:63
int32_t fSystem_clock_deviation
Definition: CRTRawTree.h:44
ULong64_t fRun_start_time
Definition: CRTRawTree.h:39
ULong64_t fThis_poll_start
Definition: CRTRawTree.h:40
TBranch * b_Fragment_timestamp
Definition: CRTRawTree.h:67
uint32_t fFeb_event_number
Definition: CRTRawTree.h:46
uint64_t GetAbsTime(size_t ientry) const
Definition: CRTRawTree.cc:44
uint8_t GetMac(size_t ientry) const
Definition: CRTRawTree.cc:54
ULong64_t fThis_poll_end
Definition: CRTRawTree.h:41
ULong64_t fLast_poll_start
Definition: CRTRawTree.h:42
process_name crt
BEGIN_PROLOG could also be cout
TBranch * b_Feb_event_number
Definition: CRTRawTree.h:65
ULong64_t fLast_poll_end
Definition: CRTRawTree.h:43
uint16_t GetADC(size_t ientry, uint8_t chan) const
Definition: CRTRawTree.cc:64
uint64_t GetInterval(size_t ientry1, size_t ientry2) const
Definition: CRTRawTree.cc:90