Public Member Functions | Private Types | Private Attributes | List of all members
StandardRawDigitExtractService Class Reference

#include <StandardRawDigitExtractService.h>

Inheritance diagram for StandardRawDigitExtractService:
RawDigitExtractService

Public Member Functions

 StandardRawDigitExtractService (fhicl::ParameterSet const &pset, art::ActivityRegistry &)
 
int extract (AdcChannelData &acd) const
 
std::ostream & print (std::ostream &out=std::cout, std::string prefix="") const
 
- Public Member Functions inherited from RawDigitExtractService
virtual ~RawDigitExtractService ()=default
 

Private Types

using AcdModifierPtr = std::unique_ptr< const AdcChannelTool >
 

Private Attributes

int m_LogLevel
 
std::string m_ROIBuilderTool
 
std::string m_DigitReadTool
 
int m_PedestalOption
 
bool m_FlagStuckOff
 
bool m_FlagStuckOn
 
AcdModifierPtr m_pDigitReadTool
 
AcdModifierPtr m_pROIBuilderTool
 
const lariov::DetPedestalProviderm_pPedProv
 
PedestalEvaluationServicem_PedestalEvaluationService
 

Detailed Description

Definition at line 35 of file StandardRawDigitExtractService.h.

Member Typedef Documentation

using StandardRawDigitExtractService::AcdModifierPtr = std::unique_ptr<const AdcChannelTool>
private

Definition at line 47 of file StandardRawDigitExtractService.h.

Constructor & Destructor Documentation

StandardRawDigitExtractService::StandardRawDigitExtractService ( fhicl::ParameterSet const &  pset,
art::ActivityRegistry  
)

Definition at line 20 of file StandardRawDigitExtractService_service.cc.

21 : m_LogLevel(1),
22  m_pDigitReadTool(nullptr),
23  m_pROIBuilderTool(nullptr),
24  m_pPedProv(nullptr) {
25  const string myname = "StandardRawDigitExtractService::ctor: ";
26  pset.get_if_present<int>("LogLevel", m_LogLevel);
27  pset.get_if_present<string>("ROIBuilderTool", m_ROIBuilderTool);
28  m_DigitReadTool = pset.get<string>("DigitReadTool");
29  m_PedestalOption = pset.get<int>("PedestalOption");
30  m_FlagStuckOff = pset.get<bool>("FlagStuckOff");
31  m_FlagStuckOn = pset.get<bool>("FlagStuckOn");
32  // Retrieve tools
34  if ( ptm == nullptr ) {
35  cout << myname << "ERROR: Unable to retrieve tool manaager." << endl;
36  } else {
39  if ( m_pDigitReadTool == nullptr ) {
40  cout << myname << "ERROR: Unable to retrieve digit reader " << m_DigitReadTool << endl;
41  } else {
42  if ( m_LogLevel ) cout << myname << "Retrieved digit read tool " << m_DigitReadTool << endl;
43  }
44  }
45  // Retrieve pedestal provider.
46  if ( m_PedestalOption == 2 ) {
47  if ( m_LogLevel ) cout << myname << "Fetching pedestal provider." << endl;
49  if ( m_LogLevel ) cout << myname << " Pedestal provider: @" << m_pPedProv << endl;
50  }
51  if ( m_PedestalOption == 3 ) {
52  if ( m_LogLevel ) cout << myname << "Fetching pedestal evaluation service." << endl;
54  if ( m_LogLevel ) cout << myname << " Pedestal evaluation service: @"
56  }
57  print(cout, myname);
58 }
PedestalEvaluationService * m_PedestalEvaluationService
const lariov::DetPedestalProvider * m_pPedProv
std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)

Member Function Documentation

int StandardRawDigitExtractService::extract ( AdcChannelData acd) const
virtual

Implements RawDigitExtractService.

Definition at line 62 of file StandardRawDigitExtractService_service.cc.

62  {
63  const string myname = "StandardRawDigitExtractService:extract: ";
64  const raw::RawDigit* pdig = acd.digit;
65  if ( pdig == nullptr ) {
66  cout << myname << "ERROR: ADC channel does not have a larsoft digit." << endl;
67  return 1;
68  }
69  const raw::RawDigit& dig = *pdig;
70  if ( m_LogLevel >= 2 ) {
71  cout << myname << "Entering..." << endl;
72  cout << myname << "Input vector size: " << dig.Samples() << endl;
73  }
74  if ( acd.samples.size() ) {
75  cout << myname << "ERROR: Channel has data." << endl;
76  return 2;
77  }
78  if ( acd.flags.size() ) {
79  cout << myname << "ERROR: Channel has flags." << endl;
80  return 3;
81  }
82  if ( m_pDigitReadTool ) {
83  m_pDigitReadTool->update(acd);
84  } else {
85  cout << myname << "ERROR: Digit read tool " << m_DigitReadTool << " was not found." << endl;
86  }
87  unsigned int nsig = acd.raw.size();
88  acd.flags.resize(nsig, AdcGood);
89  acd.samples.resize(nsig, -999);
90  // Retrieve pedestal.
91  AdcSignal ped = 0.0;
92  AdcSignal pedrms = 0.0;
93  if ( m_PedestalOption == 1 ) {
94  ped = dig.GetPedestal();
95  pedrms = dig.GetSigma();
96  } else if ( m_PedestalOption == 2 ) {
97  ped = m_pPedProv->PedMean(acd.channel());
98  }
99  acd.pedestal = ped;
100  acd.pedestalRms = pedrms;
101  // Convert int -> float, subtract pedestal and set conversion flag.
102  const AdcCount lowbits = 0x3f;
103  for ( unsigned int isig=0; isig<nsig; ++isig ) {
104  AdcCount adc = acd.raw[isig];
105  AdcCount adclow = adc & lowbits;
106  acd.samples[isig] = adc - ped;
107  if ( adc == 0 ) acd.flags[isig] = AdcUnderflow;
108  else if ( adc >= 4095 ) acd.flags[isig] = AdcOverflow;
109  else if ( m_FlagStuckOff && adclow == 0 ) acd.flags[isig] = AdcStuckOff;
110  else if ( m_FlagStuckOn && adclow == lowbits ) acd.flags[isig] = AdcStuckOn;
111  }
112  if ( m_PedestalOption == 3 ) {
113 
114  //optional: build ROI and exclude ROI from pedestal calculation
115  if( m_ROIBuilderTool.size() )
116  {
117  m_pROIBuilderTool->update(acd);
118  }
119 
121  for ( unsigned int isig=0; isig<nsig; ++isig ) {
122  acd.samples[isig] -= ped;
123  }
124  acd.pedestal += ped;
125  }
126  return 0;
127 }
float GetPedestal() const
Definition: RawDigit.h:214
ULong64_t Samples() const
Number of samples in the uncompressed ADC data.
Definition: RawDigit.h:213
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
float AdcSignal
Definition: AdcTypes.h:21
int16_t adc
Definition: CRTFragment.hh:202
const AdcFlag AdcUnderflow
Definition: AdcTypes.h:33
virtual int evaluate(const AdcChannelData &data, AdcSignal *pped=nullptr, AdcSignal *prms=nullptr, AdcSignal *ppederr=nullptr, AdcSignal *prmserr=nullptr) const =0
const raw::RawDigit * digit
const AdcFlag AdcGood
Definition: AdcTypes.h:32
AdcSignal pedestalRms
const AdcFlag AdcOverflow
Definition: AdcTypes.h:34
const AdcFlag AdcStuckOn
Definition: AdcTypes.h:37
AdcCountVector raw
PedestalEvaluationService * m_PedestalEvaluationService
const AdcFlag AdcStuckOff
Definition: AdcTypes.h:36
Channel channel() const
AdcSignal pedestal
virtual float PedMean(raw::ChannelID_t ch) const =0
Retrieve pedestal information.
short AdcCount
Definition: AdcTypes.h:18
const lariov::DetPedestalProvider * m_pPedProv
float GetSigma() const
TODO RMS of the pedestal level?
Definition: RawDigit.h:215
AdcSignalVector samples
QTextStream & endl(QTextStream &s)
AdcFlagVector flags
std::ostream & StandardRawDigitExtractService::print ( std::ostream &  out = std::cout,
std::string  prefix = "" 
) const
virtual

Implements RawDigitExtractService.

Definition at line 132 of file StandardRawDigitExtractService_service.cc.

132  {
133  out << prefix << "StandardRawDigitExtractService:" << endl;
134  out << prefix << " LogLevel: " << m_LogLevel << endl;
135  out << prefix << " DigitReadTool: " << m_DigitReadTool << endl;
136  out << prefix << " PedestalOption: " << m_PedestalOption << endl;
137  out << prefix << " FlagStuckOff: " << m_FlagStuckOff << endl;
138  out << prefix << " FlagStuckOn: " << m_FlagStuckOn << endl;
139  return out;
140 }
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::string StandardRawDigitExtractService::m_DigitReadTool
private

Definition at line 52 of file StandardRawDigitExtractService.h.

bool StandardRawDigitExtractService::m_FlagStuckOff
private

Definition at line 54 of file StandardRawDigitExtractService.h.

bool StandardRawDigitExtractService::m_FlagStuckOn
private

Definition at line 55 of file StandardRawDigitExtractService.h.

int StandardRawDigitExtractService::m_LogLevel
private

Definition at line 50 of file StandardRawDigitExtractService.h.

AcdModifierPtr StandardRawDigitExtractService::m_pDigitReadTool
private

Definition at line 57 of file StandardRawDigitExtractService.h.

PedestalEvaluationService* StandardRawDigitExtractService::m_PedestalEvaluationService
private

Definition at line 61 of file StandardRawDigitExtractService.h.

int StandardRawDigitExtractService::m_PedestalOption
private

Definition at line 53 of file StandardRawDigitExtractService.h.

const lariov::DetPedestalProvider* StandardRawDigitExtractService::m_pPedProv
private

Definition at line 60 of file StandardRawDigitExtractService.h.

AcdModifierPtr StandardRawDigitExtractService::m_pROIBuilderTool
private

Definition at line 58 of file StandardRawDigitExtractService.h.

std::string StandardRawDigitExtractService::m_ROIBuilderTool
private

Definition at line 51 of file StandardRawDigitExtractService.h.


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