Public Member Functions | Private Attributes | List of all members
mix::OpDetWaveformMixer Class Reference

#include <OpDetWaveformMixer.h>

Public Member Functions

 OpDetWaveformMixer (bool p=false)
 Default constructor. More...
 
void DeclareData (std::vector< raw::OpDetWaveform > const &dataVector, std::vector< raw::OpDetWaveform > &outputVector)
 
void Mix (std::vector< raw::OpDetWaveform > const &mcVector, std::unordered_map< raw::Channel_t, float > const &map, std::vector< raw::OpDetWaveform > &outputVector)
 
void SetSaturationPoint (short x)
 
void SetMinSampleSize (size_t x)
 
virtual ~OpDetWaveformMixer ()
 Default destructor. More...
 

Private Attributes

bool _printWarnings
 
std::unordered_map< raw::Channel_t, size_t > fChannelIndexMap
 
RawDigitAdder_HardSaturate fRDAdderAlg
 
size_t fMinSampleSize
 

Detailed Description

Definition at line 35 of file OpDetWaveformMixer.h.

Constructor & Destructor Documentation

mix::OpDetWaveformMixer::OpDetWaveformMixer ( bool  p = false)
inline

Default constructor.

Definition at line 40 of file OpDetWaveformMixer.h.

40  :
41  _printWarnings(p){};
p
Definition: test.py:223
virtual mix::OpDetWaveformMixer::~OpDetWaveformMixer ( )
inlinevirtual

Default destructor.

Definition at line 56 of file OpDetWaveformMixer.h.

56 {};

Member Function Documentation

void OpDetWaveformMixer::DeclareData ( std::vector< raw::OpDetWaveform > const &  dataVector,
std::vector< raw::OpDetWaveform > &  outputVector 
)

Definition at line 11 of file OpDetWaveformMixer.cxx.

12  {
13 
14  fChannelIndexMap.clear();
15  outputVector.reserve(dataVector.size());
16 
17  for(auto const& od : dataVector){
18 
19 
20  outputVector.emplace_back(od);
21 
22  if(od.size() < fMinSampleSize) continue;
23 
24  //we're going to keep the longest one ... JUST handling beam gate stuff for now
25  auto my_channel = fChannelIndexMap.find(od.ChannelNumber());
26  if( my_channel != fChannelIndexMap.end() && outputVector[my_channel->second].size() > od.size())
27  continue;
28 
29  fChannelIndexMap[od.ChannelNumber()] = outputVector.size()-1;
30 
31  }
32 
33 }
std::unordered_map< raw::Channel_t, size_t > fChannelIndexMap
void OpDetWaveformMixer::Mix ( std::vector< raw::OpDetWaveform > const &  mcVector,
std::unordered_map< raw::Channel_t, float > const &  map,
std::vector< raw::OpDetWaveform > &  outputVector 
)

Definition at line 35 of file OpDetWaveformMixer.cxx.

37  {
38 
39 
40  for( auto const& od : mcVector){
41 
42  if(od.size() < fMinSampleSize) continue;
43 
44  auto it_ch = fChannelIndexMap.find(od.ChannelNumber());
45 
46  //if this channel is not in the data, skip this channel!
47  if(it_ch==fChannelIndexMap.end())
48  continue;
49 
50  size_t i_output = it_ch->second;
51 
52  fRDAdderAlg.SetPedestalInputs(2048,0.0); //HARDCODED PEDESTAL AT 2048!!!!!!!
53  fRDAdderAlg.SetScaleInputs(scale_map.at(od.ChannelNumber()),1.0);
54 
55  //If the sizes are not the same...
56  if(od.size() != outputVector[i_output].size()){
57 
58  if(_printWarnings)
59  std::cout << "WARNING! Two collections don't have same number of samples:\t"
60  << outputVector[i_output].size() << " " << od.size() << std::endl;
61 
62  //if the samples is larger, we make a new vector of the right size, trimmed down appropriately
63  if(od.size() > outputVector[i_output].size()){
64  std::vector<short> const& mc_trimmed = std::vector<short>(od.begin(),
65  od.begin()+outputVector[i_output].size());
66  fRDAdderAlg.AddRawDigits(mc_trimmed,outputVector[i_output]);
67  }
68  //if the samples is shorter, pad it out with the pedestal
69  else if(od.size() < outputVector[i_output].size()){
70  std::vector<short> mc_trimmed(outputVector[i_output].size(),0.0);
71  std::copy(od.begin(),od.end(),mc_trimmed.begin());
72  fRDAdderAlg.AddRawDigits(mc_trimmed,outputVector[i_output]);
73  }
74  }
75  //Sizes are the same? Easy!
76  else{
77  fRDAdderAlg.AddRawDigits(od,outputVector[i_output]);
78  }
79  }
80 
81 }
std::unordered_map< raw::Channel_t, size_t > fChannelIndexMap
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
void AddRawDigits(std::vector< short > const &, std::vector< short > const &, std::vector< short > &)
void SetPedestalInputs(float f1, float f2)
Definition: RawDigitAdder.h:52
RawDigitAdder_HardSaturate fRDAdderAlg
T copy(T const &v)
QTextStream & endl(QTextStream &s)
void mix::OpDetWaveformMixer::SetMinSampleSize ( size_t  x)
inline

Definition at line 52 of file OpDetWaveformMixer.h.

53  { fMinSampleSize = x; }
list x
Definition: train.py:276
void mix::OpDetWaveformMixer::SetSaturationPoint ( short  x)
inline

Definition at line 49 of file OpDetWaveformMixer.h.

RawDigitAdder_HardSaturate fRDAdderAlg
list x
Definition: train.py:276

Member Data Documentation

bool mix::OpDetWaveformMixer::_printWarnings
private

Definition at line 56 of file OpDetWaveformMixer.h.

std::unordered_map<raw::Channel_t,size_t> mix::OpDetWaveformMixer::fChannelIndexMap
private

Definition at line 63 of file OpDetWaveformMixer.h.

size_t mix::OpDetWaveformMixer::fMinSampleSize
private

Definition at line 67 of file OpDetWaveformMixer.h.

RawDigitAdder_HardSaturate mix::OpDetWaveformMixer::fRDAdderAlg
private

Definition at line 65 of file OpDetWaveformMixer.h.


The documentation for this class was generated from the following files: