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

Public Member Functions

 SimWireDUNE (fhicl::ParameterSet const &pset)
 
virtual ~SimWireDUNE ()
 
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 fSimChannelLabel
 Data product holding the ionization electrons. More...
 
bool fNoiseOn
 noise turned on or off for debugging; default is on More...
 
bool fPedestalOn
 switch for simulation of nonzero pedestals More...
 
bool fDistortOn
 switch for simulation of stuck bits More...
 
bool fSuppressOn
 switch for simulation of zero suppression More...
 
bool fKeepEmptyChannels
 Write out empty channels iff true. More...
 
bool fUseRawDigitInput
 Use (presumably noise-free) RawDigits for input instead of SimChannels. More...
 
std::string fRawDigitInputLabel
 The module label for the RawDigits to read in. More...
 
std::string fAdcSimulatorName
 
std::unique_ptr< AdcSimulatorm_pads
 
art::ServiceHandle< geo::Geometrym_pgeo
 
art::ServiceHandle< AdcSuppressServicem_pzs
 
art::ServiceHandle< AdcCompressServicem_pcmp
 
art::ServiceHandle< SimChannelExtractServicem_pscx
 
art::ServiceHandle< ChannelNoiseServicem_pcns
 
art::ServiceHandle< AdcDistortionServicem_pdis
 
art::ServiceHandle< PedestalAdditionServicem_ppad
 

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 64 of file SimWireDUNE_module.cc.

Constructor & Destructor Documentation

SimWireDUNE::SimWireDUNE ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 110 of file SimWireDUNE_module.cc.

110  : EDProducer{pset} {
111  reconfigure(pset);
112  produces< std::vector<raw::RawDigit> >();
113 }
EDProducer(fhicl::ParameterSet const &pset)
Definition: EDProducer.h:20
void reconfigure(fhicl::ParameterSet const &p)
SimWireDUNE::~SimWireDUNE ( )
virtual

Definition at line 117 of file SimWireDUNE_module.cc.

117 { }

Member Function Documentation

void SimWireDUNE::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 181 of file SimWireDUNE_module.cc.

181 { }
void SimWireDUNE::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 185 of file SimWireDUNE_module.cc.

185 { }
void SimWireDUNE::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 189 of file SimWireDUNE_module.cc.

189  {
190  const string myname = "SimWireDUNE::produce: ";
191 
192  // Make a vector of const sim::SimChannel* that has same number
193  // of entries as the number of channels in the detector
194  // and set the entries for the channels that have signal on them
195  // using the chanHandle
196  std::vector<const sim::SimChannel*> chanHandle;
197  std::vector<const sim::SimChannel*> simChannels(m_pgeo->Nchannels(), nullptr);
198  evt.getView(fSimChannelLabel, chanHandle);
199  for ( size_t c=0; c<chanHandle.size(); ++c ) {
200  simChannels[chanHandle[c]->Channel()] = chanHandle[c];
201  }
202 
203  // Do the same as above, but for the RawDigits, so we can map from channel number to digit
204  std::vector<const raw::RawDigit*> inputDigitsHandle;
205  std::vector<const raw::RawDigit*> inputDigits(m_pgeo->Nchannels(), nullptr);
206  if(fUseRawDigitInput){
207  evt.getView(fRawDigitInputLabel, inputDigitsHandle);
208  for ( size_t c=0; c<inputDigitsHandle.size(); ++c ) {
209  const raw::RawDigit* dig=inputDigitsHandle[c];
210  inputDigits[dig->Channel()] = dig;
211  }
212  }
213 
214  // make an unique_ptr of sim::SimDigits that allows ownership of the produced
215  // digits to be transferred to the art::Event after the put statement below
216  std::unique_ptr<std::vector<raw::RawDigit>> digcol(new std::vector<raw::RawDigit>);
217 
218  // Fetch the number of ticks to write out for each channel.
219  auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
220  auto const detProp = art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
221  unsigned int nTickReadout = detProp.ReadOutWindowSize();
222  m_pcns->newEvent();
223  // Loop over channels.
225  for ( unsigned int chan = 0; chan<m_pgeo->Nchannels(); ++chan ) {
226 
227  // Get the SimChannel for this channel
228  const sim::SimChannel* psc = simChannels[chan];
229 
230  // Create vector that holds the floating ADC count for each tick.
231  std::vector<AdcSignal> fChargeWork;
232 
233  if(fUseRawDigitInput){
234  const raw::RawDigit* dig=inputDigits[chan];
235  fChargeWork.insert(fChargeWork.end(), dig->ADCs().begin(), dig->ADCs().end());
236  }
237  else{
238  // Extract the floating ADC count from the SimChannel for each tick in the channel.
239  m_pscx->extract(clockData, psc, fChargeWork);
240  }
241 
242  // Add noise to each tick in the channel.
243  if ( fNoiseOn ) {
244  m_pcns->addNoise(clockData, detProp, chan, fChargeWork);
245  }
246 
247  // Option to display signals before adding pedestals.
248  // E.g. logsig = chan==1000.
249  bool logsig = false;
250  if ( logsig ) {
251  cout << myname << "Signals after noise:" << endl;
252  for ( unsigned int itck=0; itck<fChargeWork.size(); ++itck ) {
253  if(fChargeWork[itck] > 0 )
254  cout << myname << " " << itck << ": chg=" << fChargeWork[itck] << endl;
255  }
256  }
257 
258  // Add pedestal.
259  float pedval = 0.0; // Pedestal to be recorded in RawDigits collection
260  float pedrms = 0.0; // Pedestal RMS to be recorded in RawDigits collection
261  if ( fPedestalOn ) {
262  m_ppad->addPedestal(chan, fChargeWork, pedval, pedrms);
263  }
264 
265  // Convert floating ADC to integral ADC count.
266  std::vector<short> adcvec(fChargeWork.size(), 0);
267  const short adcmax = 4095;
268  for ( unsigned int itck=0; itck<fChargeWork.size(); ++itck ) {
269  AdcSignal adcin = fChargeWork[itck];
270  short adc = 0;
271  bool useOldAdc = false;
272  // New ADC calculation (with tool).
273  if ( m_pads ) {
274  if(adcin > 0)
275  //cout << " adcin " << adcin << endl;
276  adc = m_pads->count(adcin, chan);
277  } else {
278  //cout << myname << "WARNING: AdcSimulator not found." << endl;
279  useOldAdc = true;
280  }
281  // Old ADC calculation.
282  if ( useOldAdc ) {
283  short adc1 = 0;
284  if ( adcin > 0 ) adc1 = (short) (adcin + 0.5);
285  if ( adc1 > adcmax ) adc1 = adcmax;
286  bool show = m_pads && adc1 != adc;
287 
288  static int ndump = 1000;
289  if ( ndump && show ) {
290  cout << myname << " ADC: " << adc1 << " --> " << adc << " (" << adcin << ")" << endl;
291  --ndump;
292  }
293  adc = adc1;
294  }
295  // Record the ADC value.
296  adcvec[itck] = adc;
297  }
298  // Resize to the correct number of time samples, dropping extra samples.
299  adcvec.resize(nTickReadout);
300 
301  // Add stuck bits.
302  if ( fDistortOn ) {
303  m_pdis->modify(chan, adcvec);
304  }
305 
306  // Zero suppress.
307  AdcCountSelection acs(adcvec, chan, pedval);
308  if ( fSuppressOn ) {
309  m_pzs->filter(acs);
310  }
311  int nkeep = 0;
312  for ( bool kept : acs.filter ) if ( kept ) ++nkeep;
313 
314  // If flag is not set and channel is empty, skip it.
315  if ( ! fKeepEmptyChannels && nkeep==0 ) continue;
316 
317  // Compress.
319  m_pcmp->compress(adcvec, acs.filter, pedval, comp);
320 
321  // Create and store raw digit.
322  raw::RawDigit rd(chan, nTickReadout, adcvec, comp);
323  rd.SetPedestal(pedval, pedrms);
324  digcol->push_back(rd); // add this digit to the collection
325 
326  } // end loop over channels
327 
328  evt.put(std::move(digcol));
329 
330 }
intermediate_table::iterator iterator
art::ServiceHandle< PedestalAdditionService > m_ppad
art::ServiceHandle< SimChannelExtractService > m_pscx
bool fKeepEmptyChannels
Write out empty channels iff true.
const ADCvector_t & ADCs() const
Reference to the compressed ADC count vector.
Definition: RawDigit.h:210
enum raw::_compress Compress_t
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:69
virtual int modify(Channel chan, AdcCountVector &adcvec) const =0
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:140
art::ServiceHandle< AdcSuppressService > m_pzs
virtual int addNoise(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, Channel chan, AdcSignalVector &sigs) const =0
virtual int extract(detinfo::DetectorClocksData const &clockData, const sim::SimChannel *psc, AdcSignalVector &sig) const =0
float AdcSignal
Definition: AdcTypes.h:21
bool fNoiseOn
noise turned on or off for debugging; default is on
std::unique_ptr< AdcSimulator > m_pads
ChannelID_t Channel() const
DAQ channel this raw data was read from.
Definition: RawDigit.h:212
int16_t adc
Definition: CRTFragment.hh:202
no compression
Definition: RawTypes.h:9
art::ServiceHandle< geo::Geometry > m_pgeo
art::ServiceHandle< ChannelNoiseService > m_pcns
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
bool fUseRawDigitInput
Use (presumably noise-free) RawDigits for input instead of SimChannels.
def move(depos, offset)
Definition: depos.py:107
std::string fRawDigitInputLabel
The module label for the RawDigits to read in.
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Definition: DataViewImpl.h:686
bool fPedestalOn
switch for simulation of nonzero pedestals
art::ServiceHandle< AdcDistortionService > m_pdis
virtual int addPedestal(Channel chan, AdcSignalVector &sigs, float &ped, float &pedrms) const =0
virtual int filter(const AdcCountVector &sigs, Channel chan, AdcPedestal ped, AdcFilterVector &keep) const =0
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::string const &processName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:500
art::ServiceHandle< AdcCompressService > m_pcmp
std::string fSimChannelLabel
Data product holding the ionization electrons.
virtual int compress(AdcCountVector &sigs, const AdcFilterVector &keep, AdcCount offset, raw::Compress_t &comp) const =0
bool fSuppressOn
switch for simulation of zero suppression
QTextStream & endl(QTextStream &s)
bool fDistortOn
switch for simulation of stuck bits
void SimWireDUNE::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 121 of file SimWireDUNE_module.cc.

121  {
122  string myname = "SimWireDUNE::reconfigure: ";
123  string myprefix = myname + " ";
124  fSimChannelLabel = p.get<std::string>("SimChannelLabel");
125  fNoiseOn = p.get<bool>("NoiseOn");
126  fPedestalOn = p.get<bool>("PedestalOn");
127  fDistortOn = p.get<bool>("DistortOn");
128  fSuppressOn = p.get<bool>("SuppressOn");
129  fKeepEmptyChannels = p.get<bool>("KeepEmptyChannels");
130  fUseRawDigitInput = p.get<bool>("UseRawDigitInput", false);
131  fRawDigitInputLabel= p.get<string>("RawDigitInputLabel", "");
132  fAdcSimulatorName = p.get<string>("AdcSimulator");
133 
135  m_pads = pdtm == nullptr ? nullptr : pdtm->getPrivate<AdcSimulator>(fAdcSimulatorName);
136  ostringstream out;
137  out << myname << "Tools:" << endl;
138  out << " AdcSimulator: " << bool(m_pads) << endl;
139  out << myname << "Accessed services:" << endl;
140  out << myname << " SimChannel extraction service:" << endl;
141  m_pscx->print(out, myprefix) << endl;
142  if ( fNoiseOn ) {
143  out << myname << " Channel noise service:" << endl;;
144  m_pcns->print(out, myprefix);
145  } else {
146  out << myname << " Channel noise is off.";
147  }
148  out << endl;
149  if ( fPedestalOn ) {
150  out << myname << " Pedestal addition service:" << endl;;
151  m_ppad->print(out, myprefix);
152  } else {
153  out << myname << " Pedestal addition is off.";
154  }
155  out << endl;
156  if ( fDistortOn ) {
157  out << myname << " ADC distortion service:" << endl;;
158  m_pdis->print(out, myprefix);
159  } else {
160  out << myname << " ADC distortion is off.";
161  }
162  out << endl;
163  if ( fSuppressOn ) {
164  out << myname << " ADC suppression service:" << endl;
165  m_pzs->print(out, myprefix);
166  } else {
167  out << myname << " ADC suppression is off.";
168  }
169  out << endl;
170  out << myname << " Compression service:" << endl;
171  out << endl;
172  m_pcmp->print(out, myprefix);
173  out << myname << " KeepEmptyChannels:" << fKeepEmptyChannels << endl;
174  mf::LogInfo("SimWireDUNE::reconfigure") << out.str();
175 
176  return;
177 }
art::ServiceHandle< PedestalAdditionService > m_ppad
art::ServiceHandle< SimChannelExtractService > m_pscx
bool fKeepEmptyChannels
Write out empty channels iff true.
art::ServiceHandle< AdcSuppressService > m_pzs
std::string string
Definition: nybbler.cc:12
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
bool fNoiseOn
noise turned on or off for debugging; default is on
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
std::unique_ptr< AdcSimulator > m_pads
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix=" ") const =0
art::ServiceHandle< ChannelNoiseService > m_pcns
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix=" ") const =0
bool fUseRawDigitInput
Use (presumably noise-free) RawDigits for input instead of SimChannels.
p
Definition: test.py:223
std::string fRawDigitInputLabel
The module label for the RawDigits to read in.
bool fPedestalOn
switch for simulation of nonzero pedestals
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
art::ServiceHandle< AdcDistortionService > m_pdis
std::string fAdcSimulatorName
art::ServiceHandle< AdcCompressService > m_pcmp
std::string fSimChannelLabel
Data product holding the ionization electrons.
int bool
Definition: qglobal.h:345
virtual std::ostream & print(std::ostream &out=std::cout, std::string prefix="") const =0
bool fSuppressOn
switch for simulation of zero suppression
static DuneToolManager * instance(std::string fclname="", int dbg=1)
QTextStream & endl(QTextStream &s)
bool fDistortOn
switch for simulation of stuck bits

Member Data Documentation

std::string SimWireDUNE::fAdcSimulatorName
private

Definition at line 90 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fDistortOn
private

switch for simulation of stuck bits

Definition at line 84 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fKeepEmptyChannels
private

Write out empty channels iff true.

Definition at line 86 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fNoiseOn
private

noise turned on or off for debugging; default is on

Definition at line 82 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fPedestalOn
private

switch for simulation of nonzero pedestals

Definition at line 83 of file SimWireDUNE_module.cc.

std::string SimWireDUNE::fRawDigitInputLabel
private

The module label for the RawDigits to read in.

Definition at line 88 of file SimWireDUNE_module.cc.

std::string SimWireDUNE::fSimChannelLabel
private

Data product holding the ionization electrons.

Definition at line 79 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fSuppressOn
private

switch for simulation of zero suppression

Definition at line 85 of file SimWireDUNE_module.cc.

bool SimWireDUNE::fUseRawDigitInput
private

Use (presumably noise-free) RawDigits for input instead of SimChannels.

Definition at line 87 of file SimWireDUNE_module.cc.

std::unique_ptr<AdcSimulator> SimWireDUNE::m_pads
private

Definition at line 93 of file SimWireDUNE_module.cc.

art::ServiceHandle<AdcCompressService> SimWireDUNE::m_pcmp
private

Definition at line 98 of file SimWireDUNE_module.cc.

art::ServiceHandle<ChannelNoiseService> SimWireDUNE::m_pcns
private

Definition at line 100 of file SimWireDUNE_module.cc.

art::ServiceHandle<AdcDistortionService> SimWireDUNE::m_pdis
private

Definition at line 101 of file SimWireDUNE_module.cc.

art::ServiceHandle<geo::Geometry> SimWireDUNE::m_pgeo
private

Definition at line 96 of file SimWireDUNE_module.cc.

art::ServiceHandle<PedestalAdditionService> SimWireDUNE::m_ppad
private

Definition at line 102 of file SimWireDUNE_module.cc.

art::ServiceHandle<SimChannelExtractService> SimWireDUNE::m_pscx
private

Definition at line 99 of file SimWireDUNE_module.cc.

art::ServiceHandle<AdcSuppressService> SimWireDUNE::m_pzs
private

Definition at line 97 of file SimWireDUNE_module.cc.


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