ProtoDUNEBeamSpill.h
Go to the documentation of this file.
1 #ifndef BEAMDATA_PROTODUNEBEAMSPILL_H
2 #define BEAMDATA_PROTODUNEBEAMSPILL_H
3 
4 #include <vector>
5 #include <bitset>
6 #include <iostream>
7 
8 namespace beamspill
9 {
10 
11  //Fiber Beam Monitor
12  //
13  struct FBM{
14 
15  //Bitmap for hit fibers in the monitor
16  std::bitset<192> fibers;
17 
18  //Raw Data from ifbeam
19  double fiberData[6];
20  double timeData[4];
21 
22  long long int timeStamp;
23 
24  //ID (position in beamline?) of monitor
25  int ID;
26  };
27 
28  //Cerenkov Threshold Detector
29  //
30  struct CKov{
31  //Status at time of system trigger (on/off)
32  bool trigger;
33 
34  long long int timeStamp;
35  };
36 
37 
38 
40  public:
43 
44  void InitFBMs(size_t);
45  long long GetT0(){ return t0; };
46 
47  void AddFBMTrigger(size_t, FBM);
48  short GetFiberStatus(size_t, size_t, size_t);
49  long long GetFiberTime(size_t, size_t);
50  int GetNFBMTriggers(size_t);
51 
52  void AddCKov0Trigger(CKov theCKov){ CKov0.push_back(theCKov); };
53  void AddCKov1Trigger(CKov theCKov){ CKov1.push_back(theCKov); };
54  int GetNCKov0Triggers(){ return CKov0.size(); };
55  int GetNCKov1Triggers(){ return CKov1.size(); };
56  short GetCKov0Status(size_t);
57  short GetCKov1Status(size_t);
58  long long GetCKov0Time(size_t);
59  long long GetCKov1Time(size_t);
60 
61  void AddTOF0Trigger(long long theT){ TOF0.push_back(theT); };
62  void AddTOF1Trigger(long long theT){ TOF1.push_back(theT); };
63  long long GetTOF0(size_t);
64  long long GetTOF1(size_t);
65  int GetNTOF0Triggers(){ return TOF0.size(); };
66  int GetNTOF1Triggers(){ return TOF1.size(); };
67 
68 
69  private:
70 
71  //First time of anything in the spill
72  //
73  long long int t0;
74 
75  //Set of FBMs
76  //Indices: [Monitor in beam]['event' in monitor]
77  std::vector< std::vector < FBM > > fiberMonitors;
78  size_t nFBMs;
79 
80  //Set of TOF detectors
81  //
82  std::vector< long long int > TOF0;
83  std::vector< long long int > TOF1;
84 
85  //Set of Cerenkov detectors
86  //
87  std::vector< CKov > CKov0;
88  std::vector< CKov > CKov1;
89 
90  };
91 
92 
93 
94  ////////////Fiber Monitor Access
95  inline void ProtoDUNEBeamSpill::AddFBMTrigger(size_t iMonitor, FBM theFBM){
96  if( (iMonitor > (nFBMs - 1) ) ){
97  std::cout << "Error FBM index out of range" << std::endl;
98  return;
99  }
100 
101  //Check if it's the first time in the monitor. Replace dummy
102  if(fiberMonitors[iMonitor][0].ID == -1){
103  std::cout << "Replacing dummy FBM" << std::endl;
104  std::vector<FBM>::iterator theIt = fiberMonitors[iMonitor].begin();
105  fiberMonitors[iMonitor].insert(theIt,theFBM);
106  fiberMonitors[iMonitor].pop_back();
107  }
108  else{
109  fiberMonitors[iMonitor].push_back(theFBM);
110  }
111  }
112 
113  inline short ProtoDUNEBeamSpill::GetFiberStatus(size_t iMonitor, size_t nTrigger, size_t iFiber){
114  if( (iMonitor > (fiberMonitors.size() - 1)) ){
115  std::cout << "Please input monitor in range [0," << fiberMonitors.size() - 1 << "]" << std::endl;
116  return -1;
117  }
118  if( (iFiber > 191)){
119  std::cout << "Please input fiber in range [0,191]" << std::endl;
120  return -1;
121  }
122  if( (nTrigger > fiberMonitors[iMonitor].size()) ){
123  std::cout << "Please input trigger in range [0," << fiberMonitors[iMonitor].size() - 1 << "]" << std::endl;
124  return -1;
125  }
126  return fiberMonitors[iMonitor][nTrigger].fibers[iFiber];
127  }
128 
129  inline long long ProtoDUNEBeamSpill::GetFiberTime(size_t iMonitor, size_t nTrigger){
130  if(iMonitor > fiberMonitors.size() - 1){
131  std::cout << "Please input monitor in range [0," << fiberMonitors.size() - 1 << "]" << std::endl;
132  return -1;
133  }
134  if( (nTrigger > fiberMonitors[iMonitor].size()) ){
135  std::cout << "Please input trigger in range [0," << fiberMonitors[iMonitor].size() - 1 << "]" << std::endl;
136  return -1;
137  }
138  return fiberMonitors[iMonitor][nTrigger].timeStamp;
139  }
140 
141  inline int ProtoDUNEBeamSpill::GetNFBMTriggers(size_t iMonitor){
142  if( (iMonitor > (fiberMonitors.size() - 1)) ){
143  std::cout << "Please input monitor in range [0," << fiberMonitors.size() - 1 << "]" << std::endl;
144  return -1;
145  }
146  return fiberMonitors[iMonitor].size();
147  }
148  /////////////////////////////////
149 
150 
151  ////////////Cerenkov Access
152 
153  inline short ProtoDUNEBeamSpill::GetCKov0Status(size_t nTrigger){
154  if( (nTrigger >= CKov0.size()) ){
155  std::cout << "Please input index in range [0," << CKov0.size() - 1 << "]" << std::endl;
156  return -1;
157  }
158 
159  return CKov0[nTrigger].trigger;
160  }
161 
162  inline short ProtoDUNEBeamSpill::GetCKov1Status(size_t nTrigger){
163  if( (nTrigger >= CKov1.size()) ){
164  std::cout << "Please input index in range [0," << CKov1.size() - 1 << "]" << std::endl;
165  return -1;
166  }
167 
168  return CKov1[nTrigger].trigger;
169  }
170 
171  inline long long ProtoDUNEBeamSpill::GetCKov0Time(size_t nTrigger){
172  if( (nTrigger >= CKov0.size()) ){
173  std::cout << "Please input index in range [0," << CKov0.size() - 1 << "]" << std::endl;
174  return -1;
175  }
176 
177  return CKov0[nTrigger].timeStamp;
178  }
179 
180  inline long long ProtoDUNEBeamSpill::GetCKov1Time(size_t nTrigger){
181  if( (nTrigger >= CKov1.size()) ){
182  std::cout << "Please input index in range [0," << CKov1.size() - 1 << "]" << std::endl;
183  return -1;
184  }
185 
186  return CKov1[nTrigger].timeStamp;
187  }
188  /////////////////////////////////
189 
190 
191  ////////////TOF Access
192  inline long long ProtoDUNEBeamSpill::GetTOF0(size_t nTrigger){
193  if( (nTrigger >= TOF0.size()) ){
194  std::cout << "Please input index in range [0," << TOF0.size() - 1 << "]" << std::endl;
195  return -1;
196  }
197 
198  return TOF0[nTrigger];
199  }
200 
201  inline long long ProtoDUNEBeamSpill::GetTOF1(size_t nTrigger){
202  if( (nTrigger >= TOF1.size()) ){
203  std::cout << "Please input index in range [0," << TOF1.size() - 1 << "]" << std::endl;
204  return -1;
205  }
206 
207  return TOF1[nTrigger];
208  }
209  /////////////////////////////////
210 
211  std::vector< long long int > TOF1;
212  std::vector< long long int > TOF2;
213 
214  //Set of Cerenkov detectors
215  //
216  std::vector< CKov > CKov1;
217  std::vector< CKov > CKov2;
218 
219 }
220 
221 
222 #endif
std::bitset< 192 > fibers
intermediate_table::iterator iterator
std::vector< std::vector< FBM > > fiberMonitors
void AddCKov1Trigger(CKov theCKov)
long long int timeStamp
long long int timeStamp
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
std::vector< CKov > CKov2
std::vector< CKov > CKov1
void AddTOF0Trigger(long long theT)
short GetFiberStatus(size_t, size_t, size_t)
std::vector< long long int > TOF2
std::vector< long long int > TOF0
void AddTOF1Trigger(long long theT)
std::vector< long long int > TOF1
std::vector< long long int > TOF1
void AddCKov0Trigger(CKov theCKov)
long long GetFiberTime(size_t, size_t)
QTextStream & endl(QTextStream &s)