Public Member Functions | Private Attributes | List of all members
unstick::UnstickADCCodes Class Reference
Inheritance diagram for unstick::UnstickADCCodes:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 UnstickADCCodes (fhicl::ParameterSet const &pset)
 
virtual ~UnstickADCCodes ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
 ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Attributes

std::string fDigitModuleLabel
 constants More...
 
std::string fSpillName
 
raw::Compress_t fCompression
 compression type to use More...
 
const unsigned int onemask = 0x003f
 Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND. More...
 
unsigned int fStickyADCCodesLimit
 Number of ADC codes to check for stickiness at 0x00 or 0x3f before stopping. More...
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

Definition at line 43 of file UnstickADCCodes_module.cc.

Constructor & Destructor Documentation

unstick::UnstickADCCodes::UnstickADCCodes ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 77 of file UnstickADCCodes_module.cc.

77  : EDProducer{pset}
78  {
79  this->reconfigure(pset);
80  produces< std::vector<raw::RawDigit> >(fSpillName);
81 
82  }
void reconfigure(fhicl::ParameterSet const &p)
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
unstick::UnstickADCCodes::~UnstickADCCodes ( )
virtual

Definition at line 85 of file UnstickADCCodes_module.cc.

86  {
87  }

Member Function Documentation

void unstick::UnstickADCCodes::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 106 of file UnstickADCCodes_module.cc.

107  {
108  }
void unstick::UnstickADCCodes::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 111 of file UnstickADCCodes_module.cc.

112  {
113  }
void unstick::UnstickADCCodes::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 116 of file UnstickADCCodes_module.cc.

117  {
118 
119  // make an unique_ptr of sim::SimDigits that allows ownership of the produced
120  // digits to be transferred to the art::Event after the put statement below
121  std::unique_ptr< std::vector<raw::RawDigit> > digcol(new std::vector<raw::RawDigit>);
122 
123  // Read in the digit List object(s).
125  auto digitVecHandle = evt.getHandle< std::vector<raw::RawDigit> >(itag1);
126 
127  if (!digitVecHandle->size()) return;
128  mf::LogInfo("UnstickADCCodes") << "UnstickADCCodes:: digitVecHandle size is " << digitVecHandle->size();
129 
130  // Use the handle to get a particular (0th) element of collection.
131  art::Ptr<raw::RawDigit> digitVec0(digitVecHandle, 0);
132 
133  unsigned int dataSize = digitVec0->Samples(); //size of raw data vectors
134 
135 
136  raw::ChannelID_t channel = raw::InvalidChannelID; // channel number
137 
138  std::vector<short> rawadc(dataSize); // vector holding uncompressed adc values
139 
140  short *rawadc_a=0;
141 
142  // loop over all raw digits
143  digcol->reserve(digitVecHandle->size());
144  for(size_t rdIter = 0; rdIter < digitVecHandle->size(); ++rdIter){ // ++ move
145 
146  // get the reference to the current raw::RawDigit
147  art::Ptr<raw::RawDigit> digitVec(digitVecHandle, rdIter);
148  channel = digitVec->Channel();
149  fCompression = digitVec->Compression();
150  float pedestal = digitVec->GetPedestal();
151  // uncompress the data
152 
153  int pedestal_value = (int) digitVec->GetPedestal();
154  raw::Uncompress(digitVec->ADCs(), rawadc, pedestal_value, fCompression);
155  dataSize = rawadc.size();
156  rawadc_a = rawadc.data();
157 
158  // loop over raw ADC vector and interpolate over stuck values
159  for(size_t i = 0; i < dataSize; ++i){
160 
161  unsigned int sixlsbs = rawadc_a[i] & onemask;
162 
163  if(sixlsbs==onemask || sixlsbs==0){ //ADC code is stuck at 0x3f or 0x00
164 
165 
166  if(i==0){ //if first ADC code is stuck, set it equal to pedestal value
167  rawadc_a[i] = (short) pedestal;
168  continue;
169  }
170 
171  //find nearest preceding unstuck ADC code
172  //which should be immediately preceding ADC code since all earlier ADC codes have been interpolated to non-stuck values
173  size_t last_unstuck = i > 0 ? i - 1 : 0;
174 
175 
176  //find nearest following unstuck ADC code
177  size_t next_unstuck = i;
178  unsigned short next_unstuck_sixlsbs;
179  unsigned short sixlsbs_stuck_in_a_row = 0;
180 
181  do{
182 
183  if(next_unstuck < dataSize - 1 && sixlsbs_stuck_in_a_row < fStickyADCCodesLimit)
184  ++next_unstuck;
185  else{
186  rawadc_a[next_unstuck] = (short) pedestal;
187  break;
188  }
189  next_unstuck_sixlsbs = rawadc_a[next_unstuck] & onemask;
190  if(next_unstuck_sixlsbs==0 || next_unstuck_sixlsbs==onemask)
191  ++sixlsbs_stuck_in_a_row;
192  else
193  sixlsbs_stuck_in_a_row = 0;
194 
195  }
196  while(next_unstuck_sixlsbs==onemask || next_unstuck_sixlsbs==0);
197 
198  // With last and next unstuck ADC codes found, interpolate linearly and replace stuck ADC code
199 
200 
201  float interpolated_unstuck_value = 1.0*(rawadc_a[next_unstuck] - rawadc_a[last_unstuck])/(next_unstuck-last_unstuck)*(i-last_unstuck)+rawadc_a[last_unstuck];
202  rawadc_a[i] = (short) interpolated_unstuck_value;
203 
204  }
205 
206 
207  }
208 
209  raw::RawDigit rd(channel, dataSize, rawadc, raw::kNone );
210  rd.SetPedestal( digitVec->GetPedestal(), digitVec->GetSigma() );
211  digcol->push_back(rd);
212 
213  }
214 
215  evt.put(std::move(digcol), fSpillName);
216 
217  return;
218  }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::string fDigitModuleLabel
constants
uint8_t channel
Definition: CRTFragment.hh:201
const unsigned int onemask
Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND.
no compression
Definition: RawTypes.h:9
constexpr ChannelID_t InvalidChannelID
ID of an invalid channel.
Definition: RawTypes.h:32
def move(depos, offset)
Definition: depos.py:107
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
unsigned int ChannelID_t
Type representing the ID of a readout channel.
Definition: RawTypes.h:28
unsigned int fStickyADCCodesLimit
Number of ADC codes to check for stickiness at 0x00 or 0x3f before stopping.
raw::Compress_t fCompression
compression type to use
void Uncompress(const std::vector< short > &adc, std::vector< short > &uncompressed, raw::Compress_t compress)
Uncompresses a raw data buffer.
Definition: raw.cxx:776
void unstick::UnstickADCCodes::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 90 of file UnstickADCCodes_module.cc.

91  {
92 
93  fDigitModuleLabel = p.get< std::string >("DigitModuleLabel", "daq");
94  fStickyADCCodesLimit = p.get< unsigned int >("StickyADCCodesLimit");
95  fSpillName.clear();
96 
97  size_t pos = fDigitModuleLabel.find(":");
98  if( pos!=std::string::npos ) {
99  fSpillName = fDigitModuleLabel.substr( pos+1 );
100  fDigitModuleLabel = fDigitModuleLabel.substr( 0, pos );
101  }
102 
103  }
std::string string
Definition: nybbler.cc:12
std::string fDigitModuleLabel
constants
p
Definition: test.py:223
unsigned int fStickyADCCodesLimit
Number of ADC codes to check for stickiness at 0x00 or 0x3f before stopping.

Member Data Documentation

raw::Compress_t unstick::UnstickADCCodes::fCompression
private

compression type to use

Definition at line 65 of file UnstickADCCodes_module.cc.

std::string unstick::UnstickADCCodes::fDigitModuleLabel
private

constants

module that made digits

Definition at line 59 of file UnstickADCCodes_module.cc.

std::string unstick::UnstickADCCodes::fSpillName
private

nominal spill is an empty string it is set by the DigitModuleLabel ex.: "daq:preSpill" for prespill data

Definition at line 61 of file UnstickADCCodes_module.cc.

unsigned int unstick::UnstickADCCodes::fStickyADCCodesLimit
private

Number of ADC codes to check for stickiness at 0x00 or 0x3f before stopping.

Definition at line 68 of file UnstickADCCodes_module.cc.

const unsigned int unstick::UnstickADCCodes::onemask = 0x003f
private

Unsigned int ending in 111111 used to select 6 LSBs with bitwise AND.

Definition at line 67 of file UnstickADCCodes_module.cc.


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