LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
detsim::SimWireT962 Class Reference
Inheritance diagram for detsim::SimWireT962:
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

 SimWireT962 (fhicl::ParameterSet const &pset)
 
virtual ~SimWireT962 ()
 
void produce (art::Event &evt)
 
void beginJob ()
 
void endJob ()
 
void reconfigure (fhicl::ParameterSet const &p)
 
void beginRun (art::Run &run)
 
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...
 
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 78 of file SimWireT962_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::SimWireT962::SimWireT962 ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 144 of file SimWireT962_module.cc.

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

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

Definition at line 161 of file SimWireT962_module.cc.

References clear().

162  {
163  fColFieldResponse.clear();
164  fIndFieldResponse.clear();
165  fColShape.clear();
166  fIndShape.clear();
167  fChargeWork.clear();
168  fElectResponse.clear();
169 
170  for(unsigned int i = 0; i < fNoise.size(); ++i) fNoise[i].clear();
171  fNoise.clear();
172 
173  }
std::vector< double > fColFieldResponse
response function for the field @ collection plane
std::vector< TComplex > fColShape
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
std::vector< double > fElectResponse
response function for the electronics
std::vector< double > fChargeWork
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
vec_iX clear()

Member Function Documentation

void detsim::SimWireT962::beginJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 205 of file SimWireT962_module.cc.

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

206  {
207  // get access to the TFile service
209 
210  fNoiseDist = tfs->make<TH1D>("Noise", ";Noise (ADC);", 1000, -10., 10.);
211 
213  fNTicks = fFFT->FFTSize();
214  fChargeWork.resize(fNTicks, 0.);
215 
217  fNoise.resize(geo->Nchannels());
218  // GenNoise() will further resize each channel's
219  // fNoise vector to fNTicks long.
220 
221  for(unsigned int p = 0; p < geo->Nchannels(); ++p){
222 
223  GenNoise(fNoise[p]);
224  for(int i = 0; i < fNTicks; ++i){
225  fNoiseDist->Fill(fNoise[p][i]);
226  }
227  }// end loop over wires
228 
229 
230 
231 
232 
233  return;
234 
235  }
TH1D * fNoiseDist
distribution of noise counts
std::vector< std::vector< float > > fNoise
noise on each channel for each time
unsigned int Nchannels() const
Returns the number of TPC readout channels in the detector.
int FFTSize() const
Definition: LArFFT.h:69
int fNTicks
number of ticks of the clock
T * make(ARGS...args) const
std::vector< double > fChargeWork
Namespace collecting geometry-related classes utilities.
void GenNoise(std::vector< float > &array)
void detsim::SimWireT962::beginRun ( art::Run run)
virtual

Reimplemented from art::EDProducer.

Definition at line 238 of file SimWireT962_module.cc.

239  {
240  // set field response and electronics response, then convolute them
244 
245  }
void ConvoluteResponseFunctions()
convolute electronics and field response
void SetElectResponse()
response of electronics
void SetFieldResponse()
response of wires to field
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::SimWireT962::ConvoluteResponseFunctions ( )
private

convolute electronics and field response

Definition at line 345 of file SimWireT962_module.cc.

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

346  {
347  std::vector<double> col(fNTicks, 0.);
348  std::vector<double> ind(fNTicks, 0.);
349 
350  unsigned int mxbin = TMath::Min(fNTicks, (int)fNElectResp + fNFieldBins);
351 
352  double sumCol = 0.;
353  double sumInd = 0.;
354 
355  for(unsigned int i = 1; i < mxbin; ++i){
356  sumCol = 0.;
357  sumInd = 0.;
358  for(unsigned int j = 0; j < (unsigned int)fNFieldBins; ++j){
359  unsigned int k = i - j;
360  if(k == 0) break;
361  sumCol += fElectResponse[k]*fColFieldResponse[j];
362  sumInd += fElectResponse[k]*fIndFieldResponse[j];
363  }
364  col[i] = sumCol;
365  ind[i] = sumInd;
366 
367  }//end loop over bins;
368 
369  // pad out the rest of the vector with 0.
370  ind.resize(fNTicks, 0.);
371  col.resize(fNTicks, 0.);
372 
373  // write the shapes out to a file
375  fColTimeShape = tfs->make<TH1D>("ConvolutedCollection",";ticks; Electronics#timesCollection",fNTicks,0,fNTicks);
376  fIndTimeShape = tfs->make<TH1D>("ConvolutedInduction",";ticks; Electronics#timesInduction",fNTicks,0,fNTicks);
377 
378  fIndShape.resize(fNTicks/2+1);
379  fColShape.resize(fNTicks/2+1);
380 
381  // do the FFT of the shapes
382  std::vector<double> delta(fNTicks);
383  delta[0] = 1.0;
384  delta[fNTicks-1]=1.0;
385 
387  fFFT->AlignedSum(ind,delta,false);
388  fFFT->AlignedSum(col,delta,false);
389  fFFT->DoFFT(ind, fIndShape);
390  fFFT->DoFFT(col, fColShape);
391 
392  // check that you did the right thing
393  for(unsigned int i = 0; i < ind.size(); ++i){
394  fColTimeShape->Fill(i, col[i]);
395  fIndTimeShape->Fill(i, ind[i]);
396  }
397 
398  fColTimeShape->Write();
399  fIndTimeShape->Write();
400 
401 
402  return;
403  }
unsigned int fNElectResp
number of entries from response to use
std::vector< double > fColFieldResponse
response function for the field @ collection plane
std::vector< TComplex > fColShape
response function for the field @ collection plane
void DoFFT(std::vector< T > &input, std::vector< TComplex > &output)
Definition: LArFFT.h:97
int fNTicks
number of ticks of the clock
int fNFieldBins
number of bins for field response
std::vector< TComplex > fIndShape
response function for the field @ induction plane
std::vector< double > fElectResponse
response function for the electronics
Int_t col[ntarg]
Definition: Style.C:29
TH1D * fColTimeShape
convoluted shape for field x electronics @ col plane
T * make(ARGS...args) const
void AlignedSum(std::vector< T > &input, std::vector< T > &output, bool add=true)
Definition: LArFFT.h:243
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
TH1D * fIndTimeShape
convoluted shape for field x electronics @ ind plane
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::SimWireT962::endJob ( )
virtual

Reimplemented from art::EDProducer.

Definition at line 248 of file SimWireT962_module.cc.

249  {
250  }
void detsim::SimWireT962::GenNoise ( std::vector< float > &  array)
private

<noise in frequency space

Definition at line 406 of file SimWireT962_module.cc.

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

407  {
409  CLHEP::HepRandomEngine &engine = rng->getEngine();
410  CLHEP::RandFlat flat(engine);
411 
412  noise.clear();
413  noise.resize(fNTicks, 0.);
414  std::vector<TComplex> noiseFrequency(fNTicks/2+1, 0.);
415 
416  double pval = 0.;
417  double lofilter = 0.;
418  double phase = 0.;
419  double rnd[2] = {0.};
420 
421  // width of frequencyBin in kHz
422  double binWidth = 1.0/(fNTicks*fSampleRate*1.0e-6);
423  for(int i=0; i< fNTicks/2+1; ++i){
424  // exponential noise spectrum
425  pval = fNoiseFact*exp(-(double)i*binWidth/fNoiseWidth);
426  // low frequency cutoff
427  lofilter = 1.0/(1.0+exp(-(i-fLowCutoff/binWidth)/0.5));
428  // randomize 10%
429  flat.fireArray(2,rnd,0,1);
430  pval *= lofilter*(0.9+0.2*rnd[0]);
431  // random pahse angle
432  phase = rnd[1]*2.*TMath::Pi();
433 
434  TComplex tc(pval*cos(phase),pval*sin(phase));
435  noiseFrequency[i] += tc;
436  }
437 
438  // inverse FFT MCSignal
440  fFFT->DoInvFFT(noiseFrequency, noise);
441 
442  noiseFrequency.clear();
443 
444  // multiply each noise value by fNTicks as the InvFFT
445  // divides each bin by fNTicks assuming that a forward FFT
446  // has already been done.
447  for(unsigned int i = 0; i < noise.size(); ++i) noise[i] *= 1.*fNTicks;
448 
449  return;
450  }
double fSampleRate
sampling rate in ns
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
int fNTicks
number of ticks of the clock
double fLowCutoff
low frequency filter cutoff (kHz)
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::SimWireT962::produce ( art::Event evt)
virtual

Implements art::EDProducer.

Definition at line 253 of file SimWireT962_module.cc.

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

254  {
255  //std::cout << "in SimWireT962::produce " << std::endl;
256  const detinfo::DetectorClocks* ts = lar::providerFrom<detinfo::DetectorClocksService>();
257 
258  // get the geometry to be able to figure out signal types and chan -> plane mappings
260  unsigned int signalSize = fNTicks/2;
261  // vectors for working
262  std::vector<short> adcvec(signalSize, 0);
263 
264  std::vector<const sim::SimChannel*> chanHandle;
265  evt.getView(fDriftEModuleLabel,chanHandle);
266 
267  // make a vector of const sim::SimChannel* that has same number
268  // of entries as the number of channels in the detector
269  // and set the entries for the channels that have signal on them
270  // using the chanHandle
271  std::vector<const sim::SimChannel*> channels(geo->Nchannels());
272  for(size_t c = 0; c < chanHandle.size(); ++c){
273  channels[chanHandle[c]->Channel()] = chanHandle[c];
274  }
275 
276  // make an unique_ptr of sim::SimDigits that allows ownership of the produced
277  // digits to be transferred to the art::Event after the put statement below
278  std::unique_ptr< std::vector<raw::RawDigit> > digcol(new std::vector<raw::RawDigit>);
279 
280  unsigned int chan = 0;
281  fChargeWork.clear();
282  fChargeWork.resize(fNTicks, 0.);
283 
285 
286  // Add all channels
288  CLHEP::HepRandomEngine &engine = rng->getEngine();
289  CLHEP::RandFlat flat(engine);
290 
292  for(chan = 0; chan < geo->Nchannels(); chan++) {
293 
294  fChargeWork.clear();
295  fChargeWork.resize(fNTicks, 0.);
296 
297  if( channels[chan] ){
298  // get the sim::SimChannel for this channel
299  const sim::SimChannel* sc = channels[chan];
300 
301  // loop over the tdcs and grab the number of electrons for each
302  for(size_t t = 0; t < fChargeWork.size(); ++t){
303  int tdc = ts->TPCTick2TDC(t);
304  if (tdc < 0) continue;
305  if (tdc >= int(fChargeWork.size())) continue;
306  fChargeWork[t] = sc->Charge(tdc);
307  }
308 
309  // Convolve charge with appropriate response function
310  if(geo->SignalType(chan) == geo::kInduction)
312  else fFFT->Convolute(fChargeWork,fColShape);
313  }
314 
315  // noise was already generated for each wire in the event
316  // raw digit vec is already in channel order
317  // pick a new "noise channel" for every channel - this makes sure
318  // the noise has the right coherent characteristics to be on one channel
319  int noisechan = TMath::Nint(flat.fire()*(1.*(fNoise.size()-1)+0.1));
320  for(unsigned int i = 0; i < signalSize; ++i){
321  adcvec[i] = (short)TMath::Nint(fNoise[noisechan][i] + fChargeWork[i]);
322  }
323 
324  // compress the adc vector using the desired compression scheme,
325  // if raw::kNone is selected nothing happens to adcvec
326  // This shrinks adcvec, if fCompression is not kNone.
327 
328 
329  raw::Compress(adcvec, fCompression);
330 
331  raw::RawDigit rd(chan, signalSize, adcvec, fCompression);
332  // Then, resize adcvec back to full length!
333  adcvec.clear();
334  adcvec.resize(signalSize,0.0);
335  // add this digit to the collection
336  digcol->push_back(rd);
337  }// end loop over channels
338 
339  evt.put(std::move(digcol));
340 
341  return;
342  }
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::vector< TComplex > fColShape
response function for the field @ collection plane
intermediate_table::iterator iterator
std::vector< std::vector< float > > fNoise
noise on each channel for each time
raw::Compress_t fCompression
compression type to use
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
int fNTicks
number of ticks of the clock
Signal from induction planes.
Definition: geo_types.h:92
std::string fDriftEModuleLabel
module making the ionization electrons
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
Conversion of times between different formats and references.
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
std::vector< double > fChargeWork
virtual double TPCTick2TDC(double tick) const =0
Converts a TPC time tick into a electronics time tick.
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::SimWireT962::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 176 of file SimWireT962_module.cc.

References fhicl::ParameterSet::get().

177  {
178  fResponseSet = false;
179  cet::search_path sp("FW_SEARCH_PATH");
180  if( !sp.find_file(p.get<std::string>("ResponseFile"), fResponseFile) )
181  throw cet::exception("SimWireT962") << "Unable to find electronics response file in\n"
182  << sp.to_string()
183  << "\n bailing ungracefully.\n";
184 
185  fDriftEModuleLabel= p.get< std::string >("DriftEModuleLabel");
186  fNoiseFact = p.get< double >("NoiseFact");
187  fNoiseWidth = p.get< double >("NoiseWidth");
188  fLowCutoff = p.get< double >("LowCutoff");
189  fNFieldBins = p.get< int >("FieldBins");
190  fCol3DCorrection = p.get< double >("Col3DCorrection");
191  fInd3DCorrection = p.get< double >("Ind3DCorrection");
192  fColFieldRespAmp = p.get< double >("ColFieldRespAmp");
193  fIndFieldRespAmp = p.get< double >("IndFieldRespAmp");
194  fShapeTimeConst = p.get< std::vector<double> >("ShapeTimeConst");
195 
196 
197  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
198  fSampleRate = detprop->SamplingRate();
199  fTriggerOffset = detprop->TriggerOffset();
200 
201  return;
202  }
double fSampleRate
sampling rate in ns
int fTriggerOffset
(units of ticks) time of expected neutrino event
std::string fResponseFile
response file for induction planes
std::vector< double > fShapeTimeConst
time constants for exponential shaping
std::string fDriftEModuleLabel
module making the ionization electrons
int fNFieldBins
number of bins for field response
double fIndFieldRespAmp
amplitude of response to field
bool fResponseSet
flag of whether to set the response functions or not
double fLowCutoff
low frequency filter cutoff (kHz)
double fNoiseWidth
exponential noise width (kHz)
double fColFieldRespAmp
amplitude of response to field
double fNoiseFact
noise scale factor
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void detsim::SimWireT962::SetElectResponse ( )
private

response of electronics

Definition at line 514 of file SimWireT962_module.cc.

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

515  {
516 
518 
519  fElectResponse.resize(fNTicks, 0.);
520  std::vector<double> time(fNTicks,0.);
521 
522  TFile inFile(fResponseFile.c_str(),"READ");
523  if(inFile.IsZombie()){
524  throw cet::exception("SimWireT962") << "Cannot open response file" << fResponseFile << "\n";
525  }
526 
527  TH1D * shape = (TH1D*)inFile.Get("shape");
528  int ctr = 0;
529  double integral = 0.;
530  double holder = 0;
531 
532  while(ctr < fNTicks){
533  holder = shape->GetBinContent(ctr+1);
534  fElectResponse[ctr] = holder;
535  time[ctr] = ctr*fSampleRate;
536  if(holder> 0.){
537  integral += holder;
538  }
539 
540  ++ctr;
541  }//end loop over input
542 
543  for(unsigned int i = 0; i < fElectResponse.size(); ++i)
544  fElectResponse[i] /= integral;
545 
546  fNElectResp = fElectResponse.size();
547 
548  // write the response out to a file
550  fElectResp = tfs->make<TH1D>("ElectronicsResponse",";t (ns);Electronics Response",fNElectResp,0,fNElectResp);
551  for(unsigned int i = 0; i < fNElectResp; ++i){
552  fElectResp->Fill(i, fElectResponse[i]);
553  }
554 
555  fElectResp->Write();
556 
557  return;
558  }
unsigned int fNElectResp
number of entries from response to use
double fSampleRate
sampling rate in ns
std::string fResponseFile
response file for induction planes
int fNTicks
number of ticks of the clock
std::vector< double > fElectResponse
response function for the electronics
T * make(ARGS...args) const
Namespace collecting geometry-related classes utilities.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
TH1D * fElectResp
response function for the electronics
void detsim::SimWireT962::SetFieldResponse ( )
private

response of wires to field

in cm

number of bins //KP

now the induction plane

Definition at line 453 of file SimWireT962_module.cc.

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

454  {
455 
457 
458  double xyz1[3] = {0.};
459  double xyz2[3] = {0.};
460  double xyzl[3] = {0.};
461  // should always have at least 2 planes
462  geo->Plane(0).LocalToWorld(xyzl, xyz1);
463  geo->Plane(1).LocalToWorld(xyzl, xyz2);
464 
465  // this assumes all planes are equidistant from each other,
466  // probably not a bad assumption
467  double pitch = xyz2[0] - xyz1[0];
468 
469  fColFieldResponse.resize(fNFieldBins, 0.);
470  fIndFieldResponse.resize(fNFieldBins, 0.);
471 
472  // set the response for the collection plane first
473  // the first entry is 0
474 
475  // write out the response functions to the file
476  // get access to the TFile service
478  fIndFieldResp = tfs->make<TH1D>("InductionFieldResponse",";t (ns);Induction Response",fNTicks,0,fNTicks);
479  fColFieldResp = tfs->make<TH1D>("CollectionFieldResponse",";t (ns);Collection Response",fNTicks,0,fNTicks);
480  const detinfo::DetectorProperties* detprop = lar::providerFrom<detinfo::DetectorPropertiesService>();
481  double driftvelocity=detprop->DriftVelocity(detprop->Efield(),detprop->Temperature())/1000.;
482  int nbinc = TMath::Nint(fCol3DCorrection*(std::abs(pitch))/(driftvelocity*fSampleRate));
483 
484  double integral = 0.;
485  for(int i = 1; i < nbinc; ++i){
486  fColFieldResponse[i] = fColFieldResponse[i-1] + 1.0;
487  integral += fColFieldResponse[i];
488  }
489 
490  for(int i = 0; i < nbinc; ++i){
491  fColFieldResponse[i] *= fColFieldRespAmp/integral;
492  fColFieldResp->Fill(i, fColFieldResponse[i]);
493  }
494 
496 
497  int nbini = TMath::Nint(fInd3DCorrection*(std::abs(pitch))/(driftvelocity*fSampleRate));//KP
498  for(int i = 0; i < nbini; ++i){
499  fIndFieldResponse[i] = fIndFieldRespAmp/(1.*nbini);
500  fIndFieldResponse[nbini+i] = -fIndFieldRespAmp/(1.*nbini);
501 
502  fIndFieldResp->Fill(i, fIndFieldResponse[i]);
503  fIndFieldResp->Fill(nbini+i, fIndFieldResponse[nbini+i]);
504 
505  }
506 
507  fColFieldResp->Write();
508  fIndFieldResp->Write();
509 
510  return;
511  }
double fSampleRate
sampling rate in ns
TH1D * fIndFieldResp
response function for the field @ induction plane
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
std::vector< double > fColFieldResponse
response function for the field @ collection plane
int fNTicks
number of ticks of the clock
int fNFieldBins
number of bins for field response
double fIndFieldRespAmp
amplitude of response to field
T * make(ARGS...args) const
TH1D * fColFieldResp
response function for the field @ collection plane
virtual double DriftVelocity(double efield=0., double temperature=0.) const =0
std::vector< double > fIndFieldResponse
response function for the field @ induction plane
Namespace collecting geometry-related classes utilities.
void LocalToWorld(const double *plane, double *world) const
Transform point from local plane frame to world frame.
Definition: PlaneGeo.h:1124
double fColFieldRespAmp
amplitude of response to field
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::SimWireT962::fChargeWork
private

Definition at line 126 of file SimWireT962_module.cc.

double detsim::SimWireT962::fCol3DCorrection
private

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

Definition at line 112 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fColFieldResp
private

response function for the field @ collection plane

Definition at line 131 of file SimWireT962_module.cc.

double detsim::SimWireT962::fColFieldRespAmp
private

amplitude of response to field

Definition at line 116 of file SimWireT962_module.cc.

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

response function for the field @ collection plane

Definition at line 122 of file SimWireT962_module.cc.

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

response function for the field @ collection plane

Definition at line 124 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fColTimeShape
private

convoluted shape for field x electronics @ col plane

Definition at line 133 of file SimWireT962_module.cc.

raw::Compress_t detsim::SimWireT962::fCompression
private

compression type to use

Definition at line 104 of file SimWireT962_module.cc.

std::string detsim::SimWireT962::fDriftEModuleLabel
private

module making the ionization electrons

Definition at line 102 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fElectResp
private

response function for the electronics

Definition at line 132 of file SimWireT962_module.cc.

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

response function for the electronics

Definition at line 127 of file SimWireT962_module.cc.

double detsim::SimWireT962::fInd3DCorrection
private

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

Definition at line 114 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fIndFieldResp
private

response function for the field @ induction plane

Definition at line 130 of file SimWireT962_module.cc.

double detsim::SimWireT962::fIndFieldRespAmp
private

amplitude of response to field

Definition at line 117 of file SimWireT962_module.cc.

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

response function for the field @ induction plane

Definition at line 123 of file SimWireT962_module.cc.

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

response function for the field @ induction plane

Definition at line 125 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fIndTimeShape
private

convoluted shape for field x electronics @ ind plane

Definition at line 134 of file SimWireT962_module.cc.

double detsim::SimWireT962::fLowCutoff
private

low frequency filter cutoff (kHz)

Definition at line 108 of file SimWireT962_module.cc.

unsigned int detsim::SimWireT962::fNElectResp
private

number of entries from response to use

Definition at line 120 of file SimWireT962_module.cc.

int detsim::SimWireT962::fNFieldBins
private

number of bins for field response

Definition at line 110 of file SimWireT962_module.cc.

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

noise on each channel for each time

Definition at line 128 of file SimWireT962_module.cc.

TH1D* detsim::SimWireT962::fNoiseDist
private

distribution of noise counts

Definition at line 135 of file SimWireT962_module.cc.

double detsim::SimWireT962::fNoiseFact
private

noise scale factor

Definition at line 106 of file SimWireT962_module.cc.

double detsim::SimWireT962::fNoiseWidth
private

exponential noise width (kHz)

Definition at line 107 of file SimWireT962_module.cc.

int detsim::SimWireT962::fNTicks
private

number of ticks of the clock

Definition at line 109 of file SimWireT962_module.cc.

std::string detsim::SimWireT962::fResponseFile
private

response file for induction planes

Definition at line 103 of file SimWireT962_module.cc.

bool detsim::SimWireT962::fResponseSet
private

flag of whether to set the response functions or not

Definition at line 101 of file SimWireT962_module.cc.

double detsim::SimWireT962::fSampleRate
private

sampling rate in ns

Definition at line 111 of file SimWireT962_module.cc.

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

time constants for exponential shaping

Definition at line 118 of file SimWireT962_module.cc.

int detsim::SimWireT962::fTriggerOffset
private

(units of ticks) time of expected neutrino event

Definition at line 119 of file SimWireT962_module.cc.


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