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

Public Member Functions

 FilterWF (fhicl::ParameterSet const &pset)
 
virtual ~FilterWF ()
 
virtual void produce (art::Event &evt) override
 
void reconfigure (fhicl::ParameterSet const &pset)
 
void beginRun (art::Run &run) override
 
void beginJob () override
 
void endRun (art::Run &run) override
 
- 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 ()
 
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 fRawDigitModuleLabel
 
std::string fRawDigitModuleInstance
 
bool fSkipStuckCodes
 
bool fSkipTicks
 
unsigned int fLowerSkipTick
 
unsigned int fUpperSkipTick
 
int fMethod
 
art::ServiceHandle< geo::GeometryfGeom
 
art::ServiceHandle< lbne::ChannelMapService > fChannelMap
 

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 65 of file FilterWF_module.cc.

Constructor & Destructor Documentation

lbne::FilterWF::FilterWF ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 96 of file FilterWF_module.cc.

96  : EDProducer{pset} {
97  this->reconfigure(pset);
98  produces<std::vector<raw::RawDigit> >();
99 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void reconfigure(fhicl::ParameterSet const &pset)
lbne::FilterWF::~FilterWF ( )
virtual

Definition at line 102 of file FilterWF_module.cc.

102  {
103 }

Member Function Documentation

void lbne::FilterWF::beginJob ( )
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 123 of file FilterWF_module.cc.

123  {
125  /*
126  int NHisto =0;
127  for (int Plane=0; Plane<3; Plane++) {
128  for (int Reg=0; Reg < 128; ++Reg) {
129  ++NHisto;
130  std::stringstream oss;
131  oss << "Channel_vs_tick_" << Plane << "_" << Reg;
132  std::string Title = oss.str();
133  std::cout << oss.str() << " " << Title << std::endl;
134  Channel_vs_tick[Plane][Reg] = tfs->make<TH2D>(Title.c_str(),"Plot of Channel vs Tick; Tick; Channel", 6000, 0., 6000., 14, -0.5, 13.5);
135  }
136  }
137  */
138 }
void lbne::FilterWF::beginRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 119 of file FilterWF_module.cc.

119  {
120  return;
121 }
void lbne::FilterWF::endRun ( art::Run run)
overridevirtual

Reimplemented from art::EDProducer.

Definition at line 141 of file FilterWF_module.cc.

141  {
142  return;
143 }
void lbne::FilterWF::produce ( art::Event evt)
overridevirtual

Implements art::EDProducer.

Definition at line 146 of file FilterWF_module.cc.

146  {
147 
150  std::vector<raw::RawDigit> const& rawDigitVector(*rawDigitHandle);
151 
152  // define temporary vector to hold filtered waveforms
153  const unsigned int n_channels = fGeom->Nchannels();
154  //const unsigned int n_channels = fGeom->rawDigitVector.size();
155  std::vector<std::vector<short> > filterWf(n_channels); // MW: I had to make this a vector of shorts to make it compile (the RawDigit constructor does not accept ADC as float)
156 
157  // raw digit map
158  std::map<int,raw::RawDigit> rawDigitMap;
159  std::map<int,float> pedestalMap;
160  unsigned int maxNumBins = 0;
161  for (std::vector<raw::RawDigit>::const_iterator digitIt = rawDigitVector.begin(); digitIt != rawDigitVector.end(); ++digitIt) {
162  rawDigitMap[digitIt->Channel()] = *digitIt;
163  pedestalMap[digitIt->Channel()] = digitIt->GetPedestal();
164  if (digitIt->NADC() > maxNumBins) maxNumBins = digitIt->NADC();
165  }
166  //std::cout<<"Method = "<<fMethod<<std::endl;
167  // define set of induction and collection channels in each regulator group
168  std::vector<std::vector<std::vector<unsigned int> > > Chs; //Chs[plane id][group id][channel id]
169 
170  if (fMethod == 0){ //group by regulators
171  Chs.resize(3);
172  for (size_t i = 0; i<3; ++i){
173  Chs[i].resize(32);
174  }
175  for (unsigned int i = 0; i<n_channels; ++i){//online channels
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);
180  }
181  }
182  else if (fMethod == 1){
183  Chs.resize(3);
184  for (size_t i = 0; i<3; ++i){
185  Chs[i].resize(128);
186  }
187  for (unsigned int i = 0; i<n_channels; ++i){//online channels
188  unsigned int plane = fChannelMap->PlaneFromOnlineChannel(i);
189  unsigned int rce = fChannelMap->RCEFromOnlineChannel(i);
190  unsigned int asic = fChannelMap->ASICFromOnlineChannel(i);
191  //std::cout<<i<<" "<<plane<<" "<<rce<<" "<<asic<<std::endl;
192  Chs[plane][rce*8+asic].push_back(i);
193  }
194  }
195  // derive correction factors - require raw adc waveform and pedestal for each channel
196  std::vector<Double_t> corrVals;
197  // loop through time slices
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){
201  //if (s==0) std::cout << "Looking at " << s << " " << i << " " << j << " " << Chs[i][j].size() << std::endl;
202  corrVals.clear();
203  for (size_t k = 0; k<Chs[i][j].size(); ++k){
204 
205  unsigned int offlineChan = fChannelMap->Offline(Chs[i][j][k]);
206  if (rawDigitMap.count(offlineChan) == 0)
207  continue;
208  int adc = rawDigitMap.at(offlineChan).ADC(s);
209  if ( fSkipStuckCodes && ( (adc & 0x3F) == 0x0 || (adc & 0x3F) == 0x3F ) )
210  continue;
211  if (adc < 10) //skip "sample dropping" problem
212  continue;
213  double mean = pedestalMap.at(offlineChan);
214  if (mean < 10)
215  continue;
216  corrVals.push_back(adc - mean);
217  }
218 
219  unsigned int corrValSize = corrVals.size();
220  sort(corrVals.begin(),corrVals.end());
221  double correction = 0;
222  if (corrValSize < 2)
223  correction = 0.0;
224  else if ((corrValSize % 2) == 0)
225  correction = (corrVals[corrValSize/2] + corrVals[(corrValSize/2)-1])/2.0;
226  else
227  correction = corrVals[(corrValSize-1)/2];
228 
229  for (size_t k = 0; k<Chs[i][j].size(); ++k){
230 
231  unsigned int offlineChan = fChannelMap->Offline(Chs[i][j][k]);
232  if (rawDigitMap.count(offlineChan) == 0)
233  continue;
234  int adc = rawDigitMap.at(offlineChan).ADC(s);
235  double newAdc = adc - correction;
236  if ( fSkipStuckCodes && ( (adc & 0x3F) == 0x0 || (adc & 0x3F) == 0x3F ) )
237  newAdc = adc; //don't do anything about stuck code, will run stuck code removal later
238  if ( fSkipTicks and s > fLowerSkipTick and s < fUpperSkipTick )
239  newAdc = adc;
240  // if the code unsticker is run first, then don't skip the stuck codes.
241  // if( adc < 10 ) //skip "sample dropping" problem
242  // newAdc = 0;
243  filterWf.at(offlineChan).push_back(newAdc);
244  //if (newAdc < 1000)
245  //Channel_vs_tick[i][j] -> SetBinContent( Channel_vs_tick[i][j]->FindBin(s,k), newAdc);
246  //if (s==0)
247  //std::cout << "Set Channel_vs_tick["<<i<<"]["<<j<<"] bin (" << s << ", " << k << ") to " << Channel_vs_tick[i][j]->GetBinContent( Channel_vs_tick[i][j]->FindBin(s, k) ) << " it should have been " << newAdc << std::endl;
248  }
249  }//all groups
250  }//all planes
251  }// all ticks
252 
253  // loop over channels - save filtered waveforms into digits
254  std::vector<raw::RawDigit> filterRawDigitVector;
255  for (unsigned int ich = 0; ich < n_channels; ich++) {
256  if (rawDigitMap.count(ich) == 0)
257  continue;
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);
262  }
263 
264  // save filtered waveforms to event
265  evt.put(std::make_unique<decltype(filterRawDigitVector)>(std::move(filterRawDigitVector)));
266 }
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
std::string fRawDigitModuleLabel
intermediate_table::const_iterator const_iterator
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
Definition: DataViewImpl.h:446
def move(depos, offset)
Definition: depos.py:107
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)
Definition: RawDigit.cxx:68
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:730
double mean(sqlite3 *db, std::string const &table_name, std::string const &column_name)
Definition: statistics.cc:15
static QCString * s
Definition: config.cpp:1042
unsigned int fLowerSkipTick
std::string fRawDigitModuleInstance
void lbne::FilterWF::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 106 of file FilterWF_module.cc.

106  {
107  fRawDigitModuleLabel = pset.get<std::string>("RawDigitModuleLabel");
108  fRawDigitModuleInstance = pset.get<std::string>("RawDigitModuleInstance");
109  //fOutputModuleLabel = "filterwf";
110  fSkipStuckCodes = pset.get<bool>("SkipStuckCodes",true);
111  fSkipTicks = pset.get<bool>("SkipTicks",false); // MW: added option to ignore certain tick ranges -- turned off by default
112  fLowerSkipTick = pset.get<int>("LowerSkipTick",0);
113  fUpperSkipTick = pset.get<int>("UpperSkipTick",0);
114  fMethod = pset.get<int>("Method",0); //0: group by regulator
115  //1: group by ASIC
116 }
std::string fRawDigitModuleLabel
std::string string
Definition: nybbler.cc:12
unsigned int fUpperSkipTick
unsigned int fLowerSkipTick
std::string fRawDigitModuleInstance

Member Data Documentation

art::ServiceHandle<lbne::ChannelMapService> lbne::FilterWF::fChannelMap
private

Definition at line 90 of file FilterWF_module.cc.

art::ServiceHandle<geo::Geometry> lbne::FilterWF::fGeom
private

Definition at line 89 of file FilterWF_module.cc.

unsigned int lbne::FilterWF::fLowerSkipTick
private

Definition at line 84 of file FilterWF_module.cc.

int lbne::FilterWF::fMethod
private

Definition at line 86 of file FilterWF_module.cc.

std::string lbne::FilterWF::fRawDigitModuleInstance
private

Definition at line 80 of file FilterWF_module.cc.

std::string lbne::FilterWF::fRawDigitModuleLabel
private

Definition at line 80 of file FilterWF_module.cc.

bool lbne::FilterWF::fSkipStuckCodes
private

Definition at line 82 of file FilterWF_module.cc.

bool lbne::FilterWF::fSkipTicks
private

Definition at line 83 of file FilterWF_module.cc.

unsigned int lbne::FilterWF::fUpperSkipTick
private

Definition at line 84 of file FilterWF_module.cc.


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