DaqChannelMask.cxx
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////
2 // \file: DaqChannelMask.cxx
3 // \brief Book-keeping for channels that need to be masked from an event
4 // \author Justin Vasel <justin.vasel@gmail.com>
5 // \date 2019-12-05
6 ////////////////////////////////////////////////////////////////////////
7 
8 // STL includes
9 #include <iostream>
10 #include <iterator>
11 #include <set>
12 
13 // NOvASOFT includes
14 #include "RawData/RawDigit.h"
15 #include "RecoBase/CellHit.h"
17 
18 
19 // ............................................................................
20 sn::DaqChannelMask::DaqChannelMask(float coldThreshold, float hotThreshold):
21 fColdThreshold(coldThreshold),
22 fHotThreshold(hotThreshold)
23 {
24 
25 }
26 
27 // ............................................................................
29 
30 // ............................................................................
32 {
33  if (this->fRatesCalculated) {
34  std::cout << "Channel rates have already been computed, so the mask is now immutable." << std::endl;
35  }
36 
37  std::map<unsigned int, float>::iterator it = this->fChannelRates.find(d.DaqChannel());
38  if (it != this->fChannelRates.end()) {
39  it->second += 1.0;
40  } else {
41  this->fChannelRates.insert(std::pair<unsigned int, float>(d.DaqChannel(), 1.0));
42  }
43 
44  ++this->fHitsAdded;
45 
46  return;
47 }
48 
49 // ............................................................................
51 {
52  if (this->fRatesCalculated) {
53  std::cout << "Channel rates have already been computed, so the mask is now immutable." << std::endl;
54  }
55 
56  std::map<unsigned int, float>::iterator it = this->fChannelRates.find(h.DaqChannel());
57  if (it != this->fChannelRates.end()) {
58  it->second += 1.0;
59  } else {
60  this->fChannelRates.insert(std::pair<unsigned int, float>(h.DaqChannel(), 1.0));
61  }
62 
63  return;
64 }
65 
66 // ............................................................................
68 {
69  this->fIntegratedDuration += i;
70 }
71 
72 // ............................................................................
74 {
75  return this->fIntegratedDuration;
76 }
77 
78 // ............................................................................
80 {
81  for (std::map<unsigned int, float>::iterator channel = this->fChannelRates.begin(); channel != this->fChannelRates.end(); ++channel) {
82  // compute rate
83  // std::cout << "Channel " << channel->first << ": " << channel->second << " hits / " << (this->fIntegratedDuration / 5e-3) << "s";
84  channel->second /= (this->fIntegratedDuration / 5e-3);
85  // channel->second /= this->fHitsAdded;
86  // std::cout << " (" << channel->second << " Hz)" << std::endl;
87 
88 
89  // determine if channel needs to be masked
90  if (channel->second < this->fColdThreshold) {
91  this->fChannelMask.insert(channel->first);
92  ++this->fNumColdChannels;
93  }
94  if (channel->second > this->fHotThreshold) {
95  this->fChannelMask.insert(channel->first);
96  ++this->fNumHotChannels;
97  }
98  }
99 
100  this->fRatesCalculated = true;
101 
102  return;
103 }
104 
105 // ............................................................................
107 {
108  return this->fRatesCalculated == true;
109 }
110 
111 
112 // ............................................................................
114 {
115  return this->fChannelRates[d.DaqChannel()];
116 }
117 
118 
119 // ............................................................................
121 {
122  return this->fChannelRates[h.DaqChannel()];
123 }
124 
125 
126 // ............................................................................
128 {
129  std::set<unsigned int>::iterator loc = this->fChannelMask.find(d.DaqChannel());
130  return loc != this->fChannelMask.end();
131 }
132 
133 
134 // ............................................................................
136 {
137  std::set<unsigned int>::iterator loc = this->fChannelMask.find(h.DaqChannel());
138  return loc != this->fChannelMask.end();
139 }
140 
141 
142 // ............................................................................
144 {
145  return this->fChannelMask.size();
146 }
147 
148 
149 // ............................................................................
151 {
152  return this->fChannelRates.size();
153 }
154 
155 
156 // ............................................................................
157 std::map<unsigned int, float> sn::DaqChannelMask::GetRates()
158 {
159  return this->fChannelRates;
160 }
161 
162 
163 // ............................................................................
165 {
166  std::cout << "COLD/HOT CHANNEL MASK DETAILS" << std::endl;
167  std::cout << "-----------------------------" << std::endl;
168  std::cout << "Cold Channels: " << this->fNumColdChannels << std::endl;
169  std::cout << "Hot Channels: " << this->fNumHotChannels << std::endl;
170  std::cout << "-----------------------------" << std::endl;
171 }
set< int >::iterator it
std::map< unsigned int, float > fChannelRates
void IncrementDuration(float i)
float Rate(rawdata::RawDigit d)
std::map< unsigned int, float > GetRates()
uint32_t DaqChannel() const
Definition: RawDigit.h:85
Float_t d
Definition: plot.C:236
std::set< unsigned int > fChannelMask
OStream cout
Definition: OStream.cxx:6
A rawdata::RawDigit with channel information decoded.
Definition: CellHit.h:27
bool ChannelIsMasked(rawdata::RawDigit d)
void AddHit(rawdata::RawDigit d)
Float_t e
Definition: plot.C:35
DaqChannelMask(float coldThreshold, float hotThreshold)