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

#include <RawDigitAdderAna.hh>

Public Member Functions

 RawDigitAdderAna (size_t sample=100, std::vector< raw::ChannelID_t > special_channels=std::vector< raw::ChannelID_t >(0), bool print_bad=true, std::string in1label="in1", std::string in2label="in2", std::string sumlabel="sum")
 Default constructor. More...
 
virtual ~RawDigitAdderAna ()
 Default destructor. More...
 
size_t CheckOverlay (std::vector< raw::RawDigit > const &in1, std::vector< raw::RawDigit > const &in2, std::vector< raw::RawDigit > const &sum)
 
void CreateOutputHistograms (std::vector< TH1S * > const histoPtrVector, std::vector< raw::RawDigit > const &in1, std::vector< raw::RawDigit > const &in2, std::vector< raw::RawDigit > const &sum, unsigned int run, unsigned int event)
 

Private Member Functions

void ResetOutput ()
 
void CreateHistogram (TH1S *histo, raw::RawDigit const &waveform, unsigned int run, unsigned int event, unsigned int channel, std::string label)
 

Private Attributes

size_t fChannelSampleInterval
 
std::vector< raw::ChannelID_tfChannelsSpecial
 
bool fPrintBadOverlays
 
std::string fInput1Label
 
std::string fInput2Label
 
std::string fSumLabel
 
std::vector< raw::ChannelID_tfChannelsToPrint
 
std::vector< raw::ChannelID_tfChannelsBadOverlay
 

Detailed Description

Definition at line 26 of file RawDigitAdderAna.hh.

Constructor & Destructor Documentation

mix::RawDigitAdderAna::RawDigitAdderAna ( size_t  sample = 100,
std::vector< raw::ChannelID_t special_channels = std::vector<raw::ChannelID_t>(0),
bool  print_bad = true,
std::string  in1label = "in1",
std::string  in2label = "in2",
std::string  sumlabel = "sum" 
)

Default constructor.

Definition at line 11 of file RawDigitAdderAna.cxx.

17  : fChannelSampleInterval(sample),
18  fChannelsSpecial(special_channels),
19  fPrintBadOverlays(print_bad),
20  fInput1Label(in1label),
21  fInput2Label(in2label),
22  fSumLabel(sumlabel)
23 {
24 }
std::vector< raw::ChannelID_t > fChannelsSpecial
virtual mix::RawDigitAdderAna::~RawDigitAdderAna ( )
inlinevirtual

Default destructor.

Definition at line 39 of file RawDigitAdderAna.hh.

39 {};

Member Function Documentation

size_t mix::RawDigitAdderAna::CheckOverlay ( std::vector< raw::RawDigit > const &  in1,
std::vector< raw::RawDigit > const &  in2,
std::vector< raw::RawDigit > const &  sum 
)

Definition at line 31 of file RawDigitAdderAna.cxx.

34 {
35 
36  ResetOutput();
37 
38  //check size of all the rawdigit vectors
39  if(in1.size()!=in2.size() ||
40  in1.size()!=sum.size() )
41  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input vector lists not equal size.");
42 
43  for(size_t i_ch=0; i_ch<sum.size(); i_ch++){
44 
45  //check to make sure channels are same
46  if(in1[i_ch].Channel()!=in2[i_ch].Channel() ||
47  in1[i_ch].Channel()!=sum[i_ch].Channel())
48  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input vector lists out of order.");
49 
50  //check to make sure channels have same ADC vector
51  if(in1[i_ch].ADCs().size()!=in2[i_ch].ADCs().size() ||
52  in1[i_ch].ADCs().size()!=sum[i_ch].ADCs().size())
53  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input channels have different sizes.");
54 
55  bool print= ( (in1[i_ch].Channel()%fChannelSampleInterval==0) ||
56  (std::find(fChannelsSpecial.begin(),fChannelsSpecial.end(),in1[i_ch].Channel())!=fChannelsSpecial.end()) );
57 
58  for(size_t i_t=0; i_t<sum[i_ch].ADCs().size(); i_t++){
59  if( (in1[i_ch].ADCs()[i_t]+in2[i_ch].ADCs()[i_t])==sum[i_ch].ADCs()[i_t] )
60  continue;
61 
62  fChannelsBadOverlay.emplace_back(in1[i_ch].Channel());
63  if(fPrintBadOverlays) print=true;
64  break;
65  }
66 
67  if(print) fChannelsToPrint.emplace_back(in1[i_ch].Channel());
68 
69  }
70 
71  return fChannelsToPrint.size()*3;
72 
73 }
std::vector< raw::ChannelID_t > fChannelsToPrint
std::vector< raw::ChannelID_t > fChannelsBadOverlay
std::vector< raw::ChannelID_t > fChannelsSpecial
ChannelMappingService::Channel Channel
void mix::RawDigitAdderAna::CreateHistogram ( TH1S *  histo,
raw::RawDigit const &  waveform,
unsigned int  run,
unsigned int  event,
unsigned int  channel,
std::string  label 
)
private

Definition at line 75 of file RawDigitAdderAna.cxx.

81 {
82  std::stringstream hname,htitle;
83  hname << "h_" << label
84  << "_run" << run
85  << "_ev" << event
86  << "_ch" << channel;
87  htitle << "Waveform, Channel " << channel
88  << ", Event " << event
89  << ", Run " << run
90  << ", Input " << label;
91  histo->SetName(hname.str().c_str());
92  histo->SetTitle(htitle.str().c_str());
93  histo->SetBins(waveform.ADCs().size(),0,waveform.ADCs().size());
94 
95  for(size_t i_t=0; i_t<waveform.ADCs().size(); i_t++)
96  histo->SetBinContent(i_t,waveform.ADCs()[i_t]);
97 
98 }
unsigned int run
void mix::RawDigitAdderAna::CreateOutputHistograms ( std::vector< TH1S * > const  histoPtrVector,
std::vector< raw::RawDigit > const &  in1,
std::vector< raw::RawDigit > const &  in2,
std::vector< raw::RawDigit > const &  sum,
unsigned int  run,
unsigned int  event 
)

Definition at line 101 of file RawDigitAdderAna.cxx.

106 {
107 
108  if(histoPtrVector.size()!=fChannelsToPrint.size())
109  throw std::runtime_error("Error in RawDigitAdderAna::CreateOutputHistograms : Histogram output vector not equal to channels to print.");
110 
111 
112  //check size of all the rawdigit vectors
113  if(in1.size()!=in2.size() ||
114  in1.size()!=sum.size() )
115  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input vector lists not equal size.");
116 
117  size_t histo_count=0;
118 
119  for(size_t i_ch=0; i_ch<sum.size(); i_ch++){
120 
121  //check to make sure channels are same
122  if(in1[i_ch].Channel()!=in2[i_ch].Channel() ||
123  in1[i_ch].Channel()!=sum[i_ch].Channel())
124  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input vector lists out of order.");
125 
126  if(std::find(fChannelsToPrint.begin(),fChannelsToPrint.end(),in1[i_ch].Channel())==fChannelsToPrint.end())
127  continue;
128 
129  //check to make sure channels have same ADC vector
130  if(in1[i_ch].ADCs().size()!=in2[i_ch].ADCs().size() ||
131  in1[i_ch].ADCs().size()!=sum[i_ch].ADCs().size())
132  throw std::runtime_error("Error in RawDigitAdderAna::CheckOverlay : Input channels have different sizes.");
133 
134  CreateHistogram(histoPtrVector.at(histo_count),
135  in1[i_ch],
136  run,event,in1[i_ch].Channel(),
137  fInput1Label);
138  histo_count++;
139  CreateHistogram(histoPtrVector.at(histo_count),
140  in2[i_ch],
141  run,event,in2[i_ch].Channel(),
142  fInput2Label);
143  histo_count++;
144  CreateHistogram(histoPtrVector.at(histo_count),
145  sum[i_ch],
146  run,event,sum[i_ch].Channel(),
147  fSumLabel);
148  histo_count++;
149 
150  }
151 
152 }
void CreateHistogram(TH1S *histo, raw::RawDigit const &waveform, unsigned int run, unsigned int event, unsigned int channel, std::string label)
std::vector< raw::ChannelID_t > fChannelsToPrint
ChannelMappingService::Channel Channel
unsigned int run
void mix::RawDigitAdderAna::ResetOutput ( )
private

Definition at line 26 of file RawDigitAdderAna.cxx.

26  {
27  fChannelsToPrint.clear();
28  fChannelsBadOverlay.clear();
29 }
std::vector< raw::ChannelID_t > fChannelsToPrint
std::vector< raw::ChannelID_t > fChannelsBadOverlay

Member Data Documentation

size_t mix::RawDigitAdderAna::fChannelSampleInterval
private

Definition at line 53 of file RawDigitAdderAna.hh.

std::vector<raw::ChannelID_t> mix::RawDigitAdderAna::fChannelsBadOverlay
private

Definition at line 60 of file RawDigitAdderAna.hh.

std::vector<raw::ChannelID_t> mix::RawDigitAdderAna::fChannelsSpecial
private

Definition at line 54 of file RawDigitAdderAna.hh.

std::vector<raw::ChannelID_t> mix::RawDigitAdderAna::fChannelsToPrint
private

Definition at line 59 of file RawDigitAdderAna.hh.

std::string mix::RawDigitAdderAna::fInput1Label
private

Definition at line 56 of file RawDigitAdderAna.hh.

std::string mix::RawDigitAdderAna::fInput2Label
private

Definition at line 57 of file RawDigitAdderAna.hh.

bool mix::RawDigitAdderAna::fPrintBadOverlays
private

Definition at line 55 of file RawDigitAdderAna.hh.

std::string mix::RawDigitAdderAna::fSumLabel
private

Definition at line 58 of file RawDigitAdderAna.hh.


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