150 std::vector<raw::RawDigit>
const& rawDigitVector(*rawDigitHandle);
155 std::vector<std::vector<short> > filterWf(n_channels);
158 std::map<int,raw::RawDigit> rawDigitMap;
159 std::map<int,float> pedestalMap;
160 unsigned int maxNumBins = 0;
162 rawDigitMap[digitIt->Channel()] = *digitIt;
163 pedestalMap[digitIt->Channel()] = digitIt->GetPedestal();
164 if (digitIt->NADC() > maxNumBins) maxNumBins = digitIt->NADC();
168 std::vector<std::vector<std::vector<unsigned int> > > Chs;
172 for (
size_t i = 0; i<3; ++i){
175 for (
unsigned int i = 0; i<n_channels; ++i){
176 unsigned int plane =
fChannelMap->PlaneFromOnlineChannel(i);
177 unsigned int rce =
fChannelMap->RCEFromOnlineChannel(i);
178 unsigned int regulator =
fChannelMap->RegulatorFromOnlineChannel(i);
179 Chs[plane][rce*2+regulator].push_back(i);
184 for (
size_t i = 0; i<3; ++i){
187 for (
unsigned int i = 0; i<n_channels; ++i){
188 unsigned int plane =
fChannelMap->PlaneFromOnlineChannel(i);
189 unsigned int rce =
fChannelMap->RCEFromOnlineChannel(i);
190 unsigned int asic =
fChannelMap->ASICFromOnlineChannel(i);
192 Chs[plane][rce*8+asic].push_back(i);
196 std::vector<Double_t> corrVals;
198 for (
unsigned int s = 0;
s < maxNumBins;
s++) {
199 for (
size_t i = 0; i<Chs.size(); ++i){
200 for (
size_t j = 0; j<Chs[i].size(); ++j){
203 for (
size_t k = 0;
k<Chs[i][j].size(); ++
k){
205 unsigned int offlineChan =
fChannelMap->Offline(Chs[i][j][
k]);
206 if (rawDigitMap.count(offlineChan) == 0)
208 int adc = rawDigitMap.at(offlineChan).ADC(
s);
209 if (
fSkipStuckCodes && ( (adc & 0x3F) == 0x0 || (adc & 0x3F) == 0x3F ) )
213 double mean = pedestalMap.at(offlineChan);
216 corrVals.push_back(adc - mean);
219 unsigned int corrValSize = corrVals.size();
220 sort(corrVals.begin(),corrVals.end());
221 double correction = 0;
224 else if ((corrValSize % 2) == 0)
225 correction = (corrVals[corrValSize/2] + corrVals[(corrValSize/2)-1])/2.0;
227 correction = corrVals[(corrValSize-1)/2];
229 for (
size_t k = 0; k<Chs[i][j].size(); ++
k){
231 unsigned int offlineChan =
fChannelMap->Offline(Chs[i][j][k]);
232 if (rawDigitMap.count(offlineChan) == 0)
234 int adc = rawDigitMap.at(offlineChan).ADC(
s);
235 double newAdc = adc - correction;
236 if (
fSkipStuckCodes && ( (adc & 0x3F) == 0x0 || (adc & 0x3F) == 0x3F ) )
243 filterWf.at(offlineChan).push_back(newAdc);
254 std::vector<raw::RawDigit> filterRawDigitVector;
255 for (
unsigned int ich = 0; ich < n_channels; ich++) {
256 if (rawDigitMap.count(ich) == 0)
258 raw::RawDigit theRawDigit(ich, filterWf.at(ich).size(), filterWf.at(ich));
259 theRawDigit.
SetPedestal(rawDigitMap[ich].GetPedestal(),
260 rawDigitMap[ich].GetSigma());
261 filterRawDigitVector.push_back(theRawDigit);
265 evt.
put(std::make_unique<decltype(filterRawDigitVector)>(
std::move(filterRawDigitVector)));
Collection of charge vs time digitized from a single readout channel.
std::string fRawDigitModuleLabel
art::ServiceHandle< geo::Geometry > fGeom
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
unsigned int fUpperSkipTick
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
void SetPedestal(float ped, float sigma=1.)
Set pedestal and its RMS (the latter is 0 by default)
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
unsigned int fLowerSkipTick
std::string fRawDigitModuleInstance