FlasherFinder.cxx
Go to the documentation of this file.
1 // C++ includes
2 #include <vector>
3 #include <algorithm>
4 #include <iostream>
5 
6 // NOvASoft includes
8 #include "RawData/RawDigit.h"
9 #include "RecoBase/CellHit.h"
10 #include "RecoBase/Cluster.h"
11 
12 using namespace dq;
13 
14 
15 //......................................................................
16 static bool gsFEBTimeSort(const FEBHit& h1, const FEBHit& h2)
17 {
18  if (h1.fFEB == h2.fFEB) return (h1.fTDC < h2.fTDC);
19  return h1.fFEB < h2.fFEB;
20 }
21 
22 
23 //......................................................................
25  fInstigatorQ(10000), //12-10,000 for FarDet, ~30,000 for NearDet, based on DocDB-13008, slides 21,22
26  fInstigatorT(64),
27  fVetoT(960), //640 (10 us), 960 (15 us), 1280 (20 us)
28  fVetoQ(500)
29 { }
30 
31 
32 //......................................................................
34 {
35  //
36  // Extract the information I need from the digit list then sort by
37  // FEB and time
38  //
39 
40  unsigned int i, j;
41  std::vector<FEBHit> febhit(d.size());
42  for (i=0; i<d.size(); ++i) {
43  febhit[i].fFEB = d[i]->DaqChannel() & 0xFFFFFF00; ///< Pixel is low 8 bits
44  febhit[i].fTDC = d[i]->TDC();
45  febhit[i].fADC = d[i]->ADC();
46  febhit[i].fDAQ = d[i]->DaqChannel();
47  }
48 
49  //
50  // Search for time windows where summed ADC crosses threshold
51  //
52  sort(febhit.begin(), febhit.end(), gsFEBTimeSort);
53  for (i=0; i<febhit.size(); ++i) {
54  unsigned int sumADC = 0;
55  for (j=i+1; j<febhit.size(); ++j) {
56  bool kInSameFEB = (febhit[j].fFEB == febhit[i].fFEB);
57  bool kInTime = ((febhit[j].fTDC - febhit[i].fTDC) < fInstigatorT);
58 
59  if (!kInSameFEB || !kInTime) break;
60  sumADC += febhit[j].fADC;
61  }
62 
63  //
64  // Check the ADC to see if it crossed threshold
65  //
66  if (sumADC>fInstigatorQ) {
67  fInstigators.push_back(febhit[i]);
68  }
69  }
70  fInstigatorsOK = true;
71  return fInstigators.size();
72 }
73 
74 
75 //......................................................................
77 {
79  unsigned int j;
80 
81  int DAQ = d->DaqChannel();
82  unsigned int TDC = d->TDC();
83 
84  for (j=0; j<fInstigators.size(); j++) {
85  if (fInstigators[j].fDAQ == DAQ && fInstigators[j].fTDC == TDC)
86  return true;
87  }
88 
89  return false;
90 }
91 
92 
93 //......................................................................
95 {
97  unsigned int j;
98 
99  int DAQ = ch->DaqChannel();
100  unsigned int TDC = ch->TDC();
101 
102  for (j=0; j<fInstigators.size(); j++) {
103  if (fInstigators[j].fDAQ == DAQ && fInstigators[j].fTDC == TDC)
104  return true;
105  }
106 
107  return false;
108 }
109 
110 
111 //......................................................................
113 {
114  if ((unsigned int)d->ADC() > fVetoQ) return false;
115 
117  unsigned int j;
118 
119  unsigned int feb = d->DaqChannel() & 0xFFFFFF00;
120  unsigned int tdc = d->TDC();
121 
122  for (j=0; j<fInstigators.size(); ++j) {
123  bool kInSameFEB = (fInstigators[j].fFEB == feb);
124  bool kInTime = (tdc > fInstigators[j].fTDC && tdc < fInstigators[j].fTDC + fVetoT);
125 
126  if (kInSameFEB && kInTime) return true;
127  }
128 
129  return false;
130 }
131 
132 
133 //......................................................................
135 {
136  if ((unsigned int)ch->ADC() > fVetoQ) return false;
137 
139  unsigned int j;
140 
141  unsigned int feb = ch->DaqChannel()&0xFFFFFF00;
142  unsigned int tdc = ch->TDC();
143 
144  for (j=0; j<fInstigators.size(); ++j) {
145  bool kInSameFEB = (fInstigators[j].fFEB == feb);
146  bool kInTime = (tdc > fInstigators[j].fTDC && tdc < fInstigators[j].fTDC + fVetoT);
147 
148  if (kInSameFEB && kInTime) return true;
149  }
150 
151  return false;
152 }
153 
154 
155 //......................................................................
157 {
158  std::vector<art::Ptr<rawdata::RawDigit>> filtered;
159  unsigned int i;
160  unsigned int nfilt = 0;
161 
162  for (i=0; i<d.size(); ++i) {
163  if (this->Veto(d[i])) {
164  ++nfilt;
165  }
166  else {
167  filtered.push_back(d[i]);
168  }
169  }
170 
171  swap(d, filtered);
172  return nfilt;
173 }
174 
175 
176 //......................................................................
177 std::vector<art::Ptr<rawdata::RawDigit>> FlasherFinder::FEBFlashHits(std::vector<art::Ptr<rawdata::RawDigit>>& d)
178 {
179  std::vector<art::Ptr<rawdata::RawDigit>> filtered;
180  for (unsigned int i=0; i<d.size(); ++i) {
181  if (this->Veto(d[i])) {
182  filtered.push_back(d[i]);
183  }
184  }
185 
186  return filtered;
187 }
188 
189 
190 //......................................................................
192 {
193  unsigned int i;
194  unsigned int nhit = 0;
195 
196  art::PtrVector<rb::CellHit> slicehits = c->AllCells();
197  for (i=0; i<slicehits.size(); ++i) {
198  if (this->Veto(slicehits[i])) ++nhit;
199  }
200 
201  return nhit;
202 }
int32_t TDC() const
The time of the last baseline sample.
Definition: RawDigit.h:94
unsigned int Nflash(const art::Ptr< rb::Cluster > &c) const
unsigned int fVetoQ
Only veto below this charge [ADC].
static bool gsFEBTimeSort(const FEBHit &h1, const FEBHit &h2)
bool IsInstigator(const art::Ptr< rawdata::RawDigit > &d) const
nhit
Definition: demo1.py:25
unsigned int fFEB
Definition: FlasherFinder.h:26
unsigned int fTDC
Definition: FlasherFinder.h:27
std::vector< FEBHit > fInstigators
The list of instigators.
unsigned int fInstigatorQ
Charge threshold for instigators [ADC].
unsigned int fVetoT
Time to veto FEB after instigator [TDC].
art::PtrVector< rb::CellHit > AllCells() const
Get all cells from both views.
Definition: Cluster.cxx:180
Flag FEB flashes and flag/filter hits they produce.
unsigned int FindInstigators(std::vector< art::Ptr< rawdata::RawDigit > > &d)
const Cut kInTime([](const caf::SRProxy *sr){return(sr->slc.meantime >=208000 && sr->slc.meantime<=236000);})
Cut events that are not in time 208us - 236us.
Definition: Cuts.h:32
uint32_t DaqChannel() const
Definition: RawDigit.h:85
Float_t d
Definition: plot.C:236
const double j
Definition: BetheBloch.cxx:29
bool Veto(const art::Ptr< rawdata::RawDigit > &d) const
unsigned int Filter(std::vector< art::Ptr< rawdata::RawDigit > > &d)
size_type size() const
Definition: PtrVector.h:308
TH1F * h2
Definition: plot.C:45
TH1F * h1
int16_t ADC(uint32_t i) const
Definition: RawDigit.cxx:58
unsigned int fInstigatorT
Time window for instigator hits [TDC].
assert(nhit_max >=nhit_nbins)
std::vector< art::Ptr< rawdata::RawDigit > > FEBFlashHits(std::vector< art::Ptr< rawdata::RawDigit >> &d)
Definition: fwd.h:28
bool fInstigatorsOK
Is the instigator list ready for use?