LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
detsim::SimWire Class Reference
Inheritance diagram for detsim::SimWire:
art::EDProducer art::ProducerBase art::Consumer art::EngineCreator art::ProductRegistryHelper

Public Types

using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerBase::Table< UserConfig, KeysToIgnore >
 

Public Member Functions

 SimWire (fhicl::ParameterSet const &pset)
 
virtual ~SimWire ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
template<typename PROD , BranchType B = InEvent>
ProductID getProductID (std::string const &instanceName={}) const
 
template<typename PROD , BranchType B>
ProductID getProductID (ModuleDescription const &moduleDescription, std::string const &instanceName) const
 
bool modifiesEvent () const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void ConvoluteResponseFunctions ()
 convolute electronics and field response More...
 
void SetFieldResponse ()
 response of wires to field More...
 
void SetElectResponse ()
 response of electronics More...
 
void GenNoise (std::vector< float > &array)
 

Private Attributes

bool fResponseSet
 flag of whether to set the response functions or not More...
 
std::string fDriftEModuleLabel
 module making the ionization electrons More...
 
std::string fResponseFile
 response file for induction planes More...
 
raw::Compress_t fCompression
 compression type to use More...
 
double fNoiseFact
 noise scale factor More...
 
double fNoiseWidth
 exponential noise width (kHz) More...
 
double fLowCutoff
 low frequency filter cutoff (kHz) More...
 
int fNTicks
 number of ticks of the clock More...
 
int fNFieldBins
 number of bins for field response More...
 
double fSampleRate
 sampling rate in ns More...
 
unsigned int fNSamplesReadout
 number of ADC readout samples in 1 readout frame More...
 
double fCol3DCorrection
 
double fInd3DCorrection
 
double fColFieldRespAmp
 amplitude of response to field More...
 
double fIndFieldRespAmp
 amplitude of response to field More...
 
std::vector< double > fShapeTimeConst
 time constants for exponential shaping More...
 
int fTriggerOffset
 (units of ticks) time of expected neutrino event More...
 
unsigned int fNElectResp
 number of entries from response to use More...
 
std::vector< double > fColFieldResponse
 response function for the field @ collection plane More...
 
std::vector< double > fIndFieldResponse
 response function for the field @ induction plane More...
 
std::vector< TComplex > fColShape
 response function for the field @ collection plane More...
 
std::vector< TComplex > fIndShape
 response function for the field @ induction plane More...
 
std::vector< double > fChargeWork
 
std::vector< double > fElectResponse
 response function for the electronics More...
 
std::vector< std::vector< float > > fNoise
 noise on each channel for each time More...
 
TH1D * fIndFieldResp
 response function for the field @ induction plane More...
 
TH1D * fColFieldResp
 response function for the field @ collection plane More...
 
TH1D * fElectResp
 response function for the electronics More...
 
TH1D * fColTimeShape
 convoluted shape for field x electronics @ col plane More...
 
TH1D * fIndTimeShape
 convoluted shape for field x electronics @ ind plane More...
 
TH1D * fNoiseDist
 distribution of noise counts More...
 

Detailed Description

Definition at line 77 of file SimWire_module.cc.

Member Typedef Documentation

using art::EDProducer::ModuleType = EDProducer
inherited

Definition at line 34 of file EDProducer.h.

template<typename UserConfig , typename KeysToIgnore = void>
using art::EDProducer::Table = ProducerBase::Table<UserConfig, KeysToIgnore>
inherited

Definition at line 43 of file EDProducer.h.

using art::EDProducer::WorkerType = WorkerT<EDProducer>
inherited

Definition at line 35 of file EDProducer.h.

Constructor & Destructor Documentation

detsim::SimWire::SimWire ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 143 of file SimWire_module.cc.

References fhicl::ParameterSet::get(), raw::kHuffman, and raw::kNone.

144  {
145  this->reconfigure(pset);
146 
147  produces< std::vector<raw::RawDigit> >();
148 
150  std::string compression(pset.get< std::string >("CompressionType"));
151  if(compression.compare("Huffman") == 0) fCompression = raw::kHuffman;
152 
153  // create a default random engine; obtain the random seed from NuRandomService,
154  // unless overridden in configuration with key "Seed"
156  ->createEngine(*this, pset, "Seed");
157  }
Huffman Encoding.
Definition: RawTypes.h:10
void reconfigure(fhicl::ParameterSet const &p)
raw::Compress_t fCompression
compression type to use
no compression
Definition: RawTypes.h:9
base_engine_t & createEngine(seed_t seed)
detsim::SimWire::~SimWire ( )
virtual

Definition at line 160 of file SimWire_module.cc.

References clear(), and LOG_WARNING.

161  {
162  fColFieldResponse.clear();
163  fIndFieldResponse.clear();
164  fColShape.clear();
165  fIndShape.clear();
166  fChargeWork.clear();
167  fElectResponse.clear();
168 
169  for(unsigned int i = 0; i < fNoise.size(); ++i) fNoise[i].clear();
170  fNoise.clear();
171 
172  LOG_WARNING("SimWire") << "SimWire is an example module that works for the "
173  << "MicroBooNE detector. Each experiment should implement "
174  << "its own version of this module to simulate electronics "
175  << "response.";
176 
177  }
std::vector< TComplex > fColShape
response function for the field @ collection plane
std::vector< double > fElectResponse
response function for the electronics
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
std::vector< double > fChargeWork
std::vector< double > fColFieldResponse
response function for the field @ collection plane
std::vector< std::vector< float > > fNoise
noise on each channel for each time
std::vector< TComplex > fIndShape
response function for the field @ induction plane
#define LOG_WARNING(category)
vec_iX clear()

Member Function Documentation

void detsim::SimWire::beginJob ( )
virtual

set field response and electronics response, then convolute them

Reimplemented from art::EDProducer.

Definition at line 210 of file SimWire_module.cc.

References util::LArFFT::FFTSize(), and art::TFileDirectory::make().

211  {
212  // get access to the TFile service
214 
215  fNoiseDist = tfs->make<TH1D>("Noise", ";Noise (ADC);", 1000, -10., 10.);
216 
218  fNTicks = fFFT->FFTSize();
219  fChargeWork.resize(fNTicks, 0.);
220 
221  // Note the magic 100 here. Argo and uBooNe use NChannels.
222  fNoise.resize(100);
223  // GenNoise() will further resize each channel's
224  // fNoise vector to fNTicks long.
225 
226  for(int p = 0; p < 100; ++p){
227  GenNoise(fNoise[p]);
228  for(int i = 0; i < fNTicks; ++i){
229  fNoiseDist->Fill(fNoise[p][i]);
230  }
231  }//end loop over wires
232 
237 
238 
239  return;
240 
241  }
void SetElectResponse()
response of electronics
TH1D * fNoiseDist
distribution of noise counts
void GenNoise(std::vector< float > &array)
int FFTSize() const
Definition: LArFFT.h:69
std::vector< double > fChargeWork
std::vector< std::vector< float > > fNoise
noise on each channel for each time
void ConvoluteResponseFunctions()
convolute electronics and field response
void SetFieldResponse()
response of wires to field
int fNTicks
number of ticks of the clock
T * make(ARGS...args) const
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void detsim::SimWire::ConvoluteResponseFunctions ( )
private

convolute electronics and field response

pad out the rest of the vector with 0.

do the FFT of the shapes

check that you did the right thing

Definition at line 340 of file SimWire_module.cc.

References util::LArFFT::AlignedSum(), col, util::LArFFT::DoFFT(), and art::TFileDirectory::make().

341  {
342  std::vector<double> col(fNTicks, 0.);
343  std::vector<double> ind(fNTicks, 0.);
344 
345  unsigned int mxbin = TMath::Min(fNTicks, (int)fNElectResp + fNFieldBins);
346 
347  double sumCol = 0.;
348  double sumInd = 0.;
349 
350  for(unsigned int i = 1; i < mxbin; ++i){
351  sumCol = 0.;
352  sumInd = 0.;
353  for(unsigned int j = 0; j < (unsigned int)fNFieldBins; ++j){
354  unsigned int k = i - j;
355  if(k == 0) break;
356  sumCol += fElectResponse[k]*fColFieldResponse[j];
357  sumInd += fElectResponse[k]*fIndFieldResponse[j];
358  }
359  col[i] = sumCol;
360  ind[i] = sumInd;
361 
362  }//end loop over bins;
363 
365  ind.resize(fNTicks, 0.);
366  col.resize(fNTicks, 0.);
367 
368  // write the shapes out to a file
370  fColTimeShape = tfs->make<TH1D>("ConvolutedCollection",";ticks; Electronics#timesCollection",fNTicks,0,fNTicks);
371  fIndTimeShape = tfs->make<TH1D>("ConvolutedInduction",";ticks; Electronics#timesInduction",fNTicks,0,fNTicks);
372 
373  fIndShape.resize(fNTicks/2+1);
374  fColShape.resize(fNTicks/2+1);
375 
377  std::vector<double> delta(fNTicks);
378  delta[0] = 1.0;
379  delta[fNTicks-1]=1.0;
380 
382  fFFT->AlignedSum(ind,delta,false);
383  fFFT->AlignedSum(col,delta,false);
384  fFFT->DoFFT(ind, fIndShape);
385  fFFT->DoFFT(col, fColShape);
386 
388  for(unsigned int i = 0; i < ind.size(); ++i){
389  fColTimeShape->Fill(i, col[i]);
390  fIndTimeShape->Fill(i, ind[i]);
391  }
392 
393  fColTimeShape->Write();
394  fIndTimeShape->Write();
395 
396 
397  return;
398  }
std::vector< TComplex > fColShape
response function for the field @ collection plane
std::vector< double > fElectResponse
response function for the electronics
TH1D * fColTimeShape
convoluted shape for field x electronics @ col plane
unsigned int fNElectResp
number of entries from response to use
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
Definition: LArFFT.h:97
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
std::vector< double > fColFieldResponse
response function for the field @ collection plane
std::vector< TComplex > fIndShape
response function for the field @ induction plane
Int_t col[ntarg]
Definition: Style.C:29
int fNTicks
number of ticks of the clock
T * make(ARGS...args) const
TH1D * fIndTimeShape
convoluted shape for field x electronics @ ind plane
void AlignedSum(std::vector< T > &input, std::vector< T > &output, bool add=true)
Definition: LArFFT.h:243
int fNFieldBins
number of bins for field response
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDProducer::currentContext ( ) const
protectedinherited

Definition at line 120 of file EDProducer.cc.

References art::EDProducer::current_context_.

121  {
122  return current_context_.get();
123  }
CPC_exempt_ptr current_context_
Definition: EDProducer.h:116
void detsim::SimWire::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 244 of file SimWire_module.cc.

245  {
246  }
void detsim::SimWire::GenNoise ( std::vector< float > &  array)
private

<noise in frequency space

multiply each noise value by fNTicks as the InvFFT divides each bin by fNTicks assuming that a forward FFT has already been done.

Definition at line 401 of file SimWire_module.cc.

References util::LArFFT::DoInvFFT(), and art::RandomNumberGenerator::getEngine().

402  {
404  CLHEP::HepRandomEngine &engine = rng->getEngine();
405  CLHEP::RandFlat flat(engine);
406 
407  noise.clear();
408  noise.resize(fNTicks, 0.);
409  std::vector<TComplex> noiseFrequency(fNTicks/2+1, 0.);
410 
411  double pval = 0.;
412  double lofilter = 0.;
413  double phase = 0.;
414  double rnd[2] = {0.};
415 
416  //width of frequencyBin in kHz
417  double binWidth = 1.0/(fNTicks*fSampleRate*1.0e-6);
418  for(int i=0; i< fNTicks/2+1; ++i){
419  //exponential noise spectrum
420  pval = fNoiseFact*exp(-(double)i*binWidth/fNoiseWidth);
421  //low frequency cutoff
422  lofilter = 1.0/(1.0+exp(-(i-fLowCutoff/binWidth)/0.5));
423  //randomize 10%
424  flat.fireArray(2,rnd,0,1);
425  pval *= lofilter*(0.9+0.2*rnd[0]);
426  //random pahse angle
427  phase = rnd[1]*2.*TMath::Pi();
428 
429  TComplex tc(pval*cos(phase),pval*sin(phase));
430  noiseFrequency[i] += tc;
431  }
432 
433  //std::cout << "filled noise freq" << std::endl;
434 
435  //inverse FFT MCSignal
437  fFFT->DoInvFFT(noiseFrequency, noise);
438 
439  noiseFrequency.clear();
440 
444  for(unsigned int i = 0; i < noise.size(); ++i) noise[i] *= 1.*fNTicks;
445 
446  return;
447  }
void DoInvFFT(std::vector< TComplex > &input, std::vector< T > &output)
Definition: LArFFT.h:119
unsigned int noise()
Definition: chem4.cc:265
base_engine_t & getEngine() const
double fSampleRate
sampling rate in ns
double fLowCutoff
low frequency filter cutoff (kHz)
int fNTicks
number of ticks of the clock
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
double fNoiseWidth
exponential noise width (kHz)
double fNoiseFact
noise scale factor
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
template<typename PROD , BranchType B>
ProductID art::EDProducer::getProductID ( std::string const &  instanceName = {}) const
inlineinherited

Definition at line 123 of file EDProducer.h.

References art::EDProducer::moduleDescription_.

124  {
125  return ProducerBase::getProductID<PROD, B>(moduleDescription_,
126  instanceName);
127  }
ModuleDescription moduleDescription_
Definition: EDProducer.h:115
template<typename PROD , BranchType B>
ProductID art::ProducerBase::getProductID ( ModuleDescription const &  moduleDescription,
std::string const &  instanceName 
) const
inherited

Definition at line 56 of file ProducerBase.h.

References B, and art::ModuleDescription::moduleLabel().

Referenced by art::ProducerBase::modifiesEvent().

58  {
59  auto const& pd =
60  get_ProductDescription<PROD>(B, md.moduleLabel(), instanceName);
61  return pd.productID();
62  }
Int_t B
Definition: plot.C:25
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::ProducerBase::modifiesEvent ( ) const
inlineinherited

Definition at line 40 of file ProducerBase.h.

References art::ProducerBase::getProductID().

41  {
42  return true;
43  }
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void detsim::SimWire::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 249 of file SimWire_module.cc.

References sim::SimChannel::Charge(), raw::Compress(), util::LArFFT::Convolute(), art::RandomNumberGenerator::getEngine(), art::DataViewImpl::getView(), geo::kInduction, geo::GeometryCore::Nchannels(), art::Event::put(), and geo::GeometryCore::SignalType().

250  {
251 
252  //std::cout << "in SimWire::produce " << std::endl;
253 
254  // get the geometry to be able to figure out signal types and chan -> plane mappings
256  unsigned int signalSize = fNTicks;
257  // vectors for working
258  std::vector<short> adcvec(signalSize, 0);
259 
260  std::vector<const sim::SimChannel*> chanHandle;
261  evt.getView(fDriftEModuleLabel,chanHandle);
262 
263  // make a vector of const sim::SimChannel* that has same number
264  // of entries as the number of channels in the detector
265  // and set the entries for the channels that have signal on them
266  // using the chanHandle
267  std::vector<const sim::SimChannel*> channels(geo->Nchannels());
268  for(size_t c = 0; c < chanHandle.size(); ++c){
269  channels[chanHandle[c]->Channel()] = chanHandle[c];
270  }
271 
272  // make an unique_ptr of sim::SimDigits that allows ownership of the produced
273  // digits to be transferred to the art::Event after the put statement below
274  std::unique_ptr< std::vector<raw::RawDigit> > digcol(new std::vector<raw::RawDigit>);
275 
276  unsigned int chan = 0;
277  fChargeWork.clear();
278  fChargeWork.resize(fNTicks, 0.);
279 
281 
282  // Add all channels
284  CLHEP::HepRandomEngine &engine = rng->getEngine();
285  CLHEP::RandFlat flat(engine);
286 
288  for(chan = 0; chan < geo->Nchannels(); chan++) {
289  // std::cout << "on channel " << chan << std::endl;
290 
291  fChargeWork.clear();
292  fChargeWork.resize(fNTicks, 0.);
293 
294  if( channels[chan] ){
295 
296  // get the sim::SimChannel for this channel
297  const sim::SimChannel* sc = channels[chan];
298 
299  // loop over the tdcs and grab the number of electrons for each
300  for(size_t t = 0; t < fChargeWork.size(); ++t)
301  fChargeWork[t] = sc->Charge(t);
302 
303  //Convolve charge with appropriate response function
304  if(geo->SignalType(chan) == geo::kInduction)
306  else fFFT->Convolute(fChargeWork,fColShape);
307  }
308 
309  // noise was already generated for each wire in the event
310  // raw digit vec is already in channel order
311  // pick a new "noise channel" for every channel - this makes sure
312  // the noise has the right coherent characteristics to be on one channel
313  int noisechan = TMath::Nint(flat.fire()*(1.*(fNoise.size()-1)+0.1));
314  for(unsigned int i = 0; i < signalSize; ++i){
315  adcvec[i] = (short)TMath::Nint(fNoise[noisechan][i] + fChargeWork[i]);
316  }
317  adcvec.resize(fNSamplesReadout);
318 
319  // compress the adc vector using the desired compression scheme,
320  // if raw::kNone is selected nothing happens to adcvec
321  // This shrinks adcvec, if fCompression is not kNone.
322 
323  raw::Compress(adcvec, fCompression);
324 
325  raw::RawDigit rd(chan, signalSize, adcvec, fCompression);
326  // Then, resize adcvec back to full length!
327  adcvec.clear();
328  adcvec.resize(signalSize,0.0);
329 
330  // add this digit to the collection
331  digcol->push_back(rd);
332  }//end loop over channels
333 
334  evt.put(std::move(digcol));
335 
336  return;
337  }
unsigned int fNSamplesReadout
number of ADC readout samples in 1 readout frame
std::vector< TComplex > fColShape
response function for the field @ collection plane
Collection of charge vs time digitized from a single readout channel.
Definition: RawDigit.h:68
Energy deposited on a readout channel by simulated tracks.
Definition: SimChannel.h:143
std::string fDriftEModuleLabel
module making the ionization electrons
intermediate_table::iterator iterator
raw::Compress_t fCompression
compression type to use
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
ProductID put(std::unique_ptr< PROD > &&product)
Definition: Event.h:102
std::size_t getView(std::string const &moduleLabel, std::string const &productInstanceName, std::vector< ELEMENT const * > &result) const
Definition: DataViewImpl.h:474
base_engine_t & getEngine() const
std::vector< double > fChargeWork
Signal from induction planes.
Definition: geo_types.h:92
std::vector< std::vector< float > > fNoise
noise on each channel for each time
double Charge(TDC_t tdc) const
Returns the total number of ionization electrons on this channel in the specified TDC...
Definition: SimChannel.cxx:132
std::vector< TComplex > fIndShape
response function for the field @ induction plane
void Convolute(std::vector< T > &input, std::vector< T > &respFunc)
Definition: LArFFT.h:172
int fNTicks
number of ticks of the clock
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
void Compress(std::vector< short > &adc, raw::Compress_t compress)
Compresses a raw data buffer.
Definition: raw.cxx:20
Namespace collecting geometry-related classes utilities.
void detsim::SimWire::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 180 of file SimWire_module.cc.

References fhicl::ParameterSet::get().

181  {
182  std::string fResponseFile = p.get<std::string>("ResponseFile", "");
183 
184  fResponseSet = !fResponseFile.empty();
185  if (fResponseSet) {
186  cet::search_path sp("FW_SEARCH_PATH");
187  sp.find_file(p.get<std::string>("ResponseFile"), fResponseFile);
188  }
189  else fResponseFile.clear();
190  fDriftEModuleLabel= p.get< std::string >("DriftEModuleLabel");
191  fNoiseFact = p.get< double >("NoiseFact");
192  fNoiseWidth = p.get< double >("NoiseWidth");
193  fLowCutoff = p.get< double >("LowCutoff");
194  fNFieldBins = p.get< int >("FieldBins");
195  fCol3DCorrection = p.get< double >("Col3DCorrection");
196  fInd3DCorrection = p.get< double >("Ind3DCorrection");
197  fColFieldRespAmp = p.get< double >("ColFieldRespAmp");
198  fIndFieldRespAmp = p.get< double >("IndFieldRespAmp");
199  fShapeTimeConst = p.get< std::vector<double> >("ShapeTimeConst");
200 
201  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
202  fSampleRate = detprop->SamplingRate();
203  fTriggerOffset = detprop->TriggerOffset();
204  fNSamplesReadout = detprop->NumberTimeSamples();
205 
206  return;
207  }
double fIndFieldRespAmp
amplitude of response to field
unsigned int fNSamplesReadout
number of ADC readout samples in 1 readout frame
std::string fDriftEModuleLabel
module making the ionization electrons
double fColFieldRespAmp
amplitude of response to field
int fTriggerOffset
(units of ticks) time of expected neutrino event
bool fResponseSet
flag of whether to set the response functions or not
double fSampleRate
sampling rate in ns
double fLowCutoff
low frequency filter cutoff (kHz)
std::string fResponseFile
response file for induction planes
double fNoiseWidth
exponential noise width (kHz)
int fNFieldBins
number of bins for field response
double fNoiseFact
noise scale factor
std::vector< double > fShapeTimeConst
time constants for exponential shaping
void detsim::SimWire::SetElectResponse ( )
private

response of electronics

end loop over time buckets

remove all values of fElectResponse and time where fElectResponse < 0.01*peak

Definition at line 513 of file SimWire_module.cc.

References DEFINE_ART_MODULE, art::TFileDirectory::make(), and norm.

514  {
515 
516  // std::cerr << "SetElectResponse" << std::endl;
517 
519 
520  fElectResponse.resize(fNTicks, 0.);
521  std::vector<double> time(fNTicks,0.);
522 
523  double norm = fShapeTimeConst[1]*TMath::Pi();
524  norm /= sin(fShapeTimeConst[1]*TMath::Pi()/fShapeTimeConst[0])/fSampleRate;
525 
526  double peak = 0.;
527 
528  for(int i = 0; i < fNTicks; ++i){
529  time[i] = (1.*i - 0.33333*fNTicks)*fSampleRate;
530 
531  // The 120000 is an arbitrary scaling to get displays for microboone
532  fElectResponse[i] = 120000.0*exp(-time[i]/fShapeTimeConst[0])/(1. + exp(-time[i]/fShapeTimeConst[1]))/norm;
533 
534  if(fElectResponse[i] > peak){
535  peak = fElectResponse[i];
536  }
537  }
538 
540  peak *= 0.01;
542  std::vector<double>::iterator titr = time.begin();
543  while(eitr != fElectResponse.end()){
544  if(*eitr < peak){
545  fElectResponse.erase(eitr);
546  time.erase(titr);
547 
548  }
549  else{
550  ++eitr;
551  ++titr;
552  }
553  }//end loop to remove low response values
554 
555  fNElectResp = fElectResponse.size();
556 
557  // write the response out to a file
559  fElectResp = tfs->make<TH1D>("ElectronicsResponse",";t (ns);Electronics Response",fNElectResp,0,fNElectResp);
560  for(unsigned int i = 0; i < fNElectResp; ++i){
561  //mf::LogInfo("SimWire") <<"checking ElectResponse: i= "<< i << " time[i]= " << time[i] << " fElectResponse[i]= " << fElectResponse[i];
562  fElectResp->Fill(i, fElectResponse[i]);
563  }
564 
565  fElectResp->Write();
566 
567  return;
568  }
std::vector< double > fElectResponse
response function for the electronics
intermediate_table::iterator iterator
unsigned int fNElectResp
number of entries from response to use
double fSampleRate
sampling rate in ns
int fNTicks
number of ticks of the clock
T * make(ARGS...args) const
Float_t norm
TH1D * fElectResp
response function for the electronics
Namespace collecting geometry-related classes utilities.
std::vector< double > fShapeTimeConst
time constants for exponential shaping
void detsim::SimWire::SetFieldResponse ( )
private

response of wires to field

< should always have at least 2 planes

this assumes all planes are equidistant from each other, probably not a bad assumption

in cm

set the response for the collection plane first the first entry is 0

number of bins //KP

now the induction plane

Definition at line 450 of file SimWire_module.cc.

References detinfo::DetectorProperties::DriftVelocity(), geo::PlaneGeo::LocalToWorld(), art::TFileDirectory::make(), and geo::GeometryCore::Plane().

451  {
452 
453  // std::cerr << "SetFieldResponse" << std::endl;
454 
456 
457  double xyz1[3] = {0.};
458  double xyz2[3] = {0.};
459  double xyzl[3] = {0.};
461  geo->Plane(0).LocalToWorld(xyzl, xyz1);
462  geo->Plane(1).LocalToWorld(xyzl, xyz2);
463 
466  double pitch = xyz2[0] - xyz1[0];
467 
468  fColFieldResponse.resize(fNFieldBins, 0.);
469  fIndFieldResponse.resize(fNFieldBins, 0.);
470 
473 
474  // write out the response functions to the file
475  // get access to the TFile service
477  fIndFieldResp = tfs->make<TH1D>("InductionFieldResponse",";t (ns);Induction Response",fNTicks,0,fNTicks);
478  fColFieldResp = tfs->make<TH1D>("CollectionFieldResponse",";t (ns);Collection Response",fNTicks,0,fNTicks);
479  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
480  double driftvelocity=detprop->DriftVelocity(detprop->Efield(),detprop->Temperature())/1000.;
481  int nbinc = TMath::Nint(fCol3DCorrection*(std::abs(pitch))/(driftvelocity*fSampleRate));
482 
483  double integral = 0.;
484  for(int i = 1; i < nbinc; ++i){
485  fColFieldResponse[i] = fColFieldResponse[i-1] + 1.0;
486  integral += fColFieldResponse[i];
487  }
488 
489  for(int i = 0; i < nbinc; ++i){
490  fColFieldResponse[i] *= fColFieldRespAmp/integral;
491  fColFieldResp->Fill(i, fColFieldResponse[i]);
492  }
493 
495 
496  int nbini = TMath::Nint(fInd3DCorrection*(std::abs(pitch))/(driftvelocity*fSampleRate));//KP
497  for(int i = 0; i < nbini; ++i){
498  fIndFieldResponse[i] = fIndFieldRespAmp/(1.*nbini);
499  fIndFieldResponse[nbini+i] = -fIndFieldRespAmp/(1.*nbini);
500 
501  fIndFieldResp->Fill(i, fIndFieldResponse[i]);
502  fIndFieldResp->Fill(nbini+i, fIndFieldResponse[nbini+i]);
503 
504  }
505 
506  fColFieldResp->Write();
507  fIndFieldResp->Write();
508 
509  return;
510  }
double fIndFieldRespAmp
amplitude of response to field
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
double fColFieldRespAmp
amplitude of response to field
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
std::vector< double > fColFieldResponse
response function for the field @ collection plane
double fSampleRate
sampling rate in ns
TH1D * fIndFieldResp
response function for the field @ induction plane
int fNTicks
number of ticks of the clock
T * make(ARGS...args) const
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
int fNFieldBins
number of bins for field response
Namespace collecting geometry-related classes utilities.
TH1D * fColFieldResp
response function for the field @ collection plane
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1124
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139

Member Data Documentation

std::vector<double> detsim::SimWire::fChargeWork
private

Definition at line 125 of file SimWire_module.cc.

double detsim::SimWire::fCol3DCorrection
private

correction factor to account for 3D path of electrons thru wires

Definition at line 111 of file SimWire_module.cc.

TH1D* detsim::SimWire::fColFieldResp
private

response function for the field @ collection plane

Definition at line 130 of file SimWire_module.cc.

double detsim::SimWire::fColFieldRespAmp
private

amplitude of response to field

Definition at line 115 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fColFieldResponse
private

response function for the field @ collection plane

Definition at line 121 of file SimWire_module.cc.

std::vector<TComplex> detsim::SimWire::fColShape
private

response function for the field @ collection plane

Definition at line 123 of file SimWire_module.cc.

TH1D* detsim::SimWire::fColTimeShape
private

convoluted shape for field x electronics @ col plane

Definition at line 132 of file SimWire_module.cc.

raw::Compress_t detsim::SimWire::fCompression
private

compression type to use

Definition at line 102 of file SimWire_module.cc.

std::string detsim::SimWire::fDriftEModuleLabel
private

module making the ionization electrons

Definition at line 100 of file SimWire_module.cc.

TH1D* detsim::SimWire::fElectResp
private

response function for the electronics

Definition at line 131 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fElectResponse
private

response function for the electronics

Definition at line 126 of file SimWire_module.cc.

double detsim::SimWire::fInd3DCorrection
private

correction factor to account for 3D path of electrons thru wires

Definition at line 113 of file SimWire_module.cc.

TH1D* detsim::SimWire::fIndFieldResp
private

response function for the field @ induction plane

Definition at line 129 of file SimWire_module.cc.

double detsim::SimWire::fIndFieldRespAmp
private

amplitude of response to field

Definition at line 116 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fIndFieldResponse
private

response function for the field @ induction plane

Definition at line 122 of file SimWire_module.cc.

std::vector<TComplex> detsim::SimWire::fIndShape
private

response function for the field @ induction plane

Definition at line 124 of file SimWire_module.cc.

TH1D* detsim::SimWire::fIndTimeShape
private

convoluted shape for field x electronics @ ind plane

Definition at line 133 of file SimWire_module.cc.

double detsim::SimWire::fLowCutoff
private

low frequency filter cutoff (kHz)

Definition at line 106 of file SimWire_module.cc.

unsigned int detsim::SimWire::fNElectResp
private

number of entries from response to use

Definition at line 119 of file SimWire_module.cc.

int detsim::SimWire::fNFieldBins
private

number of bins for field response

Definition at line 108 of file SimWire_module.cc.

std::vector< std::vector<float> > detsim::SimWire::fNoise
private

noise on each channel for each time

Definition at line 127 of file SimWire_module.cc.

TH1D* detsim::SimWire::fNoiseDist
private

distribution of noise counts

Definition at line 134 of file SimWire_module.cc.

double detsim::SimWire::fNoiseFact
private

noise scale factor

Definition at line 104 of file SimWire_module.cc.

double detsim::SimWire::fNoiseWidth
private

exponential noise width (kHz)

Definition at line 105 of file SimWire_module.cc.

unsigned int detsim::SimWire::fNSamplesReadout
private

number of ADC readout samples in 1 readout frame

Definition at line 110 of file SimWire_module.cc.

int detsim::SimWire::fNTicks
private

number of ticks of the clock

Definition at line 107 of file SimWire_module.cc.

std::string detsim::SimWire::fResponseFile
private

response file for induction planes

Definition at line 101 of file SimWire_module.cc.

bool detsim::SimWire::fResponseSet
private

flag of whether to set the response functions or not

Definition at line 99 of file SimWire_module.cc.

double detsim::SimWire::fSampleRate
private

sampling rate in ns

Definition at line 109 of file SimWire_module.cc.

std::vector<double> detsim::SimWire::fShapeTimeConst
private

time constants for exponential shaping

Definition at line 117 of file SimWire_module.cc.

int detsim::SimWire::fTriggerOffset
private

(units of ticks) time of expected neutrino event

Definition at line 118 of file SimWire_module.cc.


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